/* Light is the default. Dark is defined twice on purpose: once for an explicit
   choice, once for "System" so the OS setting still wins when nothing is chosen. */
:root {
  --ink: #23201c;
  --paper: #fbf7f0;
  --card: #fffdfa;
  --line: #e4dbcc;
  --accent: #2f6f4e;
  --accent-hover: #26593e;
  --accent-soft: #e6f0e9;
  --right-line: #bfd9ca;
  --warm: #b4551f;
  --warm-soft: #fbeade;
  --wrong-line: #edcdb6;
  --muted: #7a7166;
  --mark-bg: #ffe9a8;
  --mark-line: #e0ab2e;
  --picked: #fff6d8;
  --glass: rgba(255, 255, 255, 0.7);
  --veil: rgba(251, 247, 240, 0.92);
  --radius: 14px;

  /* Reading size. Everything meant to be read scales off this one number. */
  --reading: 20px;

  /* Spacing, in two numbers, so padding cannot quietly stack up. `--gutter` is the
     page edge and `--pad` is inside a card; both shrink on a phone, where three
     nested paddings used to leave almost no room for the text itself. */
  --gutter: 24px;
  --pad: 22px;

  /* Makes the browser draw selects, scrollbars and caret in the right theme.
     Without it a dark page gets a white dropdown and a black caret. */
  color-scheme: light;
}

:root[data-size="small"]  { --reading: 17px; }
:root[data-size="normal"] { --reading: 20px; }
:root[data-size="large"]  { --reading: 24px; }
:root[data-size="huge"]   { --reading: 29px; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #e9e4db;
    --paper: #171614;
    --card: #211f1c;
    --line: #3a352e;
    --accent: #79c79a;
    --accent-hover: #8fd6ac;
    --accent-soft: #23322a;
    --right-line: #33543f;
    --warm: #e39a63;
    --warm-soft: #33251b;
    --wrong-line: #5c3f2a;
    --muted: #9c9487;
    --mark-bg: #5a4718;
    --mark-line: #c79a2e;
    --picked: #4a3d18;
    --glass: rgba(0, 0, 0, 0.25);
    --veil: rgba(23, 22, 20, 0.93);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --ink: #e9e4db;
  --paper: #171614;
  --card: #211f1c;
  --line: #3a352e;
  --accent: #79c79a;
  --accent-hover: #8fd6ac;
  --accent-soft: #23322a;
  --right-line: #33543f;
  --warm: #e39a63;
  --warm-soft: #33251b;
  --wrong-line: #5c3f2a;
  --muted: #9c9487;
  --mark-bg: #5a4718;
  --mark-line: #c79a2e;
  --picked: #4a3d18;
  --glass: rgba(0, 0, 0, 0.25);
  --veil: rgba(23, 22, 20, 0.93);
  color-scheme: dark;
}

* { box-sizing: border-box; }

/* The browser hides [hidden] from its own stylesheet, and any author rule setting
   `display` outranks it - so `.cover { display: flex }` made the loading overlay
   permanently visible and the page looked hung. Anything hidden stays hidden. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.6 "Segoe UI", system-ui, -apple-system, sans-serif;
}

header {
  display: flex;
  align-items: baseline;
  gap: 16px;
  padding: 14px var(--gutter);
  border-bottom: 1px solid var(--line);
  background: var(--card);
}

h1 {
  margin: 0;
  font-size: 20px;
  letter-spacing: 0.02em;
  color: var(--accent);
}

.crumb { color: var(--muted); font-size: 14px; }

.who { margin-left: auto; display: flex; align-items: baseline; gap: 10px; }
.who-name { font-weight: 600; color: var(--ink); }

.who-swap {
  font: inherit;
  font-size: 13px;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
}

.who-swap:hover { color: var(--accent); }
.who-card h3 { font-size: 22px; }

.activity-card .standing {
  margin-top: 10px;
  font-size: 14px;
  color: var(--muted);
}

.activity-card .standing.resumable {
  color: var(--accent);
  font-weight: 600;
}

.activity-card[disabled] {
  opacity: 0.55;
  cursor: default;
  transform: none;
}

.activity-card[disabled]:hover {
  border-color: var(--line);
  transform: none;
}

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 28px var(--gutter) 96px;
}

.loading { color: var(--muted); }

/* ---------- choosing ---------- */

