/* ==========================================================
   格致 · 大一数理研习台
   A quiet, paper-like study surface.
   ========================================================== */

:root {
  --bg: #f6f4ee;
  --bg-soft: #efebe2;
  --paper: #fffdf9;
  --paper-2: #faf7f0;
  --ink: #1b1a17;
  --ink-soft: #45413a;
  --muted: #8a8378;
  --faint: #b3aa9c;
  --line: #e4ded2;
  --line-strong: #cfc7b7;
  --sage: #2f5d50;
  --sage-2: #3e7565;
  --sage-soft: #e8efe9;
  --clay: #9a4b2e;
  --clay-2: #b25c3a;
  --clay-soft: #f3e8e1;
  --gold: #a9803f;
  --shadow-sm: 0 1px 2px rgba(27, 26, 23, 0.04);
  --shadow-md: 0 1px 2px rgba(27, 26, 23, 0.04), 0 14px 34px -22px rgba(27, 26, 23, 0.35);
  --serif: "Iowan Old Style", "Palatino Linotype", "Songti SC", "Noto Serif SC",
    "Source Han Serif SC", "STSong", "SimSun", Georgia, serif;
  --sans: "Inter", "Segoe UI", "PingFang SC", "Noto Sans SC", "Microsoft YaHei",
    system-ui, -apple-system, sans-serif;
  --mono: "SFMono-Regular", "Cascadia Code", "JetBrains Mono", Consolas, monospace;
  --sidebar: 306px;
  --radius: 13px;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

[data-theme="dark"] {
  --bg: #121110;
  --bg-soft: #181614;
  --paper: #1b1917;
  --paper-2: #1f1d19;
  --ink: #efe9dd;
  --ink-soft: #c6bdae;
  --muted: #918878;
  --faint: #6b6357;
  --line: #2c2823;
  --line-strong: #413a30;
  --sage: #8fb8a6;
  --sage-2: #a5c9b8;
  --sage-soft: #1c2823;
  --clay: #d08a6a;
  --clay-2: #e0a184;
  --clay-soft: #2a1e18;
  --gold: #c8a163;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 1px 2px rgba(0, 0, 0, 0.3), 0 18px 40px -24px rgba(0, 0, 0, 0.8);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image: radial-gradient(rgba(120, 108, 88, 0.11) 0.5px, transparent 0.5px);
  background-size: 22px 22px;
  opacity: 0.5;
}

[data-theme="dark"] body::before { opacity: 0.25; }

::selection { background: rgba(47, 93, 80, 0.18); }

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
svg { display: block; }

.read-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: transparent;
  z-index: 80;
  pointer-events: none;
}
.read-progress i {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--sage), var(--gold));
  transition: width 0.08s linear;
}

/* ---------- shell ---------- */

.shell { position: relative; z-index: 1; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar);
  padding: 30px 26px 22px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  border-right: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 82%, var(--paper));
  backdrop-filter: blur(8px);
  z-index: 40;
  overflow-y: auto;
  scrollbar-width: thin;
}

.brand { display: flex; align-items: center; gap: 11px; color: var(--ink); }
.brand-mark { color: var(--sage); display: flex; }
.brand-text { display: flex; flex-direction: column; line-height: 1; }
.brand-text strong {
  font-family: var(--serif);
  font-size: 25px;
  font-weight: 600;
  letter-spacing: 0.16em;
}
.brand-text em {
  font-style: normal;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.34em;
  color: var(--muted);
  margin-top: 7px;
}

.brand-sub {
  margin: -14px 0 0 45px;
  font-size: 11.5px;
  letter-spacing: 0.14em;
  color: var(--faint);
}

.search {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 11px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--paper);
  color: var(--muted);
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.search:focus-within { border-color: var(--line-strong); box-shadow: 0 0 0 3px var(--sage-soft); }
.search input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 13.5px;
  font-family: var(--sans);
}
.search input::placeholder { color: var(--faint); }
.search kbd {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--faint);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 5px;
  background: var(--paper-2);
}

.nav { display: flex; flex-direction: column; gap: 4px; }

.nav-home {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13.5px;
  color: var(--ink-soft);
  transition: background 0.15s var(--ease);
}
.nav-home:hover { background: var(--bg-soft); }
.nav-home.active { background: var(--ink); color: var(--bg); }

