:root {
  --bg: #f6f7fb;
  --card: #ffffff;
  --text: #1d2433;
  --muted: #5d6679;
  --line: #dfe3ec;
  --accent: #3b5bdb;
  --accent-text: #ffffff;
  --good: #1f7a4d;
  --good-bg: #e6f6ee;
  --bad: #b42318;
  --bad-bg: #fdecea;
  --mid: #8a5a00;
  --mid-bg: #fff4dc;
  --hint: #c2410c;
  --radius: 12px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12151c;
    --card: #1b2029;
    --text: #e8ebf2;
    --muted: #a0a8b8;
    --line: #2e3542;
    --accent: #7b93ff;
    --accent-text: #0d1020;
    --good: #6fd3a0;
    --good-bg: #173226;
    --bad: #ff8a80;
    --bad-bg: #3a1c1a;
    --mid: #f3c063;
    --mid-bg: #3a2e14;
    --hint: #fb923c;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #12151c;
  --card: #1b2029;
  --text: #e8ebf2;
  --muted: #a0a8b8;
  --line: #2e3542;
  --accent: #7b93ff;
  --accent-text: #0d1020;
  --good: #6fd3a0;
  --good-bg: #173226;
  --bad: #ff8a80;
  --bad-bg: #3a1c1a;
  --mid: #f3c063;
  --mid-bg: #3a2e14;
  --hint: #fb923c;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 720px;
  margin: 0 auto;
  padding: 16px;
}

.topbar h1 { font-size: 1.3rem; margin: 0; }

/* No grey flash when tapping buttons on phones. */
button { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }

.plan-badge {
  font-size: 0.8rem;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 10px;
}

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 16px 96px;
}

h2 { font-size: 1.15rem; margin: 0 0 8px; }
h3 { font-size: 1rem; margin: 16px 0 4px; }
p { margin: 8px 0; }

.stack > * + * { margin-top: 16px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}

.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.row.spread { justify-content: space-between; }

fieldset { border: 0; margin: 8px 0; padding: 0; min-width: 0; }

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.label { color: var(--muted); }
.warn-text { color: var(--bad); }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

button {
  font: inherit;
  min-height: 44px;
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  cursor: pointer;
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
}

button.link {
  border: 0;
  background: none;
  color: var(--accent);
  padding: 4px 8px;
  min-height: 36px;
}

button.link.danger { color: var(--bad); }
button.wide { width: 100%; margin-top: 12px; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button:focus-visible, input:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.field { margin: 10px 0; }
.field label { display: block; font-weight: 600; margin-bottom: 4px; }

input[type="text"], textarea {
  width: 100%;
  font: inherit;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
}

textarea { resize: vertical; }

.choice { display: inline-flex; align-items: center; gap: 4px; margin-right: 12px; }
.choice input { width: 20px; height: 20px; }

details > summary { cursor: pointer; font-weight: 600; font-size: 1.05rem; }
details form > * { margin-top: 8px; }

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
  margin: 8px 0;
}

.tile {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
}

.tile-value { font-size: 1.3rem; font-weight: 700; }
.tile-label { font-size: 0.85rem; color: var(--muted); }

.word-list { list-style: none; margin: 0; padding: 0; }

.word-row {
  border-top: 1px solid var(--line);
  padding: 10px 0;
}

