/* Kuro. Ink on paper by day, graphite at night. One red: the seal for a miss. */
:root {
  --bg: #f5f5f4;
  --surface: #ffffff;
  --raise: #ececea;
  --ink: #0a0a0a;
  --ink-2: #2e2e30;
  --muted: #6d6d70;
  --line: #e0e0dd;
  --line-2: #cfcfcc;
  --seal: #cf3a22;
  --on-ink: #ffffff;
  --sheen: radial-gradient(120% 70% at 50% -20%, #ffffff 0%, rgba(255, 255, 255, 0) 60%);
  --glyph-fill: linear-gradient(180deg, #000 38%, #5c5c60 100%);
  --go-fill: linear-gradient(180deg, #2a2a2c 0%, #050505 100%);
  --shadow: 0 1px 0 rgba(0, 0, 0, .04), 0 10px 30px -12px rgba(0, 0, 0, .18);

  --ui: "Schibsted Grotesk", "Helvetica Neue", Arial, sans-serif;
  --mono: "Martian Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --jp: "Zen Kaku Gothic New", "Hiragino Kaku Gothic ProN", "Yu Gothic", "Noto Sans JP", sans-serif;
  --jp-mincho: "Shippori Mincho", "Hiragino Mincho ProN", "Yu Mincho", serif;
  --jp-textbook: "Klee One", "Hiragino Maru Gothic ProN", serif;
  --jp-round: "Zen Maru Gothic", "Hiragino Maru Gothic ProN", sans-serif;
  --kana: var(--jp);

  --r: 12px;
  --r-sm: 8px;
  --gutter: 16px;
  --top-h: 60px;
  --dock-h: 64px;
  --tab-h: 62px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #050505; --surface: #111112; --raise: #1b1b1d; --ink: #f4f4f2; --ink-2: #d6d6d3; --muted: #9d9da1;
    --line: #232326; --line-2: #333337; --seal: #ff5236; --on-ink: #050505;
    --sheen: radial-gradient(120% 70% at 50% -20%, #2c2c30 0%, rgba(5, 5, 5, 0) 62%);
    --glyph-fill: linear-gradient(180deg, #ffffff 36%, #85858b 100%);
    --go-fill: linear-gradient(180deg, #ffffff 0%, #c9c9c6 100%);
    --shadow: 0 1px 0 rgba(255, 255, 255, .03), 0 18px 40px -18px rgba(0, 0, 0, .9);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #050505; --surface: #111112; --raise: #1b1b1d; --ink: #f4f4f2; --ink-2: #d6d6d3; --muted: #9d9da1;
  --line: #232326; --line-2: #333337; --seal: #ff5236; --on-ink: #050505;
  --sheen: radial-gradient(120% 70% at 50% -20%, #2c2c30 0%, rgba(5, 5, 5, 0) 62%);
  --glyph-fill: linear-gradient(180deg, #ffffff 36%, #85858b 100%);
  --go-fill: linear-gradient(180deg, #ffffff 0%, #c9c9c6 100%);
  --shadow: 0 1px 0 rgba(255, 255, 255, .03), 0 18px 40px -18px rgba(0, 0, 0, .9);
  color-scheme: dark;
}

:root[data-font="mincho"] { --kana: var(--jp-mincho); }
:root[data-font="textbook"] { --kana: var(--jp-textbook); }
:root[data-font="round"] { --kana: var(--jp-round); }

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  background-image: var(--sheen);
  background-repeat: no-repeat;
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--ui);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
a { color: inherit; }
svg { width: 20px; height: 20px; flex: none; }
kbd { font-family: var(--mono); font-size: 10px; padding: 2px 5px; border: 1px solid var(--line-2); border-radius: 5px; color: var(--muted); line-height: 1; }
.jp { font-family: var(--jp); }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* ---- Top bar ---------------------------------------------------------- */
.app { min-height: 100%; display: flex; flex-direction: column; }
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  height: calc(var(--top-h) + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) max(var(--gutter), env(safe-area-inset-right, 0px)) 0 max(var(--gutter), env(safe-area-inset-left, 0px));
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(1.2) blur(10px);
  -webkit-backdrop-filter: saturate(1.2) blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: baseline; gap: 8px; text-decoration: none; }
.brand-k { font-family: var(--jp); font-weight: 900; font-size: 26px; line-height: 1; letter-spacing: -.02em; }
.brand-w { font-weight: 700; letter-spacing: -.01em; font-size: 17px; }
.tabs { display: flex; gap: 2px; margin-left: 12px; }
.tabs a, .tabs button {
  display: flex; align-items: center; gap: 7px; padding: 8px 12px; border-radius: 99px;
  text-decoration: none; color: var(--muted); font-weight: 500; transition: color .15s, background .15s;
}
.tabs svg { width: 16px; height: 16px; }
.tabs a:hover { color: var(--ink); }
.tabs a.on { color: var(--ink); background: var(--raise); }
.tab-settings { display: none !important; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.icon-btn { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 99px; color: var(--ink-2); transition: background .15s; }
.icon-btn:hover { background: var(--raise); }
.today { display: flex; align-items: center; gap: 8px; padding: 4px 10px 4px 4px; border-radius: 99px; }
.ring { width: 30px; height: 30px; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--line-2); stroke-width: 3; }
.ring-fg { fill: none; stroke: var(--ink); stroke-width: 3; stroke-linecap: round; stroke-dasharray: 94.25; stroke-dashoffset: 94.25; transition: stroke-dashoffset .6s cubic-bezier(.2, .8, .2, 1); }
.today-n { display: flex; align-items: baseline; gap: 3px; font-family: var(--mono); }
.today-n b { font-weight: 500; font-size: 15px; }
.today-n small { font-size: 10px; color: var(--muted); }

/* ---- Segmented controls ----------------------------------------------- */
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 10px; background: var(--raise); max-width: 100%; }
.seg button {
  flex: 1 1 0; min-width: 0; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 12px; border-radius: 8px; color: var(--muted); font-weight: 500; white-space: nowrap;
  transition: color .15s, background .15s, box-shadow .15s;
}
.seg button:hover { color: var(--ink); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .08), 0 0 0 1px var(--line); }
.seg button em { font-style: normal; font-family: var(--mono); font-size: 11px; color: var(--muted); }
.seg button:disabled { opacity: .35; cursor: not-allowed; }
.seg-num button { font-family: var(--mono); font-size: 13px; }

/* ---- Drill setup ------------------------------------------------------ */
.view { flex: 1; width: 100%; max-width: 1180px; margin: 0 auto; padding-inline: var(--gutter); padding-block: 28px 120px; }
#view-drill { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 32px; align-items: start; }
#view-drill[hidden] { display: none; }
.picker { display: grid; gap: 18px; min-width: 0; }
.picker-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.seg-script button { padding: 9px 16px; font-size: 15px; }
.seg-script .jp { font-size: 17px; font-weight: 700; }
.picker-actions { display: flex; gap: 4px; }
.link { padding: 6px 10px; border-radius: 8px; color: var(--muted); font-weight: 500; }
.link:hover { color: var(--ink); background: var(--raise); }

.groups { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px; border-radius: 99px;
  border: 1px solid var(--line-2); color: var(--ink-2); font-weight: 500; font-size: 13.5px;
  transition: background .15s, color .15s, border-color .15s;
}
.chip .tick { width: 14px; height: 14px; border-radius: 4px; border: 1.5px solid currentColor; display: grid; place-items: center; }
.chip.part .tick::after { content: ""; width: 6px; height: 1.5px; background: currentColor; }
.chip.on { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }
.chip.on .tick { background: var(--on-ink); border-color: var(--on-ink); }
.chip.on .tick::after { content: ""; width: 6px; height: 6px; border-radius: 1px; background: var(--ink); }
.chip:disabled { opacity: .35; cursor: default; }
.chip .frac { font-family: var(--mono); font-size: 11px; opacity: .6; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.rows { display: grid; gap: 6px; }
.rows-sec { font-family: var(--mono); font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); padding: 12px 2px 2px; }
.row {
  display: grid; grid-template-columns: 54px minmax(0, 1fr) 28px; align-items: center; gap: 12px;
  padding: 8px 12px 8px 14px; border-radius: var(--r); border: 1px solid var(--line);
  background: var(--surface); text-align: left; transition: border-color .15s, background .15s, transform .1s;
}
.row:hover { border-color: var(--line-2); }
.row:active { transform: scale(.995); }
.row-l { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.row-k { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; }
.row-c { display: grid; justify-items: center; gap: 4px; min-width: 0; }
.row-c b { font-family: var(--kana); font-weight: 700; font-size: 24px; line-height: 1.15; color: var(--ink-2); }
.row-c i { width: 70%; height: 3px; border-radius: 3px; background: var(--line); overflow: hidden; display: block; }
.row-c i::after { content: ""; display: block; height: 100%; width: var(--m, 0%); background: var(--ink); }
.row-c.gap b { color: transparent; }
.row-c.gap i { opacity: 0; }
.row .box { width: 22px; height: 22px; border-radius: 6px; border: 1.5px solid var(--line-2); justify-self: end; display: grid; place-items: center; transition: background .15s, border-color .15s; }
.row.on { border-color: var(--ink); box-shadow: inset 0 0 0 .5px var(--ink); }
.row.on .row-c b { color: var(--ink); }
.row.on .box { background: var(--ink); border-color: var(--ink); }
.row.on .box::after { content: ""; width: 9px; height: 5px; border-left: 2px solid var(--on-ink); border-bottom: 2px solid var(--on-ink); transform: translateY(-1px) rotate(-45deg); }

.launch { position: sticky; top: calc(var(--top-h) + 24px); }
.launch-card {
  display: grid; gap: 16px; padding: 22px; border-radius: 18px; background: var(--surface);
  border: 1px solid var(--line); box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.launch-card::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 160px; background: var(--sheen); pointer-events: none; opacity: .8; }
.launch-card > * { position: relative; }
.pool-preview { height: 104px; display: flex; align-items: center; justify-content: center; font-family: var(--kana); font-weight: 900; font-size: 92px; line-height: 1; letter-spacing: -.04em; overflow: hidden; }
.pool-preview span { background: var(--glyph-fill); -webkit-background-clip: text; background-clip: text; color: transparent; transition: opacity .3s; }
.pool-preview span + span { margin-left: -.18em; opacity: .28; font-size: .62em; }
.pool-preview span + span + span { opacity: .12; font-size: .45em; }
.pool-count { display: flex; align-items: baseline; justify-content: center; gap: 6px; margin-top: -6px; }
.pool-count b { font-family: var(--mono); font-weight: 400; font-size: 26px; letter-spacing: -.02em; }
.pool-count span { color: var(--muted); }
.field { display: grid; gap: 7px; }
.field .seg { width: 100%; }
.lbl { font-family: var(--mono); font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.go {
  display: flex; align-items: center; justify-content: center; gap: 12px; width: 100%;
  padding: 15px 18px; border-radius: 12px; background: var(--go-fill); color: var(--on-ink);
  font-weight: 700; font-size: 16px; letter-spacing: .01em;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .14), 0 8px 20px -10px rgba(0, 0, 0, .6);
  transition: transform .12s, filter .15s;
}
.go:hover { filter: brightness(1.12); }
.go:active { transform: translateY(1px) scale(.995); }
.go kbd { color: inherit; border-color: currentColor; opacity: .5; }
.go:disabled { opacity: .4; cursor: not-allowed; }
.ghost { padding: 14px 18px; border-radius: 12px; border: 1px solid var(--line-2); font-weight: 600; background: var(--surface); }
.ghost:hover { border-color: var(--ink); }
.msg { margin: -6px 0 0; min-height: 0; color: var(--seal); font-size: 13px; text-align: center; }
.msg:empty { display: none; }
.quick { display: grid; gap: 6px; }
.quick:empty { display: none; }
.quick button { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 14px; border-radius: 10px; border: 1px dashed var(--line-2); text-align: left; font-weight: 500; }
.quick button:hover { border-style: solid; border-color: var(--ink); }
.quick .jp { font-size: 17px; letter-spacing: .08em; color: var(--muted); font-family: var(--kana); }

.dock { display: none; }

/* ---- Chart ------------------------------------------------------------ */
.chart-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 22px; }
.seg-font button { font-size: 18px; padding: 6px 14px; color: var(--ink); }
.f-gothic { font-family: var(--jp); font-weight: 700; }
.f-mincho { font-family: var(--jp-mincho); font-weight: 600; }
.f-textbook { font-family: var(--jp-textbook); font-weight: 600; }
.f-round { font-family: var(--jp-round); font-weight: 700; }
.chart { display: grid; gap: 30px; }
.chart-sec h2 { margin: 0 0 10px; font-family: var(--mono); font-weight: 400; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.ktable { display: grid; gap: 6px; }
.ktable.cols5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.ktable.cols3 { grid-template-columns: repeat(3, minmax(0, 1fr)); max-width: 60%; }
.ktable.cols4 { grid-template-columns: repeat(4, minmax(0, 1fr)); max-width: 80%; }
.kcell {
  position: relative; display: grid; justify-items: center; align-content: center; gap: 2px;
  padding: 14px 4px 12px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line);
  min-height: 96px; overflow: hidden; transition: border-color .15s, transform .12s;
}

.kcell:active { transform: scale(.97); }
.kcell b { font-family: var(--kana); font-weight: 700; font-size: clamp(28px, 5vw, 40px); line-height: 1.1; }
.kcell span { font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
.kcell::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: linear-gradient(90deg, var(--ink) var(--m, 0%), transparent var(--m, 0%)); }
.kcell.gap { background: transparent; border-style: dashed; border-color: var(--line); pointer-events: none; }
.kcell.gap::after { display: none; }

/* ---- Stats ------------------------------------------------------------ */
.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; margin-bottom: 18px; }
.kpi { background: var(--surface); padding: 18px 18px 16px; display: grid; gap: 4px; min-width: 0; }
.kpi b { font-family: var(--mono); font-weight: 400; font-size: clamp(22px, 3.4vw, 34px); letter-spacing: -.03em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi span { font-size: 12.5px; color: var(--muted); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 18px; margin-bottom: 18px; min-width: 0; }
.panel h2 { margin: 0 0 14px; font-size: 13px; font-weight: 600; letter-spacing: .01em; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; }
.split .panel { margin: 0; }
.cal-wrap { overflow-x: auto; padding-bottom: 4px; }
.cal { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 13px); grid-auto-columns: 13px; gap: 3px; width: max-content; }
.cal i { border-radius: 3px; background: var(--raise); display: block; }
.cal i[data-l="1"] { background: color-mix(in srgb, var(--ink) 25%, var(--raise)); }
.cal i[data-l="2"] { background: color-mix(in srgb, var(--ink) 50%, var(--raise)); }
.cal i[data-l="3"] { background: color-mix(in srgb, var(--ink) 75%, var(--raise)); }
.cal i[data-l="4"] { background: var(--ink); }
.cal i.today { outline: 1.5px solid var(--seal); outline-offset: 1px; }
.maps { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; }
.map h3 { margin: 0 0 8px; font-family: var(--mono); font-weight: 400; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.map-grid { display: grid; grid-template-columns: repeat(11, minmax(0, 1fr)); gap: 3px; }
.map-grid button { aspect-ratio: 1; max-width: 100%; border-radius: 5px; font-family: var(--kana); font-weight: 700; font-size: clamp(10px, 1.6vw, 16px); display: grid; place-items: center; color: var(--ink-2); background: var(--raise); }
.map-grid button.empty { visibility: hidden; }
.map-grid button[data-l="1"] { background: color-mix(in srgb, var(--ink) 18%, var(--raise)); }
.map-grid button[data-l="2"] { background: color-mix(in srgb, var(--ink) 36%, var(--raise)); }
.map-grid button[data-l="3"] { background: color-mix(in srgb, var(--ink) 56%, var(--raise)); color: var(--on-ink); }
.map-grid button[data-l="4"] { background: color-mix(in srgb, var(--ink) 76%, var(--raise)); color: var(--on-ink); }
.map-grid button[data-l="5"] { background: var(--ink); color: var(--on-ink); }
.map-key { display: flex; align-items: center; gap: 3px; margin-top: 10px; font-family: var(--mono); font-size: 10px; color: var(--muted); }
.map-key i { width: 12px; height: 12px; border-radius: 3px; display: block; }
.mixups, .slowest { display: grid; gap: 6px; }
.mix { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 14px; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); }
.mix .pair { font-family: var(--kana); font-weight: 700; font-size: 26px; letter-spacing: .1em; }
.mix .pair small { font-family: var(--mono); font-size: 11px; color: var(--muted); letter-spacing: 0; margin-left: 4px; }
.mix .n { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.mix button { font-size: 13px; font-weight: 600; padding: 7px 12px; border-radius: 8px; background: var(--raise); }
.mix button:hover { background: var(--ink); color: var(--on-ink); }
.slow { display: grid; grid-template-columns: 36px minmax(0, 1fr) 56px; align-items: center; gap: 10px; }
.slow b { font-family: var(--kana); font-size: 22px; text-align: center; }
.slow .bar { height: 6px; border-radius: 6px; background: var(--raise); overflow: hidden; }
.slow .bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--muted), var(--ink)); border-radius: 6px; }
.slow span { font-family: var(--mono); font-size: 11.5px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }

/* ---- Run -------------------------------------------------------------- */
.run, .result {
  position: fixed; inset: 0; z-index: 40; background: var(--bg); background-image: var(--sheen);
  display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto auto;
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
}
.run-top { display: flex; align-items: center; gap: 14px; padding: 14px var(--gutter) 10px; max-width: 900px; width: 100%; margin: 0 auto; }
.run-progress { flex: 1; min-width: 0; }
.segs { display: flex; gap: 3px; height: 4px; }
.segs i { flex: 1; border-radius: 4px; background: var(--line-2); transition: background .2s; }
.segs i.ok { background: var(--ink); }
.segs i.no { background: var(--seal); }
.segs i.cur { background: color-mix(in srgb, var(--ink) 35%, var(--line-2)); }
.segs.bar i { flex: none; width: var(--p, 0%); background: var(--ink); }
.segs.bar { background: var(--line-2); border-radius: 4px; overflow: hidden; }
.run-count { font-family: var(--mono); font-size: 13px; font-variant-numeric: tabular-nums; }
.run-count span { color: var(--muted); }
.timeline { height: 2px; background: transparent; max-width: 900px; width: calc(100% - 2 * var(--gutter)); margin: 0 auto; overflow: hidden; border-radius: 2px; }
.timeline i { display: block; height: 100%; width: 100%; background: var(--ink); transform-origin: left; }
.timeline.warn i { background: var(--seal); }
.timeline.off { visibility: hidden; }
.stage { display: grid; place-content: center; justify-items: center; gap: 6px; padding: 8px var(--gutter); min-height: 0; text-align: center; }
.glyph {
  font-family: var(--kana); font-weight: 900; line-height: 1; letter-spacing: -.03em;
  font-size: clamp(120px, min(32vw, 30vh), 260px);
  background: var(--glyph-fill); -webkit-background-clip: text; background-clip: text; color: transparent;
  transition: transform .18s cubic-bezier(.2, .8, .2, 1), opacity .18s;
  user-select: none;
}
.glyph.word { font-size: clamp(56px, min(14vw, 18vh), 120px); letter-spacing: .02em; }
.glyph.roma { font-family: var(--mono); font-weight: 300; font-size: clamp(72px, min(20vw, 22vh), 160px); letter-spacing: -.04em; }
.glyph.enter { animation: rise .22s cubic-bezier(.2, .8, .2, 1); }
.glyph.ok { transform: scale(.94); opacity: .5; }
.glyph.shake { animation: shake .32s; }
@keyframes rise { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes shake { 20% { transform: translateX(-8px); } 40% { transform: translateX(7px); } 60% { transform: translateX(-5px); } 80% { transform: translateX(3px); } }
.answer { min-height: 34px; font-family: var(--mono); font-size: 22px; display: flex; align-items: center; gap: 12px; }
.answer .seal { width: 12px; height: 12px; border-radius: 50%; background: var(--seal); box-shadow: 0 0 0 4px color-mix(in srgb, var(--seal) 18%, transparent); }
.answer .you { font-size: 13px; color: var(--muted); text-decoration: line-through; text-decoration-color: var(--seal); }
.answer .snd { width: 32px; height: 32px; border-radius: 99px; display: grid; place-items: center; color: var(--muted); }
.answer .snd:hover { color: var(--ink); background: var(--raise); }
.answer .snd svg { width: 16px; height: 16px; }
.gloss { min-height: 20px; font-size: 14px; color: var(--muted); }

.input-zone { width: 100%; max-width: 640px; margin: 0 auto; padding: 0 var(--gutter) 10px; display: grid; }
.typebox { display: flex; gap: 8px; align-items: center; padding: 6px 6px 6px 18px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line-2); box-shadow: var(--shadow); }
.typebox:focus-within { border-color: var(--ink); }
.typebox input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--ink); font-family: var(--mono); font-size: 22px; padding: 10px 0; letter-spacing: .02em; }
.typebox input::placeholder { color: var(--line-2); }
.kbd-btn { width: 46px; height: 46px; border-radius: 10px; background: var(--raise); font-size: 20px; }
.typebox.bad { animation: shake .32s; border-color: var(--seal); }

