/* ============================ tokens ============================ */
/*
 * Two themes. Dark is the default and lives in :root; the light palette
 * overrides the same variable names under [data-theme="light"]. Every colour
 * that differs between themes must be a variable here - hard-coded colours
 * below would break the light theme silently.
 */
:root {
  color-scheme: dark;

  --bg: #0e1016;
  --bg-glow: #1a1f30;
  --panel: #161923;
  --panel-2: #1c2030;
  --panel-3: #232838;
  --line: #272c3a;
  --line-soft: #202534;
  --txt: #e8eaf1;
  --dim: #98a0b5;
  --dim-2: #6c7488;
  --accent: #e35b66;
  --accent-soft: rgba(227, 91, 102, .14);
  --accent-ink: #ff9aa2;
  --info: #5b8def;
  --ok: #3ecf8e;
  --warn: #f0b429;
  --bad: #e35b66;

  --ink: #e8eaf1;
  --ghost: #3a4256;

  --chart-from: #4a5378;
  --chart-to: #333a54;
  --chart-now-from: #ef6f78;
  --chart-now-to: #b84550;

  --brand-from: #ef6f78;
  --brand-to: #c93f4c;
  --btn-from: #ef6f78;
  --btn-to: #d34553;
  --btn-edge: #e35b66;
  --on-accent: #fff;

  --toast-bg: #262b3b;
  --toast-ink: #e8eaf1;
  --banner-ink: #f5d9a0;
  --banner-ink-strong: #ffdf9e;
  --banner-bg: rgba(240, 180, 41, .08);
  --banner-edge: rgba(240, 180, 41, .35);

  --met-1: #a8414c;
  --met-2: #d99a2b;
  --met-3: #c9c04a;
  --met-4: #6fc78a;

  --ok-ink: #d8ffee;
  --bad-ink: #ffd9dc;

  --scrim: rgba(5, 7, 11, .72);
  --chrome: rgba(12, 14, 20, .7);
  --chrome-top: rgba(14, 16, 22, .82);
  --chrome-bottom: rgba(12, 14, 20, .96);

  --radius: 14px;
  --radius-sm: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Yu Gothic UI", Meiryo, sans-serif;
  --jp: "Yu Gothic", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Meiryo", sans-serif;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
}

[data-theme="light"] {
  color-scheme: light;

  --bg: #f5f6fb;
  --bg-glow: #ffffff;
  --panel: #ffffff;
  --panel-2: #f2f4fa;
  --panel-3: #e6eaf4;
  --line: #d5dae7;
  --line-soft: #e5e9f3;
  --txt: #161a26;
  --dim: #545c70;
  --dim-2: #7d8598;
  --accent: #cf4450;
  --accent-soft: rgba(207, 68, 80, .1);
  --accent-ink: #a92f3a;
  --info: #2f6fd0;
  --ok: #17915e;
  --warn: #a97400;
  --bad: #cf4450;

  --ink: #161a26;
  --ghost: #c3c9d8;

  --chart-from: #8f9cc0;
  --chart-to: #ccd4e6;
  --chart-now-from: #ef8b92;
  --chart-now-to: #cf4450;

  --brand-from: #e26874;
  --brand-to: #c23b47;
  --btn-from: #e26874;
  --btn-to: #c23b47;
  --btn-edge: #cf4450;
  --on-accent: #fff;

  --toast-bg: #2b3141;
  --toast-ink: #f3f5fa;
  --banner-ink: #6f5300;
  --banner-ink-strong: #523d00;
  --banner-bg: #fff6e0;
  --banner-edge: #f0c96a;

  --met-1: #bd3f4b;
  --met-2: #b07800;
  --met-3: #8a8500;
  --met-4: #2b9560;

  --ok-ink: #0a6b43;
  --bad-ink: #8d2731;

  --scrim: rgba(22, 27, 39, .42);
  --chrome: rgba(255, 255, 255, .82);
  --chrome-top: rgba(245, 246, 251, .9);
  --chrome-bottom: rgba(255, 255, 255, .97);

  --shadow: 0 10px 30px rgba(22, 30, 60, .12);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: radial-gradient(1200px 600px at 80% -10%, var(--bg-glow) 0%, var(--bg) 55%) no-repeat, var(--bg);
  color: var(--txt);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background-color .18s ease, color .18s ease;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; }

::selection { background: var(--accent); color: #fff; }

/* ============================ layout ============================ */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px;
  flex: 0 0 232px;
  padding: 18px 14px;
  border-right: 1px solid var(--line-soft);
  background: var(--chrome);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 22px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(145deg, var(--brand-from), var(--brand-to));
  display: grid; place-items: center;
  font-family: var(--jp); font-size: 19px; color: #fff;
  box-shadow: 0 4px 14px rgba(227, 91, 102, .3);
}
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: -.01em; }
.brand-sub { font-size: 11px; color: var(--dim-2); letter-spacing: .06em; text-transform: uppercase; }

.nav-group-label {
  font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--dim-2); padding: 14px 10px 6px;
}

.nav-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border: 0; border-radius: var(--radius-sm);
  background: transparent;
  color: var(--dim);
  text-align: left;
  font-size: 14px;
  transition: background .14s, color .14s;
}
.nav-item + .nav-item { margin-top: 2px; }
.nav-item .ico { font-size: 15px; width: 20px; text-align: center; opacity: .9; }
.nav-item:hover:not(:disabled) { background: var(--panel-2); color: var(--txt); }
.nav-item.active { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; box-shadow: inset 0 0 0 1px rgba(227, 91, 102, .35); }
.nav-item .soon {
  margin-left: auto;
  font-size: 9.5px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--dim-2); border: 1px solid var(--line); border-radius: 999px; padding: 1px 6px;
}
.nav-item:disabled { opacity: .45; cursor: not-allowed; }

