:root {
  --bg: #F3EFE6;
  --surface: #FBF9F4;
  --line: #DDD6C8;
  --line-strong: #CFC7B6;
  --track: #E3DCCD;
  --ink: #1D1C1A;
  --ink-2: #3A3732;
  --muted: #5C5850;
  --faint: #6A665D;
  --primary: #2B3480;
  --primary-ink: #2B3480;
  --btn-bg: #1F2766;
  --btn-fg: #F6F3EC;
  --tint: #EEEAF6;
  --a1: #2B3480;
  --a2: #B4552A;
  --a3: #7FA487;
  --a1-ink: #2B3480;
  --a2-ink: #9A4622;
  --a3-ink: #3F6649;
  --good: #2F5A3B;
  --good-tint: #E7EFE8;
  --bad: #8E3F1C;
  --bad-line: #D9B7A5;
  --bad-tint: #F7E9E1;
  --hero-bg: #1F2766;
  --hero-fg: #F6F3EC;
  --hero-muted: #C9CCEA;
  --shadow: 0 1px 0 var(--track), 0 18px 40px -24px rgba(40, 32, 18, 0.35);
  --display: 'Newsreader', Georgia, 'Times New Roman', serif;
  --sans: 'Geist', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', sans-serif;
  --mono: 'Geist Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151513;
    --surface: #1E1D1A;
    --line: #34322D;
    --line-strong: #45423B;
    --track: #2C2A26;
    --ink: #EEEAE1;
    --ink-2: #D6D1C6;
    --muted: #A8A296;
    --faint: #9A9488;
    --primary: #A9B1F2;
    --primary-ink: #A9B1F2;
    --btn-bg: #C9CCF0;
    --btn-fg: #151A45;
    --tint: #23264A;
    --a1: #8C96E8;
    --a2: #E08A5C;
    --a3: #8FB89A;
    --a1-ink: #A9B1F2;
    --a2-ink: #EDA37C;
    --a3-ink: #A6CDB0;
    --good: #8FC79E;
    --good-tint: #1C2E21;
    --bad: #F0A07B;
    --bad-line: #6B3D29;
    --bad-tint: #2E1D15;
    --hero-bg: #252B66;
    --hero-fg: #F1EEE6;
    --hero-muted: #C0C4EC;
    --shadow: 0 1px 0 #0000, 0 18px 40px -24px rgba(0, 0, 0, 0.6);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--sans); font-size: 16px; line-height: 1.45;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
a { color: var(--primary-ink); text-decoration: none; }
button { font: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; border-radius: 8px; }

#app { max-width: 560px; margin: 0 auto; min-height: 100dvh; }

.screen {
  min-height: 100dvh; display: flex; flex-direction: column; gap: 20px;
  padding: calc(var(--safe-top) + 28px) 22px calc(var(--safe-bottom) + 112px);
}
.screen.session { padding: calc(var(--safe-top) + 12px) 18px calc(var(--safe-bottom) + 20px); gap: 16px; }

.display { font-family: var(--display); font-weight: 500; letter-spacing: -0.01em; line-height: 1.05; }
.h1 { font-size: 36px; }
.h2 { font-size: 22px; }
.eyebrow { font-family: var(--mono); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 14px; }
.tiny { font-size: 12px; }
.row { display: flex; align-items: center; gap: 10px; }
.between { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.grow { flex-grow: 1; }
.hidden { display: none !important; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 52px; padding: 0 18px; border-radius: 16px; border: 1px solid transparent;
  font-size: 16px; font-weight: 600; cursor: pointer; background: none; text-align: center;
  transition: transform 0.08s ease, opacity 0.15s ease;
}
.btn:active { transform: scale(0.98); }
.btn[disabled] { opacity: 0.45; cursor: default; transform: none; }
.btn.lg { min-height: 58px; font-size: 17px; }
.btn.block { width: 100%; }
.btn.primary { background: var(--btn-bg); color: var(--btn-fg); }
.btn.outline { border-color: var(--primary); color: var(--primary-ink); }
.btn.quiet { border-color: var(--line-strong); background: var(--surface); color: var(--ink); }
.btn.icon { width: 44px; min-height: 44px; padding: 0; border-radius: 999px; }
.btn.icon-sq { width: 58px; min-height: 58px; padding: 0; border-color: var(--line-strong); background: var(--surface); }
.btn.icon-sq[aria-pressed="true"] { border-color: var(--a2); color: var(--a2-ink); background: var(--bad-tint); }

.chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--line-strong); font-size: 13px; color: var(--ink-2);
}
.dot { width: 9px; height: 9px; border-radius: 3px; flex-shrink: 0; }
.bar { height: 8px; border-radius: 999px; background: var(--track); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 999px; min-width: 0; }
.bar.thin { height: 6px; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 20px 22px; }