.pad { display: grid; gap: 8px; }
.pad-read { height: 28px; text-align: center; font-family: var(--mono); font-size: 18px; color: var(--muted); letter-spacing: .04em; }
.pad-read b { color: var(--ink); font-weight: 400; }
.pad-onsets { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.pad-nuclei { display: grid; grid-template-columns: repeat(var(--n, 5), minmax(0, 1fr)); gap: 6px; }
.pk {
  height: 50px; border-radius: 11px; background: var(--surface); border: 1px solid var(--line);
  font-family: var(--mono); font-size: 15px; display: grid; place-items: center; touch-action: manipulation;
  transition: background .1s, color .1s, transform .08s, border-color .1s; user-select: none; -webkit-user-select: none;
}
.pk:active { transform: scale(.95); }
.pk.on { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }
.pk.v { height: 58px; font-size: 17px; background: var(--raise); border-color: transparent; }
.pk.v .full { font-size: 12px; opacity: .55; display: block; margin-top: -2px; }

.pk:disabled { opacity: .22; cursor: default; }
.pk.fn { color: var(--muted); }
.pk.fn svg { width: 18px; height: 18px; }
.pk.null { font-size: 18px; }

.choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.ch {
  position: relative; height: 74px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line-2);
  font-family: var(--mono); font-size: 22px; display: grid; place-items: center; transition: border-color .12s, background .12s, transform .08s;
}
.ch.kana { font-family: var(--kana); font-weight: 700; font-size: 36px; height: 86px; }

