/* estudio — a quiet place to review neuroscience.
   Palette from the Nissl stain (cresyl violet on a pale slide). */
:root {
  --paper: #F5F4F8;
  --paper-2: #FFFFFF;
  --ink: #221D33;
  --muted: #6E6883;
  --line: #DAD6E4;
  --nissl: #5B3B8C;
  --nissl-soft: #EEE8F7;
  --nissl-mid: #A38BCB;
  --again: #B2452F;
  --hard: #9A6B14;
  --good: #5B3B8C;
  --easy: #2E7466;
  --learning: #C9A24A;
  --shadow: 0 1px 2px rgba(34, 29, 51, .06), 0 8px 24px -12px rgba(34, 29, 51, .18);
  --radius: 10px;
  --serif: "Fraunces", "Iowan Old Style", Georgia, serif;
  --sans: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #16131F; --paper-2: #1F1B2B; --ink: #ECE8F4; --muted: #A59EB9; --line: #332D45;
    --nissl: #B9A2E6; --nissl-soft: #2A2340; --nissl-mid: #7F68A8;
    --again: #E0705A; --hard: #D5A23A; --good: #B9A2E6; --easy: #5FB8A4; --learning: #D0AE58;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px -12px rgba(0,0,0,.6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #16131F; --paper-2: #1F1B2B; --ink: #ECE8F4; --muted: #A59EB9; --line: #332D45;
  --nissl: #B9A2E6; --nissl-soft: #2A2340; --nissl-mid: #7F68A8;
  --again: #E0705A; --hard: #D5A23A; --good: #B9A2E6; --easy: #5FB8A4; --learning: #D0AE58;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px -12px rgba(0,0,0,.6);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: var(--sans); font-size: 1rem; line-height: 1.5;
  -webkit-font-smoothing: antialiased; min-height: 100dvh;
}
a { color: inherit; }
:focus-visible { outline: 2px solid var(--nissl); outline-offset: 3px; border-radius: 4px; }
button, input, select { font: inherit; color: inherit; }
h1, h2, h3 { font-family: var(--serif); font-weight: 500; letter-spacing: -0.01em; margin: 0; }
h1 { font-size: 2rem; line-height: 1.15; }
h2 { font-size: 1.125rem; line-height: 1.3; margin: 2.25rem 0 .75rem; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.dim { color: var(--muted); }

.page { max-width: 40rem; margin: 0 auto; padding: 0 16px calc(24px + env(safe-area-inset-bottom)); }
.top { display: flex; align-items: center; justify-content: space-between; padding: 18px 0 8px; }
.mark { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; color: var(--nissl); font-family: var(--serif); font-size: 1.125rem; }
.spike { width: 34px; height: 17px; }
.top nav { display: flex; gap: 4px; }
.top nav a { text-decoration: none; color: var(--muted); padding: 6px 10px; border-radius: 999px; font-size: .9375rem; }
.top nav a[aria-current="page"] { color: var(--ink); background: var(--nissl-soft); }
.top nav a:hover { color: var(--ink); }

/* ----- home ----- */
.hero { padding: 40px 0 8px; }
.how { margin: 1.75rem 0 0; color: var(--muted); font-size: .9375rem; line-height: 1.55; max-width: 48ch; padding-left: 14px; border-left: 2px solid var(--nissl-mid); }
.lede { font-family: var(--serif); font-size: clamp(1.625rem, 5.2vw, 2.125rem); line-height: 1.2; margin: 0 0 .5rem; max-width: 22ch; text-wrap: balance; }
.sub { color: var(--muted); margin: 0 0 1.5rem; max-width: 52ch; }
.row { display: flex; flex-wrap: wrap; gap: 10px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--paper-2); color: var(--ink); text-decoration: none; cursor: pointer;
  font-weight: 500; font-size: .9375rem; transition: background .15s, border-color .15s, transform .08s;
}
.btn:hover { border-color: var(--nissl-mid); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--nissl); border-color: var(--nissl); color: var(--paper); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.big { min-height: 54px; padding: 0 26px; font-size: 1.0625rem; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--nissl); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }

.decks h2 { margin-top: 2.75rem; color: var(--muted); font-family: var(--sans); font-size: .875rem; font-weight: 500; }
.decklist { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.decklist li { border-bottom: 1px solid var(--line); }
.deckrow, .decklist.plain li {
  display: grid; grid-template-columns: 4.5rem 1fr auto; grid-template-areas: "num name status" "num bar bar";
  gap: 4px 12px; align-items: baseline; padding: 14px 4px; text-decoration: none; color: inherit;
  border-radius: 6px; transition: background .15s;
}
.deckrow:hover { background: var(--nissl-soft); }
.deck-num { grid-area: num; color: var(--muted); font-size: .875rem; }
.deck-name { grid-area: name; font-family: var(--serif); font-size: 1.125rem; line-height: 1.3; }
.deck-status { grid-area: status; color: var(--muted); font-size: .8125rem; white-space: nowrap; }
.deck-status.due { color: var(--nissl); font-weight: 600; }
.bar { grid-area: bar; display: flex; height: 5px; border-radius: 3px; background: var(--line); overflow: hidden; margin-top: 6px; }
.bar i { display: block; height: 100%; }
.bar .mature, .sw.mature { background: var(--nissl); }
.bar .review, .sw.review { background: var(--nissl-mid); }
.bar .learning, .sw.learning { background: var(--learning); }
.sw.new { background: var(--line); }
.legend { color: var(--muted); font-size: .8125rem; margin: 12px 4px 0; display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.note { margin-top: 2.5rem; padding: 14px 16px; border-left: 3px solid var(--nissl-mid); color: var(--muted); font-size: .9375rem; }
.note a { color: var(--nissl); }
@media (max-width: 420px) {
  .deckrow, .decklist.plain li { grid-template-columns: 1fr auto; grid-template-areas: "num status" "name name" "bar bar"; }
}

/* ----- deck page / reading ----- */
.crumb { color: var(--muted); margin: 28px 0 6px; font-size: .9375rem; }
.crumb a { text-decoration: none; }
.crumb a:hover { text-decoration: underline; }
.summary { font-family: var(--serif); font-size: 1.125rem; line-height: 1.5; color: var(--muted); margin: .75rem 0 1.5rem; max-width: 60ch; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 0 0 1.5rem; padding: 0; }
.stats div { border-top: 1px solid var(--line); padding-top: 10px; }
.stats dt { color: var(--muted); font-size: .8125rem; }
.stats dd { margin: 2px 0 0; font-family: var(--serif); font-size: 1.75rem; line-height: 1.1; }
.stats dd small { font-size: .875rem; color: var(--muted); font-family: var(--sans); }
@media (max-width: 420px) { .stats { grid-template-columns: repeat(2, 1fr); } }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 1.5rem 0 1rem; }
.hint { color: var(--muted); font-size: .875rem; line-height: 1.5; max-width: 60ch; }

.prose { font-family: var(--serif); font-size: 1.0625rem; line-height: 1.65; max-width: 62ch; }
.prose h2 { font-size: 1.375rem; margin: 2.25rem 0 .75rem; }
.prose h3 { font-size: 1.125rem; margin: 1.75rem 0 .5rem; }
.prose h4 { font-size: 1rem; margin: 1.25rem 0 .25rem; font-family: var(--sans); font-weight: 600; }
.prose p { margin: 0 0 1rem; }
.prose ul { padding-left: 1.25rem; margin: 0 0 1rem; }
.prose li { margin: .35rem 0; }
.prose li::marker { color: var(--nissl-mid); }
.prose strong { font-weight: 600; }
.tablewrap { overflow-x: auto; margin: 0 -16px 1rem; padding: 0 16px; }
.prose table { border-collapse: collapse; font-family: var(--sans); font-size: .9rem; min-width: 100%; }
.prose th, .prose td { text-align: left; vertical-align: top; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.prose th { font-weight: 600; color: var(--muted); font-size: .8125rem; }
.reading .actions { margin-top: 2.5rem; }

/* ----- session ----- */
.studying { min-height: 100dvh; display: flex; flex-direction: column; padding-bottom: 0; }
.studying main, .session { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.session-top { display: flex; align-items: center; gap: 12px; padding: 14px 0 8px; font-size: .875rem; color: var(--muted); }
.session-title { flex: 1; text-align: center; }
.count { font-variant-numeric: tabular-nums; }
.close { width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center; border-radius: 999px; text-decoration: none; color: var(--muted); font-size: 1rem; }
.close:hover { background: var(--nissl-soft); color: var(--ink); }
.progress { height: 3px; background: var(--line); border-radius: 2px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--nissl); transition: width .3s ease; }

.card { flex: 1; display: flex; flex-direction: column; padding: 4vh 0 24px; min-height: 0; cursor: pointer; }
.card-inner { margin: auto 0; }
.card.revealed { cursor: default; }
.kind { margin: 0 0 14px; color: var(--muted); font-size: .8125rem; }
.qtext, .cloze-text { font-family: var(--serif); font-size: clamp(1.5rem, 4.6vw, 2rem); line-height: 1.3; margin: 0; text-wrap: pretty; }
.blank { display: inline-block; width: var(--w, 8ch); max-width: 60vw; height: .95em; vertical-align: -0.12em; border-bottom: 2px solid var(--nissl-mid); margin: 0 .1em; position: relative; }
.cloze-text mark { background: var(--nissl-soft); color: var(--nissl); padding: 0 .18em; border-radius: 4px; font-weight: 500; }
.a { margin-top: 26px; padding-top: 22px; border-top: 1px solid var(--line); animation: reveal .28s ease both; }
.atext { font-family: var(--serif); font-size: clamp(1.1875rem, 3.6vw, 1.5rem); line-height: 1.4; margin: 0; text-wrap: pretty; }
.why { margin: 14px 0 0; color: var(--muted); font-size: 1rem; line-height: 1.5; max-width: 60ch; }
@keyframes reveal { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.dock { position: sticky; bottom: 0; padding: 12px 0 calc(14px + env(safe-area-inset-bottom)); background: linear-gradient(to top, var(--paper) 70%, transparent); }
.dock .btn { width: 100%; }
.dockq { margin: 0 0 8px; text-align: center; font-family: var(--serif); font-size: 1rem; color: var(--ink); }
.dockhint .sep { margin: 0 4px; opacity: .6; }
.dockhint { text-align: center; color: var(--muted); font-size: .8125rem; margin: 10px 0 0; min-height: 1.2em; }
.ratings { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.rate {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 60px; padding: 8px 4px; border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--paper-2); cursor: pointer; box-shadow: var(--shadow); transition: transform .08s, border-color .15s;
  border-top: 3px solid var(--c);
}
.rate:hover { border-color: var(--c); }
.rate:active { transform: translateY(1px); }
.rate b { font-weight: 600; font-size: .9375rem; color: var(--c); }
.rate small { color: var(--muted); font-size: .75rem; font-variant-numeric: tabular-nums; }
.rate.r1 { --c: var(--again); } .rate.r2 { --c: var(--hard); } .rate.r3 { --c: var(--good); } .rate.r4 { --c: var(--easy); }
@media (max-width: 360px) { .rate b { font-size: .8125rem; } }

.flash { position: fixed; inset: 0; pointer-events: none; background: var(--c); opacity: .1; animation: flash .35s ease-out forwards; }
.flash.g1 { --c: var(--again); } .flash.g2 { --c: var(--hard); } .flash.g3 { --c: var(--good); } .flash.g4 { --c: var(--easy); }
@keyframes flash { to { opacity: 0; } }

/* ----- finish ----- */
.finish { padding: 8vh 0 0; }
.finish h1 { max-width: 20ch; text-wrap: balance; margin-bottom: .5rem; }
.ap { width: min(100%, 320px); height: auto; display: block; margin: 0 0 28px -4px; }
.ap-base { stroke: var(--line); stroke-width: 1.5; stroke-dasharray: 3 5; fill: none; }
.ap-line { stroke: var(--nissl); stroke-width: 2.5; fill: none; stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 520; stroke-dashoffset: 520; animation: draw 1.4s cubic-bezier(.4,0,.2,1) .15s forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }

/* ----- progress ----- */
.progress-page h1, .settings h1 { margin: 28px 0 1.25rem; }
.grid12 { display: grid; grid-template-rows: repeat(7, 12px); grid-auto-flow: column; grid-auto-columns: 12px; gap: 3px; }
.cell { display: block; border-radius: 3px; background: var(--line); }
.cell.l1 { background: color-mix(in oklab, var(--nissl) 30%, var(--line)); }
.cell.l2 { background: color-mix(in oklab, var(--nissl) 55%, var(--line)); }
.cell.l3 { background: color-mix(in oklab, var(--nissl) 80%, var(--line)); }
.cell.l4 { background: var(--nissl); }
.upcoming { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; align-items: end; max-width: 26rem; }
.upday { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: .75rem; color: var(--muted); }
.upday b { display: block; width: 100%; max-width: 28px; background: var(--nissl-mid); border-radius: 3px 3px 0 0; }
.upday small { color: var(--ink); font-variant-numeric: tabular-nums; }

/* ----- settings ----- */
.field { margin: 0 0 2rem; }
.field label, .field .label { display: block; font-weight: 600; margin-bottom: 8px; }
.field input[type="text"], .field input[type="number"], .field select {
  min-height: 44px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--paper-2); width: 100%;
}
.inline { display: flex; gap: 8px; }
.inline input { flex: 1; min-width: 0; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 999px; background: var(--paper-2); overflow: hidden; }
.stepper button { width: 44px; height: 44px; border: 0; background: none; cursor: pointer; font-size: 1.25rem; color: var(--nissl); }
.stepper button:hover { background: var(--nissl-soft); }
.stepper input { width: 4.5rem; text-align: center; border: 0 !important; background: none !important; -moz-appearance: textfield; appearance: textfield; }
.stepper input::-webkit-inner-spin-button { display: none; }
.method { font-size: 1rem; }
.method p { margin-bottom: .9rem; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .ap-line { stroke-dashoffset: 0; }
  .flash { display: none; }
}
