/* WalkStudy web. Tokens first; dark mode is a remap of the same names.
   Accent is "ceil", the blue of hospital scrubs: the one color that means "act here".
   Card content is set in the system serif (New York on Apple devices), because it is the material being learned;
   everything else is system UI type. */
:root {
  --bg: #f6f7f8;
  --surface: #ffffff;
  --surface-2: #eef0f2;
  --text: #1d1f21;          /* 15.8:1 on --surface */
  --text-2: #5b6167;        /* 6.2:1 on --surface */
  --line: #dcdfe3;
  --accent: #2f6690;        /* 6.1:1 on white */
  --accent-text: #ffffff;
  --accent-soft: #e3edf6;
  --good: #1d6f46;          /* 6.1:1 on white */
  --miss: #a24a17;          /* 5.6:1 on white */
  --danger: #b3261e;
  --focus: #2f6690;
  --radius: 12px;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.06), 0 4px 16px rgb(0 0 0 / 0.04);
  --ui: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, sans-serif;
  --content: ui-serif, "New York", "Iowan Old Style", Georgia, serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1113;
    --surface: #1a1d20;
    --surface-2: #24282c;
    --text: #eef0f2;        /* 14.6:1 on --surface */
    --text-2: #a4aab0;      /* 7.4:1 on --surface */
    --line: #2f3439;
    --accent: #8db8dd;      /* 8.2:1 on --surface */
    --accent-text: #0f1113;
    --accent-soft: #1f3142;
    --good: #67cf9a;
    --miss: #f0a46d;
    --danger: #ff8a80;
    --focus: #8db8dd;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1113; --surface: #1a1d20; --surface-2: #24282c; --text: #eef0f2; --text-2: #a4aab0; --line: #2f3439;
  --accent: #8db8dd; --accent-text: #0f1113; --accent-soft: #1f3142; --good: #67cf9a; --miss: #f0a46d; --danger: #ff8a80;
  --focus: #8db8dd; --shadow: none;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 17px/1.47 var(--ui);
}
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }
main:focus, main:focus-visible { outline: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  max-width: 920px; margin: 0 auto; padding: 14px 20px;
}
.brand { font-weight: 600; text-decoration: none; color: var(--text); font-size: 1.05rem; }
.topbar nav { display: flex; gap: 4px; }
.topbar nav a {
  text-decoration: none; color: var(--text-2); padding: 8px 12px; border-radius: 8px; min-height: 44px;
  display: inline-flex; align-items: center;
}
.topbar nav a[aria-current="page"] { color: var(--text); background: var(--surface-2); }

main { max-width: 920px; margin: 0 auto; padding: 8px 20px 64px; outline: none; }
h1 { font-size: 1.75rem; line-height: 1.2; margin: 12px 0 4px; font-weight: 700; }
h2 { font-size: 1.1rem; margin: 32px 0 10px; font-weight: 600; }
.sub { color: var(--text-2); margin: 0 0 20px; }
.row-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.row-head h2 { margin-bottom: 10px; }