.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 26px;
  border-bottom: 1px solid var(--line-soft);
  position: sticky; top: 0; z-index: 20;
  background: var(--chrome-top);
  backdrop-filter: blur(10px);
}
.topbar h1 { font-size: 17px; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 10px; border-radius: 999px;
  background: var(--panel-2); border: 1px solid var(--line);
  font-size: 12.5px; color: var(--dim);
}
.chip b { color: var(--txt); font-variant-numeric: tabular-nums; }
.chip.hot { border-color: rgba(240, 180, 41, .4); color: var(--warn); }

.icon-btn {
  width: 34px; height: 34px; display: grid; place-items: center;
  border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line);
  color: var(--dim); font-size: 15px;
}
.icon-btn:hover { color: var(--txt); border-color: var(--line); background: var(--panel-3); }

.banner-slot { padding: 0 26px; }

.view { padding: 24px 26px 60px; max-width: 1180px; width: 100%; margin: 0 auto; }

/* ============================ primitives ============================ */
.card {
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 18px;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--txt);
  font-size: 14px; font-weight: 550;
  transition: transform .1s, background .14s, border-color .14s;
}
.btn:hover { background: var(--panel-3); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: linear-gradient(145deg, var(--btn-from), var(--btn-to)); border-color: var(--btn-edge); color: var(--on-accent); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 6px 12px; font-size: 13px; border-radius: 9px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.spacer { flex: 1; }
.muted { color: var(--dim); }
.tiny { font-size: 12px; }
.center { text-align: center; }

.bar { height: 7px; border-radius: 999px; background: var(--panel-3); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--accent), var(--warn)); transition: width .4s ease; }
.bar.ok > i { background: linear-gradient(90deg, var(--ok), var(--ok)); }

/* ============================ kana: hero ============================ */
.hero {
  display: grid; grid-template-columns: 1fr auto; gap: 22px; align-items: center;
  background: linear-gradient(135deg, rgba(227, 91, 102, .10), rgba(91, 141, 239, .07)), var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 20px;
}
.hero h2 { font-size: 20px; margin-bottom: 4px; }
.hero .bar { margin-top: 12px; max-width: 460px; }
.hero-num { font-size: 13px; color: var(--dim); margin-top: 8px; font-variant-numeric: tabular-nums; }
.hero-badge {
  font-size: 11px; letter-spacing: .06em; text-transform: uppercase;
  padding: 3px 9px; border-radius: 999px; border: 1px solid var(--line); color: var(--dim);
}
.hero-badge.on { color: var(--ok); border-color: rgba(62, 207, 142, .45); background: rgba(62, 207, 142, .1); }
.gate-big { font-size: 34px; font-weight: 700; font-variant-numeric: tabular-nums; text-align: center; line-height: 1; }
.gate-big small { display: block; font-size: 11px; color: var(--dim-2); letter-spacing: .08em; text-transform: uppercase; margin-top: 6px; font-weight: 500; }

/* ============================ kana: mode cards ============================ */
.mode-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 22px; }
.mode-card {
  text-align: left; padding: 15px 16px;
  border-radius: var(--radius); border: 1px solid var(--line-soft);
  background: var(--panel); color: var(--txt);
  transition: border-color .14s, transform .12s, background .14s;
}
.mode-card:hover { border-color: rgba(227, 91, 102, .5); transform: translateY(-2px); background: var(--panel-2); }
.mode-card .m-ico { font-size: 20px; }
.mode-card .m-name { font-weight: 650; margin-top: 8px; font-size: 15px; }
.mode-card .m-desc { font-size: 12px; color: var(--dim); margin-top: 2px; }
.mode-card .m-meta { font-size: 11.5px; color: var(--dim-2); margin-top: 8px; font-variant-numeric: tabular-nums; }

/* ============================ kana: grid ============================ */
.section-head { display: flex; align-items: baseline; gap: 10px; margin: 26px 0 10px; }
.section-head h3 { font-size: 14.5px; }
.section-head .count { font-size: 12px; color: var(--dim-2); }

.kana-group { border: 1px solid var(--line-soft); border-radius: var(--radius); background: var(--panel); padding: 14px; width: fit-content; max-width: 100%; }
.kana-row { display: flex; align-items: center; gap: 6px; }
.kana-row + .kana-row { margin-top: 6px; }
.kana-row-label { width: 34px; flex: 0 0 34px; font-size: 11px; color: var(--dim-2); letter-spacing: .04em; }
.kana-cells { display: flex; gap: 6px; flex-wrap: wrap; }

.kana-cell {
  position: relative;
  width: 60px; height: 66px;
  border-radius: 10px;
  border: 1px solid var(--line-soft);
  background: var(--panel-2);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1px;
  padding: 0;
  transition: transform .1s, border-color .14s, background .14s;
  overflow: hidden;
}
.kana-cell:hover { transform: translateY(-2px); border-color: rgba(255, 255, 255, .22); background: var(--panel-3); }
.kana-cell.spacer { background: transparent; border-color: transparent; pointer-events: none; }
.kana-cell.spacer:hover { transform: none; }
.kana-char { font-family: var(--jp); font-size: 25px; line-height: 1.1; }
.kana-cell.youon .kana-char { font-size: 21px; }
.kana-cell .r { font-size: 10.5px; color: var(--dim-2); letter-spacing: .02em; }
.kana-cell .meter { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: transparent; }
.kana-cell .meter > i { display: block; height: 100%; width: 0; }

.kana-cell[data-box="1"] .meter > i { background: var(--met-1); }
.kana-cell[data-box="2"] .meter > i { background: var(--met-2); }
.kana-cell[data-box="3"] .meter > i { background: var(--met-3); }
.kana-cell[data-box="4"] .meter > i { background: var(--met-4); }
.kana-cell[data-box="5"] { border-color: rgba(62, 207, 142, .35); }
.kana-cell[data-box="5"] .meter > i { background: var(--ok); }

