/* ------------------------------------------------------------------
   For Juri — a personal Ethics reviewer
   Design: warm midnight paper, editorial serif, soft glass, one rose accent
------------------------------------------------------------------- */

:root {
  --bg: #08070c;
  --bg-soft: #0d0b13;
  --surface: #121019;
  --surface-2: #17141f;
  --surface-3: #1d1928;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.15);
  --text: #f7f2ea;
  --muted: #aaa2b6;
  --faint: #736b84;
  --rose: #ff8ba7;
  --rose-deep: #f26d8f;
  --rose-ink: #290d15;
  --lilac: #b9a0ff;
  --mint: #8be3c9;
  --gold: #f3c97c;
  --danger: #ff7a7a;
  --ok: #7fe0b0;
  --accent: var(--rose);
  --radius-sm: 14px;
  --radius: 22px;
  --radius-lg: 30px;
  --shadow: 0 32px 80px -44px rgba(0, 0, 0, 0.95);
  --font-body: "Plus Jakarta Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

[data-theme="light"] {
  --bg: #f6f0e7;
  --bg-soft: #fbf7f1;
  --surface: #fffdf9;
  --surface-2: #f8f1e8;
  --surface-3: #f1e8dc;
  --line: rgba(37, 26, 46, 0.1);
  --line-strong: rgba(37, 26, 46, 0.18);
  --text: #211a2b;
  --muted: #6f6479;
  --faint: #94899e;
  --rose: #e2607f;
  --rose-deep: #c94767;
  --rose-ink: #fff7f9;
  --lilac: #8a6ee0;
  --mint: #2f9d83;
  --gold: #b98429;
  --danger: #c94a4a;
  --ok: #218a68;
  --shadow: 0 30px 70px -46px rgba(61, 36, 20, 0.45);
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  letter-spacing: -0.011em;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

::selection { background: var(--rose); color: var(--rose-ink); }

h1, h2, h3, h4 { margin: 0; line-height: 1.12; letter-spacing: -0.025em; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input, textarea {
  font: inherit;
  color: inherit;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
input, textarea {
  font-size: 16px; /* Prevents auto-zoom in mobile Safari */
}
button { cursor: pointer; }
svg { display: block; }
:focus-visible { outline: 2px solid var(--rose); outline-offset: 3px; border-radius: 6px; }

.skip-link {
  position: fixed;
  top: -100px;
  left: 16px;
  z-index: 200;
  padding: 10px 16px;
  background: var(--text);
  color: var(--bg);
  border-radius: 999px;
  transition: top 0.2s;
}
.skip-link:focus { top: 12px; }

/* ---------- Ambient background ---------- */

.ambient {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}
.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.4;
  animation: drift 26s var(--ease) infinite alternate;
}
.orb-a {
  width: 46vw; height: 46vw; min-width: 340px; min-height: 340px;
  top: -16vw; right: -8vw;
  background: radial-gradient(circle at 40% 40%, rgba(255, 139, 167, 0.5), transparent 65%);
}
.orb-b {
  width: 40vw; height: 40vw; min-width: 300px; min-height: 300px;
  top: 38%; left: -16vw;
  background: radial-gradient(circle at 50% 50%, rgba(185, 160, 255, 0.36), transparent 68%);
  animation-delay: -8s;
}
.orb-c {
  width: 34vw; height: 34vw; min-width: 260px; min-height: 260px;
  bottom: -14vw; right: 10vw;
  background: radial-gradient(circle at 50% 50%, rgba(139, 227, 201, 0.26), transparent 70%);
  animation-delay: -16s;
}
[data-theme="light"] .orb { opacity: 0.5; filter: blur(80px); }
[data-theme="light"] .orb-a { background: radial-gradient(circle, rgba(255, 160, 180, 0.65), transparent 65%); }
[data-theme="light"] .orb-b { background: radial-gradient(circle, rgba(185, 160, 255, 0.45), transparent 68%); }
[data-theme="light"] .orb-c { background: radial-gradient(circle, rgba(139, 227, 201, 0.4), transparent 70%); }

.grain {
  position: absolute;
  inset: -50%;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
[data-theme="light"] .grain { opacity: 0.035; }

@keyframes drift {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to { transform: translate3d(3vw, 4vh, 0) scale(1.12); }
}

/* ---------- App frame ---------- */

.app {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: calc(12px + var(--safe-top)) calc(clamp(16px, 4vw, 44px) + var(--safe-right)) 12px calc(clamp(16px, 4vw, 44px) + var(--safe-left));
  backdrop-filter: blur(18px) saturate(1.3);
  -webkit-backdrop-filter: blur(18px) saturate(1.3);
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 11px; flex-shrink: 0; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 38px; height: 38px;
  border-radius: 12px;
  background: linear-gradient(150deg, rgba(255, 139, 167, 0.22), rgba(185, 160, 255, 0.14));
  border: 1px solid rgba(255, 139, 167, 0.28);
  color: var(--rose);
}
.brand-mark svg { width: 21px; height: 21px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-family: var(--font-display); font-weight: 600; font-size: 1.08rem; letter-spacing: -0.02em; }
.brand-text em { font-style: normal; font-size: 0.66rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--faint); }

.topnav { display: flex; align-items: center; gap: 4px; margin: 0 auto; }
.topnav a {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 500;
  transition: color 0.2s, background 0.2s;
}
.topnav a svg { width: 16px; height: 16px; opacity: 0.8; }
.topnav a:hover { color: var(--text); background: var(--surface-2); }
.topnav a.active { color: var(--text); background: var(--surface-2); border: 1px solid var(--line); }

.topbar-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.streak-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 38px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--gold);
  font-size: 0.82rem;
  font-weight: 700;
}
.streak-chip svg { width: 15px; height: 15px; }
.streak-chip:hover { background: var(--surface-2); }
.icon-btn {
  display: grid;
  place-items: center;
  width: 38px; height: 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  transition: color 0.2s, background 0.2s, transform 0.2s;
}
.icon-btn:hover { color: var(--text); background: var(--surface-2); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn svg { width: 18px; height: 18px; }

.view {
  flex: 1;
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: clamp(22px, 5vw, 56px) calc(clamp(16px, 4vw, 40px) + var(--safe-right)) 120px calc(clamp(16px, 4vw, 40px) + var(--safe-left));
  outline: none;
}
.view.is-wide { max-width: 1320px; }

/* ---------- Bottom tabbar (mobile) ---------- */

.tabbar {
  position: fixed;
  z-index: 60;
  left: 50%;
  bottom: calc(10px + var(--safe-bottom));
  transform: translateX(-50%);
  display: none;
  align-items: center;
  gap: 2px;
  width: min(calc(100vw - 20px), 430px);
  padding: 6px;
  border: 1px solid var(--line-strong);
  border-radius: 26px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(22px) saturate(1.4);
  -webkit-backdrop-filter: blur(22px) saturate(1.4);
  box-shadow: 0 20px 50px -20px rgba(0, 0, 0, 0.7);
}
.tabbar a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 44px;
  padding: 6px 2px;
  border-radius: 19px;
  color: var(--faint);
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  transition: color 0.2s, background 0.2s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.tabbar a svg { width: 20px; height: 20px; }
.tabbar a.active { color: var(--text); background: var(--surface-3); }
.tabbar a.active svg { color: var(--rose); }

@media (max-width: 860px) {
  .topnav { display: none; }
  .tabbar { display: flex; }
  .view { padding-bottom: calc(114px + var(--safe-bottom)); }
  .brand-text em { display: none; }
}

/* ---------- Reusable UI ---------- */

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--faint);
}
.eyebrow::before {
  content: "";
  width: 18px; height: 1px;
  background: currentColor;
  opacity: 0.6;
}
.eyebrow.no-rule::before { display: none; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 46px;
  padding: 0 20px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  white-space: nowrap;
  transition: transform 0.18s var(--ease), background 0.2s, border-color 0.2s, box-shadow 0.2s;
}
.btn svg { width: 17px; height: 17px; }
.btn:active { transform: scale(0.975); }
.btn-primary {
  background: linear-gradient(140deg, var(--rose), var(--rose-deep));
  color: var(--rose-ink);
  box-shadow: 0 14px 34px -16px rgba(242, 109, 143, 0.7);
}
.btn-primary:hover { box-shadow: 0 18px 40px -14px rgba(242, 109, 143, 0.8); transform: translateY(-1px); }
.btn-ghost {
  background: var(--surface);
  border-color: var(--line-strong);
  color: var(--text);
}
.btn-ghost:hover { background: var(--surface-2); border-color: var(--line-strong); transform: translateY(-1px); }
.btn-soft {
  background: var(--surface-2);
  border-color: var(--line);
  color: var(--text);
}
.btn-soft:hover { background: var(--surface-3); }
.btn-text { background: transparent; color: var(--muted); padding: 0 10px; min-height: 38px; }
.btn-text:hover { color: var(--text); }
.btn-sm { min-height: 38px; padding: 0 15px; font-size: 0.82rem; }
.btn-lg { min-height: 54px; padding: 0 26px; font-size: 0.98rem; }
.btn[disabled] { opacity: 0.45; pointer-events: none; }
.btn-block { width: 100%; }

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(165deg, var(--surface), color-mix(in srgb, var(--surface) 70%, transparent));
  box-shadow: var(--shadow);
}
.card-pad { padding: clamp(20px, 3vw, 30px); }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 650;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.pill-dot::before {
  content: "";
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--accent, var(--rose));
}
.pill-accent { color: var(--accent, var(--rose)); border-color: color-mix(in srgb, var(--accent, var(--rose)) 35%, transparent); background: color-mix(in srgb, var(--accent, var(--rose)) 10%, transparent); }