.word-row:first-child { border-top: 0; }
.word-main { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.actions { margin-top: 2px; gap: 0; }
.actions button:first-child { padding-left: 0; }

.badge {
  font-size: 0.75rem;
  border-radius: 999px;
  padding: 1px 8px;
}

.badge.good { color: var(--good); background: var(--good-bg); }
.badge.bad { color: var(--bad); background: var(--bad-bg); }
.badge.mid { color: var(--mid); background: var(--mid-bg); }
.badge.new { color: var(--muted); border: 1px solid var(--line); }

.progress {
  height: 8px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
  margin: 8px 0 16px;
}

.progress-bar { height: 100%; background: var(--accent); transition: width 0.3s; }

.hear {
  display: block;
  width: 100%;
  font-size: 1.25rem;
  font-weight: 600;
  padding: 18px;
  background: var(--bg);
}

.meaning-word {
  display: block;
  width: 100%;
  margin-top: 12px;
  padding: 28px 12px;
  font-size: 2.2rem;
  font-weight: 700;
  background: var(--bg);
  overflow-wrap: anywhere;
}
p.meaning-word { text-align: center; border-radius: 8px; margin-bottom: 8px; }

.word-of-day { text-align: center; border: 1px solid var(--line); border-radius: 8px; }

.meaning { margin-top: 12px; }
.meaning-text { font-size: 1.15rem; line-height: 1.5; }
.meaning-buttons button { flex: 1 1 160px; font-weight: 600; }

button.keep {
  background: var(--good);
  border-color: var(--good);
  color: var(--bg);
}

.hints {
  margin-top: 12px;
  padding: 8px 12px;
  border-left: 3px solid var(--line);
}

/* Word details after an answer: each one starts closed. */
.word-details { margin-top: 12px; display: grid; gap: 8px; }
.word-detail { border: 1px solid var(--line); border-radius: 8px; background: var(--card); }
.word-detail summary {
  cursor: pointer;
  min-height: 44px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  font-weight: 600;
  color: var(--accent);
  list-style: none;
}
.word-detail summary::-webkit-details-marker { display: none; }
.word-detail summary::before { content: '\25B8'; width: 1em; margin-right: 4px; }
.word-detail[open] summary::before { content: '\25BE'; }
.word-detail-body { padding: 0 12px 8px; }
.word-detail-body p { margin: 0 0 4px; }
.word-detail-body .sentence-button { margin: 0 0 4px; }

/* Voice page */
.voice-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 12px 0; }
.voice-row select { flex: 1 1 220px; min-width: 0; max-width: 100%; min-height: 44px; font: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--text); }
.voice-help { margin: 8px 0 16px; }
.voice-help summary { cursor: pointer; color: var(--accent); min-height: 36px; }
.voice-help li { margin-bottom: 6px; }
.adult-bar > span { display: inline-flex; margin-right: -8px; }
.adult-bar { flex-wrap: wrap; gap: 0 8px; }
.adult-bar strong, .adult-bar .link { white-space: nowrap; }

/* Progress and End test sit at the bottom of the test. */
.test-footer { margin-top: 24px; padding-top: 12px; border-top: 1px solid var(--line); }
.test-footer .progress { margin: 0 0 8px; }
.end-test { display: inline-flex; gap: 8px; }
.end-test.confirming { display: flex; width: 100%; }
.end-test.confirming #end-test-confirm { flex: 1; }
button.danger:not(.link) { background: var(--bad); border-color: var(--bad); color: var(--bg); font-weight: 600; }

.sentence-button {
  display: block;
  width: 100%;
  margin: 8px 0;
  padding: 6px 8px;
  min-height: 0;
  border: 0;
  background: none;
  text-align: left;
  line-height: 1.5;
}

.sentence-button:hover { background: var(--bg); }
.sentence-hint { white-space: nowrap; }

.answer-form { display: flex; gap: 8px; margin-top: 16px; }

.answer-input {
  font-size: 1.4rem !important;
  letter-spacing: 0.03em;
}

/* Spelling with Hints: the typed text is drawn on top of the box so the
   wrong part can be orange. The box's own text is hidden; its cursor stays. */
.hint-field { flex: 1 1 auto; min-width: 0; }
.hint-box { position: relative; }
.hint-box .answer-input { width: 100%; box-sizing: border-box; }
.hinted-input { color: transparent !important; caret-color: var(--text); }
.answer-mirror {
  position: absolute; inset: 0; pointer-events: none;
  white-space: pre; overflow: hidden; color: var(--text);
  border-style: solid; border-color: transparent; box-sizing: border-box;
}
.hint-wrong { color: var(--hint); text-decoration: underline wavy var(--hint); text-underline-offset: 4px; }
.hint-gap { position: relative; display: inline-block; width: 0; height: 1em; vertical-align: baseline; }
.hint-gap::after {
  content: ''; position: absolute; left: -5px; bottom: -0.45em; width: 0; height: 0;
  border-left: 5px solid transparent; border-right: 5px solid transparent; border-bottom: 7px solid var(--hint);
}
.hint-note { color: var(--hint); margin: 4px 0 0; min-height: 1.2em; }
.feedback.helped { background: var(--mid-bg); }
.feedback.helped .verdict { color: var(--mid); }

