/* Learning Hub. Default look follows TRS AskEZ: pink-to-cream gradients and red #D71920, in three modes (light, dim,
   dark; data-theme on <html>, or the system setting). data-accent swaps the accent hue; --red* names mean "the accent". */
:root {
  --accent-l: #d71920; --accent-deep-l: #b9151b; --accent-2-l: #f2b01e;
  --accent-d: #eb3941; --accent-deep-d: #ff9ba0; --accent-2-d: #f5c04a;

  --red: var(--accent-l); --red-deep: var(--accent-deep-l); --accent-2: var(--accent-2-l);
  --gold: #f2b01e; --gold-soft: #fff6dc; --gold-ink: #9a6400;
  --bg: #fbf6f4; --surface: #ffffff; --surface-2: #f4f1ee; --line: #e9e4e1; --line-strong: #dbd5d1;
  --ink: #1e2632; --muted: #717b89; --faint: #9aa1ac;
  --good: #167243; --good-soft: #ecfbf2; --blue: #2459c6; --blue-soft: #e9f0ff; --violet: #6b3fc4; --violet-soft: #f0e9ff;
  --shadow: 0 9px 28px rgb(21 29 40 / 5%);
  --shadow-lg: 0 18px 44px rgb(21 29 40 / 12%);
  --reader-bg: #efe9e7;
  --hl-yellow: #ffe066; --hl-green: #9be7a8; --hl-blue: #9cc8ff; --hl-pink: #ffb3cf;
  --radius: 16px;
  --font: "Segoe UI", Roboto, Inter, Arial, sans-serif;
  --red-soft: color-mix(in srgb, var(--red) 7%, var(--surface));
  --red-line: color-mix(in srgb, var(--red) 20%, transparent);
  --glow: color-mix(in srgb, var(--accent-l) 25%, transparent);
  --bg-grad: linear-gradient(160deg, color-mix(in srgb, var(--accent-l) 7%, #fff) 0%, color-mix(in srgb, var(--accent-l) 4%, #fffaf8) 35%, #fbfaf8 70%, #f8f5f2 100%);
  --side-grad: linear-gradient(175deg, color-mix(in srgb, var(--accent-l) 5%, #fff) 0%, color-mix(in srgb, var(--accent-l) 2.5%, #fff) 35%, #fffdfd 65%, #ffffff 100%);
  --card-grad: linear-gradient(135deg, color-mix(in srgb, var(--accent-l) 7%, #fff) 0%, color-mix(in srgb, var(--accent-l) 3%, #fffaf8) 50%, #ffffff 100%);
  --primary-grad: linear-gradient(145deg, color-mix(in srgb, var(--accent-l) 88%, #fff), color-mix(in srgb, var(--accent-l) 82%, #000));
  color-scheme: light;
}
:root[data-accent="indigo"] { --accent-l: #4f46e5; --accent-deep-l: #4338ca; --accent-2-l: #7c3aed; --accent-d: #8b93ff; --accent-deep-d: #c7cbff; --accent-2-d: #c084fc; }
:root[data-accent="blue"]   { --accent-l: #2563eb; --accent-deep-l: #1d4ed8; --accent-2-l: #0891b2; --accent-d: #60a5fa; --accent-deep-d: #bfdbfe; --accent-2-d: #22d3ee; }
:root[data-accent="teal"]   { --accent-l: #0d9488; --accent-deep-l: #0f766e; --accent-2-l: #059669; --accent-d: #2dd4bf; --accent-deep-d: #99f6e4; --accent-2-d: #34d399; }
:root[data-accent="violet"] { --accent-l: #7c3aed; --accent-deep-l: #6d28d9; --accent-2-l: #db2777; --accent-d: #a78bfa; --accent-deep-d: #ddd6fe; --accent-2-d: #f472b6; }
:root[data-accent="amber"]  { --accent-l: #d97706; --accent-deep-l: #b45309; --accent-2-l: #dc2626; --accent-d: #fbbf24; --accent-deep-d: #fde68a; --accent-2-d: #fb923c; }

/* Dịu (AskEZ "medium"): softer greys, less glare */
:root[data-theme="dim"] {
  --bg: #e9e8eb; --surface: #f7f8fa; --surface-2: #e9edf1; --line: #d8dce1; --line-strong: #cbd5e1;
  --ink: #242c37; --muted: #727d8b; --faint: #949eab;
  --good-soft: #e3f5eb; --good: #166534;
  --shadow: 0 12px 30px rgb(36 44 55 / 8%);
  --reader-bg: #dfe2e7;
  --red-soft: color-mix(in srgb, var(--red) 8%, var(--surface));
  --bg-grad: linear-gradient(160deg, color-mix(in srgb, var(--accent-l) 6%, #ede6e8) 0%, #ebe6e9 35%, #e7eaee 70%, #e4e7eb 100%);
  --side-grad: linear-gradient(175deg, color-mix(in srgb, var(--accent-l) 5%, #f3eff0) 0%, #f5f1f2 35%, #f6f6f8 65%, #f7f8fa 100%);
  --card-grad: linear-gradient(135deg, color-mix(in srgb, var(--accent-l) 6%, #f2ecee) 0%, #f0eaeb 50%, #f7f8fa 100%);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dim"]):not([data-theme="cosmic"]) {
    --red: var(--accent-d); --red-deep: var(--accent-deep-d); --accent-2: var(--accent-2-d);
    --gold: #f5c04a; --gold-soft: #3a3115; --gold-ink: #f5c04a;
    --bg: #11161c; --surface: #1e293b; --surface-2: #162032; --line: #2c3a50; --line-strong: #3d4d66;
    --ink: #f8fafc; --muted: #94a3b8; --faint: #6b7a90;
    --good: #4ade80; --good-soft: #14532d; --blue: #8fb3ff; --blue-soft: #1a2a48; --violet: #b99bff; --violet-soft: #2a2147;
    --shadow: 0 12px 36px rgb(0 0 0 / 28%);
    --shadow-lg: 0 20px 56px rgb(0 0 0 / 50%);
    --reader-bg: #0b0f15;
    --red-soft: color-mix(in srgb, var(--red) 18%, var(--surface));
    --red-line: color-mix(in srgb, var(--red) 32%, transparent);
    --bg-grad: linear-gradient(160deg, color-mix(in srgb, var(--accent-d) 8%, #1a1418) 0%, #161420 35%, #11161c 70%, #0e1218 100%);
    --side-grad: linear-gradient(175deg, color-mix(in srgb, var(--accent-d) 8%, #221c20) 0%, #221d26 35%, #1e1f2e 65%, #1e293b 100%);
    --card-grad: linear-gradient(135deg, color-mix(in srgb, var(--accent-d) 10%, #261d22) 0%, #251d27 50%, #1e293b 100%);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --red: var(--accent-d); --red-deep: var(--accent-deep-d); --accent-2: var(--accent-2-d);
  --gold: #f5c04a; --gold-soft: #3a3115; --gold-ink: #f5c04a;
  --bg: #11161c; --surface: #1e293b; --surface-2: #162032; --line: #2c3a50; --line-strong: #3d4d66;
  --ink: #f8fafc; --muted: #94a3b8; --faint: #6b7a90;
  --good: #4ade80; --good-soft: #14532d; --blue: #8fb3ff; --blue-soft: #1a2a48; --violet: #b99bff; --violet-soft: #2a2147;
  --shadow: 0 12px 36px rgb(0 0 0 / 28%);
  --shadow-lg: 0 20px 56px rgb(0 0 0 / 50%);
  --reader-bg: #0b0f15;
  --red-soft: color-mix(in srgb, var(--red) 18%, var(--surface));
  --red-line: color-mix(in srgb, var(--red) 32%, transparent);
  --bg-grad: linear-gradient(160deg, color-mix(in srgb, var(--accent-d) 8%, #1a1418) 0%, #161420 35%, #11161c 70%, #0e1218 100%);
  --side-grad: linear-gradient(175deg, color-mix(in srgb, var(--accent-d) 8%, #221c20) 0%, #221d26 35%, #1e1f2e 65%, #1e293b 100%);
  --card-grad: linear-gradient(135deg, color-mix(in srgb, var(--accent-d) 10%, #261d22) 0%, #251d27 50%, #1e293b 100%);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14.5px/1.55 var(--font); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
/* the open list of a <select> is drawn by the system: give it the theme's solid colours (cosmic surfaces are see-through) */
option, optgroup { background-color: var(--surface-solid, var(--surface)); color: var(--ink); }
option:checked { background-color: color-mix(in srgb, var(--red) 24%, var(--surface-solid, var(--surface))); color: var(--ink); }
a { color: inherit; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
.svg { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ------------------------------------------------------------------ shell */
.app { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.side { position: sticky; top: 0; display: flex; flex-direction: column; gap: 18px; height: 100vh; padding: 20px 14px; border-right: 1px solid var(--line); background: var(--surface); }
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px 6px; text-decoration: none; }
.brand-mark { position: relative; width: 30px; height: 22px; flex: none; }
.brand-mark::before, .brand-mark::after { position: absolute; top: 3px; width: 15px; height: 15px; border-radius: 3px; content: ""; transform: rotate(45deg); }
.brand-mark::before { left: 1px; background: #ff5a60; }
.brand-mark::after { left: 11px; background: var(--red); mix-blend-mode: multiply; }
.brand b { display: block; font-size: 15px; letter-spacing: -.01em; }
.brand small { display: block; color: var(--muted); font-size: 11.5px; }
.nav { display: grid; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 10px; color: var(--muted); font-weight: 600; text-decoration: none; }
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a.is-active { background: var(--red-soft); color: var(--red); }
.side-foot { display: grid; gap: 10px; margin-top: auto; }
.ai-state { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 12px; color: var(--muted); font-size: 12px; line-height: 1.35; }
.dot { width: 8px; height: 8px; flex: none; border-radius: 50%; background: var(--faint); }
.dot.on { background: var(--good); box-shadow: 0 0 0 3px var(--good-soft); }
.main { min-width: 0; }
.view { max-width: 1120px; margin: 0 auto; padding: 28px 32px 64px; }

/* ------------------------------------------------------------------ controls */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 38px; padding: 0 15px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); color: var(--ink); font-weight: 600; text-decoration: none; white-space: nowrap; cursor: pointer; transition: border-color .15s, background .15s, transform .1s; }
.btn:hover { border-color: var(--red-line); background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: progress; }
.btn.primary { border-color: transparent; background: linear-gradient(135deg, var(--red), var(--red-deep)); color: #fff; box-shadow: 0 6px 16px color-mix(in srgb, var(--red) 25%, transparent); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.small { height: 30px; padding: 0 10px; border-radius: 8px; font-size: 12.5px; }
.btn.icon { width: 34px; padding: 0; }
.btn.small.icon { width: 30px; }
.input, .select { height: 38px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); }
.input:focus, .select:focus, textarea:focus { border-color: var(--red); outline: none; box-shadow: 0 0 0 3px var(--red-soft); }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--surface); color: var(--muted); font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.chip:hover { color: var(--ink); border-color: var(--red-line); }
.chip.is-on { border-color: var(--red); background: var(--red-soft); color: var(--red); }
.switch { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; font-weight: 600; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch i { position: relative; width: 34px; height: 20px; border-radius: 999px; background: var(--line-strong); transition: background .15s; }
.switch i::after { position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: #fff; content: ""; transition: transform .15s; }
.switch input:checked + i { background: var(--red); }
.switch input:checked + i::after { transform: translateX(14px); }
.switch input:focus-visible + i { outline: 2px solid var(--red); outline-offset: 2px; }

/* ------------------------------------------------------------------ badges */
.badge { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 6px; background: var(--surface-2); color: var(--muted); font-size: 11.5px; font-weight: 700; white-space: nowrap; }
.badge.tier-astar { background: var(--gold-soft); color: var(--gold-ink); }
.badge.tier-q1 { background: var(--good-soft); color: var(--good); }
.badge.tier-a { background: var(--blue-soft); color: var(--blue); }
.badge.tier-wp { background: var(--violet-soft); color: var(--violet); }
.badge.oa { background: var(--red-soft); color: var(--red); }

/* ------------------------------------------------------------------ cards and lists */
.card { padding: 18px 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 30px 0 12px; }
.section-title h2 { font-size: 17px; }
.section-title a, .link { color: var(--red); font-size: 13px; font-weight: 600; text-decoration: none; cursor: pointer; background: none; border: 0; padding: 0; }
.muted { color: var(--muted); }
.empty { padding: 34px 20px; border: 1px dashed var(--line-strong); border-radius: var(--radius); color: var(--muted); text-align: center; }
.empty b { display: block; margin-bottom: 4px; color: var(--ink); font-size: 15px; }

/* ------------------------------------------------------------------ home */
.hero { position: relative; overflow: hidden; padding: 30px 30px 26px; border-radius: 22px; background: radial-gradient(60% 80% at 100% 0%, color-mix(in srgb, var(--red) 16%, transparent), transparent 70%), radial-gradient(50% 70% at 0% 100%, rgb(242 176 30 / 18%), transparent 70%), var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); }
.hero h1 { font-size: 27px; letter-spacing: -.02em; }
.hero p { max-width: 640px; margin: 6px 0 18px; color: var(--muted); }
.searchbox { display: flex; gap: 8px; max-width: 760px; }
.searchbox .input { flex: 1; height: 46px; padding: 0 16px; border-radius: 12px; font-size: 15px; }
.searchbox .btn { height: 46px; border-radius: 12px; padding: 0 20px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 18px; }
.stat { padding: 16px 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.stat small { color: var(--muted); font-size: 12.5px; font-weight: 600; }
.stat b { display: block; margin-top: 2px; font-size: 26px; letter-spacing: -.02em; }
.stat .week { display: flex; gap: 5px; margin-top: 8px; }
.stat .week i { width: 14px; height: 14px; border-radius: 4px; background: var(--surface-2); border: 1px solid var(--line); }
.stat .week i.on { background: var(--gold); border-color: transparent; }
.stat.streak b::after { content: " ngày"; color: var(--muted); font-size: 14px; font-weight: 600; letter-spacing: 0; }
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.paper-card { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; align-content: start; padding: 15px 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); text-decoration: none; transition: border-color .15s, transform .15s; }
.paper-card:hover { border-color: var(--red-line); transform: translateY(-2px); }
.paper-card b { display: -webkit-box; overflow: hidden; -webkit-line-clamp: 3; -webkit-box-orient: vertical; font-size: 14px; line-height: 1.4; }
.paper-card .meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.venues { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 12px; }
.venues h3 { margin-bottom: 8px; font-size: 13.5px; }
.venues ul { display: grid; gap: 5px; margin: 0; padding: 0; list-style: none; }
.venues li { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; }

/* ------------------------------------------------------------------ search */
.search-head { display: grid; gap: 14px; }
.search-head h1 { font-size: 22px; }
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.filters .group { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.filters .label { color: var(--faint); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; margin-right: 2px; }
.filters .select { height: 32px; padding: 0 8px; border-radius: 8px; font-size: 13px; }
.filters .sep { width: 1px; height: 22px; background: var(--line); }
.result-count { margin: 18px 2px 10px; color: var(--muted); font-size: 13px; }
.results { display: grid; gap: 10px; }
.result { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 14px; padding: 16px 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); transition: border-color .15s; }
.result:hover { border-color: var(--red-line); }
.result .meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; color: var(--muted); font-size: 12.5px; }
.result h3 { margin: 6px 0 3px; font-size: 16px; line-height: 1.35; }
.result h3 a { text-decoration: none; }
.result h3 a:hover { color: var(--red); }
.result .authors { color: var(--muted); font-size: 13px; }
.result .abstract { display: -webkit-box; overflow: hidden; margin-top: 6px; color: var(--ink); opacity: .85; font-size: 13.5px; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.result .actions { display: flex; flex-direction: column; gap: 6px; align-items: stretch; }
.more { display: flex; justify-content: center; margin-top: 16px; }
.skeleton { height: 118px; border-radius: var(--radius); background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%); background-size: 200% 100%; animation: shimmer 1.2s infinite; border: 1px solid var(--line); }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ------------------------------------------------------------------ library */
.tabs { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--line); }
.tabs button { position: relative; padding: 10px 12px; border: 0; background: none; color: var(--muted); font-weight: 600; cursor: pointer; }
.tabs button[aria-selected="true"] { color: var(--red); }
.tabs button[aria-selected="true"]::after { position: absolute; right: 8px; bottom: -1px; left: 8px; height: 2px; border-radius: 2px; background: var(--red); content: ""; }
.tabs .count { margin-left: 4px; color: var(--faint); font-size: 12px; }
.lib-list { display: grid; gap: 8px; margin-top: 14px; }
.lib-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 14px; padding: 13px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.lib-row a { font-weight: 650; text-decoration: none; }
.lib-row a:hover { color: var(--red); }
.lib-row .meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: 4px; color: var(--muted); font-size: 12.5px; }
.lib-row .meta span { display: inline-flex; align-items: center; gap: 4px; }
.lib-row .svg { width: 14px; height: 14px; }

/* ------------------------------------------------------------------ paper view */
.paper-view { display: grid; grid-template-rows: auto minmax(0, 1fr); height: 100vh; }
.paper-top { display: flex; align-items: center; gap: 12px; min-width: 0; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--surface); }
.paper-top .title { min-width: 0; flex: 1; }
.paper-top .title b { display: block; overflow: hidden; font-size: 14.5px; text-overflow: ellipsis; white-space: nowrap; }
.paper-top .title small { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.seg { display: inline-flex; padding: 3px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.seg button { height: 28px; padding: 0 10px; border: 0; border-radius: 7px; background: none; color: var(--muted); font-size: 12.5px; font-weight: 600; cursor: pointer; }
.seg button.is-on { background: var(--surface); color: var(--red); box-shadow: 0 1px 3px rgb(0 0 0 / 10%); }
.paper-body { display: grid; grid-template-columns: minmax(0, 1fr) 420px; min-height: 0; }
.paper-body.panel-closed { grid-template-columns: minmax(0, 1fr) 0; }
.paper-body.panel-closed .panel { display: none; }

.reader-wrap { position: relative; display: grid; grid-template-rows: auto minmax(0, 1fr); min-height: 0; background: var(--reader-bg); }
.reader-bar { display: flex; align-items: center; gap: 6px; padding: 6px 12px; border-bottom: 1px solid var(--line); background: var(--surface); font-size: 12.5px; }
.reader-bar .page-no { min-width: 92px; color: var(--muted); text-align: center; }
.reader { position: relative; overflow: auto; padding: 18px 18px 60px; scroll-behavior: smooth; }
.pdf-pages { display: grid; justify-items: center; gap: 14px; }
.pdf-page { position: relative; background: #fff; box-shadow: 0 2px 10px rgb(0 0 0 / 12%); }
.pdf-page canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.pdf-page .hl-layer { position: absolute; inset: 0; z-index: 1; pointer-events: none; }
.pdf-page .textLayer { z-index: 2; }
.pdf-page .page-label { position: absolute; top: 100%; right: 0; margin-top: 2px; color: var(--faint); font-size: 11px; }
.pdf-page.flash { animation: page-flash 1.6s; }
@keyframes page-flash { 0%, 60% { box-shadow: 0 0 0 4px var(--gold), 0 2px 10px rgb(0 0 0 / 12%); } }
.hl { position: absolute; border-radius: 2px; mix-blend-mode: multiply; opacity: .55; }
.hl.c-yellow { background: var(--hl-yellow); } .hl.c-green { background: var(--hl-green); } .hl.c-blue { background: var(--hl-blue); } .hl.c-pink { background: var(--hl-pink); }
.hl.has-note::after { position: absolute; top: -5px; right: -5px; width: 9px; height: 9px; border: 2px solid #fff; border-radius: 50%; background: var(--red); content: ""; }
.hl.active { opacity: .85; outline: 2px solid var(--red); }
.textLayer span.quote-flash { background: rgb(242 176 30 / 55%); border-radius: 2px; color: transparent; }
.reader-empty { display: grid; place-content: center; gap: 14px; max-width: 620px; margin: 40px auto; padding: 0 20px; }
.reader-empty .card { display: grid; gap: 12px; }
.reader-empty h2 { font-size: 18px; }
.reader-empty .abstract { max-height: 42vh; overflow: auto; color: var(--ink); font-size: 14px; line-height: 1.65; }
.dropzone { display: grid; place-items: center; gap: 4px; padding: 18px; border: 2px dashed var(--line-strong); border-radius: 12px; color: var(--muted); text-align: center; cursor: pointer; }
.dropzone.is-over, .dropzone:hover { border-color: var(--red); background: var(--red-soft); color: var(--red); }
.error-text { color: var(--red); font-size: 13px; }

.sel-bar { position: fixed; z-index: 30; display: flex; align-items: center; gap: 4px; padding: 5px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: 0 12px 30px rgb(0 0 0 / 18%); }
.swatch { width: 24px; height: 24px; border: 2px solid var(--surface); border-radius: 50%; box-shadow: 0 0 0 1px var(--line-strong); cursor: pointer; }
.swatch.c-yellow { background: var(--hl-yellow); } .swatch.c-green { background: var(--hl-green); } .swatch.c-blue { background: var(--hl-blue); } .swatch.c-pink { background: var(--hl-pink); }
.swatch.is-on { box-shadow: 0 0 0 2px var(--red); }
.sel-bar .sep { width: 1px; height: 20px; margin: 0 2px; background: var(--line); }
.popover { position: fixed; z-index: 31; display: grid; gap: 8px; width: 300px; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: 0 18px 44px rgb(0 0 0 / 22%); }
.popover blockquote { max-height: 90px; overflow: auto; margin: 0; padding-left: 10px; border-left: 3px solid var(--gold); color: var(--muted); font-size: 12.5px; }
.popover textarea { width: 100%; min-height: 70px; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); resize: vertical; }
.popover .row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

/* ------------------------------------------------------------------ side panel */
.panel { display: grid; grid-template-rows: auto minmax(0, 1fr); min-height: 0; border-left: 1px solid var(--line); background: var(--surface); }
.panel .tabs { padding: 0 10px; }
.panel-body { overflow: auto; padding: 16px 18px 40px; }
.brief { font-size: 14px; line-height: 1.65; }
.brief h2, .brief h3 { margin: 18px 0 6px; font-size: 14.5px; color: var(--red); }
.brief h2:first-child, .brief h3:first-child { margin-top: 0; }
.brief h4 { margin: 12px 0 4px; font-size: 13.5px; }
.brief p { margin: 0 0 8px; }
.brief ul, .brief ol, .md ul, .md ol { margin: 0 0 8px; padding-left: 20px; }
.brief li, .md li { margin: 3px 0; }
.brief code, .md code { padding: 1px 5px; border-radius: 5px; background: var(--surface-2); font-size: 12.5px; }
.brief blockquote, .md blockquote { margin: 0 0 8px; padding-left: 10px; border-left: 3px solid var(--line-strong); color: var(--muted); }
.cite { display: inline-flex; align-items: center; height: 19px; margin: 0 2px; padding: 0 6px; border: 0; border-radius: 5px; background: var(--gold-soft); color: #8a5a00; font-size: 11px; font-weight: 700; vertical-align: 1px; cursor: pointer; }
.cite:hover { background: var(--gold); color: #3a2600; }
.brief-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.brief-foot { margin-top: 16px; padding-top: 10px; border-top: 1px solid var(--line); color: var(--faint); font-size: 12px; }
.brief .cursor::after { display: inline-block; width: 7px; height: 15px; margin-left: 2px; background: var(--red); content: ""; vertical-align: -2px; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.callout { display: grid; gap: 10px; padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.callout b { font-size: 14.5px; }
.callout p { margin: 0; color: var(--muted); font-size: 13px; }
.callout code { padding: 1px 5px; border-radius: 5px; background: var(--surface); }
.hl-list { display: grid; gap: 8px; }
.hl-item { display: grid; gap: 4px; padding: 10px 12px; border: 1px solid var(--line); border-left-width: 4px; border-radius: 10px; cursor: pointer; }
.hl-item:hover { background: var(--surface-2); }
.hl-item.c-yellow { border-left-color: var(--hl-yellow); } .hl-item.c-green { border-left-color: var(--hl-green); } .hl-item.c-blue { border-left-color: var(--hl-blue); } .hl-item.c-pink { border-left-color: var(--hl-pink); }
.hl-item q { display: -webkit-box; overflow: hidden; font-size: 13px; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.hl-item small { color: var(--faint); font-size: 11.5px; }
.hl-item .hl-note { color: var(--muted); font-size: 12.5px; }
.note-editor { display: grid; gap: 8px; margin-top: 18px; }
.note-editor textarea { width: 100%; min-height: 220px; padding: 12px; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--surface); line-height: 1.6; resize: vertical; }
.note-editor .row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.md { padding: 12px; border: 1px solid var(--line); border-radius: 12px; font-size: 14px; }
.md h1, .md h2, .md h3 { margin: 10px 0 6px; font-size: 15px; }
.md p { margin: 0 0 8px; }
.info dl { display: grid; gap: 10px; margin: 0; }
.info dt { color: var(--faint); font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.info dd { margin: 2px 0 0; }
.info .abstract { font-size: 13.5px; line-height: 1.65; }
.cite-box { position: relative; }
.cite-box pre { margin: 0; padding: 10px 12px; overflow: auto; border-radius: 10px; background: var(--surface-2); font-family: inherit; font-size: 12px; white-space: pre-wrap; word-break: break-word; }
.cite-box .btn { position: absolute; top: 6px; right: 6px; }
.related { display: grid; gap: 6px; }
.related a { display: block; padding: 8px 10px; border-radius: 10px; text-decoration: none; font-size: 13px; }
.related a:hover { background: var(--surface-2); }
.related small { display: block; color: var(--muted); font-size: 11.5px; }

/* ------------------------------------------------------------------ sticky notes, PDF sources, TL;DR */
.btn.is-on { border-color: var(--red); background: var(--red-soft); color: var(--red); }
.reader.pin-mode .textLayer, .reader.pin-mode .textLayer span { cursor: copy; }
.pin { position: absolute; display: grid; place-items: center; width: 26px; height: 26px; margin: -2px 0 0 -2px; border-radius: 7px 7px 7px 2px; background: var(--hl-yellow); box-shadow: 0 3px 8px rgb(0 0 0 / 25%); color: #5a4300; }
.pin svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; }
.pin.c-green { background: var(--hl-green); color: #0d4a1f; } .pin.c-blue { background: var(--hl-blue); color: #0d2f66; } .pin.c-pink { background: var(--hl-pink); color: #6b0f33; }
.pin.active { outline: 2px solid var(--red); outline-offset: 2px; }
.loading-card { display: flex !important; align-items: center; gap: 14px; }
.loading-card p { margin: 2px 0 0; }
.sources { display: grid; gap: 6px; }
.source-link { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; text-decoration: none; font-size: 13.5px; }
.source-link:hover { border-color: var(--red-line); background: var(--surface-2); }
.source-link .badge { min-width: 46px; justify-content: center; }
.grow { flex: 1; min-width: 0; }
.watch { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.pulse { width: 10px; height: 10px; border-radius: 50%; background: var(--good); animation: pulse 1.6s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgb(23 128 74 / 45%); } 70% { box-shadow: 0 0 0 9px rgb(23 128 74 / 0%); } 100% { box-shadow: 0 0 0 0 rgb(23 128 74 / 0%); } }
.file-row { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 13px; }
.file-row small { display: block; color: var(--muted); font-size: 11.5px; }
.file-row b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-row.is-new { border-color: var(--good); background: var(--good-soft); animation: fade-up .3s; }
@keyframes fade-up { from { opacity: 0; transform: translateY(6px); } }
.fresh { display: grid; gap: 6px; }
.older summary { color: var(--muted); font-size: 13px; cursor: pointer; }
.older .file-row { margin-top: 6px; }
.tldr { margin-top: 6px; padding: 7px 10px; border-radius: 8px; background: var(--blue-soft); font-size: 13px; line-height: 1.5; }
.tldr b { color: var(--blue); font-size: 11.5px; letter-spacing: .03em; }
.tldr-box { margin-bottom: 14px; padding: 10px 12px; border-left: 3px solid var(--blue); border-radius: 8px; background: var(--blue-soft); font-size: 13.5px; }
.tldr-box small { color: var(--blue); font-size: 11.5px; font-weight: 700; }
.tldr-box p { margin: 3px 0 0; }

a.chip { text-decoration: none; }
.math { font-family: "Cambria Math", "Times New Roman", serif; font-style: italic; white-space: nowrap; }
.sim-summary p { margin: 0 0 4px; }

/* ------------------------------------------------------------------ navigation extras */
.nav a { position: relative; }
.nav-badge { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--red); color: #fff; font-size: 11px; font-style: normal; font-weight: 700; line-height: 20px; text-align: center; }
.bar { height: 7px; overflow: hidden; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); }
.bar i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--gold), var(--red)); transition: width .4s; }
.stat.xp .bar { margin: 8px 0 4px; }
.stat.xp b { color: var(--red); }
a.link-stat { text-decoration: none; transition: border-color .15s, transform .15s; }
a.link-stat:hover { border-color: var(--red-line); transform: translateY(-2px); }

/* ------------------------------------------------------------------ home shelves (auto-scrolling) */
.shelf { margin-top: 28px; }
.shelf-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.shelf-head h2 { font-size: 17px; }
.shelf-head p { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; }
.shelf-nav { display: flex; gap: 6px; }
.shelf-viewport { overflow-x: auto; scrollbar-width: none; mask-image: linear-gradient(90deg, transparent, #000 3%, #000 97%, transparent); }
.shelf-viewport::-webkit-scrollbar { display: none; }
.shelf-track { display: flex; gap: 12px; width: max-content; padding: 4px 2px 8px; }
.shelf-track.loading { width: auto; }
/* minmax(0, 1fr): without it the single grid column grows to the title's full width and the text overflows the card */
.shelf-card { display: grid; grid-template-columns: minmax(0, 1fr); gap: 7px; align-content: start; width: 268px; min-height: 196px; padding: 14px 15px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); text-decoration: none; transition: border-color .15s, transform .15s, box-shadow .15s; }
.shelf-card:hover, .shelf-card:focus-visible { border-color: var(--red-line); box-shadow: var(--shadow); transform: translateY(-3px); }
.shelf-card.skeleton { height: 196px; }
.shelf-card b { display: -webkit-box; overflow: hidden; -webkit-line-clamp: 3; -webkit-box-orient: vertical; font-size: 14px; line-height: 1.4; }
.shelf-card .venue { overflow: hidden; color: var(--red); font-size: 12px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.shelf-card .meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.shelf-card .meta.foot span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.shelf-card .meta .svg { width: 12px; height: 12px; }
.follow-box { margin-top: 28px; }
.follow-form { display: flex; gap: 8px; margin-top: 12px; }
.follow-form .input { flex: 1; }
.chip-x { margin-left: 2px; padding: 0 2px; border: 0; background: none; color: inherit; font-size: 15px; line-height: 1; cursor: pointer; }
.paths { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.path-card { display: grid; gap: 4px; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); text-decoration: none; transition: border-color .15s, transform .15s; }
.path-card:hover { border-color: var(--red-line); transform: translateY(-2px); }
.path-card small { color: var(--muted); font-size: 12px; }
.path-icon { display: grid; width: 34px; height: 34px; place-items: center; margin-bottom: 4px; border-radius: 10px; background: var(--red-soft); color: var(--red); }
.catalog-cta { display: flex; align-items: center; gap: 16px; margin-top: 28px; padding: 20px 22px; border: 1px solid var(--line); border-radius: 18px; background: linear-gradient(120deg, var(--red-soft), var(--gold-soft)); text-decoration: none; transition: transform .15s; }
.catalog-cta:hover { transform: translateY(-2px); }
.catalog-cta > span { display: grid; width: 48px; height: 48px; place-items: center; border-radius: 14px; background: var(--surface); color: var(--red); }
.catalog-cta div { flex: 1; }
.catalog-cta b { font-size: 17px; }
.catalog-cta p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }

/* ------------------------------------------------------------------ learning path page */
.path-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin: 10px 0 18px; }
.path-head h1 { font-size: 24px; }
.path-head p { margin: 4px 0 0; }
.path-progress { display: grid; gap: 4px; min-width: 180px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.path-progress b { font-size: 20px; }
.path-progress small { color: var(--muted); font-size: 12px; }
.timeline { display: grid; gap: 22px; margin: 0; padding: 0; list-style: none; }
.timeline > li { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 14px; }
.step-dot { display: grid; width: 36px; height: 36px; place-items: center; border-radius: 50%; background: var(--red); color: #fff; font-weight: 800; }
.step-body h2 { font-size: 17px; }
.step-body p { margin: 2px 0 10px; font-size: 13px; }

/* ------------------------------------------------------------------ paper panel: more tabs */
.panel .tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: thin; }
.panel .tabs button { flex: none; padding: 10px 8px; font-size: 13px; }
.panel-body.is-chat { display: flex; flex-direction: column; padding-bottom: 12px; }

/* chat */
.chat { display: flex; flex-direction: column; gap: 10px; min-height: 100%; }
.chat-log { display: grid; gap: 10px; align-content: start; flex: 1; }
.msg { max-width: 92%; padding: 10px 13px; border-radius: 14px; font-size: 13.8px; line-height: 1.6; }
.msg.user { justify-self: end; background: var(--red); color: #fff; border-bottom-right-radius: 4px; white-space: pre-wrap; }
.msg.ai { justify-self: start; background: var(--surface-2); border-bottom-left-radius: 4px; }
.msg.ai.error { color: var(--red); }
.msg.ai h2, .msg.ai h3 { margin-top: 8px; font-size: 13.5px; }
.chat-empty { display: grid; gap: 4px; justify-items: center; padding: 30px 10px; color: var(--muted); text-align: center; }
.chat-empty b { color: var(--ink); }
.chat-suggest { display: flex; flex-wrap: wrap; gap: 6px; }
.chat-suggest .chip { height: auto; min-height: 30px; padding: 5px 11px; white-space: normal; text-align: left; }
.chat-input { position: sticky; bottom: 0; display: flex; gap: 8px; align-items: flex-end; padding-top: 6px; background: var(--surface); }
.chat-input textarea { flex: 1; min-height: 44px; max-height: 160px; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--surface); resize: vertical; }
.chat-input .btn { height: 44px; width: 44px; }
.chat-foot { color: var(--faint); font-size: 11.5px; }
.typing { display: inline-flex; gap: 4px; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: typing 1s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }
@keyframes typing { 50% { opacity: .2; transform: translateY(-2px); } }

/* study: quiz + flashcards */
.study { display: grid; gap: 10px; }
.study-card { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; }
.study-card small { display: block; color: var(--muted); font-size: 12px; }
.card-progress { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12.5px; }
.card-progress .bar { flex: 1; }
.quiz { display: grid; gap: 12px; }
.quiz h3 { font-size: 15px; line-height: 1.45; }
.options { display: grid; gap: 8px; }
.option { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--surface); color: var(--ink); font-size: 13.5px; text-align: left; cursor: pointer; transition: border-color .15s, background .15s; }
.option span { display: grid; width: 24px; height: 24px; flex: none; place-items: center; border-radius: 7px; background: var(--surface-2); font-size: 12px; font-weight: 700; }
.option:hover:not(:disabled) { border-color: var(--red); }
.option.right { border-color: var(--good); background: var(--good-soft); }
.option.right span { background: var(--good); color: #fff; }
.option.wrong { border-color: var(--red); background: var(--red-soft); }
.option.wrong span { background: var(--red); color: #fff; }
.option:disabled { cursor: default; }
.feedback { margin-bottom: 10px; padding: 10px 12px; border-radius: 10px; font-size: 13px; }
.feedback.good { background: var(--good-soft); } .feedback.bad { background: var(--red-soft); }
.quiz-result { display: grid; gap: 10px; justify-items: center; text-align: center; }
.score-ring { display: grid; width: 110px; height: 110px; place-items: center; border-radius: 50%; background: conic-gradient(var(--good) calc(var(--p) * 1%), var(--surface-2) 0); }
.score-ring b { display: grid; width: 84px; height: 84px; place-items: center; border-radius: 50%; background: var(--surface); font-size: 22px; }
.quiz-review { display: grid; gap: 6px; width: 100%; margin: 6px 0; padding-left: 20px; text-align: left; font-size: 13px; }
.quiz-review li.ok::marker { color: var(--good); } .quiz-review li.miss::marker { color: var(--red); }
.quiz-review small { display: block; color: var(--muted); }
.flashcard { position: relative; display: block; width: 100%; min-height: 180px; margin: 10px 0; padding: 0; border: 0; background: none; perspective: 1000px; cursor: pointer; }
.flashcard .face { position: absolute; inset: 0; display: grid; place-content: center; gap: 8px; padding: 18px; border: 1px solid var(--line-strong); border-radius: 16px; backface-visibility: hidden; color: var(--ink); font-size: 15px; font-weight: 600; line-height: 1.5; text-align: center; transition: transform .45s; }
.flashcard .front { background: linear-gradient(160deg, var(--surface), var(--red-soft)); }
.flashcard .back { background: linear-gradient(160deg, var(--surface), var(--gold-soft)); transform: rotateY(180deg); font-weight: 500; }
.flashcard.flipped .front { transform: rotateY(-180deg); } .flashcard.flipped .back { transform: rotateY(0); }
.flashcard small { color: var(--muted); font-size: 11.5px; font-weight: 500; }
.grades { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.btn.bad { border-color: var(--red-line); color: var(--red); } .btn.good { border-color: var(--good); color: var(--good); }
.done-box { display: grid; gap: 4px; justify-items: center; padding: 28px; color: var(--good); text-align: center; }
.done-box b { color: var(--ink); font-size: 16px; }
.card-paper { display: block; margin-top: 8px; overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.view.narrow { max-width: 720px; }
.review-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.review-head h1 { font-size: 22px; }
.xp-card { display: grid; gap: 4px; min-width: 200px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.xp-card small { color: var(--muted); font-size: 12px; } .xp-card b { color: var(--red); font-size: 18px; }
.review-box { padding: 18px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); }
.review-box .flashcard { min-height: 240px; }

/* simulation */
.sim { display: grid; gap: 8px; }
.sim h3 { font-size: 15px; }
.sim p { margin: 0; font-size: 13px; }
.sim-y { color: var(--muted); font-size: 11.5px; font-weight: 700; }
.sim-chart { width: 100%; height: auto; overflow: visible; }
.sim-chart text { fill: var(--muted); font-size: 10px; }
.sim-chart .axis { fill: var(--ink); font-size: 11px; font-weight: 600; }
.sim-chart .grid { stroke: var(--line); stroke-width: 1; }
.sim-chart .lines path { fill: none; stroke-width: 2.4; stroke-linejoin: round; stroke-linecap: round; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 3px; border-radius: 2px; }
.sliders { display: grid; gap: 10px; padding: 12px; border-radius: 12px; background: var(--surface-2); }
.slider { display: grid; gap: 4px; font-size: 12.5px; }
.slider span { display: flex; justify-content: space-between; gap: 8px; }
.slider b { color: var(--red); }
.slider input { width: 100%; accent-color: var(--red); }
.insights { padding: 10px 12px; border-left: 3px solid var(--gold); border-radius: 8px; background: var(--gold-soft); font-size: 13px; }
.insights ul { margin: 4px 0 0; padding-left: 18px; }
.formula summary { color: var(--muted); font-size: 12px; cursor: pointer; }
.formula code { display: block; margin-top: 6px; padding: 6px 8px; overflow-x: auto; border-radius: 8px; background: var(--surface-2); font-size: 12px; }

/* compare */
.pick-list { display: grid; gap: 6px; max-height: 360px; overflow: auto; padding: 4px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.pick { display: flex; align-items: flex-start; gap: 10px; padding: 9px 10px; border-radius: 10px; cursor: pointer; }
.pick:hover { background: var(--surface-2); }
.pick input { margin-top: 3px; accent-color: var(--red); }
.pick b { display: block; font-size: 13.5px; }
.pick small { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.compare-bar { position: sticky; bottom: 0; display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 10px 0 16px; padding: 10px 0; background: var(--bg); }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.compare-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.compare-table th, .compare-table td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.compare-table thead th { min-width: 200px; background: var(--surface-2); }
.compare-table thead th a { display: block; margin-bottom: 4px; font-weight: 700; text-decoration: none; }
.compare-table tbody th { width: 150px; color: var(--red); font-size: 12.5px; white-space: nowrap; }
.compare-notes { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.compare-notes h3 { margin-bottom: 6px; font-size: 14px; }
.compare-notes p { margin: 0; font-size: 13.5px; }

/* citation map */
.graph-dialog { width: min(1080px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: 0; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); color: var(--ink); box-shadow: 0 30px 80px rgb(0 0 0 / 30%); }
.graph-dialog::backdrop { background: rgb(8 10 20 / 45%); backdrop-filter: blur(3px); }
.graph-head { position: sticky; top: 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--surface); }
.graph-head small { display: block; overflow: hidden; max-width: 860px; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.graph-body { padding: 10px 16px 18px; }
.graph-legend { display: flex; justify-content: space-between; color: var(--muted); font-size: 12.5px; font-weight: 600; }
.graph-svg { width: 100%; height: auto; }
.graph-svg .edge { fill: none; stroke: var(--line-strong); stroke-width: 1.2; }
.graph-svg .node circle { fill: var(--blue); opacity: .85; }
.graph-svg .node.right circle { fill: var(--red); }
.graph-svg .node text { fill: var(--ink); font-size: 11.5px; }
.graph-svg .node:hover text { fill: var(--red); text-decoration: underline; }
.graph-svg .sub { fill: var(--muted) !important; font-size: 10px !important; }
.graph-svg .center { fill: var(--gold); stroke: var(--surface); stroke-width: 3; }
.graph-svg .center-text { fill: #3a2600; font-size: 11px; font-weight: 700; }

@media (max-width: 520px) {
  .side .brand > span:last-child { display: none; }
  .nav a { padding: 9px 8px; }
}
@media (max-width: 860px) {
  .compare-notes { grid-template-columns: 1fr; }
  .path-head, .review-head { flex-direction: column; align-items: stretch; }
  .nav-badge { position: absolute; top: 2px; right: 0; min-width: 16px; height: 16px; padding: 0 4px; font-size: 10px; line-height: 16px; }
  .shelf-card { width: 230px; }
}

/* ------------------------------------------------------------------ sign-in */
.login-page { display: grid; min-height: 100vh; place-items: center; padding: 16px; background: radial-gradient(60% 60% at 100% 0%, color-mix(in srgb, var(--red) 14%, transparent), transparent 70%), radial-gradient(50% 60% at 0% 100%, rgb(242 176 30 / 16%), transparent 70%), var(--bg); }
.login-card { display: grid; gap: 14px; width: min(420px, 100%); padding: 30px 28px; border: 1px solid var(--line); border-radius: 22px; background: var(--surface); box-shadow: var(--shadow); }
.login-card .brand { padding: 0; }
.login-card h1 { margin-top: 8px; font-size: 22px; letter-spacing: -.01em; }
.login-card p { margin: 0; }
.btn.google { height: 46px; border-radius: 12px; font-size: 15px; }
.user-chip { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 9px 10px; border: 1px solid var(--line); border-radius: 14px; font-size: 12.5px; }
.user-chip:empty { display: none; }
.user-chip img, .user-chip .avatar { width: 34px; height: 34px; flex: none; border-radius: 50%; background: var(--red-soft); color: var(--red); display: grid; place-items: center; font-weight: 700; object-fit: cover; }
.user-chip .who { display: flex; align-items: center; gap: 6px; min-width: 0; }
.user-chip b { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; }
.user-chip .sub { display: flex; flex-wrap: wrap; gap: 2px 8px; margin-top: 2px; }
.user-chip .sub a { color: var(--muted); font-size: 11.5px; text-decoration: none; }
.user-chip .sub a:hover { color: var(--text); text-decoration: underline; }
.user-chip .sub .xp-line { color: var(--red); font-weight: 700; }
.user-chip .sub .ai-left { color: var(--gold-ink); font-weight: 700; }
/* the reading streak: one small flame beside the name, grey until the first day */
.streak-flame { display: inline-flex; align-items: center; gap: 2px; flex: none; color: var(--muted); font-size: 12.5px; font-weight: 800;
  text-decoration: none; opacity: .65; }
.streak-flame .svg { width: 15px; height: 15px; }
.streak-flame.lit { color: var(--gold); opacity: 1; }
.streak-flame.lit .svg { filter: drop-shadow(0 0 4px rgb(255 170 60 / 55%)); animation: flicker 2.4s ease-in-out infinite; transform-origin: 50% 90%; }
@keyframes flicker { 0%, 100% { transform: scale(1) rotate(0); } 30% { transform: scale(1.08, 1.12) rotate(-3deg); } 60% { transform: scale(.96, 1.04) rotate(2deg); } }
@media (prefers-reduced-motion: reduce) { .streak-flame.lit .svg { animation: none; } }

/* ------------------------------------------------------------------ toast, spinner */
.toast { position: fixed; z-index: 50; bottom: 22px; left: 50%; max-width: min(560px, calc(100vw - 32px)); padding: 11px 16px; border-radius: 12px; background: #231819; color: #fff; box-shadow: 0 14px 34px rgb(0 0 0 / 25%); font-size: 13.5px; transform: translateX(-50%); animation: toast-in .25s; }
.toast.bad { background: #8f0f15; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 10px); } }
.spin { width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------------ responsive */
@media (max-width: 1100px) {
  .paper-body { grid-template-columns: minmax(0, 1fr) 360px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .venues { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .side { position: sticky; z-index: 20; flex-direction: row; align-items: center; height: auto; padding: 8px 12px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand small, .side-foot { display: none; }
  .nav { display: flex; margin-left: auto; }
  .nav a span { display: none; }
  .view { padding: 18px 16px 48px; }
  .paper-view { height: calc(100vh - 55px); }
  .paper-body, .paper-body.panel-closed { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }
  .panel { max-height: 45vh; border-left: 0; border-top: 1px solid var(--line); }
  .paper-top { gap: 8px; padding: 8px 10px; }
  .paper-top .seg, #pdfHint, #zoomFit { display: none; }
  .paper-top .title small { flex-wrap: nowrap; overflow: hidden; white-space: nowrap; }
  .paper-top .title small span { white-space: nowrap; }
  .paper-top .btn.small:not(.icon) { width: 30px; padding: 0; font-size: 0; gap: 0; }
  .reader-bar { padding: 6px 8px; }
  .reader-bar .page-no { min-width: 0; white-space: nowrap; }
  .result { grid-template-columns: minmax(0, 1fr); }
  .result .actions { flex-direction: row; }
  .hero { padding: 22px 18px; }
  .searchbox { flex-direction: column; }
  .searchbox .input { flex: none; }
}

/* ------------------------------------------------------------------ drawing on the PDF */
.pdf-page .draw-layer { position: absolute; inset: 0; z-index: 3; pointer-events: none; }
.reader.drawing .draw-layer { pointer-events: auto; cursor: crosshair; touch-action: none; }
.reader.drawing[data-tool="text"] .draw-layer { cursor: text; }
.reader.drawing[data-tool="pin"] .draw-layer { cursor: copy; }
.reader.drawing .textLayer { pointer-events: none; }
.shape-layer { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.shape-layer.preview { opacity: .75; }
.text-box { position: absolute; padding: 0 2px; line-height: 1.3; font-family: Helvetica, Arial, sans-serif; white-space: pre-wrap; overflow-wrap: anywhere; }
.text-box.c-red { color: #e5232a; } .text-box.c-blue { color: #2f6fe0; } .text-box.c-green { color: #1f9d55; }
.text-box.c-black { color: #222; } .text-box.c-yellow { color: #b07c00; } .text-box.c-pink { color: #e8457f; }
.text-box.active { outline: 2px dashed var(--red); outline-offset: 2px; }
.tools { display: inline-flex; align-items: center; gap: 2px; padding: 2px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.tool { display: grid; place-items: center; width: 30px; height: 28px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; }
.tool:hover { background: var(--surface); color: var(--ink); }
.tool.is-on { background: var(--surface); color: var(--red); box-shadow: 0 1px 3px rgb(0 0 0 / 12%); }
.tool-sep { width: 1px; height: 18px; margin: 0 4px; background: var(--line-strong); }
.ink-dot { width: 18px; height: 18px; margin: 0 1px; padding: 0; border: 2px solid var(--surface); border-radius: 50%; background: var(--ink); cursor: pointer; box-shadow: 0 0 0 1px var(--line-strong); }
.ink-dot.is-on { box-shadow: 0 0 0 2px var(--ink); }
.width-select { height: 28px; margin-left: 4px; padding: 0 6px; font-size: 12px; }
.ai-range { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border: 1px dashed var(--red-line); border-radius: 10px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.ai-range .input { width: 62px; height: 26px; padding: 0 6px; font-size: 12px; }
.menu { position: relative; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-list { position: absolute; right: 0; top: calc(100% + 6px); z-index: 40; display: grid; gap: 2px; min-width: 300px; padding: 6px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: 0 18px 44px rgb(0 0 0 / 18%); }
.menu-list a { display: flex; align-items: flex-start; gap: 10px; padding: 9px 10px; border-radius: 9px; text-decoration: none; }
.menu-list a:hover { background: var(--surface-2); }
.menu-list a small { display: block; color: var(--muted); font-size: 11.5px; }
.menu-list.folders { min-width: 360px; padding: 10px; font-size: 12px; }
.menu-list.folders code { overflow-wrap: anywhere; }

/* ------------------------------------------------------------------ mind map / infographic */
.mindmap { display: grid; gap: 16px; }
.mm-hero { padding: 16px; border-radius: 14px; background: linear-gradient(135deg, var(--red-soft), var(--gold-soft)); }
.mm-hero h3 { font-size: 17px; }
.mm-hero p { margin: 6px 0 0; font-size: 14px; }
.mm-numbers { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.mm-number { display: grid; gap: 2px; align-content: start; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.mm-number b { color: var(--red); font-size: 20px; line-height: 1.2; overflow-wrap: anywhere; }
.mm-number span { color: var(--muted); font-size: 12px; }
.mm-number .cite { justify-self: start; }
.mm-section { display: grid; gap: 8px; }
.mm-section h4 { display: flex; align-items: center; gap: 6px; font-size: 14px; }
.mm-pipeline { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.mm-pipeline li { position: relative; display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; }
.mm-pipeline li span { display: grid; place-items: center; width: 24px; height: 24px; flex: none; border-radius: 50%; background: var(--red); color: #fff; font-size: 12px; font-weight: 800; }
.mm-pipeline li:not(:last-child)::after { position: absolute; left: 11px; top: 26px; bottom: -6px; width: 2px; background: var(--red-line); content: ""; }
.mm-branch { border: 1px solid var(--line); border-left: 4px solid var(--c); border-radius: 10px; background: var(--surface); }
.mm-branch summary { display: flex; align-items: center; gap: 8px; padding: 8px 12px; font-weight: 700; cursor: pointer; }
.mm-branch summary i { width: 10px; height: 10px; flex: none; border-radius: 50%; background: var(--c); }
.mm-branch summary small { margin-left: auto; color: var(--muted); font-size: 11px; font-weight: 600; }
.mm-branch ul { margin: 0; padding: 0 14px 10px 34px; font-size: 13px; }
.mm-branch li { margin: 3px 0; }
.new-problems { padding: 14px; border: 1px solid var(--red-line); border-radius: 14px; background: var(--red-soft); }
.new-problems h4 { color: var(--red); }
.problem-card { display: grid; gap: 6px; padding: 12px; border-radius: 10px; background: var(--surface); }
.problem-card dl, .pick dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 10px; margin: 0; font-size: 13px; }
.problem-card dt, .pick dt { color: var(--muted); font-weight: 700; }
.problem-card dd, .pick dd { margin: 0; }
.mm-canvas { overflow: auto; }
.mm-canvas svg { display: block; max-width: 100%; height: auto; margin: 0 auto; border-radius: 12px; }

/* ------------------------------------------------------------------ books */
.books-head, .search-title { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.search-title { align-items: center; margin-bottom: 10px; }
.books-head h1 { font-size: 22px; }
.books-head p { margin: 4px 0 0; }
.scan-box { display: flex; align-items: center; gap: 8px; }
.book-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 18px 14px; }
.book-card { position: relative; display: grid; align-content: start; gap: 4px; min-width: 0; text-decoration: none; }
.book-card .cover { position: relative; display: grid; place-items: center; aspect-ratio: 3 / 4; overflow: hidden; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: linear-gradient(160deg, var(--red-soft), var(--surface-2)); box-shadow: var(--shadow); color: var(--muted); font-size: 12px; font-weight: 700; text-align: center; transition: transform .15s; }
.book-card .cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.book-card:hover .cover { transform: translateY(-3px); }
.book-card b { display: -webkit-box; overflow: hidden; font-size: 13px; line-height: 1.35; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.book-card small { overflow: hidden; color: var(--muted); font-size: 11.5px; text-overflow: ellipsis; white-space: nowrap; }
.book-card small.folder { color: var(--faint); }
.hide-book { position: absolute; top: 6px; right: 6px; display: none; width: 24px; height: 24px; border: 0; border-radius: 50%; background: rgb(0 0 0 / 55%); color: #fff; cursor: pointer; }
.book-card:hover .hide-book, .hide-book:focus-visible { display: block; }

/* ------------------------------------------------------------------ research assistant */
.research-head h1 { font-size: 22px; }
.research-head p { max-width: 760px; margin: 6px 0 14px; }
.research-form { display: grid; gap: 10px; margin-bottom: 20px; }
.research-form textarea { width: 100%; height: auto; padding: 12px 14px; line-height: 1.5; resize: vertical; }
.research-layout { display: grid; grid-template-columns: minmax(0, 1fr) 240px; gap: 24px; align-items: start; }
.research-history { position: sticky; top: 16px; display: grid; gap: 8px; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.history-item { display: grid; gap: 2px; padding-bottom: 8px; border-bottom: 1px solid var(--line); font-size: 13px; }
.history-item .link { text-align: left; }
.history-item small { color: var(--faint); font-size: 11px; }
.progress-steps { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.progress-steps li { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13.5px; }
.progress-steps li.ok { color: var(--good); }
.progress-steps li.ok .spin { display: none; }
.progress-steps li.ok::before { content: "\2713"; font-weight: 800; }
.session { display: grid; gap: 14px; }
.session h3 { margin-top: 8px; font-size: 16px; }
.picks { display: grid; gap: 10px; }
.pick { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 12px; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); scroll-margin-top: 80px; }
.pick-num { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--red); color: #fff; font-weight: 800; }
.pick h4 { margin: 6px 0 2px; font-size: 15px; }
.pick h4 a { text-decoration: none; }
.pick h4 a:hover { color: var(--red); }
.pick .meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.pick .authors { margin-bottom: 8px; color: var(--muted); font-size: 12.5px; }
.pick .actions { display: flex; gap: 8px; margin-top: 10px; }
.build-steps { display: grid; gap: 10px; margin: 0; padding-left: 22px; }
.build-steps p { margin: 4px 0 0; color: var(--muted); font-size: 13.5px; }
.ref { color: var(--red); font-size: 12px; font-weight: 700; text-decoration: none; }
.gap-list { margin: 0; padding-left: 20px; font-size: 13.5px; }
.gap-list li { margin: 4px 0; }

/* ------------------------------------------------------------------ authors */
.segmented { display: inline-flex; padding: 3px; border-radius: 10px; background: var(--surface-2); }
.segmented button { height: 30px; padding: 0 14px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-weight: 600; cursor: pointer; }
.segmented button.is-on { background: var(--surface); color: var(--red); box-shadow: 0 1px 3px rgb(0 0 0 / 12%); }
.people { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 16px; }
.people .label { color: var(--muted); font-size: 12px; font-weight: 700; }
.person { display: flex; align-items: center; gap: 8px; max-width: 320px; padding: 6px 12px 6px 6px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); text-decoration: none; }
.person:hover { border-color: var(--red); }
.person b { display: block; font-size: 13px; }
.person small { display: block; overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.person .avatar, .avatar.big { display: grid; place-items: center; width: 30px; height: 30px; flex: none; border-radius: 50%; background: var(--red); color: #fff; font-weight: 800; }
.avatar.big { width: 56px; height: 56px; font-size: 24px; }
.author-head { display: flex; gap: 16px; align-items: flex-start; margin: 14px 0 18px; }
.author-head h1 { font-size: 22px; }
.author-head p { margin: 2px 0 6px; }
.author-head .meta { display: flex; flex-wrap: wrap; gap: 6px; color: var(--muted); font-size: 13px; }
.result.compact { padding: 12px 16px; }

@media (max-width: 900px) {
  .research-layout { grid-template-columns: 1fr; }
  .research-history { position: static; }
  .book-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
}
.reader-wrap { min-width: 0; }
.reader-bar { flex-wrap: wrap; row-gap: 6px; }
.reader-bar .tools { flex-wrap: wrap; }

/* ------------------------------------------------------------------ interactive mind map */
.mm-open { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 2px 12px; align-items: center; width: 100%; padding: 12px 14px; border: 1px dashed var(--red-line); border-radius: 12px; background: var(--surface); color: var(--ink); text-align: left; cursor: pointer; }
.mm-open:hover { border-style: solid; border-color: var(--red); background: var(--red-soft); }
.mm-open > span { grid-row: span 2; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; background: var(--red); color: #fff; }
.mm-open small { color: var(--muted); font-size: 12px; }
.mapview { width: calc(100vw - 24px); max-width: none; height: calc(100vh - 24px); max-height: none; padding: 0; border: 1px solid var(--line); border-radius: 16px; background: var(--bg); color: var(--ink); overflow: hidden; }
.mapview[open] { display: grid; grid-template-rows: auto minmax(0, 1fr); }
.mapview::backdrop { background: rgb(8 10 20 / 55%); backdrop-filter: blur(3px); }
.mv-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--surface); }
.mv-title { display: grid; min-width: 0; flex: 1 1 200px; }
.mv-title small { overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.mv-search { width: 200px; height: 32px; }
.mv-group { display: inline-flex; align-items: center; gap: 4px; }
.mv-zoom { min-width: 44px; color: var(--muted); font-size: 12px; text-align: center; }
.mv-saved { min-width: 56px; font-size: 12px; }
.mv-stage { position: relative; overflow: hidden; outline: none; background:
  radial-gradient(circle, var(--line) 1px, transparent 1.2px) 0 0 / 22px 22px, var(--bg); cursor: grab; }
.mv-stage.panning { cursor: grabbing; }
.mv-svg { display: block; width: 100%; height: 100%; font-family: "Segoe UI", Roboto, Arial, sans-serif; user-select: none; touch-action: none; }
.mv-node { cursor: pointer; transition: transform .28s ease, opacity .2s; }
.mv-node:hover .mm-box { filter: brightness(1.06) drop-shadow(0 2px 6px rgb(0 0 0 / 15%)); }
.mv-node.dim { opacity: .28; }
.mv-edge { fill: none; opacity: .65; transition: d .28s ease; }
.mm-page, .mm-fold { cursor: pointer; }
.mm-page:hover rect { filter: brightness(.92); }
.mm-fold:hover circle { stroke-width: 2.6; }
.mv-tools { position: absolute; z-index: 3; display: flex; flex-wrap: wrap; align-items: center; gap: 4px; max-width: 520px; padding: 6px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: 0 10px 30px rgb(0 0 0 / 18%); }
.mv-tools small { padding: 0 6px; font-size: 11.5px; }
.mv-edit { position: absolute; z-index: 4; min-height: 54px; padding: 8px 10px; border: 2px solid var(--gold); border-radius: 10px; background: var(--surface); color: var(--ink); font: 13px/1.4 "Segoe UI", Roboto, Arial, sans-serif; resize: both; box-shadow: 0 10px 30px rgb(0 0 0 / 20%); }
.mv-help { position: absolute; left: 12px; right: 12px; bottom: 10px; font-size: 11.5px; text-align: center; pointer-events: none; }
.mv-help kbd { padding: 0 4px; border: 1px solid var(--line-strong); border-radius: 4px; background: var(--surface); font-size: 10.5px; }
.mm-branch ul ul { padding-left: 18px; }

/* ------------------------------------------------------------------ local catalogue */
.catalog-card { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin: 0 0 16px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); font-size: 13px; }
.catalog-card b { font-size: 14px; }
.catalog-card .grow { flex: 1 1 260px; color: var(--muted); }
.catalog-card .bar { width: 160px; height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.catalog-card .bar i { display: block; height: 100%; background: var(--red); }
.badge.local { background: var(--blue-soft); color: var(--blue); }
.mv-viewport.gliding { transition: transform .3s ease; }
.mv-viewport { transform-origin: 0 0; }

/* ------------------------------------------------------------------ uploads */
.drop-zone { display: flex; align-items: center; gap: 14px; margin: 0 0 16px; padding: 14px 16px; border: 2px dashed var(--line-strong); border-radius: 14px; background: var(--surface); color: var(--muted); cursor: pointer; transition: border-color .15s, background .15s; }
.drop-zone:hover, .drop-zone.over { border-color: var(--red); background: var(--red-soft); color: var(--red); }
.drop-zone b { display: block; color: var(--ink); font-size: 14px; }
.drop-zone small { display: block; font-size: 12px; }
.upload-badge { position: absolute; top: 6px; left: 6px; background: var(--blue-soft); color: var(--blue); }
body.drop-ready::after { position: fixed; inset: 12px; z-index: 100; display: grid; place-items: center; border: 3px dashed var(--red); border-radius: 20px; background: color-mix(in srgb, var(--red) 8%, transparent); color: var(--red); font-size: 20px; font-weight: 800; content: "Thả PDF vào đây để thêm vào Sách & tài liệu"; pointer-events: none; backdrop-filter: blur(2px); }
.shelf-nav { display: flex; align-items: center; gap: 6px; }

/* tabs: icon and label on one line, the same stroke for every icon */
.tabs button { display: inline-flex; align-items: center; gap: 6px; line-height: 1.2; }
.tabs button .svg { width: 16px !important; height: 16px !important; stroke-width: 1.8; }
.tabs button[aria-selected="true"] .svg { stroke-width: 2; }

/* ------------------------------------------------------------------ translation */
.translate { display: grid; gap: 10px; }
.tr-bar { position: sticky; top: -16px; z-index: 2; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: -4px 0 0; padding: 6px 0; background: var(--surface); border-bottom: 1px solid var(--line); }
.tr-page { min-width: 92px; font-size: 13px; text-align: center; }
.tr-body { font-size: 14.5px; line-height: 1.7; }
.tr-body p { margin: 0 0 12px; }
.tr-body h4 { margin: 14px 0 8px; font-size: 15px; }
.tr-formula { overflow-x: auto; margin: 0 0 12px; padding: 8px 10px; border-radius: 8px; background: var(--surface-2); font: 13px/1.5 Consolas, "Cascadia Mono", monospace; white-space: pre-wrap; }
.tr-caption { color: var(--muted); font-size: 13px; font-style: italic; }
.tr-list { padding-left: 10px; border-left: 3px solid var(--line-strong); }
.tr-wait { display: flex; align-items: center; gap: 10px; padding: 18px 0; color: var(--muted); }
.tr-terms { display: grid; gap: 6px; margin: 6px 0 4px; padding-top: 10px; border-top: 1px dashed var(--line-strong); }
.tr-term { height: auto; min-height: 28px; padding: 4px 10px; white-space: normal; text-align: left; }
.tr-term span { color: var(--red); font-weight: 800; }
.tr-pop { width: 380px; max-height: 60vh; overflow: auto; }
.tr-pop-text { margin: 0; font-size: 14px; line-height: 1.6; }
.gl-form { display: grid; grid-template-columns: 1fr 1.4fr auto; gap: 8px; margin-bottom: 12px; }
.gl-list { display: grid; gap: 4px; max-height: 55vh; overflow: auto; }
.gl-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) auto; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 8px; }
.gl-row:nth-child(odd) { background: var(--surface-2); }
.glossary { width: min(720px, calc(100vw - 32px)); }

/* ------------------------------------------------------------------ morning digest */
.digest { margin: 18px 0 4px; padding: 18px 20px; border: 1px solid var(--line); border-radius: var(--radius); background:
  linear-gradient(120deg, var(--gold-soft), transparent 55%), var(--surface); box-shadow: var(--shadow); }
.digest:empty { display: none; }
.dg-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.dg-kicker { display: inline-flex; align-items: center; gap: 6px; color: var(--gold-ink); font-size: 12.5px; font-weight: 800; letter-spacing: .02em; text-transform: uppercase; }
.dg-tools { display: inline-flex; align-items: center; gap: 6px; }
.dg-days { height: 30px; font-size: 12.5px; }
.dg-title { margin: 8px 0 4px; font-size: 20px; }
.dg-intro { margin: 0 0 12px; color: var(--muted); max-width: 900px; }
.dg-wait { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.dg-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; margin: 0; padding: 0; list-style: none; counter-reset: dg; }
.dg-item { position: relative; display: grid; gap: 5px; height: 100%; padding: 12px 14px 12px 40px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); text-decoration: none; transition: border-color .15s, transform .15s; }
.dg-item:hover { border-color: var(--red-line); transform: translateY(-2px); }
.dg-items li { counter-increment: dg; }
.dg-item::before { position: absolute; top: 12px; left: 12px; display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--red); color: #fff; font-size: 11px; font-weight: 800; content: counter(dg); }
.dg-tag { justify-self: start; padding: 1px 8px; border-radius: 6px; background: var(--red-soft); color: var(--red); font-size: 11px; font-weight: 700; }
.dg-item b { font-size: 14px; line-height: 1.35; }
.dg-item small { color: var(--faint); font-size: 11.5px; }
.dg-sum { color: var(--ink); font-size: 13px; line-height: 1.5; }
.dg-why { color: var(--muted); font-size: 12.5px; font-style: italic; }
.dg-why .svg { width: 12px; height: 12px; vertical-align: -1px; }
.digest.folded .dg-intro, .digest.folded .dg-items, .digest.folded .brief-foot { display: none; }
.digest.folded [data-dg="fold"] .svg { transform: rotate(-90deg); }
.digest:not(.folded) [data-dg="fold"] .svg { transform: rotate(90deg); }

.profile-form { display: grid; gap: 6px; margin-bottom: 16px; padding-bottom: 16px; border-bottom: 1px dashed var(--line-strong); }
.profile-form label b { display: block; font-size: 15px; }
.profile-form label small { color: var(--muted); font-size: 12.5px; }
.profile-form textarea { width: 100%; height: auto; padding: 10px 12px; line-height: 1.5; resize: vertical; }

/* ------------------------------------------------------------------ theme polish (overrides earlier rules) */
h1, h2, h3 { letter-spacing: -.018em; }
::selection { background: color-mix(in srgb, var(--red) 25%, transparent); }
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }

.side { background: color-mix(in srgb, var(--surface) 82%, transparent); backdrop-filter: blur(14px); }
.brand-mark::before { background: color-mix(in srgb, var(--accent-l) 72%, #fff); }
.brand b { font-size: 15.5px; font-weight: 800; }
.nav a { position: relative; border-radius: 11px; transition: background .15s, color .15s; }
.nav a.is-active { background: var(--red-soft); color: var(--red); }
.nav a.is-active::before { position: absolute; left: -14px; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0; background: var(--red); content: ""; }

.btn { border-radius: 11px; }
.btn.small { border-radius: 9px; }
.input, .select { border-radius: 11px; transition: border-color .15s, box-shadow .15s; }
.input:focus, .select:focus, textarea:focus { box-shadow: 0 0 0 4px color-mix(in srgb, var(--red) 16%, transparent); }
.chip { transition: border-color .15s, color .15s, background .15s; }
.chip.is-on { background: var(--red-soft); }

.hero { border-radius: 22px; background:
  radial-gradient(60% 80% at 100% 0%, color-mix(in srgb, var(--red) 16%, transparent), transparent 70%),
  radial-gradient(50% 70% at 0% 100%, color-mix(in srgb, var(--gold) 18%, transparent), transparent 70%),
  var(--surface); }
.hero h1 { font-size: 30px; font-weight: 800; }
.hero h1 em { font-style: normal; color: var(--red); }
.searchbox .input { height: 50px; border-radius: 14px; font-size: 15.5px; box-shadow: var(--shadow); }
.searchbox .btn { height: 50px; border-radius: 14px; }

.card, .stat, .paper-card, .shelf-card, .result, .digest, .follow-box { border-radius: var(--radius); }
.paper-card:hover, .shelf-card:hover, .result:hover { box-shadow: var(--shadow-lg); }
.stat { box-shadow: var(--shadow); }
.badge.tier-astar { color: var(--gold-ink); }
.cite { color: var(--gold-ink); }
.dg-kicker { color: var(--gold-ink); }
.graph-dialog, .mapview, .popover, .menu-list, .sel-bar { box-shadow: var(--shadow-lg); }

/* theme picker in the sidebar */
.theme-box { display: grid; gap: 8px; padding: 10px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.theme-box .seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; padding: 3px; border-radius: 10px; background: var(--surface-2); }
.theme-box .seg button { display: grid; place-items: center; height: 28px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; }
.theme-box .seg button[aria-pressed="true"] { background: var(--surface); color: var(--red); box-shadow: 0 1px 3px rgb(0 0 0 / 15%); }
.theme-box .accents { display: flex; justify-content: space-between; padding: 0 2px; }
.theme-box .accents button { width: 20px; height: 20px; padding: 0; border: 2px solid var(--surface); border-radius: 50%; background: var(--sw); box-shadow: 0 0 0 1px var(--line-strong); cursor: pointer; }
.theme-box .accents button[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--sw); }
.theme-box small { color: var(--faint); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }

/* universal search: suggestions under the search box */
.omni { position: relative; flex: 1; min-width: 0; }
.omni .input { width: 100%; }
.omni-panel { position: absolute; top: calc(100% + 8px); left: 0; right: 0; z-index: 50; display: grid; gap: 2px; max-height: min(70vh, 560px); overflow: auto; padding: 8px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: var(--shadow-lg); }
.omni-panel h5 { margin: 8px 8px 4px; color: var(--faint); font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
.omni-item { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 10px; align-items: center; padding: 8px 10px; border-radius: 10px; color: var(--ink); text-decoration: none; cursor: pointer; }
.omni-item:hover, .omni-item.is-on { background: var(--red-soft); }
.omni-item .ic { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: var(--surface-2); color: var(--red); }
.omni-item b { display: block; overflow: hidden; font-size: 13.5px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.omni-item small { display: block; overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.omni-item mark { background: color-mix(in srgb, var(--red) 18%, transparent); color: inherit; border-radius: 3px; }
.omni-foot { padding: 8px 10px 4px; color: var(--faint); font-size: 11.5px; }
.match-strip { display: grid; gap: 10px; margin: 16px 0 4px; }
.match-strip .label { color: var(--muted); font-size: 12px; font-weight: 700; }
.match-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

/* fixes after the theme review */
.hero { overflow: visible; z-index: 3; }
.btn.primary { background: linear-gradient(135deg, color-mix(in srgb, var(--accent-l) 80%, #fff), var(--accent-l) 55%, var(--accent-deep-l));
  color: #fff; box-shadow: 0 6px 16px var(--glow); }
.btn.primary:hover { filter: brightness(1.08); }
.digest { background: linear-gradient(120deg, var(--gold-soft), transparent 55%), var(--surface); }

/* ------------------------------------------------------------------ AskEZ-style surfaces (default look) */
body { background: var(--bg-grad); background-attachment: fixed; background-repeat: no-repeat; }  /* every layer fixed: no seam when scrolling */
.side { background: var(--side-grad); backdrop-filter: none; border-right: 1px solid var(--red-line); }
.btn.primary { background: var(--primary-grad); color: #fff; border-color: transparent; box-shadow: 0 4px 12px var(--glow); }
.btn.primary:hover { filter: brightness(1.06); transform: translateY(-1px); }
.hero { background: radial-gradient(60% 90% at 100% 0%, color-mix(in srgb, var(--red) 14%, transparent), transparent 70%), var(--card-grad); border-color: var(--red-line); }
.digest { background: var(--card-grad); border-color: var(--red-line); }
.chip:hover { background: var(--red-soft); color: var(--red); }
.nav a.is-active { background: linear-gradient(90deg, color-mix(in srgb, var(--red) 12%, transparent), transparent); }
.brand-mark::before { background: color-mix(in srgb, var(--accent-l) 72%, #fff); }
.pick-num, .mm-pipeline li span, .dg-item::before { background: var(--primary-grad); }
.card, .stat, .result, .paper-card, .shelf-card { border-color: color-mix(in srgb, var(--red) 9%, var(--line)); }

/* ------------------------------------------------------------------ settings page */
.settings { display: grid; gap: 18px; max-width: 900px; }
.settings h1 { font-size: 24px; }
.set-card { display: grid; gap: 14px; padding: 20px 22px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.set-card > h2 { display: flex; align-items: center; gap: 8px; font-size: 16px; }
.set-card > p { margin: -8px 0 0; color: var(--muted); font-size: 13px; }
.set-row { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 14px; align-items: start; }
.set-row > label, .set-row > span.lbl { padding-top: 6px; color: var(--muted); font-size: 13px; font-weight: 600; }
.modes { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.mode { display: grid; gap: 6px; padding: 8px; border: 2px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--ink); font-weight: 600; font-size: 13px; cursor: pointer; text-align: center; }
.mode[aria-pressed="true"] { border-color: var(--red); background: var(--red-soft); color: var(--red); }
.mode .pv { height: 54px; border-radius: 9px; border: 1px solid rgb(0 0 0 / 8%); }
.pv.light { background: linear-gradient(160deg, #fdeff0, #fbfaf8 70%); }
.pv.dim { background: linear-gradient(160deg, #ece4e6, #e4e7eb); }
.pv.dark { background: linear-gradient(160deg, #241820, #0e1218); }
.pv.auto { background: linear-gradient(90deg, #fdeff0 50%, #161420 50%); }
.accents-row { display: flex; flex-wrap: wrap; gap: 10px; }
.accent-opt { display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 12px 0 8px; border: 2px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink); font-size: 13px; font-weight: 600; cursor: pointer; }
.accent-opt i { width: 20px; height: 20px; border-radius: 50%; background: var(--sw); }
.accent-opt[aria-pressed="true"] { border-color: var(--sw); }
.sizes { display: inline-flex; gap: 6px; }
.set-list { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; font-size: 13px; }
.set-list code { overflow-wrap: anywhere; }
.set-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
@media (max-width: 760px) { .set-row { grid-template-columns: 1fr; } .modes { grid-template-columns: repeat(2, 1fr); } }

/* ------------------------------------------------------------------ compare picker */
.cmp-tray { position: sticky; top: 0; z-index: 5; display: grid; gap: 10px; margin-bottom: 14px; padding: 12px; border: 1px solid var(--red-line); border-radius: var(--radius); background: var(--card-grad); box-shadow: var(--shadow); }
.tray-slots { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.slot { display: flex; align-items: center; gap: 8px; min-width: 0; height: 44px; padding: 0 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.slot b { flex: 1; min-width: 0; overflow: hidden; font-size: 12.5px; text-overflow: ellipsis; white-space: nowrap; }
.slot .n { display: grid; place-items: center; width: 22px; height: 22px; flex: none; border-radius: 50%; background: var(--primary-grad); color: #fff; font-size: 11px; font-weight: 800; }
.slot button { width: 24px; height: 24px; flex: none; border: 0; border-radius: 50%; background: var(--surface-2); color: var(--muted); cursor: pointer; }
.slot button:hover { background: var(--red-soft); color: var(--red); }
.empty-slot { border-style: dashed; color: var(--faint); }
.empty-slot .n { background: var(--surface-2); color: var(--faint); }
.tray-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; font-size: 13px; }
.tray-actions .muted { margin-right: auto; }
.cmp-tools { margin: 12px 0 8px; }
.cmp-tools .input { width: 100%; max-width: 520px; }
.cmp-list { display: grid; gap: 6px; max-height: 460px; overflow: auto; padding: 4px; }
.cmp-item { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 10px; align-items: center; padding: 9px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.cmp-item.is-on { border-color: var(--red); background: var(--red-soft); }
.cmp-item a { display: block; font-size: 13.5px; font-weight: 600; text-decoration: none; }
.cmp-item a:hover { color: var(--red); }
.cmp-item small { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-top: 2px; color: var(--muted); font-size: 12px; }
.cmp-toggle { display: grid; place-items: center; width: 30px; height: 30px; border: 1px solid var(--line-strong); border-radius: 50%; background: var(--surface); color: var(--muted); font-size: 18px; cursor: pointer; }
.cmp-toggle:hover { border-color: var(--red); color: var(--red); }
.cmp-toggle[aria-pressed="true"] { border-color: transparent; background: var(--primary-grad); color: #fff; }
.cmp-history { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.cmp-history ol { margin: 4px 0 0; padding-left: 20px; font-size: 13px; }
@media (max-width: 900px) { .tray-slots { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ------------------------------------------------------------------ "Vũ trụ" (cosmic) theme: deep space, nebulae, glass */
:root { --surface-solid: var(--surface); }
:root[data-theme="cosmic"] {
  --accent-d: #ff4d6d; --accent-deep-d: #ff8fa3; --accent-2-d: #a78bfa;
  --red: var(--accent-d); --red-deep: var(--accent-deep-d); --accent-2: var(--accent-2-d);
  --gold: #ffc861; --gold-soft: rgb(255 200 97 / 12%); --gold-ink: #ffd27f;
  --bg: #06070f; --surface: rgb(24 22 44 / 58%); --surface-2: rgb(255 255 255 / 5%); --surface-solid: #15132a;
  --line: rgb(255 255 255 / 9%); --line-strong: rgb(255 255 255 / 17%);
  --ink: #f4f1ff; --muted: #aaa6c8; --faint: #716d93;
  --good: #5eead4; --good-soft: rgb(94 234 212 / 12%); --blue: #93c5fd; --blue-soft: rgb(147 197 253 / 12%);
  --violet: #c4b5fd; --violet-soft: rgb(196 181 253 / 12%);
  --shadow: 0 10px 34px rgb(0 0 0 / 35%), inset 0 1px 0 rgb(255 255 255 / 5%);
  --shadow-lg: 0 24px 70px rgb(0 0 0 / 60%), 0 0 0 1px rgb(255 255 255 / 6%);
  --reader-bg: rgb(3 4 10 / 70%);
  --red-soft: color-mix(in srgb, var(--red) 16%, transparent);
  --red-line: color-mix(in srgb, var(--red) 34%, transparent);
  --glow: color-mix(in srgb, var(--accent-d) 45%, transparent);
  --primary-grad: linear-gradient(135deg, color-mix(in srgb, var(--accent-d) 92%, #fff), color-mix(in srgb, var(--accent-d) 55%, var(--accent-2-d)));
  --card-grad: linear-gradient(135deg, color-mix(in srgb, var(--accent-d) 14%, rgb(24 22 44 / 60%)), rgb(24 22 44 / 55%) 60%);
  --side-grad: linear-gradient(175deg, rgb(28 18 40 / 72%), rgb(12 12 28 / 72%));
  --bg-grad:
    radial-gradient(1100px 700px at 88% -12%, color-mix(in srgb, var(--accent-d) 26%, transparent), transparent 62%),
    radial-gradient(900px 650px at -12% 28%, color-mix(in srgb, var(--accent-2-d) 22%, transparent), transparent 62%),
    radial-gradient(800px 520px at 55% 115%, rgb(56 189 248 / 12%), transparent 60%),
    radial-gradient(1400px 900px at 50% 50%, #0b0b1d, #05060d 75%);
  color-scheme: dark;
}
#cosmos { position: fixed; inset: 0; z-index: 0; width: 100vw; height: 100vh; pointer-events: none; display: none; }
:root[data-theme="cosmic"] #cosmos { display: block; }
:root[data-theme="cosmic"] .app { position: relative; z-index: 1; }

/* glass surfaces */
:root[data-theme="cosmic"] :is(.side, .card, .stat, .hero, .result, .paper-card, .shelf-card, .digest, .set-card, .cmp-tray, .cmp-item,
  .follow-box, .panel, .paper-top, .reader-bar, .filters, .book-card .cover, .pick, .problem-card, .callout, .mm-number, .mm-branch,
  .lib-row, .empty, .research-history, .dg-item, .catalog-card, .drop-zone, .slot, .person, .chip, .tabs, .input, .select, .btn:not(.primary)) {
  -webkit-backdrop-filter: blur(16px) saturate(140%); backdrop-filter: blur(16px) saturate(140%);
}
:root[data-theme="cosmic"] .side { background: var(--side-grad); border-right: 1px solid var(--line); }
:root[data-theme="cosmic"] :is(.input, .select, textarea.input) { background: rgb(255 255 255 / 5%); }
:root[data-theme="cosmic"] .chip { background: rgb(255 255 255 / 4%); }
:root[data-theme="cosmic"] .chip:hover, :root[data-theme="cosmic"] .chip.is-on { background: var(--red-soft); box-shadow: 0 0 18px color-mix(in srgb, var(--red) 25%, transparent); }
:root[data-theme="cosmic"] :is(.popover, .menu-list, .omni-panel, .sel-bar, .graph-dialog, .mapview, .mv-tools, .mv-bar, .tr-bar, .glossary, dialog) {
  background: var(--surface-solid);
}
:root[data-theme="cosmic"] .btn.primary { background: var(--primary-grad); box-shadow: 0 0 0 1px rgb(255 255 255 / 10%) inset, 0 8px 28px var(--glow); }
:root[data-theme="cosmic"] .btn.primary:hover { box-shadow: 0 0 0 1px rgb(255 255 255 / 16%) inset, 0 10px 36px var(--glow); }
:root[data-theme="cosmic"] :is(.paper-card, .shelf-card, .result, .dg-item, .book-card .cover):hover {
  border-color: var(--red-line); box-shadow: 0 0 0 1px var(--red-line), 0 16px 50px rgb(0 0 0 / 50%), 0 0 40px color-mix(in srgb, var(--red) 14%, transparent);
}
:root[data-theme="cosmic"] .nav a.is-active { background: linear-gradient(90deg, color-mix(in srgb, var(--red) 24%, transparent), transparent); color: #fff; }
:root[data-theme="cosmic"] .nav a.is-active .svg { color: var(--red); filter: drop-shadow(0 0 6px var(--red)); }
:root[data-theme="cosmic"] .brand-mark::after { mix-blend-mode: screen; filter: drop-shadow(0 0 6px var(--red)); }
:root[data-theme="cosmic"] .reader-wrap { background: var(--reader-bg); }
:root[data-theme="cosmic"] .pdf-page { box-shadow: 0 0 0 1px rgb(255 255 255 / 8%), 0 18px 60px rgb(0 0 0 / 60%); }
:root[data-theme="cosmic"] .badge { background: rgb(255 255 255 / 7%); }

/* hero: glowing orb and gradient title */
:root[data-theme="cosmic"] .hero { background: var(--card-grad); border-color: var(--line); overflow: visible; isolation: isolate; }
:root[data-theme="cosmic"] .hero::before {
  position: absolute; top: -70px; right: 40px; z-index: -1; width: 260px; height: 260px; border-radius: 50%; content: ""; pointer-events: none;
  background: radial-gradient(circle at 35% 30%, #fff 0%, color-mix(in srgb, var(--accent-d) 80%, #fff) 8%, var(--accent-d) 26%,
    color-mix(in srgb, var(--accent-2-d) 70%, transparent) 55%, transparent 70%);
  filter: blur(2px) saturate(130%); opacity: .85; animation: orb-float 9s ease-in-out infinite;
  box-shadow: 0 0 120px 30px color-mix(in srgb, var(--accent-d) 30%, transparent);
}
:root[data-theme="cosmic"] .hero::after {
  position: absolute; top: -30px; right: 0; z-index: -1; width: 340px; height: 180px; border: 1px solid rgb(255 255 255 / 14%);
  border-radius: 50%; content: ""; transform: rotate(-18deg); pointer-events: none; animation: orb-ring 14s linear infinite;
}
:root[data-theme="cosmic"] .hero h1 { background: linear-gradient(90deg, #fff, #ffd1da 55%, color-mix(in srgb, var(--accent-d) 70%, #fff));
  -webkit-background-clip: text; background-clip: text; color: transparent; }
:root[data-theme="cosmic"] .hero h1 em { color: var(--red); -webkit-text-fill-color: var(--red); text-shadow: 0 0 24px var(--glow); }
@keyframes orb-float { 0%, 100% { transform: translateY(0) scale(1); } 50% { transform: translateY(14px) scale(1.04); } }
@keyframes orb-ring { from { transform: rotate(-18deg) scaleX(1); } 50% { transform: rotate(-12deg) scaleX(1.06); } to { transform: rotate(-18deg) scaleX(1); } }

/* settings preview */
.pv.cosmic { background: radial-gradient(circle at 75% 25%, #ff4d6d 0 6%, transparent 30%), radial-gradient(circle at 20% 70%, rgb(167 139 250 / 70%), transparent 45%),
  radial-gradient(1px 1px at 30% 30%, #fff, transparent), radial-gradient(1px 1px at 60% 70%, #fff, transparent), radial-gradient(1px 1px at 85% 55%, #fff, transparent), #070812; }

@media (prefers-reduced-motion: reduce) {
  :root[data-theme="cosmic"] .hero::before, :root[data-theme="cosmic"] .hero::after { animation: none; }
}
:root[data-theme="cosmic"] { --primary-grad: linear-gradient(135deg, #e11d48, #a21caf 60%, #7c3aed); }
:root[data-theme="cosmic"][data-accent] { --primary-grad: linear-gradient(135deg, var(--accent-l), color-mix(in srgb, var(--accent-l) 50%, var(--accent-2-l))); }
:root[data-theme="cosmic"] .hero::before { top: -26px; right: 56px; width: 210px; height: 210px; }
:root[data-theme="cosmic"] .hero::after { top: 6px; right: 14px; width: 300px; height: 150px; }



/* ------------------------------------------------------------------ progress: level, heatmap, quests, badges */
.progress-page { display: grid; gap: 18px; }
.prog-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 18px; padding: 20px 22px; border: 1px solid var(--red-line); border-radius: var(--radius); background: var(--card-grad); box-shadow: var(--shadow); }
.lvl { display: flex; align-items: center; gap: 16px; min-width: 300px; }
.lvl-num { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 50%; background: var(--primary-grad); color: #fff; font-size: 28px; font-weight: 800; box-shadow: 0 0 0 5px var(--red-soft), 0 8px 24px var(--glow); }
.lvl b { display: block; font-size: 20px; }
.lvl small { color: var(--muted); font-size: 12.5px; }
.bar { position: relative; height: 7px; margin: 6px 0 4px; overflow: hidden; border-radius: 99px; background: var(--surface-2); }
.bar i { display: block; height: 100%; border-radius: inherit; background: var(--primary-grad); transition: width .4s; }
.bar.big { width: 280px; height: 9px; }
.prog-stats { display: flex; flex-wrap: wrap; gap: 22px; }
.prog-stats div { display: grid; text-align: center; }
.prog-stats b { font-size: 24px; color: var(--red); }
.prog-stats small { color: var(--muted); font-size: 12px; }
.heat-wrap { display: grid; gap: 4px; overflow-x: auto; padding-bottom: 4px; }
.heat-months, .heat { display: grid; gap: 3px; }
.heat-months span { font-size: 10.5px; color: var(--faint); white-space: nowrap; }
.heat-col { display: grid; grid-template-rows: repeat(7, 13px); gap: 3px; }
.heat i, .heat-legend i { display: block; width: 13px; height: 13px; border-radius: 3px; background: var(--surface-2); border: 1px solid var(--line); }
.heat i.pad { visibility: hidden; }
.heat i.l1, .heat-legend i.l1 { background: color-mix(in srgb, var(--red) 25%, var(--surface)); }
.heat i.l2, .heat-legend i.l2 { background: color-mix(in srgb, var(--red) 50%, var(--surface)); }
.heat i.l3, .heat-legend i.l3 { background: color-mix(in srgb, var(--red) 75%, var(--surface)); }
.heat i.l4, .heat-legend i.l4 { background: var(--red); box-shadow: 0 0 8px var(--glow); }
.heat-legend { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; }
.heat-legend .scale { display: inline-flex; align-items: center; gap: 3px; }
.quest-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.quest { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px 0; border-top: 1px dashed var(--line); }
.quest b { font-size: 13.5px; }
.quest small { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.q-ic { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 10px; background: var(--surface-2); color: var(--muted); }
.quest.done .q-ic { background: var(--primary-grad); color: #fff; box-shadow: 0 4px 14px var(--glow); }
.quest.done b { color: var(--good); }
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.badge-card { display: grid; gap: 3px; justify-items: center; padding: 16px 12px 12px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); text-align: center; }
.badge-card .medal { display: grid; place-items: center; width: 54px; height: 54px; margin-bottom: 6px; border-radius: 50%; background: var(--surface-2); color: var(--faint); }
.badge-card.bronze .medal { background: radial-gradient(circle at 35% 30%, #ffd9b8, #cd7f32 60%, #8a4f1c); color: #fff; box-shadow: 0 6px 18px rgb(205 127 50 / 40%); }
.badge-card.silver .medal { background: radial-gradient(circle at 35% 30%, #ffffff, #c0c6d0 55%, #7b8494); color: #fff; box-shadow: 0 6px 18px rgb(160 170 185 / 45%); }
.badge-card.gold .medal { background: radial-gradient(circle at 35% 30%, #fff6c4, #f5c04a 50%, #b88400); color: #fff; box-shadow: 0 6px 22px rgb(245 192 74 / 55%); }
.badge-card.locked { opacity: .75; }
.badge-card .bar { width: 100%; }
.badge-card small { font-size: 11.5px; }
.tiers { display: flex; gap: 5px; margin-top: 4px; }
.tiers .t { width: 10px; height: 10px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--line-strong); }
.tiers .t.bronze.on { background: #cd7f32; } .tiers .t.silver.on { background: #c0c6d0; } .tiers .t.gold.on { background: #f5c04a; }
@media (max-width: 900px) { .quest-cols { grid-template-columns: 1fr; } }

/* ------------------------------------------------------------------ timeline of an idea */
.seg-link { display: inline-flex; align-items: center; height: 30px; padding: 0 14px; border-radius: 8px; color: var(--muted); font-size: 13px; font-weight: 600; text-decoration: none; }
.seg-link.is-on { background: var(--surface); color: var(--red); box-shadow: 0 1px 3px rgb(0 0 0 / 12%); }
.tl-form { display: flex; gap: 8px; }
.tl-form .input { flex: 1; height: 46px; font-size: 15px; }
.tl-form .btn { height: 46px; }
.tl-axis-wrap { padding: 12px 14px 8px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.tl-axis { display: block; width: 100%; height: auto; overflow: visible; }
.tl-axis text { fill: var(--muted); font-size: 12px; }
.tl-line { stroke: var(--line-strong); stroke-width: 2; }
.tl-tick line { stroke: var(--line-strong); }
.tl-era text { fill: var(--ink); font-size: 12px; font-weight: 700; }
.tl-arc { fill: none; stroke-width: 1.6; opacity: .45; stroke-dasharray: 4 3; }
.tl-stem { stroke: var(--line-strong); stroke-width: 1; }
.tl-dot { cursor: pointer; outline: none; transition: opacity .2s; }
.tl-dot circle { stroke: var(--surface-solid, var(--surface)); stroke-width: 2.5; transition: transform .15s; transform-box: fill-box; transform-origin: center; }
.tl-dot:hover circle, .tl-dot:focus circle { transform: scale(1.25); filter: drop-shadow(0 0 6px currentColor); }
.tl-dot.dim { opacity: .15; }
.tl-legend { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.tl-legend .chip i { width: 10px; height: 10px; border-radius: 50%; }
.tl-legend .chip:not(.is-on) { opacity: .45; }
.tl-list { position: relative; display: grid; gap: 12px; margin: 18px 0 0; padding: 0; list-style: none; }
.tl-list::before { position: absolute; top: 6px; bottom: 6px; left: 70px; width: 2px; background: linear-gradient(var(--red-line), var(--line)); content: ""; }
.tl-item { display: grid; grid-template-columns: 56px 30px minmax(0, 1fr); align-items: start; gap: 0 4px; }
.tl-year { padding-top: 14px; color: var(--c); font-size: 15px; font-weight: 800; text-align: right; }
.tl-node { justify-self: center; width: 14px; height: 14px; margin-top: 17px; border: 3px solid var(--c); border-radius: 50%; background: var(--surface-solid, var(--surface)); box-shadow: 0 0 0 4px color-mix(in srgb, var(--c) 18%, transparent); z-index: 1; }
.tl-card { padding: 12px 16px; border: 1px solid var(--line); border-left: 3px solid var(--c); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow); }
.tl-card h4 { margin: 6px 0 2px; font-size: 15px; }
.tl-card h4 a { text-decoration: none; }
.tl-card h4 a:hover { color: var(--red); }
.tl-card .meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.tl-card .authors { color: var(--muted); font-size: 12.5px; }
.tl-card p { margin: 8px 0 6px; font-size: 13.5px; }
.tl-card .actions { display: flex; gap: 8px; margin-top: 8px; }
.tl-role { background: color-mix(in srgb, var(--c) 18%, transparent) !important; color: var(--c) !important; }
.tl-base { font-size: 12px; text-align: left; }
.tl-item.flash .tl-card { animation: tl-flash 1.4s; }
@keyframes tl-flash { 0%, 40% { box-shadow: 0 0 0 3px var(--c), var(--shadow); } }
.tl-eras { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.tl-era-card { padding: 12px 14px; border: 1px solid var(--line); border-top: 3px solid var(--c); border-radius: 12px; background: var(--surface); }
.tl-era-card small { color: var(--c); font-weight: 800; }
.tl-era-card b { display: block; margin: 2px 0 4px; }
.tl-era-card p { margin: 0; color: var(--muted); font-size: 13px; }

/* ------------------------------------------------------------------ data lab */
.lab { display: grid; gap: 12px; }
.lab-job { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.lab-list { display: grid; gap: 10px; }
.lab-card { display: grid; gap: 6px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.lab-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.lab-card-head b { font-size: 13.5px; }
.lab-preview { overflow: hidden; border: 1px solid var(--line); border-radius: 8px; }
.lab-preview table { width: 100%; border-collapse: collapse; font-size: 11px; }
.lab-preview th, .lab-preview td { padding: 3px 6px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.lab-preview th { background: var(--surface-2); }
.lab-dialog { width: min(1300px, calc(100vw - 24px)); }
.lab-body { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 16px; padding: 14px 16px 18px; }
.lab-grid-wrap { display: grid; gap: 8px; align-content: start; min-width: 0; }
.lab-grid { max-height: 62vh; overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
.lab-grid table { border-collapse: collapse; font-size: 12.5px; }
.lab-grid td { min-width: 60px; padding: 5px 8px; border: 1px solid var(--line); white-space: nowrap; outline: none; }
.lab-grid td:focus { box-shadow: inset 0 0 0 2px var(--red); background: var(--red-soft); }
.lab-grid td.n { text-align: right; font-variant-numeric: tabular-nums; }
.lab-grid td.edited { background: color-mix(in srgb, var(--gold) 18%, transparent); }
.lab-grid tr.hdr td { position: sticky; top: 0; background: var(--surface-2); font-weight: 700; text-align: center; z-index: 1; }
.lab-grid td.rowx { min-width: 0; padding: 0 4px; border: 0; }
.lab-grid td.rowx button { width: 20px; height: 20px; border: 0; border-radius: 50%; background: transparent; color: var(--faint); cursor: pointer; }
.lab-grid td.rowx button:hover { background: var(--red-soft); color: var(--red); }
.lab-side { display: grid; gap: 10px; align-content: start; min-width: 0; }
.lab-controls { display: flex; flex-wrap: wrap; gap: 10px; font-size: 12.5px; color: var(--muted); }
.lab-controls label { display: inline-flex; align-items: center; gap: 6px; }
.lab-ys { display: flex; flex-wrap: wrap; gap: 6px; }
.lab-ys .chip { height: 28px; font-size: 12px; cursor: pointer; }
.lab-chart { width: 100%; height: auto; }
.lab-chart text { fill: var(--muted); font-size: 10.5px; }
.lab-chart .grid { stroke: var(--line); }
.lab-chart .zero { stroke: var(--line-strong); }
.lab-stats { width: 100%; border-collapse: collapse; font-size: 12px; }
.lab-stats th, .lab-stats td { padding: 4px 6px; border-bottom: 1px solid var(--line); text-align: right; font-variant-numeric: tabular-nums; }
.lab-stats th:first-child { text-align: left; }
.lab-explain { padding: 12px; border: 1px solid var(--line); border-radius: 12px; font-size: 13px; }
@media (max-width: 1000px) { .lab-body { grid-template-columns: 1fr; } }

/* compare: a clear "add" button */
.cmp-toggle { width: 32px; height: 32px; border: 1.5px solid var(--red-line); background: var(--red-soft); color: var(--red); transition: background .15s, color .15s, box-shadow .15s, transform .1s; }
.cmp-toggle .svg { stroke-width: 2.4; }
.cmp-toggle:hover { border-color: transparent; background: var(--primary-grad); color: #fff; box-shadow: 0 4px 14px var(--glow); transform: scale(1.06); }
.cmp-toggle[aria-pressed="true"] { box-shadow: 0 4px 14px var(--glow); }
.cmp-item:hover { border-color: var(--red-line); }

/* ------------------------------------------------------------------ podcast */
.pod { display: grid; gap: 14px; }
.pod-wait .bar { margin: 4px 0; }
.pod-card { display: grid; grid-template-columns: 74px minmax(0, 1fr); gap: 14px; align-items: center; padding: 14px; border: 1px solid var(--red-line); border-radius: 16px; background: var(--card-grad); }
.pod-art { position: relative; display: grid; place-items: center; width: 74px; height: 74px; border-radius: 18px; background: var(--primary-grad); box-shadow: 0 8px 24px var(--glow); }
.pod-art span { position: absolute; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; border: 2px solid rgb(255 255 255 / 70%); color: #fff; font-weight: 800; background: rgb(255 255 255 / 14%); }
.pod-art span:first-child { left: 8px; top: 10px; } .pod-art span:last-child { right: 8px; bottom: 10px; }
.pod-meta small { color: var(--muted); font-size: 12px; }
.pod-meta b { display: block; margin: 2px 0; font-size: 15px; }
.pod-meta p { margin: 0; color: var(--muted); font-size: 12.5px; }
.pod-controls { display: flex; align-items: center; gap: 8px; }
.pod-play { display: grid; place-items: center; width: 46px; height: 46px; flex: none; border: 0; border-radius: 50%; background: var(--primary-grad); color: #fff; cursor: pointer; box-shadow: 0 6px 18px var(--glow); }
.pod-play .svg { fill: currentColor; stroke: none; }
.pod-seek { display: grid; flex: 1; min-width: 0; }
.pod-seek input { width: 100%; accent-color: var(--red); }
.pod-seek small { color: var(--muted); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.pod-speed { width: 72px; height: 32px; }
.pod-lines { display: grid; gap: 8px; max-height: 52vh; overflow: auto; margin: 0; padding: 0 2px 0 0; list-style: none; }
.pod-line { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 8px; padding: 8px 10px; border-radius: 12px; cursor: pointer; transition: background .15s; }
.pod-line:hover { background: var(--surface-2); }
.pod-line .who { align-self: start; padding: 2px 0; border-radius: 6px; font-size: 11.5px; font-weight: 800; text-align: center; }
.pod-line.m .who { background: var(--blue-soft); color: var(--blue); }
.pod-line.l .who { background: var(--red-soft); color: var(--red); }
.pod-line p { margin: 0; font-size: 13.5px; line-height: 1.55; }
.pod-line.now { background: var(--red-soft); box-shadow: inset 3px 0 0 var(--red); }

/* lab: the close button always visible in the corner */
.lab-dialog .graph-head { position: sticky; top: 0; z-index: 3; flex-wrap: wrap; padding-right: 64px; }
.lab-close { position: absolute; top: 10px; right: 12px; display: grid; place-items: center; width: 38px; height: 38px; border: 1px solid var(--line-strong);
  border-radius: 50%; background: var(--surface-solid, var(--surface)); color: var(--ink); font-size: 22px; line-height: 1; cursor: pointer; }
.lab-close:hover { border-color: transparent; background: var(--primary-grad); color: #fff; }
.lab-dialog { overflow: auto; }

/* ------------------------------------------------------------------ server mode: account, admin */
:root[data-mode="server"] .local-only { display: none !important; }
.ai-meter { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 2px 12px; align-items: center; margin-bottom: 14px; }
.ai-meter b { grid-row: span 2; font-size: 26px; color: var(--red); }
.ai-meter span { color: var(--muted); font-size: 13px; }
.ai-meter .bar { margin: 0; }
.key-form label b { font-size: 14px; }
.invite-form { display: grid; gap: 8px; }
.invite-form textarea { width: 100%; height: auto; padding: 10px 12px; resize: vertical; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-table th, .admin-table td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.admin-table th { color: var(--muted); font-size: 12px; }
.admin-table td small { display: block; color: var(--muted); font-size: 11.5px; }
.admin-table tr.off td { opacity: .5; }
.admin-table .select { height: 30px; font-size: 12.5px; }
/* ------------------------------------------------------------------ invitations: e-mail state, send / preview / copy */
.invite-list { display: grid; gap: 8px; margin-bottom: 6px; }
.invite-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.invite-row b { word-break: break-all; }
.invite-row small { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; }
.mail-ok { color: var(--good); }
.mail-bad { color: var(--red); cursor: help; }
.btn.danger { color: var(--red); }
.mail-setup { display: flex; gap: 8px; align-items: flex-start; margin: 4px 0 14px; padding: 10px 12px; border: 1px solid var(--gold); border-radius: 12px;
  background: var(--gold-soft); color: var(--ink); font-size: 13px; line-height: 1.55; }
.mail-setup .svg { flex: none; margin-top: 3px; color: var(--gold-ink); }
/* ------------------------------------------------------------------ privacy policy & terms (open without sign-in) */
.legal-page { min-height: 100vh; padding: 32px 16px; background: var(--bg-grad, var(--bg)); background-attachment: fixed; }
.legal { width: min(760px, 100%); margin: 0 auto; padding: 30px 32px; border: 1px solid var(--line); border-radius: 22px; background: var(--surface);
  box-shadow: var(--shadow); line-height: 1.7; }
.legal .brand { text-decoration: none; color: inherit; }
.legal-nav { display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 18px 0 6px; font-weight: 700; }
.legal-nav a, .legal a:not(.btn):not(.brand) { color: var(--red); }
.legal section { padding-top: 14px; scroll-margin-top: 20px; }
.legal h1 { margin: 10px 0 2px; font-size: 26px; }
.legal h2 { margin: 18px 0 4px; font-size: 16.5px; }
.legal p, .legal li { color: var(--ink); }
.legal ul { padding-left: 20px; }
.legal li { margin-bottom: 8px; }
.login-legal { margin: 2px 0 0; text-align: center; font-size: 12px; }
.login-legal a { color: var(--muted); }
@media (max-width: 600px) { .legal { padding: 22px 18px; } }