.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 0.82rem; }
.tiny { font-size: 0.72rem; }
.center { text-align: center; }
.serif { font-family: var(--font-display); }
.accent { color: var(--rose); }
.mint { color: var(--mint); }
.gold { color: var(--gold); }
.lilac { color: var(--lilac); }
.nowrap { white-space: nowrap; }
.mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; } .mt-4 { margin-top: 34px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; }

.stack { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.grow { flex: 1; }
.hr { height: 1px; background: var(--line); border: 0; margin: 24px 0; }
[hidden] { display: none !important; }

.study-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.study-table th {
  text-align: left;
  font-size: 0.64rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--faint);
  font-weight: 800;
  padding: 0 12px 9px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.study-table td { padding: 11px 12px; border-bottom: 1px solid var(--line); color: var(--muted); vertical-align: top; }
.study-table tr:last-child td { border-bottom: 0; }
.study-table td:first-child { color: var(--text); font-weight: 600; white-space: nowrap; }
.study-table strong { color: var(--text); }

.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 18px; flex-wrap: wrap; }
.section-head h2 { font-family: var(--font-display); font-size: clamp(1.45rem, 2.6vw, 1.9rem); font-weight: 550; letter-spacing: -0.03em; }
.section-head p { color: var(--muted); font-size: 0.88rem; margin-top: 4px; }

/* ---------- Progress ring ---------- */

.ring {
  --p: 0;
  --size: 116px;
  width: var(--size); height: var(--size);
  display: grid;
  place-items: center;
  border-radius: 50%;
  background:
    conic-gradient(var(--accent-ring, var(--rose)) calc(var(--p) * 1%), color-mix(in srgb, var(--text) 9%, transparent) 0);
  position: relative;
  flex-shrink: 0;
}
.ring::before {
  content: "";
  position: absolute;
  inset: 7px;
  border-radius: 50%;
  background: var(--surface);
}
.ring-inner { position: relative; z-index: 1; text-align: center; line-height: 1; }
.ring-value { font-family: var(--font-display); font-size: calc(var(--size) * 0.24); font-weight: 600; }
.ring-label { font-size: calc(var(--size) * 0.068); color: var(--faint); letter-spacing: 0.12em; text-transform: uppercase; margin-top: 5px; font-weight: 700; }

/* ---------- Home ---------- */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(280px, 0.75fr);
  gap: clamp(26px, 4vw, 56px);
  align-items: center;
  padding: clamp(10px, 2vw, 22px) 0 clamp(34px, 5vw, 58px);
}
.hero h1 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(2.55rem, 6.2vw, 4.7rem);
  line-height: 0.98;
  letter-spacing: -0.035em;
  margin: 14px 0 0;
  max-width: 14ch;
}
.hero h1 em { font-style: italic; color: var(--rose); }
.hero-sub {
  margin-top: 18px;
  max-width: 44ch;
  color: var(--muted);
  font-size: clamp(0.94rem, 1.4vw, 1.04rem);
  line-height: 1.65;
}
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 26px; }
.hero-meta { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 26px; padding-top: 20px; border-top: 1px solid var(--line); }
.hero-meta div { display: flex; flex-direction: column; }
.hero-meta strong { font-size: 1.02rem; font-weight: 700; }
.hero-meta span { font-size: 0.7rem; color: var(--faint); text-transform: uppercase; letter-spacing: 0.12em; }

