/* ---------- Tokens ---------- */
:root {
  --bg: #f4f1e9;
  --bg-2: #eae6da;
  --paper: #fffdf8;
  --paper-2: #faf7ef;
  --ink: #15232c;
  --ink-2: #30444e;
  --muted: #6b787e;
  --line: #ddd7c8;
  --line-2: #ece7db;
  --accent: #1f6f63;
  --accent-2: #2b8a7a;
  --accent-soft: #dcebe5;
  --accent-ink: #ffffff;
  --gold: #b97b2c;
  --gold-soft: #f5e9d4;
  --red: #a94a40;
  --red-soft: #f6ded9;
  --blue: #2f5f9e;
  --blue-soft: #dfe9f5;
  --grid: rgba(21, 35, 44, 0.045);
  --shadow: 0 1px 2px rgba(21, 35, 44, 0.05), 0 14px 34px -14px rgba(21, 35, 44, 0.22);
  --shadow-sm: 0 1px 2px rgba(21, 35, 44, 0.06), 0 6px 16px -8px rgba(21, 35, 44, 0.2);
  --radius: 20px;
  --sans: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --mono: "Cascadia Mono", "Cascadia Code", Consolas, ui-monospace, SFMono-Regular, monospace;
  --nav-w: 252px;
}

[data-theme="dark"] {
  --bg: #0e161b;
  --bg-2: #16232a;
  --paper: #15222a;
  --paper-2: #182731;
  --ink: #edf2ef;
  --ink-2: #c6d2d1;
  --muted: #91a1a4;
  --line: #293b45;
  --line-2: #21323b;
  --accent: #63c7b3;
  --accent-2: #7ad6c3;
  --accent-soft: #173b36;
  --accent-ink: #0e1b1f;
  --gold: #e0a458;
  --gold-soft: #3a2c1a;
  --red: #e08d83;
  --red-soft: #3b2320;
  --blue: #82abdd;
  --blue-soft: #1d3147;
  --grid: rgba(255, 255, 255, 0.035);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 18px 42px -18px rgba(0, 0, 0, 0.7);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 18px -10px rgba(0, 0, 0, 0.55);
}

