:root {
  --ink: #17212b;
  --muted: #5b6873;
  --canvas: #f4f7f8;
  --surface: #ffffff;
  --line: #d9e1e5;
  --teal: #0f766e;
  --teal-dark: #115e59;
  --coral: #c95d45;
  --yellow: #c58a08;
  --green: #26734d;
  --red: #b84343;
  --plum: #7c4d87;
  --shadow: 0 1px 3px rgba(23, 33, 43, 0.10);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-width: 320px;
  background: var(--canvas);
  color: var(--ink);
  font-family: Inter, "Segoe UI", system-ui, sans-serif;
}
button, input, select { font: inherit; }
button { touch-action: manipulation; }

.shell { max-width: 720px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; }
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: max(14px, env(safe-area-inset-top)) 16px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand { flex: 1; min-width: 0; }
.brand h1 { margin: 0; font-size: 20px; letter-spacing: 0; }
.brand-title { display: flex; align-items: baseline; gap: 7px; }
.app-version { color: var(--muted); font-size: 11px; font-weight: 700; }

.brand p { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
.install { display: none; }

main { flex: 1; padding: 16px 16px 60px; }
.app-footer {
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-style: italic;
  padding: 14px 16px max(14px, env(safe-area-inset-bottom));
  text-align: center;
}
.tabs, .segmented { display: flex; gap: 6px; }
.tabs { margin: 0 0 16px; }
.tab, .segment {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  border-radius: 6px;
  min-height: 40px;
  padding: 0 13px;
  font-size: 14px;
  font-weight: 700;
}
.tab.active, .segment.active { background: var(--teal); border-color: var(--teal); color: white; }

.section-head { margin: 0 0 12px; }
.section-head h2 { font-size: 19px; margin: 0; }
.section-head p { color: var(--muted); margin: 4px 0 0; font-size: 14px; line-height: 1.4; }

.lesson-list { display: grid; gap: 8px; }
.lesson-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 7px;
  box-shadow: var(--shadow);
}
.lesson-row h3 { font-size: 15px; margin: 0; }
.lesson-row p { font-size: 12px; margin: 3px 0 0; color: var(--muted); }
.lesson-state { font-size: 12px; font-weight: 800; color: var(--yellow); margin-top: 5px; }
.lesson-state.done { color: var(--green); }

.button {
  border: 0;
  border-radius: 6px;
  min-height: 42px;
  padding: 0 14px;
  cursor: pointer;
  font-weight: 800;
  color: white;
  background: var(--teal);
}
.button.secondary { background: var(--surface); color: var(--ink); border: 1px solid var(--line); }
.button.coral { background: var(--coral); }
.button.small { min-height: 36px; padding: 0 11px; font-size: 13px; }
.button:disabled { opacity: 0.5; cursor: default; }

.study-card, .review-card, .panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 7px;
  box-shadow: var(--shadow);
}
.study-card { padding: 16px; }
.study-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; margin: 16px 0; }
.kana-tile { border: 1px solid var(--line); background: #f8fafb; padding: 10px 4px; min-height: 148px; text-align: center; }
.kana-char { font-family: "Yu Gothic UI", "Meiryo", sans-serif; color: var(--plum); font-size: 37px; line-height: 1.1; }
.kata .kana-char { color: var(--teal); }
.kana-reading { font-size: 14px; font-weight: 800; margin: 7px 0 5px; }
.kana-hint { color: var(--muted); font-size: 11px; line-height: 1.35; }
.lesson-actions { display: flex; gap: 8px; flex-wrap: wrap; }


.kanji-study-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin: 14px 0; }
.kanji-study-item {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 12px;
  box-shadow: var(--shadow);
}
.kanji-study-char { font-family: "Yu Gothic UI", "Meiryo", sans-serif; font-size: 54px; line-height: 1; color: var(--yellow); text-align: center; }
.kanji-study-copy h3 { font-size: 15px; margin: 0; }
.kanji-primary { color: var(--teal); font-size: 12px; font-weight: 800; margin-top: 2px; }
.kanji-study-copy p { color: var(--muted); font-size: 11px; line-height: 1.35; margin: 3px 0 8px; }
.kanji-word { border-top: 1px solid var(--line); padding: 6px 0; display: grid; grid-template-columns: auto 1fr; gap: 0 7px; align-items: baseline; }
.kanji-word strong { font-family: "Yu Gothic UI", "Meiryo", sans-serif; font-size: 15px; }
.kanji-word span { color: var(--muted); font-size: 12px; }
.kanji-word small { grid-column: 1 / -1; color: var(--muted); font-size: 11px; }
.review-char.vocabulary { font-size: 64px; }