/* Buttons: one prominent style for the main action on a screen; plain for the rest. */
button, .button {
  font: inherit; font-size: 1rem; min-height: 44px; padding: 0 18px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none;
}
button:hover, .button:hover { background: var(--surface-2); }
button.primary, .button.primary { background: var(--accent); color: var(--accent-text); border-color: transparent; font-weight: 600; }
button.primary:hover, .button.primary:hover { filter: brightness(1.08); background: var(--accent); }
button.plain { border-color: transparent; background: transparent; color: var(--accent); padding: 0 10px; }
button.plain:hover { background: var(--accent-soft); }
button.danger { color: var(--danger); }
button:disabled { opacity: 0.5; cursor: default; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
svg.icon { width: 1.1em; height: 1.1em; flex: none; }

/* Grouped lists, like an inset table view. */
.list { list-style: none; margin: 0; padding: 0; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.list > li { border-top: 1px solid var(--line); }
.list > li:first-child { border-top: 0; }
.list .item {
  display: flex; align-items: center; gap: 14px; padding: 14px 16px; min-height: 56px;
  color: inherit; text-decoration: none; width: 100%; background: none; border: 0; border-radius: 0; text-align: left; font: inherit;
}
a.item:hover, button.item:hover { background: var(--surface-2); }
.item .main { flex: 1; min-width: 0; }
.item .title { font-weight: 600; display: block; }
.item .meta { color: var(--text-2); font-size: 0.9rem; display: block; }
.item .end { color: var(--text-2); font-size: 0.9rem; display: flex; align-items: center; gap: 8px; flex: none; }
.dot { width: 12px; height: 12px; border-radius: 50%; flex: none; background: var(--c, var(--accent)); }
.empty { color: var(--text-2); padding: 20px 16px; margin: 0; }
.chev { color: var(--text-2); }

.c-blue { --c: #2f6690; } .c-green { --c: #2e8b57; } .c-orange { --c: #c66a1e; }
.c-purple { --c: #7056b8; } .c-pink { --c: #c2477a; } .c-teal { --c: #1e8a8a; }

.note { display: flex; gap: 12px; align-items: flex-start; background: var(--surface); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); margin: 16px 0; }
.note p { margin: 0; flex: 1; }
.note .icon { color: var(--accent); margin-top: 3px; }

/* Drop zone */
.drop {
  border: 2px dashed var(--line); border-radius: var(--radius); padding: 22px; text-align: center; color: var(--text-2);
  background: var(--surface); transition: border-color 0.15s, background 0.15s;
}
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop p { margin: 0 0 12px; }

progress { width: 100%; height: 6px; appearance: none; border: 0; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
progress::-webkit-progress-bar { background: var(--surface-2); }
progress::-webkit-progress-value { background: var(--accent); }
progress::-moz-progress-bar { background: var(--accent); }

.status svg.icon { vertical-align: -0.2em; margin-right: 6px; }
.status svg.spin { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(1turn); } }
.status.good { color: var(--good); }
.status.bad { color: var(--danger); }

/* Forms */
label.field { display: block; margin: 0 0 16px; }
label.field > span { display: block; font-weight: 600; margin-bottom: 6px; }
input[type="text"], input[type="password"], input[type="number"], textarea, select {
  font: inherit; width: 100%; padding: 10px 12px; min-height: 44px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
}
textarea { min-height: 88px; resize: vertical; font-family: var(--content); line-height: 1.45; }
.hint { color: var(--text-2); font-size: 0.9rem; margin: 6px 0 0; }
.error { color: var(--danger); margin: 8px 0 0; }
fieldset { border: 0; padding: 0; margin: 0 0 18px; }
legend { font-weight: 600; margin-bottom: 8px; padding: 0; }

/* Segmented control */
.segmented { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.segmented span { display: inline-flex; align-items: center; min-height: 38px; padding: 0 14px; border-radius: 8px; color: var(--text); }
.segmented input:checked + span { background: var(--surface); box-shadow: 0 1px 3px rgb(0 0 0 / 0.12); font-weight: 600; }
.segmented input:focus-visible + span { outline: 3px solid var(--focus); }

.checks label { display: flex; gap: 10px; align-items: center; padding: 10px 0; min-height: 44px; }
.checks input { width: 20px; height: 20px; accent-color: var(--accent); }

input[type="range"] { width: 100%; accent-color: var(--accent); min-height: 44px; }

dialog {
  border: 0; border-radius: 16px; padding: 0; width: min(640px, calc(100vw - 24px)); max-height: calc(100vh - 48px);
  background: var(--bg); color: var(--text); box-shadow: 0 20px 60px rgb(0 0 0 / 0.3);
}
dialog::backdrop { background: rgb(0 0 0 / 0.35); }
dialog form, .dialog-body { padding: 20px 22px; }
dialog h2 { margin-top: 0; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; flex-wrap: wrap; }

.source-page { position: relative; background: var(--surface); border-radius: 10px; padding: 12px 14px; color: var(--text-2); white-space: pre-wrap; font-size: 0.95rem; max-height: 220px; overflow: auto; }
.source-page mark { background: var(--accent-soft); color: var(--text); border-radius: 3px; }

.card-q { font-family: var(--content); }
.tag { font-size: 0.8rem; color: var(--text-2); border: 1px solid var(--line); border-radius: 6px; padding: 1px 7px; white-space: nowrap; }

/* Player: the screen glanced at mid-walk. Big text, big targets in the lower half. */
.player { display: grid; grid-template-rows: auto 1fr auto; min-height: calc(100dvh - 90px); gap: 16px; }
.player-head { display: flex; justify-content: space-between; align-items: center; color: var(--text-2); gap: 12px; }
.player-stage { display: flex; flex-direction: column; justify-content: center; gap: 18px; padding: 8px 0; }
.player-text { font-family: var(--content); font-size: clamp(1.5rem, 3.6vw, 2.1rem); line-height: 1.3; margin: 0; }
.player-answer { font-family: var(--content); font-size: clamp(1.25rem, 3vw, 1.6rem); line-height: 1.35; margin: 0; color: var(--accent); }
.player-choices { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 1.1rem; }
.player-choices li { display: flex; gap: 10px; }
.player-choices b { width: 1.4em; flex: none; }
.player-choices li.correct { color: var(--good); font-weight: 600; }
.phase { display: flex; align-items: center; gap: 12px; color: var(--text-2); }
.ring { width: 28px; height: 28px; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 4; }
.ring .track { stroke: var(--surface-2); }
.ring .fill { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset 0.1s linear; }
.grades { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grades button { min-height: 88px; font-size: 1.2rem; font-weight: 600; border-radius: 16px; flex-direction: column; gap: 4px; }
.grades .got { color: var(--good); }
.grades .miss { color: var(--miss); }
.grades small { font-weight: 400; font-size: 0.8rem; color: var(--text-2); }
.controls { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 12px; }
.controls button { min-height: 56px; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 16px 0 24px; }
.stats div { background: var(--surface); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stats dt { color: var(--text-2); font-size: 0.9rem; }
.stats dd { margin: 2px 0 0; font-size: 1.4rem; font-weight: 600; }

.signin { max-width: 400px; margin: 12vh auto 0; }
.signin h1 { margin-bottom: 8px; }
.signin .actions { margin-top: 20px; }
.signin .error:not([hidden]) { margin-top: 16px; }
.button.google { font-weight: 600; }
.button.google svg.g { width: 1.15em; height: 1.15em; flex: none; }

#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--text); color: var(--bg);
  padding: 10px 16px; border-radius: 10px; opacity: 0; pointer-events: none; transition: opacity 0.2s; max-width: calc(100vw - 32px);
}
#toast.show { opacity: 1; }

kbd { font: 0.85em var(--ui); border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px; background: var(--surface); }

@media (max-width: 560px) {
  main { padding: 4px 16px 48px; }
  .topbar { padding: 10px 16px; }
  h1 { font-size: 1.5rem; }
  .stats { grid-template-columns: 1fr; }
  .item .end .hide-narrow { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
  .status svg.spin { animation: none; }
}
.segmented span.dot { padding: 0; min-height: 0; width: 18px; height: 18px; display: block; }
.segmented label:has(.dot) > span { padding: 0 12px; }
/* "‹ Courses" style back links */
main > p > a:only-child { text-decoration: none; display: inline-flex; align-items: center; gap: 2px; min-height: 44px; }
.row-head { align-items: baseline; }
@media (hover: none) { .keys { display: none; } }