[data-mod="1"] { --mod-color: #1f6f63; --mod-soft: #dcebe5; }
[data-mod="2"] { --mod-color: #2f5f9e; --mod-soft: #dfe9f5; }
[data-mod="3"] { --mod-color: #a86d22; --mod-soft: #f5e9d4; }
[data-mod="4"] { --mod-color: #a94a40; --mod-soft: #f6ded9; }

[data-theme="dark"] [data-mod="1"] { --mod-color: #6cc4b2; --mod-soft: #173b36; }
[data-theme="dark"] [data-mod="2"] { --mod-color: #82abdd; --mod-soft: #1d3147; }
[data-theme="dark"] [data-mod="3"] { --mod-color: #e0a458; --mod-soft: #3a2c1a; }
[data-theme="dark"] [data-mod="4"] { --mod-color: #e08d83; --mod-soft: #3b2320; }

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 34px 34px;
  mask-image: radial-gradient(ellipse at 70% 0%, #000 0%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse at 70% 0%, #000 0%, transparent 75%);
}
* { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 999px;
  border: 3px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background-color: var(--muted); }
[hidden] { display: none !important; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ico {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.ico .fill { fill: currentColor; stroke: none; }
h1, h2, h3, h4, p { margin-top: 0; }
a { color: inherit; }
button { font: inherit; color: inherit; }
::selection { background: var(--accent); color: var(--accent-ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.muted { color: var(--muted); }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Shell ---------- */
.app { position: relative; z-index: 1; display: flex; min-height: 100vh; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--nav-w);
  padding: 24px 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 26px;
  border-right: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 72%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 40;
}
.brand { display: flex; align-items: center; gap: 11px; text-decoration: none; padding: 2px 8px; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center;
  background: var(--ink); color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}
.brand-mark svg { width: 34px; height: 34px; fill: none; stroke: currentColor; stroke-width: 2.4; }
.brand-mark svg circle:nth-child(3) { stroke: var(--gold); }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text b { font-size: 17px; letter-spacing: 0.02em; }
.brand-text small { font-family: var(--mono); font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); margin-top: 4px; }

.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-btn {
  position: relative;
  display: flex; align-items: center; gap: 11px;
  width: 100%;
  padding: 10px 12px;
  border: 0; border-radius: 11px;
  background: transparent; color: var(--muted);
  font-size: 14px; font-weight: 550; text-align: left; cursor: pointer;
  transition: background 0.18s, color 0.18s, transform 0.18s;
}
.nav-btn .ico { width: 19px; height: 19px; }
.nav-btn:hover { background: color-mix(in srgb, var(--ink) 5%, transparent); color: var(--ink); }
.nav-btn.is-active { background: var(--paper); color: var(--ink); box-shadow: var(--shadow-sm); }
.nav-btn.is-active .ico { color: var(--accent); }
.nav-btn.is-active::before {
  content: ""; position: absolute; left: -16px; top: 11px; bottom: 11px;
  width: 3px; border-radius: 0 4px 4px 0; background: var(--accent);
}
.nav-badge {
  margin-left: auto; min-width: 22px; height: 20px; padding: 0 6px;
  display: grid; place-items: center;
  border-radius: 999px; background: var(--accent-soft); color: var(--accent);
  font-family: var(--mono); font-size: 10.5px; font-weight: 700;
}

.side-progress {
  margin-top: auto;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--paper);
  box-shadow: var(--shadow-sm);
}
.side-progress-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); }
.side-progress-top b { font-family: var(--mono); font-size: 11px; color: var(--ink); font-weight: 600; }
.side-progress .bar { margin: 9px 0 8px; }
.side-progress p { margin: 0; font-size: 11px; line-height: 1.5; color: var(--muted); }
.side-foot { display: flex; flex-direction: column; gap: 7px; padding: 0 4px; }
.text-btn {
  border: 0; background: none; padding: 0; text-align: left;
  font-size: 12px; color: var(--muted); cursor: pointer; text-decoration: underline;
  text-decoration-color: var(--line); text-underline-offset: 3px;
}
.text-btn:hover { color: var(--ink); }
.side-note { font-family: var(--mono); font-size: 10px; letter-spacing: 0.08em; color: var(--muted); opacity: 0.75; }

.main {
  position: relative;
  flex: 1;
  min-width: 0;
  margin-left: var(--nav-w);
  padding: 0 40px;
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  max-width: 1160px;
  margin: 0 auto;
  padding: 20px 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  background: var(--bg);
}
.topbar::after {
  content: "";
  position: absolute;
  left: 0; right: 0; top: 100%;
  height: 22px;
  background: linear-gradient(var(--bg), transparent);
  pointer-events: none;
}
.topbar-title { min-width: 0; }
.kicker {
  margin: 0 0 4px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}
.topbar h1 { margin: 0; font-size: 25px; line-height: 1.15; letter-spacing: -0.035em; font-weight: 700; }
.topbar-actions { display: flex; align-items: center; gap: 9px; }
.topbar .about-top-btn { display: none; }
.streak-chip {
  display: inline-flex; align-items: center; gap: 7px;
  height: 38px; padding: 0 13px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--paper); color: var(--ink-2);
  font-size: 12px; font-weight: 600; cursor: default;
  box-shadow: var(--shadow-sm);
}
.streak-chip .ico { width: 16px; height: 16px; color: var(--gold); }
.icon-btn {
  display: inline-grid; place-items: center;
  width: 38px; height: 38px;
  border: 1px solid var(--line); border-radius: 11px;
  background: var(--paper); color: var(--ink-2);
  cursor: pointer; transition: background 0.18s, color 0.18s, transform 0.18s;
}
.icon-btn:hover { background: var(--bg-2); color: var(--ink); }
.icon-btn:active { transform: scale(0.96); }
.theme-btn .only-dark { display: none; }
[data-theme="dark"] .theme-btn .only-light { display: none; }
[data-theme="dark"] .theme-btn .only-dark { display: block; }

.view { display: none; max-width: 1160px; margin: 0 auto; padding-bottom: 40px; }
.view.is-active { display: block; animation: viewIn 0.4s cubic-bezier(0.22, 0.8, 0.25, 1); }
@keyframes viewIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.footer {
  max-width: 1160px; margin: 10px auto 0; padding: 26px 0 34px;
  border-top: 1px solid var(--line);
  display: flex; flex-wrap: wrap; gap: 8px;
  font-size: 11.5px; color: var(--muted);
}
.footer .dot { opacity: 0.5; }

/* ---------- Common ---------- */
.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.bar { height: 6px; border-radius: 999px; background: var(--bg-2); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: inherit; background: var(--accent); transition: width 0.6s cubic-bezier(0.22, 0.8, 0.25, 1); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 18px;
  border: 1px solid transparent; border-radius: 12px;
  font-size: 13.5px; font-weight: 650; letter-spacing: -0.005em;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: transform 0.16s, box-shadow 0.16s, background 0.16s, border-color 0.16s;
}
.btn .ico { width: 17px; height: 17px; }
.btn:active { transform: translateY(1px) scale(0.995); }
.btn.primary { background: var(--ink); color: var(--bg); box-shadow: var(--shadow-sm); }
.btn.primary:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.btn.accent { background: var(--accent); color: var(--accent-ink); }
[data-theme="light"] .btn.accent { color: #fff; }
.btn.accent:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.btn.ghost { background: var(--paper); border-color: var(--line); color: var(--ink); box-shadow: var(--shadow-sm); }
.btn.ghost:hover { background: var(--paper-2); border-color: color-mix(in srgb, var(--ink) 22%, var(--line)); }
.btn.soft { background: var(--bg-2); color: var(--ink); }
.btn.soft:hover { background: color-mix(in srgb, var(--bg-2) 70%, var(--line)); }
.btn.danger-soft { background: var(--red-soft); color: var(--red); }
.btn.danger-soft:hover { background: color-mix(in srgb, var(--red-soft) 70%, var(--red) 10%); }
.btn.sm { min-height: 34px; padding: 6px 12px; font-size: 12px; border-radius: 9px; }
.btn.sm .ico { width: 14px; height: 14px; }
.btn.lg { min-height: 50px; padding: 13px 24px; font-size: 14.5px; border-radius: 14px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; transform: none !important; }

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  min-height: 23px; padding: 2px 8px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--paper); color: var(--muted);
  font-family: var(--mono); font-size: 10.5px; font-weight: 600;
  letter-spacing: 0.02em; white-space: nowrap;
}
.chip.mod { color: var(--mod-color); background: var(--mod-soft); border-color: transparent; }
.chip.marks { color: var(--ink-2); background: var(--bg-2); border-color: transparent; }
.chip.status-new { color: var(--muted); }
.chip.status-learning { color: var(--gold); background: var(--gold-soft); border-color: transparent; }
.chip.status-reviewing { color: var(--blue); background: var(--blue-soft); border-color: transparent; }
.chip.status-mastered { color: var(--accent); background: var(--accent-soft); border-color: transparent; }
.chip.bookmarked { color: var(--gold); background: var(--gold-soft); border-color: transparent; }
.chip.g-correct { color: var(--accent); background: var(--accent-soft); border-color: transparent; font-family: var(--sans); font-size: 11px; font-weight: 700; }
.chip.g-partial { color: var(--gold); background: var(--gold-soft); border-color: transparent; font-family: var(--sans); font-size: 11px; font-weight: 700; }
.chip.g-wrong { color: var(--red); background: var(--red-soft); border-color: transparent; font-family: var(--sans); font-size: 11px; font-weight: 700; }
.chip .ico { width: 12px; height: 12px; }

.filter-chip {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 32px; padding: 5px 12px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--paper); color: var(--muted);
  font-size: 12px; font-weight: 600; cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.filter-chip:hover { border-color: color-mix(in srgb, var(--ink) 25%, var(--line)); color: var(--ink); }
.filter-chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.filter-chip[aria-pressed="true"] .ico { color: var(--accent); }
[data-theme="dark"] .filter-chip[aria-pressed="true"] .ico { color: var(--accent); }

.section-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px;
  margin: 34px 0 14px;
}
.section-head h2 { margin: 0; font-size: 18px; letter-spacing: -0.025em; }
.section-head h2 span { color: var(--muted); font-weight: 500; }
.section-head p { margin: 3px 0 0; font-size: 12.5px; color: var(--muted); }
.section-head .text-btn { font-size: 12px; }

.empty {
  padding: 54px 24px; text-align: center;
  border: 1px dashed var(--line); border-radius: 18px;
  color: var(--muted); background: color-mix(in srgb, var(--paper) 55%, transparent);
}
.empty .ico { width: 30px; height: 30px; color: var(--accent); margin-bottom: 10px; }
.empty h3 { margin: 0 0 6px; font-size: 16px; color: var(--ink); }
.empty p { margin: 0 auto 18px; max-width: 44ch; font-size: 13px; line-height: 1.6; }

/* ---------- Home ---------- */
.hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(340px, 0.88fr);
  min-height: 392px;
  border: 1px solid var(--line);
  border-radius: 26px;
  overflow: hidden;
  background: var(--paper);
  box-shadow: var(--shadow);
}
.hero-copy {
  position: relative;
  padding: clamp(30px, 4vw, 48px);
  display: flex; flex-direction: column; justify-content: center;
}
.hero-copy::before {
  content: "";
  position: absolute; inset: 0; pointer-events: none;
  background-image:
    radial-gradient(circle at 82% 18%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 42%),
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: auto, 28px 28px, 28px 28px;
  mask-image: linear-gradient(105deg, transparent 15%, #000 100%);
  -webkit-mask-image: linear-gradient(105deg, transparent 15%, #000 100%);
}
.hero-copy > * { position: relative; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--mono); font-size: 10.5px; font-weight: 600;
  letter-spacing: 0.16em; text-transform: uppercase; color: var(--accent);
}
.eyebrow::before { content: ""; width: 18px; height: 1px; background: var(--accent); }
.hero h1 {
  margin: 16px 0 16px;
  font-size: clamp(34px, 4.1vw, 53px);
  line-height: 1.02;
  letter-spacing: -0.048em;
  font-weight: 750;
}
.hero h1 em {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 500;
  letter-spacing: -0.025em;
  color: var(--accent);
}
.hero .lede { max-width: 46ch; margin: 0; color: var(--muted); font-size: 14.5px; line-height: 1.68; }
.hero-cta { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 26px; }
.hero-meta {
  display: flex; flex-wrap: wrap; gap: 22px;
  margin-top: 30px; padding-top: 18px;
  border-top: 1px dashed var(--line);
}
.hero-meta div { display: flex; align-items: baseline; gap: 6px; font-size: 12px; color: var(--muted); }
.hero-meta b { font-family: var(--mono); font-size: 15px; color: var(--ink); font-weight: 600; }

.hero-panel {
  position: relative;
  padding: 32px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  background: #15232c;
  color: #edf3ef;
  overflow: hidden;
}
.hero-panel::before {
  content: "";
  position: absolute; inset: 0;
  background-image:
    radial-gradient(circle at 50% 42%, rgba(99, 199, 179, 0.18), transparent 56%),
    linear-gradient(rgba(255, 255, 255, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.045) 1px, transparent 1px);
  background-size: auto, 26px 26px, 26px 26px;
  mask-image: radial-gradient(circle at 50% 45%, #000, transparent 80%);
  -webkit-mask-image: radial-gradient(circle at 50% 45%, #000, transparent 80%);
}
.hero-panel > * { position: relative; }
.ring-wrap { position: relative; width: 190px; height: 190px; }
.ring { width: 100%; height: 100%; transform: rotate(-90deg); overflow: visible; }
.ring circle { fill: none; stroke-width: 9; }
.ring .track { stroke: rgba(255, 255, 255, 0.12); }
.ring .prog { stroke: #63c7b3; stroke-linecap: round; transition: stroke-dasharray 0.9s cubic-bezier(0.22, 0.8, 0.25, 1); filter: drop-shadow(0 0 10px rgba(99, 199, 179, 0.35)); }
.ring-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.ring-center b { font-family: var(--mono); font-size: 39px; font-weight: 600; letter-spacing: -0.04em; line-height: 1; }
.ring-center b small { font-size: 16px; opacity: 0.6; }
.ring-center span { margin-top: 7px; font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.16em; text-transform: uppercase; color: rgba(237, 243, 239, 0.58); }
.hero-panel-stats { display: flex; align-items: center; gap: 0; width: 100%; max-width: 280px; }
.hero-panel-stats div { flex: 1; text-align: center; padding: 0 8px; }
.hero-panel-stats div + div { border-left: 1px solid rgba(255, 255, 255, 0.1); }
.hero-panel-stats b { display: block; font-family: var(--mono); font-size: 17px; font-weight: 600; }
.hero-panel-stats span { font-size: 9.5px; letter-spacing: 0.1em; text-transform: uppercase; color: rgba(237, 243, 239, 0.52); }
.hero-goal { width: 100%; max-width: 280px; }
.hero-goal-top { display: flex; justify-content: space-between; font-size: 10.5px; color: rgba(237, 243, 239, 0.62); margin-bottom: 7px; font-family: var(--mono); }
.hero-goal-top b { color: #edf3ef; font-weight: 600; }
.hero-goal .bar { height: 5px; background: rgba(255, 255, 255, 0.12); }
.hero-goal .bar i { background: #e0a458; }

.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 14px; }
.stat {
  display: flex; align-items: center; gap: 12px;
  padding: 15px 16px;
  border: 1px solid var(--line); border-radius: 16px;
  background: var(--paper); box-shadow: var(--shadow-sm);
}
.stat-ico {
  width: 38px; height: 38px; border-radius: 11px;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
}
.stat-ico .ico { width: 19px; height: 19px; }
.stat.gold .stat-ico { background: var(--gold-soft); color: var(--gold); }
.stat.blue .stat-ico { background: var(--blue-soft); color: var(--blue); }
.stat.red .stat-ico { background: var(--red-soft); color: var(--red); }
.stat b { display: block; font-family: var(--mono); font-size: 19px; font-weight: 600; line-height: 1.15; letter-spacing: -0.02em; }
.stat span { display: block; margin-top: 3px; font-size: 10.5px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }

.module-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.module-card {
  position: relative; overflow: hidden;
  padding: 20px 22px 18px 24px;
  text-align: left;
  border: 1px solid var(--line); border-radius: 17px;
  background: var(--paper); box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}
.module-card::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--mod-color);
}
.module-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--mod-color) 35%, var(--line)); }
.module-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.mod-num { font-family: var(--mono); font-size: 9.5px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--mod-color); }
.mod-due { font-family: var(--mono); font-size: 10px; color: var(--muted); }
.module-card h3 { margin: 8px 0 5px; font-size: 15.5px; letter-spacing: -0.015em; }
.module-card > p { margin: 0; font-size: 11.5px; color: var(--muted); }
.mod-meta { display: flex; align-items: center; gap: 10px; margin-top: 16px; }
.mod-meta .bar { flex: 1; }
.mod-meta .bar i { background: var(--mod-color); }
.mod-meta span { font-family: var(--mono); font-size: 10px; color: var(--muted); white-space: nowrap; }

.home-lower { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.65fr); gap: 12px; margin-top: 12px; }
.queue-card { padding: 20px 20px 12px; }
.queue-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.queue-head h2 { margin: 0; font-size: 15px; letter-spacing: -0.02em; }
.queue-head .text-btn { font-size: 11.5px; }
.queue-list { display: flex; flex-direction: column; }
.queue-row {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 4px; border-top: 1px solid var(--line-2);
  background: none; border-left: 0; border-right: 0; border-bottom: 0;
  text-align: left; cursor: pointer; width: 100%;
}
.queue-row:hover .queue-q { color: var(--accent); }
.queue-q { flex: 1; min-width: 0; font-size: 12.5px; line-height: 1.4; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; transition: color 0.15s; }
.queue-row .chip { flex: 0 0 auto; }

.activity-card { padding: 20px; display: flex; flex-direction: column; }
.activity-card h2 { margin: 0 0 2px; font-size: 15px; letter-spacing: -0.02em; }
.activity-card > p { margin: 0 0 16px; font-size: 11px; color: var(--muted); }
.activity-bars { flex: 1; display: flex; align-items: flex-end; gap: 7px; min-height: 112px; padding-top: 18px; }
.activity-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.activity-col .count { font-family: var(--mono); font-size: 9px; color: var(--muted); }
.activity-col .bar-v {
  width: 100%; max-width: 30px; min-height: 5px;
  border-radius: 5px 5px 2px 2px;
  background: color-mix(in srgb, var(--accent) 30%, var(--bg-2));
  transition: height 0.5s;
}
.activity-col.today .bar-v { background: var(--accent); }
.activity-col .day { font-family: var(--mono); font-size: 9px; color: var(--muted); text-transform: uppercase; }
.activity-col.today .day { color: var(--accent); font-weight: 700; }
.activity-total { display: flex; align-items: baseline; gap: 6px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line-2); font-size: 11px; color: var(--muted); }
.activity-total b { font-family: var(--mono); font-size: 15px; color: var(--ink); }

