:root {
  --paper: #f4efe6;
  --paper-strong: #fffdf8;
  --ink: #1b2422;
  --muted: #5d6b66;
  --line: #d9d0c3;
  --teal: #0f6b5c;
  --teal-deep: #0b4d42;
  --amber: #e3a31a;
  --good: #2c8a57;
  --good-bg: #e5f5eb;
  --bad: #b83a32;
  --bad-bg: #f8e6e4;
  --shadow: 0 12px 32px rgba(27, 36, 34, 0.08);
  --radius: 20px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top right, #f8e7b8 0, transparent 28%),
    var(--paper);
  color: var(--ink);
  font-family: Outfit, "Segoe UI", sans-serif;
  line-height: 1.45;
}

#app {
  width: min(980px, calc(100% - 32px));
  margin: 0 auto;
  padding: 20px 0 48px;
}

h1, h2, h3, h4, .prompt, .score-line {
  font-family: Fraunces, Georgia, serif;
  font-weight: 680;
  letter-spacing: -0.02em;
}

h1 { font-size: 1.7rem; margin: 0; }
h2 { font-size: 1.8rem; margin: 0 0 8px; }
h3 { font-size: 1.15rem; margin: 0 0 14px; }
h4 { font-size: 1.15rem; margin: 0 0 8px; }

p { margin: 0; }

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--teal);
  margin-bottom: 4px;
}

.lede, .muted, .last-score { color: var(--muted); }
.lede { margin: 0 0 18px; }
.warn { color: var(--bad); }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.topbar, .session-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

.topbar h1 { font-size: 1.25rem; }

.hero, .panel, .card {
  background: var(--paper-strong);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.hero {
  display: grid;
  gap: 24px;
  padding: 24px;
  margin-bottom: 18px;
}

.panel {
  padding: 20px;
  margin-bottom: 18px;
}

.ring-wrap { display: grid; place-items: center; }

.ring {
  --pct: 0;
  width: 168px;
  height: 168px;
  border-radius: 50%;
  background: conic-gradient(var(--teal) calc(var(--pct) * 1%), #e8e0d4 0);
  display: grid;
  place-items: center;
}

.ring-inner {
  width: 128px;
  height: 128px;
  border-radius: 50%;
  background: var(--paper-strong);
  display: grid;
  place-items: center;
  text-align: center;
}

.ring-inner strong {
  font-family: Fraunces, Georgia, serif;
  font-size: 2rem;
  line-height: 1;
}

.ring-inner span {
  color: var(--muted);
  font-size: 0.8rem;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 18px 0 12px;
}

.stat {
  background: #f7f2e9;
  border-radius: 14px;
  padding: 10px 8px;
  text-align: center;
}

.stat b { display: block; font-size: 1.2rem; }
.stat span, .mode-card span, .chip small {
  color: var(--muted);
  font-size: 0.75rem;
}

.hero-actions, .drill-actions, .chip-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.hero-actions { margin-top: 16px; }

button, input, select {
  font: inherit;
}

button {
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  cursor: pointer;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.primary {
  background: var(--teal);
  color: white;
}

.primary:hover:not(:disabled) { background: var(--teal-deep); }

.secondary, .ghost, .chip {
  background: #f3eee4;
  color: var(--ink);
}

.secondary, .ghost { border: 1px solid var(--line); }

.text-btn {
  background: transparent;
  color: var(--teal-deep);
  padding: 8px 0;
  font-weight: 600;
}

.full { width: 100%; }

.mode-grid, .split {
  display: grid;
  gap: 12px;
}

.mode-card {
  text-align: left;
  border-radius: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  background: #fbf7f0;
}

.mode-card:hover { border-color: var(--teal); }

.plain-list, .miss-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.plain-list li, .miss-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.plain-list li:first-child, .miss-list li:first-child { border-top: 0; }

.chip-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 280px;
  overflow: auto;
  padding: 2px;
  margin: 12px 0 18px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
}

.chip.is-on {
  background: var(--teal);
  color: white;
}

.chip.is-on small { color: #d9efe9; }

.search-label input, #user-answer {
  width: 100%;
  border: 1px solid var(--line);
  background: white;
  border-radius: 14px;
  padding: 12px 14px;
}

.setup-options {
  display: grid;
  gap: 14px;
  margin-bottom: 18px;
}

fieldset {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
}

legend { padding: 0 6px; color: var(--muted); }

.choice {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0;
}

.session-bar {
  position: sticky;
  top: 0;
  z-index: 5;
  background: color-mix(in srgb, var(--paper) 88%, white);
  backdrop-filter: blur(10px);
  padding: 10px 0;
  margin: -8px 0 16px;
}

.session-meta { flex: 1; }

.session-meta p {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 6px;
}

.bar {
  height: 8px;
  background: #e6ddd0;
  border-radius: 99px;
  overflow: hidden;
}

.bar span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--teal), #2f9e86);
}

.card {
  padding: 28px 22px 24px;
  text-align: center;
}

.review-pill {
  display: inline-block;
  background: #f4dfb0;
  color: #6b4f00;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.75rem;
  font-weight: 700;
  margin-bottom: 10px;
}

.prompt {
  font-size: clamp(1.8rem, 6vw, 2.6rem);
  line-height: 1.15;
  margin-bottom: 8px;
}

.form-label {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--teal-deep);
}

.infinitive-hint {
  color: var(--muted);
  margin: 6px 0 22px;
  font-size: 0.92rem;
}

#user-answer {
  text-align: center;
  font-size: 1.2rem;
  padding: 16px;
  margin-bottom: 14px;
}

#user-answer:focus {
  outline: 3px solid color-mix(in srgb, var(--teal) 35%, white);
  border-color: var(--teal);
}

.drill-actions { justify-content: center; }

.card.is-correct { background: var(--good-bg); border-color: #b5ddc4; }
.card.is-wrong { background: var(--bad-bg); border-color: #efc4c0; }

.feedback { margin-bottom: 18px; }
.feedback-title {
  font-weight: 700;
  margin-bottom: 4px;
}
.feedback-answer {
  font-family: Fraunces, Georgia, serif;
  font-size: 1.6rem;
}

.recap-hero { text-align: center; }
.score-line {
  font-size: 4rem;
  line-height: 1;
  margin: 8px 0 10px;
}
.score-line span {
  font-size: 1.6rem;
  color: var(--muted);
}

.miss-list li { align-items: baseline; text-align: left; }
.miss-list strong { display: block; }
.miss-list span, .miss-list em { color: var(--muted); }
.miss-list em {
  font-family: Fraunces, Georgia, serif;
  font-style: normal;
  color: var(--ink);
  font-size: 1.1rem;
}

.loading { text-align: center; color: var(--muted); padding: 48px 0; }

@media (min-width: 760px) {
  #app { padding-top: 32px; }

  .hero {
    grid-template-columns: 200px 1fr;
    align-items: center;
    padding: 32px;
  }

  .mode-grid, .split { grid-template-columns: 1fr 1fr; }

  .card { padding: 40px 48px 32px; }

  .stat-grid { max-width: 420px; }
}

@media (max-width: 480px) {
  #app { width: min(100% - 20px, 980px); }

  .stat-grid { grid-template-columns: repeat(2, 1fr); }

  .topbar { align-items: flex-start; }

  .session-bar { flex-direction: column; align-items: stretch; }

  .hero-actions, .drill-actions { flex-direction: column; }
  .hero-actions button, .drill-actions button { width: 100%; }

  .score-line { font-size: 3.2rem; }
}
