/* Wheelwright: a woodworking workshop.
   Linen paper, walnut ink, brass fittings and an olive for "retained"; a bookish serif
   for headings (Spectral), a plain workmanlike sans for reading (Work Sans), and
   monospaced figures (IBM Plex Mono). Squared-off corners, like cut timber.
   Dark (charred oak and copper) for everyone. A light theme (linen and walnut) is kept
   below and can be switched on with <html data-theme="light">. */

:root {
  color-scheme: dark;        /* text boxes, scrollbars and date pickers match */
  --paper: #16110c;          /* page: charred oak */
  --surface: #1f1812;        /* cards and panels */
  --surface-2: #2a2119;      /* inputs, tracks */
  --ink: #eee4d5;
  --muted: #a59684;
  --line: #3a2e23;
  --accent: #d08a5a;         /* copper */
  --accent-strong: #e3a275;
  --accent-soft: #3a271a;
  --on-accent: #1a110a;
  --brass: #d8aa52;
  --brass-soft: #3a2f18;
  --forgot: #e57a66;
  --shaky: #e0a64a;
  --solid: #93bf6b;          /* olive */
  --flag-bg: #3b2f17;
  --shadow: 0 1px 0 rgba(0, 0, 0, .3), 0 8px 22px rgba(0, 0, 0, .3);

  --font-display: "Spectral", Georgia, "Times New Roman", serif;
  --font-body: "Work Sans", "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", "Cascadia Mono", Consolas, monospace;
  --radius: 6px;
}
:root[data-theme="light"] {
  color-scheme: light;
  --paper: #f2ece1;          /* linen */
  --surface: #fbf8f2;
  --surface-2: #ece4d6;
  --ink: #2b2118;            /* walnut ink */
  --muted: #7b6f62;
  --line: #ddd2c0;
  --accent: #6e4224;         /* walnut */
  --accent-strong: #55321a;
  --accent-soft: #eadccb;
  --on-accent: #fbf6ee;
  --brass: #a87b2d;
  --brass-soft: #f0e2c2;
  --forgot: #a8402f;
  --shaky: #b0761c;
  --solid: #4f7537;
  --flag-bg: #f6e6c8;
  --shadow: 0 1px 0 rgba(43, 33, 24, .05), 0 6px 18px rgba(43, 33, 24, .07);
}

/* ------------------------------------------------------------------ base */
* { box-sizing: border-box; }
[hidden] { display: none !important; } /* hidden must win over display rules below */
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  color: var(--ink);
  background-color: var(--paper);
  font: 17px/1.65 var(--font-body);
  -webkit-font-smoothing: antialiased;
}
/* Faint ink-wash mountains in mist, fixed to the bottom of the window behind everything
   (static/mountains.svg). Cards and panels have solid backgrounds, so they sit on top. */
