:root{--bg:#f4f1ea;--card:#fffefb;--ink:#191816;--muted:#6f6a60;--line:#d8d2c6;--guide:#e7e2d7;--accent:#b3261e;--accent-ink:#fff;--good:#1f6f4a;--good-ink:#fff;--soft:#ebe6db;--warn:#8a5a00;--shadow:0 1px 2px rgba(40,30,10,.08),0 10px 28px rgba(40,30,10,.10)}
[data-theme=dark]{color-scheme:dark;--bg:#171614;--card:#23211e;--ink:#f3efe7;--muted:#a8a296;--line:#403c35;--guide:#35322c;--accent:#ff8a7d;--accent-ink:#2a0805;--good:#6fd0a3;--good-ink:#06281a;--soft:#2e2b27;--warn:#e9b949;--shadow:0 1px 2px rgba(0,0,0,.4),0 10px 28px rgba(0,0,0,.35)}
*{box-sizing:border-box}
html,body{height:100%}
body{margin:0;background:var(--bg);color:var(--ink);font-family:"Noto Sans JP Kartu","Noto Sans JP",system-ui,sans-serif;-webkit-text-size-adjust:100%;-webkit-tap-highlight-color:transparent}
button{font:inherit;color:inherit;cursor:pointer;border:0;background:none}
button:focus-visible,.card:focus-visible{outline:3px solid var(--accent);outline-offset:2px}
[hidden]{display:none!important}
.view{min-height:100dvh;max-width:560px;margin:0 auto;padding:max(20px,env(safe-area-inset-top)) 16px max(20px,env(safe-area-inset-bottom));display:flex;flex-direction:column}
h1{font-size:1.5rem;margin:0;font-weight:700}
.sub{color:var(--muted);font-size:.875rem;margin:.25rem 0 1.25rem}
.tabs{display:grid;grid-template-columns:repeat(3,1fr);gap:8px;margin-bottom:1.25rem}
.tab{background:var(--card);border:1.5px solid var(--line);border-radius:12px;padding:12px 6px;text-align:center;min-height:88px}
.tab b{display:block;font-size:1.0625rem}
.tab small{display:block;color:var(--muted);font-size:.75rem;margin-top:2px}
.tab .bar{margin-top:8px}
.tab[aria-pressed=true]{border-color:var(--accent);box-shadow:inset 0 0 0 1px var(--accent)}
.bar{height:5px;border-radius:3px;background:var(--soft);overflow:hidden}
.bar i{display:block;height:100%;background:var(--good);width:0}
.label{font-size:.8125rem;font-weight:700;color:var(--muted);margin:0 0 .5rem}
.cats{display:flex;flex-direction:column;gap:6px;margin-bottom:1.25rem}
.cat{display:flex;align-items:center;gap:10px;background:var(--card);border:1px solid var(--line);border-radius:10px;padding:11px 12px;text-align:left;min-height:46px}
.box{width:20px;height:20px;border-radius:5px;border:1.5px solid var(--line);flex:none;display:grid;place-items:center;color:transparent;font-size:.8125rem;font-weight:700}
[aria-checked=true]>.box,[aria-checked=mixed]>.box{background:var(--accent);border-color:var(--accent);color:var(--accent-ink)}
.cat span:nth-child(2){flex:1;min-width:0}
.cat small{color:var(--muted);font-variant-numeric:tabular-nums;font-size:.8125rem}
.bulk{display:flex;flex-wrap:wrap;align-items:center;gap:0 8px;margin-bottom:.25rem}
.bulk .label{flex:1 1 100%;margin:0}
.mini{flex:1;min-height:44px;font-size:.8125rem;font-weight:700;color:var(--accent)}
.acc{background:var(--card);border:1px solid var(--line);border-radius:10px;overflow:hidden}
.acc-r{display:flex;align-items:stretch}
.acc-c{flex:none;width:48px;min-height:48px;display:grid;place-items:center}
.acc-h{flex:1;min-width:0;display:flex;align-items:center;gap:8px;padding:8px 12px 8px 0;text-align:left}
.acc-t{flex:1;min-width:0;overflow-wrap:anywhere}
.num{flex:none;color:var(--muted);font-variant-numeric:tabular-nums;font-size:.8125rem;white-space:nowrap}
.chev{flex:none;width:8px;height:8px;margin:0 3px;border:solid var(--muted);border-width:0 2px 2px 0;transform:translateY(-2px) rotate(45deg)}
.acc-h[aria-expanded=true] .chev{transform:translateY(2px) rotate(225deg)}
.secr{display:flex;align-items:center;border-top:1px solid var(--guide);padding-right:8px}
.sec{flex:1;min-width:0;min-height:48px;display:flex;align-items:center;gap:0;padding:4px 8px 4px 14px;text-align:left}
.sec .box{margin-right:14px}
.sec-n{flex:1;min-width:0;padding-right:8px;overflow-wrap:anywhere;font-size:.9375rem}
.sec-n small{display:block;color:var(--muted);font-size:.75rem;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.lat{flex:none;min-width:56px;min-height:44px;border-radius:8px;background:var(--soft);color:var(--accent);font-size:.8125rem;font-weight:700}
.opts{display:flex;flex-direction:column;gap:6px;margin-bottom:1.25rem}
.primary{background:var(--accent);color:var(--accent-ink);font-weight:700;border-radius:12px;padding:14px;width:100%;font-size:1.0625rem;min-height:52px}
.primary:disabled{opacity:.45;cursor:not-allowed}
.spacer{flex:1}
.foot{color:var(--muted);font-size:.6875rem;line-height:1.55;margin-top:1rem}
.link{color:var(--muted);text-decoration:underline;font-size:.8125rem;padding:10px 0;align-self:center}
.top{display:flex;align-items:center;gap:12px;margin-bottom:12px}
.top .bar{flex:1}
.top .x{width:44px;height:44px;margin:-8px 0 -8px -10px;font-size:1.375rem;color:var(--muted)}
.count{font-size:.8125rem;color:var(--muted);font-variant-numeric:tabular-nums;white-space:nowrap}
.stage{flex:1;perspective:1600px;min-height:340px;display:flex;margin-bottom:12px}
.card{position:relative;flex:1;transform-style:preserve-3d;transition:transform .36s cubic-bezier(.3,.7,.3,1);cursor:pointer;border-radius:18px}
.card.flip{transform:rotateY(180deg)}
.card.still{transition:none}
.face{position:absolute;inset:0;backface-visibility:hidden;-webkit-backface-visibility:hidden;background:var(--card);border-radius:18px;box-shadow:var(--shadow);display:flex;flex-direction:column;padding:14px 16px;overflow-y:auto;container-type:inline-size}
.back{transform:rotateY(180deg)}
.meta{font-size:.75rem;color:var(--muted);flex:none}
.id{font-size:.75rem;color:var(--muted);text-align:right;flex:none}
.mid{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;min-height:0;gap:10px;padding:6px 0}
.big{font-weight:400;line-height:1.2;overflow-wrap:anywhere}
.reading{font-weight:700;color:var(--accent);line-height:1.3;overflow-wrap:anywhere}
.meaning{font-size:1.25rem;line-height:1.4}
.note{font-size:.875rem;color:var(--muted);line-height:1.55;max-width:34em}
.hint{font-size:.75rem;color:var(--muted);text-align:center;flex:none}
.strokes{display:flex;gap:8px;justify-content:center;width:100%}
.sbox{flex:1 1 0;max-width:min(62cqw,250px);aspect-ratio:1;border:1px solid var(--line);border-radius:4px;display:block;background:var(--card)}
.sbox .gd{stroke:var(--guide);stroke-width:.6;stroke-dasharray:2 2}
.sbox .st{fill:none;stroke:var(--ink);stroke-width:3.4;stroke-linecap:round;stroke-linejoin:round}
.sbox text{fill:var(--accent);font-size:7px;font-family:inherit}
.play{font-size:.8125rem;color:var(--accent);padding:10px 14px;font-weight:700;min-height:44px}
.kj{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:14px;align-items:center;width:100%;text-align:left}
.kj .sbox{max-width:none;width:100%}
.yomi{font-weight:700;color:var(--accent);line-height:1.8;font-size:1rem}
.yomi span{color:var(--muted);font-weight:400;margin-right:.4em}
.ex{list-style:none;padding:0;margin:0;width:100%;text-align:left;font-size:.875rem;line-height:1.5}
.ex li{padding:4px 0;border-top:1px solid var(--guide)}
.ex b{font-weight:500}
.ex em{font-style:normal;color:var(--muted)}
.acts{display:grid;grid-template-columns:1fr 1fr;gap:8px;flex:none}
.acts button{border-radius:12px;padding:14px 8px;font-weight:700;min-height:52px}
.again{background:var(--soft)}
.know{background:var(--good);color:var(--good-ink)}
.full{grid-column:1/-1;background:var(--accent);color:var(--accent-ink)}
.keys{font-size:.6875rem;color:var(--muted);text-align:center;margin-top:8px}
@media (hover:none){.keys{display:none}}
.done{flex:1;display:flex;flex-direction:column;justify-content:center;text-align:center;gap:8px}
.done .n{font-size:3.5rem;font-weight:700;color:var(--good);line-height:1.1}
.done .primary{margin-top:1rem}
@media (prefers-reduced-motion:reduce){.card{transition:none}}
.recall-row{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:2px 8px;margin-bottom:8px}
.recall{font-size:.8125rem;font-weight:700;font-variant-numeric:tabular-nums}
.recall-key{font-size:.6875rem;color:var(--muted)}
[data-grade=ex]{color:var(--good)}
[data-grade=go]{color:var(--warn)}
[data-grade=po]{color:var(--accent)}
.recall-sum{display:flex;flex-wrap:wrap;justify-content:center;gap:4px 14px;font-weight:700;font-variant-numeric:tabular-nums}
.recall-sum small{flex-basis:100%;text-align:center;font-weight:400;color:var(--muted)}