/* ---------- Study session ---------- */
.narrow { max-width: 840px; margin: 0 auto; }
.study-start { padding: clamp(26px, 4vw, 40px); }
.start-head { display: flex; gap: 16px; align-items: flex-start; justify-content: space-between; }
.start-head h2 { margin: 0 0 6px; font-size: clamp(22px, 3vw, 30px); letter-spacing: -0.035em; }
.start-head p { margin: 0; max-width: 56ch; color: var(--muted); font-size: 13.5px; line-height: 1.65; }
.start-count {
  flex: 0 0 auto; min-width: 92px; padding: 12px 14px;
  border-radius: 14px; background: var(--accent-soft); color: var(--accent);
  text-align: center;
}
.start-count b { display: block; font-family: var(--mono); font-size: 26px; font-weight: 600; line-height: 1.1; }
.start-count span { font-family: var(--mono); font-size: 9px; letter-spacing: 0.1em; text-transform: uppercase; }
.setup-block { margin-top: 28px; padding-top: 20px; border-top: 1px dashed var(--line); }
.setup-label { display: flex; align-items: center; justify-content: space-between; gap: 80px; margin-bottom: 10px; font-family: var(--mono); font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.chip-row { display: flex; flex-wrap: wrap; gap: 7px; }
.start-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px; margin-top: 28px; }
.start-note { font-size: 11.5px; color: var(--muted); max-width: 40ch; line-height: 1.5; }