.mastery-card {
  position: relative;
  padding: 26px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background:
    radial-gradient(120% 120% at 100% 0%, rgba(255, 139, 167, 0.16), transparent 55%),
    linear-gradient(165deg, var(--surface-2), var(--surface));
  overflow: hidden;
}
.mastery-card::after {
  content: "";
  position: absolute;
  width: 180px; height: 180px;
  right: -60px; bottom: -70px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(185, 160, 255, 0.25), transparent 70%);
  filter: blur(10px);
}
.mastery-top { display: flex; align-items: center; gap: 20px; }
.mastery-copy { display: flex; flex-direction: column; gap: 3px; }
.mastery-copy strong { font-family: var(--font-display); font-size: 1.28rem; font-weight: 550; }
.mastery-copy span { color: var(--muted); font-size: 0.8rem; }
.mastery-foot { display: flex; justify-content: space-between; gap: 10px; margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line); font-size: 0.76rem; color: var(--muted); }
.mastery-foot b { color: var(--text); font-weight: 700; }

.stat-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 clamp(32px, 5vw, 56px);
}
.stat-strip.stat-strip-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.stat {
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--surface) 65%, transparent);
  min-width: 0;
}
.stat-label { font-size: 0.66rem; letter-spacing: 0.13em; text-transform: uppercase; color: var(--faint); font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat-value { font-family: var(--font-display); font-size: clamp(1.35rem, 3.2vw, 1.65rem); font-weight: 550; margin-top: 6px; line-height: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat-value small { font-family: var(--font-body); font-size: 0.72rem; color: var(--muted); font-weight: 500; }

.chapter-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.chapter-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 24px 22px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(170deg, var(--surface), color-mix(in srgb, var(--surface) 62%, transparent));
  overflow: hidden;
  transition: transform 0.35s var(--ease), border-color 0.3s, box-shadow 0.35s;
  isolation: isolate;
}
.chapter-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), transparent 80%);
  opacity: 0.85;
}
.chapter-card::after {
  content: "";
  position: absolute;
  z-index: -1;
  width: 150px; height: 150px;
  top: -70px; right: -40px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  filter: blur(30px);
}
.chapter-card:hover { transform: translateY(-4px); border-color: color-mix(in srgb, var(--accent) 36%, var(--line)); box-shadow: 0 28px 60px -34px color-mix(in srgb, var(--accent) 38%, transparent); }
.chapter-num {
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: var(--accent);
}
.chapter-card h3 { font-family: var(--font-display); font-size: 1.34rem; font-weight: 550; line-height: 1.15; letter-spacing: -0.02em; }
.chapter-card .chapter-desc { color: var(--muted); font-size: 0.83rem; line-height: 1.55; }
.chapter-card .tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 2px; }
.chapter-card .tags span { font-size: 0.62rem; color: var(--faint); border: 1px solid var(--line); padding: 3px 7px; border-radius: 6px; }
.chapter-progress { margin-top: auto; display: flex; flex-direction: column; gap: 7px; }
.chapter-progress .between { font-size: 0.71rem; color: var(--faint); }
.bar { height: 5px; border-radius: 99px; background: color-mix(in srgb, var(--text) 9%, transparent); overflow: hidden; }
.bar span { display: block; height: 100%; border-radius: inherit; background: var(--accent); transition: width 0.8s var(--ease); }
.chapter-cta { display: flex; align-items: center; justify-content: space-between; padding-top: 14px; border-top: 1px solid var(--line); font-size: 0.78rem; font-weight: 650; color: var(--text); }
.chapter-cta svg { width: 16px; height: 16px; color: var(--accent); transition: transform 0.25s; }
.chapter-card:hover .chapter-cta svg { transform: translateX(3px); }

/* note card */
.note-card {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 20px;
  align-items: center;
  margin-top: clamp(36px, 5vw, 58px);
  padding: clamp(22px, 3.4vw, 34px);
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255, 139, 167, 0.22);
  background:
    radial-gradient(100% 160% at 0% 0%, rgba(255, 139, 167, 0.14), transparent 55%),
    radial-gradient(90% 140% at 100% 100%, rgba(185, 160, 255, 0.12), transparent 55%),
    var(--surface);
  overflow: hidden;
}
.note-card .note-text { font-family: var(--font-display); font-size: clamp(1.15rem, 2.2vw, 1.55rem); font-weight: 400; font-style: italic; line-height: 1.42; letter-spacing: -0.015em; }
.note-card .note-sign { margin-top: 12px; font-size: 0.72rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--faint); font-weight: 700; }
.note-heart { width: 54px; height: 54px; display: grid; place-items: center; border-radius: 50%; background: rgba(255, 139, 167, 0.1); border: 1px solid rgba(255, 139, 167, 0.22); color: var(--rose); }
.note-heart svg { width: 26px; height: 26px; }

/* quick grid */
.quick-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 16px; }
.quick-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--surface) 70%, transparent);
  transition: background 0.2s, border-color 0.2s, transform 0.25s var(--ease);
}
.quick-card:hover { background: var(--surface-2); border-color: var(--line-strong); transform: translateY(-2px); }
.quick-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; background: var(--surface-3); color: var(--accent, var(--rose)); }
.quick-icon svg { width: 17px; height: 17px; }
.quick-card strong { font-size: 0.88rem; font-weight: 650; }
.quick-card span { font-size: 0.73rem; color: var(--faint); }

/* ---------- Study ---------- */

.page-head { margin-bottom: clamp(24px, 3.5vw, 36px); }
.page-head h1 { font-family: var(--font-display); font-size: clamp(2rem, 4.6vw, 3.3rem); font-weight: 400; letter-spacing: -0.035em; margin-top: 10px; line-height: 1.02; }
.page-head h1 em { font-style: italic; color: var(--rose); }
.page-head p { color: var(--muted); margin-top: 12px; max-width: 60ch; font-size: 0.94rem; }

.searchbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  max-width: 440px;
  width: 100%;
}
.searchbar svg { width: 17px; height: 17px; color: var(--faint); flex-shrink: 0; }
.searchbar input { flex: 1; background: none; border: 0; outline: none; font-size: 0.88rem; min-width: 0; }
.searchbar input::placeholder { color: var(--faint); }

.search-results { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.search-hit { display: block; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); }
.search-hit:hover { border-color: var(--line-strong); background: var(--surface-2); }
.search-hit strong { font-size: 0.88rem; }
.search-hit span { display: block; margin-top: 3px; font-size: 0.76rem; color: var(--faint); }
.search-hit mark { background: rgba(255, 139, 167, 0.25); color: var(--text); border-radius: 3px; padding: 0 2px; }

.chapter-block { margin-bottom: 44px; }
.chapter-block-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 14px; }
.chapter-badge {
  flex-shrink: 0;
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border-radius: 13px;
  background: color-mix(in srgb, var(--accent) 13%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  color: var(--accent);
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
}
.chapter-block-head h2 { font-family: var(--font-display); font-size: clamp(1.35rem, 2.6vw, 1.8rem); font-weight: 550; margin-top: 1px; }
.chapter-block-head p { color: var(--muted); font-size: 0.82rem; margin-top: 4px; }
.chapter-block-head .progress-mini { margin-left: auto; text-align: right; font-size: 0.72rem; color: var(--faint); min-width: 84px; }
.chapter-block-head .progress-mini b { color: var(--text); font-size: 0.9rem; }

.lesson-list { display: flex; flex-direction: column; gap: 8px; }
.lesson-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 15px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--surface) 72%, transparent);
  transition: background 0.2s, border-color 0.2s, transform 0.2s var(--ease);
}
.lesson-row:hover { background: var(--surface-2); border-color: var(--line-strong); transform: translateX(2px); }
.lesson-num { font-size: 0.66rem; font-weight: 800; letter-spacing: 0.08em; color: var(--accent); width: 42px; flex-shrink: 0; }
.lesson-row-main { flex: 1; min-width: 0; }
.lesson-row-main strong { display: block; font-size: 0.9rem; font-weight: 600; letter-spacing: -0.012em; }
.lesson-row-main span { display: block; margin-top: 2px; font-size: 0.72rem; color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lesson-state { flex-shrink: 0; width: 24px; height: 24px; border-radius: 50%; border: 1px solid var(--line-strong); display: grid; place-items: center; color: transparent; }
.lesson-state.done { background: color-mix(in srgb, var(--mint) 16%, transparent); border-color: color-mix(in srgb, var(--mint) 45%, transparent); color: var(--mint); }
.lesson-state svg { width: 13px; height: 13px; }

.lesson-layout { display: grid; grid-template-columns: minmax(0, 1fr) 250px; gap: clamp(24px, 4vw, 48px); align-items: start; }
.lesson-main { min-width: 0; }
.lesson-hero { margin-bottom: 28px; }
.lesson-hero h1 { font-family: var(--font-display); font-size: clamp(1.85rem, 4.2vw, 2.9rem); font-weight: 400; line-height: 1.06; letter-spacing: -0.03em; margin-top: 10px; }
.lesson-hero .meta { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 14px; }
.lesson-prose { font-size: 0.97rem; line-height: 1.75; color: color-mix(in srgb, var(--text) 88%, var(--muted)); }
.lesson-prose > * + * { margin-top: 14px; }
.lesson-prose h3 {
  font-family: var(--font-display);
  font-size: 1.24rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-top: 32px;
  color: var(--text);
}
.lesson-prose h4 { font-size: 0.78rem; letter-spacing: 0.13em; text-transform: uppercase; color: var(--faint); margin-top: 26px; }
.lesson-prose ul, .lesson-prose ol { margin: 12px 0 0; padding-left: 22px; }
.lesson-prose li { margin: 7px 0; padding-left: 4px; }
.lesson-prose li::marker { color: var(--accent); font-weight: 700; }
.lesson-prose strong { color: var(--text); font-weight: 650; }
.lesson-prose em { color: var(--text); }
.lesson-prose .term-line { padding: 12px 16px; border-left: 2px solid var(--accent); background: color-mix(in srgb, var(--accent) 6%, transparent); border-radius: 0 10px 10px 0; }
.lesson-prose .term-line b { color: var(--accent); }

.callout {
  padding: 18px 20px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-size: 0.9rem;
  line-height: 1.6;
}
.callout-title { display: flex; align-items: center; gap: 8px; font-size: 0.68rem; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent); margin-bottom: 8px; }
.callout-title svg { width: 14px; height: 14px; }
.callout.mnemonic { border-color: color-mix(in srgb, var(--gold) 30%, transparent); background: color-mix(in srgb, var(--gold) 7%, transparent); }
.callout.mnemonic .callout-title { color: var(--gold); }
.callout.exam { border-color: color-mix(in srgb, var(--mint) 30%, transparent); background: color-mix(in srgb, var(--mint) 6%, transparent); }
.callout.exam .callout-title { color: var(--mint); }

.term-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; margin-top: 14px; }
.term-card { padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.term-card dt { font-weight: 700; font-size: 0.82rem; color: var(--accent); }
.term-card dd { margin: 5px 0 0; font-size: 0.79rem; color: var(--muted); line-height: 1.55; }

.lesson-side { position: sticky; top: 92px; display: flex; flex-direction: column; gap: 12px; }
.side-card { padding: 18px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); }
.side-card h4 { font-size: 0.66rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--faint); font-weight: 800; }
.side-nav { display: flex; flex-direction: column; gap: 2px; margin-top: 10px; }
.side-nav a { display: flex; gap: 8px; padding: 7px 9px; border-radius: 8px; font-size: 0.78rem; color: var(--muted); }
.side-nav a:hover { background: var(--surface-2); color: var(--text); }
.side-nav a.active { background: color-mix(in srgb, var(--accent) 10%, transparent); color: var(--accent); font-weight: 600; }
.read-toggle { display: flex; align-items: center; gap: 9px; width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--surface-2); font-size: 0.79rem; font-weight: 600; }
.read-toggle.done { border-color: color-mix(in srgb, var(--mint) 40%, transparent); color: var(--mint); background: color-mix(in srgb, var(--mint) 8%, transparent); }
.read-toggle svg { width: 15px; height: 15px; }
.lesson-pager { display: flex; justify-content: space-between; gap: 10px; margin-top: 34px; padding-top: 22px; border-top: 1px solid var(--line); }
.lesson-pager a { display: flex; flex-direction: column; gap: 2px; font-size: 0.72rem; color: var(--faint); max-width: 46%; }
.lesson-pager a strong { font-size: 0.83rem; color: var(--text); font-weight: 600; }
.lesson-pager a.next { text-align: right; margin-left: auto; }