.lead { font-size: 18px; margin: 0 0 24px; }

.offer {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--pad);
  margin-bottom: 14px;
  cursor: pointer;
  font: inherit;
  color: inherit;
  transition: border-color 0.15s, transform 0.15s;
}

.offer:hover { border-color: var(--accent); transform: translateY(-1px); }
.offer h3 { margin: 0 0 6px; font-size: 19px; }
.offer p { margin: 0; color: var(--muted); }

/* ---------- reading ---------- */

.story-title { font-size: 26px; margin: 0 0 4px; }
.page-of { color: var(--muted); font-size: 14px; margin-bottom: 24px; }

.page {
  font-size: var(--reading);
  line-height: 1.85;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--pad);
}

.page p { margin: 0 0 1.1em; }
.page p:last-child { margin-bottom: 0; }

.w {
  cursor: pointer;
  border-radius: 4px;
  padding: 0 1px;
  transition: background 0.12s;
}

.w:hover { background: var(--accent-soft); }
.w.asked { background: var(--warm-soft); box-shadow: inset 0 -2px 0 var(--warm); }

/* A word the exam is asking about. Still readable, just not a free answer. */
.w.blocked { cursor: help; }
.w.blocked:hover { background: var(--mark-bg); }

/* ---------- exam beside the story ---------- */

main.wide { max-width: 1180px; }

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 30px;
  align-items: start;
}

.story-pane {
  position: sticky;
  top: 20px;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  padding-right: 4px;
}

.story-pane h3 {
  margin: 0 0 12px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.story-pane .page { font-size: calc(var(--reading) - 3px); line-height: 1.8; }
.story-pane .hint { margin-top: 12px; }

@media (max-width: 920px) {
  .split { grid-template-columns: 1fr; }
  .story-pane { position: static; max-height: 44vh; }
}

.s.picked { background: var(--picked); border-radius: 6px; }

.hint {
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 14px;
}

/* ---------- buttons ---------- */

.row { display: flex; gap: 12px; align-items: center; margin-top: 28px; flex-wrap: wrap; }

button.primary,
button.ghost {
  font: inherit;
  border-radius: 999px;
  padding: 11px 22px;
  cursor: pointer;
  border: 1px solid transparent;
}

button.primary { background: var(--accent); color: #fff; }
button.primary:hover { background: var(--accent-hover); }
button.ghost { background: transparent; border-color: var(--line); color: var(--ink); }
button.ghost:hover { border-color: var(--accent); }
button:disabled { opacity: 0.5; cursor: default; }

/* ---------- popup ---------- */

.popup {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: 12px;
  margin: 0 auto;
  max-width: 560px;
  max-height: min(70vh, 520px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.28);
  padding: var(--pad);
  padding-right: calc(var(--pad) + 26px);   /* room for the close button */
  z-index: 40;
}

#popup-body {
  overflow-y: auto;
  overscroll-behavior: contain;
}

.popup-close {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 44px;
  height: 44px;
  background: none;
  border: none;
  font-size: 26px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  z-index: 1;
}

.popup-close:hover { color: var(--ink); }

.popup h4 { margin: 0 0 6px; font-size: 20px; color: var(--accent); }
.popup .meaning { font-size: 17px; margin: 0 0 8px; }
.popup .note { margin: 0; color: var(--muted); font-size: 14px; }
.popup .again {
  margin: 0 0 10px;
  padding: 8px 12px;
  background: var(--warm-soft);
  border-left: 3px solid var(--warm);
  border-radius: 6px;
  font-size: 14px;
  color: var(--warm);
}
.popup .wordlist { margin: 10px 0 0; padding: 0; list-style: none; font-size: 14px; color: var(--muted); }
.popup .wordlist li { display: inline-block; margin-right: 14px; }

/* ---------- exam ---------- */

.q {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--pad);
  margin-bottom: 14px;
}

