/* HSC Papers Mirror — modern, fast, THSCOnline-style */
:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --text: #0f172a;
  --muted: #64748b;
  --muted-2: #94a3b8;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef2ff;
  --accent-border: #c7d2fe;
  --border: #e2e8f0;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.07), 0 4px 14px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 10px 34px rgba(79, 70, 229, 0.16);
}
[data-theme="dark"] {
  --bg: #0b1220;
  --surface: #111b30;
  --surface-2: #1a2742;
  --text: #e8eefc;
  --muted: #9aa8c3;
  --muted-2: #6b7a99;
  --accent: #818cf8;
  --accent-hover: #a5b4fc;
  --accent-soft: #1e2560;
  --accent-border: #3b438f;
  --border: #223052;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 34px rgba(0, 0, 0, 0.5);
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--accent); }

/* ---------- Header ---------- */
header {
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.nav {
  max-width: 1220px;
  margin: 0 auto;
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}
.logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 800;
  font-size: 1.08rem;
  letter-spacing: -0.01em;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}
.logo-mark {
  width: 34px; height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, #4f46e5, #7c3aed 60%, #06b6d4);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 1rem;
  box-shadow: var(--shadow);
}
.logo small {
  display: block;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.nav-links { display: flex; gap: 0.25rem; margin-left: 0.5rem; }
.nav-links a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 600;
  padding: 0.45rem 0.8rem;
  border-radius: 999px;
}
.nav-links a:hover, .nav-links a.active { color: var(--accent); background: var(--accent-soft); }
.nav-right { margin-left: auto; display: flex; align-items: center; gap: 0.6rem; }
.host-badge {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  border: 1px dashed var(--border);
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.icon-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  width: 36px; height: 36px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 1.05rem;
  display: grid;
  place-items: center;
}
.icon-btn:hover { border-color: var(--accent); }

