:root {
  --paper: oklch(0.985 0.006 85);
  --paper-sunk: oklch(0.965 0.008 82);
  --ink: oklch(0.24 0.012 70);
  --ink-soft: oklch(0.44 0.012 70);
  --ink-faint: oklch(0.60 0.010 70);
  --line: oklch(0.90 0.010 78);
  --accent: oklch(0.46 0.10 264);
  --accent-soft: oklch(0.94 0.03 264);
  --match: oklch(0.52 0.10 150);
  --miss: oklch(0.55 0.12 40);
  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --sans: "Inter", system-ui, -apple-system, sans-serif;
  --col: 40rem;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

* { 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: 1.0625rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.wrap { max-width: var(--col); margin: 0 auto; padding: 0 1.5rem; }

/* ---- Masthead ---- */
.masthead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 2.25rem 0 1.5rem;
  border-bottom: 1px solid var(--line);
}
.wordmark {
  font-family: var(--serif);
  font-size: 1.2rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  margin: 0;
}
.wordmark .os { color: var(--ink-faint); font-style: italic; }
.who { font-size: 0.8rem; color: var(--ink-faint); display: flex; align-items: center; gap: 0.6rem; }
.linkbtn {
  font: inherit; font-size: 0.8rem; background: none; border: 0; color: var(--ink-soft);
  cursor: pointer; padding: 0; border-bottom: 1px solid var(--line);
}
.linkbtn:hover { color: var(--ink); }

/* ---- Score ---- */
.score {
  display: flex; align-items: flex-end; gap: 0.9rem;
  padding: 1.5rem 0 1.75rem;
}
.score-label {
  font-size: 0.7rem; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--ink-faint); margin: 0 0 0.15rem;
}
.score-num { font-family: var(--serif); font-size: 3rem; line-height: 0.9; font-weight: 400; font-variant-numeric: tabular-nums; }
.score-side { flex: 1; padding-bottom: 0.45rem; }
.score-meter { position: relative; height: 2px; background: var(--line); border-radius: 2px; }
.score-fill { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--accent); border-radius: 2px; transition: width 600ms var(--ease); }
.score-tick { position: absolute; top: -3px; bottom: -3px; left: 80%; width: 1px; background: var(--ink-faint); opacity: 0.5; }
.score-caption { font-size: 0.72rem; color: var(--ink-faint); margin-top: 0.5rem; }
.progress { font-size: 0.72rem; color: var(--ink-faint); }

/* ---- Reading view ---- */
.view { padding: 0.5rem 0 4rem; }
.enter { animation: enter 420ms var(--ease) both; }
@keyframes enter { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.intro {
  font-family: var(--serif); font-size: 1.15rem; line-height: 1.7;
  background: var(--paper-sunk); border: 1px solid var(--line); border-radius: 12px;
  padding: 1.4rem 1.6rem; color: var(--ink);
}
.intro p { margin: 0 0 0.9rem; }
.intro p:first-child { font-size: 1.3rem; }
.intro p:last-child { margin-bottom: 0; }
.question { font-family: var(--serif); font-size: 1.75rem; line-height: 1.3; font-weight: 400; margin: 0.5rem 0 1.4rem; }

/* options */
.opts { display: flex; flex-direction: column; gap: 0.5rem; }
.opt {
  display: flex; align-items: center; gap: 0.75rem; width: 100%; text-align: left;
  font: inherit; color: var(--ink); background: transparent;
  border: 1px solid var(--line); border-radius: 10px; padding: 0.8rem 1rem; cursor: pointer;
  transition: background 160ms var(--ease), border-color 160ms var(--ease);
}
.opt:hover { background: var(--paper-sunk); border-color: var(--ink-faint); }
.opt:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.opt .key { font-family: var(--serif); color: var(--ink-faint); min-width: 1.1rem; }
.opt[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); }

/* yes/no */
.binary { display: flex; gap: 0.6rem; }
.binary .opt { justify-content: center; }