.nav-group { margin-top: 14px; }
.nav-group-head {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 10px;
  border: 0;
  background: none;
  cursor: pointer;
  text-align: left;
  color: var(--muted);
}
.nav-group-head .num {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--faint);
}
.nav-group-head .name {
  font-size: 12px;
  letter-spacing: 0.18em;
  font-weight: 600;
}
.nav-group-head .count {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--faint);
}
.nav-group-head .chev {
  color: var(--faint);
  transition: transform 0.25s var(--ease);
}
.nav-group[data-open="false"] .chev { transform: rotate(-90deg); }

.nav-items { display: flex; flex-direction: column; gap: 1px; overflow: hidden; }
.nav-group[data-open="false"] .nav-items { display: none; }

.nav-item {
  display: flex;
  align-items: baseline;
  gap: 9px;
  padding: 6px 10px 6px 14px;
  border-radius: 7px;
  font-size: 12.5px;
  color: var(--ink-soft);
  line-height: 1.5;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}
.nav-item .idx {
  font-family: var(--mono);
  font-size: 9.5px;
  color: var(--faint);
  min-width: 22px;
  letter-spacing: 0.02em;
}
.nav-item span.t { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-item:hover { background: var(--bg-soft); color: var(--ink); }
.nav-item.active { background: var(--sage-soft); color: var(--sage); font-weight: 600; }
.nav-item.active .idx { color: var(--sage); }
.nav-item .tick {
  width: 13px;
  height: 13px;
  color: var(--sage);
  opacity: 0;
  transform: translateY(2px);
}
.nav-item.done .tick { opacity: 1; }
[data-theme="dark"] .nav-item.active { background: var(--sage-soft); color: var(--sage-2); }

.sidebar-foot {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--muted);
}
.foot-line { display: flex; align-items: center; gap: 7px; color: var(--ink-soft); font-size: 12px; }
.foot-line .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--sage); }
.sidebar-foot p { margin: 5px 0 0 13px; color: var(--faint); font-size: 11px; }

/* ---------- main ---------- */

.main { margin-left: var(--sidebar); min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 14px;
  height: 62px;
  padding: 0 44px;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  backdrop-filter: blur(14px) saturate(1.1);
}

.crumbs { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); min-width: 0; }
.crumbs a { color: var(--muted); transition: color 0.15s; white-space: nowrap; }
.crumbs a:hover { color: var(--ink); }
.crumbs .sep { color: var(--faint); font-family: var(--mono); font-size: 10px; }
.crumbs .here { color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.top-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.top-link { font-size: 12.5px; color: var(--muted); padding: 5px 9px; border-radius: 6px; }
.top-link:hover { color: var(--ink); background: var(--bg-soft); }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.icon-btn:hover { background: var(--bg-soft); border-color: var(--line); color: var(--ink); }
.menu-btn { display: none; }

.i-moon { display: none; }
[data-theme="dark"] .i-sun { display: none; }
[data-theme="dark"] .i-moon { display: block; }

#view { flex: 1; width: 100%; max-width: 1060px; margin: 0 auto; padding: 46px 44px 30px; }
#view:focus { outline: none; }

/* ---------- home ---------- */

.hero { padding: 34px 0 10px; max-width: 880px; }

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.26em;
  color: var(--muted);
  text-transform: uppercase;
}
.eyebrow::before { content: ""; width: 30px; height: 1px; background: var(--line-strong); }

.hero h1 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(38px, 5.4vw, 66px);
  line-height: 1.16;
  letter-spacing: -0.015em;
  margin: 22px 0 0;
  text-wrap: balance;
}
.hero h1 .accent { color: var(--sage); font-style: italic; }

.hero-lead {
  margin: 22px 0 0;
  max-width: 590px;
  color: var(--ink-soft);
  font-size: 16px;
  line-height: 1.9;
}
.hero-lead b { font-weight: 600; color: var(--ink); }

.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 26px;
  margin-top: 30px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
  max-width: 760px;
}
.hero-stat { display: flex; flex-direction: column; gap: 2px; }
.hero-stat strong { font-family: var(--serif); font-size: 27px; font-weight: 500; line-height: 1.2; }
.hero-stat span { font-size: 11.5px; letter-spacing: 0.12em; color: var(--muted); }

.subjects {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-top: 52px;
}