/* ============================ drill ============================ */
.drill-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.seg { display: inline-flex; background: var(--panel-2); border: 1px solid var(--line); border-radius: 11px; padding: 3px; gap: 2px; }
.seg button {
  border: 0; background: transparent; color: var(--dim);
  padding: 6px 12px; border-radius: 8px; font-size: 13px;
}
.seg button.on { background: var(--panel-3); color: var(--txt); box-shadow: 0 1px 4px rgba(0, 0, 0, .3); }
.drill-progress { flex: 1; min-width: 120px; max-width: 260px; }

.drill-card {
  background: var(--panel); border: 1px solid var(--line-soft);
  border-radius: 18px; padding: 34px 22px;
  min-height: 340px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px;
  position: relative;
}
.drill-card.correct { border-color: rgba(62, 207, 142, .6); box-shadow: 0 0 0 1px rgba(62, 207, 142, .3), 0 0 40px rgba(62, 207, 142, .09); }
.drill-card.wrong { border-color: rgba(227, 91, 102, .6); box-shadow: 0 0 0 1px rgba(227, 91, 102, .3); }

.q-kana { font-family: var(--jp); font-size: clamp(64px, 13vw, 104px); line-height: 1.05; }
.q-romaji { font-size: clamp(30px, 6vw, 46px); font-weight: 650; letter-spacing: .02em; font-family: var(--font); }
.q-label { font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--dim-2); }
.q-hint { font-size: 12.5px; color: var(--dim-2); min-height: 18px; }

.answer-input {
  width: min(320px, 100%);
  padding: 13px 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  text-align: center;
  font-size: 19px;
  letter-spacing: .04em;
  outline: none;
  transition: border-color .14s, box-shadow .14s;
}
.answer-input:focus { border-color: rgba(227, 91, 102, .7); box-shadow: 0 0 0 3px rgba(227, 91, 102, .15); }
.answer-input.big { font-family: var(--jp); font-size: 24px; }

.kana-preview {
  font-family: var(--jp); font-size: 30px; min-height: 38px; color: var(--txt);
  letter-spacing: .06em;
}

.options { display: grid; grid-template-columns: repeat(2, minmax(110px, 1fr)); gap: 10px; width: min(420px, 100%); }
.opt {
  padding: 16px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  font-family: var(--jp);
  font-size: 30px;
  transition: transform .1s, border-color .14s, background .14s;
}
.opt:hover:not(:disabled) { border-color: rgba(255, 255, 255, .25); background: var(--panel-3); transform: translateY(-1px); }
.opt.good { border-color: var(--ok); background: rgba(62, 207, 142, .14); color: var(--ok-ink); }
.opt.bad { border-color: var(--bad); background: rgba(227, 91, 102, .12); color: var(--bad-ink); }
.opt:disabled { cursor: default; }

.speaker {
  width: 84px; height: 84px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--panel-2);
  font-size: 30px; display: grid; place-items: center;
  transition: transform .1s, background .14s;
}
.speaker:hover { background: var(--panel-3); transform: scale(1.04); }
.speaker.playing { animation: pulse .9s ease infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(227, 91, 102, .4); } 50% { box-shadow: 0 0 0 14px rgba(227, 91, 102, 0); } }

.feedback { min-height: 30px; font-size: 14.5px; font-weight: 550; }
.feedback.ok { color: var(--ok); }
.feedback.no { color: var(--bad); }
.feedback .detail { color: var(--dim); font-weight: 400; }

.summary { text-align: center; display: flex; flex-direction: column; gap: 14px; align-items: center; }
.summary .score { font-size: 54px; font-weight: 700; line-height: 1; }
.summary .score small { font-size: 18px; color: var(--dim); font-weight: 500; }
.summary-stats { display: flex; gap: 22px; justify-content: center; }
.summary-stats div { font-variant-numeric: tabular-nums; }
.summary-stats b { display: block; font-size: 20px; }
.summary-stats span { font-size: 11.5px; color: var(--dim-2); letter-spacing: .06em; text-transform: uppercase; }

/* ============================ strokes / trace ============================ */
.stroke-box { display: flex; align-items: flex-end; justify-content: center; gap: 4px; }
.stroke-box.composed { gap: 0; }
.stroke-char { width: 168px; height: 168px; }
.stroke-char.follower { width: 112px; height: 112px; margin-left: -14px; margin-bottom: -6px; }
.stroke-svg { width: 100%; height: 100%; display: block; }
.stroke-svg path {
  fill: none; stroke: var(--ink); stroke-width: 4.2;
  stroke-linecap: round; stroke-linejoin: round;
}
.stroke-svg.ghost path { stroke: var(--ghost); stroke-width: 4.2; }

.trace-wrap { position: relative; width: min(300px, 78vw); aspect-ratio: 1 / 1; margin: 0 auto; }
.trace-wrap .stroke-box { position: absolute; inset: 0; gap: 0; align-items: flex-end; justify-content: center; }
.trace-wrap .stroke-char { width: 100%; height: 100%; }
.trace-wrap .stroke-box.composed .stroke-char { width: 78%; height: 78%; }
.trace-wrap .stroke-char.follower { width: 52%; height: 52%; margin-left: -6%; margin-bottom: 2%; }
.trace-wrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }

/* ============================ modal ============================ */
.modal-root { position: fixed; inset: 0; z-index: 100; display: none; }
.modal-root.open { display: block; }
.modal-backdrop { position: absolute; inset: 0; background: var(--scrim); backdrop-filter: blur(3px); animation: fade .16s ease; }
.modal {
  position: relative; z-index: 1;
  margin: max(6vh, 20px) auto;
  width: min(560px, calc(100% - 32px));
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  animation: pop .18s ease;
  max-height: 86vh; overflow-y: auto;
}
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.985); } }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--line-soft); }
.modal-head h3 { font-size: 15.5px; }
.modal-body { padding: 18px; }
.modal-foot { padding: 14px 18px; border-top: 1px solid var(--line-soft); display: flex; gap: 10px; justify-content: flex-end; }