/* scale 1-10 */
.scale { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.dot {
  font: inherit; font-variant-numeric: tabular-nums; width: 2.6rem; height: 2.6rem;
  border: 1px solid var(--line); border-radius: 8px; background: transparent; color: var(--ink-soft);
  cursor: pointer; transition: background 140ms var(--ease), color 140ms var(--ease), border-color 140ms var(--ease);
}
.dot:hover { border-color: var(--ink-faint); color: var(--ink); }
.dot:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* elaboration */
.field { margin-top: 1.1rem; }
.field textarea {
  width: 100%; font-family: var(--sans); font-size: 1rem; line-height: 1.55; color: var(--ink);
  background: transparent; border: 0; border-bottom: 1px solid var(--line);
  padding: 0.5rem 0.1rem; resize: vertical; min-height: 2.6rem;
}
.field textarea::placeholder { color: var(--ink-faint); }
.field textarea:focus { outline: none; border-bottom-color: var(--accent); }

/* open-question answer field is larger */
.field.open textarea { min-height: 6rem; border: 1px solid var(--line); border-radius: 10px; padding: 0.75rem 0.9rem; }

/* primary action */
.act { margin-top: 1.3rem; display: flex; gap: 0.8rem; align-items: center; }
.btn {
  font: inherit; font-size: 0.95rem; background: var(--accent); color: var(--paper);
  border: 0; border-radius: 10px; padding: 0.65rem 1.3rem; cursor: pointer;
  transition: filter 160ms var(--ease);
}
.btn:hover { filter: brightness(1.08); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn[disabled] { opacity: 0.5; cursor: default; }

/* narration notes */
.note {
  border: 1px solid var(--line); border-radius: 12px; padding: 1rem 1.2rem; margin: 0 0 1.4rem;
  background: var(--paper-sunk);
}
.note.summary { background: var(--accent-soft); border-color: color-mix(in oklch, var(--accent) 22%, var(--line)); }
.note.refocus { background: var(--paper-sunk); }
.note-label {
  font-size: 0.68rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-faint);
  margin: 0 0 0.5rem;
}
.note-body { font-family: var(--serif); font-size: 1.05rem; line-height: 1.6; }
.note-body :is(h1,h2,h3,strong) { font-weight: 500; }

/* feedback line */
.feedback { min-height: 1.4em; margin-top: 1rem; font-size: 0.82rem; color: var(--ink-faint); }
.feedback .m { color: var(--match); }
.feedback .x { color: var(--miss); }

.done h2 { font-family: var(--serif); font-weight: 400; font-size: 1.5rem; }
.muted { color: var(--ink-faint); }

/* ---- Auth ---- */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: 2rem 1.5rem; }
.auth-card { width: 100%; max-width: 22rem; }
.auth h1 { font-family: var(--serif); font-weight: 500; font-size: 1.6rem; margin: 0 0 0.2rem; }
.auth h1 .os { color: var(--ink-faint); font-style: italic; }
.auth .sub { color: var(--ink-soft); margin: 0 0 1.6rem; font-size: 0.95rem; }
.auth label { display: block; font-size: 0.78rem; letter-spacing: 0.02em; color: var(--ink-soft); margin: 0.9rem 0 0.3rem; }
.auth input {
  width: 100%; font: inherit; font-size: 1rem; color: var(--ink); background: var(--paper);
  border: 1px solid var(--line); border-radius: 10px; padding: 0.6rem 0.75rem;
}
.auth input:focus { outline: none; border-color: var(--accent); }
.auth .btn { width: 100%; justify-content: center; margin-top: 1.3rem; text-align: center; }
.auth .toggle { margin-top: 1.1rem; }
.auth .err { color: var(--miss); font-size: 0.85rem; min-height: 1.2em; margin: 0.8rem 0 0; }

@media (prefers-reduced-motion: reduce) {
  .enter { animation: none; }
  .score-fill { transition: none; }
}