.subject-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 300px;
  padding: 28px 28px 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: transform 0.3s var(--ease), box-shadow 0.3s var(--ease), border-color 0.3s var(--ease);
}
.subject-card::after {
  content: "";
  position: absolute;
  inset: auto -40px -60px auto;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--tint) 0%, transparent 68%);
  opacity: 0.85;
  pointer-events: none;
  transition: transform 0.5s var(--ease);
}
.subject-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--line-strong); }
.subject-card:hover::after { transform: scale(1.15); }
.subject-card.math { --tint: var(--sage-soft); --accent: var(--sage); }
.subject-card.phys { --tint: var(--clay-soft); --accent: var(--clay); }

.subject-top { display: flex; align-items: flex-start; justify-content: space-between; }
.subject-no {
  font-family: var(--serif);
  font-size: 44px;
  font-style: italic;
  line-height: 1;
  color: var(--accent);
  opacity: 0.55;
}
.subject-en {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.28em;
  color: var(--muted);
  text-align: right;
  line-height: 1.6;
}
.subject-card h2 {
  font-family: var(--serif);
  font-size: 34px;
  font-weight: 500;
  letter-spacing: 0.02em;
  margin: 28px 0 0;
  line-height: 1.2;
}
.subject-tag { margin: 8px 0 0; font-size: 13px; color: var(--muted); letter-spacing: 0.04em; }
.subject-desc { margin: 16px 0 0; font-size: 13.5px; line-height: 1.8; color: var(--ink-soft); max-width: 330px; }

.subject-foot {
  margin-top: auto;
  padding-top: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
}
.subject-foot .go { display: inline-flex; align-items: center; gap: 7px; color: var(--accent); font-weight: 600; }
.subject-foot .go svg { transition: transform 0.25s var(--ease); }
.subject-card:hover .go svg { transform: translateX(4px); }

.progress-track { height: 3px; border-radius: 2px; background: var(--line); overflow: hidden; margin-top: 12px; }
.progress-track i { display: block; height: 100%; background: var(--accent); border-radius: 2px; transition: width 0.5s var(--ease); }

.howto { margin-top: 74px; }
.section-head { display: flex; align-items: baseline; gap: 16px; margin-bottom: 26px; }
.section-head h2 { font-family: var(--serif); font-size: 22px; font-weight: 500; margin: 0; letter-spacing: 0.02em; }
.section-head .rule { flex: 1; height: 1px; background: var(--line); }
.section-head .en { font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.24em; color: var(--faint); }

.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; border-top: 1px solid var(--line); }
.step { padding: 22px 26px 6px 0; border-right: 1px solid var(--line); }
.step:last-child { border-right: 0; }
.step .n { font-family: var(--mono); font-size: 10.5px; color: var(--faint); letter-spacing: 0.1em; }
.step h3 { font-size: 14.5px; font-weight: 600; margin: 8px 0 6px; }
.step p { font-size: 13px; color: var(--muted); margin: 0; line-height: 1.75; padding-right: 18px; }

/* ---------- subject page ---------- */

.subject-hero { padding: 22px 0 0; }
.subject-hero .eyebrow.math { color: var(--sage); }
.subject-hero .eyebrow.phys { color: var(--clay); }
.subject-hero h1 {
  font-family: var(--serif);
  font-size: clamp(36px, 4.6vw, 54px);
  font-weight: 500;
  line-height: 1.18;
  margin: 18px 0 0;
  letter-spacing: -0.01em;
}
.subject-hero .lead { max-width: 620px; color: var(--ink-soft); font-size: 15.5px; line-height: 1.9; margin: 18px 0 0; }

.subject-meter {
  display: flex;
  align-items: center;
  gap: 22px;
  margin-top: 32px;
  padding: 18px 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
}
.ring { --p: 0; position: relative; width: 58px; height: 58px; flex: none; }
.ring svg { transform: rotate(-90deg); }
.ring .track { stroke: var(--bg-soft); }
.ring .bar { stroke: var(--sage); stroke-linecap: round; transition: stroke-dashoffset 0.6s var(--ease); }
.ring.phys .bar { stroke: var(--clay); }
.ring b {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--serif);
  font-size: 14px;
  font-weight: 600;
}
.meter-copy strong { display: block; font-size: 14px; font-weight: 600; }
.meter-copy span { font-size: 12.5px; color: var(--muted); }
.meter-actions { margin-left: auto; display: flex; gap: 8px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--paper);
  padding: 8px 14px;
  font-size: 12.5px;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.btn:hover { border-color: var(--ink-soft); color: var(--ink); }