.detail-top { display: flex; align-items: center; gap: 18px; margin-bottom: 18px; }
.detail-kana { font-family: var(--jp); font-size: 64px; line-height: 1; }
.detail-meta { display: flex; flex-direction: column; gap: 3px; }
.detail-meta .r { font-size: 20px; font-weight: 600; }
.detail-meta .s { font-size: 12px; color: var(--dim); }
.kv { display: flex; gap: 8px; font-size: 12.5px; color: var(--dim); }
.kv b { color: var(--txt); font-variant-numeric: tabular-nums; font-weight: 600; }
.label { font-size: 11px; letter-spacing: .09em; text-transform: uppercase; color: var(--dim-2); margin-bottom: 8px; }

/* settings form */
.field { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 11px 0; border-bottom: 1px solid var(--line-soft); }
.field:last-child { border-bottom: 0; }
.field-label { font-size: 14px; }
.field-label small { display: block; color: var(--dim-2); font-size: 11.5px; font-weight: 400; }
.field input[type="number"], .field select {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px;
  padding: 7px 10px; font-size: 13.5px; min-width: 96px;
}

/* ============================ banner / toast ============================ */
.banner {
  display: flex; gap: 12px; align-items: flex-start;
  margin-top: 14px; padding: 13px 15px;
  border-radius: var(--radius);
  border: 1px solid var(--banner-edge);
  background: var(--banner-bg);
  font-size: 13.5px; color: var(--banner-ink);
}
.banner b { color: var(--banner-ink-strong); }
.banner .x { margin-left: auto; background: transparent; border: 0; color: inherit; opacity: .6; font-size: 15px; }
.banner code { background: rgba(0, 0, 0, .3); padding: 1px 5px; border-radius: 5px; font-size: 12px; }

.toast-wrap { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  background: var(--toast-bg); border: 1px solid var(--line); color: var(--toast-ink);
  padding: 10px 16px; border-radius: 999px; font-size: 13.5px;
  box-shadow: var(--shadow); animation: toastIn .2s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } }

/* ============================ placeholder page ============================ */
.soon-page { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; min-height: 52vh; text-align: center; }
.soon-page .glyph { font-family: var(--jp); font-size: 64px; opacity: .25; }
.soon-page p { color: var(--dim); max-width: 420px; margin: 0; }

/* ============================ lesson ============================ */
.bab-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.bab-row {
  display: flex; align-items: center; gap: 12px;
  width: 100%; text-align: left;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-soft);
  background: var(--panel);
  color: var(--txt);
  transition: border-color .14s, background .14s, transform .1s;
}
button.bab-row:hover { border-color: rgba(227, 91, 102, .45); background: var(--panel-2); transform: translateX(2px); }
.bab-row.locked { opacity: .55; }
.bab-no {
  flex: 0 0 30px; width: 30px; height: 30px; border-radius: 9px;
  display: grid; place-items: center;
  background: var(--panel-2); border: 1px solid var(--line);
  font-size: 12.5px; color: var(--dim); font-variant-numeric: tabular-nums;
}
.bab-mid { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.bab-jp { font-family: var(--jp); font-size: 14.5px; }
.bab-id { font-size: 11.5px; color: var(--dim-2); }
.bab-right { margin-left: auto; flex: 0 0 auto; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; letter-spacing: .04em;
  padding: 3px 9px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--dim);
  background: var(--panel-2);
}
.badge.ok { color: var(--ok); border-color: rgba(62, 207, 142, .4); background: rgba(62, 207, 142, .1); }
.ok-text { color: var(--ok); }

/* bab header */
.bab-head { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 16px; flex-wrap: wrap; }
.bab-title { flex: 1; min-width: 200px; }
.bab-title h2 { font-size: 21px; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-top: 2px; }
.bab-title h2 .jp { font-family: var(--jp); }
.bab-title h2 .id { font-size: 14px; color: var(--dim); font-weight: 500; }
.bab-status { align-self: center; }

.goal-card { margin-bottom: 6px; background: linear-gradient(135deg, rgba(91, 141, 239, .09), transparent), var(--panel); }
.goal-card p { margin: 0; font-size: 14px; color: var(--txt); line-height: 1.6; }

.jp-inline { font-family: var(--jp); color: var(--dim); font-weight: 500; }

/* bunkei */
.bunkei-list { display: flex; flex-direction: column; gap: 8px; }
.bunkei-card { background: var(--panel); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 14px 16px; }
.bunkei-top { display: flex; align-items: flex-start; gap: 12px; }
.bunkei-no {
  flex: 0 0 26px; width: 26px; height: 26px; border-radius: 8px;
  display: grid; place-items: center; font-size: 11px; font-weight: 600;
  background: var(--accent-soft); color: var(--accent-ink); border: 1px solid rgba(227, 91, 102, .3);
}
.bunkei-txt { flex: 1; min-width: 0; }
.bunkei-jp { font-family: var(--jp); font-size: 18px; line-height: 1.5; }
.bunkei-romaji { font-size: 12.5px; color: var(--dim); margin-top: 1px; }
.bunkei-arti { font-size: 13.5px; color: var(--txt); margin-top: 4px; }
.bunkei-note {
  margin-top: 10px; padding: 9px 12px;
  border-radius: 9px; background: var(--panel-2);
  font-size: 12.5px; color: var(--dim); line-height: 1.55;
  border-left: 2px solid rgba(91, 141, 239, .5);
}

/* reibun */
.reibun-list { background: var(--panel); border: 1px solid var(--line-soft); border-radius: var(--radius); overflow: hidden; }
.reibun-row { display: flex; align-items: flex-start; gap: 12px; padding: 11px 16px; border-bottom: 1px solid var(--line-soft); }
.reibun-row:last-child { border-bottom: 0; }
.reibun-row:hover { background: var(--panel-2); }
.reibun-body { flex: 1; min-width: 0; }
.reibun-jp { font-family: var(--jp); font-size: 15.5px; }
.reibun-romaji { font-size: 12px; color: var(--dim-2); }
.reibun-arti { font-size: 13px; color: var(--dim); margin-top: 2px; }