body::before {
  content: ""; position: fixed; left: 0; right: 0; bottom: 0; z-index: -1;
  height: min(56vh, 560px); pointer-events: none;
  background: url("mountains.svg") center bottom / cover no-repeat;
  /* fade the top edge, so however a window crops the image, nothing ends in a hard line */
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 30%);
  mask-image: linear-gradient(to bottom, transparent, #000 30%);
}
:root[data-theme="light"] body::before { filter: invert(1) opacity(.7); }  /* dark ink on light paper */
main { max-width: 760px; margin: 0 auto; padding: 36px 18px 80px; }
a { color: var(--accent); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { color: var(--accent-strong); }
code { font: 0.88em var(--font-mono); background: var(--surface-2); padding: 1px 5px; border-radius: 3px; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; letter-spacing: -0.005em; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.center { text-align: center; }
:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }

/* ------------------------------------------------------------------ header */
.site-header { border-bottom: 1px solid var(--line); background: var(--paper); }
.nav {
  display: flex; align-items: center; justify-content: space-between;
  max-width: 760px; margin: 0 auto; padding: 14px 18px;
}
.brand { display: inline-flex; align-items: center; gap: 11px; color: var(--ink); text-decoration: none; }
.brand:hover { color: var(--ink); }
.brand-mark { width: 46px; height: 46px; flex: none; }
.mark-ink { fill: var(--ink); }        /* the ring: pale ink on dark, dark ink on light */
.mark-ridge { fill: var(--accent); }   /* the ridge: copper (walnut in the light theme) */
.brand-text { display: flex; flex-direction: column; line-height: 1; }
.brand-name { font: 600 28px/1 var(--font-display); letter-spacing: .01em; }
/* While studying: a compact header (smaller logo and name) so the card has the stage. */
.site-header.compact .nav { padding-top: 10px; padding-bottom: 10px; }
.site-header.compact .brand-mark { width: 32px; height: 32px; }
.site-header.compact .brand-name { font-size: 20px; }
.nav-link { font-size: 15px; color: var(--muted); text-decoration: none; }
.nav-link:hover { color: var(--ink); }
.nav-links { display: flex; gap: 18px; }

/* ------------------------------------------------------------------ buttons */
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font: 500 15.5px/1.2 var(--font-body); letter-spacing: .01em; text-decoration: none; cursor: pointer;
  transition: background .12s ease, border-color .12s ease, box-shadow .12s ease;
}
.button:hover { border-color: var(--muted); color: var(--ink); }
.button.primary {
  background: var(--accent); border-color: var(--accent-strong); color: var(--on-accent);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .15);
}
.button.primary:hover { background: var(--accent-strong); color: var(--on-accent); }
.button.big { padding: 14px 30px; font-size: 17px; }
.button.small { padding: 6px 13px; font-size: 14px; }
.button.ghost { background: transparent; border-style: dashed; color: var(--muted); }
.button.ghost:hover { color: var(--accent); border-color: var(--accent); }
.button:disabled { opacity: .5; cursor: default; }
.link-button {
  background: none; border: none; padding: 0; color: var(--accent);
  font: inherit; font-size: 14px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px;
}
kbd {
  font: 11px var(--font-mono); padding: 1px 5px; margin-left: 2px;
  border: 1px solid currentColor; border-radius: 3px; opacity: .55;
}

/* ------------------------------------------------------------------ home */
.hero { text-align: center; padding: 4px 0 8px; }
.eyebrow {
  margin: 0; font: 600 12px var(--font-body); letter-spacing: .18em; text-transform: uppercase;
  color: var(--brass);
}
.hero-title { font-size: clamp(32px, 6vw, 46px); line-height: 1.1; margin: 10px 0 28px; }
.ledger {
  display: grid; grid-template-columns: repeat(3, 1fr);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.ledger-item { padding: 18px 12px 16px; display: flex; flex-direction: column; gap: 6px; }
.ledger-item + .ledger-item { border-left: 1px solid var(--line); }
.ledger-num { font: 600 40px/1 var(--font-display); color: var(--accent); font-variant-numeric: oldstyle-nums; }
.ledger-item:nth-child(2) .ledger-num { color: var(--brass); }
.ledger-item:nth-child(3) .ledger-num { color: var(--ink); }
.ledger-label { font-size: 13px; color: var(--muted); letter-spacing: .02em; }
.hero-actions { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-top: 28px; }

.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px 22px; margin-top: 36px;
}
.section-title { font-size: 23px; margin: 0 0 4px; }
.ai-panel { display: flex; gap: 16px; align-items: flex-start; }
.ai-panel p { margin: 0; color: var(--muted); }
.ai-status {
  flex: none; width: 11px; height: 11px; margin-top: 11px; border-radius: 50%; background: var(--muted);
}
.ai-panel.on .ai-status { background: var(--solid); box-shadow: 0 0 0 4px color-mix(in srgb, var(--solid) 20%, transparent); }

