:root {
  color-scheme: light;
  --ink: #24211f;
  --muted: #6b625d;
  --paper: #f7f5ef;
  --surface: #fffdf8;
  --line: #d9d0c7;
  --accent: #b42b30;
  --accent-dark: #8f1f24;
  --accent-soft: #f8e7e6;
  --gold: #c78a26;
  --danger: #842329;
  --shadow: 0 16px 42px rgba(50, 38, 31, 0.09);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at top right, rgba(180, 43, 48, 0.08), transparent 30rem),
    var(--paper);
  line-height: 1.55;
}

button, textarea, select, input { font: inherit; }
button, select, input { min-height: 44px; }

button:focus-visible,
textarea:focus-visible,
select:focus-visible,
input:focus-visible,
a:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid #285da8;
  outline-offset: 3px;
}

[hidden] { display: none !important; }

.site-header {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 24px 0;
}

.back-link {
  color: var(--accent-dark);
  font-weight: 700;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

.page-shell {
  width: min(900px, calc(100% - 32px));
  margin: 0 auto;
  padding: 38px 0 72px;
}

.intro { max-width: 720px; margin-bottom: 28px; }
.intro h1 { margin: 0; font-size: clamp(2.25rem, 7vw, 4.5rem); line-height: 1; letter-spacing: -0.045em; }
.intro > p:last-child { max-width: 660px; margin: 18px 0 0; color: var(--muted); font-size: 1.08rem; }
.eyebrow { margin: 0 0 8px; color: var(--accent); font-size: 0.78rem; font-weight: 800; letter-spacing: 0.13em; text-transform: uppercase; }

.panel {
  padding: clamp(22px, 5vw, 42px);
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel h2 { margin: 0 0 22px; font-size: clamp(1.45rem, 4vw, 2rem); }
.field { display: grid; align-content: start; gap: 7px; }
.field label, .field legend { font-weight: 750; }
.field-help { margin: 0; color: var(--muted); font-size: 0.92rem; }
.field-wide { margin-bottom: 28px; }

textarea, select, input[type="number"] {
  width: 100%;
  border: 1px solid #bdb2a9;
  border-radius: 10px;
  color: var(--ink);
  background: #fff;
}

textarea { min-height: 230px; padding: 14px; resize: vertical; line-height: 1.6; }
select, input[type="number"] { padding: 9px 12px; }
.item-count { margin: 2px 0 0; color: var(--muted); font-weight: 700; }

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
}

.option-group { margin: 0; padding: 0; border: 0; }
.option-group label { display: flex; align-items: center; min-height: 44px; gap: 10px; font-weight: 500; }
.option-group input { width: 20px; height: 20px; min-height: auto; accent-color: var(--accent); }
.number-row { display: grid; grid-template-columns: minmax(90px, 140px) auto; align-items: center; gap: 10px; }

.actions, .card-actions, .practice-tools, .section-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.actions { margin-top: 30px; }
.button {
  min-height: 44px;
  padding: 10px 18px;
  border: 2px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 800;
  line-height: 1.2;
}
.button:disabled { cursor: not-allowed; opacity: 0.48; }
.button-primary { color: #fff; border-color: var(--accent); background: var(--accent); }
.button-primary:hover:not(:disabled) { border-color: var(--accent-dark); background: var(--accent-dark); }
.button-secondary { color: var(--accent-dark); border-color: var(--accent); background: #fff; }
.button-secondary:hover:not(:disabled) { background: var(--accent-soft); }
.button-danger { color: #fff; border-color: var(--danger); background: var(--danger); }
.button-quiet { color: var(--ink); border-color: #bdb2a9; background: transparent; }
.button-quiet:hover:not(:disabled) { background: #eee9e2; }
.button-large { min-width: 170px; min-height: 52px; font-size: 1.05rem; }

.notice { padding: 12px 14px; border-radius: 10px; }
.notice-error { color: #6e161b; border: 1px solid #dda7aa; background: #fff0f0; }
.notice-error ul { margin: 7px 0 0; padding-left: 22px; }

.practice-heading { display: flex; justify-content: space-between; gap: 20px; align-items: start; }
.practice-heading h2 { margin-bottom: 0; }
.progress { margin: 2px 0 0; color: var(--muted); font-weight: 800; white-space: nowrap; }
.status { min-height: 28px; margin: 24px 0 12px; color: var(--muted); text-align: center; font-weight: 650; }

.dictation-card {
  display: grid;
  justify-items: center;
  gap: 20px;
  min-height: 330px;
  padding: clamp(28px, 7vw, 54px) 20px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(150deg, #fff, #fbf5ed);
  text-align: center;
}

.sound-mark { display: flex; align-items: center; gap: 5px; height: 58px; }
.sound-mark span { display: block; width: 7px; border-radius: 99px; background: var(--gold); }
.sound-mark span:nth-child(1), .sound-mark span:nth-child(4) { height: 20px; }
.sound-mark span:nth-child(2) { height: 40px; }
.sound-mark span:nth-child(3) { height: 56px; }
.hidden-label { margin: -8px 0 0; color: var(--muted); font-weight: 700; }
.card-actions { justify-content: center; }

.answer-region {
  width: min(540px, 100%);
  padding: 18px;
  border: 1px solid #d9b9b5;
  border-radius: 12px;
  background: var(--accent-soft);
}
.answer-original { margin: 0; font-size: clamp(1.5rem, 5vw, 2.3rem); font-weight: 800; overflow-wrap: anywhere; }
.answer-reading { margin: 7px 0 0; color: var(--muted); font-size: 1.12rem; }

.practice-tools { justify-content: center; margin-top: 20px; }
.all-answers { margin-top: 30px; padding-top: 28px; border-top: 1px solid var(--line); }
.section-heading { justify-content: space-between; }
.section-heading h3 { margin: 0; font-size: 1.45rem; }
.all-answers ol { display: grid; gap: 9px; margin: 20px 0 0; padding-left: 32px; }
.all-answers li { padding: 10px 12px; border-radius: 8px; background: #f4f0ea; overflow-wrap: anywhere; }
.derived-reading { display: block; color: var(--muted); font-size: 0.93rem; }

.complete-panel { text-align: center; }
.complete-panel p:not(.eyebrow) { max-width: 580px; margin: 0 auto; color: var(--muted); }
.complete-panel .actions { justify-content: center; }

dialog {
  width: min(520px, calc(100% - 32px));
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 16px;
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(34, 28, 25, 0.58); }
dialog h2 { margin: 0 0 12px; }
dialog p { color: var(--muted); }
.dialog-actions { justify-content: flex-end; }

@media (max-width: 640px) {
  .site-header { padding-inline: 16px; }
  .page-shell { width: min(100% - 20px, 900px); padding-top: 30px; }
  .panel { border-radius: 16px; }
  .settings-grid { grid-template-columns: 1fr; }
  .practice-heading { align-items: end; }
  .practice-tools .button { flex: 1 1 45%; }
  .card-actions { width: 100%; }
  .card-actions .button { flex: 1; }
  dialog { padding: 22px; }
  .dialog-actions .button { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
}