:root {
  --paper: #f4efe4;
  --paper-deep: #e7dfd0;
  --card: #fffdf8;
  --ink: #1d2430;
  --muted: #5e675f;
  --line: #e3d9c8;
  --terra: #b8432e;
  --terra-deep: #8d3120;
  --teal: #0f6b66;
  --teal-soft: #e5f3f1;
  --gold: #f3d7a1;
  --ok: #1d7a4a;
  --ok-soft: #e5f6ec;
  --bad: #a33b32;
  --bad-soft: #fdeceb;
  --warn: #8a5a12;
  --warn-soft: #fff4df;
  --shadow: 0 16px 40px rgba(70, 48, 24, 0.08);
  --serif: "Fraunces", "Iowan Old Style", Palatino, Georgia, serif;
  --sans: "Outfit", "Avenir Next", "Segoe UI", sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #161412;
    --paper-deep: #241f1a;
    --card: #221e1a;
    --ink: #f6f1e7;
    --muted: #c4b8a8;
    --line: #3c342c;
    --terra: #e07a64;
    --terra-deep: #f0b2a4;
    --teal: #8ed9d2;
    --teal-soft: #1b3331;
    --gold: #3c2e1c;
    --ok: #8dcea8;
    --ok-soft: #173226;
    --bad: #f0aaa2;
    --bad-soft: #3a221f;
    --warn: #f0d09a;
    --warn-soft: #3a2c18;
    --shadow: 0 16px 40px rgba(0, 0, 0, 0.28);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(184, 67, 46, 0.08), transparent 32%),
    var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 18px;
  line-height: 1.45;
}

button, input { font: inherit; color: inherit; }

button { cursor: pointer; }

button:focus-visible, input:focus-visible, summary:focus-visible {
  outline: 3px solid var(--teal);
  outline-offset: 3px;
}

.app {
  width: min(920px, calc(100% - 28px));
  margin: 0 auto;
  padding: 28px 0 64px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--terra);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1, h2, h3, p { margin-top: 0; }

h1 {
  margin-bottom: 8px;
  font-family: var(--serif);
  font-size: clamp(2.4rem, 6vw, 4.4rem);
  font-weight: 560;
  letter-spacing: -0.04em;
  line-height: 0.95;
}

h2 {
  margin-bottom: 0;
  font-family: var(--serif);
  font-size: 1.7rem;
  font-weight: 560;
  letter-spacing: -0.03em;
}

.lede, .quiet { color: var(--muted); }