.session-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.session-info { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-family: var(--mono); font-size: 11px; color: var(--muted); }
.session-info b { color: var(--ink); font-weight: 600; }
.session-head .icon-btn { width: 34px; height: 34px; border-radius: 9px; }
.session-bar { height: 3px; border-radius: 999px; background: var(--bg-2); margin-bottom: 18px; overflow: hidden; }
.session-bar i { display: block; height: 100%; background: var(--accent); border-radius: inherit; transition: width 0.4s; }

.qcard {
  position: relative;
  padding: clamp(24px, 4.2vw, 44px);
  border: 1px solid var(--line); border-radius: 22px;
  background: var(--paper); box-shadow: var(--shadow);
}
.q-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; margin-bottom: 18px; }
.q-meta .spacer { flex: 1; }
.q-meta .chip.bookmarked { border: 0; background: none; padding: 0; font-size: 13px; }
.q-text {
  margin: 0 0 22px;
  font-family: var(--serif);
  font-size: clamp(21px, 2.5vw, 28px);
  font-weight: 600;
  line-height: 1.38;
  letter-spacing: -0.012em;
  color: var(--ink);
}
.q-sub { margin: -10px 0 22px; font-size: 12px; color: var(--muted); }
.reveal-hint { text-align: center; padding: 24px 0 4px; }
.reveal-hint p { margin: 0 0 16px; font-size: 12px; color: var(--muted); }
.kbd-hint { margin-top: 14px; font-size: 10.5px; color: var(--muted); }
kbd {
  display: inline-block; padding: 2px 6px; margin: 0 1px;
  border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px;
  background: var(--bg-2); font-family: var(--mono); font-size: 9.5px; color: var(--ink-2);
}