.ch:active { transform: scale(.98); }
.ch kbd { position: absolute; top: 8px; left: 9px; }
.ch.right { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }
.ch.wrong { border-color: var(--seal); color: var(--seal); }
.run-foot { display: flex; justify-content: center; gap: 18px; padding: 6px var(--gutter) 16px; font-size: 12px; color: var(--muted); }
.run-foot span { display: inline-flex; gap: 6px; align-items: center; }
.run.paused .stage::after { content: "Paused"; position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--mono); font-size: 14px; letter-spacing: .2em; text-transform: uppercase; background: color-mix(in srgb, var(--bg) 70%, transparent); }

/* ---- Result ----------------------------------------------------------- */
.result { display: block; overflow-y: auto; }
.result-inner { max-width: 760px; margin: 0 auto; padding: 48px var(--gutter) 40px; display: grid; gap: 26px; }
.res-big { display: flex; align-items: flex-start; justify-content: center; line-height: .85; }
.res-big b { font-family: var(--mono); font-weight: 300; font-size: clamp(110px, 28vw, 200px); letter-spacing: -.07em; background: var(--glyph-fill); -webkit-background-clip: text; background-clip: text; color: transparent; }
.res-big span { font-family: var(--mono); font-size: 28px; color: var(--muted); margin-top: .4em; }
.res-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.res-row div { padding: 14px 6px; display: grid; gap: 2px; justify-items: center; }
.res-row div + div { border-left: 1px solid var(--line); }
.res-row b { font-family: var(--mono); font-weight: 400; font-size: 20px; font-variant-numeric: tabular-nums; }
.res-row span { font-size: 12px; color: var(--muted); }
.strip { display: flex; flex-wrap: wrap; gap: 3px; justify-content: center; }
.strip i { width: 14px; height: 30px; border-radius: 3px; display: block; position: relative; background: var(--raise); }
.strip i::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: var(--h, 0%); background: var(--ink); border-radius: 3px; }
.strip i.no { background: transparent; box-shadow: inset 0 0 0 1.5px var(--seal); }
.strip i.no::after { display: none; }
.missed { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 8px; }
.missed:empty { display: none; }
.miss { display: grid; justify-items: center; gap: 2px; padding: 12px 6px 10px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); }