.lede { max-width: 38rem; font-size: 1.08rem; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.back, .text-button {
  border: 0;
  background: transparent;
  color: var(--teal);
  font-weight: 650;
  padding: 8px 0;
}

.score-pill {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.hero, .card, .panel, .choice, .word-row {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
}

.hero {
  padding: 26px;
  box-shadow: var(--shadow);
  background:
    linear-gradient(180deg, var(--gold), transparent 42%),
    var(--card);
}

.section-title {
  margin: 34px 0 12px;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.actions, .segment, .choice-grid, .accent-row, .result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.primary, .ghost, .choice, .accent-row button, .segment button {
  border-radius: 999px;
  border: 1px solid transparent;
  min-height: 48px;
  padding: 10px 16px;
}

.primary {
  background: var(--terra);
  color: white;
  font-weight: 700;
}

@media (prefers-color-scheme: dark) {
  .primary { color: #24110d; }
}

.ghost, .segment button, .accent-row button {
  background: transparent;
  border-color: var(--line);
}

.segment button[aria-pressed="true"] {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

.list-card, .mode-card {
  text-align: left;
  padding: 16px 16px 14px;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: var(--card);
  box-shadow: none;
}

.list-card strong, .mode-card strong { display: block; font-size: 1.08rem; }

.list-card span, .mode-card span, .meta {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.92rem;
}

.list-card .tag,
.list-card .index {
  width: auto;
}

.list-card .tag { display: inline-block; }
.list-card .index { display: inline-grid; }

.index {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  margin-bottom: 12px;
  border-radius: 50%;
  background: var(--paper-deep);
  font-weight: 700;
}

.focus .index, .tag {
  background: var(--terra);
  color: white;
}

.tag {
  display: inline-block;
  margin-bottom: 10px;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.panel { padding: 22px; box-shadow: var(--shadow); }

.kicker {
  margin-bottom: 8px;
  color: var(--teal);
  font-size: 0.84rem;
  font-weight: 700;
}

.prompt {
  margin-bottom: 6px;
  font-family: var(--serif);
  font-size: clamp(2rem, 5vw, 3.3rem);
  font-weight: 560;
  letter-spacing: -0.04em;
  line-height: 1.02;
}

.prompt-long {
  font-family: var(--sans);
  font-size: clamp(1.35rem, 3vw, 1.85rem);
  font-weight: 650;
  letter-spacing: -0.03em;
}

.wide { grid-column: 1 / -1; }

.blog-text {
  width: 100%;
  min-height: 220px;
  margin: 14px 0 10px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--paper);
  resize: vertical;
}

.check-list {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}

.check-list li { padding: 8px 0; border-top: 1px solid var(--line); }
.ok-mark, .miss-mark { font-weight: 700; }
.ok-mark { color: var(--ok); }
.miss-mark { color: var(--bad); }

.task { font-size: 1.05rem; }

.answer-input {
  width: 100%;
  margin: 16px 0 10px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--paper);
}

.choice-grid { margin-top: 16px; }

.choice {
  flex: 1 1 220px;
  text-align: left;
  border-color: var(--line);
  border-radius: 16px;
  line-height: 1.3;
}

.choice.good, .feedback.good { background: var(--ok-soft); border-color: transparent; }
.choice.bad, .feedback.bad { background: var(--bad-soft); border-color: transparent; }
.choice.good, .feedback.good strong { color: var(--ok); }
.choice.bad { color: var(--bad); }

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

.feedback.warn { background: var(--warn-soft); }
.feedback strong { display: block; margin-bottom: 4px; }

.paradigm {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 18px;
  margin-top: 12px;
  font-size: 0.95rem;
}

.paradigm b { font-weight: 700; }

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

.progress span {
  display: block;
  height: 100%;
  background: var(--teal);
}

.words { display: grid; gap: 8px; margin-top: 8px; }

.word-row {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 14px;
}

.word-row em { font-style: normal; color: var(--muted); }

details {
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

summary { cursor: pointer; font-weight: 700; }

.grammar-table {
  width: 100%;
  margin-top: 10px;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.grammar-table th, .grammar-table td {
  padding: 7px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.miss-list { padding-left: 18px; }
.miss-list li { margin: 8px 0; }

.flip {
  width: 100%;
  min-height: 240px;
  padding: 28px 20px;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: var(--card);
  box-shadow: var(--shadow);
}

.flip small { color: var(--muted); }

.check { margin-left: 8px; color: var(--teal); font-weight: 700; }

.sheet-banner {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.exam-flag {
  margin: 0;
  padding: 8px 12px;
  background: #0e4c5b;
  color: #f7f3ea;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.script {
  margin-bottom: 0;
  font-family: var(--serif);
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 560;
  letter-spacing: -0.03em;
}

.script-sub {
  margin-top: 0;
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.4rem;
}

.plain { margin-top: 0; }

.verb-grid, .link-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px 18px;
}

.inf { font-weight: 700; }

.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.line { display: block; }
.line span {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.line span:empty { display: none; }

.ruled {
  width: 100%;
  border: 0;
  border-bottom: 1.5px solid var(--ink);
  border-radius: 0;
  background: transparent;
  padding: 4px 2px 6px;
}

.ruled.good { border-bottom-color: var(--ok); background: var(--ok-soft); }
.ruled.bad { border-bottom-color: var(--bad); background: var(--bad-soft); }
.ruled.empty { border-bottom-style: dashed; }

.facit {
  display: block;
  color: var(--ok);
  font-style: normal;
  font-size: 0.85rem;
}

.sheet-table { width: 100%; border-collapse: collapse; margin-top: 8px; }
.sheet-table th, .sheet-table td {
  border: 1px solid var(--line);
  padding: 10px;
  text-align: left;
  vertical-align: top;
}
.sheet-table th { background: var(--paper-deep); }
.sheet-table .line { display: inline-block; width: 7.5rem; margin: 0 4px; vertical-align: baseline; }
.sheet-table .ruled { width: 7.5rem; }

.score-line { font-weight: 700; }

@media (max-width: 640px) {
  .app { width: min(100% - 20px, 920px); }
  .word-row, .paradigm, .verb-grid, .link-grid { grid-template-columns: 1fr; }
  .hero, .panel { padding: 18px; }
  .sheet-banner { align-items: flex-start; flex-direction: column; }
}