/* The app's own keyboard on phones and tablets. */
.keyboard { margin-top: 12px; display: grid; gap: 6px; user-select: none; -webkit-user-select: none; }
.key-row { display: flex; gap: 4px; justify-content: center; }
.key {
  flex: 1 1 0;
  min-width: 0;
  max-width: 48px;
  min-height: 48px;
  padding: 0;
  font-size: 1.25rem;
  border-radius: 6px;
  background: var(--card);
  box-shadow: 0 1px 0 var(--line);
}
.key:active { background: var(--line); }
.key.wide-key { flex: 1.5 1 0; max-width: 72px; }
.key.wide-key.on { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.key.space-key { flex: 4 1 0; max-width: none; font-size: 1rem; }
.key.check-key { flex: 2.5 1 0; max-width: none; font-size: 1.05rem; }

.feedback {
  margin-top: 16px;
  padding: 12px 16px;
  border-radius: 8px;
}

.feedback.good { background: var(--good-bg); }
.feedback.bad { background: var(--bad-bg); }
.feedback.good .verdict { color: var(--good); }
.feedback.bad .verdict { color: var(--bad); }
.verdict { font-weight: 700; font-size: 1.2rem; margin-top: 0; }
.spelling { font-size: 1.3rem; letter-spacing: 0.03em; }

.big-score { font-size: 3rem; font-weight: 800; margin: 0; color: var(--accent); }
.missed { padding-left: 20px; }

.notice {
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  width: min(680px, calc(100% - 32px));
  padding: 12px 16px;
  border-radius: 8px;
  background: var(--text);
  color: var(--bg);
  display: none;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.notice.show { display: block; cursor: pointer; }
.notice.warn, .notice.error { background: var(--bad); color: var(--bg); }

.table-wrap {
  position: relative;
  overflow-x: auto;
  margin: 12px -16px;
  padding: 0 16px;
}

.grid { border-collapse: collapse; width: 100%; min-width: 760px; }
.grid th { text-align: left; font-size: 0.85rem; color: var(--muted); padding: 4px; }
.grid td { padding: 3px; vertical-align: top; border-top: 1px solid var(--line); }
.grid td.num { color: var(--muted); font-size: 0.85rem; padding-top: 12px; width: 2em; }
.grid .ai-mark { display: block; margin-top: 4px; font-size: 0.7rem; font-weight: 600; color: var(--mid); }
.grid .cell { padding: 8px; font-size: 0.95rem; min-width: 160px; }
.grid .word-cell { font-weight: 600; min-width: 130px; }
.grid tr.has-error .cell { border-color: var(--bad); }
.grid tr.row-error td { border-top: 0; color: var(--bad); font-size: 0.85rem; padding-top: 0; }
.choice.block { display: flex; margin: 8px 0 0; }
.auth-form .choice.block { align-items: flex-start; gap: 8px; }
.auth-form .choice.block input { flex: none; margin-top: 2px; }

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 10;
}

.dialog {
  background: var(--card);
  color: var(--text);
  border-radius: var(--radius);
  padding: 20px;
  width: min(440px, 100%);
  display: grid;
  gap: 12px;
}

.dialog p { margin: 0; }
button.primary.danger { background: var(--bad); border-color: var(--bad); color: var(--bg); }

.topbar { gap: 8px; flex-wrap: wrap; }
.topbar-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.account-area { display: flex; align-items: center; gap: 4px; }
.save-status { font-size: 0.8rem; color: var(--muted); }
.save-status.error { color: var(--bad); }
.account-email { font-size: 0.8rem; color: var(--muted); max-width: 18ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-left: 6px; }
@media (max-width: 480px) { .account-email { max-width: 12ch; } }

.learner-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.auth-form { max-width: 480px; }
.auth-form input[type="email"], .auth-form input[type="password"], .dialog input {
  width: 100%;
  font: inherit;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
}

.tags { list-style: none; margin: 4px 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px; }
.tag {
  font-size: 0.8rem;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 999px;
  padding: 0 10px;
}

button.star {
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 1.3rem;
  line-height: 1;
  min-height: 36px;
  min-width: 36px;
  padding: 0;
}
button.star.on { color: var(--mid); }
.test-scope { margin: 0 0 4px; }

/* Installed on a phone, the app runs full screen: keep clear of the notch,
   rounded corners and home bar. */
.topbar { padding-top: max(16px, env(safe-area-inset-top)); }
.topbar, main {
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
}
main { padding-bottom: max(96px, calc(env(safe-area-inset-bottom) + 80px)); }
.notice { bottom: max(16px, env(safe-area-inset-bottom)); }

.install-banner {
  width: min(688px, calc(100% - 32px));
  margin: 0 auto 16px;
}
.install-banner p { margin-top: 0; }
.install-banner[hidden] { display: none; }

/* Home and learner pages: big buttons stacked top to bottom. */
.home h2 { font-size: 1.4rem; margin-bottom: 12px; }
.home-buttons { display: flex; flex-direction: column; gap: 12px; margin: 16px 0; }
/* 25% more space before a new group of buttons (12px gap + 3px). */
.home-buttons .gap-before { margin-top: 3px; }
.home-button {
  width: 100%;
  min-height: 64px;
  font-size: 1.25rem;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}
.home-button.main-account {
  margin-top: 12px;
  font-size: 1.05rem;
  min-height: 52px;
  border-style: dashed;
}
.home-note { font-size: 0.8rem; font-weight: 400; opacity: 0.85; }

.adult-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
}