/* ---------- Quiz hub / practice ---------- */

.practice-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.practice-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
  transition: transform 0.3s var(--ease), border-color 0.2s;
}
.practice-card:hover { transform: translateY(-3px); border-color: color-mix(in srgb, var(--accent) 38%, var(--line)); }
.practice-card .best { position: absolute; top: 18px; right: 18px; font-size: 0.66rem; font-weight: 800; letter-spacing: 0.06em; color: var(--accent); }
.practice-card h3 { font-family: var(--font-display); font-size: 1.24rem; font-weight: 550; max-width: 18ch; }
.practice-card .desc { font-size: 0.8rem; color: var(--muted); }
.practice-card .types { display: flex; flex-wrap: wrap; gap: 5px; }
.practice-card .types span { font-size: 0.6rem; padding: 3px 7px; border-radius: 5px; background: var(--surface-3); color: var(--muted); }
.practice-card .practice-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; font-size: 0.76rem; color: var(--faint); }
.practice-card .practice-foot b { color: var(--text); font-size: 0.8rem; }

.exam-banner {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 24px;
  align-items: center;
  margin-top: 14px;
  padding: clamp(24px, 4vw, 38px);
  border: 1px solid rgba(255, 139, 167, 0.24);
  border-radius: var(--radius-lg);
  background:
    radial-gradient(110% 170% at 8% 0%, rgba(255, 139, 167, 0.18), transparent 55%),
    radial-gradient(90% 150% at 100% 100%, rgba(185, 160, 255, 0.14), transparent 55%),
    var(--surface);
  overflow: hidden;
}
.exam-banner h2 { font-family: var(--font-display); font-size: clamp(1.6rem, 3.4vw, 2.4rem); font-weight: 450; letter-spacing: -0.03em; margin-top: 8px; }
.exam-banner p { color: var(--muted); font-size: 0.88rem; margin-top: 8px; max-width: 48ch; }
.exam-facts { display: flex; gap: 22px; flex-wrap: wrap; margin-top: 20px; }
.exam-facts div { display: flex; flex-direction: column; gap: 2px; }
.exam-facts b { font-size: 1.05rem; font-weight: 700; }
.exam-facts span { font-size: 0.64rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--faint); font-weight: 700; }

/* ---------- Runner ---------- */

.runner { max-width: 800px; margin: 0 auto; }
.runner-top { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.runner-top .between { flex: 1; }
.runner-title { font-size: 0.76rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--faint); }
.runner-count { font-family: var(--font-display); font-size: 1.05rem; }
.runner-count b { color: var(--rose); }
.timer { display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); font-variant-numeric: tabular-nums; font-size: 0.82rem; font-weight: 700; }
.timer.low { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.timer svg { width: 14px; height: 14px; }

.progress-line { height: 4px; border-radius: 99px; background: color-mix(in srgb, var(--text) 8%, transparent); margin-bottom: 24px; overflow: hidden; }
.progress-line span { display: block; height: 100%; background: var(--rose); border-radius: inherit; transition: width 0.4s var(--ease); }

.question-card { padding: clamp(22px, 4vw, 38px); border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow); }
.q-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 16px; }
.q-type { font-size: 0.64rem; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent, var(--rose)); }
.q-tag { font-size: 0.64rem; color: var(--faint); }
.q-text { font-family: var(--font-display); font-size: clamp(1.25rem, 2.6vw, 1.65rem); font-weight: 450; line-height: 1.35; letter-spacing: -0.015em; }
.q-prompt { margin-top: 10px; font-size: 0.82rem; color: var(--muted); }

.answers { display: flex; flex-direction: column; gap: 9px; margin-top: 24px; }
.answer {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: color-mix(in srgb, var(--surface-2) 60%, transparent);
  text-align: left;
  font-size: 0.9rem;
  line-height: 1.5;
  transition: border-color 0.18s, background 0.18s, transform 0.15s;
}
.answer:hover:not(.locked) { border-color: var(--line-strong); background: var(--surface-2); }
.answer:active:not(.locked) { transform: scale(0.995); }
.answer .letter {
  flex-shrink: 0;
  width: 26px; height: 26px;
  display: grid; place-items: center;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--muted);
  transition: all 0.18s;
}
.answer.selected { border-color: var(--rose); background: color-mix(in srgb, var(--rose) 10%, transparent); }
.answer.selected .letter { background: var(--rose); border-color: var(--rose); color: var(--rose-ink); }
.answer.correct { border-color: color-mix(in srgb, var(--ok) 55%, transparent); background: color-mix(in srgb, var(--ok) 9%, transparent); }
.answer.correct .letter { background: var(--ok); border-color: var(--ok); color: #06251c; }
.answer.wrong { border-color: color-mix(in srgb, var(--danger) 55%, transparent); background: color-mix(in srgb, var(--danger) 8%, transparent); }
.answer.wrong .letter { background: var(--danger); border-color: var(--danger); color: #2b0a0a; }
.answer.locked { cursor: default; }
.answer .a-body { flex: 1; min-width: 0; }
.answer .a-note { display: block; margin-top: 3px; font-size: 0.72rem; color: var(--faint); }

.tf-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 24px; }
.tf-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 20px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-2);
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 550;
  transition: all 0.18s;
}
.tf-btn:hover { border-color: var(--line-strong); background: var(--surface-3); }
.tf-btn.selected { border-color: var(--rose); background: color-mix(in srgb, var(--rose) 11%, transparent); }
.tf-btn.correct { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 10%, transparent); color: var(--ok); }
.tf-btn.wrong { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 9%, transparent); color: var(--danger); }
.tf-btn svg { width: 18px; height: 18px; }

.input-answer { margin-top: 22px; display: flex; flex-direction: column; gap: 10px; }
.text-input {
  width: 100%;
  height: 52px;
  padding: 0 16px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface-2);
  outline: none;
  font-size: 0.95rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.text-input:focus { border-color: var(--rose); box-shadow: 0 0 0 3px rgba(255, 139, 167, 0.12); }
