:root { color: #263044; background: #f5f1e8; font-family: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif; line-height: 1.7; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
.lab { max-width: 780px; margin: auto; padding: 24px 20px 40px; }
h1 { margin: 4px 0; font-size: clamp(24px, 5vw, 32px); }
h2 { margin: 12px 0; font-size: clamp(20px, 4vw, 26px); line-height: 1.8; }
p { margin: 8px 0; }
.eyebrow { color: #9a4428; font-size: 12px; font-weight: 700; letter-spacing: .06em; }
.hint { color: #606b7d; font-size: 14px; }
a { color: #3157b7; }
nav, .actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 16px 0; }
.review-start { flex-basis: 100%; }
.kanji-picker { margin: 16px 0; padding: 10px 16px; border: 1px solid #bbb5a9; border-radius: 12px; }
.library-controls { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
label { display: block; font-size: 14px; }
select { width: 100%; min-height: 48px; padding: 10px; border: 1px solid #929cac; border-radius: 8px; background: #fff; color: inherit; font: inherit; }
select:focus-visible { outline: 3px solid #3157b7; outline-offset: 3px; }
.character-list { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; margin: 14px 0; }
.character-list.word-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.character-item { display: grid; gap: 3px; padding: 8px 4px; }
.character-item strong { font-family: "Hiragino Mincho ProN", "Yu Mincho", serif; font-size: 28px; }
.character-item .hint { font-size: 12px; }
.character-model { display: block; font-family: "Hiragino Mincho ProN", "Yu Mincho", serif; font-size: 64px; }
.readings { font-size: 15px; overflow-wrap: anywhere; }
button { min-height: 48px; padding: 10px 16px; border: 1px solid #bbb5a9; border-radius: 10px; color: inherit; background: #fff; cursor: pointer; font: inherit; font-size: 15px; font-weight: 700; }
button:hover:not(:disabled) { border-color: #3157b7; }
button:disabled { opacity: .45; cursor: default; }
button:focus-visible, a:focus-visible, summary:focus-visible, input:focus-visible { outline: 3px solid #3157b7; outline-offset: 3px; }
button[aria-pressed="true"], .primary { color: #fff; border-color: #3157b7; background: #3157b7; }
.card { padding: 22px; border: 1px solid #ddd8ce; border-radius: 16px; background: #fff; box-shadow: 0 6px 24px #28231908; }
.question-reading { padding: 2px 8px; color: #9a4428; background: #fff1e8; border-bottom: 2px solid #b1573a; }
.writing-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin-top: 20px; }
.writing-grid.single { grid-template-columns: minmax(0, 320px); justify-content: center; }
.writing-cell { min-width: 0; }
.cell-label { margin-bottom: 6px; font-size: 13px; color: #606b7d; }
.paper { position: relative; aspect-ratio: 1; border: 2px solid #929cac; border-radius: 8px; overflow: hidden; background: #fffdf8; }
.paper::before, .paper::after { content: ""; position: absolute; pointer-events: none; }
.paper::before { top: 50%; width: 100%; border-top: 1px dashed #c9c4b9; }
.paper::after { left: 50%; height: 100%; border-left: 1px dashed #c9c4b9; }
.model { position: absolute; inset: 0; display: grid; place-items: center; color: #b9b2a4; font-family: "Hiragino Mincho ProN", "Yu Mincho", serif; font-size: 230px; line-height: 1; pointer-events: none; user-select: none; }
canvas { display: block; position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; user-select: none; -webkit-user-select: none; cursor: crosshair; }
.answer { margin-top: 18px; padding: 16px; border-radius: 12px; background: #f0f4fc; }
.answer-word { display: block; font-family: "Hiragino Mincho ProN", "Yu Mincho", serif; font-size: 44px; letter-spacing: .12em; }
.rating { margin-bottom: 0; }
.judgement { margin-top: 18px; padding: 12px 16px; border-radius: 10px; background: #f0f4fc; border-left: 4px solid #929cac; }
.judgement[data-state="pass"] { border-color: #21804a; background: #edf8f0; }
.judgement[data-state="retry"] { border-color: #bd421b; background: #fff1e8; }
.stroke-demonstration { margin: 12px 0; }
.stroke-models { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; }
.stroke-model { display: block; width: 100%; max-width: 290px; background: #fffdf8; border: 1px solid #c9c4b9; border-radius: 8px; }
.stroke-model path, .stroke-outline path { fill: none; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.stroke-background { stroke: #c9c4b9; }
.stroke-ink { stroke: #202b40; }
.stroke-highlight { stroke: #bd421b; }
.stroke-ink, .stroke-highlight { opacity: 0; animation: stroke-draw .55s linear forwards; }
@keyframes stroke-draw { from { opacity: 1; } to { opacity: 1; stroke-dashoffset: 0; } }
.stroke-number { fill: #9a4428; font: 7px sans-serif; }
.stroke-outline { width: 100%; height: 100%; }
.next { width: 100%; margin-top: 16px; }
.count { color: #606b7d; font-size: 14px; }
progress { display: block; width: 100%; height: 8px; accent-color: #3157b7; margin: 8px 0 16px; }
summary { cursor: pointer; min-height: 44px; padding: 8px 0; }
input { display: block; width: 100%; min-height: 48px; padding: 10px; border: 1px solid #929cac; border-radius: 8px; font: inherit; }
.result { text-align: center; }
.result-score { font-size: 36px; font-weight: 700; color: #3157b7; }
.result ul { text-align: left; }
@media (max-width: 480px) {
  .lab { padding: 16px 12px 28px; }
  .card { padding: 16px 12px; }
  .writing-grid { grid-template-columns: minmax(0, 290px); justify-content: center; gap: 16px; }
  nav button { flex: 1; }
  nav button { flex-basis: 100%; }
  .character-list { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .actions button { flex: 1; }
}
@media (prefers-color-scheme: dark) {
  :root { background: #111722; color: #edf1f8; }
  .card, button { background: #1d2635; border-color: #4a566b; }
  .hint, .count, .cell-label { color: #b8c1d0; }
  .eyebrow { color: #ffad8f; }
  .question-reading { background: #3b241d; color: #ffad8f; }
  .answer { background: #26334c; }
  .judgement { background: #26334c; }
  .judgement[data-state="pass"] { background: #17362a; border-color: #7fda9a; }
  .judgement[data-state="retry"] { background: #3b241d; border-color: #ffad8f; }
  a, .result-score { color: #a6bfff; }
  input { background: #111722; color: inherit; }
  select { background: #1d2635; }
}
@media (prefers-reduced-motion: reduce) {
  .stroke-model path { animation: none !important; opacity: 1 !important; stroke-dashoffset: 0 !important; }
}