.learner-words .word-row { padding: 8px 0; }

/* Orthoglot Coach settings and learners' lists */
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 12px 0; cursor: pointer; }
.switch-row .block { display: block; margin-top: 4px; }
input.switch {
  appearance: none; -webkit-appearance: none; flex: none; position: relative; cursor: pointer;
  width: 52px; height: 30px; margin: 0; border-radius: 15px; border: 1px solid var(--line); background: var(--line);
  transition: background 0.15s;
}
input.switch::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 24px; height: 24px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3); transition: left 0.15s;
}
input.switch:checked { background: var(--accent); border-color: var(--accent); }
input.switch:checked::after { left: 24px; }
input.switch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
fieldset.access { margin: 8px 0; }
fieldset.access legend { font-weight: 600; }
.own-words { margin: 8px 0; }
.own-words summary { cursor: pointer; color: var(--accent); min-height: 36px; }
.learner-switches { border-top: 1px solid var(--line); padding-top: 8px; margin-top: 8px; }
.learner-switches:first-of-type { border-top: 0; margin-top: 0; }
.learner-switches h3 { margin: 4px 0 0; }
.list-choice { align-items: center; margin: 4px 0; }

/* Orthoglot Coach sections that open and close */
.fold > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px; min-height: 44px; }
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary::before { content: '\25B8'; color: var(--accent); transition: transform 0.15s; }
.fold[open] > summary::before { transform: rotate(90deg); }
.fold > summary h2 { margin: 0; }
.list-name { margin: 0; font-size: 1.1rem; }
.fold-body { padding-top: 4px; }
.fold.learner-panel { border-top: 1px solid var(--line); padding: 4px 0; }
.fold.learner-panel > summary { font-size: 1.1em; }
.fold.inner { margin-left: 16px; }
.fold.inner > summary { min-height: 40px; font-weight: 600; }
.list-details { margin-top: 8px; }
.fold-title { display: flex; align-items: center; gap: 8px; flex: 1; }
.fold-title h2 { margin: 0; }
.fold-action { margin-left: auto; }
.ask-choice { display: flex; flex-direction: column; gap: 4px; margin: 8px 0; }
.ask-choice select { font: inherit; padding: 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--card, #fff); color: inherit; }
.list-row { border-top: 1px solid var(--line); }
.list-row:first-child { border-top: none; }
.list-summary { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.list-words { margin: 8px 0; }
.fold.list-fold > .fold-body { padding-bottom: 8px; }
button.link.inline { display: inline; padding: 0; min-height: 0; font-size: inherit; }
.word-filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.word-filters input, .word-filters select { font: inherit; padding: 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: inherit; }
.word-filters input { flex: 1 1 100%; }
.word-filters select { flex: 1 1 40%; min-width: 0; }
.age-picker { display: flex; flex-direction: column; gap: 4px; margin: 8px 0; }
.age-picker select { font: inherit; padding: 6px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: inherit; }
.word-row[hidden] { display: none; }
.back-to-words { position: sticky; bottom: 12px; display: flex; justify-content: center; align-items: center; gap: 4px; z-index: 5; }
.back-to-words .primary { box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25); }
.flash { animation: flash 1.5s ease-out; }
@keyframes flash { from { background: rgba(123, 147, 255, 0.35); } to { background: transparent; } }

/* A word's name opens its pop-up. */
button.link.word-name { padding: 0; min-height: 0; color: var(--text); text-align: left; }
button.link.word-name strong { text-decoration: underline dotted; text-underline-offset: 3px; }
.word-main input.pick { width: 20px; height: 20px; margin: 0; }
.word-dialog { max-height: calc(100vh - 32px); overflow-y: auto; }
.word-dialog-head { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.word-dialog-head h2 { margin: 0; font-size: 1.6rem; }
.word-info h3 { margin: 0 0 4px; font-size: 0.85rem; color: var(--muted); font-weight: 600; }
.word-info p { margin: 0; }
.word-dialog .sentence-button { text-align: left; padding-left: 0; }
.my-sentence { border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; }
.my-sentence summary { cursor: pointer; color: var(--accent); font-weight: 600; }
.my-sentence .stack { margin-top: 8px; display: grid; gap: 8px; }
.my-sentence textarea { width: 100%; box-sizing: border-box; }
.my-notes { display: grid; gap: 6px; }
.my-notes-text { white-space: pre-wrap; }
.word-row:has(button.word-name) { cursor: pointer; }
.pick-hint { color: var(--text); font-weight: 700; margin: 0; }
.pick-float {
  position: sticky; bottom: 12px; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin-top: 12px; padding: 10px 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}
.part-of-speech { font-style: italic; }
/* Word study on top, a gap, then the spelling tips */
.tips-block > p { margin: 0; }
.tips-block > .tips-text:not(:first-child) { margin-top: 1em; }

/* Coach's Enable/Disable choices on each word list */
.learner-switches { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 8px; }
.learner-switches h4 { margin: 0 0 6px; font-size: .95em; }
.ls-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 6px 0; }
.ls-row label { flex: 1; }
.ls-row select { flex: none; width: auto; }

/* Study: left/right switches (both sides are a choice, so both look "on") */
.either-row { display: flex; align-items: center; gap: 12px; margin: 10px 0; }
.either-row label { cursor: pointer; color: var(--muted); }
.either-row label.chosen { color: var(--text); font-weight: 700; }
.either-left { flex: 1; text-align: right; }
.either-right { flex: 1; }
input.switch.either, input.switch.either:checked { background: var(--accent); border-color: var(--accent); }
.direction-choice { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin: 10px 0; }
.direction-option { flex: 1 1 0; min-width: 0; padding: 8px 6px; font-size: 0.9rem; line-height: 1.25; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--muted); font-weight: 600; white-space: normal; }
.direction-option.chosen { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }

/* A list's name with its Start button on the same line */
.title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.title-row h2 { margin: 0; }
.start-button { flex: none; }
.word-main > .start-button { margin-left: auto; }

/* How-to notes on Study */
.how-to { margin: 8px 0; padding: 8px 10px; border-radius: 8px; background: var(--bg); border: 1px solid var(--line); }

/* "Orthoglot.com" at the top goes back to the start screen */
.topbar h1 a.home-link { color: inherit; text-decoration: none; }
.topbar h1 a.home-link:hover { text-decoration: underline; }

/* Privacy Policy and Terms pages, and the footer linking to them */
.legal { max-width: 760px; margin: 16px auto; line-height: 1.55; }
.legal h3 { margin: 20px 0 6px; }
.legal ul { padding-left: 20px; }
.legal-draft { padding: 8px 12px; border-radius: 8px; background: var(--mid-bg); color: var(--mid); font-weight: 600; }
.site-footer { text-align: center; padding: 16px; font-size: 0.9em; color: var(--muted); }
.site-footer a, .legal a { color: var(--accent); }

/* Signed-out welcome, learners grouped by classroom, classroom picker */
.welcome p { margin: 8px 0; }
.welcome-points { margin: 8px 0; padding-left: 20px; line-height: 1.5; }
.home-group { margin: 8px 0 -4px; font-size: 1rem; color: var(--muted); }
.inline-field { display: flex; align-items: center; gap: 8px; margin: 8px 0; }
.inline-field select { width: auto; }
.list-details { margin: 8px 0; }
.list-details textarea, .card textarea[id^=classroom-desc-] { width: 100%; }
.due-date { margin: 4px 0; font-weight: 600; color: var(--accent); }
.list-description { margin: 4px 0; white-space: pre-line; }
.home-group-note { margin: -6px 0 0; }
.home a { color: var(--accent); }
.definition-card { font-size: 1.25rem; line-height: 1.5; margin: 8px 0 16px; padding: 16px; border-radius: 12px; background: var(--bg); border: 1px solid var(--line); }
.possible-answers { margin: 12px 0; }
.possible-answers > summary.button-like { display: inline-block; cursor: pointer; padding: 10px 16px; border: 1px solid var(--line); border-radius: 10px; font-weight: 600; list-style: none; color: var(--accent); }
.possible-answers > summary::-webkit-details-marker { display: none; }
.possible-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.possible-word { padding: 8px 14px; border-radius: 999px; }
.possible-definitions { flex-direction: column; }
.possible-definition { text-align: left; padding: 10px 14px; border-radius: 10px; white-space: normal; line-height: 1.4; }