.text-input.correct { border-color: var(--ok); }
.text-input.wrong { border-color: var(--danger); }
.input-hint { font-size: 0.72rem; color: var(--faint); }

.enum-list { display: flex; flex-direction: column; gap: 8px; margin-top: 20px; }
.enum-row { display: flex; align-items: center; gap: 10px; }
.enum-row .n { width: 22px; font-size: 0.72rem; font-weight: 800; color: var(--faint); text-align: right; flex-shrink: 0; }
.enum-row .text-input { height: 46px; }
.enum-note { margin-top: 12px; font-size: 0.72rem; color: var(--faint); }

.feedback { margin-top: 20px; padding: 16px 18px; border-radius: 13px; border: 1px solid var(--line); background: var(--surface-2); font-size: 0.86rem; line-height: 1.6; animation: pop 0.3s var(--ease); }
.feedback.good { border-color: color-mix(in srgb, var(--ok) 40%, transparent); background: color-mix(in srgb, var(--ok) 8%, transparent); }
.feedback.bad { border-color: color-mix(in srgb, var(--danger) 38%, transparent); background: color-mix(in srgb, var(--danger) 7%, transparent); }
.feedback-head { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 0.78rem; letter-spacing: 0.04em; margin-bottom: 5px; }
.feedback.good .feedback-head { color: var(--ok); }
.feedback.bad .feedback-head { color: var(--danger); }
.feedback-head svg { width: 16px; height: 16px; }
.feedback .answer-key { font-weight: 700; color: var(--text); }
.feedback .explain { color: var(--muted); margin-top: 5px; font-size: 0.82rem; }

.runner-actions { display: flex; align-items: center; gap: 10px; margin-top: 20px; }
.runner-actions .grow { flex: 1; }
.flag-btn { display: inline-flex; align-items: center; gap: 7px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 999px; background: transparent; font-size: 0.74rem; font-weight: 600; color: var(--faint); }
.flag-btn.on { color: var(--gold); border-color: color-mix(in srgb, var(--gold) 45%, transparent); background: color-mix(in srgb, var(--gold) 8%, transparent); }
.flag-btn svg { width: 14px; height: 14px; }

.exam-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}
.palette-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: none;
  border: 0;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
}
.palette-toggle svg { width: 15px; height: 15px; }
.palette {
  display: none;
  margin-top: 14px;
  padding: 16px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-2);
}
.palette.open { display: block; animation: pop 0.25s var(--ease); }
.palette-grid {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 5px;
  margin-top: 10px;
  max-height: 44vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 4px 2px;
  scrollbar-width: thin;
}
.palette-grid::-webkit-scrollbar { width: 5px; }
.palette-grid::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 99px; }
.palette-grid button {
  aspect-ratio: 1;
  min-height: 28px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  font-size: 0.66rem;
  font-weight: 700;
  color: var(--muted);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.palette-grid button.answered { border-color: color-mix(in srgb, var(--rose) 45%, transparent); background: color-mix(in srgb, var(--rose) 14%, transparent); color: var(--text); }
.palette-grid button.flagged { border-color: var(--gold); }
.palette-grid button.current { outline: 2px solid var(--rose); outline-offset: 1px; }
.palette-legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 12px; font-size: 0.66rem; color: var(--faint); }
.palette-legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend-dot { width: 9px; height: 9px; border-radius: 3px; border: 1px solid var(--line); }
.legend-dot.done { background: color-mix(in srgb, var(--rose) 30%, transparent); border-color: var(--rose); }
.legend-dot.flag { border-color: var(--gold); }

/* ---------- Results ---------- */

.result-hero {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: clamp(22px, 4vw, 40px);
  align-items: center;
  padding: clamp(26px, 4vw, 40px);
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background:
    radial-gradient(110% 160% at 0% 0%, rgba(255, 139, 167, 0.14), transparent 55%),
    var(--surface);
  margin-bottom: 20px;
}
.result-hero h1 { font-family: var(--font-display); font-size: clamp(1.7rem, 3.6vw, 2.5rem); font-weight: 450; letter-spacing: -0.03em; }
.result-hero p { color: var(--muted); font-size: 0.88rem; margin-top: 7px; max-width: 46ch; }
.result-actions { display: flex; gap: 9px; flex-wrap: wrap; margin-top: 18px; }
.result-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 24px; }
.result-stats.result-stats-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.result-stat { padding: 16px 18px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); min-width: 0; }
.result-stat span { display: block; font-size: 0.64rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--faint); font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-stat b { display: block; font-family: var(--font-display); font-size: 1.4rem; font-weight: 600; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.breakdown { display: flex; flex-direction: column; gap: 12px; margin: 18px 0 26px; }
.breakdown-row { display: grid; grid-template-columns: 120px 1fr 48px; align-items: center; gap: 12px; font-size: 0.78rem; }
.breakdown-row .bar { height: 7px; }
.breakdown-row b { text-align: right; font-variant-numeric: tabular-nums; }

.review-list { display: flex; flex-direction: column; gap: 8px; }
.review-item { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); overflow: hidden; }
.review-item summary { list-style: none; cursor: pointer; display: flex; align-items: flex-start; gap: 11px; padding: 13px 15px; font-size: 0.83rem; }
.review-item summary::-webkit-details-marker { display: none; }
.review-item summary .mark { flex-shrink: 0; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; }
.review-item summary .mark svg { width: 12px; height: 12px; }
.review-item.ok summary .mark { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.review-item.no summary .mark { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.review-item .review-body { padding: 0 15px 14px 46px; font-size: 0.78rem; color: var(--muted); line-height: 1.6; }
.review-item .review-body b { color: var(--text); }
.review-item[open] summary { background: var(--surface-2); }

/* ---------- Flashcards ---------- */

.deck-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.seg {
  display: inline-flex;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  gap: 2px;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.seg::-webkit-scrollbar { display: none; }
.seg button {
  border: 0;
  background: transparent;
  padding: 7px 13px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  transition: background 0.2s, color 0.2s;
  touch-action: manipulation;
}
.seg button.active { background: var(--surface-3); color: var(--text); }
.seg button:hover { color: var(--text); }

.flash-stage { max-width: 620px; margin: 0 auto; }
.flashcard-wrap { perspective: 1400px; }
.flashcard {
  position: relative;
  width: 100%;
  min-height: 300px;
  transform-style: preserve-3d;
  transition: transform 0.6s var(--ease);
  cursor: pointer;
}
.flashcard.flipped { transform: rotateY(180deg); }
.flash-face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 12px;
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: linear-gradient(165deg, var(--surface-2), var(--surface));
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  text-align: center;
  box-shadow: var(--shadow);
}
.flash-face.back { transform: rotateY(180deg); align-items: flex-start; justify-content: flex-start; text-align: left; overflow-y: auto; }
.flash-face .deck-label { font-size: 0.62rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent); font-weight: 800; }
.flash-face .term { font-family: var(--font-display); font-size: clamp(1.5rem, 4vw, 2.1rem); font-weight: 500; line-height: 1.15; letter-spacing: -0.02em; }
.flash-face .hint { font-size: 0.72rem; color: var(--faint); }
.flash-face .def { font-size: 0.92rem; line-height: 1.68; color: var(--muted); }
.flash-face .def b { color: var(--text); }
.flash-controls { display: flex; gap: 10px; justify-content: center; margin-top: 18px; }
.flash-progress { display: flex; align-items: center; justify-content: space-between; font-size: 0.74rem; color: var(--faint); margin-bottom: 12px; }
.flash-empty { padding: 40px 24px; text-align: center; color: var(--muted); }
.flash-complete { padding: 36px 24px; text-align: center; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); }