/* login */
.login { justify-content: space-between; padding-top: calc(var(--safe-top) + 90px); padding-bottom: calc(var(--safe-bottom) + 40px); }
.brand { display: flex; align-items: center; gap: 12px; font-family: var(--mono); font-size: 13px; letter-spacing: 0.1em; text-transform: uppercase; }
.mark { display: flex; flex-direction: column; gap: 4px; }
.mark span { display: block; height: 6px; border-radius: 3px; }
.login h1 { font-size: 44px; line-height: 1.02; letter-spacing: -0.015em; margin: 28px 0 18px; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--faint); font-size: 13px; }
.divider::before, .divider::after { content: ''; flex-grow: 1; height: 1px; background: var(--line-strong); }
.field { display: flex; flex-direction: column; gap: 6px; }
.label { font-size: 13px; font-weight: 500; color: var(--ink-2); }
input[type=password], input[type=text], input[type=date], select {
  height: 52px; border-radius: 14px; border: 1px solid var(--line-strong); background: var(--surface);
  padding: 0 16px; font-size: 17px; font-family: inherit; color: var(--ink); width: 100%;
}
.error { color: var(--bad); font-size: 14px; min-height: 20px; }
.fine { text-align: center; font-size: 13px; color: var(--faint); }

/* today */
.hero { background: var(--hero-bg); color: var(--hero-fg); border-radius: 22px; padding: 22px; display: flex; flex-direction: column; gap: 16px; }
.hero .eyebrow, .hero .hm { color: var(--hero-muted); }
.hero .big { font-family: var(--display); font-size: 64px; line-height: 0.9; font-weight: 500; }
.hero .btn { background: var(--hero-fg); color: var(--hero-bg); }
.go { flex-shrink: 0; width: 52px; height: 52px; border-radius: 999px; background: var(--btn-bg); color: var(--btn-fg); display: flex; align-items: center; justify-content: center; }
.area-row { display: flex; flex-direction: column; gap: 8px; color: var(--ink); padding: 4px 0; }

/* tabs */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  background: var(--surface); border-top: 1px solid var(--line);
  padding: 8px 12px calc(var(--safe-bottom) + 8px);
}
.tabs-inner { max-width: 560px; margin: 0 auto; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; }
.tabs a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 50px; color: var(--faint); font-size: 11px; font-weight: 500; }
.tabs a[aria-current="page"] { color: var(--primary-ink); font-weight: 600; }