.btn.solid { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.btn.solid:hover { background: var(--ink-soft); border-color: var(--ink-soft); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--bg-soft); }

.unit-list { margin-top: 46px; }
.unit-group { margin-bottom: 34px; }
.unit-group-title {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  color: var(--muted);
  text-transform: uppercase;
  margin-bottom: 12px;
}
.unit-group-title::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.unit-row {
  display: flex;
  align-items: flex-start;
  gap: 20px;
  padding: 20px 16px 20px 14px;
  border-bottom: 1px solid var(--line);
  transition: background 0.18s var(--ease);
  position: relative;
}
.unit-row:hover { background: var(--paper); }
.unit-row .u-idx {
  font-family: var(--serif);
  font-style: italic;
  font-size: 19px;
  color: var(--faint);
  width: 34px;
  flex: none;
  line-height: 1.5;
}
.unit-row:hover .u-idx { color: var(--accent-ink, var(--sage)); }
.unit-body { flex: 1; min-width: 0; }
.unit-body h3 {
  font-size: 17px;
  font-weight: 600;
  margin: 0;
  line-height: 1.5;
  letter-spacing: 0.01em;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.unit-body p { margin: 4px 0 0; font-size: 13px; color: var(--muted); line-height: 1.7; }
.unit-tags { display: flex; gap: 7px; margin-top: 10px; flex-wrap: wrap; }
.tag {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.06em;
  padding: 2px 7px;
  border-radius: 4px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: var(--paper-2);
}
.tag.done { color: var(--sage); border-color: color-mix(in srgb, var(--sage) 30%, var(--line)); background: var(--sage-soft); }
.unit-right { display: flex; align-items: center; gap: 14px; flex: none; padding-top: 3px; }
.unit-right .arrow { color: var(--faint); transition: transform 0.25s var(--ease), color 0.2s; }
.unit-row:hover .arrow { transform: translateX(4px); color: var(--ink); }

/* ---------- lesson ---------- */

.lesson-head { max-width: 820px; padding-top: 8px; }
.lesson-kicker {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.2em;
  color: var(--muted);
  text-transform: uppercase;
}
.lesson-kicker .chip {
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--sage-soft);
  color: var(--sage);
  letter-spacing: 0.1em;
}
.lesson-kicker .chip.phys { background: var(--clay-soft); color: var(--clay); }

.lesson-head h1 {
  font-family: var(--serif);
  font-size: clamp(31px, 4vw, 44px);
  line-height: 1.25;
  font-weight: 500;
  letter-spacing: -0.005em;
  margin: 14px 0 0;
  text-wrap: balance;
}
.lesson-sub { margin: 14px 0 0; font-size: 15.5px; color: var(--ink-soft); line-height: 1.85; max-width: 680px; }

.lesson-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin-top: 22px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
}
.lesson-meta span { display: inline-flex; align-items: center; gap: 6px; }
.lesson-meta b { font-weight: 600; color: var(--ink-soft); }

.lesson-body { max-width: 800px; margin-top: 34px; }

.block { margin-top: 46px; }
.block:first-child { margin-top: 0; }
.block-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 16px;
}
.block-head .k {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.2em;
  color: var(--faint);
  text-transform: uppercase;
  padding-top: 3px;
}
.block-head h2 { font-family: var(--serif); font-size: 22px; font-weight: 500; margin: 0; letter-spacing: 0.02em; }

.prose p { margin: 0 0 14px; font-size: 15px; line-height: 1.95; color: var(--ink-soft); }
.prose p:last-child { margin-bottom: 0; }
.prose strong { color: var(--ink); font-weight: 600; }
.prose em { font-style: italic; color: var(--ink); }

.note {
  margin: 20px 0 0;
  padding: 16px 20px;
  border-left: 2px solid var(--sage);
  background: var(--sage-soft);
  border-radius: 0 8px 8px 0;
  font-size: 13.5px;
  line-height: 1.85;
  color: var(--ink-soft);
}
.note.phys { border-left-color: var(--clay); background: var(--clay-soft); }
.note b { color: var(--ink); }