/* kaiwa */
.kaiwa-card { background: var(--panel); border: 1px solid var(--line-soft); border-radius: var(--radius); overflow: hidden; }
.kaiwa-top {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 16px; border-bottom: 1px solid var(--line-soft);
  background: var(--panel-2);
}
.kaiwa-top > div { flex: 1; }
.kaiwa-title { font-family: var(--jp); font-size: 15px; }
.kaiwa-line { display: flex; align-items: flex-start; gap: 11px; padding: 11px 16px; border-bottom: 1px solid var(--line-soft); }
.kaiwa-line:last-child { border-bottom: 0; }
.kaiwa-who {
  flex: 0 0 22px; width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center; font-size: 11px; font-weight: 600;
  background: var(--panel-3); color: var(--dim); margin-top: 2px;
}
.kaiwa-body { flex: 1; min-width: 0; }
.kaiwa-jp { font-family: var(--jp); font-size: 15px; }
.kaiwa-romaji { font-size: 11.5px; color: var(--dim-2); }
.kaiwa-arti { font-size: 12.5px; color: var(--dim); margin-top: 2px; }

/* vocab table */
.vocab-card { padding: 16px; }
.vocab-table { margin-top: 10px; border-top: 1px solid var(--line-soft); }
.vocab-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 2px; border-bottom: 1px solid var(--line-soft);
}
.vocab-row:last-child { border-bottom: 0; }
.vocab-jp { flex: 0 0 150px; display: flex; flex-direction: column; }
.vocab-jp .w { font-family: var(--jp); font-size: 16px; }
.vocab-jp .k { font-family: var(--jp); font-size: 10.5px; color: var(--dim-2); }
.vocab-romaji { flex: 0 0 120px; font-size: 12px; color: var(--dim-2); }
.vocab-arti { flex: 1; min-width: 0; font-size: 13px; color: var(--dim); }
.vocab-row .meter { position: relative; flex: 0 0 44px; height: 3px; background: var(--panel-3); border-radius: 999px; overflow: hidden; }
.vocab-row .meter > i { display: block; height: 100%; background: var(--ok); }
.vocab-row[data-box="0"] .meter > i { background: transparent; }
.vocab-row[data-box="1"] .meter > i { background: var(--met-1); }
.vocab-row[data-box="2"] .meter > i { background: var(--met-2); }
.icon-btn.sm { width: 28px; height: 28px; font-size: 12px; border-radius: 8px; }

/* options with text instead of kana */
.opt.text {
  font-family: var(--font);
  font-size: 14.5px;
  font-weight: 500;
  padding: 15px 12px;
  line-height: 1.35;
}
.vocab-options { grid-template-columns: 1fr; width: min(440px, 100%); }
.vocab-options .opt.text { text-align: left; padding: 13px 16px; }
.renshuu-q { font-family: var(--jp); font-size: 24px; text-align: center; line-height: 1.5; max-width: 620px; }
.renshuu-options { grid-template-columns: repeat(2, minmax(0, 1fr)); width: min(520px, 100%); }
.renshuu-options .opt.text { font-family: var(--jp); font-size: 17px; }

@media (max-width: 860px) {
  .vocab-jp { flex-basis: 118px; }
  .vocab-romaji { flex-basis: 92px; }
  .bab-head { gap: 10px; }
  .bab-title h2 { font-size: 18px; }
  .renshuu-q { font-size: 20px; }
}
@media (max-width: 520px) {
  .vocab-romaji { display: none; }
  .vocab-jp { flex-basis: 96px; }
  .renshuu-options { grid-template-columns: 1fr; }
  .kaiwa-line, .reibun-row { padding: 10px 12px; }
}

/* ============================ srs ============================ */
.srs-start { margin-bottom: 6px; }
.srs-types { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px; }
.srs-type {
  background: var(--panel); border: 1px solid var(--line-soft);
  border-radius: var(--radius); padding: 14px 16px;
}
.srs-type-top { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.srs-type-icon {
  width: 26px; height: 26px; border-radius: 8px;
  display: grid; place-items: center;
  background: var(--panel-2); border: 1px solid var(--line);
  font-family: var(--jp); font-size: 13px; color: var(--dim);
}
.srs-type-name { font-size: 14px; font-weight: 600; }
.srs-type-top .badge { margin-left: auto; }
.badge.hot { color: var(--warn); border-color: rgba(240,180,41,.4); background: rgba(240,180,41,.1); }
.srs-type-nums { font-size: 11.5px; color: var(--dim-2); margin-top: 8px; font-variant-numeric: tabular-nums; }
.srs-type-nums b { color: var(--txt); font-size: 13px; }

.forecast { padding: 16px 18px 8px; }
.forecast-bars { display: flex; align-items: flex-end; gap: 8px; height: 130px; }
.forecast-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 3px; }
.forecast-bar {
  width: 100%; max-width: 46px; min-height: 3px;
  border-radius: 6px 6px 2px 2px;
  background: linear-gradient(180deg, var(--chart-from), var(--chart-to));
  transition: height .3s ease;
}
.forecast-bar.now { background: linear-gradient(180deg, var(--chart-now-from), var(--chart-now-to)); }
.forecast-n { font-size: 11.5px; font-variant-numeric: tabular-nums; color: var(--txt); }
.forecast-d { font-size: 10px; color: var(--dim-2); letter-spacing: .02em; }

.srs-rules { margin: 0; padding-left: 18px; font-size: 13px; color: var(--dim); line-height: 1.8; }
.srs-rules li::marker { color: var(--accent); }

.card-tag { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.q-jp { font-family: var(--jp); font-size: clamp(30px, 6vw, 44px); line-height: 1.25; text-align: center; }
.q-kanji { font-family: var(--jp); font-size: clamp(78px, 15vw, 120px); line-height: 1.05; }
.opt.text.jp { font-family: var(--jp); font-size: 17px; }

/* ============================ kanji ============================ */
.kanji-filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.chip-btn {
  padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--panel);
  color: var(--dim); font-size: 12.5px;
  transition: background .14s, color .14s, border-color .14s;
}
.chip-btn:hover { background: var(--panel-2); color: var(--txt); }
.chip-btn.on { background: var(--accent-soft); color: var(--accent-ink); border-color: rgba(227,91,102,.45); }