/* quiz in flashcard mode */
.quiz-mode-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.quiz-mode-bar .pill { margin-left: auto; }
.flashcard.q-flash { min-height: 330px; }
.flashcard.q-flash .flash-face.front { overflow-y: auto; }
.flash-face .term.is-question { font-size: clamp(1.02rem, 2.3vw, 1.3rem); line-height: 1.42; letter-spacing: -0.01em; max-width: 44ch; font-weight: 500; }
.flash-face.back .answer-model { font-family: var(--font-display); font-size: clamp(1.15rem, 2.5vw, 1.5rem); line-height: 1.32; color: var(--text); }
.flash-explain { font-size: 0.8rem; line-height: 1.65; color: var(--muted); }
.flash-explain em { color: var(--text); }

/* ---------- Progress ---------- */

.progress-grid { display: grid; grid-template-columns: 1.15fr 0.85fr; gap: 16px; align-items: start; }
.mastery-list { display: flex; flex-direction: column; gap: 18px; margin-top: 20px; }
.mastery-item .between { font-size: 0.8rem; margin-bottom: 7px; }
.mastery-item .between b { font-variant-numeric: tabular-nums; }
.history { display: flex; flex-direction: column; }
.history-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 0.8rem; }
.history-row:last-child { border-bottom: 0; }
.history-row .h-mark { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--surface-3); color: var(--muted); flex-shrink: 0; }
.history-row .h-mark svg { width: 14px; height: 14px; }
.history-row .h-main { flex: 1; min-width: 0; }
.history-row .h-main strong { display: block; font-weight: 600; font-size: 0.8rem; }
.history-row .h-main span { font-size: 0.68rem; color: var(--faint); }
.history-row .h-score { font-family: var(--font-display); font-size: 0.98rem; font-weight: 600; }
.history-empty { padding: 24px 0; color: var(--faint); font-size: 0.82rem; text-align: center; }

.heatmap { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-top: 12px; }
.heat { aspect-ratio: 1; border-radius: 4px; background: color-mix(in srgb, var(--text) 6%, transparent); }
.heat.l1 { background: color-mix(in srgb, var(--rose) 25%, transparent); }
.heat.l2 { background: color-mix(in srgb, var(--rose) 50%, transparent); }
.heat.l3 { background: color-mix(in srgb, var(--rose) 78%, transparent); }
.heat.l4 { background: var(--rose); }

.badge-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.achievement { display: flex; align-items: center; gap: 9px; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line); font-size: 0.72rem; color: var(--muted); background: var(--surface-2); }
.achievement.on { border-color: color-mix(in srgb, var(--gold) 35%, transparent); color: var(--text); background: color-mix(in srgb, var(--gold) 7%, transparent); }
.achievement svg { width: 15px; height: 15px; color: var(--gold); }

/* ---------- Modal / toast ---------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(5, 4, 8, 0.66);
  backdrop-filter: blur(8px);
  animation: fade 0.2s;
}
.modal {
  width: min(480px, 100%);
  padding: 26px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: 0 40px 100px -30px rgba(0, 0, 0, 0.8);
  animation: pop 0.3s var(--ease);
}
.modal h2 { font-family: var(--font-display); font-size: 1.5rem; font-weight: 550; }
.modal p { color: var(--muted); font-size: 0.86rem; margin-top: 8px; }
.modal-actions { display: flex; gap: 9px; justify-content: flex-end; margin-top: 22px; }

.toast-region { position: fixed; z-index: 120; bottom: 92px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; width: min(92vw, 380px); pointer-events: none; }
.toast {
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: color-mix(in srgb, var(--surface-3) 94%, transparent);
  backdrop-filter: blur(14px);
  font-size: 0.8rem;
  text-align: center;
  animation: toast-in 0.3s var(--ease);
  box-shadow: var(--shadow);
}
@media (min-width: 861px) { .toast-region { bottom: 28px; } }

/* ---------- Animations ---------- */

.page-enter { animation: rise 0.45s var(--ease) both; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes heart-burst {
  0% { opacity: 0; transform: translateY(0) scale(0.4); }
  20% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-90px) scale(1.1); }
}
.confetti-layer { position: fixed; inset: 0; pointer-events: none; z-index: 110; overflow: hidden; }
.confetti-heart { position: absolute; bottom: 20%; color: var(--rose); animation: heart-burst 1.6s ease-out forwards; }
.confetti-heart svg { width: 18px; height: 18px; }

@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; }
}

/* ---------- Responsive ---------- */

@media (max-width: 980px) {
  .chapter-grid { grid-template-columns: 1fr; gap: 12px; }
  .chapter-card { display: flex; flex-direction: column; gap: 14px; padding: 22px 20px; }
  .chapter-card .chapter-cta { display: flex; }
  .quick-grid { grid-template-columns: repeat(2, 1fr); }
  .lesson-layout { grid-template-columns: 1fr; }
  .lesson-side { position: static; flex-direction: row; flex-wrap: wrap; }
  .lesson-side .side-card { flex: 1; min-width: 220px; }
  .lesson-side .side-card.nav-card { display: none; }
  .progress-grid { grid-template-columns: 1fr; }
  .practice-grid { grid-template-columns: 1fr; }
}