.miss b { font-family: var(--kana); font-weight: 700; font-size: 34px; line-height: 1.1; }
.miss.word b { font-size: 20px; }
.miss span { font-family: var(--mono); font-size: 12px; }
.miss small { font-family: var(--mono); font-size: 10.5px; color: var(--seal); text-decoration: line-through; }
.res-actions { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 8px; }

/* ---- Sheet ------------------------------------------------------------ */
.sheet { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .45); animation: fade .2s; }
.sheet-card {
  position: relative; width: min(560px, 100%); max-height: min(86vh, 860px); overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 24px; box-shadow: var(--shadow);
  animation: rise .22s cubic-bezier(.2, .8, .2, 1);
}
.sheet-x { position: absolute; top: 12px; right: 12px; }
@keyframes fade { from { opacity: 0; } }
.sheet h2 { margin: 0 0 18px; font-size: 18px; letter-spacing: -.01em; }
.detail-top { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 22px; align-items: center; }
.detail-glyph { font-family: var(--kana); font-weight: 900; font-size: 120px; line-height: 1; background: var(--glyph-fill); -webkit-background-clip: text; background-clip: text; color: transparent; }
.detail-r { display: grid; gap: 6px; }
.detail-r .rom { font-family: var(--mono); font-size: 34px; letter-spacing: -.02em; display: flex; align-items: center; gap: 10px; }
.detail-r .alt { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.detail-r .twin { font-size: 13px; color: var(--muted); }
.detail-r .twin b { font-family: var(--kana); font-size: 22px; color: var(--ink); margin-left: 4px; }
.fonts4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin: 20px 0; }
.fonts4 div { display: grid; justify-items: center; padding: 10px 0 8px; border-radius: 10px; background: var(--raise); }
.fonts4 b { font-size: 40px; line-height: 1.15; }
.fonts4 span { font-family: var(--mono); font-size: 9.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.dstats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.dstats div { background: var(--surface); padding: 10px 12px; display: grid; gap: 2px; }
.dstats b { font-family: var(--mono); font-weight: 400; font-size: 16px; }
.dstats span { font-size: 11.5px; color: var(--muted); }
.look { display: flex; align-items: center; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.look .lbl { margin-right: 4px; }
.look button { font-family: var(--kana); font-weight: 700; font-size: 26px; width: 48px; height: 48px; border-radius: 10px; border: 1px solid var(--line); }
.look button:hover { border-color: var(--ink); }
.detail-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 18px; }

.set-list { display: grid; gap: 0; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.set-row:last-child { border-bottom: 0; }
.set-row > span { font-weight: 500; }
.switch { width: 44px; height: 26px; border-radius: 99px; background: var(--line-2); position: relative; transition: background .15s; flex: none; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--surface); box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .18s; }
.switch[aria-checked="true"] { background: var(--ink); }
.switch[aria-checked="true"]::after { transform: translateX(18px); }
.data-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.data-btns button, .data-btns label { padding: 8px 12px; border-radius: 8px; border: 1px solid var(--line-2); font-weight: 500; font-size: 13.5px; cursor: pointer; }
.data-btns button:hover, .data-btns label:hover { border-color: var(--ink); }
.data-btns .danger { color: var(--seal); border-color: color-mix(in srgb, var(--seal) 40%, transparent); }
.data-btns .danger.arm { background: var(--seal); color: #fff; }

.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 80; background: var(--ink); color: var(--on-ink); padding: 10px 16px; border-radius: 10px; font-weight: 500; font-size: 14px; box-shadow: var(--shadow); animation: rise .2s; max-width: calc(100% - 32px); }

/* ---- Small screens ---------------------------------------------------- */
@media (max-width: 900px) {
  #view-drill { grid-template-columns: minmax(0, 1fr); }
  .launch { position: static; }
  .pool-preview, .pool-count, .launch .go, .launch .msg { display: none; }
  .launch-card { padding: 18px; }
  .dock {
    display: flex; position: fixed; z-index: 15; left: 0; right: 0;
    bottom: calc(var(--tab-h) + env(safe-area-inset-bottom, 0px));
    align-items: center; gap: 14px; padding: 10px var(--gutter);
    background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid var(--line);
  }
  .dock-n { font-family: var(--mono); font-size: 13px; color: var(--muted); }
  .dock-n b { color: var(--ink); font-weight: 500; font-size: 16px; }
  .go-sm { flex: 1; padding: 13px 16px; }
  .dock-opt { font-family: var(--mono); font-size: 11px; color: var(--ink-2); padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line-2); white-space: nowrap; }
  .launch { scroll-margin-top: calc(var(--top-h) + 12px); }
  .view { padding-block: 18px calc(var(--tab-h) + var(--dock-h) + 40px); }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpis .kpi:first-child { grid-column: 1 / -1; }
  .split, .maps { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  /* A backdrop filter would make the header the containing block for the fixed tab bar. */
  .top { backdrop-filter: none; -webkit-backdrop-filter: none; background: var(--bg); }
  .tabs {
    position: fixed; left: 0; right: 0; bottom: 0; margin: 0; z-index: 25;
    height: calc(var(--tab-h) + env(safe-area-inset-bottom, 0px)); padding: 0 6px env(safe-area-inset-bottom, 0px);
    background: var(--surface); border-top: 1px solid var(--line); justify-content: space-around; gap: 0;
  }
  .tabs a, .tabs button { flex-direction: column; gap: 3px; font-size: 11px; padding: 8px 4px; flex: 1; border-radius: 0; background: none !important; }
  .tabs svg { width: 20px; height: 20px; }
  .tabs a.on { color: var(--ink); }
  .tabs a.on svg { transform: translateY(-1px); }
  .tab-settings { display: flex !important; }
  .hide-sm { display: none !important; }
  .row { grid-template-columns: 40px minmax(0, 1fr) 24px; gap: 8px; padding: 6px 10px; }
  .row-c b { font-size: 21px; }
  .seg-script button { padding: 8px 10px; font-size: 14px; }
  .ktable.cols3, .ktable.cols4 { max-width: none; }
  .kcell { min-height: 78px; padding: 10px 2px 10px; }
  .pad-onsets { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 5px; }
  .pk { height: 46px; }
  .pk.v { height: 56px; }
  .run-foot { display: none; }
  .res-actions { grid-template-columns: 1fr 1fr; }
  .res-actions .go { grid-column: 1 / -1; }
  .res-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .res-row div:nth-child(3) { border-left: 0; }
  .res-row div:nth-child(n+3) { border-top: 1px solid var(--line); }
  .sheet { place-items: end center; padding: 0; }
  .sheet-card { border-radius: 20px 20px 0 0; max-height: 90vh; padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px)); }
  .detail-glyph { font-size: 92px; }
  .dstats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .brand-w { display: none; }
}
@media (max-height: 640px) and (max-width: 640px) {
  .glyph { font-size: clamp(90px, 24vh, 160px); }
  .pk { height: 42px; }
  .pk.v { height: 48px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* ---- Spell setup ------------------------------------------------------ */
.spell-setup { display: grid; gap: 22px; min-width: 0; }
.sp-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 18px; }
.sp-grid .field .seg { width: 100%; }
.sp-grid .seg button { font-size: 13.5px; padding: 8px 8px; }
.sp-grid .seg em { font-style: normal; font-family: var(--mono); font-size: 11px; color: var(--muted); }
.tagmini { font-size: 10px; padding: 1px 5px; border-radius: 4px; border: 1px solid currentColor; font-family: var(--mono); line-height: 1.4; }
#sp-prompt button:not([data-v="both"]) { font-family: var(--mono); font-size: 12.5px; }
.sp-preview { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.spc { display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: auto auto; gap: 4px 12px; align-items: center; padding: 12px 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); min-width: 0; }
.spc-tag { grid-row: 1 / 3; align-self: start; font-size: 10.5px; padding: 3px 6px; border-radius: 5px; background: var(--ink); color: var(--on-ink); }
.spc-p { font-family: var(--mono); font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spc-p small { font-family: var(--ui); margin-left: 6px; }
.spc-a { font-family: var(--kana); font-weight: 700; font-size: 22px; line-height: 1.2; }
.pool-preview.wordy { font-size: 52px; letter-spacing: 0; }

/* ---- Spell run -------------------------------------------------------- */
.sp-tag { font-size: 13px; font-weight: 700; padding: 5px 12px; border-radius: 99px; background: var(--ink); color: var(--on-ink); letter-spacing: .08em; }
.sp-tag.unknown { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--ink); font-family: var(--mono); }
.glyph.spell { font-size: clamp(44px, min(11vw, 12vh), 96px); letter-spacing: -.02em; overflow-wrap: anywhere; max-width: 100%; line-height: 1.15; padding-bottom: .08em; }
.glyph.spell.mean { font-family: var(--ui); font-weight: 700; font-size: clamp(36px, min(9vw, 10vh), 76px); letter-spacing: -.03em; }
.run.spelling .stage { gap: 10px; }
.run.spelling .stage > * { order: 5; }
.run.spelling #sp-tag-run { order: 1; }
.run.spelling #glyph { order: 2; }
.run.spelling #gloss { order: 3; margin-top: -4px; }
.run.spelling #sp-out { order: 4; }
.sp-out { min-height: 64px; display: flex; align-items: center; justify-content: center; font-family: var(--kana); font-weight: 700; font-size: clamp(36px, min(9vw, 8vh), 64px); line-height: 1; padding: 6px 14px; border-bottom: 2px solid var(--line-2); min-width: min(320px, 80vw); cursor: default; }
.sp-out .rest { font-family: var(--mono); font-weight: 300; font-size: .5em; color: var(--muted); margin-left: 2px; }
.sp-out .caret { width: 2px; height: .8em; background: var(--ink); margin-left: 3px; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.sp-ans { flex-direction: column; gap: 8px; min-height: 0; }
.sp-out .x { color: var(--seal); text-decoration: line-through; text-decoration-thickness: 3px; }
.sp-out .gap { width: .7em; align-self: stretch; border-bottom: 3px dashed var(--seal); margin: 0 2px; }
.sp-out .none { color: var(--muted); font-family: var(--mono); font-size: .5em; }
.sp-line { font-family: var(--kana); font-size: 22px; letter-spacing: .06em; color: var(--muted); display: flex; }
.sp-line .x { color: var(--seal); text-decoration: line-through; text-decoration-thickness: 2px; }
.sp-line .gap { width: .9em; border-bottom: 2px dashed var(--seal); margin: 0 1px; }
.sp-key { display: inline-flex; align-items: center; gap: 4px; font-family: var(--kana); font-weight: 700; font-size: 30px; letter-spacing: .04em; padding: 4px 12px; border-radius: 10px; }
.sp-key:hover { background: var(--raise); }
.sp-key .k { box-shadow: inset 0 -3px 0 var(--seal); }
.sp-key .seal { width: 10px; height: 10px; border-radius: 50%; background: var(--seal); margin-right: 8px; }
.sp-key svg { width: 16px; height: 16px; color: var(--muted); margin-left: 8px; }
.mchips { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.mchip { font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 99px; border: 1px solid color-mix(in srgb, var(--seal) 50%, transparent); color: var(--seal); }
.script-tog { width: 46px; height: 46px; border-radius: 10px; font-size: 18px; font-weight: 700; border: 1.5px solid var(--ink); }
.script-tog.kata { background: var(--ink); color: var(--on-ink); }

.kpad { display: grid; gap: 6px; }
.kp-on { display: grid; grid-template-columns: repeat(11, minmax(0, 1fr)); gap: 5px; }
.kp-nu { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 5px; }
.kp-fn { display: flex; gap: 5px; }
.kp-fn .pk { flex: 1; }
.kpad .pk { height: 42px; font-size: 13.5px; }
.kpad .pk.sm { font-size: 11px; }
.kpad .pk.v { height: 56px; display: grid; place-content: center; gap: 1px; }
.kpad .pk.v b { font-family: var(--kana); font-size: 20px; line-height: 1.1; font-weight: 700; }
.kpad .pk.v span { font-family: var(--mono); font-size: 10px; opacity: .55; }
.kpad .pk.fn { height: 46px; font-size: 17px; background: var(--raise); border-color: transparent; color: var(--ink); }
.kpad .pk.tog b { font-weight: 700; color: var(--ink); }
.kpad .pk.tog { color: var(--muted); font-size: 15px; }
.kpad .pk.ok { background: var(--go-fill); color: var(--on-ink); font-family: var(--ui); font-weight: 700; font-size: 15px; flex: 1.6; }

.tiles { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.tile { width: 58px; height: 62px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line-2); font-family: var(--kana); font-weight: 700; font-size: 28px; display: grid; place-items: center; box-shadow: 0 2px 0 var(--line-2); transition: transform .08s, opacity .15s; }
.tile:active { transform: translateY(2px); box-shadow: none; }
.tile:disabled { opacity: .18; box-shadow: none; }
.tile.fn { color: var(--muted); background: var(--raise); border-color: transparent; box-shadow: none; }
.tile.fn svg { width: 20px; height: 20px; }

/* ---- Mistake bars ------------------------------------------------------ */
.res-mist { border-top: 1px solid var(--line); padding-top: 18px; }
.mbars { display: grid; gap: 8px; }
.mbar { display: grid; grid-template-columns: 110px minmax(0, 1fr) 36px auto; align-items: center; gap: 12px; }
.mlabel { font-size: 13px; font-weight: 500; }
.mtrack { height: 8px; border-radius: 8px; background: var(--raise); overflow: hidden; }
.mtrack i { display: block; height: 100%; border-radius: 8px; background: linear-gradient(90deg, var(--muted), var(--ink)); }
.mbar:first-child .mtrack i { background: linear-gradient(90deg, color-mix(in srgb, var(--seal) 50%, var(--ink)), var(--seal)); }
.mbar b { font-family: var(--mono); font-weight: 400; font-size: 12.5px; text-align: right; }
.mbar button { font-size: 12.5px; font-weight: 600; padding: 6px 11px; border-radius: 8px; background: var(--raise); }
.mbar button:hover { background: var(--ink); color: var(--on-ink); }
.res-actions { grid-template-columns: 2fr repeat(3, minmax(0, 1fr)); }
.res-actions [hidden] { display: none; }
.result-inner { position: relative; }
.res-help { position: absolute; top: 16px; right: 12px; }

/* ---- Help ------------------------------------------------------------- */
.help-btn svg { width: 21px; height: 21px; }
.help-topics { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin: -6px 0 16px; scrollbar-width: none; }
.help-topics::-webkit-scrollbar { display: none; }
.help-topics button { flex: none; font-size: 12.5px; font-weight: 500; padding: 6px 11px; border-radius: 99px; border: 1px solid var(--line-2); color: var(--muted); white-space: nowrap; }
.help-topics button.on { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; counter-reset: s; }
.steps li { display: grid; gap: 6px; padding: 12px 14px; border-radius: 12px; background: var(--raise); animation: rise .3s backwards; animation-delay: calc(var(--i) * 70ms); }
.sline { font-size: 13.5px; color: var(--ink-2); }
.demo { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-height: 36px; }
.demo .ds { display: inline-flex; align-items: center; animation: pop .35s backwards; animation-delay: calc(var(--i) * 70ms + var(--d) * 160ms + 120ms); }
@keyframes pop { from { opacity: 0; transform: translateY(4px) scale(.9); } }
.dk { font-family: var(--mono); font-size: 13px; padding: 5px 9px; border-radius: 7px; border: 1px solid var(--line-2); border-bottom-width: 3px; background: var(--surface); color: var(--ink); }
.dp { font-family: var(--mono); font-size: 13px; padding: 6px 10px; border-radius: 8px; background: var(--surface); border: 1px solid var(--line); }
.dp.on { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }
.dout { font-family: var(--kana); font-weight: 700; font-size: 26px; line-height: 1; }
.dout u { text-decoration-color: var(--seal); text-decoration-thickness: 2px; }
.dro { font-family: var(--mono); font-size: 15px; }
.dtag { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 99px; background: var(--ink); color: var(--on-ink); }
.dar { color: var(--muted); }
.dor, .dvs { font-size: 12px; color: var(--muted); }
.dbad { font-family: var(--mono); font-size: 12px; color: var(--seal); }
.dseal { width: 10px; height: 10px; border-radius: 50%; background: var(--seal); }
.dok { color: var(--ink); font-weight: 700; }
.dtile { font-size: 15px; font-family: var(--mono); min-width: 40px; height: 40px; padding: 0 8px; border-radius: 9px; border: 1px solid var(--line-2); background: var(--surface); display: inline-grid; place-items: center; }
.dtile.jp { font-family: var(--kana); font-weight: 700; font-size: 20px; }
.dtile.on { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }
.drow { font-family: var(--mono); font-size: 12px; padding: 8px 12px; border-radius: 9px; border: 1.5px solid var(--ink); background: var(--surface); }
.drow .jp { font-size: 16px; letter-spacing: .3em; }
.dbox { width: 20px; height: 20px; border-radius: 6px; background: var(--ink); }
.dchip { font-size: 12px; padding: 5px 10px; border-radius: 99px; border: 1px solid var(--line-2); background: var(--surface); }
.dchip:first-child { background: var(--ink); color: var(--on-ink); }
.dbar { width: 120px; height: 4px; border-radius: 4px; background: var(--line-2); overflow: hidden; display: block; }
.dbar i { display: block; height: 100%; background: var(--ink); }
.dsnd { font-size: 18px; }
.dfont { font-size: 30px; padding: 0 4px; }
.dn { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.dlv { width: 22px; height: 22px; border-radius: 5px; display: inline-block; margin-right: 3px; background: var(--surface); border: 1px solid var(--line-2); }
.dlv.l1 { background: color-mix(in srgb, var(--ink) 20%, var(--surface)); }
.dlv.l3 { background: color-mix(in srgb, var(--ink) 58%, var(--surface)); }
.dlv.l5 { background: var(--ink); }
.dmix { display: flex; width: 220px; height: 10px; border-radius: 10px; overflow: hidden; gap: 2px; }
.dmix i { display: block; height: 100%; background: var(--ink); }
.dmix i:first-child { background: var(--seal); }
.dmix i:last-child { background: var(--muted); }
.tut-sec { display: grid; gap: 8px; margin-bottom: 18px; }
.sheet.help .sheet-card { width: min(600px, 100%); }
#tut-go { margin-top: 4px; }

@media (max-width: 900px) {
  .sp-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .kp-on { grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
  .kp-nu { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; }
  .kpad .pk { height: 38px; font-size: 13px; }
  .kpad .pk.v { height: 48px; }
  .kpad .pk.v b { font-size: 18px; }
  .kpad .pk.fn { height: 42px; }
  .tile { width: 52px; height: 56px; font-size: 25px; }
  .sp-out { min-height: 52px; }
  .run.spelling .stage { padding-block: 0; }
  .mbar { grid-template-columns: 92px minmax(0, 1fr) 28px auto; gap: 8px; }
  .res-actions { grid-template-columns: 1fr 1fr; }
  .res-actions .go { grid-column: 1 / -1; }
  .sp-preview { grid-template-columns: minmax(0, 1fr); }
}

/* ---- Full-chart answer board (romaji to kana) -------------------------- */
.input-zone.wide { max-width: 860px; }
.board { display: grid; gap: 10px; }
.btabs { width: 100%; }
.btabs button { font-size: 13px; padding: 7px 6px; }
.bgrid { display: grid; grid-auto-flow: column; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); grid-template-rows: repeat(var(--rows), auto); gap: 4px; }
.bgrid.flat { grid-auto-flow: row; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); grid-template-rows: none; }
.bk { height: 50px; border-radius: 9px; background: var(--surface); border: 1px solid var(--line); font-family: var(--kana); font-weight: 700; font-size: 22px; display: grid; place-items: center; touch-action: manipulation; transition: background .1s, border-color .1s, transform .08s; min-width: 0; }

.bk:active { transform: scale(.94); }
.bk.gap { background: transparent; border-color: transparent; pointer-events: none; }
.bk.right { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }
.bk.wrong { border-color: var(--seal); color: var(--seal); box-shadow: inset 0 0 0 1px var(--seal); }
.dtile.dwrong { border-color: var(--seal); color: var(--seal); }
@media (max-width: 640px) {
  .bgrid { gap: 3px; }
  .bk { height: 42px; font-size: 17px; border-radius: 7px; }
  .bgrid.flat { grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); }
  .btabs button { font-size: 11.5px; padding: 6px 2px; }
}

/* ---- Gradient text: keep descenders and accents inside the paint box ----
   background-clip:text only paints within the element's box, and at
   line-height 1 the tails of g, y, p, j (and tall kana marks) fall outside
   it. Pad the box so the gradient covers the whole glyph, and pull the
   margins back so the layout does not move. */
.glyph, .res-big b, .detail-glyph {
  padding-block: .14em .26em;
  margin-block: -.14em -.26em;
  padding-inline: .06em;
}
.glyph.spell { padding-block: .14em .26em; margin-block: -.14em -.26em; }
.pool-preview span { padding-block: .14em .26em; }
.s10 .q, .s8 .q { padding-block: .14em .26em; }

/* ---- Row, then kana picker (phones) -------------------------------------- */
.board.rowpick { gap: 8px; }
.rp-rows { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
.rp-break { grid-column: 1 / -1; height: 1px; background: var(--line); margin: 2px 0; }
.rp-row { height: 58px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); display: grid; place-content: center; gap: 1px; touch-action: manipulation; transition: transform .08s, border-color .1s; min-width: 0; }
.rp-row:active { transform: scale(.95); }

.rp-row b { font-family: var(--kana); font-size: 22px; font-weight: 700; line-height: 1.1; }
.rp-row span { font-family: var(--mono); font-size: 10.5px; color: var(--muted); }
.rp-kana { display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); gap: 8px; }
.rp-kana .bk { height: 92px; font-size: 40px; border-radius: 14px; }
.rp-kana .bk.sel { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.rp-marks { display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); gap: 8px; }
.rp-mark, .rp-enter { height: 58px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); touch-action: manipulation; transition: transform .08s, border-color .1s, opacity .1s; min-width: 0; }
.rp-mark { display: grid; place-items: center; }
.rp-mark svg { width: 34px; height: 34px; }
.rp-enter { font-family: var(--mono); font-size: 13px; color: var(--ink-2); }
.rp-mark:active, .rp-enter:active { transform: scale(.95); }
.rp-mark:disabled, .rp-enter:disabled { opacity: .35; }
.rp-mark.right { background: var(--ink); color: var(--on-ink); border-color: var(--ink); opacity: 1; }
.rp-mark.wrong { border-color: var(--seal); color: var(--seal); box-shadow: inset 0 0 0 1px var(--seal); opacity: 1; }
.rp-back { display: flex; align-items: center; justify-content: center; gap: 8px; height: 46px; border-radius: 12px; background: var(--raise); font-family: var(--mono); font-size: 13px; color: var(--ink-2); }
.rp-back svg { width: 16px; height: 16px; }
.dp small { font-family: var(--mono); font-size: 10px; opacity: .6; }
.dp.dmark { display: inline-grid; place-items: center; padding: 3px 8px; }
.dp.dmark .dmk { width: 22px; height: 22px; }
.sline .dmk { width: 1.3em; height: 1.3em; vertical-align: -.35em; }
@media (max-width: 640px) {
  .rp-rows { gap: 5px; }
  .rp-row { height: 54px; }
  .rp-kana .bk { height: 84px; font-size: 36px; }
}

