/* Tadaima — washi paper, sumi ink, vermilion. */
:root {
  --bg: #f4efe6;
  --surface: #fffdf8;
  --surface-2: #ece5d8;
  --ink: #1d1b18;
  --ink-2: #5a544b;
  --ink-3: #8d867a;
  --line: #ded5c5;
  --red: #c4382c;
  --red-soft: #f6dfda;
  --indigo: #2f4b7c;
  --indigo-soft: #dfe6f2;
  --green: #4c7a3a;
  --green-soft: #e3eed8;
  --gold: #a9781c;
  --gold-soft: #f3e7c9;
  --shadow: 0 1px 0 rgba(40, 30, 10, .04), 0 10px 28px -14px rgba(60, 40, 20, .28);
  --r: 16px;
  --r-sm: 10px;
  --font: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", "Segoe UI", system-ui, sans-serif;
  --font-jp: "Hiragino Sans", "Noto Sans JP", "Yu Gothic", "Meiryo", sans-serif;
  --font-display: "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif JP", "Songti SC", serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #161411; --surface: #201d19; --surface-2: #2c2823; --ink: #f2ecdf; --ink-2: #bdb5a6; --ink-3: #8b8477;
  --line: #3a352d; --red: #e86a5c; --red-soft: #47231f; --indigo: #9bb3e6; --indigo-soft: #232c40;
  --green: #96c079; --green-soft: #26321f; --gold: #dcb35a; --gold-soft: #3a3120;
  --shadow: 0 1px 0 rgba(0, 0, 0, .3), 0 10px 28px -14px rgba(0, 0, 0, .7);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161411; --surface: #201d19; --surface-2: #2c2823; --ink: #f2ecdf; --ink-2: #bdb5a6; --ink-3: #8b8477;
    --line: #3a352d; --red: #e86a5c; --red-soft: #47231f; --indigo: #9bb3e6; --indigo-soft: #232c40;
    --green: #96c079; --green-soft: #26321f; --gold: #dcb35a; --gold-soft: #3a3120;
    --shadow: 0 1px 0 rgba(0, 0, 0, .3), 0 10px 28px -14px rgba(0, 0, 0, .7);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.5 var(--font); -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none; -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, p { margin: 0; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; padding: 0; touch-action: manipulation; }
button:disabled { cursor: default; }
a { color: inherit; }
input, textarea, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--indigo); outline-offset: 2px; border-radius: 6px; }
#app { height: 100%; }
.boot { height: 100%; display: grid; place-items: center; font: 42px var(--font-display); color: var(--red); letter-spacing: .08em; }