.answer { margin-top: 6px; padding-top: 24px; border-top: 1px dashed var(--line); animation: reveal 0.35s ease; }
@keyframes reveal { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.answer > *:last-child { margin-bottom: 0; }
.answer p { margin: 0 0 13px; color: var(--ink-2); font-size: 14.5px; line-height: 1.72; }
.answer h4 {
  margin: 22px 0 9px;
  font-family: var(--mono); font-size: 10.5px; font-weight: 700;
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent);
}
.answer h4:first-child { margin-top: 0; }
.answer ul, .answer ol { margin: 0 0 16px; padding-left: 22px; }
.answer li { margin: 0 0 7px; font-size: 14px; line-height: 1.65; color: var(--ink-2); }
.answer li::marker { color: var(--accent); }
.answer ol li::marker { font-family: var(--mono); font-size: 11px; color: var(--accent); }
.answer .formula {
  margin: 4px 0 16px;
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 9px;
  background: var(--bg-2);
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.75;
  color: var(--ink);
  white-space: pre-wrap;
  overflow-x: auto;
}
.answer .note {
  margin: 0 0 16px;
  padding: 10px 13px;
  border-left: 3px solid var(--gold);
  border-radius: 8px;
  background: var(--gold-soft);
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--ink-2);
}
.answer figure { margin: 8px 0 20px; }
.answer figure img {
  width: 100%; height: auto; display: block;
  border: 1px solid var(--line); border-radius: 12px;
  background: #fff;
}
.answer figcaption { margin-top: 7px; font-size: 10.5px; color: var(--muted); text-align: center; }
.table-wrap {
  margin: 6px 0 18px;
  border: 1px solid var(--line); border-radius: 11px;
  overflow-x: auto;
  background: var(--paper);
}
.table-wrap table { width: 100%; border-collapse: collapse; font-size: 12.5px; line-height: 1.5; min-width: 480px; }
.table-wrap th {
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-2);
  font-family: var(--mono); font-size: 9.5px; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase; text-align: left; color: var(--muted);
  white-space: nowrap;
}
.table-wrap td { padding: 9px 12px; border-bottom: 1px solid var(--line-2); vertical-align: top; color: var(--ink-2); }
.table-wrap tr:last-child td { border-bottom: 0; }
.table-wrap td:first-child { font-weight: 650; color: var(--ink); white-space: nowrap; }
.table-wrap tbody tr:hover td { background: color-mix(in srgb, var(--accent) 4%, transparent); }

.rate-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; margin-top: 26px; }
.rate {
  padding: 11px 12px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--paper); text-align: left; cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
}
.rate b { display: block; font-size: 12.5px; font-weight: 650; }
.rate small { display: block; margin-top: 2px; font-family: var(--mono); font-size: 9.5px; color: var(--muted); }
.rate:hover { transform: translateY(-1px); border-color: var(--c); background: color-mix(in srgb, var(--c) 7%, var(--paper)); }
.rate[data-r="again"] { --c: var(--red); }
.rate[data-r="hard"] { --c: var(--gold); }
.rate[data-r="good"] { --c: var(--accent); }
.rate[data-r="easy"] { --c: var(--blue); }
.rate b::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--c); margin-right: 7px; vertical-align: 2px; }

.session-done { text-align: center; padding: clamp(32px, 5vw, 54px); }
.done-badge {
  width: 62px; height: 62px; margin: 0 auto 18px;
  display: grid; place-items: center; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
}
.done-badge .ico { width: 30px; height: 30px; stroke-width: 2.2; }
.session-done h2 { margin: 0 0 8px; font-size: 26px; letter-spacing: -0.035em; }
.session-done > p { margin: 0 auto 24px; max-width: 44ch; color: var(--muted); font-size: 13.5px; line-height: 1.65; }
.done-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; max-width: 480px; margin: 0 auto 26px; }
.done-stat { padding: 12px 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper-2); }
.done-stat b { display: block; font-family: var(--mono); font-size: 20px; font-weight: 600; }
.done-stat span { font-size: 9.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.done-stat.again b { color: var(--red); }
.done-stat.hard b { color: var(--gold); }
.done-stat.good b { color: var(--accent); }
.done-stat.easy b { color: var(--blue); }
.done-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }

/* ---------- Flashcards ---------- */
.deck-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 14px; }
.deck-toolbar .filter-chip { min-height: 30px; font-size: 11.5px; padding: 4px 10px; }
.deck-toolbar .spacer { flex: 1; }
.deck-toolbar .icon-btn { width: 34px; height: 34px; border-radius: 9px; }
.deck-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; font-family: var(--mono); font-size: 10.5px; color: var(--muted); }
.deck-meta b { color: var(--ink); font-weight: 600; }
.deck-bar { height: 3px; background: var(--bg-2); border-radius: 999px; margin-bottom: 16px; overflow: hidden; }
.deck-bar i { display: block; height: 100%; background: var(--accent); transition: width 0.4s; }