.decks-section { margin-top: 40px; }
.section-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding-bottom: 8px; margin-bottom: 12px; border-bottom: 1px solid var(--line);
}
.saved { color: var(--solid); font-weight: 600; }
.deck-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.deck {
  display: flex; align-items: center; gap: 16px;
  background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--brass);
  border-radius: var(--radius); padding: 14px 16px;
  transition: box-shadow .12s ease, border-color .12s ease;
}
.deck:hover { box-shadow: var(--shadow); border-left-color: var(--accent); }
.deck-main { flex: 1; min-width: 0; }
.deck-name { font: 600 18px var(--font-display); color: var(--ink); text-decoration: none; }
.deck-name:hover { color: var(--accent); }
.progress { height: 4px; margin: 8px 0 6px; background: var(--surface-2); border-radius: 2px; overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--accent); }
.deck-meta { font-size: 13px; color: var(--muted); }
.deck-side { display: flex; align-items: center; gap: 10px; flex: none; }
.badge {
  font: 500 12.5px var(--font-mono); padding: 3px 9px; border-radius: 3px;
  background: var(--brass-soft); color: color-mix(in srgb, var(--brass) 55%, var(--ink));
}
.remind-toggle { position: relative; cursor: pointer; }
.remind-toggle input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.remind-toggle span {
  display: inline-block; padding: 4px 11px; border-radius: 3px; font-size: 13px;
  border: 1px solid var(--line); color: var(--muted);
}
.remind-toggle input:checked + span { background: var(--accent-soft); border-color: transparent; color: var(--accent); font-weight: 600; }
.remind-toggle input:focus-visible + span { outline: 2px solid var(--brass); outline-offset: 2px; }

/* The "Choose file" button for restoring progress, dressed like the other buttons. */
input[type="file"] { color: var(--muted); font: 14px var(--font-body); max-width: 100%; }
input[type="file"]::file-selector-button {
  margin-right: 12px; padding: 8px 14px; border-radius: var(--radius); cursor: pointer;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); font: 500 14px var(--font-body);
}
input[type="file"]::file-selector-button:hover { border-color: var(--muted); }

/* ------------------------------------------------------------------ about */
.about-lede { font-size: 18px; line-height: 1.6; margin: 0; }
.about-section { margin-top: 24px; }
.about-section p, .about-section li { line-height: 1.65; }
.about-section ul { margin: 8px 0 0; padding-left: 20px; display: grid; gap: 8px; }

/* ------------------------------------------------------------------ study */
.review-bar {
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  color: var(--muted); font-size: 14px; margin-bottom: 14px;
}
.session-count { font-family: var(--font-mono); color: var(--muted); }
.session-count strong { color: var(--accent); font-weight: 500; }
.session-track { height: 3px; margin: -6px 0 16px; background: var(--surface-2); overflow: hidden; }
.session-track span { display: block; height: 100%; background: var(--brass); transition: width .3s ease; }
.session-ledger { margin-top: 28px; }

/* A card: a planed board with a brass rule. */
.card {
  position: relative; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 30px 32px 28px; box-shadow: var(--shadow);
}
article.card { border-top: 3px solid var(--brass); }
.card-meta { margin: 0 0 18px; color: var(--muted); font-size: 13px; letter-spacing: .02em; }
.flag { background: var(--flag-bg); padding: 8px 12px; border-radius: 4px; font-size: 14px; }
.question { font: 600 25px/1.4 var(--font-display); margin: 0; white-space: pre-line; }
.answer { margin-top: 26px; padding-top: 20px; border-top: 1px solid var(--line); }
.answer h2, .fb h2, .fb summary {
  font: 600 11.5px var(--font-body); text-transform: uppercase; letter-spacing: .16em;
  color: var(--muted); margin: 0 0 8px;
}
.answer-text { white-space: pre-line; margin: 0; }
.note { margin: 16px 0 0; padding: 10px 14px; background: var(--brass-soft); border-radius: 4px; color: var(--ink); font-size: 15px; }
.actions { margin-top: 22px; text-align: center; }
.rate-prompt { color: var(--muted); margin: 0 0 14px; font-size: 15px; }