.kanji-origin { border-top: 1px solid var(--line); margin-top: 7px; padding-top: 6px; }
.kanji-origin summary { color: var(--teal); cursor: pointer; font-size: 12px; font-weight: 800; }
.kanji-origin > div { padding: 7px 0 2px; color: var(--muted); font-size: 11px; line-height: 1.4; }
.kanji-origin ul { margin: 5px 0; padding-left: 18px; }
.kanji-origin li { margin: 3px 0; }
.kanji-origin li strong { color: var(--ink); font-family: "Yu Gothic UI", "Meiryo", sans-serif; font-size: 14px; }
.kanji-origin li span { color: var(--coral); font-weight: 700; }
.kanji-origin p { margin: 6px 0; }
.kanji-origin small { display: block; color: var(--muted); }


.settings { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 0 0 12px; }
.field { display: grid; gap: 5px; }
.field label { color: var(--muted); font-size: 12px; font-weight: 700; }
select, .answer-input {
  min-height: 42px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  padding: 0 10px;
}
.review-card { min-height: 350px; display: flex; flex-direction: column; padding: 20px 16px 16px; }
.prompt { text-align: center; color: var(--muted); font-size: 14px; line-height: 1.4; min-height: 40px; }
.review-char { flex: 1; display: grid; place-items: center; font-family: "Yu Gothic UI", "Meiryo", sans-serif; font-size: clamp(90px, 24vw, 145px); color: var(--plum); line-height: 1; }
.review-char.katakana { color: var(--teal); }
.review-char.kanji { color: var(--yellow); }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.choice { min-height: 52px; background: #f8fafb; color: var(--ink); border: 1px solid var(--line); border-radius: 6px; font-weight: 800; font-size: 16px; }
.choice.correct { background: var(--green); color: white; border-color: var(--green); }
.choice.incorrect { background: var(--red); color: white; border-color: var(--red); }
.typed-answer { display: flex; gap: 8px; }
.feedback { min-height: 26px; text-align: center; font-size: 14px; font-weight: 800; margin: 10px 0 0; }
.feedback.correct { color: var(--green); }
.feedback.incorrect { color: var(--red); }
.review-footer { display: flex; justify-content: space-between; gap: 8px; margin-top: 12px; color: var(--muted); font-size: 13px; }

.panel { padding: 15px; margin-bottom: 12px; }
.metric-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.metric { border-left: 3px solid var(--teal); padding-left: 9px; }
.metric strong { display: block; font-size: 20px; }
.metric span { color: var(--muted); font-size: 12px; }
.progress-row { display: grid; grid-template-columns: 100px 1fr 38px; align-items: center; gap: 8px; margin: 9px 0; font-size: 13px; }
.track { height: 8px; background: #e2e9eb; overflow: hidden; border-radius: 4px; }
.fill { height: 100%; background: var(--teal); }
.empty { color: var(--muted); font-size: 14px; text-align: center; padding: 30px 12px; }
.notice { color: var(--muted); font-size: 13px; margin: 12px 0 0; }

@media (max-width: 480px) {
  .study-grid { grid-template-columns: repeat(3, 1fr); }
  .kanji-study-grid { grid-template-columns: 1fr; }
  .kana-tile { min-height: 132px; }
  .lesson-row { grid-template-columns: minmax(0, 1fr); }
  .lesson-row .button { width: 100%; }
}

.tabs .tab { flex: 1; padding-left: 8px; padding-right: 8px; }
.sprint-head { align-items: center; margin-bottom: 10px; font-size: 14px; }
.sprint-head strong { color: var(--yellow); font-size: 20px; }
.sprint-config { margin-top: 14px; }