.kanji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.kanji-cell {
  position: relative; overflow: hidden;
  padding: 12px 6px 14px;
  border-radius: 11px;
  border: 1px solid var(--line-soft);
  background: var(--panel);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  transition: transform .1s, border-color .14s, background .14s;
}
.kanji-cell:hover { transform: translateY(-2px); border-color: rgba(255,255,255,.22); background: var(--panel-2); }
.kanji-char { font-family: var(--jp); font-size: 30px; line-height: 1.1; }
.kanji-arti { font-size: 10px; color: var(--dim-2); text-align: center; line-height: 1.2; padding: 0 2px; }
.kanji-cell .meter { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: transparent; }
.kanji-cell .meter > i { display: block; height: 100%; width: 0; }
.kanji-cell[data-box="1"] .meter > i { background: var(--met-1); }
.kanji-cell[data-box="2"] .meter > i { background: var(--met-2); }
.kanji-cell[data-box="3"] .meter > i { background: var(--met-3); }
.kanji-cell[data-box="4"] .meter > i { background: var(--met-4); }
.kanji-cell[data-box="5"] { border-color: rgba(62,207,142,.35); }
.kanji-cell[data-box="5"] .meter > i { background: var(--ok); }

.kanji-detail-top { display: flex; gap: 16px; align-items: flex-start; margin-bottom: 16px; }
.kanji-detail-char {
  width: 96px; height: 96px; flex: 0 0 96px;
  border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line);
  display: grid; place-items: center;
  font-family: var(--jp); font-size: 56px; line-height: 1;
}
.kanji-detail-meta { flex: 1; min-width: 0; }
.kanji-detail-arti { font-size: 17px; font-weight: 600; margin-bottom: 4px; }
.kanji-readings { margin-top: 10px; display: flex; flex-direction: column; gap: 4px; }
.reading-row { display: flex; gap: 10px; font-size: 13px; }
.reading-label { flex: 0 0 88px; color: var(--dim-2); font-size: 11.5px; letter-spacing: .02em; }
.reading-val { color: var(--txt); }
.reading-val.jp { font-family: var(--jp); }
.kanji-stroke { background: var(--panel-2); display: flex; justify-content: center; padding: 16px; }
.kanji-words { display: flex; flex-direction: column; border: 1px solid var(--line-soft); border-radius: var(--radius-sm); overflow: hidden; }
.kanji-word { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--line-soft); background: var(--panel); }
.kanji-word:last-child { border-bottom: 0; }
.kanji-word-main { flex: 0 0 120px; display: flex; flex-direction: column; }
.kanji-word-main .w { font-size: 15px; }
.kanji-word-main .k { font-size: 10.5px; color: var(--dim-2); }
.kanji-word-arti { flex: 1; min-width: 0; font-size: 12.5px; color: var(--dim); }

@media (max-width: 860px) {
  .kanji-grid { grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); }
  .kanji-char { font-size: 26px; }
  .kanji-detail-char { width: 76px; height: 76px; flex-basis: 76px; font-size: 44px; }
  .forecast-bars { height: 104px; gap: 5px; }
  .reading-label { flex-basis: 76px; }
}
@media (max-width: 520px) {
  .srs-types { grid-template-columns: 1fr; }
  .kanji-worker-main { flex-basis: 96px; }
  .kanji-word-main { flex-basis: 92px; }
}

/* ============================ grammar ============================ */
.particle-ref { display: flex; flex-direction: column; border: 1px solid var(--line-soft); border-radius: var(--radius); overflow: hidden; background: var(--panel); }
.particle-row { display: flex; align-items: baseline; gap: 12px; padding: 9px 16px; border-bottom: 1px solid var(--line-soft); }
.particle-row:last-child { border-bottom: 0; }
.particle-row:hover { background: var(--panel-2); }
.particle-char { flex: 0 0 44px; font-size: 20px; color: var(--accent); }
.particle-meaning { flex: 1; min-width: 0; font-size: 13px; color: var(--txt); }
.particle-note { font-size: 11.5px; color: var(--dim-2); }

.q-sentence { font-family: var(--jp); font-size: clamp(20px, 4vw, 28px); text-align: center; line-height: 1.7; max-width: 660px; }
.q-sentence .blank { color: var(--accent); font-weight: 600; }
.particle-options { grid-template-columns: repeat(4, minmax(0, 1fr)); width: min(460px, 100%); }
.particle-options .opt { font-family: var(--jp); font-size: 22px; }

.form-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; margin-top: 16px; }
.form-stat { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; }
.form-stat-jp { font-size: 16px; margin-bottom: 1px; }
.form-stat-id { font-size: 11px; color: var(--dim-2); margin-bottom: 8px; }

.verb-select {
  width: 100%; padding: 11px 14px; margin-bottom: 14px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
  font-size: 14px;
}
.verb-card { padding: 16px 18px; }
.verb-dict { font-size: 26px; font-weight: 600; }
.verb-forms { margin-top: 14px; border-top: 1px solid var(--line-soft); }
.verb-form-row { display: flex; align-items: center; gap: 12px; padding: 9px 2px; border-bottom: 1px solid var(--line-soft); }
.verb-form-row:last-child { border-bottom: 0; }
.verb-form-label { flex: 0 0 210px; display: flex; flex-direction: column; gap: 1px; }
.verb-form-label .jp { font-size: 14px; }
.verb-form-val { flex: 1; font-size: 18px; color: var(--txt); }

