:root {
  --bg: #efe8db;
  --card: #fbf7f0;
  --ink: #211c17;
  --muted: #4e463d;
  --line: #ddd2c1;
  --pine: #1f463c;
  --pine-2: #2d6a56;
  --mist: #e7f1eb;
  --gold: #6d4a22;
  --gold-bg: #f8f1e4;
  --good: #1c5b40;
  --good-bg: #e5f3eb;
  --bad: #8a382e;
  --bad-bg: #f8ebe6;
  --shadow: 0 12px 30px rgba(55, 38, 18, 0.06);
  --nav-h: 4.4rem;
  color-scheme: light;
}

* { box-sizing: border-box; }

html { scroll-behavior: auto; }

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  background:
    radial-gradient(900px 280px at 0% -10%, #f7f1e6, transparent 55%),
    var(--bg);
  color: var(--ink);
  font-size: 1.0625rem;
  line-height: 1.65;
  padding-bottom: calc(var(--nav-h) + 1.25rem + env(safe-area-inset-bottom));
}

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

button, .choice, .primary, .ghost { touch-action: manipulation; }

button { cursor: pointer; }

textarea, input { font-size: 1rem; }

a { color: var(--pine-2); }

.skip {
  position: absolute;
  left: -999px;
  top: 0.6rem;
  background: var(--card);
  padding: 0.4rem 0.7rem;
}

.skip:focus { left: 0.6rem; z-index: 5; }

.notice {
  background: #e7f0ea;
  color: #17342c;
  padding: 0.7rem 1rem 0.75rem;
  border-bottom: 1px solid #c9ddd2;
}

.notice p { margin: 0; }

.notice-en {
  margin-top: 0.15rem;
  font-size: 0.86rem;
  color: #31584c;
}

.shell { width: min(46rem, calc(100% - 1.5rem)); margin: 0 auto; }

.top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 1rem 0 0.4rem;
}

.brand {
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, "Songti SC", "STSong", serif;
  color: var(--ink);
  text-decoration: none;
  font-size: 1.55rem;
  letter-spacing: 0.04em;
  font-weight: 650;
}

.brand::before {
  content: "";
  display: inline-block;
  width: 0.72rem;
  height: 0.72rem;
  margin-right: 0.45rem;
  border-radius: 3px;
  background: var(--pine);
  box-shadow: inset 0 -3px 0 #d7b07a;
  transform: translateY(1px);
}

.eyebrow, .kicker { color: var(--pine); margin: 0; }

.eyebrow { font-size: 0.92rem; }

.kicker {
  font-size: 0.78rem;
  letter-spacing: 0.12em;
}

h1 {
  font-size: 1.65rem;
  line-height: 1.28;
  letter-spacing: -0.02em;
  margin: 0.2rem 0 0.35rem;
  font-weight: 650;
}

h2 { font-size: 1.12rem; margin: 0 0 0.35rem; }

h3 { font-size: 1rem; margin: 0 0 0.25rem; }

p { margin: 0.35rem 0; }

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

.fine { font-size: 0.92rem; }

.stack { display: grid; gap: 0.85rem; margin: 0.6rem 0 1.4rem; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 1rem;
  box-shadow: var(--shadow);
}

.goal { border-left: 4px solid var(--pine); }

.banner {
  background: var(--gold-bg);
  border: 1px solid #e4d3b6;
  border-radius: 16px;
  padding: 0.9rem 1rem;
}

.banner strong { color: var(--gold); }

.primary, .ghost, .segment button, .choice {
  min-height: 3rem;
  border-radius: 999px;
}

.primary, .ghost, a.primary, a.ghost {
  width: 100%;
  padding: 0.7rem 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  text-decoration: none;
}

.primary {
  background: var(--pine);
  color: #f7f3ea;
  border: 0;
}

.ghost {
  background: transparent;
  border: 1px solid var(--line);
}

