:root {
  --bg: #f3efe4;
  --surface: #fffdf8;
  --ink: #17202b;
  --muted: #3a4654;
  --line: #e3dac8;
  --primary: #0c5c56;
  --primary-ink: #ffffff;
  --primary-soft: #e5f3f1;
  --accent: #8f3418;
  --ok: #0d5c32;
  --ok-bg: #e5f6ec;
  --bad: #7a1f1a;
  --bad-bg: #fdecea;
  --warn: #7a4e00;
  --warn-bg: #fff4d6;
  --focus: #0b57d0;
  --shadow: 0 10px 30px rgba(23, 32, 43, 0.06);
  --sans: "Segoe UI", "Helvetica Neue", system-ui, sans-serif;
  --serif: Georgia, "Iowan Old Style", Palatino, serif;
  color-scheme: light;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1200px 400px at 10% -10%, #efe4cf 0%, transparent 50%),
    var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.5;
}

.skip {
  position: absolute;
  left: 0.75rem;
  top: -4rem;
  background: var(--ink);
  color: white;
  padding: 0.6rem 0.9rem;
  z-index: 5;
}

.skip:focus { top: 0.75rem; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 2;
  background: rgba(243, 239, 228, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  max-width: 44rem;
  margin: 0 auto;
  padding: 0.8rem 1rem;
  color: inherit;
  text-decoration: none;
}

.brand strong {
  display: block;
  font-family: var(--serif);
  font-size: 1.15rem;
  font-weight: 700;
}

.brand small {
  color: var(--muted);
  font-size: 0.82rem;
}

.mark {
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 0.7rem;
  display: grid;
  place-items: center;
  background: var(--primary);
  color: var(--primary-ink);
  font-family: var(--serif);
  font-size: 1.4rem;
}

main {
  max-width: 44rem;
  margin: 0 auto;
  padding: 1.1rem 1rem 6.5rem;
}

h1, h2, h3 {
  font-family: var(--serif);
  line-height: 1.2;
  font-weight: 700;
  margin: 0 0 0.4rem;
}

h1 { font-size: 1.85rem; }
h2 { font-size: 1.35rem; margin-top: 1.4rem; }

p { margin: 0.4rem 0 0.8rem; }

a { color: var(--primary); }

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

.en {
  font-size: 0.95rem;
}

.en-label, .kicker {
  display: inline-block;
  font-family: var(--sans);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--primary);
}

.english {
  background: var(--primary-soft);
  border-radius: 0.9rem;
  padding: 0.85rem 1rem;
  margin: 0.8rem 0;
}

.english p:last-child { margin-bottom: 0; }

.card, .lesson-card, .stat, .concept {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 1rem;
  box-shadow: var(--shadow);
}

.card, .lesson-card { padding: 1rem; margin: 0.8rem 0; }

.hero {
  padding: 0.3rem 0 0.6rem;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.6rem;
  margin: 0.8rem 0 1rem;
}

.stat {
  padding: 0.75rem;
}

.stat b {
  display: block;
  font-family: var(--serif);
  font-size: 1.35rem;
}

.stat span, .fine {
  color: var(--muted);
  font-size: 0.82rem;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.btn, .option, .chip, .tabbar a, button {
  font: inherit;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0.65rem 1rem;
  border-radius: 999px;
  border: 2px solid transparent;
  background: var(--primary);
  color: var(--primary-ink);
  text-decoration: none;
  cursor: pointer;
}

.btn.secondary {
  background: transparent;
  color: var(--primary);
  border-color: var(--primary);
}

.btn.ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}

.btn.full { width: 100%; }

.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.level, .pill {
  display: inline-flex;
  align-items: center;
  min-height: 1.7rem;
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 700;
}

.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.ok { background: var(--ok-bg); color: var(--ok); }

.husk {
  border-left: 4px solid var(--accent);
  padding: 0.2rem 0 0.2rem 0.8rem;
  margin: 0.8rem 0;
}