/* timer */
.timer { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.timer-track { flex: 1; height: 4px; background: var(--surface-2); overflow: hidden; }
.timer-fill { height: 100%; width: 100%; background: var(--accent); transition: width .2s linear, background .3s; }
.timer-text { font: 500 13px var(--font-mono); color: var(--muted); min-width: 92px; text-align: right; }
.timer.warning .timer-fill { background: var(--shaky); }
.timer.timed-out .timer-fill { background: var(--forgot); }
.timer.timed-out .timer-text { color: var(--forgot); }
.timer.stopped .timer-fill { background: var(--solid); }
.time-result { margin: 0 0 16px; font-size: 14px; color: var(--muted); }

/* typed answers + inputs */
.answer-label { display: block; margin: 28px 0 8px; font-size: 14px; color: var(--muted); }
textarea, input[type="text"], input[type="email"], input[type="password"], input[type="date"], input[type="time"], select {
  width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: 4px;
  background: var(--surface-2); color: var(--ink); font: inherit;
  transition: border-color .12s ease, background .12s ease;
}
textarea { resize: vertical; line-height: 1.6; }
textarea:focus, input:focus, select:focus { outline: none; border-color: var(--accent); background: var(--surface); }
.answer-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.grading { color: var(--muted); text-align: right; margin: 10px 0 0; font-style: italic; }

/* feedback */
.score { display: flex; align-items: baseline; gap: 8px; margin: 22px 0 6px; }
.score-num { font: 600 56px/1 var(--font-display); font-variant-numeric: oldstyle-nums; }
.score-of { color: var(--muted); }
.score-label { margin-left: auto; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .14em; }
.score-1 .score-num { color: var(--forgot); }
.score-2 .score-num { color: var(--shaky); }
.score-3 .score-num, .score-4 .score-num { color: var(--solid); }
.fb { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.fb summary { cursor: pointer; }
.fb ul { margin: 0; padding-left: 20px; }
.fb li { margin-bottom: 4px; }
.fb li::marker { color: var(--brass); }
.fb-text { white-space: pre-line; margin: 0; }
.fb-wrong h2 { color: var(--forgot); }
.fb-wrong li::marker { color: var(--forgot); }
.fb-rewrite .fb-text {
  border-left: 2px solid var(--solid); padding: 4px 0 4px 16px;
  font: italic 400 19px/1.55 var(--font-display);
}
.error { background: var(--flag-bg); padding: 12px 14px; border-radius: 4px; margin-top: 16px; }
.notice { background: var(--accent-soft); color: var(--accent-strong); padding: 12px 14px; border-radius: 4px; font-weight: 500; }

/* Forgotten -> Retained slider */
.retention { max-width: 580px; margin: 0 auto; text-align: left; }
.retention-ends {
  display: flex; justify-content: space-between; margin-bottom: 8px;
  font-size: 11.5px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase;
}
.retention-ends span:first-child { color: var(--forgot); }
.retention-ends span:last-child { color: var(--solid); }
.retention input[type="range"] {
  --fill: 50%; --hue: 60;
  width: 100%; height: 8px; margin: 0; padding: 0; border: none; border-radius: 4px; cursor: pointer;
  -webkit-appearance: none; appearance: none;
  background: linear-gradient(to right, hsl(calc(var(--hue) * 0.8 + 8) 45% 42%) var(--fill), var(--surface-2) var(--fill));
}
.retention input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 24px; height: 24px; border-radius: 50%;
  background: var(--surface); border: 3px solid var(--accent); box-shadow: var(--shadow);
}
.retention input[type="range"]::-moz-range-thumb {
  width: 18px; height: 18px; border-radius: 50%; background: var(--surface); border: 3px solid var(--accent);
}
.retention-readout { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 6px 16px; margin-top: 12px; font-size: 15px; }
#retention-value { font-family: var(--font-mono); }
.retention-confirm { display: flex; margin: 20px auto 0; }
.custom-date { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px 14px; margin-top: 10px; }
.custom-date input[type="date"] { width: auto; padding: 6px 10px; }

/* ------------------------------------------------------------------ forms: settings, add card, drafts */
.page-title { font-size: 36px; margin: 4px 0 20px; }
.settings h2 { font-size: 21px; margin: 30px 0 8px; padding-top: 18px; border-top: 1px solid var(--line); }
.settings h2:first-child { margin-top: 0; padding-top: 0; border-top: none; }
.settings label { display: block; margin: 14px 0 6px; font-size: 15px; font-weight: 500; }
.settings label.check { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.settings input[type="text"], .settings input[type="email"], .settings input[type="password"], .settings select { max-width: 440px; }
.settings input[type="time"] { width: auto; }
input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--accent); }
.settings-actions { margin-top: 26px; }
.time-row { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.weekdays { display: flex; flex-wrap: wrap; gap: 8px; }
.weekdays label.check { margin: 0; padding: 5px 11px; border: 1px solid var(--line); border-radius: 3px; font-size: 14px; }
.weekdays label.check:has(input:checked) { background: var(--accent-soft); border-color: transparent; color: var(--accent); font-weight: 600; }
.outlook { border-collapse: collapse; font-size: 15px; margin-top: 4px; }
.outlook td { padding: 5px 18px 5px 0; border-bottom: 1px solid var(--line); }
.outlook td.num { font-family: var(--font-mono); font-size: 14px; }
.outlook .rest-day { color: var(--muted); }
.schedule { margin-top: 24px; }
form.center { margin-top: 16px; }

.draft { margin-bottom: 16px; }
.draft label { display: block; margin: 12px 0 6px; font-size: 13px; color: var(--muted); }
.draft label.keep { display: flex; align-items: center; gap: 8px; margin-top: 0; color: var(--ink); font-size: 15px; font-weight: 600; }
.draft-actions { display: flex; justify-content: flex-end; gap: 10px; }
.suggest-form { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 14px; }
.suggest-form label { margin: 0; }
.suggest-form select { width: auto; }

.done { text-align: center; margin-top: 56px; }
.done h1 { font-size: 40px; margin-bottom: 8px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------------ fresh numbers */
.pill {
  display: inline-block; margin-left: 6px; padding: 2px 8px; border-radius: 3px;
  font: 600 10.5px var(--font-body); letter-spacing: .08em; text-transform: uppercase; vertical-align: 1px;
  background: var(--surface-2); color: var(--muted);
}
.pill-on { background: var(--brass-soft); color: color-mix(in srgb, var(--brass) 55%, var(--ink)); }
.pill-ready { background: var(--accent-soft); color: var(--accent); }
.pill-bad { background: var(--flag-bg); color: var(--forgot); }
.variant { margin-top: 16px; }
.variant-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.variant-head .card-meta { margin: 0; }
.variant-label { margin: 16px 0 4px; font: 600 11px var(--font-body); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.variant-q { margin: 0; white-space: pre-line; font-family: var(--font-display); font-size: 18px; }
.variant-example { background: var(--surface-2); border-radius: 4px; padding: 12px 14px; }
.variant-example .fb-text { margin-top: 10px; font-size: 15px; }
.variant .draft-actions { margin-top: 14px; }
.variant form { display: flex; gap: 8px; }

/* ------------------------------------------------------------------ public demo */
.demo-intro { margin: 0 0 28px; border-left: 3px solid var(--brass); }
.demo-intro p { margin: 6px 0 0; }
.demo-intro .eyebrow { margin: 0; }
.import-form { margin-top: 28px; }
.import-form .section-title { margin-bottom: 8px; }
.demo-try { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 14px; }
.site-footer {
  max-width: 760px; margin: 0 auto; padding: 0 18px 40px;
  text-align: center; font-size: 13px; color: var(--muted);
}

/* ------------------------------------------------------------------ small screens */
@media (max-width: 560px) {
  main { padding-top: 22px; }
  .card { padding: 22px 18px; }
  .question { font-size: 21px; }
  .ledger-num { font-size: 32px; }
  .brand-mark { width: 38px; height: 38px; }
  .brand-name { font-size: 23px; }
  .deck { flex-direction: column; align-items: stretch; gap: 10px; }
  .deck-side { justify-content: flex-end; }
}
