:root {
  color-scheme: light;
  --bg: #f3f5f4;
  --surface: #ffffff;
  --surface-alt: #edf2f1;
  --ink: #26353a;
  --muted: #66767a;
  --line: #d5dfdc;
  --teal: #0f766e;
  --teal-dark: #0b5c56;
  --coral: #dc6b55;
  --mustard: #b9790f;
  --plum: #704b73;
  --green: #2f855a;
  --red: #c2413a;
  --shadow: 0 8px 24px rgba(38, 53, 58, 0.08);
  font-family: "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; background: var(--bg); color: var(--ink); min-height: 100dvh; }
button, input { font: inherit; }
button { cursor: pointer; }
.loading { display: grid; place-items: center; min-height: 100dvh; color: var(--muted); }
.shell { max-width: 760px; min-height: 100dvh; margin: 0 auto; background: var(--bg); display: flex; flex-direction: column; }

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: max(16px, env(safe-area-inset-top)) 18px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand { min-width: 0; flex: 1; }
.brand h1 { margin: 0; font-size: 20px; line-height: 1.15; letter-spacing: 0; }
.brand p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.install { display: none; }

.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 10px 18px;
  background: var(--surface);
}
.tab {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface);
  color: var(--muted);
  font-weight: 800;
  font-size: 14px;
}
.tab.active { background: var(--teal); border-color: var(--teal); color: #fff; }
main { flex: 1; padding: 18px 18px 24px; }
.site-footer { padding: 14px 18px calc(14px + env(safe-area-inset-bottom)); text-align: center; color: var(--muted); font-size: 12px; font-weight: 700; }

.section-head { margin-bottom: 16px; }
.section-head h2 { margin: 0; font-size: 22px; letter-spacing: 0; }
.section-head p { margin: 5px 0 0; color: var(--muted); font-size: 14px; line-height: 1.45; }
.metrics { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--surface); border: 1px solid var(--line); margin-bottom: 14px; }
.metric { min-width: 0; padding: 15px 8px; text-align: center; border-right: 1px solid var(--line); }
.metric:last-child { border-right: 0; }
.metric strong { display: block; font-size: 24px; color: var(--teal); }
.metric span { display: block; color: var(--muted); font-size: 11px; margin-top: 2px; }

.panel { background: var(--surface); border: 1px solid var(--line); padding: 18px; box-shadow: var(--shadow); }
.panel h3 { margin: 0; font-size: 17px; }
.panel p { margin: 6px 0 15px; color: var(--muted); font-size: 14px; line-height: 1.45; }
.button {
  min-height: 48px;
  border: 0;
  border-radius: 5px;
  padding: 0 16px;
  background: var(--teal);
  color: #fff;
  font-size: 15px;
  font-weight: 800;
}
.button:hover { background: var(--teal-dark); }
.button.secondary { background: var(--surface); color: var(--ink); border: 1px solid var(--line); }
.button.secondary:hover { background: var(--surface-alt); }
.button.danger { color: var(--red); }
.button.small { min-height: 38px; padding: 0 12px; font-size: 13px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 15px; }

.lesson-list { display: grid; gap: 8px; }
.lesson-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 13px;
  background: var(--surface);
  border: 1px solid var(--line);
}
.lesson-row h3 { margin: 0; font-size: 15px; }
.lesson-row p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.lesson-state { margin-top: 5px; color: var(--mustard); font-size: 12px; font-weight: 800; }
.lesson-state.done { color: var(--green); }

.back { margin-bottom: 13px; }
.word-list { display: grid; gap: 7px; }
.word-row {
  display: grid;
  grid-template-columns: minmax(90px, 1fr) minmax(110px, 1fr) minmax(0, 2.4fr);
  gap: 10px;
  align-items: center;
  padding: 11px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
}
.word-written { font-family: "Yu Gothic UI", Meiryo, sans-serif; color: var(--plum); font-size: 22px; font-weight: 800; }
.word-reading { font-family: "Yu Gothic UI", Meiryo, sans-serif; color: var(--teal); font-size: 13px; font-weight: 700; }
.word-romaji { color: var(--muted); font-size: 11px; margin-top: 2px; }
.word-natural { color: var(--mustard); font-size: 11px; font-weight: 800; margin-top: 3px; }
.word-pronunciation-note { color: var(--mustard); font-size: 11px; line-height: 1.3; margin-top: 4px; }
.pronunciation-key { margin-bottom: 10px; padding: 11px 12px; background: var(--surface-alt); border-left: 4px solid var(--mustard); color: var(--muted); font-size: 11px; line-height: 1.45; }
.pronunciation-key strong { display: block; color: var(--ink); font-size: 13px; margin-bottom: 3px; }
.pronunciation-key b { color: var(--mustard); }
.word-meaning { font-size: 13px; font-weight: 800; }
.word-example { color: var(--muted); font-size: 13px; line-height: 1.35; margin-top: 3px; }