/* ---------- Hero ---------- */
.hero {
  max-width: 1220px;
  margin: 0 auto;
  padding: 3.2rem 1.5rem 1.6rem;
  text-align: center;
}
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  padding: 0.32rem 0.85rem;
  border-radius: 999px;
  margin-bottom: 1rem;
}
.hero h1 {
  font-size: clamp(1.9rem, 4.4vw, 3rem);
  letter-spacing: -0.03em;
  line-height: 1.1;
  max-width: 720px;
  margin: 0 auto;
}
.hero h1 span {
  display: block;
  background: linear-gradient(90deg, #4f46e5, #7c3aed, #06b6d4);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero p { color: var(--muted); margin: 0.9rem auto 1.6rem; max-width: 600px; font-size: 1.02rem; }
.search-wrap {
  max-width: 620px;
  margin: 0 auto;
  position: relative;
}
.search {
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 999px;
  padding: 0.35rem 0.35rem 0.35rem 1.1rem;
  box-shadow: var(--shadow);
  gap: 0.5rem;
}
.search:focus-within { border-color: var(--accent); box-shadow: var(--shadow-lg); }
.search .s-icon { color: var(--muted-2); font-size: 1.1rem; }
.search input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 1rem;
  background: transparent;
  color: var(--text);
  min-width: 0;
}
.search button {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 0.6rem 1.45rem;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.search button:hover { background: var(--accent-hover); }
.quick-pills {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 1rem;
}
.pill {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 650;
  padding: 0.38rem 0.9rem;
  border-radius: 999px;
  cursor: pointer;
}
.pill:hover { border-color: var(--accent); color: var(--accent); }
.pill.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.stats-row {
  display: flex;
  gap: 2.2rem;
  justify-content: center;
  margin-top: 1.8rem;
  flex-wrap: wrap;
}
.stat b { font-size: 1.4rem; display: block; letter-spacing: -0.02em; }
.stat span { font-size: 0.82rem; color: var(--muted); font-weight: 600; }

/* ---------- Layout ---------- */
.layout {
  max-width: 1220px;
  margin: 0 auto;
  padding: 1.2rem 1.5rem 5rem;
  display: grid;
  grid-template-columns: 272px 1fr;
  gap: 1.4rem;
  align-items: start;
  width: 100%;
  flex: 1;
}
/* Subjects strip */
/* Subjects strip (sticky app bar — always visible while browsing) */
.strip-bar {
  position: sticky;
  top: var(--header-h, 61px);
  z-index: 40;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.strip-inner { max-width: 1220px; margin: 0 auto; padding: 0.55rem 1.5rem 0.7rem; width: 100%; }
.strip-bar .strip-inner h2 {
  font-size: 0.78rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.45rem;
}
.subject-strip h2, .panel h2 { font-size: 1.02rem; letter-spacing: -0.01em; margin-bottom: 0.7rem; }
.strip-scroll {
  display: flex;
  gap: 0.6rem;
  overflow-x: auto;
  padding-bottom: 0.4rem;
  scrollbar-width: thin;
}
.subj-chip {
  flex: 0 0 auto;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 0.7rem 0.95rem;
  cursor: pointer;
  text-align: left;
  min-width: 178px;
  box-shadow: var(--shadow);
}
.subj-chip:hover { border-color: var(--accent); transform: translateY(-1px); }
.subj-chip.on { border-color: var(--accent); outline: 2px solid var(--accent-border); }
.subj-chip b { display: block; font-size: 0.9rem; }
.subj-chip span { font-size: 0.78rem; color: var(--muted); font-weight: 600; }

/* Sidebar */
.sidebar {
  position: sticky;
  top: 76px;
  /* Collapsible panels keep this short; it only scrolls when a long list
     panel is expanded. (The old fixed 100vh height made ~400 filter rows
     a mandatory scroll marathon.) */
  max-height: calc(100vh - 88px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  padding-right: 4px;
  padding-bottom: 0.4rem;
}
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1rem 1.05rem;
  box-shadow: var(--shadow);
}
/* Collapsible filter panels */
details.panel > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  user-select: none;
}
details.panel > summary::-webkit-details-marker { display: none; }
details.panel > summary::after {
  content: "▾";
  margin-left: auto;
  color: var(--muted);
  font-size: 0.8rem;
  transition: transform 0.15s;
}
details.panel[open] > summary::after { transform: rotate(180deg); }
details.panel > summary h2 { flex: 1; margin-bottom: 0; }
details.panel[open] > summary { margin-bottom: 0.7rem; }
details.panel:not([open]) { padding: 0.62rem 1rem; }
details.panel > summary:hover h2 { color: var(--accent); }
details.panel > summary { border-radius: var(--radius-sm); }
.panel-hint {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
}
.drawer-close { display: none; }
.panel h2 { display: flex; align-items: center; justify-content: space-between; }
.panel h2 button {
  border: none; background: none; color: var(--accent);
  font-size: 0.78rem; font-weight: 700; cursor: pointer;
}
.filter-search {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.7rem;
  font-size: 0.88rem;
  color: var(--text);
  outline: none;
  margin-bottom: 0.6rem;
}
.filter-search:focus { border-color: var(--accent); }
.check-list {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  /* No inner scroller: the sidebar itself is the single scroller (inner
     236px boxes used to trap the wheel for dozens of ticks before the
     sidebar moved at all). */
}
.check {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.88rem;
  padding: 0.32rem 0.4rem;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text);
}
.check:hover { background: var(--surface-2); }
.check input { accent-color: var(--accent); width: 15px; height: 15px; }
.check .count {
  margin-left: auto;
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--muted);
  background: var(--surface-2);
  border-radius: 999px;
  padding: 0.05rem 0.5rem;
}
.seg { display: flex; background: var(--surface-2); border-radius: 999px; padding: 3px; gap: 3px; }
.seg button {
  flex: 1;
  border: none;
  background: transparent;
  padding: 0.45rem 0.3rem;
  border-radius: 999px;
  font-size: 0.83rem;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
}
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.toggle-row { display: flex; align-items: center; justify-content: space-between; font-size: 0.88rem; font-weight: 600; padding: 0.4rem 0.1rem; }
.switch { position: relative; width: 38px; height: 22px; display: inline-block; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; inset: 0; cursor: pointer;
  background: var(--border); border-radius: 999px; transition: 0.2s;
}
.slider:before {
  content: ""; position: absolute; height: 16px; width: 16px;
  left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider:before { transform: translateX(16px); }

/* Content */
.content { min-width: 0; }
/* Shell mode (desktop widths): the page becomes an app shell — header and
   strip stay pinned, the layout locks to the remaining viewport, and the
   paper grid is THE ONLY scroll region. About/footer live below in normal
   flow, so the page bottom is always reachable. */
@media (min-width: 921px) {
  .layout {
    flex: none;
    height: calc(100dvh - var(--header-h, 61px));
    grid-template-rows: minmax(0, 1fr);
    align-items: stretch;
    padding: 1.2rem 1.5rem 1.2rem;
  }
  .sidebar { position: relative; top: auto; max-height: none; min-height: 0; }
  .content { overflow-y: auto; min-height: 0; scrollbar-width: thin; }
  .content > .toolbar {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--bg);
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.7rem;
  }
  .content > .chips { margin-top: 0.55rem; }
}
.toolbar {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  flex-wrap: wrap;
  margin-bottom: 0.9rem;
}
.results-count { font-weight: 750; font-size: 0.95rem; }
.results-count span { color: var(--muted); font-weight: 600; }
.toolbar .spacer { flex: 1; }
.select {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.65rem;
  font-size: 0.86rem;
  font-weight: 600;
}
.btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 0.52rem 0.85rem;
  font-size: 0.86rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  text-decoration: none;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.on { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.btn.icon-only { padding: 0.52rem 0.55rem; }

/* Active-filter chips */
.chips { display: flex; flex-wrap: wrap; gap: 0.45rem; margin-bottom: 0.8rem; }
.chips[hidden] { display: none; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border: 1px solid var(--accent-border);
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 999px;
  padding: 0.28rem 0.5rem 0.28rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  max-width: 100%;
}
.chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip i { font-style: normal; font-weight: 800; opacity: 0.65; }
.chip:hover { border-color: var(--accent); }
.chip:hover i { opacity: 1; }
.chip-all { background: var(--surface); color: var(--muted); border-color: var(--border); padding: 0.28rem 0.7rem; }
.chip-all:hover { color: #dc2626; border-color: #fca5a5; }

/* Filter-button badge (mobile drawer) */
.fbadge {
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 800;
  padding: 0.06rem 0.42rem;
  margin-left: 0.2rem;
}
.fbadge[hidden] { display: none; }

/* Drag-select feedback: rubber band + no text selection while sweeping */
body.drag-select { user-select: none; cursor: crosshair; }
body.drag-select .grid { cursor: crosshair; }
.marquee {
  position: fixed;
  z-index: 90;
  border: 1px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  border-radius: 4px;
  pointer-events: none;
  display: none;
}

/* Compact density (more columns, tighter cards) */
body.compact .grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 0.55rem; }
body.compact .grid.list { grid-template-columns: 1fr; }
body.compact .card { padding: 0.6rem 0.7rem 0.55rem; contain-intrinsic-size: auto 120px; }
body.compact .card h3 { font-size: 0.87rem; margin-bottom: 0.15rem; }
body.compact .card .meta { font-size: 0.74rem; margin-bottom: 0.4rem; }
body.compact .card-top { margin-bottom: 0.25rem; gap: 0.3rem; padding-right: 1.15rem; }
body.compact .tag { font-size: 0.58rem; padding: 0.08rem 0.34rem; }
body.compact .star-btn { font-size: 0.85rem; padding: 0.1rem 0.2rem; top: 0.35rem; right: 0.35rem; }
body.compact .card-actions { gap: 0.3rem; }
body.compact .card-actions .mini-btn { padding: 0.26rem 0.5rem; font-size: 0.72rem; }
body.compact .check { padding: 0.22rem 0.4rem; font-size: 0.82rem; }

/* Paper cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 0.85rem; }
.grid.list { grid-template-columns: 1fr; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.95rem 1rem 0.9rem;
  box-shadow: var(--shadow);
  display: flex;
  gap: 0.75rem;
  transition: border-color 0.15s, transform 0.15s;
  position: relative;
  /* Perf: let the browser skip layout/paint for off-screen cards */
  content-visibility: auto;
  contain-intrinsic-size: auto 190px;
}
.show-more-wrap { display: flex; justify-content: center; padding: 1.1rem 0 0.2rem; }
.show-more-wrap:empty { display: none; }
.card:hover { border-color: var(--accent-border); }
.card.selected { border-color: var(--accent); outline: 2px solid var(--accent-border); }
.card input[type="checkbox"] {
  width: 18px; height: 18px; accent-color: var(--accent);
  margin-top: 0.25rem; flex-shrink: 0; cursor: pointer;
}
.card-body { min-width: 0; flex: 1; }
.card-top { display: flex; gap: 0.45rem; flex-wrap: wrap; margin-bottom: 0.4rem; padding-right: 1.25rem; }
/* Card star: bookmark toggle (feeds the ★ My papers shelf) */
.star-btn {
  position: absolute; top: 0.45rem; right: 0.55rem;
  border: none; background: var(--surface); padding: 0.15rem 0.3rem;
  font-size: 1rem; line-height: 1; cursor: pointer;
  color: var(--muted); opacity: 0.4;
  border-radius: 8px;
  box-shadow: 0 0 0 3px var(--surface);
  transition: opacity 0.15s, color 0.15s;
}
.star-btn:hover { opacity: 1; }
.star-btn.on { color: #f59e0b; opacity: 1; }
[data-theme="dark"] .star-btn.on { color: #fbbf24; }
.tag {
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 0.16rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  background: var(--surface-2);
}
.tag.hsc { color: #047857; background: #ecfdf5; border-color: #a7f3d0; }
[data-theme="dark"] .tag.hsc { color: #6ee7b7; background: #06362a; border-color: #0e5c49; }
.tag.trial { color: var(--accent); background: var(--accent-soft); border-color: var(--accent-border); }
.tag.sol { color: #b45309; background: #fffbeb; border-color: #fde68a; }
[data-theme="dark"] .tag.sol { color: #fcd34d; background: #3a2a08; border-color: #6b5113; }
.card h3 { font-size: 0.96rem; line-height: 1.4; letter-spacing: -0.01em; margin-bottom: 0.25rem; }
.card .meta { font-size: 0.83rem; color: var(--muted); font-weight: 550; margin-bottom: 0.65rem; }
.card-actions { display: flex; gap: 0.45rem; flex-wrap: wrap; }
.mini-btn {
  font-size: 0.8rem;
  font-weight: 750;
  padding: 0.4rem 0.7rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}
.mini-btn:hover { border-color: var(--accent); color: var(--accent); }
.mini-btn.go { background: var(--text); color: var(--bg); border-color: var(--text); }
.mini-btn.go:hover { opacity: 0.88; color: var(--bg); }
.empty {
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 2.6rem 1.5rem;
  text-align: center;
  color: var(--muted);
}
.empty b { color: var(--text); display: block; font-size: 1.05rem; margin-bottom: 0.3rem; }

/* Bulk bar */
.bulkbar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  bottom: 18px;
  z-index: 60;
  background: var(--text);
  color: var(--bg);
  border-radius: 16px;
  padding: 0.7rem 0.7rem 0.7rem 1.1rem;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  max-width: calc(100vw - 2rem);
  flex-wrap: wrap;
}
.bulkbar.show { opacity: 1; pointer-events: auto; transform: translateX(-50%) translateY(0); }
.bulkbar b { font-size: 0.92rem; white-space: nowrap; }
.bulkbar .bb-btn {
  border: none;
  border-radius: 10px;
  padding: 0.55rem 0.9rem;
  font-size: 0.85rem;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}
.bb-zip { background: #4f46e5; color: #fff; }
.bb-zip:hover { background: #4338ca; }
.bb-each { background: rgba(255,255,255,0.16); color: inherit; }
.bb-ghost { background: transparent; color: inherit; opacity: 0.8; }
.bb-ghost:hover { opacity: 1; }
[data-theme="dark"] .bulkbar { background: #e8eefc; color: #0b1220; }
[data-theme="dark"] .bb-each { background: rgba(0,0,0,0.1); }
.progress { font-size: 0.8rem; opacity: 0.85; font-weight: 600; }

/* Resume bar (interrupted / scheduled batch) */
.resume-bar {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius);
  padding: 0.6rem 0.9rem;
  margin-bottom: 0.9rem;
  box-shadow: var(--shadow);
  font-size: 0.9rem;
  font-weight: 650;
}
.resume-bar[hidden] { display: none; }
.resume-bar span { color: var(--text); }

/* App self-update bar (keyless updater) */
.update-bar {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  flex-wrap: wrap;
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius);
  padding: 0.6rem 0.9rem;
  margin-bottom: 0.9rem;
  box-shadow: var(--shadow);
  font-size: 0.9rem;
  font-weight: 650;
}
.update-bar[hidden] { display: none; }
.update-bar span { color: var(--text); }

/* About / footer */
.about {
  max-width: 1220px;
  margin: 0 auto;
  padding: 0 1.5rem 3rem;
  width: 100%;
}

/* Features band (marketing) */
.features { max-width: 1220px; margin: 0 auto; padding: 1.8rem 1.5rem 0.8rem; width: 100%; }
.features h2 { font-size: 1.5rem; letter-spacing: -0.02em; margin-bottom: 1.1rem; text-align: center; }
.features-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 0.9rem; }
.feature-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.15rem;
  box-shadow: var(--shadow);
}
.feature-card h3 { font-size: 0.98rem; margin-bottom: 0.35rem; letter-spacing: -0.01em; }
.feature-card p { font-size: 0.88rem; color: var(--muted); }
.feature-card code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 0.05rem 0.35rem;
  border-radius: 6px;
  color: var(--text);
}
.feat-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 1.6rem;
  justify-content: center;
  margin-top: 1.4rem;
  padding: 0.9rem 1.2rem;
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius);
}
.feat-stats span { font-size: 0.86rem; font-weight: 700; color: var(--accent); }
.about-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.4rem 1.5rem;
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.4rem;
}
.about-card h2 { font-size: 1.05rem; margin-bottom: 0.5rem; }
.about-card p, .about-card li { font-size: 0.9rem; color: var(--muted); }
/* Third card (Content & removal) spans the row for policy prominence */
.about-card > div:nth-child(3) { grid-column: 1 / -1; border-top: 1px solid var(--border); padding-top: 1.1rem; }
.about-card code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 0.1rem 0.4rem;
  border-radius: 6px;
  color: var(--text);
}
.about-card ol { padding-left: 1.1rem; display: flex; flex-direction: column; gap: 0.3rem; }
footer {
  border-top: 1px solid var(--border);
  padding: 1.6rem 1.5rem 5.5rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.86rem;
}
footer b { color: var(--text); }