/* In a test, Word and Syllables share one line, same size. */
.hear-row { display: flex; gap: 8px; }
.hear-row .hear { flex: 1 1 0; min-width: 0; font-size: 1.1rem; padding: 12px 8px; }
.hear-syllables { margin-top: 8px; font-size: 1.05rem; padding: 12px; }
.hear-row .hear-syllables { margin-top: 0; }
.hear-stack { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
#word-of-day-syllables { margin-top: 8px; }

/* Change Voice sits just left of End test; it steps aside while End test asks to confirm. */
.test-actions { display: inline-flex; gap: 6px; align-items: center; margin-left: auto; }
.test-actions > *, .test-actions button { white-space: nowrap; }
.test-actions:has(.confirming) { display: flex; width: 100%; }
.test-actions:has(.confirming) #change-voice { display: none; }
.voice-dialog { grid-template-columns: minmax(0, 1fr); }
.voice-dialog h2 { margin: 0; }
.voice-dialog .row.spread { flex-wrap: nowrap; }
.dialog-x { padding: 4px 10px; font-size: 1.1rem; line-height: 1; }
.list-group-title { margin: 12px 0 4px; font-size: 0.95rem; }
.autoplay { display: inline-flex; gap: 4px; align-items: center; font-size: 0.9rem; }
.test-actions:has(.confirming) .autoplay { display: none; }
.test-actions { flex-wrap: wrap; justify-content: flex-end; }
.test-actions:has(.confirming) .test-sound { display: none; }
.test-sound .sound-select { max-width: 10.5rem; padding: 4px 6px; font-size: 0.9rem; }
.sound-choice .sound-select { width: 100%; max-width: 22rem; }
.test-actions button.link { padding-left: 4px; padding-right: 4px; }

/* Study: the test menu with Combine Lists on its right. */
.study-bar { display: flex; gap: 8px; align-items: center; }
.study-bar select { flex: 1 1 auto; min-width: 0; min-height: 44px; font: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--text); }
.study-bar button { white-space: nowrap; }
.title-row + .study-bar { margin-top: 12px; }
.study-item { margin-top: 12px; }
.study-item h3 { margin: 0; }
.test-settings { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); }
.test-settings h3 { margin: 0 0 4px; font-size: 1rem; }
#combine-start { margin-top: 8px; width: 100%; }
.learners-list-pick { display: flex; flex-direction: column; gap: 4px; margin: 4px 0 12px; }
.learners-list-pick select { font: inherit; min-height: 44px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--text); max-width: 100%; }
.syllable-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.syllable-chips:empty { display: none; }
.syllable-chip { font-size: 0.85rem; padding: 2px 8px; min-height: 30px; border-radius: 999px; background: var(--bg); }

