:root {
  --bg: #ffffff; --fg: #2b2b2b; --muted: #606064; --line: #e2e2e2; --soft: #f4f4f2;
  --accent: #b5482f; --link: #2f6fa8; --common: #497621; --field: #ffffff; --bar: #d9d9d6; --cur: #c8321e;
  --on-accent: #fff;
  --jp: "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Yu Gothic", "Meiryo", "Noto Sans JP", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1c1d1f; --fg: #e4e4e2; --muted: #9a9a9d; --line: #36373a; --soft: #26272a;
    --accent: #e0765c; --link: #7fb4e6; --common: #8cc152; --field: #121314; --bar: #3b3c40; --cur: #ff6a52;
    --on-accent: #111;
  }
}
:root[data-theme="dark"] {
  --bg: #1c1d1f; --fg: #e4e4e2; --muted: #9a9a9d; --line: #36373a; --soft: #26272a;
  --accent: #e0765c; --link: #7fb4e6; --common: #8cc152; --field: #121314; --bar: #3b3c40; --cur: #ff6a52;
  --on-accent: #111;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
/* native controls follow the chosen theme */
:root { color-scheme: light dark; } :root[data-theme="light"] { color-scheme: light; } :root[data-theme="dark"] { color-scheme: dark; }
input, select, textarea { background-color: var(--field); color: var(--fg); }
body { margin: 0; background: var(--bg); color: var(--fg); font: 16px/1.6 "Helvetica Neue", Helvetica, Arial, var(--jp); }
[lang="ja"] { font-family: var(--jp); }
a { color: var(--link); }
a:hover { text-decoration-thickness: 2px; }
.wrap { container-type: inline-size; max-width: 1040px; margin: 0 auto; padding: 0 16px 40px; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.linkish { background: none; border: 0; padding: 0; font: inherit; color: var(--link); text-decoration: underline; cursor: pointer; }

/* header */
.top { display: flex; justify-content: space-between; align-items: flex-start; padding: 12px 0 6px; gap: 12px; }
.logo { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--fg); flex: none; }
.logo .seal { white-space: nowrap; }
.logo .seal { background: var(--accent); color: #fff; font-family: "Yu Mincho", "Hiragino Mincho ProN", serif; font-size: 1.5rem; line-height: 1; padding: 8px 7px; border-radius: 6px; letter-spacing: 1px; }
.logo .name { font-size: 2.3rem; font-weight: 700; letter-spacing: -1.5px; line-height: 1; }
.top nav { display: flex; gap: 6px 16px; font-size: 0.92rem; padding-top: 4px; flex-wrap: wrap; justify-content: flex-end; }
/* narrow screens: logo on its own line, the links in one row that scrolls sideways */
@media (max-width: 640px) {
  .top { flex-direction: column; align-items: stretch; gap: 6px; }
  .logo .name { font-size: 1.9rem; }
  .top nav { flex-wrap: nowrap; justify-content: flex-start; overflow-x: auto; white-space: nowrap; gap: 14px; padding: 4px 0 8px; scrollbar-width: thin; }
}

/* search */
#search { display: flex; align-items: center; gap: 14px; margin: 8px 0 6px; }
.inputs { display: flex; gap: 6px; }
.input-btn { background: none; border: 0; color: var(--fg); cursor: pointer; display: flex; flex-direction: column; align-items: center; font-size: 0.72rem; padding: 2px 6px; border-radius: 6px; min-width: 46px; }
.input-btn:hover, .input-btn.on { background: var(--soft); }
.input-btn .bu { font-size: 1.45rem; line-height: 26px; }
.bar { flex: 1; display: flex; align-items: stretch; border: 4px solid var(--bar); border-radius: 5px; background: var(--field); min-width: 0; }
.bar select { border: 0; border-right: 1px solid var(--line); background: transparent; color: var(--muted); font: inherit; font-size: 0.9rem; padding: 0 6px 0 10px; cursor: pointer; }
.bar select option { color: #222; }
.bar input { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--fg); font: inherit; font-size: 1.35rem; padding: 6px 10px; outline: none; }
.bar:focus-within { border-color: var(--accent); }
#clear { background: none; border: 0; color: var(--fg); font-size: 1.7rem; line-height: 1; padding: 0 10px; cursor: pointer; }
#go { background: var(--soft); border: 0; color: var(--fg); padding: 0 12px; cursor: pointer; display: flex; align-items: center; }
#go:hover { background: var(--bar); }

/* input panels */
.panel { border: 1px solid var(--line); border-radius: 6px; padding: 12px; margin: 8px 0; background: var(--soft); }
.draw-wrap { display: flex; gap: 14px; flex-wrap: wrap; }
#draw-canvas { background: var(--field); border: 1px solid var(--line); border-radius: 4px; touch-action: none; cursor: crosshair; width: 260px; height: 260px; }
.draw-side { flex: 1; min-width: 200px; display: flex; flex-direction: column; gap: 10px; }
#draw-results { display: flex; flex-wrap: wrap; gap: 6px; align-content: flex-start; }
#draw-results button { font-size: 1.6rem; width: 46px; height: 46px; border: 1px solid var(--line); background: var(--field); color: var(--fg); border-radius: 4px; cursor: pointer; font-family: var(--jp); }
#draw-results button:hover { border-color: var(--accent); }
.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
:is(.panel, .input-btn, .sense, .word-choice, .filter-preview) :focus-visible, .input-btn:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }
.draw-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.draw-actions button, #draw-results button { touch-action: manipulation; }
.draw-actions button { font: inherit; padding: 4px 12px; border: 1px solid var(--line); background: var(--field); color: var(--fg); border-radius: 4px; cursor: pointer; }

.rad-grid, .rad-out { display: flex; flex-wrap: wrap; gap: 3px; align-items: center; }
.rad-out { min-height: 44px; padding-bottom: 10px; margin-bottom: 10px; border-bottom: 1px solid var(--line); max-height: 220px; overflow-y: auto; }
.rad, .rad-k { width: 32px; height: 32px; font-size: 1.15rem; line-height: 1; padding: 0; border: 1px solid var(--line); background: var(--field); color: var(--fg); border-radius: 3px; cursor: pointer; font-family: var(--jp); }
.rad-k { width: 40px; height: 40px; font-size: 1.5rem; }
.rad:hover:not(:disabled), .rad-k:hover { border-color: var(--accent); }
.rad.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.rad:disabled { opacity: 0.25; cursor: default; }
.rad-n { display: inline-flex; align-items: center; justify-content: center; min-width: 24px; height: 24px; padding: 0 4px; font-size: 0.75rem; font-weight: 700; color: #fff; background: var(--muted); border-radius: 3px; }
.rad-reset { margin-top: 10px; font: inherit; padding: 4px 12px; border: 1px solid var(--line); background: var(--field); color: var(--fg); border-radius: 4px; cursor: pointer; }

/* sentences and names */
.sentence, .nm { padding-bottom: 12px; margin-bottom: 12px; border-bottom: 1px solid var(--line); }
.sj { font-size: 1.25rem; line-height: 2.1; }
.col-side .sj { font-size: 1.05rem; }
.sj a.sw, .example a.sw { color: inherit; text-decoration: none; }
.sj a.sw:hover, .example a.sw:hover { background: var(--soft); border-radius: 3px; }
.sentence .en, .example .en { color: var(--muted); font-size: 0.92rem; }
.example { margin: 2px 0 6px 26px; padding-left: 10px; border-left: 3px solid var(--line); line-height: 2; }
.example .en { line-height: 1.4; }
.nj { font-size: 1.2rem; }
.nm .pos { margin-top: 2px; }

/* layout */
main { margin-top: 18px; }
main.narrow { max-width: 620px; margin-left: auto; margin-right: auto; }
.cols { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 36px; }
.cols.single { grid-template-columns: minmax(0, 1fr); }
@media (max-width: 800px) { .cols { grid-template-columns: minmax(0, 1fr); gap: 8px; } }
h2.count { font-size: 1rem; font-weight: 700; border-bottom: 1px solid var(--line); padding-bottom: 4px; margin: 18px 0 14px; }
h2.count span { font-weight: 400; color: var(--muted); }
.col-main > h2.count:first-child, .col-side > h2.count:first-child { margin-top: 0; }

/* notes */
.note, .fact { background: var(--soft); border-left: 4px solid var(--bar); padding: 8px 12px; margin: 0 0 12px; border-radius: 0 4px 4px 0; }
.fact { border-left-color: var(--accent); font-size: 1.15rem; }
.note ul { margin: 4px 0 0; padding-left: 20px; }

/* sentence */
.tokens { display: flex; flex-wrap: wrap; gap: 4px 2px; margin: 0 0 18px; padding: 10px; background: var(--soft); border-radius: 6px; align-items: flex-end; }
.tok { display: inline-flex; flex-direction: column; align-items: center; padding: 4px 6px 2px; border-radius: 4px; text-decoration: none; color: var(--fg); border-bottom: 3px solid transparent; }
a.tok:hover { background: var(--bg); }
.tok.sel { background: var(--bg); border-bottom-color: var(--accent); }
.tok.unknown .tok-w { color: var(--muted); }
.tok-w { font-size: 1.5rem; line-height: 1.9; }
.tok.other .tok-w, .tok.other { font-size: 1.5rem; color: var(--muted); }
.tok-pos { font-size: 0.68rem; color: var(--muted); min-height: 1em; }
ruby rt { font-size: 0.5em; color: var(--muted); user-select: none; }
.example mark rt { color: MarkText; background-color: Mark; }

/* entries */
.entry { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 20px; padding: 0 0 18px; margin: 0 0 18px; border-bottom: 1px solid var(--line); }
@container (max-width: 34rem) {
  #search { flex-direction: column-reverse; align-items: stretch; gap: 6px; }
  .entry { grid-template-columns: minmax(0, 1fr); gap: 6px; }
}
.word { font-size: 1.9rem; line-height: 2.1; word-break: break-all; }
.word ruby rt { font-size: 0.42em; }
.tags { margin: 2px 0 6px; }
.tag { display: inline-block; font-size: 0.72rem; padding: 1px 7px; border-radius: 3px; color: #fff; background: var(--muted); margin-right: 4px; }
.tag.common { background: var(--common); }
.tag.jlpt { background: var(--link); text-decoration: none; }
.tag.wk { background: #8e5bb5; text-decoration: none; }
.tags .tag { margin-bottom: 4px; }
.tag:not(.wk) { color: var(--on-accent); }
.audio.synth { color: var(--muted); }
.star { display: block; font-size: 0.85rem; margin: 2px 0; text-decoration: none; }
.star.on { color: var(--accent); }
.exports { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 20px; }
.exports p { flex-basis: 100%; margin: 4px 0 0; }
.btn { font: inherit; font-size: 0.92rem; padding: 6px 12px; border: 1px solid var(--line); background: var(--soft); color: var(--fg); border-radius: 4px; cursor: pointer; text-decoration: none; }
.btn:hover { border-color: var(--accent); }
.btn.danger { margin-left: auto; color: var(--muted); }
.entry-head .audio, .details-link { display: block; font-size: 0.85rem; margin-top: 2px; }
.entry-head :is(.star, .audio, .details-link) { min-height: 24px; }
.pos { color: var(--muted); font-size: 0.82rem; margin-top: 8px; }
.entry-body > .pos:first-child { margin-top: 2px; }
.sense { display: block; padding-left: 26px; text-indent: -26px; }
.sense .num { color: var(--muted); display: inline-block; width: 26px; text-indent: 0; }
.sense .gloss { font-size: 1.05rem; }
.filter-match { display: inline-block; text-indent: 0; color: var(--fg); background: var(--soft); border-radius: 3px; padding: 1px 5px; font-size: .82rem; }
.filter-preview { margin: 0 0 .4rem; }
.word-choice { border-block: 1px solid var(--line); padding: .75rem 0; }
.word-choice h2 { margin: 0; font-size: 1.12rem; }
.word-choice ul { list-style: none; padding: 0; margin: .6rem 0; }
.word-choice li + li { margin-top: .65rem; }
.word-choice li div { margin-top: .15rem; }
.word-choice small { color: var(--muted); }
.sense:target { outline: 2px solid var(--link); outline-offset: 2px; scroll-margin: 1rem; }
.collocations { margin: .3rem 0 .6rem; padding-left: .7rem; border-left: 2px solid var(--line); text-indent: 0; }
.collocations strong { font-size: .82rem; }
.collocations ul { margin: .1rem 0 0; padding: 0; list-style: none; }
.collocations li { line-height: 1.6; }
.sense .supp { color: var(--muted); font-size: 0.82rem; }
.sense.other-forms { padding-left: 0; text-indent: 0; font-size: 1.05rem; }
.inflected-from { font-size: 0.82rem; color: var(--accent); }
.more { display: inline-block; margin: 0 0 20px; font-weight: 700; }
.inflections { margin-top: 12px; }
.codes { margin: 14px 0 4px; }
.codes summary { cursor: pointer; color: var(--link); }
.codes table td { font-size: 0.9rem; }
.inflections summary { cursor: pointer; color: var(--link); }
.inflections table, table.data { border-collapse: collapse; margin-top: 6px; width: 100%; }
.inflections th, .inflections td, table.data td { border: 1px solid var(--line); padding: 4px 8px; text-align: left; font-weight: 400; }
.inflections thead th, .inflections tbody th { color: var(--muted); font-size: 0.85rem; }
.inflections td { font-size: 1.05rem; }
.yes { color: var(--common); font-weight: 700; } .no { color: var(--muted); }

/* kanji */
.kanji-light { display: grid; grid-template-columns: 62px minmax(0, 1fr); gap: 12px; padding-bottom: 14px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.kanji-light .literal { font-size: 3.2rem; line-height: 1.1; text-decoration: none; color: var(--fg); }
.kl-meanings { font-size: 1rem; }
.kl-r, .kd-r { font-size: 0.95rem; } .lab { color: var(--muted); font-size: 0.82rem; }
.kl-r a, .kd-r a { text-decoration: none; }
.kanji-detail { padding-bottom: 24px; margin-bottom: 24px; border-bottom: 1px solid var(--line); }
.kd-top { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 24px; }
@media (max-width: 560px) { .kd-top { grid-template-columns: minmax(0, 1fr); } }
.kd-char .big { font-size: 9rem; line-height: 1.1; }
.kd-meanings { font-size: 1.35rem; margin-bottom: 8px; }
.kd-r { font-size: 1.15rem; margin: 2px 0; }
.kd-facts { list-style: none; padding: 0; margin: 10px 0; color: var(--muted); }
.kanji-detail h3, .prose h3 { font-size: 0.95rem; margin: 18px 0 8px; }
.so-row { display: flex; gap: 16px; align-items: flex-start; }
.so-anim { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 0.85rem; }
.so-steps { display: flex; flex-wrap: wrap; gap: 4px; }
svg.strokes { background: var(--field); border: 1px solid var(--line); border-radius: 3px; flex: none; }
svg.strokes path { fill: none; stroke: var(--muted); stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round; }
svg.strokes.whole path { stroke: var(--fg); }
svg.strokes path.cur { stroke: var(--cur); }
svg.strokes .guide { stroke: var(--line); stroke-width: 1; stroke-dasharray: 4 4; }
svg.strokes .dot { fill: var(--cur); }
.comp-row { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
@media (max-width: 700px) { .comp-row { grid-template-columns: 1fr; } .so-row { flex-direction: column; } }
.comp-reading { font-weight: 700; margin-top: 8px; }
.compounds ul { list-style: none; padding: 0; margin: 2px 0; }
.compounds li { font-size: 0.92rem; margin: 2px 0; }
.kanji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.kg { border: 1px solid var(--line); border-radius: 5px; padding: 6px; text-decoration: none; color: var(--fg); display: flex; flex-direction: column; align-items: center; text-align: center; }
.kg:hover { border-color: var(--accent); }
.kg-c { font-size: 2.3rem; line-height: 1.2; } .kg-m { font-size: 0.72rem; color: var(--muted); line-height: 1.25; }

/* furigana modes: smart hides readings over kanji you have studied; off hides all in sentences; hover peeks */
:root[data-furi="smart"] ruby.kn rt, :root[data-furi="off"] .sj rt, :root[data-furi="off"] .example rt, :root[data-furi="off"] .qz-ex rt { visibility: hidden; }
:root[data-furi] ruby:hover rt { visibility: visible; }
/* notes */
.note-box { margin: 14px 0 4px; } .note-box summary { cursor: pointer; color: var(--link); }
.note-box textarea { width: 100%; font: inherit; padding: 8px; margin: 6px 0; border: 1px solid var(--line); border-radius: 5px; background: var(--field); color: var(--fg); }
.qz-notes.mine { border-left: 3px solid var(--accent); padding-left: 8px; }
/* reader */
.rd { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 28px; }
@media (max-width: 860px) { .rd { grid-template-columns: minmax(0, 1fr); } .rd-side { position: static !important; max-height: none !important; } }
.rd-text { font-size: 1.45rem; line-height: 2.3; } .rd-title { font-size: 1.5rem; }
.rd-tools, .rd-nav { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 8px 0 14px; } .rd-nav { justify-content: space-between; margin-top: 22px; }
.rd-tools select, .rd-nav select { font: inherit; padding: 4px; }
.rw { cursor: pointer; border-radius: 3px; } .rw:hover { outline: 2px solid var(--accent); }
.rw.st-0 { background: rgba(47, 111, 168, 0.16); } .rw.st-1 { background: rgba(217, 165, 32, 0.32); } .rw.sel { outline: 2px solid var(--accent); }
.sent.speaking { background: rgba(58, 154, 92, 0.15); border-radius: 4px; }
.rd-side { position: sticky; top: 12px; align-self: start; max-height: calc(100vh - 24px); overflow-y: auto; border-left: 1px solid var(--line); padding-left: 16px; }
.rd-side .entry { grid-template-columns: minmax(0, 1fr); gap: 4px; } .rd-side .word { font-size: 1.6rem; }
.rd-status { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0; } .rd-status button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.rd-side > label { display: block; margin-top: 8px; }
.rd-side .gloss + button { margin-inline: 0.35em; }
.rd-side select { display: block; width: 100%; margin-block: 4px 8px; font: inherit; }
.rd-side input, .rd-side textarea, .rd-notes textarea, .reader-import input[type=text] { width: 100%; font: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: 5px; background: var(--field); color: var(--fg); }
.rd-credits pre { white-space: pre-wrap; font-size: 0.8rem; color: var(--muted); }
.rv mark { background: rgba(217, 165, 32, 0.35); color: inherit; }
.gr-block { font-size: 0.95rem; margin: 18px 0 4px; color: var(--muted); font-weight: 600; }
/* pitch accent */
.pitch { font-size: 1rem; margin: -4px 0 6px; color: var(--muted); } .pitch-w { margin-right: 10px; white-space: nowrap; }
.pitch span.hi, .pitch span.lo { display: inline-block; padding: 0 1px; border-top: 2px solid transparent; }
.pitch span.hi { border-top-color: var(--accent); } .pitch span.drop { border-right: 2px solid var(--accent); }
.pitch sup { font-size: 0.65rem; margin-left: 3px; }
/* placement, skills, goal, heatmap, path, text analyser */
.known-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 2px 14px; margin: 10px 0; }
.known-grid label { display: block; padding: 3px 4px; border-radius: 4px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .known-grid label:hover { background: var(--soft); }
.known-grid [lang="ja"] { font-size: 1.1rem; }
.skills { white-space: nowrap; } .skills span { display: inline-block; width: 22px; height: 6px; background: var(--soft); border-radius: 3px; margin-right: 2px; overflow: hidden; vertical-align: middle; } .skills i { display: block; height: 100%; background: var(--link); }
.st-extras { font-size: 0.9rem; justify-content: flex-start; gap: 10px 20px; } .st-extras select { font: inherit; }
.goal { display: inline-flex; align-items: center; gap: 8px; } .goal .pbar { width: 120px; margin: 0; } .st-links { display: inline-flex; flex-wrap: wrap; gap: 4px 16px; margin-left: auto; }
.heat { display: flex; gap: 2px; overflow-x: auto; padding-bottom: 4px; } .heat-w { display: grid; grid-template-rows: repeat(7, 11px); gap: 2px; }
.heat span { width: 11px; height: 11px; border-radius: 2px; background: var(--soft); } .heat .hx { background: none; }
.heat .h1 { background: #b7dfb9; } .heat .h2 { background: #7cc47f; } .heat .h3 { background: #46a04b; } .heat .h4 { background: #23702a; }
.path { list-style: none; padding: 0; counter-reset: step; } .path li { display: flex; gap: 14px; align-items: center; justify-content: space-between; padding: 12px 14px; margin: 8px 0; border: 1px solid var(--line); border-radius: 8px; }
.path li div { display: flex; flex-direction: column; } .path li.done { opacity: 0.6; } .path li.next { border-color: var(--accent); border-width: 2px; }
.prose textarea { width: 100%; font: inherit; font-size: 1.1rem; padding: 8px; border: 1px solid var(--line); border-radius: 5px; background: var(--field); color: var(--fg); }
.study-these { margin: 6px 0 22px; padding-top: 10px; border-top: 1px dashed var(--line); }
#search-sched input { font: inherit; padding: 5px 8px; border: 1px solid var(--line); border-radius: 5px; background: var(--field); color: var(--fg); min-width: 220px; }
/* forecast and coverage */
.st-forecast { display: flex; gap: 6px; align-items: flex-end; height: 96px; margin-bottom: 8px; }
.st-fc { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 3px; height: 100%; font-size: 0.78rem; }
.st-fc span { width: 100%; max-width: 44px; background: var(--link); border-radius: 3px 3px 0 0; min-height: 1px; } .st-fc em { font-style: normal; color: var(--muted); }
.st-cov th { text-align: left; font-size: 0.85rem; color: var(--muted); padding: 4px 8px; } .st-cov td { vertical-align: top; }
.pbar.small { height: 8px; margin-bottom: 3px; }
/* practice */
.pr-list { list-style: none; padding: 0; } .pr-list li { margin: 8px 0; } .pr-list a { font-weight: 700; margin-right: 8px; }
.pr-opts { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; margin: 8px 0 14px; font-size: 0.9rem; }
.pr-opts select { font: inherit; padding: 3px 6px; } .pr-opts fieldset { border: 1px solid var(--line); border-radius: 5px; padding: 4px 10px; display: flex; flex-wrap: wrap; gap: 4px 12px; } .pr-opts legend { font-size: 0.78rem; color: var(--muted); padding: 0 4px; }
.sentence details.en summary { cursor: pointer; font-size: 0.85rem; }
.reading-credit { margin-top: .4rem; overflow-wrap: anywhere; }
.qz-built, .qz-bank { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; min-height: 50px; padding: 8px; margin-bottom: 10px; }
.qz-built { border-bottom: 2px solid var(--line); }
.qz-tok { font: inherit; font-family: var(--jp); font-size: 1.3rem; padding: 6px 12px; border: 2px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--fg); cursor: pointer; }
.qz-tok:hover { border-color: var(--accent); } .qz-full { font-size: 1.2rem; }
/* shiritori and crossword */
.game { max-width: 560px; margin: 0 auto; } #crossword.game { max-width: none; }
.sh-chain { padding-left: 26px; font-size: 1.25rem; min-height: 60px; } .sh-chain li { margin: 4px 0; } .sh-chain li.me { color: var(--accent); }
.sh-chain .muted { font-size: 0.85rem; }
.cw-wrap { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.cw-grid { display: grid; gap: 2px; background: var(--fg); padding: 2px; border-radius: 4px; }
.cw-cell { position: relative; width: 40px; height: 40px; background: var(--bg); display: flex; align-items: center; justify-content: center; font-size: 1.35rem; cursor: pointer; }
.cw-cell.black { background: var(--fg); cursor: default; } .cw-cell.active { background: #f0d98c; color: #222; } .cw-cell.solved { color: #2f7d4f; }
.cw-cell sup { position: absolute; top: 1px; left: 3px; font-size: 0.6rem; color: var(--muted); }
.cw-side { flex: 1; min-width: 260px; } .cw-clue { flex-basis: 100%; text-align: left; margin-bottom: 6px; } .cw-form { flex-wrap: wrap; justify-content: flex-start; }
.cw-clues { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; font-size: 0.92rem; } .cw-clues h3 { margin: 0 0 4px; font-size: 0.9rem; }
.cw-clues ol { list-style: none; padding: 0; margin: 0; } .cw-clues li { padding: 3px 4px; border-radius: 4px; cursor: pointer; } .cw-clues li:hover, .cw-clues li.active { background: var(--soft); } .cw-clues li.solved { color: var(--muted); text-decoration: line-through; }
@media (max-width: 520px) { .cw-cell { width: 30px; height: 30px; font-size: 1rem; } .cw-clues { grid-template-columns: 1fr; } }

/* study */
.btn.primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); font-weight: 700; }
.btn.done { color: var(--muted); cursor: default; }
.st-top { display: flex; flex-wrap: wrap; gap: 10px 22px; align-items: center; margin-bottom: 22px; }
.st-stat strong { font-size: 1.7rem; display: block; line-height: 1.1; } .st-stat span { font-size: 0.8rem; color: var(--muted); }
.st-sched { padding: 10px 0 14px; border-bottom: 1px solid var(--line); }
.st-name { margin-bottom: 6px; font-weight: 700; } .st-name .muted { font-weight: 400; }
.st-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin: 8px 0; }
.pbar { display: flex; height: 12px; border-radius: 6px; overflow: hidden; background: var(--soft); }
.pb-mastered { background: #2f7d4f; } .pb-known { background: #6bb36f; } .pb-reviewing { background: #d9a520; } .pb-learning { background: #e08a4f; } .pb-new { background: var(--bar); }
.pkey { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 0.78rem; color: var(--muted); margin: 8px 0 14px; } .pkey i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; }
.st-days { display: flex; gap: 4px; align-items: flex-end; height: 84px; }
.st-day { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 3px; height: 100%; }
.st-day span { width: 100%; max-width: 26px; background: var(--common); border-radius: 3px 3px 0 0; min-height: 1px; } .st-day em { font-style: normal; font-size: 0.7rem; color: var(--muted); }
.st-presets { display: flex; flex-wrap: wrap; gap: 8px; } .st-presets.many .btn { min-width: 92px; }
.st-terms td { font-size: 0.9rem; } .st-terms td:first-child { font-size: 1.1rem; white-space: nowrap; }
.lv { display: inline-block; font-size: 0.72rem; padding: 1px 7px; border-radius: 3px; color: #fff; white-space: nowrap; } .lv.pb-new { color: var(--fg); }
#quiz { max-width: 560px; margin: 0 auto; }
.qz-head { display: flex; gap: 12px; align-items: baseline; margin-bottom: 8px; }
.qz-bar { height: 6px; background: var(--soft); border-radius: 3px; overflow: hidden; margin-bottom: 18px; } .qz-bar span { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.25s; }
.qz-prompt { text-align: center; margin-bottom: 16px; }
.qz-word { font-size: 3rem; line-height: 1.3; font-family: var(--jp); } .qz-sentence { font-size: 1.5rem; line-height: 1.8; }
.qz-reading { font-size: 1.2rem; color: var(--muted); } .qz-en { font-size: 1.25rem; margin: 6px 0; }
.qz-ask { color: var(--muted); margin: 8px 0 0; }
.qz-tag { display: inline-block; font-size: 0.72rem; padding: 1px 8px; border-radius: 10px; background: var(--soft); color: var(--muted); margin: 0 0 6px; } .qz-tag.new { background: var(--accent); color: #fff; }
.qz-options { display: grid; gap: 8px; }
.qz-opt { display: flex; gap: 12px; align-items: center; text-align: left; font: inherit; font-size: 1.1rem; padding: 10px 14px; border: 2px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--fg); cursor: pointer; }
.qz-opt:hover:not(:disabled) { border-color: var(--accent); } .qz-opt[lang="ja"] { font-size: 1.35rem; }
.qz-opt.right { border-color: #3a9a5c; background: rgba(58, 154, 92, 0.14); } .qz-opt.wrong { border-color: #c8321e; background: rgba(200, 50, 30, 0.12); }
.qz-key { flex: none; width: 22px; height: 22px; border-radius: 4px; background: var(--soft); color: var(--muted); font-size: 0.75rem; display: flex; align-items: center; justify-content: center; }
.qz-type { display: flex; gap: 8px; justify-content: center; } .qz-type input { font: inherit; font-size: 1.4rem; padding: 6px 10px; border: 2px solid var(--line); border-radius: 6px; background: var(--field); color: var(--fg); width: 240px; }
.qz-draw { display: flex; flex-direction: column; align-items: center; gap: 8px; } .qz-draw canvas { background: var(--field); border: 1px solid var(--line); border-radius: 4px; touch-action: none; cursor: crosshair; }
.qz-feedback { margin-top: 16px; padding: 12px 14px; border-radius: 8px; background: var(--soft); border-left: 5px solid #3a9a5c; } .qz-feedback.no { border-left-color: #c8321e; }
.qz-verdict { font-weight: 700; margin: 0 0 6px; }
.qz-card { margin: 6px 0 10px; } .qz-card .qz-word { font-size: 2rem; } .qz-meanings { margin: 4px 0; padding-left: 20px; } .qz-notes { font-size: 0.92rem; }
.qz-ex { border-left: 3px solid var(--line); padding-left: 10px; margin: 8px 0; } .qz-links { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-top: 8px; font-size: 0.9rem; }
.qz-end { text-align: center; } .qz-end .qz-links { justify-content: center; }
/* grammar */
#grammar-filter { font: inherit; padding: 6px 10px; width: 100%; max-width: 380px; border: 1px solid var(--line); border-radius: 5px; background: var(--field); color: var(--fg); }
.gr-list { list-style: none; padding: 0; } .gr-list li { padding: 3px 0; } .gr-list a { font-size: 1.1rem; margin-right: 8px; }
.grammar-point h1 { font-size: 2.2rem; } .gr-meaning { font-size: 1.2rem; } .gr-form li { font-size: 1.05rem; }
.grammar-point mark { background: rgba(217, 165, 32, 0.35); color: inherit; border-radius: 3px; padding: 0 2px; }

/* word game */
#play { max-width: 460px; margin: 0 auto; }
.pg-head h1 { font-size: 1.3rem; margin: 0 0 8px; } .pg-title-sub { font-size: 0.85rem; font-weight: 400; margin-left: 6px; }
.pg-opts { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; font-size: 0.9rem; }
.pg-grid { display: grid; gap: 5px; justify-content: center; }
.pg-row { display: grid; grid-template-columns: repeat(4, 46px); gap: 5px; }
.pg-tile { position: relative; width: 46px; height: 46px; border: 2px solid var(--line); border-radius: 6px; display: flex; align-items: center; justify-content: center; font-size: 1.5rem; font-weight: 700; }
.pg-tile.typed { border-color: var(--muted); }
.pg-tile.hit, .pg-key.hit, .pg-swatch.hit { background: #3a9a5c; border-color: #3a9a5c; color: #fff; }
.pg-tile.near, .pg-key.near, .pg-swatch.near { background: #d9a520; border-color: #d9a520; color: #fff; }
.pg-tile.miss, .pg-key.miss, .pg-swatch.miss { background: #84878c; border-color: #84878c; color: #fff; }
.pg-tile.h-variant::after, .pg-swatch.h-variant::after { content: ''; position: absolute; inset: 3px; border: 3px solid #fff; border-radius: 50%; opacity: 0.9; }
.pg-tile.h-row, .pg-swatch.h-row { box-shadow: inset 0 -6px 0 #7cc4f4; }
.pg-tile.h-col, .pg-swatch.h-col { box-shadow: inset 6px 0 0 #7cc4f4; }
.pg-msg { text-align: center; min-height: 1.6em; margin: 8px 0; color: var(--accent); font-weight: 700; }
.pg-result { background: var(--soft); border-radius: 6px; padding: 12px 14px; margin-bottom: 12px; }
.pg-result p { margin: 0 0 6px; } .pg-verdict { font-weight: 700; } .pg-answer a { font-size: 1.2rem; }
.pg-result .exports { margin: 8px 0 0; }
.pg-keys { display: grid; gap: 4px; justify-content: center; }
.pg-krow { display: grid; grid-template-columns: repeat(10, minmax(0, 38px)); gap: 4px; } .pg-krow.gap { margin-top: 8px; }
.pg-key { height: 36px; border: 1px solid var(--line); background: var(--soft); color: var(--fg); border-radius: 5px; font: inherit; font-size: 1.05rem; font-family: var(--jp); cursor: pointer; padding: 0; }
.pg-key.blank { visibility: hidden; } .pg-key:hover { border-color: var(--accent); }
.pg-actions { display: flex; justify-content: center; gap: 10px; margin: 12px 0; } .pg-enter { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 700; }
.pg-how { margin-top: 18px; font-size: 0.92rem; } .pg-how summary { cursor: pointer; color: var(--link); } .pg-how ul { list-style: none; padding-left: 0; } .pg-how li { margin: 6px 0; display: flex; gap: 8px; align-items: center; }
.pg-swatch { position: relative; display: inline-block; flex: none; width: 24px; height: 24px; border-radius: 4px; }
@media (max-width: 420px) { .pg-row { grid-template-columns: repeat(4, 40px); } .pg-tile { width: 40px; height: 40px; font-size: 1.3rem; } .pg-key { height: 32px; font-size: 0.95rem; } }

/* prose */
.prose { font-size: 1.05rem; }
.prose h1 { font-size: 1.6rem; margin: 0 0 12px; } .prose h2 { font-size: 1.15rem; margin: 26px 0 6px; }
.prose li { margin: 3px 0; }
.prose code { background: var(--soft); padding: 1px 5px; border-radius: 3px; }
.taglist { columns: 2; font-size: 0.88rem; padding-left: 18px; } @media (max-width: 560px) { .taglist { columns: 1; } }
footer { margin-top: 48px; border-top: 1px solid var(--line); padding-top: 12px; font-size: 0.78rem; color: var(--muted); }

@media (max-width: 560px) {
  #search { flex-direction: column-reverse; align-items: stretch; gap: 6px; }
  .inputs { justify-content: flex-start; }
  .bar input { font-size: 1.1rem; }
  .logo .name { font-size: 1.9rem; }
}

.kana-map { display: flex; flex-wrap: wrap; gap: .4rem; }
.kana-map .btn { min-width: 7rem; }

.rd-dialog { background: var(--bg); color: var(--fg); border: 1px solid var(--line); border-radius: 6px; max-width: min(90vw, 30rem); }
.rd-dialog::backdrop { background: #0009; }
.rd-dialog input { display: block; box-sizing: border-box; width: 100%; margin-top: .5rem; padding: .5rem; background: var(--field); color: var(--fg); border: 1px solid var(--line); font: inherit; }

/* Kana Garden: the Godot game at its own 1200×760 shape, as large as the page allows */
.kg .kg-frame { width: 100%; max-width: 1200px; aspect-ratio: 1200 / 760; margin: 12px 0; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; background: #f6f0e2; }
.kg .kg-frame iframe { display: block; width: 100%; height: 100%; border: 0; }
.kg .kg-small { display: none; }
@media (max-width: 700px) { .kg .kg-small { display: block; } }

/* reader: your audio, speaking practice, editing a part */
.rd-audio { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 12px; } .rd-audio audio { max-width: 100%; }
.rd-edit textarea, .rd-edit input#rd-edit-title { width: 100%; font: inherit; } .rd-edit textarea { font-family: var(--jp); }
.rd-speak select, .rd-edit select { max-width: 100%; }

/* kanji shape lookup */
.kshape fieldset { border: 1px solid var(--line); border-radius: 6px; margin: 10px 0; padding: 8px 10px; display: flex; flex-wrap: wrap; gap: 8px; }
.kshape fieldset[hidden] { display: none; }
.kshape legend { font-weight: 600; padding: 0 4px; }
.shape-pick { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 6px; cursor: pointer; min-height: 44px; }
.shape-pick:has(input:checked) { border-color: var(--accent); background: var(--soft); }
.shape-counts { display: flex; flex-wrap: wrap; gap: 10px 18px; } .shape-counts input { width: 4.5em; } .shape-counts label[hidden] { display: none; }
.si { display: inline-flex; width: 26px; height: 26px; border: 2px solid var(--fg); border-radius: 3px; gap: 2px; padding: 2px; box-sizing: border-box; }
.si i { flex: 1; background: var(--muted); border-radius: 1px; } .si-stack { flex-direction: column; }
.si-wrap { padding: 5px 0 0 5px; border-right-color: transparent; border-bottom-color: transparent; }
.si-whole { background: var(--muted); }

/* study: deck cards */
.qz-image { display: block; max-width: min(100%, 320px); max-height: 220px; margin: 0 auto 10px; border-radius: 6px; object-fit: contain; }
.qz-near { margin: 12px 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--soft); }

/* your decks: the editor */
.dk-card { border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; margin: 10px 0; display: grid; gap: 6px; }
.dk-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.dk-field { display: grid; grid-template-columns: 11em minmax(0, 1fr); gap: 8px; align-items: center; } .dk-field input { width: 100%; font: inherit; }
@media (max-width: 560px) { .dk-field { grid-template-columns: 1fr; gap: 2px; } }
.dk-medias { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; }
.dk-thumb { max-height: 56px; max-width: 90px; border-radius: 4px; vertical-align: middle; }
.deck-new textarea, .deck-edit textarea { width: 100%; font: inherit; } .deck-edit #dk-title { width: 100%; font: inherit; }

/* kana voice studio */
.kv-current { text-align: center; margin: 14px 0; }
.kv-kana { font-family: var(--jp); font-size: 4.5rem; line-height: 1.1; }
.kv-romaji { color: var(--muted); }
.kv-buttons { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; } .kv-buttons .btn { min-height: 44px; }
.kv-progress { display: grid; gap: 4px; }
.kv-grid { display: flex; flex-wrap: wrap; gap: 4px; margin: 10px 0 18px; }
.kv-cell { font-family: var(--jp); min-width: 44px; min-height: 44px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--fg); cursor: pointer; }
.kv-cell.done { background: var(--soft); border-color: var(--common); }
.kv-cell.on { outline: 2px solid var(--accent); }

/* pattern drills: the pack at a glance */
.pt-frame { font-size: 1.25rem; margin: 6px 0; }
.pt-slot { display: inline-block; padding: 0 6px; border-radius: 4px; background: var(--soft); border: 1px dashed var(--line); font-size: .85rem; vertical-align: middle; }
.pt-matrix { display: flex; flex-wrap: wrap; gap: 10px; margin: 10px 0 14px; }
.pt-col { flex: 1 1 140px; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; }
.pt-key { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 4px; }
.pt-val { padding: 2px 0; }
.rw:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }
.rd-lexical [data-component] { text-decoration: underline dotted; text-underline-offset: .18em; }
.rd-lexical [data-open-expression] { cursor: pointer; }
.rd-lexical:has(> [data-expression].sel) { outline: 2px solid var(--accent); border-radius: 3px; }
.rd-lexical:has(> [data-form-reading]:focus-visible) { outline: 2px solid var(--accent); border-radius: 3px; }
.rd-lexical > [data-expression].sel { outline: 0; }
.rd-lexical [data-expression-icon] { display: inline-block; min-width: 1em; text-align: center; vertical-align: middle; font: 0.7em/1 system-ui, sans-serif; }
.rd-lexical [data-expression-icon]::before { content: '⋯'; }
.rd-audio input[type="number"] { width: 7em; }