.q label { display: block; font-size: 17px; margin-bottom: 10px; }
.q .tag {
  display: inline-block;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 6px;
}

/* Every typed-into thing, in one place. An input that sets a background but not a
   colour inherits the browser's black, which is invisible on a dark card - that was
   a real bug and this rule is why it cannot come back. */
input[type="text"],
textarea,
select {
  font: inherit;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
}

input[type="text"],
textarea {
  width: 100%;
  padding: 11px 13px;
  min-height: 44px;   /* a finger, not a mouse */
}

input[type="text"]:focus,
textarea:focus,
select:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}

input::placeholder,
textarea::placeholder { color: var(--muted); opacity: 1; }

.result { border-radius: var(--radius); padding: var(--pad); margin-bottom: 14px; }
.result.right { background: var(--accent-soft); border: 1px solid var(--right-line); }
.result.wrong { background: var(--warm-soft); border: 1px solid var(--wrong-line); }
.result .head { font-weight: 600; margin-bottom: 4px; }
.result .evidence {
  margin: 8px 0 0;
  padding: 8px 12px;
  background: var(--glass);
  border-radius: 8px;
  font-style: italic;
}

.sentence-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--pad);
  margin-bottom: 14px;
}
.sentence-card .af { font-size: var(--reading); margin: 0 0 16px; line-height: 1.7; }

.sentence-card mark {
  background: var(--mark-bg);
  color: inherit;
  padding: 1px 4px;
  border-radius: 4px;
  box-shadow: inset 0 -2px 0 var(--mark-line);
  font-weight: 600;
}

.ask { display: block; margin-top: 12px; }
.ask span { display: block; margin-bottom: 6px; font-size: 16px; color: var(--muted); }
.ask b { color: var(--ink); font-size: 17px; }


/* ---------- bringing in your own page ---------- */

.import-head { margin: 0 0 6px; font-size: 19px; }

.filebtn { display: inline-block; margin-top: 14px; cursor: pointer; }

.filebtn .primary-ish {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  padding: 11px 22px;
  font-size: 16px;
}

.filebtn:hover .primary-ish { background: var(--accent-hover); }

textarea { font-size: 16px; line-height: 1.6; resize: vertical; }

#draft-box { font-size: calc(var(--reading) - 3px); line-height: 1.75; }

/* ---------- waiting ----------
   A full cover, not a corner dot. While Claude is thinking she must not be able to
   click anything, and she must be able to see why nothing is happening. */

.cover {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--veil);
  backdrop-filter: blur(3px);
  animation: fade-in 0.18s ease-out;
}

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.cover-inner {
  text-align: center;
  max-width: 440px;
  padding: 0 24px;
}