/* Classrooms and Groups: the New form and the Classroom / Group badge. */
.new-classroom { display: grid; gap: 6px; margin: 10px 0 14px; }
.new-classroom .kind-choice { justify-content: flex-start; margin: 0; max-width: 22rem; }
.new-classroom-row { flex-wrap: nowrap; }
.new-classroom-row input { flex: 1 1 auto; min-width: 0; }
.kind-badge { display: inline-block; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); font-weight: 600; }

/* Learner sign-in on their own device: the coach code (General Settings)
   and each learner's username (Learner Settings). */
.coach-code-value { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.coach-code-value code { font-size: 1.1rem; font-weight: 700; letter-spacing: 0.04em; }
.learner-login { margin: 12px 0; }
.learner-login p { margin: 4px 0; }
.warn-text { color: var(--bad); font-weight: 600; }

/* Scan a word list from a photo, at the top of the word table */
.scan-box {
  margin: 0.75rem 0;
}
.scan-box p {
  margin: 0.4rem 0 0;
}
.dialog .choice input { width: 20px; flex: none; }
.grid .unsure-mark { display: block; margin-top: 4px; font-size: 0.7rem; font-weight: 600; color: var(--bad); }
.grid tr.unsure .word-cell { border-color: var(--bad); }
.dialog .choice input { width: 20px; flex: none; }
.grid .unsure-mark { display: block; margin-top: 4px; font-size: 0.7rem; font-weight: 600; color: var(--bad); }
.grid tr.unsure .word-cell { border-color: var(--bad); }

/* Your Account: Download my data / Delete my account */
.account-action { margin: 12px 0 0; }
.account-action p { margin: 4px 0 0; }

/* Game touches: "N in a row!" in tests, the practice streak, the
   celebration under a test score, the learned bar and confetti. */
.combo {
  display: inline-block;
  margin: 8px 0 0;
  padding: 4px 12px;
  border-radius: 999px;
  font-weight: 700;
  color: var(--good);
  background: var(--good-bg);
  animation: combo-pop 0.35s ease-out;
}
@keyframes combo-pop { 0% { transform: scale(0.6); } 70% { transform: scale(1.12); } 100% { transform: scale(1); } }
.streak { font-weight: 700; margin: 4px 0 12px; }
.celebration { margin: 8px 0; }
.celebration p { margin: 4px 0; }
.cheer { font-size: 1.25rem; font-weight: 800; }
.cheer.perfect { color: var(--good); }
.cheer.best { color: var(--accent); }
.learned-bar { margin: 8px 0 12px; }
.learned-bar .progress { margin: 0 0 4px; height: 12px; }
.learned-bar.all-learned .progress-bar { background: var(--good); }
.learned-label { font-weight: 600; }
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 1000; }
.confetti span {
  position: absolute;
  top: -12px;
  width: 8px;
  height: 14px;
  border-radius: 2px;
  animation-name: confetti-fall;
  animation-timing-function: linear;
  animation-fill-mode: forwards;
}
@keyframes confetti-fall { to { top: 105%; transform: translateX(40px) rotate(540deg); } }
@media (prefers-reduced-motion: reduce) { .combo { animation: none; } }