/* Hover outlines only where there is a real pointer; on touch they stick to the last tapped key. */
@media (hover: hover) {
  .bk:hover { border-color: var(--ink); }
  .rp-row:hover { border-color: var(--ink); }
  .rp-mark:not(:disabled):hover, .rp-enter:not(:disabled):hover { border-color: var(--ink); }
  .ch:hover { border-color: var(--ink); }
  .pk.v:hover { border-color: var(--ink); }
  .kcell:hover { border-color: var(--ink); }
  .miss:hover { border-color: var(--ink); }
}

/* ---- Mode bar: the four modes, named, at the top of Drill -------------- */
.modes { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.modes button { display: grid; gap: 3px; justify-items: start; text-align: left; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); transition: border-color .15s, background .15s, color .15s; min-width: 0; }
.modes button b { font-size: 16px; font-weight: 700; letter-spacing: -.01em; }
.modes button span { font-family: var(--mono); font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.modes button i { font-style: normal; font-family: var(--kana); font-weight: 700; font-size: 13px; }
.modes button.on { background: var(--go-fill); border-color: var(--ink); color: var(--on-ink); }
.modes button.on span { color: var(--on-ink); opacity: .7; }
@media (hover: hover) { .modes button:hover { border-color: var(--ink); } }
@media (max-width: 640px) {
  .modes { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .modes button { padding: 10px 12px; }
}

/* Script tag above a Find prompt when both scripts are drilled. */
.run:not(.spelling) .stage #sp-tag-run { margin-bottom: -4px; }

/* ---- Drill chooser ----------------------------------------------------- */
#view-modes { padding-block: 28px 120px; }
.chooser { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 28px; align-items: start; }
.mode-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.mcard { position: relative; display: grid; align-content: end; gap: 6px; min-height: 190px; padding: 18px; border-radius: 18px; text-align: left; background: var(--surface); border: 1px solid var(--line); overflow: hidden; transition: border-color .15s, transform .12s; }
.mcard:active { transform: scale(.985); }
.mcard .mc-ex { position: absolute; top: 16px; left: 18px; right: 18px; font-family: var(--mono); font-size: 13px; color: var(--muted); }
.mcard .mc-ex i, .md-head i, .setup-mode i { font-style: normal; font-family: var(--kana); font-weight: 700; font-size: 1.25em; color: var(--ink); }
.mcard b { font-size: 26px; font-weight: 800; letter-spacing: -.03em; line-height: 1; }
.mcard .mc-line { font-size: 13.5px; color: var(--muted); line-height: 1.35; text-wrap: pretty; }
.mcard.on { background: var(--go-fill); border-color: var(--ink); color: var(--on-ink); box-shadow: var(--shadow); }
.mcard.on .mc-line, .mcard.on .mc-ex { color: var(--on-ink); opacity: .72; }
.mcard.on .mc-ex i { color: var(--on-ink); }
@media (hover: hover) { .mcard:hover { border-color: var(--ink); } }
.mode-detail { position: sticky; top: calc(var(--top-h) + 24px); display: grid; gap: 10px; padding: 20px; border-radius: 18px; background: var(--surface); border: 1px solid var(--line); scroll-margin-top: calc(var(--top-h) + 12px); }
.md-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.md-head b { font-size: 22px; font-weight: 800; letter-spacing: -.02em; }
.md-head span { font-family: var(--mono); font-size: 13px; color: var(--muted); }
.md-sub { margin-top: 8px; }
.mode-detail #mode-detail { display: grid; gap: 8px; }
.mode-detail .steps { gap: 6px; }
.mode-detail .steps li { grid-template-columns: minmax(0, 46%) minmax(0, 1fr); align-items: center; gap: 12px; padding: 9px 12px; }
.mode-detail .demo { min-height: 30px; }
.mode-detail .sline { font-size: 13px; }
.confirm-bar { margin-top: 6px; }

.setup-head { grid-column: 1 / -1; display: flex; align-items: center; gap: 14px; }
.back-modes { display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px 8px 10px; border-radius: 99px; border: 1px solid var(--line-2); text-decoration: none; font-weight: 600; font-size: 14px; }
.back-modes svg { width: 16px; height: 16px; }
@media (hover: hover) { .back-modes:hover { border-color: var(--ink); } }
.setup-mode { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.setup-mode b { font-size: 22px; font-weight: 800; letter-spacing: -.02em; }
.setup-mode span { font-family: var(--mono); font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

@media (max-width: 900px) {
  .chooser { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .mode-detail { position: static; }
  .mode-detail .steps li { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .confirm-bar { position: fixed; left: 0; right: 0; bottom: calc(var(--tab-h) + env(safe-area-inset-bottom, 0px)); margin: 0; padding: 10px var(--gutter); background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-top: 1px solid var(--line); z-index: 15; }
  .confirm-bar .go { width: 100%; min-width: 0; }
  #view-modes { padding-block: 16px calc(var(--tab-h) + 110px); }
}
@media (min-width: 641px) and (max-width: 900px) {
  .confirm-bar { bottom: 0; }
}
@media (max-width: 640px) {
  .mode-cards { gap: 8px; }
  .mcard { min-height: 138px; padding: 14px; border-radius: 16px; }
  .mcard .mc-ex { top: 12px; left: 14px; font-size: 12px; }
  .mcard b { font-size: 21px; }
  .mcard .mc-line { font-size: 12.5px; }
  .mode-detail { padding: 16px; }
}

/* Empty states: a dimmed sample of what will appear, no sentences. */
.sample { opacity: .32; pointer-events: none; user-select: none; filter: grayscale(1); }

/* ---- Words setup ------------------------------------------------------- */
.words-setup { display: grid; gap: 22px; min-width: 0; }
.incs { display: flex; flex-wrap: wrap; gap: 6px; }
.incs .chip .jp { font-family: var(--kana); font-weight: 700; }
.incs .chip.fixed { cursor: default; opacity: .75; }

/* Prompt-to-answer connector: a short drawn line ending in a dot. Arrow
   characters are not used anywhere in the UI (CLAUDE.md, rule 1). */
.to { display: inline-block; position: relative; width: .95em; height: 1.5px; margin: 0 .45em; vertical-align: middle; background: currentColor; opacity: .45; border-radius: 1px; }
.to::after { content: ""; position: absolute; right: -2px; top: 50%; width: 5px; height: 5px; margin-top: -2.5px; border-radius: 50%; background: currentColor; }
