/* Trang thư viện "Nhìn Xa Trông Rộng": nền kem như phần giới thiệu trang chủ, chữ Comfortaa */
:root { color-scheme: light; --ink: #103b79; --ink-soft: #2d4a73; --paper: #fbf7ea; --line: #e6dcc3; }
* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 16px/1.6 "Segoe UI", Arial, sans-serif; }
h1, h2, .lib-chip, .lib-tab, .lib-tile-title, .lc-ask, .lib-eyebrow, .lib-back { font-family: "Comfortaa", "Segoe UI", Arial, sans-serif; font-weight: 700; }
button { font: inherit; color: inherit; cursor: pointer; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 3px solid #b67744; outline-offset: 3px; }

.lib-top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px max(16px, calc((100% - 1160px) / 2)); background: #174e98; color: #fff; }
.lib-back { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 12px 0 6px; border-radius: 22px; color: #fff; text-decoration: none; font-size: 15px; }
.lib-back:hover { background: #ffffff1f; }
.lib-back svg { width: 24px; height: 24px; }
.lib-progress { margin: 0; font-size: 14px; color: #ffe59b; font-weight: 700; }

.lib-main { max-width: 1160px; margin: 0 auto; padding: 28px 16px 64px; }
.lib-hero { display: flex; align-items: center; gap: clamp(16px, 4vw, 48px); margin-bottom: 24px; }
.lib-hero-art { flex: 0 0 auto; width: clamp(150px, 26vw, 300px); height: auto; filter: drop-shadow(0 14px 18px #4c453433); }
.lib-eyebrow { margin: 0 0 6px; font-size: 15px; color: #4a6a99; }
.lib-hero h1 { margin: 0 0 10px; font-size: clamp(30px, 4.4vw, 48px); line-height: 1.1; }
.lib-lead { margin: 0; max-width: 32em; color: var(--ink-soft); font-size: 17px; }

.lib-controls { display: grid; gap: 12px; margin-bottom: 22px; }
.lib-grades, .lib-tabs { display: flex; flex-wrap: wrap; gap: 8px; }
.lib-chip, .lib-tab { min-height: 44px; padding: 8px 18px; border: 1.5px solid #c9bd9d; border-radius: 999px; background: transparent; font-size: 15px; transition: background-color .15s; }
.lib-chip:hover, .lib-tab:hover { background: #f0e8d0; }
.lib-chip[aria-pressed="true"] { background: #1b5fc4; border-color: #1b5fc4; color: #fff; }
.lib-tab[aria-pressed="true"] { background: #103b79; border-color: #103b79; color: #fff; }
.lib-chip.is-soon:not([aria-pressed="true"]) { opacity: .55; }

.lib-empty { margin: 8px 0 24px; padding: 18px 20px; border-radius: 16px; background: #f3ecd6; color: var(--ink-soft); }

.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 18px; }
.lib-tile { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; min-height: 190px; padding: 18px 18px 20px; border: 0; border-radius: 22px; background: #fffdf6; text-align: left; box-shadow: 2px 6px 0 var(--line), 3px 10px 16px #5e4a3018; transition: transform .18s, box-shadow .18s; }
.lib-tile:hover { transform: translateY(-4px) rotate(-.5deg); box-shadow: 2px 10px 0 var(--line), 3px 14px 20px #5e4a3022; }
.lib-tile-art { display: grid; place-items: center; width: 54px; height: 54px; border-radius: 16px; background: var(--gc); color: #fff; }
.lib-tile-art svg { width: 30px; height: 30px; stroke-width: 1.9; }
.lib-tile-group { margin-top: 4px; font-size: 13px; font-weight: 700; color: var(--gc); filter: brightness(.78); }
.lib-tile-title { font-size: 19px; line-height: 1.3; color: var(--ink); }
.lib-tile-read { margin-top: auto; padding: 2px 10px; border-radius: 999px; background: #dff0d8; color: #3b6a34; font-size: 12.5px; font-weight: 700; }

/* Thẻ chi tiết */
.lib-card { width: min(620px, calc(100vw - 24px)); max-height: 90dvh; margin: auto; padding: 22px 24px 24px; border: 0; border-top: 8px solid var(--gc, #5b8fc9); border-radius: 26px; background: #fffdf6; color: var(--ink); box-shadow: 0 24px 70px #0a2a5c66; overflow-y: auto; }
.lib-card::backdrop { background: #0a2a5c66; }
.lc-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.lc-group { margin: 0; font-size: 14px; font-weight: 700; color: var(--gc); filter: brightness(.78); }
.lc-close { width: 40px; height: 40px; padding: 8px; border: 0; border-radius: 50%; background: #efe7d0; color: var(--ink); }
.lc-close:hover { background: #e6dcc3; }
.lc-close svg { width: 100%; height: 100%; }
.lib-card h2 { margin: 6px 0 12px; font-size: clamp(22px, 3.4vw, 28px); line-height: 1.25; }
.lc-body { margin: 0 0 14px; font-size: 17px; line-height: 1.75; color: var(--ink-soft); }
.lc-fact { margin: 0 0 18px; padding: 12px 14px; border-radius: 14px; background: #f6ecc8; color: #5b4a1a; font-size: 16px; }
.lc-fact strong { font-family: "Comfortaa", "Segoe UI", sans-serif; }
.lc-q { margin: 0 0 10px; font-weight: 700; font-size: 17px; }
.lc-options { display: grid; gap: 8px; }
.lc-opt { padding: 12px 14px; border: 1.5px solid #c9bd9d; border-radius: 14px; background: transparent; text-align: left; font-size: 16px; transition: background-color .15s; }
.lc-opt:hover:not(:disabled) { background: #f0e8d0; }
.lc-opt:disabled { cursor: default; }
.lc-opt.is-right { background: #dff0d8; border-color: #6aa86a; }
.lc-opt.is-wrong { background: #f7dcd5; border-color: #cc7a68; }
.lc-result { margin: 10px 0 0; padding: 10px 14px; border-radius: 12px; font-size: 16px; }
.lc-result.is-ok { background: #e7f4e1; color: #2f5d2a; }
.lc-result.is-no { background: #fbe7e1; color: #7c3a2c; }
.lc-actions { margin-top: 18px; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; }
.lc-next, .lc-ask-teacher { min-height: 48px; padding: 10px 22px; border-radius: 24px; font: 700 16px "Comfortaa", "Segoe UI", sans-serif; }
.lc-next { border: 0; background: #1b5fc4; color: #fff; box-shadow: 0 4px 0 #134a9c; }
.lc-next:hover { transform: translateY(-1px); }
.lc-ask-teacher { border: 1.5px solid #1b5fc4; background: transparent; color: #1b5fc4; }
.lc-ask-teacher:hover { background: #e8f0fb; }

@media (max-width: 640px) {
  .lib-hero { flex-direction: column; align-items: flex-start; }
  .lib-hero-art { width: 150px; }
  .lib-grid { grid-template-columns: 1fr; }
  .lib-tile { min-height: 0; }
}
@media (prefers-reduced-motion: reduce) { .lib-tile, .lib-tile:hover { transition: none; transform: none; } }

/* Đồng hồ đếm ngược cho câu hỏi nhỏ */
.lib-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; }
.lib-timer-toggle { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 8px 16px; border: 1.5px solid #c9bd9d; border-radius: 999px; background: transparent; font: 700 15px "Comfortaa", "Segoe UI", sans-serif; }
.lib-timer-toggle svg { width: 22px; height: 22px; }
.lib-timer-toggle[aria-pressed="true"] { background: #f6ecc8; border-color: #d9b24a; color: #5b4a1a; }
.lib-timer-toggle:hover { background: #f0e8d0; }
.lc-start { width: 100%; min-height: 52px; padding: 12px 18px; border: 2px dashed #b9ab84; border-radius: 16px; background: transparent; font: 700 17px "Comfortaa", "Segoe UI", sans-serif; color: var(--ink); }
.lc-start:hover { background: #f0e8d0; }
.lc-timer { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.lc-bar { flex: 1; height: 12px; border-radius: 999px; background: #eadfc4; overflow: hidden; }
.lc-bar span { display: block; height: 100%; width: 100%; border-radius: 999px; background: #6aa86a; transition: width .1s linear, background-color .2s; }
.lc-sec { display: grid; place-items: center; flex: 0 0 auto; width: 58px; height: 58px; border-radius: 50%; background: #e3f1dc; border: 3px solid #6aa86a; font: 700 28px/1 "Comfortaa", "Segoe UI", sans-serif; color: #2f5d2a; font-variant-numeric: tabular-nums; }
.lc-sec.is-jump { animation: lc-jump .35s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes lc-jump { 0% { transform: scale(1.5); } 100% { transform: scale(1); } }
.lc-timer.is-warn .lc-sec { background: #fbe3da; border-color: #d97a4a; color: #b3422f; }
.lc-timer.is-warn .lc-sec.is-jump { animation-name: lc-jump-warn; }
@keyframes lc-jump-warn { 0% { transform: scale(1.7) rotate(-8deg); } 60% { transform: scale(.95) rotate(4deg); } 100% { transform: scale(1) rotate(0); } }
.lc-timer.is-warn .lc-bar span { background: #d97a4a; }
.lc-result.is-time { background: #fcefd2; color: #6b4b12; }
@media (prefers-reduced-motion: reduce) { .lc-bar span { transition: none; } .lc-sec.is-jump { animation: none !important; } }

/* Kiến thức đầu vào: bài đọc ngắn trước, câu hỏi nhỏ sau */
.lib-tile-sum { margin-top: 2px; font-size: 14px; line-height: 1.5; color: var(--ink-soft); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.lc-summary { margin: 0 0 14px; padding: 12px 14px; border-left: 5px solid var(--gc, #5b8fc9); border-radius: 0 12px 12px 0; background: #f4efdc; font-size: 17px; font-weight: 700; line-height: 1.6; color: var(--ink); }
.lc-parts { display: grid; gap: 14px; margin-bottom: 14px; }
.lc-part h3 { margin: 0 0 4px; font: 700 17px "Comfortaa", "Segoe UI", sans-serif; color: var(--ink); }
.lc-part p { margin: 0; font-size: 17px; line-height: 1.75; color: var(--ink-soft); }
.lc-keys { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; }
.lc-key { padding: 4px 12px; border-radius: 999px; background: #e8efe0; color: #3b5a34; font-size: 14px; font-weight: 700; }
.lc-try { margin: 0 0 18px; padding: 12px 14px; border-radius: 14px; background: #e4eef9; color: #1f3f69; font-size: 16px; line-height: 1.65; }
.lc-quiz { padding-top: 14px; border-top: 2px dashed #d8ccaa; }
.lc-quiz-title { margin: 0 0 10px; font: 700 16px "Comfortaa", "Segoe UI", sans-serif; color: var(--ink); }
.lc-quiz-title span { font-weight: 400; font-size: 14px; color: #7a6f55; font-family: "Segoe UI", sans-serif; }

/* Công cụ nghe, hình minh họa và dấu ? ở cuối bài */
.lc-tools { display: flex; margin: 0 0 12px; }
.lc-listen { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 8px 16px; border: 1.5px solid #1b5fc4; border-radius: 999px; background: transparent; color: #1b5fc4; font: 700 15px "Comfortaa", "Segoe UI", sans-serif; }
.lc-listen svg { width: 22px; height: 22px; }
.lc-listen:hover, .lc-listen[aria-pressed="true"] { background: #e8f0fb; }
.lc-media { display: grid; gap: 14px; margin: 0 0 16px; }
.lc-fig { margin: 0; }
.lc-fig-art svg, .lc-fig img, .lc-fig video { display: block; width: 100%; height: auto; border-radius: 16px; }
.lc-fig audio { width: 100%; }
.lc-fig figcaption { margin-top: 6px; font-size: 14px; color: #6b6147; text-align: center; }
.lc-qrow { display: flex; align-items: center; gap: 14px; }
.lc-qmark { flex: 0 0 auto; display: grid; place-items: center; width: 68px; height: 68px; padding: 0; border: 0; border-radius: 50%; background: #f3c14b; color: #5b3a05; font: 700 40px/1 "Comfortaa", "Segoe UI", sans-serif; box-shadow: 0 5px 0 #c99a2b, 2px 9px 14px #5e4a3030; animation: lc-pulse 2.2s ease-in-out infinite; }
.lc-qmark:hover { transform: translateY(-2px) rotate(-4deg); }
.lc-qhint { margin: 0; font-size: 16px; line-height: 1.5; color: var(--ink-soft); }
@keyframes lc-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.07); } }
@media (prefers-reduced-motion: reduce) { .lc-qmark { animation: none; } }
/* Hình minh họa SVG: không thừa hưởng nét viền của biểu tượng chung */
.lc-fig-art svg { fill: currentColor; stroke: none; stroke-width: 1; stroke-linecap: butt; stroke-linejoin: miter; }

/* Bỏ hết khung: thẻ, ô biểu tượng, nhãn, nút lọc chỉ còn chữ và hình */
.lib-tile { background: transparent; box-shadow: none; border-radius: 16px; padding: 14px 14px 16px; min-height: 0; transition: background-color .15s; }
.lib-tile:hover { transform: none; background: #f3ecd6; box-shadow: none; }
.lib-tile-art { width: auto; height: auto; border-radius: 0; background: none; color: var(--gc); place-items: start; }
.lib-tile-art svg { width: 46px; height: 46px; stroke-width: 1.7; }
.lib-tile-read { margin-top: 6px; padding: 0; border-radius: 0; background: none; color: #3b6a34; }
.lib-tile-read::before { content: "✓ "; }
.lib-chip, .lib-tab, .lib-timer-toggle { border: 0; }
.lib-chip[aria-pressed="true"], .lib-tab[aria-pressed="true"] { border: 0; }
.lib-timer-toggle[aria-pressed="true"] { border: 0; }
.lib-key, .lc-key { border: 0; }

/* Mỗi môn một khối nền nhẹ: một biểu tượng đại diện, bên dưới là các cụm câu hỏi */
.lib-grid { display: block; }
.lib-sec { margin: 0 0 22px; padding: 22px 22px 14px; border-radius: 26px; background: var(--tint); }
.lib-sec-head { display: flex; align-items: center; gap: 16px; margin-bottom: 10px; }
.lib-sec-art { display: grid; place-items: center; width: 64px; height: 64px; color: var(--gc); }
.lib-sec-art svg { width: 60px; height: 60px; stroke-width: 1.6; }
.lib-sec-art { flex: 0 0 64px; }
.lib-sec-art img { display: block; width: 60px; height: 60px; object-fit: contain; }
.lib-sec-names h2 { margin: 0; font-size: clamp(22px, 3vw, 28px); line-height: 1.2; color: var(--ink); }
.lib-sec-names p { margin: 2px 0 0; font-size: 14px; color: #5f6f86; }
.lib-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 4px 12px; }
.lib-sec .lib-tile { background: transparent; padding: 12px 12px 14px; }
.lib-sec .lib-tile:hover { background: #ffffffa6; }
.lib-sec .lib-tile-read { margin-top: 4px; }
@media (max-width: 640px) { .lib-cards { grid-template-columns: 1fr; } .lib-sec { padding: 16px 14px 8px; border-radius: 20px; } }