/* Continue with Google / Apple / Microsoft */
.provider-buttons { display: flex; flex-direction: column; gap: 10px; margin: 4px 0 8px; }
.provider-buttons:empty { display: none; }
.provider-button { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; min-height: 44px; font-weight: 600; }
.provider-logo { display: inline-flex; width: 18px; height: 18px; }
.provider-logo svg { width: 18px; height: 18px; }
.provider-button.provider-apple { background: #000; border-color: #000; color: #fff; }
.provider-buttons .or-line { display: flex; align-items: center; gap: 10px; margin: 6px 0 0; color: var(--muted, #6b7280); font-size: 0.9em; }
.provider-buttons .or-line::before, .provider-buttons .or-line::after { content: ""; flex: 1; border-top: 1px solid var(--line); }

/* Design review fixes (Oct 2026) */

/* The footer sits at the bottom of the screen even on short pages. */
body { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }
body > main { flex: 1 0 auto; width: 100%; }
body > .topbar, body > .site-footer { width: 100%; }

/* Welcome screen: one headline, a picture of a test, one main button. */
.welcome-title { font-size: 1.45rem; line-height: 1.25; margin: 4px 0 8px; }
.welcome-links { text-align: center; margin: 4px 0 0; }
.welcome-links .link { padding: 0; min-height: 0; font: inherit; text-decoration: underline; color: var(--accent); }
.welcome-links a { color: var(--accent); }
.welcome-picture {
  display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center;
  margin: 14px 0; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg);
}
.welcome-picture > div { border-radius: 10px; padding: 8px 12px; font-weight: 600; white-space: nowrap; }
.wp-hear { background: var(--accent); color: var(--accent-text); }
.wp-answer { background: var(--card); border: 1px solid var(--line); font-size: 1.2rem; font-weight: 500 !important; display: flex; align-items: center; }
.wp-caret { display: inline-block; width: 2px; height: 1.2em; margin-left: 1px; background: var(--text); animation: wp-blink 1s steps(1) infinite; }
.wp-check { border: 1px solid var(--accent); color: var(--accent); }
.wp-right { grid-column: 1 / -1; text-align: center; background: var(--good-bg); color: var(--good); }
@keyframes wp-blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .wp-caret { animation: none; } }

/* Test types: two rows of two on phones, so no name is cut off. */
@media (max-width: 560px) {
  .direction-choice.two-by-two .direction-option { flex: 1 1 calc(50% - 3px); }
}

/* Test footer: where the learner is, then ⚙ and End test. */
.test-count { display: flex; flex-direction: column; line-height: 1.3; }
.gear { min-width: 44px; min-height: 44px; padding: 0 10px; font-size: 1.3rem; line-height: 1; }
.test-actions:has(.confirming) .gear { display: none; }
.voice-dialog .test-sound { margin-bottom: 12px; }
.voice-dialog .test-sound .sound-select { max-width: none; width: 100%; min-height: 44px; font-size: 1rem; }
.voice-dialog .autoplay { font-size: 1rem; margin-bottom: 4px; }
.block-label { display: block; font-weight: 600; margin-bottom: 4px; }

/* Summary: full-width buttons, the main one first. */
.summary-buttons { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.summary-buttons button { width: 100%; min-height: 48px; }

/* Spelling with Hints results: no hints / Right* / missed. */
#hints-tally .tile.good .tile-value { color: var(--good); }
#hints-tally .tile.mid .tile-value { color: var(--mid); }
#hints-tally .tile.bad .tile-value { color: var(--bad); }
#hints-tally .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
#hints-tally .tile { padding: 8px; }

/* Change User, at the bottom of the start screen. */
.home-buttons .change-user { align-self: center; margin-top: 4px; }

/* Summary: change since last test and best streak. */
.test-compare { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.test-compare .tile.good .tile-value { color: var(--good); }
.test-compare .tile.bad .tile-value { color: var(--bad); }