.formulas {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.formulas > .formula:last-child:nth-child(odd) { grid-column: 1 / -1; }
.formula {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 104px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  overflow-x: auto;
  text-align: center;
}
.formula .tex { font-size: 15px; color: var(--ink); }
.formula .cap { margin-top: 10px; font-size: 11.5px; color: var(--muted); line-height: 1.6; }

.examples { display: flex; flex-direction: column; gap: 14px; }
.example {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  overflow: hidden;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.example:hover { border-color: var(--line-strong); }
.example.open { box-shadow: var(--shadow-sm); border-color: var(--line-strong); }

.ex-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px 0;
}
.lvl {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.12em;
  padding: 2.5px 8px;
  border-radius: 4px;
  flex: none;
}
.lvl.basic { background: var(--sage-soft); color: var(--sage); }
.lvl.mid { background: color-mix(in srgb, var(--gold) 13%, var(--paper)); color: var(--gold); }
.lvl.hard { background: var(--clay-soft); color: var(--clay); }
.ex-title { font-size: 13.5px; font-weight: 600; color: var(--ink); }
.ex-num { margin-left: auto; font-family: var(--mono); font-size: 10px; color: var(--faint); }

.ex-q { padding: 10px 20px 16px; font-size: 14.5px; line-height: 1.9; color: var(--ink-soft); }
.ex-q .q-label {
  display: inline-block;
  font-size: 10px;
  letter-spacing: 0.14em;
  color: var(--faint);
  font-family: var(--mono);
  margin-right: 6px;
}

.ex-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 11px 20px;
  border: 0;
  border-top: 1px solid var(--line);
  background: var(--paper-2);
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}
.ex-toggle:hover { color: var(--ink); background: var(--bg-soft); }
.ex-toggle .plus {
  width: 14px;
  height: 14px;
  position: relative;
  flex: none;
}
.ex-toggle .plus::before,
.ex-toggle .plus::after {
  content: "";
  position: absolute;
  inset: 50% 0 auto 0;
  height: 1px;
  background: currentColor;
  transition: transform 0.25s var(--ease);
}
.ex-toggle .plus::after { transform: rotate(90deg); }
.example.open .ex-toggle .plus::after { transform: rotate(0); }
.ex-toggle .txt { flex: 1; text-align: left; }
.ex-toggle .up { display: none; }
.example.open .ex-toggle .up { display: inline; }
.example.open .ex-toggle .down { display: none; }

.ex-body {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.35s var(--ease);
}
.example.open .ex-body { grid-template-rows: 1fr; }
.ex-inner { overflow: hidden; }
.ex-inner-pad { padding: 4px 20px 20px; }

.hint {
  display: flex;
  gap: 10px;
  padding: 11px 14px;
  border-radius: 8px;
  background: var(--bg-soft);
  font-size: 13px;
  line-height: 1.75;
  color: var(--ink-soft);
  margin-bottom: 14px;
}
.hint b { font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.12em; color: var(--faint); flex: none; padding-top: 3px; }

.steps-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 11px; }
.steps-list li {
  position: relative;
  padding-left: 28px;
  font-size: 14px;
  line-height: 1.9;
  color: var(--ink-soft);
}
.steps-list li::before {
  content: counter(stepc);
  counter-increment: stepc;
  position: absolute;
  left: 0;
  top: 2px;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-size: 9px;
  color: var(--muted);
}
.steps-list { counter-reset: stepc; }

.answer {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-top: 16px;
  padding: 12px 16px;
  border-radius: 8px;
  background: var(--sage-soft);
  border: 1px solid color-mix(in srgb, var(--sage) 22%, transparent);
}
.answer.phys { background: var(--clay-soft); border-color: color-mix(in srgb, var(--clay) 22%, transparent); }
.answer .lb {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.16em;
  color: var(--sage);
  flex: none;
  padding-top: 2px;
}
.answer.phys .lb { color: var(--clay); }
.answer .val { font-size: 14px; color: var(--ink); line-height: 1.8; }