/* session */
.topbar { display: flex; align-items: center; gap: 12px; }
.topbar .count { font-family: var(--mono); font-size: 13px; color: var(--muted); min-width: 44px; text-align: right; }
.card {
  flex-grow: 1; background: var(--surface); border: 1px solid var(--line); border-radius: 28px;
  padding: 26px 24px; display: flex; flex-direction: column; gap: 18px; box-shadow: var(--shadow);
  cursor: pointer; min-height: 420px;
}
.card.back { cursor: default; }
.card-front-main { flex-grow: 1; display: flex; flex-direction: column; justify-content: center; gap: 18px; }
.card .term { font-family: var(--display); font-weight: 500; font-size: 40px; line-height: 1.04; letter-spacing: -0.015em; text-wrap: balance; }
.card .term.long { font-size: 24px; line-height: 1.3; font-family: var(--sans); font-weight: 500; letter-spacing: 0; }
.card .prompt { font-size: 18px; line-height: 1.45; color: var(--ink-2); }
.card .answer { font-size: 18px; line-height: 1.5; }
.card ul { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; font-size: 16px; line-height: 1.4; color: var(--ink-2); }
.lens { display: flex; flex-direction: column; gap: 6px; padding: 14px 16px; background: var(--tint); border-radius: 14px; }
.lens .eyebrow { color: var(--primary-ink); font-size: 11px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding-bottom: 14px; border-bottom: 1px solid var(--track); }
.card-head .t { font-family: var(--display); font-weight: 500; font-size: 26px; line-height: 1.12; }
.card-head .t.long { font-family: var(--sans); font-size: 16px; line-height: 1.4; font-weight: 500; }
.ratings { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.rate { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; height: 64px; border-radius: 14px; border: 1px solid var(--line-strong); background: var(--surface); font-size: 15px; font-weight: 600; cursor: pointer; }
.rate small { font-family: var(--mono); font-size: 11px; font-weight: 400; color: var(--faint); }
.rate.again { border-color: var(--bad-line); color: var(--bad); }
.rate.good { background: var(--btn-bg); color: var(--btn-fg); border-color: transparent; }
.rate.good small { color: inherit; opacity: 0.75; }
.rate[disabled] { opacity: 0.5; }

/* practice */
.stem { font-size: 18px; line-height: 1.5; }
.stem strong.qual, .qual { letter-spacing: 0.02em; font-weight: 700; }
.options { display: flex; flex-direction: column; gap: 10px; }
.opt {
  display: flex; align-items: flex-start; gap: 14px; min-height: 60px; padding: 14px 16px; border-radius: 16px;
  border: 1px solid var(--line); background: var(--surface); font-size: 16px; line-height: 1.4; text-align: left; cursor: pointer; width: 100%;
}
.opt .k { flex-shrink: 0; width: 28px; height: 28px; border-radius: 999px; border: 1px solid var(--line-strong); display: flex; align-items: center; justify-content: center; font-family: var(--mono); font-size: 13px; }
.opt[aria-pressed="true"] { border: 2px solid var(--primary); background: var(--tint); padding: 13px 15px; }
.opt[aria-pressed="true"] .k { background: var(--primary); border-color: var(--primary); color: var(--bg); }
.verdict { display: flex; align-items: center; gap: 12px; }
.verdict .ic { width: 40px; height: 40px; border-radius: 999px; display: flex; align-items: center; justify-content: center; color: #fff; flex-shrink: 0; }
.verdict.ok .ic { background: #2F5A3B; }
.verdict.no .ic { background: #A14A22; }
.res { display: flex; gap: 12px; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); }
.res .k { font-family: var(--mono); font-size: 13px; color: var(--faint); padding-top: 1px; }
.res .t { font-size: 15px; font-weight: 500; }
.res .w { font-size: 14px; line-height: 1.4; color: var(--muted); }
.res.correct { border: 2px solid var(--good); background: var(--good-tint); }
.res.correct .k { color: var(--good); font-weight: 600; }
.res.chosen { border: 2px solid var(--bad-line); background: var(--bad-tint); }
.res .tag { font-family: var(--mono); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; margin-left: 6px; }
.section-label { font-size: 13px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.path { font-family: var(--mono); font-size: 12px; line-height: 1.5; color: var(--muted); }
.actions { display: flex; gap: 10px; margin-top: auto; }
.actions .btn { flex: 1 1 0; }

/* outline */
.area-head { display: flex; justify-content: space-between; align-items: baseline; padding-bottom: 6px; border-bottom: 2px solid; }
.area-head h2 { font-size: 16px; font-weight: 600; }
.comp-row { display: grid; grid-template-columns: 40px minmax(0, 1fr) 70px; align-items: center; gap: 10px; min-height: 48px; color: var(--ink); font-size: 15px; border-bottom: 1px solid var(--track); }
.comp-row:last-child { border-bottom: 0; }
.comp-row .id { font-family: var(--mono); font-size: 12px; color: var(--faint); }
.comp-row.soon { color: var(--faint); }
.soon-label { font-family: var(--mono); font-size: 11px; color: var(--faint); text-align: right; }
.stat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; }
.stat .n { font-family: var(--display); font-size: 30px; line-height: 1; }
.stmt { display: flex; flex-direction: column; gap: 4px; padding: 12px 0; border-bottom: 1px solid var(--track); color: var(--ink); }
.stmt:last-child { border-bottom: 0; }
.stmt .meta { font-family: var(--mono); font-size: 12px; color: var(--faint); }
.back-link { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; font-weight: 600; font-size: 15px; }

.banner { display: flex; flex-direction: column; gap: 12px; padding: 16px 18px; border-radius: 18px; background: var(--tint); }

#toast {
  position: fixed; left: 50%; bottom: calc(var(--safe-bottom) + 100px); transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 14px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; max-width: calc(100vw - 40px); z-index: 50;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.loading { min-height: 100dvh; display: flex; align-items: center; justify-content: center; color: var(--faint); font-family: var(--mono); font-size: 13px; }

@media (min-width: 700px) {
  .screen { padding-top: 48px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