.flip-card { height: clamp(360px, 58vh, 570px); perspective: 2000px; margin-bottom: 14px; }
.flip-inner {
  position: relative; width: 100%; height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.55s cubic-bezier(0.22, 0.8, 0.25, 1);
}
.flip-inner.is-flipped { transform: rotateY(180deg); }
.face {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  padding: clamp(22px, 3.6vw, 38px);
  border: 1px solid var(--line); border-radius: 22px;
  background: var(--paper); box-shadow: var(--shadow);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow: hidden;
}
.face.face-back { transform: rotateY(180deg); }
.face-top { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin-bottom: 18px; }
.face-top .spacer { flex: 1; }
.face-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; padding-right: 4px; }
.face-front { justify-content: space-between; }
.face-front .front-q { flex: 1; display: flex; flex-direction: column; justify-content: center; }
.face-front .front-q p {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(23px, 3.2vw, 34px);
  line-height: 1.32; letter-spacing: -0.015em; font-weight: 600;
}
.face-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-top: 16px; border-top: 1px dashed var(--line); font-size: 10.5px; color: var(--muted); }
.face.face-back .answer { border-top: 0; padding-top: 0; margin-top: 0; }
.face.face-back .answer p { font-size: 14px; }
.face.face-back .face-scroll { padding-bottom: 8px; }
.deck-controls { display: flex; align-items: center; gap: 9px; }
.deck-controls .spacer { flex: 1; }
.deck-controls .btn { min-height: 42px; }
.flip-btn { min-width: 150px; }