.spinner {
  width: 46px;
  height: 46px;
  margin: 0 auto 22px;
  border: 4px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.cover-title {
  margin: 0 0 8px;
  font-size: 22px;
  color: var(--ink);
}

.cover-sub {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  min-height: 1.4em;
}

.bar {
  margin: 22px auto 0;
  width: 260px;
  height: 8px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.4s linear;
}

/* The popup does its own waiting, so a tap does not black out the whole page. */
.popup .looking {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
}

.popup .looking::before {
  content: "";
  width: 16px;
  height: 16px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

body.waiting-word .w { cursor: default; }
body.waiting-word .w:hover { background: none; }

.error {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  background: var(--warm-soft);
  border: 1px solid var(--wrong-line);
  border-radius: var(--radius);
  padding: var(--pad);
  margin-bottom: 22px;
}

.error-face { font-size: 30px; line-height: 1; }
.error-body { flex: 1; }
.error-message { margin: 0 0 4px; font-size: 18px; color: var(--ink); }
.error-hint { margin: 0; color: var(--muted); font-size: 15px; }
.error .row { margin-top: 16px; }

/* ---------- header tools ---------- */

.tools {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.who { margin-left: 0; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.size, .mode {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

.size select, .mode select {
  font-size: 14px;
  padding: 6px 8px;
  min-height: 36px;
}

.danger {
  font: inherit;
  font-size: 13px;
  background: none;
  border: none;
  color: var(--warm);
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
}

.danger:hover { color: var(--ink); }

/* ---------- small screens ----------
   The layout problem here was additive: page gutter, then card padding, then more
   padding inside that, all sized for a desktop. On a 360px phone it left a column
   of text barely wide enough to read. Both spacing tokens shrink together. */

@media (max-width: 720px) {
  :root { --gutter: 12px; --pad: 15px; }

  header {
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 14px;
    position: sticky;
    top: 0;
    z-index: 30;
  }

  h1 { font-size: 18px; }

  /* The breadcrumb is the first thing to go - it repeats what is on screen. */
  .crumb { display: none; }

  .tools { width: 100%; margin-left: 0; justify-content: space-between; gap: 10px; }
  .size span, .mode span { display: none; }   /* the control explains itself */

  main { padding-bottom: 72px; }
  .page { line-height: 1.7; }
  .story-title { font-size: 21px; }
  .lead { font-size: 17px; }

  /* Full-width buttons: a 44px pill in the middle of a row is a missed tap. */
  .row { gap: 10px; }
  .row button.primary,
  .row button.ghost,
  .filebtn,
  .filebtn .primary-ish { width: 100%; text-align: center; }

  button.primary, button.ghost { padding: 13px 20px; }

  .popup { left: 8px; right: 8px; bottom: 8px; max-height: 80vh; }
  .popup h4 { font-size: 18px; }
  .popup .meaning { font-size: 16px; }
}

/* Very narrow, or a phone held in a case: stop the header eating the screen. */
@media (max-width: 380px) {
  :root { --gutter: 10px; --pad: 13px; }
  .tools { gap: 8px; }
}

.confirm { display: inline-flex; align-items: baseline; gap: 6px; font-size: 13px; color: var(--muted); }

/* ---------- the first screen (the demo's own: what this is, and who is reading) ---------- */

.setup .lead { font-size: 22px; line-height: 1.4; }
.steps { margin: 0 0 28px; padding-left: 1.3em; }
.steps li { margin-bottom: 10px; }
.steps b { color: var(--ink); }
.choose {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--pad);
}
.choose .ask { margin-top: 0; }
.choose select { width: 100%; padding: 10px 12px; min-height: 44px; }
#check:not(:empty) { margin-top: 20px; }
.setup .hint { margin-top: 18px; }
@media (max-width: 640px) { .choose { grid-template-columns: 1fr; } }

.kept { margin: 8px 0 0; padding-left: 1.2em; }
.kept li { margin-bottom: 4px; }

/* ---------- the demo's header and first screen: no stray wrapping (owner, 2026-10-23) ---------- */

header { flex-wrap: wrap; row-gap: 8px; }
h1 { white-space: nowrap; }
/* the story's name and page on one line, cut short rather than wrapped */
.crumb { flex: 1 1 160px; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who-name { white-space: nowrap; }
/* the three choices line up along their boxes, however their labels fall */
.choose { align-items: end; }
.choose .ask span { white-space: nowrap; }
@media (max-width: 720px) {
  /* the two settings together, labelled, with the reader's line under them (the demo has no learner between them) */
  .tools { justify-content: flex-start; }
  .size span, .mode span { display: inline; }
  .who { width: 100%; }
}