.primary:disabled, .ghost:disabled, .choice:disabled { cursor: default; }

.segment {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.4rem;
}

.segment button {
  border: 1px solid var(--line);
  background: transparent;
  padding: 0.55rem 0.3rem;
}

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

.check {
  display: flex;
  gap: 0.65rem;
  align-items: flex-start;
  padding: 0.2rem 0;
}

.check input { width: 1.15rem; height: 1.15rem; margin-top: 0.25rem; }

.choices, .row-actions { display: grid; gap: 0.55rem; }

.choice {
  width: 100%;
  text-align: left;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fffdf9;
  padding: 0.85rem 0.95rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; }

.step {
  display: flex;
  gap: 0.7rem;
  align-items: flex-start;
  min-height: 3rem;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fffdf9;
}

.step.current { border-color: var(--pine); background: var(--mist); }

.step .index {
  flex: 0 0 1.75rem;
  width: 1.75rem;
  height: 1.75rem;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--pine);
  color: #f7f3ea;
  font-size: 0.85rem;
}

.step .pill { margin-left: 0.35rem; }

.next-card { border-color: #b7cfc4; }

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

.choice.bad { background: var(--bad-bg); border-color: var(--bad); }

.feedback { border-radius: 14px; padding: 0.85rem 0.95rem; margin-top: 0.8rem; scroll-margin-bottom: 6rem; }

.feedback.good { background: var(--good-bg); }

.feedback.bad { background: var(--bad-bg); }

.passage, .example, textarea {
  white-space: pre-wrap;
}

.passage, .example {
  background: #f3ecdf;
  border-radius: 12px;
  padding: 0.75rem 0.85rem;
}

textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fffdf9;
  padding: 0.75rem;
  min-height: 7rem;
}

.list { margin: 0.3rem 0 0; padding-left: 1.15rem; }

.list li + li { margin-top: 0.35rem; }

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.5rem;
  margin: 0.2rem 0 0.7rem;
}

.pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.12rem 0.55rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.lesson-link, .text-link {
  display: block;
  text-decoration: none;
  color: inherit;
}

.lesson-link strong { display: block; }

dl.stats { display: grid; gap: 0.6rem; margin: 0; }

dl.stats div {
  background: #f6f0e6;
  border-radius: 12px;
  padding: 0.7rem 0.8rem;
}

dt { color: var(--muted); font-size: 0.85rem; }

dd { margin: 0.1rem 0 0; }

.error {
  background: var(--bad-bg);
  border-radius: 14px;
  padding: 0.8rem 0.9rem;
}

audio { width: 100%; margin-top: 0.6rem; }

.foot {
  color: var(--muted);
  font-size: 0.9rem;
  padding: 0.2rem 0 1.2rem;
}

.nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 3;
  display: flex;
  background: rgba(251, 247, 240, 0.96);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}

.nav a {
  flex: 1;
  min-height: 3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: var(--muted);
}

.nav a[aria-current="page"] {
  color: var(--pine);
  font-weight: 650;
}

button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--pine-2);
  outline-offset: 2px;
}

#view:focus { outline: none; }

#view:focus-visible { outline: 2px solid var(--pine-2); }

@media (max-width: 380px) {
  .top { flex-direction: column; align-items: flex-start; gap: 0.15rem; }
  h1 { font-size: 1.42rem; }
  .shell { width: min(46rem, calc(100% - 1rem)); }
  .notice { font-size: 0.98rem; }
  .segment button { font-size: 0.95rem; }
}

@media (min-width: 840px) {
  body { padding-bottom: 2rem; }
  .nav {
    position: static;
    border: 1px solid var(--line);
    border-radius: 999px;
    margin: 0 0 1rem;
  }
  .shell { padding-top: 0.4rem; }
  .row-actions.two { grid-template-columns: 1fr 1fr; }
  dl.stats { grid-template-columns: 1fr 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto; }
}