.lesson-end {
  margin-top: 54px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.mark-btn { min-width: 148px; justify-content: center; }
.mark-btn.is-done { background: var(--sage-soft); border-color: color-mix(in srgb, var(--sage) 30%, var(--line)); color: var(--sage); }

.pager { display: flex; gap: 12px; margin-top: 26px; }
.pager a {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 15px 18px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  transition: border-color 0.2s, background 0.2s;
  min-width: 0;
}
.pager a:hover { border-color: var(--line-strong); background: var(--paper-2); }
.pager .dir { font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.16em; color: var(--faint); }
.pager .ttl { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pager a.next { text-align: right; align-items: flex-end; }
.pager a.only { align-items: flex-start; text-align: left; }

/* ---------- misc ---------- */

.site-foot {
  max-width: 1060px;
  width: 100%;
  margin: 0 auto;
  padding: 26px 44px 38px;
  border-top: 1px solid var(--line);
  font-size: 11px;
  color: var(--faint);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  letter-spacing: 0.04em;
}
.foot-dot { color: var(--line-strong); }

.empty {
  padding: 60px 0;
  text-align: center;
  color: var(--muted);
}
.empty h3 { font-family: var(--serif); font-weight: 500; font-size: 20px; color: var(--ink); margin: 0 0 8px; }
.empty p { margin: 0; font-size: 13px; }

.scrim {
  position: fixed;
  inset: 0;
  background: rgba(20, 18, 15, 0.42);
  backdrop-filter: blur(2px);
  z-index: 35;
  opacity: 0;
  transition: opacity 0.25s var(--ease);
}
.scrim.show { opacity: 1; }

.view-enter { animation: rise 0.45s var(--ease) both; }
@keyframes rise {
  from { opacity: 0; transform: translateY(9px); }
  to { opacity: 1; transform: none; }
}

.katex { font-size: 1.02em; }
.katex-display { margin: 0.65em 0; overflow-x: auto; overflow-y: hidden; padding: 2px 0; }

/* ---------- responsive ---------- */

@media (max-width: 1080px) {
  :root { --sidebar: 258px; }
  #view { padding: 38px 32px 26px; }
  .topbar { padding: 0 32px; }
  .site-foot { padding-left: 32px; padding-right: 32px; }
}

@media (max-width: 880px) {
  .sidebar {
    transform: translateX(-102%);
    transition: transform 0.32s var(--ease);
    width: min(320px, 86vw);
    box-shadow: 0 30px 60px -20px rgba(0, 0, 0, 0.35);
  }
  .sidebar.open { transform: none; }
  .main { margin-left: 0; }
  .menu-btn { display: inline-flex; }
  .topbar { padding: 0 18px; height: 58px; }
  #view { padding: 30px 18px 20px; }
  .site-foot { padding: 22px 18px 32px; }
  .subjects { grid-template-columns: 1fr; gap: 14px; }
  .subject-card { min-height: 260px; }
  .steps { grid-template-columns: 1fr; }
  .step { border-right: 0; border-bottom: 1px solid var(--line); padding: 18px 0 16px; }
  .step:last-child { border-bottom: 0; }
  .formulas { grid-template-columns: 1fr; }
  .hero { padding-top: 16px; }
  .hero-meta { gap: 18px 26px; }
  .subject-meter { flex-wrap: wrap; }
  .meter-actions { margin-left: 0; width: 100%; }
  .unit-row { padding: 17px 6px; gap: 12px; }
  .unit-row .u-idx { width: 26px; font-size: 16px; }
  .pager { flex-direction: column; }
  .pager a.next { align-items: flex-start; text-align: left; }
  .lesson-end { align-items: flex-start; }
}

@media (max-width: 520px) {
  body { font-size: 15px; }
  .top-actions .top-link { display: none; }
  .crumbs { font-size: 11.5px; }
  .hero h1 { font-size: 34px; }
  .hero-lead { font-size: 14.5px; }
  .subject-card { padding: 22px 20px 20px; }
  .lesson-meta { gap: 6px 14px; font-size: 11.5px; }
  .ex-head { flex-wrap: wrap; }
  .ex-num { margin-left: 0; }
  .lesson-body { margin-top: 26px; }
  .block { margin-top: 36px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
  html { scroll-behavior: auto; }
}

@media print {
  .sidebar, .topbar, .site-foot, .pager, .lesson-end, .scrim { display: none !important; }
  .main { margin: 0; }
  #view { max-width: none; padding: 0; }
  .example .ex-body { grid-template-rows: 1fr !important; }
  .ex-toggle { display: none; }
}