.session-head { display: grid; gap: 7px; margin-bottom: 14px; }
.session-meta { color: var(--muted); font-size: 13px; font-weight: 800; }
.track { height: 7px; overflow: hidden; background: var(--line); border-radius: 4px; }
.fill { height: 100%; background: var(--green); }
.study-card { min-height: 500px; background: var(--surface); border: 1px solid var(--line); padding: 22px 18px; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.prompt { min-height: 24px; text-align: center; color: var(--muted); font-size: 15px; line-height: 1.4; }
.english-cue { margin-top: 10px; text-align: center; color: var(--teal); font-size: 16px; font-weight: 800; }
.study-main { flex: 1; display: grid; place-items: center; text-align: center; padding: 18px 0; }
.study-word { font-family: "Yu Gothic UI", Meiryo, sans-serif; color: var(--plum); font-size: 64px; font-weight: 800; line-height: 1.2; }
.study-reading { font-family: "Yu Gothic UI", Meiryo, sans-serif; color: var(--teal); font-size: 22px; font-weight: 800; margin-top: 7px; }
.study-romaji { color: var(--muted); font-size: 14px; margin-top: 3px; }
.study-natural { color: var(--mustard); font-size: 15px; font-weight: 800; margin-top: 7px; }
.study-pronunciation-note { max-width: 620px; color: var(--muted); font-size: 13px; line-height: 1.4; margin: 4px auto 0; }
.study-meaning { font-size: 22px; font-weight: 800; margin-top: 15px; }
.part-of-speech { color: var(--muted); font-size: 12px; margin-top: 4px; }
.example { width: 100%; padding: 14px; background: var(--surface-alt); border-left: 4px solid var(--coral); margin-top: 20px; }
.example-jp { font-family: "Yu Gothic UI", Meiryo, sans-serif; font-size: 18px; font-weight: 800; }
.example-reading { color: var(--teal); font-size: 14px; margin-top: 4px; }
.example-en { color: var(--muted); font-size: 15px; margin-top: 5px; }
.cloze { font-family: "Yu Gothic UI", Meiryo, sans-serif; font-size: 34px; font-weight: 800; line-height: 1.35; }

.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.choice { min-height: 62px; border: 1px solid var(--line); border-radius: 5px; padding: 9px; background: var(--surface-alt); color: var(--ink); font-family: "Yu Gothic UI", Meiryo, sans-serif; font-size: 18px; font-weight: 800; }
.choice:hover { border-color: var(--teal); }
.choice.correct { background: var(--green); border-color: var(--green); color: #fff; }
.choice.incorrect { background: var(--red); border-color: var(--red); color: #fff; }
.choice:disabled { cursor: default; }
.typed-answer { display: flex; gap: 8px; }
.answer-input { min-width: 0; flex: 1; height: 52px; border: 1px solid var(--line); border-radius: 5px; padding: 0 12px; background: var(--surface); color: var(--ink); font-family: "Yu Gothic UI", Meiryo, sans-serif; font-size: 18px; }
.answer-input:focus { outline: 3px solid rgba(15, 118, 110, 0.18); border-color: var(--teal); }
.feedback { min-height: 62px; margin-top: 12px; text-align: center; }
.feedback strong { display: block; font-size: 16px; }
.feedback.correct strong { color: var(--green); }
.feedback.incorrect strong { color: var(--red); }
.feedback span { display: block; margin-top: 4px; color: var(--muted); font-size: 14px; }
.session-footer { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 12px; color: var(--muted); font-size: 13px; }

.progress-panel { background: var(--surface); border: 1px solid var(--line); padding: 16px; }
.progress-panel h3 { margin: 0 0 12px; font-size: 16px; }
.progress-row { display: grid; grid-template-columns: 82px 1fr 48px; align-items: center; gap: 10px; margin: 12px 0; font-size: 13px; }
.progress-row strong { text-align: right; }
.empty { padding: 30px 12px; text-align: center; color: var(--muted); }

@media (max-width: 560px) {
  main { padding-left: 12px; padding-right: 12px; }
  .topbar, .tabs { padding-left: 12px; padding-right: 12px; }
  .brand h1 { font-size: 18px; }
  .metrics { grid-template-columns: 1fr 1fr 1fr; }
  .metric strong { font-size: 20px; }
  .word-row { grid-template-columns: minmax(82px, 1fr) minmax(95px, 1fr); }
  .word-copy { grid-column: 1 / -1; padding-top: 7px; border-top: 1px solid var(--line); }
  .study-card { min-height: 470px; padding: 18px 13px; }
  .study-word { font-size: 52px; }
  .cloze { font-size: 27px; }
  .choices { grid-template-columns: 1fr; }
  .choice { min-height: 56px; }
}