/* ---------- Test ---------- */
.test-setup { padding: clamp(24px, 4vw, 38px); max-width: 900px; margin: 0 auto; }
.test-setup h2 { margin: 0 0 6px; font-size: clamp(24px, 3.2vw, 32px); letter-spacing: -0.04em; }
.test-setup > p { margin: 0; color: var(--muted); font-size: 13.5px; line-height: 1.65; max-width: 60ch; }
.setup-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px 28px; margin-top: 26px; padding-top: 24px; border-top: 1px dashed var(--line); }
.setup-item h4 { margin: 0 0 9px; font-family: var(--mono); font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.seg { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px; background: var(--bg-2); border-radius: 10px; }
.seg button {
  border: 0; border-radius: 8px; background: transparent;
  padding: 6px 12px; font-size: 12px; font-weight: 600; color: var(--muted);
  cursor: pointer; transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
.seg button.is-on { background: var(--paper); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08); }
.test-summary { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px; margin-top: 28px; padding-top: 20px; border-top: 1px dashed var(--line); }
.test-summary p { margin: 0; font-size: 12px; color: var(--muted); }
.test-run-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.test-run-head .left { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.timer {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 11px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--paper); font-family: var(--mono); font-size: 11px; color: var(--ink-2);
}
.timer.warn { color: var(--red); border-color: color-mix(in srgb, var(--red) 35%, var(--line)); background: var(--red-soft); }
.timer .ico { width: 14px; height: 14px; }
.test-progress-text { font-family: var(--mono); font-size: 10.5px; color: var(--muted); }
.test-progress-text b { color: var(--ink); }
.scratch-label { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 22px 0 8px; font-family: var(--mono); font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
textarea.scratch {
  width: 100%; min-height: 132px; resize: vertical;
  padding: 13px 14px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--bg-2); color: var(--ink);
  font-family: var(--sans); font-size: 13.5px; line-height: 1.6;
}
textarea.scratch:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 15%, transparent); }
textarea.scratch::placeholder { color: var(--muted); opacity: 0.8; }
.test-nav { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 20px; }
.qdots { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 18px; padding-top: 16px; border-top: 1px dashed var(--line); }
.qdot {
  width: 27px; height: 27px; border-radius: 7px;
  border: 1px solid var(--line); background: var(--paper);
  font-family: var(--mono); font-size: 9.5px; color: var(--muted);
  cursor: pointer; transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.qdot:hover { border-color: var(--accent); color: var(--ink); }
.qdot.answered { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.qdot.current { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.qdot.flagged { box-shadow: inset 0 -3px 0 var(--gold); }

.grade-card .answer { margin-top: 20px; }
.your-note {
  margin: 18px 0 6px;
  padding: 13px 15px;
  border: 1px solid var(--line); border-radius: 11px;
  background: var(--bg-2);
}
.your-note h4 { margin: 0 0 5px; font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.your-note p { margin: 0; font-size: 12.5px; line-height: 1.6; color: var(--ink-2); white-space: pre-wrap; }
.grade-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin-top: 22px; }
.grade-btn {
  padding: 12px 10px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--paper); cursor: pointer; text-align: center;
  transition: transform 0.15s, background 0.15s, border-color 0.15s;
}
.grade-btn b { display: block; font-size: 12.5px; }
.grade-btn small { display: block; margin-top: 2px; font-family: var(--mono); font-size: 9px; color: var(--muted); }
.grade-btn:hover { transform: translateY(-1px); border-color: var(--c); background: color-mix(in srgb, var(--c) 8%, var(--paper)); }
.grade-btn.correct { --c: var(--accent); }
.grade-btn.partial { --c: var(--gold); }
.grade-btn.wrong { --c: var(--red); }
.grade-btn.is-on { background: var(--c); border-color: var(--c); color: #fff; }
.grade-btn.is-on small { color: rgba(255, 255, 255, 0.75); }

.result-hero { text-align: center; padding: clamp(30px, 5vw, 50px) 24px; }
.result-ring-wrap { position: relative; width: 168px; height: 168px; margin: 0 auto 18px; }
.result-ring-wrap .ring .prog { stroke: var(--accent); filter: none; }
.result-ring-wrap .ring .track { stroke: var(--bg-2); }
.result-ring-wrap .ring-center b { font-size: 38px; }
.result-ring-wrap .ring-center span { color: var(--muted); }
.result-hero h2 { margin: 0 0 6px; font-size: 26px; letter-spacing: -0.035em; }
.result-hero > p { margin: 0 auto 24px; max-width: 48ch; color: var(--muted); font-size: 13px; line-height: 1.65; }
.result-stats { display: flex; justify-content: center; gap: 22px; flex-wrap: wrap; margin-bottom: 26px; }
.result-stats div { min-width: 74px; }
.result-stats b { display: block; font-family: var(--mono); font-size: 20px; font-weight: 600; }
.result-stats span { font-size: 9.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.result-stats .ok b { color: var(--accent); }
.result-stats .part b { color: var(--gold); }
.result-stats .bad b { color: var(--red); }
.result-breakdown { max-width: 620px; margin: 0 auto 26px; text-align: left; }
.result-breakdown h3 { margin: 0 0 12px; font-size: 14px; }
.breakdown-row { display: grid; grid-template-columns: 54px 1fr 48px; gap: 12px; align-items: center; margin-bottom: 9px; font-size: 11.5px; }
.breakdown-row .name { font-family: var(--mono); font-size: 10.5px; color: var(--muted); }
.breakdown-row .bar { height: 8px; }
.breakdown-row .bar i { background: var(--mod-color, var(--accent)); }
.breakdown-row .pct { font-family: var(--mono); font-size: 10px; text-align: right; color: var(--muted); }
.result-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.review-list { max-width: 840px; margin: 18px auto 0; border-top: 1px solid var(--line); }
.review-item { padding: 16px 2px; border-bottom: 1px solid var(--line); }
.review-top { display: flex; align-items: flex-start; gap: 10px; }
.review-top .chip { margin-top: 1px; }
.review-q { flex: 1; font-size: 13px; line-height: 1.5; color: var(--ink); }
.review-note { margin: 8px 0 0 0; font-size: 11.5px; color: var(--muted); }
.review-item details { margin-top: 8px; }
.review-item summary { font-size: 11px; color: var(--accent); cursor: pointer; }
.review-item .answer { border-top: 0; padding-top: 12px; }

/* ---------- Library ---------- */
.lib-toolbar {
  padding: 14px 16px;
  border: 1px solid var(--line); border-radius: 16px;
  background: var(--paper); box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
}
.search-box {
  display: flex; align-items: center; gap: 9px;
  padding: 0 12px; height: 42px;
  border: 1px solid var(--line); border-radius: 11px;
  background: var(--bg-2);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 12%, transparent); }
.search-box .ico { width: 17px; height: 17px; color: var(--muted); }
.search-box input {
  flex: 1; min-width: 0; border: 0; background: none; outline: none;
  font-family: var(--sans); font-size: 13.5px; color: var(--ink);
}
.search-box input::placeholder { color: var(--muted); }
.search-clear { border: 0; background: none; padding: 2px; color: var(--muted); cursor: pointer; display: grid; place-items: center; }
.search-clear:hover { color: var(--ink); }
.lib-filters { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 11px; }
.lib-filters .divider { width: 1px; background: var(--line); margin: 4px 3px; }
.lib-count { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0 2px 12px; font-size: 11.5px; color: var(--muted); }
.lib-count b { color: var(--ink); font-family: var(--mono); font-size: 11px; }

.lib-part { margin-bottom: 26px; }
.lib-part-head { display: flex; align-items: baseline; gap: 9px; padding-bottom: 8px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.lib-part-head h2 { margin: 0; font-size: 15px; letter-spacing: -0.02em; }
.lib-part-head span { font-family: var(--mono); font-size: 10px; color: var(--muted); }
.lib-mod-head {
  display: flex; align-items: center; gap: 8px;
  margin: 16px 2px 2px;
  font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--mod-color);
}
.lib-mod-head::after { content: ""; flex: 1; height: 1px; background: var(--line-2); }

.lib-item { border-bottom: 1px solid var(--line-2); }
.lib-item summary {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 13px 4px;
  list-style: none; cursor: pointer;
}
.lib-item summary::-webkit-details-marker { display: none; }
.lib-item summary:hover .lib-q { color: var(--accent); }
.lib-num {
  flex: 0 0 auto; width: 28px; height: 28px; margin-top: 1px;
  display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--paper); font-family: var(--mono); font-size: 10px; color: var(--muted);
}
.lib-main { flex: 1; min-width: 0; }
.lib-q { font-size: 13px; line-height: 1.5; color: var(--ink-2); transition: color 0.15s; }
.lib-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; margin-top: 6px; }
.lib-chev { flex: 0 0 auto; margin-top: 4px; color: var(--muted); transition: transform 0.2s; }
.lib-item[open] .lib-chev { transform: rotate(90deg); }
.lib-item[open] .lib-num { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.lib-body { padding: 2px 8px 22px 40px; }
.lib-body .answer { margin-top: 0; padding-top: 8px; border-top: 0; }
.lib-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 18px; padding-top: 14px; border-top: 1px dashed var(--line); }
.lib-actions .btn.sm { min-height: 32px; }

/* ---------- Modal / toast ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center;
  padding: 20px;
  background: rgba(10, 18, 22, 0.55);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
}
.modal {
  position: relative; width: 100%; max-width: 540px;
  max-height: calc(100vh - 40px); overflow-y: auto;
  padding: 30px;
  border: 1px solid var(--line); border-radius: 22px;
  background: var(--paper); box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.5);
  animation: modalIn 0.28s cubic-bezier(0.22, 0.8, 0.25, 1);
}
@keyframes modalIn { from { opacity: 0; transform: translateY(14px) scale(0.98); } to { opacity: 1; transform: none; } }
.modal h2 { margin: 8px 0 12px; font-size: 25px; letter-spacing: -0.035em; }
.modal p { font-size: 13px; line-height: 1.7; color: var(--ink-2); }
.modal .muted { color: var(--muted); font-size: 12px; }
.modal-close { position: absolute; top: 14px; right: 14px; width: 34px; height: 34px; border-radius: 9px; }
.about-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin: 18px 0; }
.about-grid div { padding: 12px 8px; text-align: center; border: 1px solid var(--line); border-radius: 11px; background: var(--paper-2); }
.about-grid b { display: block; font-family: var(--mono); font-size: 21px; font-weight: 600; }
.about-grid span { font-size: 9px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.modal-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0 12px; }
.fineprint { font-size: 10px !important; color: var(--muted) !important; margin: 0; }

.toast {
  position: fixed; left: 50%; bottom: 26px; z-index: 120;
  transform: translate(-50%, 16px);
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--ink); color: var(--bg);
  font-size: 12px; font-weight: 600;
  box-shadow: var(--shadow);
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  max-width: calc(100vw - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.noscript { padding: 20px; text-align: center; background: var(--red-soft); color: var(--red); }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .main { padding: 0 28px; }
  .hero { grid-template-columns: minmax(0, 1fr) minmax(300px, 0.8fr); }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1040px) {
  .home-lower { grid-template-columns: 1fr; }
  .activity-card { min-height: 220px; }
  .activity-bars { max-width: 100%; }
}
@media (max-width: 900px) {
  .sidebar { display: none; }
  .topbar .about-top-btn { display: inline-grid; }
  .main { margin-left: 0; padding: 0 22px; }
  .tabbar { display: grid; }
  .footer { padding-bottom: 92px; }
  .topbar { padding-top: 16px; }
  .toast { bottom: 84px; }
  .hero { grid-template-columns: 1fr; }
  .hero-copy { padding: 34px 30px; }
  .hero-panel { flex-direction: row; flex-wrap: wrap; justify-content: center; padding: 26px 24px; gap: 20px 30px; }
  .hero-panel .ring-wrap { width: 154px; height: 154px; }
  .hero-panel-stats { max-width: 250px; }
  .hero-goal { max-width: 100%; flex-basis: 100%; }
  .module-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 680px) {
  body { font-size: 14.5px; }
  .main { padding: 0 16px; }
  .topbar h1 { font-size: 21px; }
  .topbar { padding: 13px 0 12px; gap: 10px; }
  .streak-chip { height: 34px; padding: 0 10px; font-size: 10.5px; }
  .theme-btn { width: 34px; height: 34px; }
  .hero-copy { padding: 28px 22px; }
  .hero h1 { font-size: clamp(32px, 9vw, 42px); }
  .hero .lede { font-size: 13.5px; }
  .hero-cta { margin-top: 22px; }
  .hero-cta .btn { flex: 1; }
  .hero-meta { gap: 12px 18px; margin-top: 24px; }
  .hero-panel { padding: 24px 18px 26px; }
  .hero-panel .ring-wrap { width: 140px; height: 140px; }
  .ring-center b { font-size: 31px; }
  .hero-panel-stats { max-width: 210px; }
  .hero-panel-stats b { font-size: 15px; }
  .stat-grid { gap: 9px; }
  .stat { padding: 12px; gap: 10px; }
  .stat-ico { width: 33px; height: 33px; border-radius: 9px; }
  .stat b { font-size: 16px; }
  .stat span { font-size: 9px; }
  .module-grid { grid-template-columns: 1fr; }
  .section-head { margin-top: 26px; }
  .queue-q { white-space: normal; }
  .queue-row { align-items: flex-start; }
  .queue-row .chip { display: none; }
  .study-start { padding: 22px 18px; }
  .start-head { flex-direction: column; }
  .start-count { align-self: stretch; display: flex; align-items: baseline; justify-content: center; gap: 8px; }
  .start-count b { font-size: 22px; }
  .qcard { padding: 24px 18px; border-radius: 18px; }
  .q-text { font-size: 22px; }
  .rate-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .done-grid { grid-template-columns: repeat(2, 1fr); }
  .flip-card { height: clamp(360px, 60vh, 540px); }
  .face { padding: 22px 18px; border-radius: 18px; }
  .face-front .front-q p { font-size: 23px; }
  .deck-controls { flex-wrap: wrap; }
  .deck-controls .flip-btn { order: 5; flex-basis: 100%; }
  .deck-controls .btn { min-height: 40px; }
  .setup-grid { grid-template-columns: 1fr; gap: 18px; }
  .test-setup { padding: 22px 18px; }
  .grade-row { grid-template-columns: 1fr; }
  .result-stats { gap: 16px; }
  .lib-body { padding-left: 4px; }
  .lib-item summary { gap: 9px; }
  .lib-filters { gap: 6px; }
  .lib-filters .filter-chip { font-size: 11px; min-height: 29px; padding: 3px 9px; }
  .topbar .kicker { display: none; }
  .activity-col .count { display: none; }
  .modal { padding: 24px 20px; }
  .tabbar { grid-template-columns: repeat(5, 1fr); }
}
@media (max-width: 380px) {
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .hero-panel { flex-direction: column; }
  .hero-panel-stats { max-width: 100%; }
}

/* ---------- Tabbar ---------- */
.tabbar {
  display: none;
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
.tab {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 5px 2px; border: 0; background: none;
  font-size: 9px; letter-spacing: 0.01em; color: var(--muted); cursor: pointer;
}
.tab .ico { width: 21px; height: 21px; }
.tab.is-active { color: var(--accent); }
.tab-dot { position: absolute; top: 4px; right: calc(50% - 15px); width: 6px; height: 6px; border-radius: 50%; background: var(--gold); }

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

@media (max-width: 900px) {
  .tabbar { display: grid; }
}