/* Body scroll lock while the mobile drawer is open */
body.drawer-lock { overflow: hidden; }

/* Mobile filters */
.filters-toggle { display: none; }

@media (max-width: 920px) {
  .layout { grid-template-columns: 1fr; }
  .filters-toggle { display: inline-flex; }
  .about-card { grid-template-columns: 1fr; }
  .nav-links { display: none; }
  .host-badge { display: none; }
  /* Sidebar becomes a slide-in drawer over a backdrop */
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    height: 100dvh;
    max-height: none;
    width: min(84vw, 340px);
    background: var(--bg);
    z-index: 120;
    padding: 1rem 1rem 2rem;
    transform: translateX(-103%);
    transition: transform 0.25s ease;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: none; }
  .drawer-close { display: grid; align-self: flex-end; margin-bottom: 0.3rem; }
  .drawer-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, 0.45);
    z-index: 110;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s;
  }
  .drawer-backdrop.show { opacity: 1; pointer-events: auto; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); }
}

@media (max-width: 640px) {
  .hero { padding: 2.2rem 1rem 1.2rem; }
  .hero h1 { font-size: 1.75rem; }
  .layout { padding: 1rem 0.9rem 4.5rem; gap: 1rem; }
  .stats-row { gap: 1.2rem; margin-top: 1.2rem; }
  .toolbar { gap: 0.5rem; }
  .btn { padding: 0.45rem 0.6rem; font-size: 0.8rem; }
  .check { padding: 0.45rem 0.4rem; }
  .check input { width: 17px; height: 17px; }
  .bulkbar { left: 0.7rem; right: 0.7rem; transform: translateY(20px); justify-content: center; }
  .bulkbar.show { transform: translateY(0); }
  .bulkbar b { font-size: 0.8rem; }
  .bb-btn { padding: 0.5rem 0.65rem; font-size: 0.78rem; }
  .reader-title { max-width: 55%; }
}