/* ============================ shadowing ============================ */
.shadow-card { padding: 0; overflow: hidden; }
.shadow-top { display: flex; align-items: center; gap: 12px; padding: 13px 16px; border-bottom: 1px solid var(--line-soft); background: var(--panel-2); }
.shadow-top > div { flex: 1; }
.shadow-line { display: flex; align-items: flex-start; gap: 12px; padding: 18px 16px; }
.shadow-line-txt { flex: 1; min-width: 0; }
.shadow-line-txt .kaiwa-jp { font-size: 20px; line-height: 1.6; }
.shadow-actions { padding: 0 16px 14px; }
.shadow-clip { padding: 0 16px 14px; }
.shadow-nav { padding: 12px 16px; border-top: 1px solid var(--line-soft); background: var(--panel-2); }
.shadow-model { font-family: var(--jp); font-size: 20px; line-height: 1.6; padding: 12px 14px; background: var(--panel-2); border-radius: var(--radius-sm); border: 1px solid var(--line); margin-bottom: 14px; }
.shadow-status { display: flex; align-items: center; gap: 9px; justify-content: center; font-size: 13.5px; color: var(--dim); }
.rec-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--dim-2); flex: 0 0 9px; }
.rec-dot.on { background: var(--accent); animation: recPulse 1s ease infinite; }
.rec-dot.bad { background: var(--warn); }
@keyframes recPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(227, 91, 102, .5); }
  50% { box-shadow: 0 0 0 9px rgba(227, 91, 102, 0); }
}

/* ============================ quiz ============================ */
.quiz-row { display: flex; align-items: center; gap: 12px; padding: 10px 14px; cursor: default; }
.quiz-row:hover { transform: none; background: var(--panel); }
.quiz-meter { display: flex; align-items: center; gap: 8px; flex: 0 0 132px; }
.quiz-meter .bar { flex: 1; }
.quiz-meter .tiny { min-width: 38px; text-align: right; font-variant-numeric: tabular-nums; }

@media (max-width: 860px) {
  .verb-form-label { flex-basis: 150px; }
  .verb-form-val { font-size: 16px; }
  .particle-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .quiz-meter { flex-basis: 100px; }
  .shadow-line { padding: 14px 12px; }
  .shadow-line-txt .kaiwa-jp { font-size: 17px; }
}
@media (max-width: 520px) {
  .verb-form-label { flex-basis: 116px; }
  .particle-char { flex-basis: 34px; font-size: 18px; }
  .quiz-row { flex-wrap: wrap; }
  .quiz-meter { flex-basis: 100%; order: 3; }
}

/* ============================ ringkasan ============================ */
.dash-hero .bar { max-width: 100%; }

.plan-list { display: flex; flex-direction: column; gap: 8px; }
.plan-step {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--line-soft);
  background: var(--panel);
  transition: border-color .14s, background .14s;
}
.plan-step.first { border-color: rgba(227, 91, 102, .4); background: linear-gradient(135deg, rgba(227,91,102,.07), transparent), var(--panel); }
.plan-step:hover { background: var(--panel-2); }
.plan-num {
  flex: 0 0 26px; width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums;
  background: var(--panel-3); border: 1px solid var(--line); color: var(--dim);
}
.plan-step.first .plan-num { background: var(--accent-soft); border-color: rgba(227,91,102,.45); color: var(--accent-ink); }
.plan-body { flex: 1; min-width: 0; }
.plan-title { font-size: 14.5px; font-weight: 600; margin-bottom: 2px; }
.plan-meta { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }

.mod-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(196px, 1fr)); gap: 10px; }
.mod-tile {
  text-align: left; padding: 13px 15px;
  border-radius: var(--radius); border: 1px solid var(--line-soft);
  background: var(--panel); color: var(--txt);
  display: flex; flex-direction: column; gap: 8px;
  transition: border-color .14s, background .14s, transform .1s;
}
.mod-tile:hover { border-color: rgba(255,255,255,.2); background: var(--panel-2); transform: translateY(-1px); }
.mod-top { display: flex; align-items: center; gap: 8px; }
.mod-icon {
  width: 24px; height: 24px; border-radius: 7px; flex: 0 0 24px;
  display: grid; place-items: center;
  background: var(--panel-2); border: 1px solid var(--line);
  font-family: var(--jp); font-size: 12px; color: var(--dim);
}
.mod-name { font-size: 13px; font-weight: 600; }
.mod-value { margin-left: auto; font-size: 12px; color: var(--dim); font-variant-numeric: tabular-nums; }

.act-bars { display: flex; align-items: flex-end; gap: 5px; height: 92px; margin-bottom: 10px; }
.act-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; }
.act-bar { width: 100%; border-radius: 4px 4px 2px 2px; background: linear-gradient(180deg, var(--chart-from), var(--chart-to)); transition: height .3s ease; }
.act-bar.empty { background: var(--panel-3); }
.act-bar.today { background: linear-gradient(180deg, var(--chart-now-from), var(--chart-now-to)); }
.act-d { font-size: 9.5px; color: var(--dim-2); font-variant-numeric: tabular-nums; }
.act-stats { font-size: 12px; color: var(--dim-2); }
.act-stats b { color: var(--txt); }

/* ============================ accessibility ============================ */
:focus-visible {
  outline: 2px solid var(--info);
  outline-offset: 2px;
  border-radius: 6px;
}
button:focus-visible, .kana-cell:focus-visible, .kanji-cell:focus-visible { outline-offset: 2px; }
.answer-input:focus-visible { outline: none; }

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.kbd-hint { font-size: 11px; color: var(--dim-2); }
.kbd {
  display: inline-grid; place-items: center;
  min-width: 17px; height: 17px; padding: 0 4px;
  font-size: 10px; font-family: var(--font);
  border-radius: 4px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--dim);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ============================ responsive ============================ */
@media (max-width: 860px) {
  .plan-step { flex-wrap: wrap; gap: 10px; }
  .plan-body { flex: 1 1 60%; }
  .plan-meta { flex: 1 1 100%; justify-content: flex-end; }
  .mod-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .act-bars { gap: 3px; }
  .act-d { font-size: 8.5px; }
}
@media (max-width: 520px) {
  .mod-grid { grid-template-columns: 1fr; }
  .act-d { display: none; }
}