.example {
  display: grid;
  gap: 0.15rem;
  padding: 0.7rem 0;
  border-top: 1px solid var(--line);
}

.example .no { font-weight: 650; }

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

.word .no {
  font-family: var(--serif);
  font-size: 1.25rem;
}

.progress {
  height: 0.45rem;
  background: #e7e0d2;
  border-radius: 99px;
  overflow: hidden;
  margin: 0.4rem 0 0.8rem;
}

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

.sentence, .wrong-box, .answer-line {
  font-size: 1.12rem;
  line-height: 1.45;
}

.wrong-box, .answer-line {
  border: 1px dashed #b7ad9a;
  border-radius: 0.8rem;
  padding: 0.8rem;
  min-height: 3.4rem;
  background: #fff;
}

.gap {
  display: inline-block;
  min-width: 3rem;
  border-bottom: 2px solid var(--primary);
}

.options, .bank, .chosen {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.option, .chip {
  min-height: 48px;
  border-radius: 0.85rem;
  border: 2px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 0.55rem 0.8rem;
  text-align: left;
  cursor: pointer;
}

.option { width: 100%; }
.option[aria-pressed="true"], .chip:focus-visible {
  border-color: var(--primary);
  background: var(--primary-soft);
}

label {
  display: block;
  font-weight: 650;
  margin: 0.6rem 0;
}

input[type="text"], input[type="search"], textarea, select {
  width: 100%;
  margin-top: 0.3rem;
  min-height: 48px;
  border-radius: 0.8rem;
  border: 2px solid #cfc6b4;
  background: #fff;
  color: var(--ink);
  font: inherit;
  padding: 0.6rem 0.75rem;
}

textarea { min-height: 7rem; resize: vertical; }

.feedback {
  border-radius: 0.9rem;
  padding: 0.9rem 1rem;
  margin: 0.8rem 0;
}

.feedback.ok { background: var(--ok-bg); color: var(--ok); }
.feedback.bad { background: var(--bad-bg); color: var(--bad); }
.feedback p { color: inherit; }
.feedback .en { color: var(--ink); }

.note {
  color: var(--bad);
  font-weight: 650;
}

.meter {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.6rem;
  align-items: center;
}

.meter-track {
  height: 0.55rem;
  background: #e7e0d2;
  border-radius: 99px;
  overflow: hidden;
}

.meter-track span {
  display: block;
  height: 100%;
  background: var(--primary);
}

.meter.low .meter-track span { background: var(--bad); }
.meter.mid .meter-track span { background: #a16207; }
.meter.none .meter-track span { width: 0 !important; }

.concept {
  padding: 0.75rem 0.85rem;
  margin: 0.45rem 0;
  box-shadow: none;
}

.concept h3 { font-size: 1rem; font-family: var(--sans); }

.lesson-card h3 { font-size: 1.15rem; }

.lesson-card .meta, .meta {
  color: var(--muted);
  font-size: 0.9rem;
}

.done { border-color: #b7d8c6; }

.filters { margin: 0.4rem 0 0.8rem; }

.filters button[aria-pressed="true"] {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: #fffdf8;
  border-top: 1px solid var(--line);
  padding: 0.25rem 0.2rem calc(0.25rem + env(safe-area-inset-bottom));
  z-index: 3;
}

.tabbar a {
  text-align: center;
  text-decoration: none;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  min-height: 48px;
  display: grid;
  place-items: center;
  border-radius: 0.7rem;
}

.tabbar a[aria-current="page"] {
  color: var(--primary);
  background: var(--primary-soft);
}

dialog {
  border: 0;
  border-radius: 1rem;
  padding: 1rem;
  max-width: 24rem;
  box-shadow: var(--shadow);
}

dialog::backdrop { background: rgba(23, 32, 43, 0.45); }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

@media (min-width: 800px) {
  h1 { font-size: 2.15rem; }
  .stats { grid-template-columns: repeat(4, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}