/* ---------- shell ---------- */
.shell { height: 100%; display: grid; grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
.main { overflow-y: auto; -webkit-overflow-scrolling: touch; min-height: 0; padding-top: var(--safe-t); }
.side { display: none; }
.tabs {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  background: var(--surface); border-top: 1px solid var(--line);
  padding: 6px 6px calc(6px + var(--safe-b));
}
.tab { display: grid; justify-items: center; gap: 2px; padding: 6px 2px; border-radius: 12px; color: var(--ink-3); font-size: 11px; font-weight: 600; position: relative; }
.tab svg { width: 24px; height: 24px; }
.tab.on { color: var(--red); }
.tab .dot { position: absolute; top: 2px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--red); color: #fff; font-size: 11px; line-height: 18px; text-align: center; font-weight: 700; }
.shell.focus-mode { grid-template-rows: 1fr; }
.shell.focus-mode .tabs, .shell.focus-mode .side { display: none; }

@media (min-width: 900px) {
  .shell { grid-template-columns: 232px 1fr; grid-template-rows: 1fr; }
  .shell.focus-mode { grid-template-columns: 1fr; }
  .tabs { display: none; }
  .side { display: flex; flex-direction: column; gap: 4px; padding: 22px 14px; border-right: 1px solid var(--line); background: var(--surface); overflow-y: auto; }
  .brand { padding: 4px 10px 18px; }
  .brand b { display: block; font: 30px/1.1 var(--font-display); color: var(--red); letter-spacing: .04em; }
  .brand span { font-size: 12px; color: var(--ink-3); letter-spacing: .14em; text-transform: uppercase; }
  .nav { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; color: var(--ink-2); font-weight: 600; text-align: left; width: 100%; }
  .nav svg { width: 21px; height: 21px; flex: none; }
  .nav:hover { background: var(--surface-2); }
  .nav.on { background: var(--red-soft); color: var(--red); }
  .nav .dot { margin-left: auto; min-width: 22px; padding: 0 6px; height: 22px; border-radius: 11px; background: var(--red); color: #fff; font-size: 12px; line-height: 22px; text-align: center; }
  .nav-sep { height: 1px; background: var(--line); margin: 10px 8px; }
  .side-foot { margin-top: auto; padding: 12px 10px 0; font-size: 12px; color: var(--ink-3); }
}

.page { max-width: 760px; margin: 0 auto; padding: 22px 18px 40px; }
.page-head { margin-bottom: 18px; }
.page-head h1 { font-size: 28px; line-height: 1.15; letter-spacing: -.02em; }
.page-head p { color: var(--ink-2); margin-top: 4px; }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); }
.muted { color: var(--ink-2); }
.small { font-size: 14px; }
.tiny { font-size: 12.5px; }
.center { text-align: center; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack { display: grid; gap: 12px; }
.stack-lg { display: grid; gap: 20px; }
.grow { flex: 1; min-width: 0; }
.h2 { font-size: 19px; letter-spacing: -.01em; margin: 26px 0 10px; }

/* ---------- Japanese text ---------- */
.jp { font-family: var(--font-jp); line-height: 2; word-break: keep-all; overflow-wrap: anywhere; }
.jp-xl { font-size: 30px; font-weight: 600; }
.jp-lg { font-size: 24px; font-weight: 600; }
.jp-md { font-size: 19px; }
ruby { ruby-position: over; }
rt { font-size: .48em; color: var(--ink-3); font-weight: 400; letter-spacing: 0; user-select: none; }
.no-furi rt { visibility: hidden; }
.no-furi .show-furi rt, .no-furi .tok:hover rt { visibility: visible; }
.tok { position: relative; border-radius: 6px; cursor: pointer; transition: background .12s; }
.tok:hover, .tok.open { background: var(--gold-soft); }
.tok.is-particle { color: var(--red); }
.pop {
  position: absolute; left: 50%; top: calc(100% + 4px); transform: translateX(-50%); z-index: 30;
  background: var(--ink); color: var(--bg); border-radius: 10px; padding: 8px 12px; width: max-content; max-width: 230px;
  font: 13.5px/1.4 var(--font); font-weight: 500; text-align: center; box-shadow: var(--shadow); white-space: normal; word-break: normal;
}
.pop b { display: block; font: 600 16px var(--font-jp); margin-bottom: 2px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 18px; border-radius: 14px; font-weight: 700; font-size: 16px;
  background: var(--surface); border: 1.5px solid var(--line); color: var(--ink);
  transition: transform .08s, background .15s, border-color .15s, opacity .15s; user-select: none;
}
.btn:active:not(:disabled) { transform: translateY(1px) scale(.99); }
.btn:hover:not(:disabled) { border-color: var(--ink-3); }
.btn:disabled { opacity: .45; }
.btn svg { width: 20px; height: 20px; flex: none; }
.btn-primary { background: var(--red); border-color: var(--red); color: #fff; box-shadow: 0 3px 0 color-mix(in srgb, var(--red) 70%, #000); }
.btn-primary:hover:not(:disabled) { border-color: var(--red); filter: brightness(1.05); }
.btn-primary:active:not(:disabled) { box-shadow: 0 1px 0 color-mix(in srgb, var(--red) 70%, #000); transform: translateY(2px); }
.btn-dark { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.btn-ok { background: var(--green); border-color: var(--green); color: #fff; box-shadow: 0 3px 0 color-mix(in srgb, var(--green) 70%, #000); }
.btn-soft { background: var(--surface-2); border-color: transparent; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); border-color: transparent; }
.btn-lg { min-height: 54px; font-size: 17px; border-radius: 16px; padding: 0 24px; }
.btn-sm { min-height: 36px; font-size: 14px; padding: 0 12px; border-radius: 10px; }
.btn-block { width: 100%; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; display: inline-grid; place-items: center; color: var(--ink-2); flex: none; }
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn.sm { width: 34px; height: 34px; }
.icon-btn.sm svg { width: 19px; height: 19px; }
.icon-btn.tint { background: var(--indigo-soft); color: var(--indigo); }
.icon-btn.playing { background: var(--indigo); color: #fff; }
.link { color: var(--indigo); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }

/* ---------- surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; }
.card.lift { box-shadow: var(--shadow); }
.card-btn { display: block; width: 100%; text-align: left; transition: border-color .15s, transform .08s; }
.card-btn:hover { border-color: var(--ink-3); }
.card-btn:active { transform: scale(.995); }
.chip { display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 9px; border-radius: 12px; font-size: 12px; font-weight: 700; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.chip.polite { background: var(--indigo-soft); color: var(--indigo); }
.chip.casual { background: var(--gold-soft); color: var(--gold); }
.chip.ok { background: var(--green-soft); color: var(--green); }
.chip.red { background: var(--red-soft); color: var(--red); }
.note { background: var(--surface-2); border-radius: var(--r-sm); padding: 12px 14px; font-size: 14.5px; color: var(--ink-2); }
.note.warn { background: var(--gold-soft); color: var(--ink); }
.note.err { background: var(--red-soft); color: var(--ink); }
.kanji-badge { width: 46px; height: 46px; border-radius: 13px; display: grid; place-items: center; font: 600 24px var(--font-display); background: var(--red-soft); color: var(--red); flex: none; }
.kanji-badge.indigo { background: var(--indigo-soft); color: var(--indigo); }
.kanji-badge.gold { background: var(--gold-soft); color: var(--gold); }
.kanji-badge.green { background: var(--green-soft); color: var(--green); }
.kanji-badge.lg { width: 60px; height: 60px; font-size: 32px; border-radius: 16px; }

.bar { height: 10px; border-radius: 5px; background: var(--surface-2); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 5px; background: var(--red); transition: width .35s cubic-bezier(.3, .8, .3, 1); }
.bar.green > i { background: var(--green); }
.bar.thin { height: 6px; }

/* ---------- home ---------- */
.hero { display: grid; grid-template-columns: 1fr auto; gap: 14px; align-items: center; }
.hero h1 { font: 600 34px/1.15 var(--font-display); letter-spacing: .02em; }
.hero h1 small { display: block; font: 500 15px var(--font); color: var(--ink-2); letter-spacing: 0; margin-top: 6px; }
.ring { position: relative; width: 92px; height: 92px; flex: none; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 9; }
.ring .trk { stroke: var(--surface-2); }
.ring .val { stroke: var(--red); stroke-linecap: round; transition: stroke-dashoffset .6s cubic-bezier(.3, .8, .3, 1); }
.ring.done .val { stroke: var(--green); }
.ring .mid { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; line-height: 1.1; }
.ring .mid b { font-size: 21px; }
.ring .mid span { font-size: 10.5px; color: var(--ink-3); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 18px 0 6px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 12px 10px; }
.stat b { display: block; font-size: 24px; line-height: 1.15; letter-spacing: -.02em; }
.stat span { font-size: 12.5px; color: var(--ink-2); font-weight: 600; }
.stat .unit { font-size: 14px; color: var(--ink-3); font-weight: 600; margin-left: 2px; }
.plan { display: grid; gap: 10px; }
.plan-item { display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center; padding: 14px; }
.plan-item h3 { font-size: 16.5px; line-height: 1.25; }
.plan-item p { font-size: 13.5px; color: var(--ink-2); margin-top: 2px; }
.plan-item .go { color: var(--ink-3); }
.plan-item .go svg { width: 20px; height: 20px; display: block; }
.plan-item.done { opacity: .62; }
.plan-item.done .kanji-badge { background: var(--green-soft); color: var(--green); }
.plan-item.next { border-color: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
.level { display: grid; gap: 6px; }

/* ---------- learn path ---------- */
.unit-head { display: flex; align-items: center; gap: 14px; margin: 28px 0 12px; }
.unit-head:first-child { margin-top: 0; }
.unit-head h2 { font-size: 20px; line-height: 1.2; }
.unit-head p { font-size: 13.5px; color: var(--ink-2); }
.unit-head .count { margin-left: auto; font-size: 13px; font-weight: 700; color: var(--ink-3); white-space: nowrap; }
.nodes { display: grid; gap: 8px; }
.node { display: grid; grid-template-columns: 34px 1fr auto; gap: 12px; align-items: center; padding: 12px 14px; }
.node .num { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 14px; background: var(--surface-2); color: var(--ink-2); }
.node.done .num { background: var(--green); color: #fff; }
.node.next { border-color: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
.node.next .num { background: var(--red); color: #fff; }
.node h3 { font: 600 17px/1.3 var(--font-jp); }
.node p { font-size: 13.5px; color: var(--ink-2); }
.node .num svg { width: 18px; height: 18px; }

/* ---------- focus (lesson / review / drills) ---------- */
.focus { height: 100%; display: grid; grid-template-rows: auto 1fr auto; max-width: 760px; margin: 0 auto; padding-top: var(--safe-t); }
.focus-top { display: flex; align-items: center; gap: 10px; padding: 10px 12px 6px; }
.focus-top .bar { flex: 1; }
.focus-top .count { font-size: 13px; font-weight: 700; color: var(--ink-3); min-width: 44px; text-align: right; }
.focus-body { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 14px 18px 20px; min-height: 0; }
.focus-foot { padding: 12px 18px calc(14px + var(--safe-b)); border-top: 1px solid transparent; }
.focus-foot.ok { background: var(--green-soft); border-color: transparent; }
.focus-foot.bad { background: var(--red-soft); }
.focus-foot .verdict { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 12px; }
.focus-foot .verdict svg { width: 26px; height: 26px; flex: none; margin-top: 1px; }
.focus-foot.ok .verdict { color: var(--green); }
.focus-foot.bad .verdict { color: var(--red); }
.focus-foot .verdict b { display: block; font-size: 17px; }
.focus-foot .verdict .ans { color: var(--ink); font-size: 15px; }
.q-label { font-size: 13px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 10px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.q-en { font-size: 22px; line-height: 1.3; font-weight: 700; letter-spacing: -.01em; }
.q-area { min-height: 100%; display: flex; flex-direction: column; }
.q-area .spacer { flex: 1; min-height: 16px; }

.lesson-title { font: 600 30px/1.25 var(--font-jp); }
.pattern { display: inline-block; font: 600 16px/1.5 var(--font-jp); background: var(--ink); color: var(--bg); padding: 8px 14px; border-radius: 12px; margin: 12px 0 4px; }
.prose p { margin: 12px 0; font-size: 16.5px; line-height: 1.7; }
.prose strong { color: var(--red); font-weight: 700; }
.prose em { font-style: normal; color: var(--indigo); font-weight: 600; }
.prose ruby rt { font-size: .5em; }
.anatomy { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 6px; }
.anatomy > div { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px 9px; text-align: center; }
.anatomy .jp { font-size: 20px; font-weight: 600; line-height: 1.9; }
.anatomy span { display: block; font-size: 12.5px; color: var(--ink-2); font-weight: 600; border-top: 1px dashed var(--line); padding-top: 5px; margin-top: 2px; }
.ex { display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.ex:last-child { border-bottom: 0; }
.ex .jp { font-size: 20px; font-weight: 500; }
.ex .en { grid-column: 1 / -1; font-size: 14.5px; color: var(--ink-2); margin-top: -4px; }
.vocab { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.vocab button { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; text-align: left; }
.vocab button:hover { border-color: var(--ink-3); }
.vocab .jp { font-size: 18px; font-weight: 600; line-height: 1.9; display: block; }
.vocab span { font-size: 13px; color: var(--ink-2); display: block; line-height: 1.3; }

/* tiles */
.slots { min-height: 124px; border-bottom: 2px solid var(--line); background:
  linear-gradient(var(--line), var(--line)) 0 60px / 100% 2px no-repeat; display: flex; flex-wrap: wrap; gap: 8px; align-content: flex-start; padding: 6px 0 10px; margin: 16px 0 18px; }
.tiles { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.tile { min-height: 46px; padding: 0 14px; border-radius: 12px; background: var(--surface); border: 1.5px solid var(--line); box-shadow: 0 2px 0 var(--line); font: 600 19px var(--font-jp); display: inline-flex; align-items: center; }
.tile:active { transform: translateY(2px); box-shadow: none; }
.tile.used { background: var(--surface-2); color: transparent; box-shadow: none; border-color: transparent; pointer-events: none; }
.tile { line-height: 1.9; padding-top: 4px; }

/* choices */
.choices { display: grid; gap: 10px; }
.choices.two { grid-template-columns: 1fr 1fr; }
.choice { text-align: left; padding: 14px 16px; border-radius: 14px; background: var(--surface); border: 1.5px solid var(--line); box-shadow: 0 2px 0 var(--line); font-size: 16.5px; font-weight: 600; min-height: 54px; }
.choice.jp { font: 600 20px var(--font-jp); text-align: center; line-height: 1.6; }
.choice:hover:not(:disabled) { border-color: var(--ink-3); }
.choice.picked { border-color: var(--indigo); background: var(--indigo-soft); box-shadow: 0 2px 0 var(--indigo); }
.choice.right { border-color: var(--green); background: var(--green-soft); box-shadow: 0 2px 0 var(--green); color: var(--green); }
.choice.wrong { border-color: var(--red); background: var(--red-soft); box-shadow: 0 2px 0 var(--red); color: var(--red); }
.blank { display: inline-block; min-width: 54px; border-bottom: 3px solid var(--red); margin: 0 4px; text-align: center; color: var(--red); line-height: 1.3; }
.blank.filled { border-color: transparent; background: var(--red-soft); border-radius: 8px; padding: 0 8px; }
.listen-card { display: grid; place-items: center; gap: 12px; padding: 28px 16px; }
.big-play { width: 92px; height: 92px; border-radius: 50%; background: var(--indigo); color: #fff; display: grid; place-items: center; box-shadow: 0 4px 0 color-mix(in srgb, var(--indigo) 65%, #000); }
.big-play:active { transform: translateY(3px); box-shadow: none; }
.big-play svg { width: 40px; height: 40px; }

/* speaking */
.mic { width: 84px; height: 84px; border-radius: 50%; background: var(--red); color: #fff; display: grid; place-items: center; box-shadow: 0 4px 0 color-mix(in srgb, var(--red) 65%, #000); position: relative; flex: none; }
.mic svg { width: 36px; height: 36px; }
.mic:active { transform: translateY(3px); box-shadow: none; }
.mic.live { animation: pulse 1.2s ease-in-out infinite; }
.mic.sm { width: 52px; height: 52px; box-shadow: 0 3px 0 color-mix(in srgb, var(--red) 65%, #000); }
.mic.sm svg { width: 24px; height: 24px; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--red) 55%, transparent); } 50% { box-shadow: 0 0 0 16px transparent; } }
.heard { min-height: 28px; font: 500 18px var(--font-jp); color: var(--ink-2); text-align: center; }
.speak-zone { display: grid; justify-items: center; gap: 12px; padding: 8px 0; }
.input { width: 100%; min-height: 48px; padding: 10px 14px; border-radius: 14px; background: var(--surface); border: 1.5px solid var(--line); font-size: 17px; }
.input:focus { outline: none; border-color: var(--indigo); }
textarea.input { resize: none; line-height: 1.5; }
.answer { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; text-align: center; }
.score { display: inline-flex; align-items: center; gap: 6px; font-weight: 800; font-size: 14px; padding: 4px 10px; border-radius: 12px; }
.score.hi { background: var(--green-soft); color: var(--green); }
.score.mid { background: var(--gold-soft); color: var(--gold); }
.score.lo { background: var(--red-soft); color: var(--red); }

/* review grades */
.grades { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.grade { display: grid; gap: 1px; justify-items: center; padding: 9px 4px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--surface); font-weight: 800; font-size: 15px; }
.grade small { font-size: 12px; font-weight: 600; color: var(--ink-3); }
.grade.again { border-color: var(--red); color: var(--red); }
.grade.hard { border-color: var(--gold); color: var(--gold); }
.grade.good { border-color: var(--green); color: var(--green); }
.grade.easy { border-color: var(--indigo); color: var(--indigo); }
.grade.suggest { box-shadow: 0 0 0 3px var(--surface-2); background: var(--surface-2); }
.review-card { display: grid; gap: 14px; justify-items: center; text-align: center; padding: 8px 0; }
.review-card .q-en { font-size: 25px; }

/* celebration */
.done-screen { min-height: 100%; display: grid; place-content: center; justify-items: center; text-align: center; gap: 14px; padding: 30px 10px; }
.done-screen .stamp { width: 132px; height: 132px; border-radius: 50%; border: 5px solid var(--red); color: var(--red); display: grid; place-items: center; font: 600 62px var(--font-display); transform: rotate(-8deg); animation: stamp .5s cubic-bezier(.2, 1.6, .4, 1) both; }
@keyframes stamp { from { transform: rotate(-8deg) scale(2.2); opacity: 0; } to { transform: rotate(-8deg) scale(1); opacity: 1; } }
.done-screen h1 { font-size: 28px; letter-spacing: -.02em; }
.done-stats { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.done-stats .stat { min-width: 104px; text-align: center; }

/* chat */
.chat { display: grid; gap: 14px; padding-bottom: 8px; }
.msg { max-width: 88%; display: grid; gap: 6px; }
.msg.ai { justify-self: start; }
.msg.me { justify-self: end; justify-items: end; }
.bubble { padding: 10px 14px; border-radius: 18px; background: var(--surface); border: 1px solid var(--line); }
.msg.ai .bubble { border-bottom-left-radius: 6px; }
.msg.me .bubble { background: var(--ink); color: var(--bg); border-color: var(--ink); border-bottom-right-radius: 6px; }
.msg.me .bubble rt { color: color-mix(in srgb, var(--bg) 70%, transparent); }
.bubble .jp { font-size: 19px; line-height: 1.95; }
.bubble .en { font-size: 14px; color: var(--ink-2); border-top: 1px dashed var(--line); margin-top: 6px; padding-top: 6px; }
.msg-tools { display: flex; gap: 2px; align-items: center; flex-wrap: wrap; }
.fb { font-size: 14.5px; border-radius: 14px; padding: 10px 12px; display: grid; gap: 4px; max-width: 100%; text-align: left; }
.fb.good { background: var(--green-soft); }
.fb.improve { background: var(--gold-soft); }
.fb .jp { font-size: 17px; line-height: 1.9; font-weight: 600; }
.fb-head { font-weight: 800; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.fb.good .fb-head { color: var(--green); }
.fb.improve .fb-head { color: var(--gold); }
.hints { display: grid; gap: 6px; }
.hint { text-align: left; background: var(--surface); border: 1px dashed var(--ink-3); border-radius: 12px; padding: 8px 12px; }
.hint .jp { font-size: 16.5px; line-height: 1.85; }
.hint span { display: block; font-size: 13px; color: var(--ink-2); }
.composer { display: flex; gap: 8px; align-items: flex-end; }
.composer .input { min-height: 52px; }
.typing { display: inline-flex; gap: 5px; padding: 6px 2px; }
.typing i { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; }
.typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

/* grids & lists */
.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.pick { display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: center; padding: 14px; }
.pick h3 { font-size: 16.5px; line-height: 1.25; }
.pick p { font-size: 13.5px; color: var(--ink-2); margin-top: 2px; }
.pick .jp-sub { font: 500 13px var(--font-jp); color: var(--ink-3); }
.list { display: grid; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 12px 2px; border-bottom: 1px solid var(--line); }
.list-row:last-child { border-bottom: 0; }

/* forms */
.field { display: grid; gap: 6px; margin-bottom: 16px; }
.field > label, .field > .label { font-weight: 700; font-size: 15px; }
.field .help { font-size: 13.5px; color: var(--ink-2); }
.select { min-height: 46px; padding: 0 12px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface); width: 100%; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 12px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { padding: 8px 14px; border-radius: 10px; font-weight: 700; font-size: 14.5px; color: var(--ink-2); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .12); }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.switch:last-child { border-bottom: 0; }
.switch b { display: block; font-size: 15.5px; }
.switch span { font-size: 13.5px; color: var(--ink-2); }
.toggle { width: 50px; height: 30px; border-radius: 15px; background: var(--surface-2); position: relative; flex: none; transition: background .15s; border: 1px solid var(--line); }
.toggle::after { content: ""; position: absolute; top: 2px; left: 2px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform .15s; }
.toggle.on { background: var(--green); border-color: var(--green); }
.toggle.on::after { transform: translateX(20px); }
input[type="range"] { width: 100%; accent-color: var(--red); }

/* stats */
.heat { display: grid; grid-template-rows: repeat(7, 1fr); grid-auto-flow: column; grid-auto-columns: 1fr; gap: 3px; }
.heat i { aspect-ratio: 1; border-radius: 3px; background: var(--surface-2); }
.heat i.l1 { background: color-mix(in srgb, var(--red) 28%, var(--surface-2)); }
.heat i.l2 { background: color-mix(in srgb, var(--red) 55%, var(--surface-2)); }
.heat i.l3 { background: color-mix(in srgb, var(--red) 80%, var(--surface-2)); }
.heat i.l4 { background: var(--red); }
.heat i.future { background: transparent; }
.split { display: flex; height: 14px; border-radius: 7px; overflow: hidden; background: var(--surface-2); }
.split i { display: block; height: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13.5px; color: var(--ink-2); margin-top: 10px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; }

/* toasts & overlays */
.toasts { position: fixed; left: 0; right: 0; bottom: calc(84px + var(--safe-b)); display: grid; justify-items: center; gap: 8px; pointer-events: none; z-index: 60; padding: 0 16px; }
.toast { background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 14px; font-weight: 600; font-size: 14.5px; box-shadow: var(--shadow); animation: rise .25s ease-out both; max-width: 100%; }
.toast.err { background: var(--red); color: #fff; }
@keyframes rise { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }
.overlay { position: fixed; inset: 0; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); z-index: 70; display: grid; place-items: center; padding: 24px; }
.sheet { background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 24px; max-width: 440px; width: 100%; box-shadow: var(--shadow); max-height: 90%; overflow-y: auto; }
.fade-in { animation: rise .25s ease-out both; }

@media (max-width: 420px) {
  .page { padding: 18px 14px 32px; }
  .hero h1 { font-size: 29px; }
  .jp-xl { font-size: 26px; }
  .q-en { font-size: 20px; }
  .stat b { font-size: 21px; }
  .grades { gap: 6px; }
  .grade { font-size: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
.go svg { width: 20px; height: 20px; display: block; }
.msg.me .bubble .en { color: color-mix(in srgb, var(--bg) 72%, transparent); border-top-color: color-mix(in srgb, var(--bg) 30%, transparent); }
.msg.me .tok:hover, .msg.me .tok.open { background: color-mix(in srgb, var(--bg) 22%, transparent); }
.kanji-badge svg { width: 24px; height: 24px; }
/* Hide the host's "Powered by Netlify" badge (the owner asked for it gone). */
#nl-badge-frame, #netlify-badge-iframe, iframe[id*="badge"], div[class*="netlify-badge"] {
  display: none !important; visibility: hidden !important; opacity: 0 !important; pointer-events: none !important;
}
.card.chosen { border-color: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }

/* flashcards */
.flip { perspective: 1200px; cursor: pointer; outline: none; }
.flip-inner { display: grid; transition: transform .45s cubic-bezier(.3, .8, .3, 1); transform-style: preserve-3d; }
.flip.on .flip-inner { transform: rotateY(180deg); }
.flip.on { cursor: default; }
.flip-face { grid-area: 1 / 1; backface-visibility: hidden; -webkit-backface-visibility: hidden; display: grid; gap: 10px; place-content: center; justify-items: center; text-align: center;
  min-height: 260px; padding: 26px 18px; background: var(--surface); border: 1px solid var(--line); border-radius: 22px; box-shadow: 0 3px 0 var(--line); }
.flip-back { transform: rotateY(180deg); }
.flip-jp { font-size: 34px; line-height: 1.7; font-weight: 600; }
.flip-jp.small { font-size: 21px; }
.flip:focus-visible .flip-face { box-shadow: 0 0 0 3px var(--indigo-soft); }
.grade kbd { font: 700 11px var(--font); padding: 1px 5px; border-radius: 5px; background: var(--surface-2); color: var(--ink-2); margin-right: 2px; }
.card-btn:disabled { opacity: .5; }
@media (max-width: 520px) { .flip-jp { font-size: 28px; } .flip-face { min-height: 220px; } }
@media (prefers-reduced-motion: reduce) { .flip-inner { transition: none; } }
