/* =========================================================
   THƯ VIỆN SỐ – Hệ thống thiết kế
   Tông màu tươi sáng: xanh cyan → xanh dương → tím (chuyển đổi số)
   ========================================================= */
:root {
  color-scheme: light;
  --bg: #f3f7ff;
  --surface: #ffffff;
  --surface-2: #f7faff;
  --surface-3: #edf3fd;
  --border: #e2e9f5;
  --border-strong: #cfd9ea;
  --text: #0f1b33;
  --text-2: #475773;
  --muted: #7888a3;
  --brand: #1f6bff;
  --brand-600: #1757d6;
  --brand-50: #eaf2ff;
  --brand-100: #d6e5ff;
  --violet: #7c4dff;
  --cyan: #06b6d4;
  --teal: #14b8a6;
  --green: #10b981;
  --amber: #f59e0b;
  --pink: #ec4899;
  --red: #ef4444;
  --grad: linear-gradient(135deg, #06b6d4 0%, #1f6bff 48%, #7c4dff 100%);
  --grad-soft: linear-gradient(135deg, #e0f7fb 0%, #e6efff 50%, #f0e9ff 100%);
  --grad-warm: linear-gradient(135deg, #ffb547 0%, #ff6b8b 100%);
  --shadow-sm: 0 1px 2px rgba(15, 27, 51, .06), 0 1px 3px rgba(15, 27, 51, .05);
  --shadow: 0 6px 24px -8px rgba(31, 84, 180, .18), 0 2px 6px rgba(15, 27, 51, .05);
  --shadow-lg: 0 24px 60px -18px rgba(31, 84, 180, .35);
  --radius: 16px;
  --radius-sm: 10px;
  --header-h: 68px;
  --font: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  /* chart tokens (bảng màu đã kiểm định cho người mù màu) */
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100;
  --series-5: #e87ba4; --series-6: #008300; --series-7: #4a3aa7; --series-8: #e34948;
  --grid: #e6eaf2; --axis: #c3cad8;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0b1222; --surface: #121b2f; --surface-2: #16213a; --surface-3: #1c2945; --border: #25324f; --border-strong: #33446a;
    --text: #eef3ff; --text-2: #b6c2da; --muted: #8392ad; --brand-50: #172a52; --brand-100: #1e3668;
    --grad-soft: linear-gradient(135deg, #0f2a3a 0%, #13244a 50%, #221a45 100%);
    --shadow: 0 8px 28px -10px rgba(0, 0, 0, .6); --shadow-lg: 0 24px 60px -18px rgba(0, 0, 0, .7);
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500; --series-5: #d55181; --series-6: #008300; --series-7: #9085e9; --series-8: #e66767;
    --grid: #25324f; --axis: #33446a;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b1222; --surface: #121b2f; --surface-2: #16213a; --surface-3: #1c2945; --border: #25324f; --border-strong: #33446a;
  --text: #eef3ff; --text-2: #b6c2da; --muted: #8392ad; --brand-50: #172a52; --brand-100: #1e3668;
  --grad-soft: linear-gradient(135deg, #0f2a3a 0%, #13244a 50%, #221a45 100%);
  --shadow: 0 8px 28px -10px rgba(0, 0, 0, .6); --shadow-lg: 0 24px 60px -18px rgba(0, 0, 0, .7);
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500; --series-5: #d55181; --series-6: #008300; --series-7: #9085e9; --series-8: #e66767;
  --grid: #25324f; --axis: #33446a;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.6; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; overflow-x: hidden; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: 2rem; font-weight: 800; } h2 { font-size: 1.45rem; font-weight: 700; } h3 { font-size: 1.1rem; font-weight: 700; }
p { margin: 0 0 1em; }
img { max-width: 100%; }
.hidden { display: none !important; }
.ic { flex: none; vertical-align: middle; }
mark { background: #fff1a8; color: inherit; padding: 0 2px; border-radius: 3px; }
:root[data-theme="dark"] mark { background: #6b5b12; }
::selection { background: var(--brand-100); }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 55%, transparent); outline-offset: 2px; border-radius: 6px; }
.container { width: 100%; max-width: 1280px; margin: 0 auto; padding: 0 24px; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .nowrap { white-space: nowrap; }
.grad-text { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- Buttons & inputs ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px; border-radius: 12px; border: 1px solid transparent; font: inherit; font-weight: 600; font-size: .92rem; cursor: pointer; transition: .18s; white-space: nowrap; color: var(--text); background: var(--surface); text-decoration: none !important; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--grad); color: #fff; box-shadow: 0 6px 16px -6px rgba(31, 107, 255, .55); background-size: 140% 140%; }
.btn-primary:hover:not(:disabled) { background-position: 100% 0; transform: translateY(-1px); box-shadow: 0 10px 22px -8px rgba(31, 107, 255, .6); }
.btn-ghost { background: var(--surface); border-color: var(--border); }
.btn-ghost:hover:not(:disabled) { border-color: var(--brand); color: var(--brand); background: var(--brand-50); }
.btn-soft { background: var(--brand-50); color: var(--brand); }
.btn-soft:hover:not(:disabled) { background: var(--brand-100); }
.btn-green { background: var(--green); color: #fff; } .btn-green:hover:not(:disabled) { filter: brightness(1.05); transform: translateY(-1px); }
.btn-amber { background: var(--amber); color: #fff; }
.btn-danger { background: var(--red); color: #fff; } .btn-danger:hover:not(:disabled) { filter: brightness(1.05); }
.btn-sm { height: 32px; padding: 0 11px; font-size: .84rem; border-radius: 9px; gap: 6px; }
.btn-lg { height: 50px; padding: 0 24px; font-size: 1rem; border-radius: 14px; }
.btn-block { width: 100%; }
.icon-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 11px; border: 1px solid transparent; background: transparent; color: var(--text-2); cursor: pointer; transition: .15s; }
.icon-btn:hover { background: var(--surface-3); color: var(--brand); }
.icon-btn.active { background: var(--brand-50); color: var(--brand); border-color: var(--brand-100); }
.btn-group { display: inline-flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.seg { display: inline-flex; background: var(--surface-3); padding: 3px; border-radius: 11px; gap: 2px; }
.seg button { border: 0; background: transparent; height: 32px; padding: 0 10px; border-radius: 8px; color: var(--text-2); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; font: inherit; font-size: .85rem; font-weight: 600; }
.seg button.active { background: var(--surface); color: var(--brand); box-shadow: var(--shadow-sm); }
input[type=text], input[type=search], input[type=email], input[type=password], input[type=number], input[type=date], input[type=tel], input:not([type]), select, textarea {
  width: 100%; font: inherit; font-size: .93rem; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: 11px; padding: 9px 12px; transition: .15s; min-height: 40px; }
textarea { resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 16%, transparent); }
input[type=checkbox], input[type=radio] { accent-color: var(--brand); width: 17px; height: 17px; margin: 0; }
input[type=range] { accent-color: var(--brand); width: 100%; }
label { font-weight: 600; font-size: .87rem; color: var(--text-2); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid .field:has(textarea), .form-grid .field:has(.checks), .form-grid .field:has(.img-field) { grid-column: 1 / -1; }
.hint { font-size: .8rem; color: var(--muted); font-weight: 400; }
.req { color: var(--red); }
.check { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; color: var(--text); cursor: pointer; font-size: .9rem; }
.checks { display: flex; flex-wrap: wrap; gap: 8px 18px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 11px; background: var(--surface-2); max-height: 220px; overflow: auto; }
.img-field { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.img-field img { width: 72px; height: 72px; object-fit: cover; border-radius: 12px; border: 1px solid var(--border); }
.html-preview { margin-top: 6px; padding: 10px 12px; border: 1px dashed var(--border-strong); border-radius: 10px; background: var(--surface-2); font-weight: 400; font-size: .9rem; }
.input-icon { position: relative; }
.input-icon .ic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.input-icon input { padding-left: 38px; }

/* ---------- Chips, badges ---------- */
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; background: var(--surface-3); color: var(--text-2); font-size: .78rem; font-weight: 600; white-space: nowrap; border: 0; font-family: inherit; }
a.chip:hover, button.chip:hover { background: var(--brand-50); color: var(--brand); text-decoration: none; cursor: pointer; }
.chip-blue { background: #e3eeff; color: #1d4fbf; } .chip-amber { background: #fff3d6; color: #a15c00; } .chip-pink { background: #ffe4f1; color: #b41d6b; } .chip-green { background: #dcfaec; color: #047a55; } .chip-violet { background: #efe7ff; color: #5b2fd0; }
:root[data-theme="dark"] .chip-blue { background: #1b3263; color: #a9c6ff; } :root[data-theme="dark"] .chip-amber { background: #4a3408; color: #ffd27a; } :root[data-theme="dark"] .chip-pink { background: #4d1631; color: #ffadd3; } :root[data-theme="dark"] .chip-green { background: #0d3d2c; color: #7ff0c1; } :root[data-theme="dark"] .chip-violet { background: #2f2159; color: #cbb6ff; }
.chip-removable button { border: 0; background: transparent; color: inherit; cursor: pointer; padding: 0; display: inline-grid; }
.type-badge { display: inline-flex; align-items: center; gap: 5px; font-size: .74rem; font-weight: 700; padding: 3px 9px; border-radius: 8px; color: #fff; background: var(--brand); letter-spacing: .01em; }
.t-sach { background: #1f6bff; } .t-giao-trinh { background: #0ea371; } .t-luan-van { background: #9b43e6; } .t-luan-an { background: #6d28d9; } .t-bai-bao { background: #e36a00; } .t-bao-cao-nghien-cuu { background: #0d9488; } .t-tai-lieu-so-hoa { background: #a15c00; } .t-hinh-anh { background: #db2777; } .t-video { background: #dc2626; } .t-am-thanh { background: #0891b2; }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; font-weight: 700; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.s-green { background: #dcfaec; color: #047a55; } .s-amber { background: #fff3d6; color: #a15c00; } .s-red { background: #ffe4e4; color: #c01d1d; } .s-gray { background: var(--surface-3); color: var(--text-2); } .s-blue { background: #e3eeff; color: #1d4fbf; }
:root[data-theme="dark"] .s-green { background: #0d3d2c; color: #7ff0c1; } :root[data-theme="dark"] .s-amber { background: #4a3408; color: #ffd27a; } :root[data-theme="dark"] .s-red { background: #4d1717; color: #ffabab; } :root[data-theme="dark"] .s-blue { background: #1b3263; color: #a9c6ff; }
.avatar { display: inline-grid; place-items: center; border-radius: 50%; color: #fff; font-weight: 700; flex: none; object-fit: cover; }

/* ---------- Cards & panels ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.panel-head h2, .panel-head h3 { margin: 0; display: flex; align-items: center; gap: 10px; }
.panel-head .ic-bubble { width: 34px; height: 34px; }
.ic-bubble { display: inline-grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; background: var(--brand-50); color: var(--brand); flex: none; }
.grid { display: grid; gap: 20px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stack { display: flex; flex-direction: column; gap: 20px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.divider { height: 1px; background: var(--border); margin: 16px 0; }

/* ---------- Header (public) ---------- */
.topbar { position: sticky; top: 0; z-index: 50; height: var(--header-h); background: color-mix(in srgb, var(--surface) 82%, transparent); backdrop-filter: saturate(1.6) blur(14px); border-bottom: 1px solid var(--border); }
.topbar .container { display: flex; align-items: center; gap: 20px; height: 100%; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.12rem; color: var(--text); text-decoration: none !important; white-space: nowrap; }
.logo-mark { width: 40px; height: 40px; border-radius: 12px; background: var(--grad); display: grid; place-items: center; color: #fff; box-shadow: 0 6px 16px -6px rgba(31, 107, 255, .6); }
.logo small { display: block; font-size: .7rem; font-weight: 500; color: var(--muted); letter-spacing: .02em; }
.mainnav { display: flex; gap: 2px; }
.mainnav a { display: inline-flex; align-items: center; gap: 7px; padding: 8px 12px; border-radius: 10px; color: var(--text-2); font-weight: 600; font-size: .9rem; text-decoration: none; white-space: nowrap; }
.mainnav a:hover { background: var(--surface-3); color: var(--text); }
.mainnav a.active { color: var(--brand); background: var(--brand-50); }
.top-actions { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.top-search { position: relative; width: 230px; }
.top-search input { height: 38px; min-height: 38px; padding-left: 36px; border-radius: 11px; background: var(--surface-2); }
.top-search .ic { position: absolute; left: 11px; top: 11px; color: var(--muted); }
.user-btn { display: flex; align-items: center; gap: 8px; padding: 4px 10px 4px 4px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font: inherit; font-weight: 600; font-size: .88rem; color: var(--text); }
.user-btn:hover { border-color: var(--brand); }
.dropdown { position: relative; }
.menu { position: absolute; right: 0; top: calc(100% + 8px); min-width: 230px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 6px; z-index: 60; display: none; }
.dropdown.open .menu { display: block; animation: pop .15s ease; }
.menu a, .menu button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; border-radius: 9px; color: var(--text); font: inherit; font-size: .9rem; background: none; border: 0; cursor: pointer; text-align: left; text-decoration: none; }
.menu a:hover, .menu button:hover { background: var(--surface-3); color: var(--brand); }
.menu .menu-head { padding: 10px 12px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.menu .menu-head b { display: block; } .menu .menu-head span { font-size: .8rem; color: var(--muted); }
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } }
.burger { display: none; }
.bottom-nav { display: none; }

/* ---------- Footer ---------- */
.footer { margin-top: 64px; background: var(--surface); border-top: 1px solid var(--border); padding: 40px 0 24px; color: var(--text-2); font-size: .9rem; }
.footer-grid { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr; gap: 32px; }
.footer h4 { color: var(--text); font-size: .95rem; margin-bottom: 12px; }
.footer a { color: var(--text-2); display: block; padding: 3px 0; }
.footer a:hover { color: var(--brand); }
.footer-bottom { margin-top: 28px; padding-top: 18px; border-top: 1px solid var(--border); display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: .82rem; color: var(--muted); }
.app-badges { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.app-badges span { display: inline-flex; gap: 6px; align-items: center; padding: 6px 10px; border: 1px solid var(--border); border-radius: 10px; font-size: .8rem; font-weight: 600; color: var(--text); }

/* ---------- Hero ---------- */
.hero { position: relative; overflow: hidden; padding: 64px 0 88px; background: var(--grad-soft); border-bottom: 1px solid var(--border); }
.hero::before, .hero::after { content: ""; position: absolute; border-radius: 50%; filter: blur(60px); opacity: .55; pointer-events: none; }
.hero::before { width: 460px; height: 460px; background: #7dd3fc; top: -160px; right: -80px; }
.hero::after { width: 380px; height: 380px; background: #c4b5fd; bottom: -200px; left: -120px; }
:root[data-theme="dark"] .hero::before { background: #0e7490; opacity: .35; } :root[data-theme="dark"] .hero::after { background: #5b21b6; opacity: .35; }
.hero .container { position: relative; z-index: 1; display: grid; grid-template-columns: 1.25fr 1fr; gap: 48px; align-items: center; }
.hero-kicker { display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); font-weight: 600; font-size: .84rem; color: var(--brand); box-shadow: var(--shadow-sm); margin-bottom: 18px; }
.hero h1 { font-size: clamp(2rem, 4.4vw, 3.3rem); line-height: 1.12; margin-bottom: 16px; }
.hero p.lead { font-size: 1.08rem; color: var(--text-2); max-width: 580px; margin-bottom: 26px; }
.hero-search { background: var(--surface); border-radius: 20px; padding: 8px; box-shadow: var(--shadow-lg); display: flex; gap: 8px; align-items: center; border: 1px solid var(--border); }
.hero-search select { width: auto; border: 0; background: var(--surface-3); height: 46px; border-radius: 13px; font-weight: 600; }
.hero-search input { border: 0; height: 46px; font-size: 1rem; box-shadow: none !important; background: transparent; }
.hero-tips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; font-size: .84rem; color: var(--text-2); align-items: center; }
.hero-tips code { background: var(--surface); border: 1px solid var(--border); padding: 2px 7px; border-radius: 6px; font-size: .8rem; color: var(--violet); cursor: pointer; }
.hero-art { position: relative; height: 380px; }
.hero-art .float { position: absolute; border-radius: 14px; box-shadow: var(--shadow-lg); overflow: hidden; transition: transform .4s; }
.hero-art .float img { display: block; width: 100%; height: 100%; object-fit: cover; }
.hero-art .f1 { width: 180px; height: 252px; left: 8%; top: 30px; transform: rotate(-8deg); animation: bob 6s ease-in-out infinite; }
.hero-art .f2 { width: 200px; height: 280px; left: 36%; top: 0; z-index: 2; animation: bob 7s ease-in-out infinite .6s; }
.hero-art .f3 { width: 170px; height: 238px; right: 2%; top: 70px; transform: rotate(9deg); animation: bob 6.5s ease-in-out infinite 1.1s; }
.hero-art .stat-float { position: absolute; z-index: 3; background: var(--surface); padding: 12px 16px; border-radius: 14px; box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: 12px; font-size: .82rem; color: var(--text-2); border: 1px solid var(--border); }
.hero-art .stat-float b { display: block; font-size: 1.15rem; color: var(--text); }
.hero-art .sf1 { left: 0; bottom: 30px; } .hero-art .sf2 { right: 0; bottom: 0; }
@keyframes bob { 50% { translate: 0 -10px; } }
.stats-strip { margin-top: -44px; position: relative; z-index: 2; }
.stats-strip .inner { display: grid; grid-template-columns: repeat(4, 1fr); background: var(--surface); border-radius: 20px; box-shadow: var(--shadow); border: 1px solid var(--border); }
.stat { padding: 20px 24px; display: flex; gap: 14px; align-items: center; }
.stat + .stat { border-left: 1px solid var(--border); }
.stat b { display: block; font-size: 1.55rem; font-weight: 800; line-height: 1.1; }
.stat span { color: var(--muted); font-size: .85rem; }

/* ---------- Sections ---------- */
.section { margin-top: 56px; }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.section-head h2 { margin: 0; font-size: 1.55rem; }
.section-head p { margin: 4px 0 0; color: var(--muted); }
.see-all { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; font-size: .9rem; }
.page-head { padding: 32px 0 8px; }
.page-head h1 { font-size: 1.9rem; margin-bottom: 6px; }
.page-head p { color: var(--text-2); margin: 0; }
.crumbs { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: .85rem; color: var(--muted); margin-bottom: 10px; }
.crumbs a { color: var(--text-2); } .crumbs span:last-child { color: var(--text); font-weight: 600; }

/* ---------- Doc cards ---------- */
.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(178px, 1fr)); gap: 22px; }
.doc-card { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; transition: .2s; }
.doc-card:hover { transform: translateY(-4px); box-shadow: var(--shadow); border-color: var(--brand-100); }
.doc-card-cover { position: relative; display: block; aspect-ratio: 5/7; background: var(--surface-3); overflow: hidden; }
.doc-card-cover .cover { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .35s; }
.doc-card:hover .cover { transform: scale(1.04); }
.corner-badge { position: absolute; top: 10px; right: 10px; display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; font-size: .72rem; font-weight: 700; border-radius: 8px; background: rgba(255, 255, 255, .92); color: #a15c00; }
.doc-card-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.doc-card-body .type-badge { align-self: flex-start; }
.doc-card h3 { font-size: .95rem; margin: 2px 0 0; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.doc-card h3 a { color: var(--text); } .doc-card h3 a:hover { color: var(--brand); text-decoration: none; }
.doc-card .meta { font-size: .8rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-card-foot { margin-top: auto; display: flex; justify-content: space-between; font-size: .78rem; color: var(--muted); padding-top: 6px; }
.doc-card-foot span { display: inline-flex; gap: 4px; align-items: center; }
.doc-list { display: flex; flex-direction: column; gap: 14px; }
.doc-row { display: flex; gap: 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; transition: .2s; }
.doc-row:hover { box-shadow: var(--shadow); border-color: var(--brand-100); }
.doc-row-cover { flex: none; width: 92px; }
.doc-row-cover .cover { width: 92px; aspect-ratio: 5/7; object-fit: cover; border-radius: 10px; display: block; box-shadow: var(--shadow-sm); }
.doc-row-body { flex: 1; min-width: 0; }
.doc-row-top { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.doc-row h3 { margin: 0 0 4px; font-size: 1.05rem; }
.doc-row h3 a { color: var(--text); } .doc-row h3 a:hover { color: var(--brand); }
.doc-row .meta { font-size: .86rem; color: var(--text-2); margin-bottom: 6px; }
.doc-row .abstract, .doc-row .snippet { font-size: .88rem; color: var(--text-2); margin: 0 0 8px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.doc-row .snippet { background: var(--surface-2); border-left: 3px solid var(--cyan); padding: 6px 10px; border-radius: 0 8px 8px 0; -webkit-line-clamp: 3; }
.doc-row-foot { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; font-size: .8rem; color: var(--muted); }
.doc-row-foot > span:not(.chip) { display: inline-flex; gap: 4px; align-items: center; }

/* ---------- Tiles ---------- */
.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 18px; }
.tile { position: relative; display: flex; gap: 14px; align-items: flex-start; padding: 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); transition: .2s; color: var(--text); text-decoration: none !important; overflow: hidden; }
.tile:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--brand-100); }
.tile h3 { font-size: 1rem; margin: 0 0 4px; }
.tile p { margin: 0; font-size: .84rem; color: var(--muted); }
.tile .logo-img { width: 46px; height: 46px; border-radius: 12px; object-fit: cover; flex: none; }
.tile-icon { width: 46px; height: 46px; border-radius: 13px; display: grid; place-items: center; color: #fff; flex: none; }
.tile .count { font-size: .8rem; font-weight: 700; color: var(--brand); margin-top: 6px; display: block; }
.subject-tile { padding: 20px; border-radius: 18px; color: #fff; text-decoration: none !important; position: relative; overflow: hidden; min-height: 130px; display: flex; flex-direction: column; justify-content: space-between; transition: .2s; }
.subject-tile:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.subject-tile h3 { font-size: 1.08rem; margin: 0; }
.subject-tile span { font-size: .84rem; opacity: .92; }
.subject-tile .ic-bg { position: absolute; right: -10px; bottom: -14px; opacity: .22; }
.feature-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; }
.feature { padding: 22px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); }
.feature .ic-bubble { margin-bottom: 12px; }
.feature h3 { font-size: 1rem; } .feature p { font-size: .87rem; color: var(--text-2); margin: 0; }
.cta { margin-top: 56px; border-radius: 24px; padding: 36px 40px; background: var(--grad); color: #fff; display: flex; align-items: center; justify-content: space-between; gap: 24px; flex-wrap: wrap; box-shadow: var(--shadow-lg); position: relative; overflow: hidden; }
.cta::after { content: ""; position: absolute; width: 300px; height: 300px; border-radius: 50%; background: rgba(255, 255, 255, .12); right: -80px; top: -120px; }
.cta h2 { margin: 0 0 6px; } .cta p { margin: 0; opacity: .92; }
.cta .btn { background: #fff; color: var(--brand); position: relative; z-index: 1; }

/* ---------- Search page ---------- */
.search-layout { display: grid; grid-template-columns: 290px minmax(0, 1fr); gap: 26px; align-items: start; margin-top: 20px; }
.search-bar { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 14px; box-shadow: var(--shadow-sm); display: grid; grid-template-columns: 170px minmax(0, 1fr) 190px auto; gap: 10px; align-items: center; }
.search-opts { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 10px; align-items: center; font-size: .86rem; }
.search-help { font-size: .84rem; color: var(--text-2); }
.search-help summary { cursor: pointer; font-weight: 600; color: var(--brand); display: inline-flex; gap: 6px; align-items: center; }
.search-help .help-body { margin-top: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 16px; display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 8px 20px; }
.search-help code { background: var(--surface-3); padding: 1px 6px; border-radius: 5px; color: var(--violet); }
.facets { position: sticky; top: calc(var(--header-h) + 16px); display: flex; flex-direction: column; gap: 12px; max-height: calc(100vh - var(--header-h) - 32px); overflow: auto; padding-right: 4px; }
.facets-head { display: flex; align-items: center; justify-content: space-between; }
.facets-head h3 { margin: 0; display: flex; align-items: center; gap: 8px; font-size: 1rem; }
.facet { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 12px 14px; }
.facet summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: .9rem; }
.facet summary::-webkit-details-marker { display: none; }
.facet summary .chev { margin-left: auto; transition: .2s; color: var(--muted); }
.facet[open] summary .chev { transform: rotate(180deg); }
.facet-search { margin: 10px 0 6px; }
.facet-search input { height: 32px; min-height: 32px; font-size: .84rem; padding: 4px 10px; }
.facet-list { display: flex; flex-direction: column; gap: 2px; max-height: 230px; overflow: auto; }
.facet-item { display: flex; align-items: center; gap: 8px; padding: 5px 6px; border-radius: 8px; cursor: pointer; font-size: .86rem; font-weight: 500; color: var(--text); }
.facet-item:hover { background: var(--surface-3); }
.facet-item span.lbl { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.facet-item .cnt { font-size: .75rem; color: var(--muted); background: var(--surface-3); border-radius: 999px; padding: 0 8px; font-weight: 700; }
.facet-more { border: 0; background: none; color: var(--brand); font: inherit; font-size: .82rem; font-weight: 600; cursor: pointer; padding: 4px 6px; }
.results-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.results-head .count { font-size: .95rem; color: var(--text-2); }
.results-head .count b { color: var(--text); font-size: 1.1rem; }
.active-filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.active-filters .chip { background: var(--brand-50); color: var(--brand); padding: 5px 8px 5px 12px; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 22px; font-size: .88rem; color: var(--text-2); }
.pager-btns { display: flex; gap: 4px; align-items: center; }
.pg { min-width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; display: inline-grid; place-items: center; padding: 0 8px; }
.pg:hover:not(:disabled) { border-color: var(--brand); color: var(--brand); }
.pg.cur { background: var(--grad); color: #fff; border-color: transparent; }
.pg:disabled { opacity: .4; cursor: default; }
.pg-gap { padding: 0 4px; color: var(--muted); }
.per { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; }
.per select { width: auto; min-height: 34px; padding: 4px 8px; }

/* ---------- Browse ---------- */
.alpha { display: flex; flex-wrap: wrap; gap: 4px; margin: 10px 0 16px; }
.alpha button { min-width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface); font: inherit; font-weight: 700; cursor: pointer; color: var(--text-2); }
.alpha button.active, .alpha button:hover { background: var(--brand); color: #fff; border-color: var(--brand); }
.browse-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.browse-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); font-weight: 600; font-size: .9rem; text-decoration: none !important; transition: .15s; }
.browse-item:hover { border-color: var(--brand); color: var(--brand); transform: translateY(-1px); }
.browse-item .cnt { font-size: .78rem; background: var(--brand-50); color: var(--brand); border-radius: 999px; padding: 1px 9px; font-weight: 700; flex: none; }
.year-bars { display: flex; align-items: flex-end; gap: 6px; height: 160px; padding: 10px 4px 0; border-bottom: 1px solid var(--axis); overflow-x: auto; }
.year-bars a { flex: 1; min-width: 30px; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; height: 100%; text-decoration: none !important; color: var(--text-2); font-size: .72rem; font-weight: 600; }
.year-bars a i { display: block; width: 100%; max-width: 24px; background: var(--series-1); border-radius: 4px 4px 0 0; transition: .15s; }
.year-bars a:hover i, .year-bars a.active i { background: var(--violet); }
.year-labels { display: flex; gap: 6px; padding: 4px; overflow-x: auto; }
.year-labels span { flex: 1; min-width: 30px; text-align: center; font-size: .72rem; color: var(--muted); }
.tree { display: flex; flex-direction: column; gap: 10px; }
.tree-main { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
.tree-main > a, .tree-main > .tree-title { display: flex; align-items: center; gap: 12px; padding: 14px 16px; font-weight: 700; color: var(--text); text-decoration: none; }
.tree-main > a:hover { background: var(--surface-2); color: var(--brand); }
.tree-subs { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 16px 14px 60px; }

/* ---------- Document detail ---------- */
.doc-hero { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 36px; margin-top: 16px; }
.doc-hero-cover { position: sticky; top: calc(var(--header-h) + 16px); align-self: start; }
.doc-hero-cover .cover { width: 100%; border-radius: 16px; box-shadow: var(--shadow-lg); display: block; aspect-ratio: 5/7; object-fit: cover; background: var(--surface-3); }
.doc-hero-cover .actions { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }
.doc-title { font-size: clamp(1.5rem, 2.6vw, 2.1rem); margin: 10px 0 8px; }
.doc-authors { font-size: 1rem; color: var(--text-2); margin-bottom: 16px; }
.doc-kpis { display: flex; gap: 12px; flex-wrap: wrap; margin: 18px 0; }
.kpi-mini { display: flex; gap: 10px; align-items: center; padding: 10px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; }
.kpi-mini b { display: block; font-size: 1.1rem; line-height: 1.1; } .kpi-mini span { font-size: .78rem; color: var(--muted); }
.kpi-mini .ic-bubble { width: 36px; height: 36px; border-radius: 10px; }
.meta-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.meta-table th { text-align: left; width: 210px; color: var(--muted); font-weight: 600; padding: 10px 12px 10px 0; vertical-align: top; }
.meta-table td { padding: 10px 0; border-bottom: 1px dashed var(--border); }
.meta-table tr:last-child td { border-bottom: 0; }
.meta-table code { font-size: .78rem; color: var(--violet); background: var(--surface-3); padding: 1px 6px; border-radius: 5px; }
.lend-box { padding: 14px; border-radius: 14px; background: linear-gradient(135deg, #fff8e6, #ffeef4); border: 1px solid #fde2b3; font-size: .86rem; color: #7a4a00; }
:root[data-theme="dark"] .lend-box { background: linear-gradient(135deg, #3a2a0a, #3a1427); border-color: #5b4210; color: #ffd98a; }
.lend-box .meter { height: 8px; background: #fde7bd; border-radius: 99px; overflow: hidden; margin: 8px 0 4px; }
.lend-box .meter i { display: block; height: 100%; background: var(--amber); border-radius: 99px; }
.share-row { display: flex; gap: 8px; flex-wrap: wrap; }
.share-btn { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; color: #fff; border: 0; cursor: pointer; font-weight: 800; font-size: .9rem; font-family: inherit; }
.timeline { position: relative; padding-left: 22px; }
.timeline::before { content: ""; position: absolute; left: 6px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
.tl-item { position: relative; padding-bottom: 16px; }
.tl-item::before { content: ""; position: absolute; left: -21px; top: 6px; width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 3px solid var(--brand); }
.tl-item b { display: block; }
.tl-item span { font-size: .82rem; color: var(--muted); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); }
.table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.table th { text-align: left; font-weight: 700; color: var(--text-2); background: var(--surface-2); padding: 11px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; font-size: .82rem; }
.table th.sortable { cursor: pointer; user-select: none; }
.table th.sortable:hover { color: var(--brand); }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .actions { text-align: right; white-space: nowrap; }
.table .title-cell { display: flex; align-items: center; gap: 10px; min-width: 240px; }
.table .title-cell img { width: 34px; height: 48px; object-fit: cover; border-radius: 6px; flex: none; }
.table .title-cell b { display: block; font-size: .88rem; line-height: 1.3; }
.table .title-cell span { font-size: .78rem; color: var(--muted); }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar .input-icon { width: 280px; max-width: 100%; }
.toolbar select { width: auto; min-width: 150px; }
.bulkbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 14px; background: var(--brand-50); border: 1px solid var(--brand-100); border-radius: 12px; margin-bottom: 12px; font-size: .88rem; font-weight: 600; color: var(--brand); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; scrollbar-width: none; }
.tab { display: inline-flex; align-items: center; gap: 8px; padding: 10px 14px; border: 0; background: none; font: inherit; font-weight: 600; font-size: .9rem; color: var(--text-2); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); }
.tab-count { background: var(--surface-3); color: var(--text-2); font-size: .74rem; padding: 0 8px; border-radius: 99px; }
.tab.active .tab-count { background: var(--brand-50); color: var(--brand); }

/* ---------- Modal, toast, tooltip ---------- */
.modal-wrap { position: fixed; inset: 0; z-index: 200; background: rgba(10, 20, 40, .45); backdrop-filter: blur(3px); display: grid; place-items: center; padding: 16px; opacity: 0; transition: .2s; }
.modal-wrap.show { opacity: 1; }
.modal { background: var(--surface); border-radius: 20px; box-shadow: var(--shadow-lg); width: 100%; max-height: calc(100vh - 32px); display: flex; flex-direction: column; transform: translateY(10px) scale(.98); transition: .2s; border: 1px solid var(--border); }
.modal-wrap.show .modal { transform: none; }
.modal-sm { max-width: 440px; } .modal-md { max-width: 620px; } .modal-lg { max-width: 880px; } .modal-xl { max-width: 1120px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; font-size: 1.08rem; }
.modal-body { padding: 20px; overflow: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 20px 20px; flex-wrap: wrap; }
.confirm-msg { font-size: .95rem; color: var(--text-2); margin: 0; }
#toasts { position: fixed; right: 20px; bottom: 20px; z-index: 300; display: flex; flex-direction: column; gap: 10px; max-width: min(420px, calc(100vw - 32px)); }
.toast { display: flex; gap: 10px; align-items: flex-start; padding: 12px 16px; border-radius: 14px; background: var(--surface); box-shadow: var(--shadow-lg); border: 1px solid var(--border); border-left: 4px solid var(--green); font-size: .9rem; animation: slidein .25s ease; transition: .3s; }
.toast .ic { margin-top: 2px; }
.toast-ok .ic { color: var(--green); } .toast-error { border-left-color: var(--red); } .toast-error .ic { color: var(--red); } .toast-warn { border-left-color: var(--amber); } .toast-warn .ic { color: var(--amber); } .toast-info { border-left-color: var(--brand); } .toast-info .ic { color: var(--brand); }
.toast.out { opacity: 0; transform: translateX(20px); }
@keyframes slidein { from { opacity: 0; transform: translateX(20px); } }
#tip { position: fixed; left: 0; top: 0; z-index: 400; pointer-events: none; background: var(--text); color: var(--surface); padding: 8px 11px; border-radius: 10px; font-size: .8rem; line-height: 1.45; box-shadow: var(--shadow-lg); opacity: 0; transition: opacity .12s; max-width: 280px; }
#tip.show { opacity: 1; }
#tip .sw { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 6px; }
.empty { text-align: center; padding: 48px 16px; color: var(--muted); }
.empty .ic { color: var(--border-strong); margin-bottom: 8px; }
.empty p { margin: 0 0 12px; }
.notice { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 14px; background: var(--brand-50); border: 1px solid var(--brand-100); color: var(--text); font-size: .9rem; }
.notice .ic { color: var(--brand); margin-top: 2px; }
.notice.warn { background: #fff7e6; border-color: #fde2b3; } .notice.warn .ic { color: var(--amber); }
.notice.danger { background: #fff0f0; border-color: #ffd0d0; } .notice.danger .ic { color: var(--red); }
:root[data-theme="dark"] .notice.warn { background: #3a2a0a; border-color: #5b4210; } :root[data-theme="dark"] .notice.danger { background: #3a1414; border-color: #5b2020; }

/* ---------- Charts ---------- */
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .axis { stroke: var(--axis); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 11px; font-family: var(--font); font-variant-numeric: tabular-nums; }
.chart .hit { fill: transparent; }
.chart .col-hit:hover .hit { fill: color-mix(in srgb, var(--brand) 6%, transparent); }
.chart .xhair { stroke: var(--axis); stroke-width: 1; opacity: 0; }
.chart .hover-dot { opacity: 0; }
.chart .line-hit:hover .xhair, .chart .line-hit:hover .hover-dot { opacity: 1; }
.chart .dot-ring { stroke: var(--surface); stroke-width: 2; }
.chart .slice { stroke: var(--surface); stroke-width: 2; transition: opacity .15s; }
.chart .slice:hover { opacity: .85; }
.donut-total { font-size: 24px; font-weight: 800; fill: var(--text); font-family: var(--font); }
.donut-wrap { display: grid; grid-template-columns: minmax(140px, 200px) 1fr; gap: 18px; align-items: center; }
.donut-legend { display: flex; flex-direction: column; gap: 6px; font-size: .84rem; min-width: 0; }
.donut-legend div { display: flex; align-items: center; gap: 8px; }
.donut-legend i, .legend i { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.donut-legend .lbl { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.donut-legend b { font-variant-numeric: tabular-nums; }
.donut-legend .pct { color: var(--muted); width: 38px; text-align: right; font-variant-numeric: tabular-nums; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: .82rem; color: var(--text-2); margin-bottom: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.hbar { display: flex; flex-direction: column; gap: 8px; }
.hbar-row { display: grid; grid-template-columns: minmax(0, 42%) minmax(0, 1fr); gap: 12px; align-items: center; padding: 3px 4px; border-radius: 8px; }
.hbar-row:hover { background: var(--surface-2); }
.hbar-label { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: .86rem; }
.hbar-label a, .hbar-label span:not(.rank) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.hbar-label .rank { width: 22px; height: 22px; border-radius: 7px; background: var(--surface-3); color: var(--text-2); font-size: .72rem; font-weight: 800; display: grid; place-items: center; flex: none; }
.hbar-row:nth-child(-n+3) .rank { background: var(--brand-50); color: var(--brand); }
.hbar-track { display: flex; align-items: center; gap: 8px; }
.hbar-bar { height: 14px; border-radius: 0 4px 4px 0; min-width: 2px; }
.hbar-val { font-size: .8rem; font-weight: 700; color: var(--text-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.spark { width: 100%; height: 32px; display: block; }

/* ---------- Auth ---------- */
.auth-wrap { min-height: calc(100vh - var(--header-h)); display: grid; place-items: center; padding: 40px 16px; background: var(--grad-soft); }
.auth-card { width: 100%; max-width: 940px; display: grid; grid-template-columns: 1fr 1fr; background: var(--surface); border-radius: 24px; overflow: hidden; box-shadow: var(--shadow-lg); border: 1px solid var(--border); }
.auth-side { background: var(--grad); color: #fff; padding: 40px; position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between; gap: 24px; }
.auth-side::after { content: ""; position: absolute; width: 280px; height: 280px; border-radius: 50%; background: rgba(255, 255, 255, .12); right: -90px; bottom: -90px; }
.auth-side h2 { font-size: 1.7rem; }
.auth-side ul { padding: 0; margin: 0; list-style: none; display: flex; flex-direction: column; gap: 10px; font-size: .92rem; }
.auth-side li { display: flex; gap: 10px; align-items: center; }
.auth-form { padding: 40px; display: flex; flex-direction: column; gap: 16px; }
.demo-accounts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.demo-acc { text-align: left; padding: 10px 12px; border: 1px dashed var(--border-strong); border-radius: 12px; background: var(--surface-2); cursor: pointer; font: inherit; font-size: .82rem; color: var(--text); }
.demo-acc:hover { border-color: var(--brand); background: var(--brand-50); }
.demo-acc b { display: block; font-size: .86rem; } .demo-acc span { color: var(--muted); }

/* ---------- Account / shelf ---------- */
.shelf-item { display: grid; grid-template-columns: 84px minmax(0, 1fr) auto; gap: 16px; padding: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; align-items: center; }
.shelf-item .cover { width: 84px; aspect-ratio: 5/7; object-fit: cover; border-radius: 10px; }
.shelf-item h3 { font-size: 1rem; margin: 0 0 4px; }
.shelf-meta { font-size: .82rem; color: var(--text-2); display: flex; flex-wrap: wrap; gap: 4px 14px; }
.remain { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: .84rem; padding: 4px 10px; border-radius: 99px; background: #dcfaec; color: #047a55; margin-top: 8px; }
.remain.soon { background: #fff3d6; color: #a15c00; } .remain.over { background: #ffe4e4; color: #c01d1d; }
:root[data-theme="dark"] .remain { background: #0d3d2c; color: #7ff0c1; } :root[data-theme="dark"] .remain.soon { background: #4a3408; color: #ffd27a; } :root[data-theme="dark"] .remain.over { background: #4d1717; color: #ffabab; }
.progress { height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; margin-top: 8px; max-width: 320px; }
.progress i { display: block; height: 100%; background: var(--grad); border-radius: 99px; }
.shelf-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; max-width: 330px; }
.shelf-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 18px; }
.shelf-card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; overflow: hidden; display: flex; flex-direction: column; }
.shelf-card .cover { width: 100%; aspect-ratio: 5/6; object-fit: cover; }
.shelf-card .body { padding: 12px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.shelf-card h3 { font-size: .92rem; margin: 0; }
.profile-head { display: flex; gap: 20px; align-items: center; padding: 24px; border-radius: 20px; background: var(--grad); color: #fff; margin-top: 20px; flex-wrap: wrap; }
.profile-head .avatar { border: 4px solid rgba(255, 255, 255, .5); }
.profile-head h1 { margin: 0; font-size: 1.6rem; } .profile-head p { margin: 4px 0 0; opacity: .9; }

/* ---------- Author ---------- */
.author-card { display: flex; gap: 14px; align-items: center; padding: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; color: var(--text); text-decoration: none !important; transition: .2s; }
.author-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--brand-100); }
.author-card b { display: block; } .author-card span { font-size: .82rem; color: var(--muted); }
.author-hero { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 28px; align-items: center; padding: 28px; border-radius: 24px; background: var(--grad-soft); border: 1px solid var(--border); margin-top: 16px; }
.author-hero .avatar { box-shadow: var(--shadow-lg); border: 5px solid var(--surface); }
.info-list { display: flex; flex-wrap: wrap; gap: 8px 20px; font-size: .9rem; color: var(--text-2); }
.info-list span { display: inline-flex; gap: 6px; align-items: center; }

/* ---------- Admin layout ---------- */
.admin { display: grid; grid-template-columns: 268px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--surface); border-right: 1px solid var(--border); padding: 18px 14px; display: flex; flex-direction: column; gap: 4px; }
.sidebar .logo { padding: 4px 8px 16px; }
.side-group { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; padding: 14px 10px 6px; }
.side-link { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; color: var(--text-2); font-weight: 600; font-size: .88rem; text-decoration: none !important; }
.side-link:hover { background: var(--surface-3); color: var(--text); }
.side-link.active { background: var(--brand-50); color: var(--brand); }
.side-link.locked { opacity: .45; }
.side-link .badge { margin-left: auto; background: var(--red); color: #fff; font-size: .7rem; padding: 0 7px; border-radius: 99px; font-weight: 700; }
.admin-main { min-width: 0; display: flex; flex-direction: column; }
.admin-top { position: sticky; top: 0; z-index: 40; height: 64px; display: flex; align-items: center; gap: 12px; padding: 0 28px; background: color-mix(in srgb, var(--surface) 85%, transparent); backdrop-filter: blur(12px); border-bottom: 1px solid var(--border); }
.admin-content { padding: 26px 28px 60px; }
.admin-title { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.admin-title h1 { font-size: 1.55rem; margin: 0; }
.admin-title p { margin: 4px 0 0; color: var(--muted); font-size: .9rem; }
.kpi { padding: 18px; border-radius: 18px; background: var(--surface); border: 1px solid var(--border); position: relative; overflow: hidden; }
.kpi .kpi-top { display: flex; justify-content: space-between; align-items: flex-start; }
.kpi .kpi-label { font-size: .84rem; color: var(--text-2); font-weight: 600; }
.kpi .kpi-value { font-size: 1.9rem; font-weight: 800; margin: 6px 0 2px; line-height: 1.1; }
.kpi .kpi-sub { font-size: .8rem; color: var(--muted); }
.kpi .spark { margin-top: 8px; }
.tree-admin { display: flex; flex-direction: column; gap: 6px; }
.tnode { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.tnode:hover { border-color: var(--brand-100); box-shadow: var(--shadow-sm); }
.tnode .t-ic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; color: #fff; flex: none; overflow: hidden; }
.tnode .t-ic img { width: 100%; height: 100%; object-fit: cover; }
.tnode .t-name { flex: 1; min-width: 0; }
.tnode .t-name b { display: block; font-size: .92rem; } .tnode .t-name span { font-size: .78rem; color: var(--muted); }
.tchildren { margin-left: 28px; padding-left: 14px; border-left: 2px dashed var(--border); display: flex; flex-direction: column; gap: 6px; }
.perm-table td, .perm-table th { text-align: center; }
.perm-table td:first-child, .perm-table th:first-child { text-align: left; }
.wf-steps { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.wf-step { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 99px; font-size: .78rem; font-weight: 700; background: var(--surface-3); color: var(--muted); }
.wf-step.done { background: #dcfaec; color: #047a55; } .wf-step.cur { background: var(--brand); color: #fff; }
.dc-row { display: grid; grid-template-columns: 220px minmax(0, 1fr) auto; gap: 10px; align-items: start; padding: 8px 0; border-bottom: 1px dashed var(--border); }
.dc-row label { padding-top: 9px; }
.dc-row label code { display: block; font-size: .72rem; color: var(--violet); font-weight: 500; }
.dc-vals { display: flex; flex-direction: column; gap: 6px; }
.dc-val { display: flex; gap: 6px; }
.dc-row.invalid input, .dc-row.invalid textarea { border-color: var(--red); background: color-mix(in srgb, var(--red) 5%, var(--surface)); }
.dc-row.invalid label { color: var(--red); }
.file-list { display: flex; flex-direction: column; gap: 8px; }
.file-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.f-ic { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; font-size: .66rem; font-weight: 800; color: #fff; text-transform: uppercase; flex: none; }
.file-item .f-name { flex: 1; min-width: 0; }
.file-item .f-name b { display: block; font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-item .f-name span { font-size: .78rem; color: var(--muted); }
.dropzone { border: 2px dashed var(--border-strong); border-radius: 16px; padding: 26px; text-align: center; color: var(--text-2); background: var(--surface-2); cursor: pointer; transition: .15s; display: block; }
.dropzone:hover, .dropzone.drag { border-color: var(--brand); background: var(--brand-50); color: var(--brand); }
.dropzone input { display: none; }
pre.code { background: var(--surface-3); border-radius: 12px; padding: 12px 14px; font-size: .8rem; overflow: auto; margin: 0; }
.req-group { margin-bottom: 14px; }
.req-uc { border: 1px solid var(--border); border-radius: 14px; background: var(--surface); margin-bottom: 8px; }
.req-uc summary { list-style: none; display: flex; align-items: center; gap: 12px; padding: 12px 16px; cursor: pointer; }
.req-uc summary::-webkit-details-marker { display: none; }
.req-uc summary .no { width: 30px; height: 30px; border-radius: 9px; background: var(--brand-50); color: var(--brand); font-weight: 800; display: grid; place-items: center; font-size: .82rem; flex: none; }
.req-uc summary b { flex: 1; }
.req-uc ul { margin: 0; padding: 0 16px 14px 58px; display: flex; flex-direction: column; gap: 6px; font-size: .88rem; color: var(--text-2); }
.req-uc li { list-style: none; display: flex; gap: 8px; }
.req-uc li .ic { color: var(--green); margin-top: 3px; }
.level { font-size: .74rem; font-weight: 700; padding: 2px 8px; border-radius: 99px; }
.level-don-gian { background: #dcfaec; color: #047a55; } .level-trung-binh { background: #e3eeff; color: #1d4fbf; } .level-phuc-tap { background: #ffe4f1; color: #b41d6b; }

/* ---------- Reader ---------- */
.reader { position: fixed; inset: 0; z-index: 90; display: flex; flex-direction: column; background: #e9eef6; }
:root[data-theme="dark"] .reader { background: #070c17; }
.reader-top { height: 58px; flex: none; display: flex; align-items: center; gap: 8px; padding: 0 12px; background: var(--surface); border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: thin; }
.reader-top .r-title { min-width: 120px; max-width: 320px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-weight: 700; font-size: .92rem; }
.reader-top .r-title span { display: block; font-size: .74rem; color: var(--muted); font-weight: 500; }
.reader-top .sep { width: 1px; height: 26px; background: var(--border); flex: none; margin: 0 4px; }
.reader-top .pg-input { width: 56px; min-height: 34px; height: 34px; text-align: center; padding: 4px; }
.reader-top .zoom-val { font-size: .82rem; font-weight: 700; width: 46px; text-align: center; color: var(--text-2); flex: none; }
.reader-body { flex: 1; display: flex; min-height: 0; position: relative; }
.reader-side { width: 300px; flex: none; background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; }
.reader-side .tabs { margin: 0; padding: 0 6px; gap: 0; }
.reader-side .tab { flex: 1; justify-content: center; padding: 11px 4px; font-size: .83rem; }
.reader-side-body { flex: 1; overflow: auto; padding: 12px; }
.toc-item { display: block; width: 100%; text-align: left; padding: 8px 10px; border-radius: 9px; border: 0; background: none; font: inherit; font-size: .86rem; color: var(--text); cursor: pointer; }
.toc-item:hover { background: var(--surface-3); }
.toc-item.active { background: var(--brand-50); color: var(--brand); font-weight: 600; }
.toc-item span { float: right; color: var(--muted); font-size: .78rem; }
.find-hit { display: block; width: 100%; text-align: left; border: 1px solid var(--border); background: var(--surface); border-radius: 10px; padding: 8px 10px; margin-bottom: 6px; font: inherit; font-size: .82rem; cursor: pointer; color: var(--text-2); }
.find-hit:hover { border-color: var(--brand); }
.find-hit b { color: var(--brand); display: block; font-size: .76rem; }
.note-item { border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; font-size: .84rem; background: #fffbea; }
:root[data-theme="dark"] .note-item { background: #2d2a14; }
.note-item .q { font-style: italic; color: var(--muted); border-left: 3px solid var(--amber); padding-left: 8px; margin-bottom: 4px; }
.reader-stage { flex: 1; overflow: auto; position: relative; padding: 28px 20px 60px; }
.pages { display: flex; flex-direction: column; align-items: center; gap: 24px; transform-origin: top center; }
.pages.book { flex-direction: row; flex-wrap: wrap; justify-content: center; gap: 0; }
.page { width: 640px; min-height: 905px; background: #fff; color: #1d2433; box-shadow: 0 10px 30px -12px rgba(0, 0, 0, .35); padding: 70px 72px; font-family: Georgia, "Times New Roman", serif; font-size: 16px; line-height: 1.75; position: relative; transition: transform .25s; user-select: text; }
.pages.book .page { width: 520px; min-height: 740px; padding: 52px 54px; font-size: 14.5px; }
.pages.book .page:nth-child(odd) { box-shadow: -10px 10px 30px -14px rgba(0, 0, 0, .35); }
.page h2 { font-family: var(--font); font-size: 1.35rem; color: #0f1b33; margin-bottom: 20px; }
.page h4 { font-family: var(--font); color: #334155; margin: 12px 0; }
.page p { text-align: justify; margin: 0 0 14px; }
.page .pno { position: absolute; bottom: 26px; left: 0; right: 0; text-align: center; font-size: 12px; color: #94a3b8; font-family: var(--font); }
.page.cover-page { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; background: linear-gradient(160deg, #f5f9ff, #eef2ff); }
.page.cover-page h1 { font-family: var(--font); font-size: 2rem; color: #0f1b33; }
.page.slide { width: 880px; min-height: 495px; padding: 48px 56px; font-family: var(--font); background: linear-gradient(135deg, #fff 60%, #eef4ff); }
.page.slide h2 { color: var(--brand); font-size: 1.7rem; }
.page.slide ul { font-size: 1.05rem; line-height: 1.8; }
.page.sheet { width: 880px; min-height: 500px; padding: 18px; font-family: var(--font); font-size: 13px; }
.page.sheet table { border-collapse: collapse; width: 100%; }
.page.sheet td, .page.sheet th { border: 1px solid #d7deea; padding: 5px 8px; text-align: right; }
.page.sheet th { background: #eef3fb; text-align: center; color: #334155; }
.page.sheet td:first-child, .page.sheet th:first-child { text-align: left; background: #f7f9fc; }
.page mark.find { background: #ffe066; }
.page .hl-note { background: #fff3b0; border-bottom: 2px solid var(--amber); }
.bm-flag { position: absolute; top: 0; right: 36px; color: var(--pink); }
.watermark { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 3; }
.watermark span { position: absolute; white-space: nowrap; font: 700 15px var(--font); color: rgba(31, 107, 255, .085); transform: rotate(-30deg); user-select: none; }
.img-viewer { height: 100%; display: flex; flex-direction: column; }
.img-stage { flex: 1; display: grid; place-items: center; overflow: hidden; position: relative; cursor: grab; }
.img-stage img { max-width: 92%; max-height: 92%; box-shadow: 0 20px 50px -20px rgba(0, 0, 0, .5); transition: transform .25s; user-select: none; -webkit-user-drag: none; border-radius: 6px; }
.img-thumbs { flex: none; display: flex; gap: 8px; padding: 10px; overflow-x: auto; background: var(--surface); border-top: 1px solid var(--border); justify-content: center; }
.img-thumbs button { border: 2px solid transparent; padding: 0; border-radius: 8px; overflow: hidden; cursor: pointer; flex: none; background: none; }
.img-thumbs button.active { border-color: var(--brand); }
.img-thumbs img { width: 88px; height: 58px; object-fit: cover; display: block; }
.nav-arrow { position: absolute; top: 50%; transform: translateY(-50%); width: 46px; height: 46px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, .92); box-shadow: var(--shadow); cursor: pointer; display: grid; place-items: center; z-index: 4; color: #1d2433; }
.nav-arrow.l { left: 16px; } .nav-arrow.r { right: 16px; }
.media-stage { height: 100%; display: grid; place-items: center; padding: 24px; }
.media-box { width: 100%; max-width: 980px; background: #000; border-radius: 16px; overflow: hidden; box-shadow: var(--shadow-lg); position: relative; }
.media-box video { width: 100%; display: block; max-height: 70vh; background: #000; }
.audio-card { width: 100%; max-width: 620px; background: var(--surface); border-radius: 24px; padding: 32px; box-shadow: var(--shadow-lg); text-align: center; border: 1px solid var(--border); }
.audio-card .disc { width: 180px; height: 180px; margin: 0 auto 20px; border-radius: 50%; background: conic-gradient(from 0deg, #06b6d4, #1f6bff, #7c4dff, #ec4899, #06b6d4); display: grid; place-items: center; animation: spin 8s linear infinite; animation-play-state: paused; }
.audio-card .disc.playing { animation-play-state: running; }
.audio-card .disc::after { content: ""; width: 56px; height: 56px; border-radius: 50%; background: var(--surface); }
.audio-card audio { width: 100%; margin-top: 16px; }
@keyframes spin { to { transform: rotate(360deg); } }
.eq { display: flex; gap: 3px; align-items: flex-end; height: 26px; justify-content: center; margin-top: 8px; }
.eq i { width: 4px; background: var(--brand); border-radius: 2px; height: 20%; }
.eq.on i { animation: eq 1s ease-in-out infinite; }
.eq i:nth-child(2) { animation-delay: .2s !important; } .eq i:nth-child(3) { animation-delay: .4s !important; } .eq i:nth-child(4) { animation-delay: .1s !important; } .eq i:nth-child(5) { animation-delay: .3s !important; }
@keyframes eq { 50% { height: 100%; } }
/* EPUB reflow */
.epub { max-width: 760px; margin: 0 auto; padding: 50px 56px 80px; border-radius: 6px; box-shadow: 0 10px 30px -12px rgba(0, 0, 0, .25); background: #fff; color: #1d2433; transition: background .2s, color .2s; user-select: text; }
.epub.sepia { background: #f7eed9; color: #4a3b22; }
.epub.night { background: #121212; color: #d7d7d7; }
.epub h2 { font-family: var(--font); margin-bottom: 18px; }
.epub p { text-align: justify; margin: 0 0 1em; }
.epub p.speaking { background: color-mix(in srgb, var(--cyan) 22%, transparent); border-radius: 6px; }
.epub-nav { display: flex; justify-content: space-between; gap: 10px; margin-top: 30px; font-family: var(--font); }
.reader-panel { position: absolute; right: 16px; top: 12px; width: 320px; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow-lg); padding: 16px; z-index: 20; max-height: calc(100% - 24px); overflow: auto; }
.reader-panel h4 { margin: 0 0 10px; display: flex; align-items: center; gap: 8px; font-size: .95rem; }
.reader-panel .field { margin-bottom: 12px; }
.theme-dots { display: flex; gap: 8px; }
.theme-dots button { width: 36px; height: 36px; border-radius: 50%; border: 2px solid var(--border); cursor: pointer; font: 700 .8rem var(--font); }
.theme-dots button.active { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-100); }
.brightness-veil { position: absolute; inset: 0; background: #000; pointer-events: none; z-index: 10; opacity: 0; transition: opacity .2s; }
.protect-note { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); background: rgba(15, 27, 51, .85); color: #fff; padding: 6px 14px; border-radius: 99px; font-size: .78rem; display: flex; gap: 6px; align-items: center; z-index: 12; pointer-events: none; }
.no-select { user-select: none; -webkit-user-select: none; }
html.protect-print body > * { }
@media print {
  html.protect-print body > * { display: none !important; }
  html.protect-print body::before { content: "Tài liệu được bảo vệ bản quyền – chức năng in đã bị chặn."; display: block; padding: 40px; font: 700 20px sans-serif; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .mainnav a span.lbl-long { display: none; }
  .top-search { display: none; }
  .feature-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 1024px) {
  .hero .container { grid-template-columns: 1fr; }
  .hero-art { display: none; }
  .search-layout { grid-template-columns: 1fr; }
  .facets { position: static; max-height: none; }
  .facets.collapsed .facet { display: none; }
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; z-index: 120; width: 280px; transform: translateX(-100%); transition: transform .25s; box-shadow: var(--shadow-lg); }
  .admin.side-open .sidebar { transform: none; }
  .admin .burger { display: inline-grid; }
  .reader-side { position: absolute; left: 0; top: 0; bottom: 0; z-index: 15; box-shadow: var(--shadow-lg); }
  .page.slide, .page.sheet { width: 100%; }
}
@media (max-width: 860px) {
  .mainnav { display: none; }
  .burger { display: inline-grid; }
  .mainnav.open { display: flex; flex-direction: column; position: absolute; top: var(--header-h); left: 0; right: 0; background: var(--surface); border-bottom: 1px solid var(--border); padding: 10px 16px 16px; box-shadow: var(--shadow); }
  .bottom-nav { display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 70; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(12px); border-top: 1px solid var(--border); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  .bottom-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: .68rem; font-weight: 600; color: var(--muted); text-decoration: none; padding: 4px; }
  .bottom-nav a.active { color: var(--brand); }
  body.has-bottom-nav { padding-bottom: 72px; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
  .doc-hero { grid-template-columns: 1fr; }
  .doc-hero-cover { position: static; display: grid; grid-template-columns: 140px 1fr; gap: 16px; align-items: start; }
  .doc-hero-cover .actions { margin-top: 0; }
  .auth-card { grid-template-columns: 1fr; }
  .auth-side { display: none; }
  .search-bar { grid-template-columns: 1fr 1fr; }
  .search-bar .q-input { grid-column: 1 / -1; order: -1; }
  .stats-strip .inner { grid-template-columns: repeat(2, 1fr); }
  .stat:nth-child(3) { border-left: 0; }
  .stat:nth-child(n+3) { border-top: 1px solid var(--border); }
  .shelf-item { grid-template-columns: 70px minmax(0, 1fr); }
  .shelf-item .cover { width: 70px; }
  .shelf-actions { grid-column: 1 / -1; justify-content: flex-start; max-width: none; }
  .page { width: 100%; min-height: auto; padding: 36px 26px 60px; }
  .pages.book .page { width: 100%; }
  .reader-top .r-title { display: none; }
  .reader-panel { left: 12px; right: 12px; width: auto; }
  .dc-row { grid-template-columns: 1fr; }
  .dc-row label { padding-top: 0; }
  .meta-table th { width: 130px; }
  .author-hero { grid-template-columns: 1fr; text-align: center; justify-items: center; }
  .info-list { justify-content: center; }
}
@media (max-width: 640px) {
  .container { padding: 0 16px; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .feature-grid { grid-template-columns: 1fr; }
  .hero { padding: 36px 0 70px; }
  .hero-search { flex-wrap: wrap; }
  .hero-search select { width: 100%; }
  .doc-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .doc-row { flex-direction: column; }
  .doc-row-cover { display: none; }
  .admin-content { padding: 18px 16px 60px; }
  .admin-top { padding: 0 16px; }
  .demo-accounts { grid-template-columns: 1fr; }
  .auth-form { padding: 24px; }
  .cta { padding: 26px; }
  .donut-wrap { grid-template-columns: 1fr; justify-items: center; }
  .donut-wrap .donut { max-width: 200px; }
  .donut-legend { width: 100%; }
  .hbar-row { grid-template-columns: 1fr; gap: 2px; }
  .footer-grid { grid-template-columns: 1fr; }
  .top-actions .hide-sm { display: none; }
  .logo small { display: none; }
  .search-bar { grid-template-columns: 1fr; }
  .toolbar .input-icon { width: 100%; }
  .epub { padding: 30px 22px 60px; }
  .tchildren { margin-left: 10px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
main#view:not(.admin-content) { min-height: calc(100vh - var(--header-h) - 120px); }

/* Biểu đồ tròn tự xếp dọc khi khung hẹp */
.panel { container-type: inline-size; }
@container (max-width: 440px) {
  .donut-wrap { grid-template-columns: 1fr; justify-items: center; }
  .donut-wrap .donut { max-width: 180px; }
  .donut-legend { width: 100%; }
}

.shelf-meta span, .file-item .f-name span { overflow-wrap: anywhere; }
.protect-note { animation: fadeNote 1s ease 5s forwards; }
@keyframes fadeNote { to { opacity: 0; visibility: hidden; } }
@media (max-width: 640px) {
  .logo { font-size: 1rem; gap: 8px; }
  .logo-mark { width: 36px; height: 36px; }
  .topbar .container { gap: 10px; }
  .protect-note { font-size: .7rem; max-width: calc(100% - 32px); }
}

.facet-toggle { display: none; }
@media (max-width: 1024px) { .facet-toggle { display: inline-flex; } }
@media (min-width: 1025px) { .facets.collapsed .facet { display: block; } }