@media (max-width: 780px) {
  .topbar { gap: 12px; padding: calc(10px + var(--safe-top)) calc(16px + var(--safe-right)) 10px calc(16px + var(--safe-left)); }
  .brand-text strong { font-size: 1rem; }
  .hero { grid-template-columns: 1fr; gap: 26px; padding: 8px 0 32px; }
  .hero h1 { max-width: 18ch; font-size: clamp(2.3rem, 7vw, 3.4rem); }
  .mastery-card { max-width: 100%; }
  .stat-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-strip.stat-strip-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-strip.stat-strip-3 > *:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .result-hero { grid-template-columns: 1fr; text-align: center; padding: 24px 18px; }
  .result-hero .ring { margin: 0 auto 12px; }
  .result-hero p { margin-left: auto; margin-right: auto; }
  .result-actions { justify-content: center; }
  .result-actions .btn { flex: 1; min-width: 130px; }
  .result-stats.result-stats-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .exam-banner { grid-template-columns: 1fr; padding: 22px 18px; gap: 18px; }
  .exam-banner .btn { width: 100%; }
  .exam-facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
  .note-card { grid-template-columns: 1fr; padding: 20px 18px; }
  .note-heart { display: none; }
  .breakdown-row { grid-template-columns: 90px 1fr 42px; }
}

@media (max-width: 540px) {
  .view {
    padding-left: calc(14px + var(--safe-left));
    padding-right: calc(14px + var(--safe-right));
    padding-top: 18px;
    padding-bottom: calc(114px + var(--safe-bottom));
  }
  .hero h1 { font-size: clamp(2rem, 8.5vw, 2.7rem); }
  .hero-sub { font-size: 0.9rem; margin-top: 12px; }
  .hero-actions { flex-direction: column; width: 100%; gap: 10px; margin-top: 20px; }
  .hero-actions .btn { width: 100%; min-height: 48px; }
  .hero-meta { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px 10px; padding-top: 16px; margin-top: 20px; }
  .stat { padding: 12px 14px; }
  .stat-value { font-size: 1.35rem; }
  .quick-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .quick-card { padding: 14px 12px; }
  .quick-card strong { font-size: 0.82rem; }
  .quick-card span { font-size: 0.7rem; }
  .chapter-card { padding: 18px 16px; }
  .chapter-card h3 { font-size: 1.2rem; }
  .lesson-row { padding: 12px 14px; gap: 10px; }
  .lesson-row-main span {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    white-space: normal;
    line-height: 1.35;
  }
  .lesson-hero h1 { font-size: clamp(1.6rem, 6.5vw, 2.2rem); }
  .lesson-pager { flex-direction: column; gap: 8px; }
  .lesson-pager a {
    max-width: 100%;
    width: 100%;
    padding: 12px 14px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 12px;
  }
  .lesson-pager a.next { text-align: left; margin-left: 0; }
  .question-card { padding: 18px 14px; border-radius: 18px; }
  .q-text { font-size: clamp(1.1rem, 4vw, 1.45rem); }
  .runner-top { gap: 8px; margin-bottom: 12px; }
  .runner-title { font-size: 0.68rem; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .runner-actions { gap: 8px; }
  .runner-actions .grow { display: none; }
  .runner-actions .btn { flex: 1; min-height: 48px; }
  .tf-grid { gap: 8px; margin-top: 18px; }
  .tf-btn { padding: 14px 8px; min-height: 48px; font-size: 1.02rem; }
  .exam-tools { flex-direction: column; align-items: stretch; gap: 10px; }
  .exam-tools .row { display: flex; justify-content: space-between; width: 100%; }
  .palette-toggle {
    justify-content: center;
    padding: 9px 12px;
    background: var(--surface-2);
    border-radius: 999px;
    border: 1px solid var(--line);
    width: 100%;
  }
  .palette { padding: 14px 10px; }
  .palette-grid { gap: 4px; }
  .palette-grid button { min-height: 28px; font-size: 0.64rem; }
  .palette-legend { gap: 10px; justify-content: center; font-size: 0.64rem; }
  .result-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .result-stat { padding: 10px 8px; text-align: center; }
  .result-stat span { font-size: 0.58rem; letter-spacing: 0.08em; }
  .result-stat b { font-size: 1.15rem; }
  .breakdown-row { grid-template-columns: 78px 1fr 38px; gap: 8px; font-size: 0.74rem; }
  .flash-face { padding: 24px 16px; }
  .flash-face .term { font-size: clamp(1.3rem, 5vw, 1.8rem); }
  .flash-face .def { font-size: 0.88rem; }
  .flash-controls { gap: 8px; }
  .flash-controls .btn { flex: 1; min-height: 48px; }
  .modal { padding: 22px 18px; border-radius: 20px; }
  .modal-actions { flex-direction: column-reverse; width: 100%; gap: 8px; }
  .modal-actions .btn { width: 100%; min-height: 46px; }
  .toast-region { bottom: calc(84px + var(--safe-bottom)); width: min(calc(100vw - 28px), 380px); }
}

@media (max-width: 380px) {
  .topbar { padding-left: 12px; padding-right: 12px; gap: 8px; }
  .streak-chip { padding: 0 9px; height: 34px; font-size: 0.76rem; }
  .icon-btn { width: 34px; height: 34px; }
  .brand-mark { width: 32px; height: 32px; }
  .brand-text strong { font-size: 0.94rem; }
  .quick-grid { grid-template-columns: 1fr; }
  .result-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .result-stat:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .palette-grid { grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 3px; }
  .palette-grid button { font-size: 0.6rem; min-height: 26px; }
  .breakdown-row { grid-template-columns: 68px 1fr 34px; font-size: 0.7rem; }
  .lesson-hero .meta { gap: 4px; }
  .pill { padding: 3px 8px; font-size: 0.64rem; }
}

@media (hover: none) {
  .btn:hover { transform: none; box-shadow: none; }
  .btn:active { transform: scale(0.97); }
  .chapter-card:hover { transform: none; box-shadow: none; }
  .quick-card:hover { transform: none; }
  .lesson-row:hover { transform: none; }
  .search-hit:hover { background: var(--surface); }
}