/* ---------- embedded reader overlay (in-page; v0.7.0) ---------- */
.reader-overlay { position: fixed; inset: 0; z-index: 200; background: var(--bg, #f7f8fb); display: flex; flex-direction: column; }
.reader-overlay[hidden] { display: none; }
.reader-bar { display: flex; align-items: center; gap: .55rem; padding: .5rem .9rem; background: var(--card, #fff); border-bottom: 1px solid rgba(125,125,155,.25); flex-wrap: wrap; }
.bar-btn { background: var(--soft, #eef0f6); color: var(--text, #1c2333); border: 1px solid rgba(125,125,155,.25); border-radius: 8px; padding: .38rem .7rem; font-weight: 700; font-size: .8rem; cursor: pointer; text-decoration: none; }
.bar-btn:hover { background: var(--primary, #4f46e5); color: #fff; }
.bar-select { border: 1px solid rgba(125,125,155,.35); border-radius: 8px; padding: .3rem .45rem; font-size: .8rem; background: var(--card, #fff); color: var(--text, #1c2333); }
.reader-title { font-weight: 800; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 40%; }
.reader-pageinfo { color: var(--muted, #6b7280); font-size: .78rem; }
.reader-pagenum { font-variant-numeric: tabular-nums; font-size: .8rem; font-weight: 700; color: var(--muted, #64748b); min-width: 4.2rem; text-align: center; }
.reader-timer { font-variant-numeric: tabular-nums; font-weight: 800; font-size: .9rem; color: var(--primary, #4f46e5); min-width: 4.6rem; text-align: center; }
.reader-timer.warn { color: #d97706; }
.reader-timer.done { color: #dc2626; }
.reader-scroll { flex: 1; overflow: auto; text-align: center; background: var(--soft, #e9ecf3); }
/* Continuous scroll: one placeholder per page, rendered lazily in a window
   around the viewport. aspect-ratio keeps scroll height stable before a
   page renders; the placeholder shows its page number while empty. */
.rpage { position: relative; margin: 1rem auto; width: min(96%, 860px); background: var(--surface-2, #eef0f6); box-shadow: 0 2px 14px rgba(10,15,40,.35); overflow: hidden; }
.rpage::before { content: attr(data-n); position: absolute; inset: 0; display: grid; place-items: center; color: #aab2c8; font: 800 2.2rem system-ui; }
.rpage.done { background: #fff; }
.rpage.done::before { content: none; }
.rpage canvas { display: block; width: 100%; height: auto; }
.rpage.rerr::before { content: "⚠ " attr(data-n); color: #dc2626; font-size: 1.2rem; }
.reader-err { color: #dc2626; padding: 1.2rem; font-weight: 700; }
.bar-btn:disabled { opacity: .45; cursor: not-allowed; }
/* F5 split-view: paper + solutions side by side */
.reader-split { flex: 1; display: flex; min-height: 0; }
.reader-pane { flex: 1; min-width: 0; display: flex; flex-direction: column; border-right: 1px solid rgba(125,125,155,.25); position: relative; }
.reader-pane:last-child { border-right: none; }
.reader-pane .pane-scroll { flex: 1; }
.reader-pane.focus::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  box-shadow: inset 0 0 0 2px var(--primary, #4f46e5); z-index: 2;
}
.pane-bar {
  display: flex; align-items: center; gap: .5rem;
  padding: .3rem .7rem; font-size: .78rem; font-weight: 700;
  background: var(--card, #fff); border-bottom: 1px solid rgba(125,125,155,.25);
}
.pane-label { color: var(--muted, #6b7280); text-transform: uppercase; letter-spacing: .06em; font-size: .7rem; }
.pane-num { font-variant-numeric: tabular-nums; color: var(--muted, #64748b); min-width: 3.6rem; text-align: center; }
.pane-label + .bar-btn { margin-left: auto; }
.pane-close { opacity: .85; }
.bar-btn.on { background: var(--primary, #4f46e5); color: #fff; }
/* Class-kill: an author display rule (e.g. .reader-pane { display:flex })
   overrides the UA's [hidden] → display:none, which kept the empty
   solutions pane permanently visible. This one rule makes [hidden]
   authoritative everywhere, present and future. */
[hidden] { display: none !important; }
@media (max-width: 860px) {
  .reader-split { flex-direction: column; }
  .reader-pane { border-right: none; border-bottom: 1px solid rgba(125,125,155,.25); }
  .reader-pane:last-child { border-bottom: none; }
  .reader-title { max-width: 100%; }
}

/* ---------- Library dropdown menu (v0.8.0) ---------- */
.menu { position: relative; display: inline-block; }
.menu-summary { list-style: none; cursor: pointer; user-select: none; }
.menu-summary::-webkit-details-marker { display: none; }
.menu[open] .menu-summary { background: var(--accent, #4f46e5); color: #fff; }
.menu-list { position: absolute; right: 0; top: calc(100% + 6px); background: var(--card, #fff); border: 1px solid var(--border, #e2e5ee); border-radius: var(--radius, 12px); box-shadow: var(--shadow-lg, 0 12px 32px rgba(10,15,40,.18)); min-width: 11rem; padding: .3rem; z-index: 60; }
.menu-list button { display: block; width: 100%; text-align: left; background: none; border: none; border-radius: var(--radius-sm, 8px); padding: .5rem .7rem; font-weight: 700; font-size: .82rem; color: var(--text, #1c2333); cursor: pointer; }
.menu-list button:hover { background: var(--accent-soft, #eef0ff); color: var(--accent, #4f46e5); }

/* ---------- slow-route tag (v0.8.2) ---------- */
.tag.slow { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }
[data-theme="dark"] .tag.slow { background: #451a03; color: #fcd34d; border-color: #92400e; }

/* ---------- downloaded-before badge (device-local, web) ---------- */
.tag.got { color: #047857; background: #ecfdf5; border-color: #a7f3d0; }
[data-theme="dark"] .tag.got { color: #6ee7b7; background: #06362a; border-color: #0e5c49; }

/* Static subject directory (footer grid, injected by tools/landing-pages.cjs
   and tools/coverage-report.cjs — the HTML-sitemap crawl lane) */
.footer-subjects { max-width: 1200px; margin: 0 auto; padding: 1.1rem 1.2rem 2.4rem; border-top: 1px solid var(--border); }
.footer-subjects h2 { font-size: .95rem; margin: 0 0 .7rem; }
.footer-subjects h2 a { color: var(--accent); text-decoration: none; font-weight: 600; }
.footer-subjects .f-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: .3rem .7rem; font-size: .8rem; }
.footer-subjects .f-grid a { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; padding: .32rem .6rem; border: 1px solid var(--border); border-radius: 9px; text-decoration: none; color: var(--text); }
.footer-subjects .f-grid a:hover { border-color: var(--accent); }
.footer-subjects .f-grid small { color: var(--muted); white-space: nowrap; }