@media (max-width: 860px) {
  .app { flex-direction: column; }
  .sidebar {
    position: fixed; bottom: 0; left: 0; right: 0; top: auto;
    width: 100%; height: auto; flex: none;
    display: flex; gap: 4px; padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
    border-right: 0; border-top: 1px solid var(--line);
    background: var(--chrome-bottom);
    overflow-x: auto; overflow-y: hidden;
    z-index: 50;
    scrollbar-width: none;
  }
  .sidebar::-webkit-scrollbar { display: none; }
  .brand, .nav-group-label { display: none; }
  .nav-item {
    flex: 0 0 auto; width: auto; flex-direction: column; gap: 3px;
    padding: 7px 11px; font-size: 10.5px; min-width: 60px; text-align: center;
    justify-content: center;
  }
  .nav-item .ico { font-size: 17px; width: auto; }
  .nav-item .nav-label { display: block; white-space: nowrap; }
  .nav-item .soon { display: none; }
  .content { width: 100%; }
  .view { padding: 18px 16px 104px; }
  .topbar { padding: 12px 16px; }
  .topbar h1 { font-size: 15.5px; }
  .banner-slot { padding: 0 16px; }
  .hero { grid-template-columns: 1fr; gap: 14px; }
  .gate-big { text-align: left; }
  .gate-big small { text-align: left; }
  .kana-cell { width: 50px; height: 58px; }
  .kana-char { font-size: 21px; }
  .kana-cell.youon .kana-char { font-size: 17px; }
  .kana-row { gap: 4px; }
  .kana-cells { gap: 4px; }
  .kana-row-label { width: 22px; flex-basis: 22px; font-size: 9.5px; }
  .kana-group { padding: 10px 8px; }
  .mode-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .drill-card { padding: 26px 14px; min-height: 300px; }
  .summary-stats { gap: 16px; }
}

@media (max-width: 520px) {
  .kana-cell { width: 46px; height: 54px; }
  .kana-char { font-size: 19px; }
  .kana-cell.youon .kana-char { font-size: 15px; }
  .kana-cell .r { font-size: 9px; }
  .kana-row-label { display: none; }
  .hero h2 { font-size: 18px; }
}

/* ------------------------------ level picker ------------------------------ */
.level-choices { display: grid; gap: 10px; margin-top: 14px; }
.level-choice {
  display: block; width: 100%; text-align: left; cursor: pointer; font: inherit;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel-2);
  color: var(--txt);
  transition: border-color .14s, background .14s, transform .1s;
}
.level-choice:hover { background: var(--panel-3); border-color: var(--accent); }
.level-choice:active { transform: translateY(1px); }
.level-choice.on { border-color: var(--accent); background: var(--accent-soft); }
.level-choice b { display: block; font-size: 15px; color: var(--txt); }
.level-choice span { display: block; margin-top: 3px; font-size: 12px; color: var(--dim); }
.level-choice.on b { color: var(--accent-ink); }

/* ------------------------------- auth screen ------------------------------ */
html.auth-on, html.auth-on body { overflow: hidden; }
.auth-root {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 22px;
  background:
    radial-gradient(1100px 520px at 50% -12%, var(--bg-glow), transparent 70%),
    var(--bg);
  overflow-y: auto;
}
.auth-card {
  width: 100%; max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.auth-mark {
  width: 44px; height: 44px; flex: 0 0 44px;
  display: grid; place-items: center;
  border-radius: 12px;
  background: linear-gradient(145deg, var(--brand-from), var(--brand-to));
  color: #fff; font-size: 24px; font-family: var(--jp);
}
.auth-name { font-size: 17px; font-weight: 650; letter-spacing: -.01em; }
.auth-tag { font-size: 11.5px; color: var(--dim-2); }

.auth-tabs { display: flex; gap: 6px; background: var(--panel-2); border-radius: 10px; padding: 4px; margin-bottom: 16px; }
.auth-tab {
  flex: 1; padding: 8px 10px; border: 0; border-radius: 7px; cursor: pointer;
  background: transparent; color: var(--dim); font: inherit; font-size: 13.5px; font-weight: 550;
}
.auth-tab:hover { color: var(--txt); }
.auth-tab.on { background: var(--panel-3); color: var(--txt); }

.auth-form { display: grid; gap: 12px; }
.auth-field { display: grid; gap: 5px; }
.auth-label { font-size: 12.5px; color: var(--dim); }
.auth-field small { font-size: 11px; color: var(--dim-2); }
.auth-field input {
  width: 100%; padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--txt);
  font: inherit; font-size: 14px;
}
.auth-field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.auth-check { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--dim); cursor: pointer; }
.auth-check input { accent-color: var(--accent); }

.auth-error {
  padding: 9px 11px; border-radius: var(--radius-sm);
  background: rgba(227, 91, 102, .12);
  border: 1px solid rgba(227, 91, 102, .4);
  color: var(--bad-ink);
  font-size: 12.5px;
}
.auth-submit { width: 100%; margin-top: 4px; }

.auth-foot { margin-top: 14px; font-size: 11.5px; color: var(--dim-2); line-height: 1.5; }
.auth-guest {
  display: block; width: 100%; margin-top: 12px; padding: 8px;
  background: transparent; border: 0; cursor: pointer;
  color: var(--dim); font: inherit; font-size: 12.5px;
  text-decoration: underline; text-underline-offset: 3px;
}
.auth-guest:hover { color: var(--txt); }

.account-box { display: grid; gap: 10px; margin-top: 16px; }
.account-name { font-size: 14px; font-weight: 600; }
.account-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.auth-note {
  margin: 0 0 12px; padding: 9px 11px;
  border-radius: var(--radius-sm);
  background: var(--panel-2);
  border: 1px solid var(--line-soft);
  color: var(--dim);
  font-size: 12.5px; line-height: 1.5;
}
