/* Hallmark · component: writing dialog · genre: editorial · theme: Japanese notebook
 * states: default · hover · focus · active · disabled · loading · error · success
 * Single navigation footer; mobile example/practice tabs. */
.writing-modal{width:min(860px,calc(100% - 48px));max-height:min(880px,calc(100dvh - 48px));padding:0;border-radius:12px;overflow:hidden}
.writing-modal[open]{display:flex;flex-direction:column}
.writing-modal [hidden]{display:none!important}
.writing-modal-head{flex:none;align-items:center;padding:16px 28px;border-bottom:1px solid var(--color-rule)}
.writing-heading{display:flex;gap:16px;align-items:center;min-width:0}
.writing-modal-head h2{font-size:20px;line-height:1.35}
#writing-symbol{font:500 42px/1.2 var(--font-japanese);color:var(--color-accent)}
#writing-reading{display:block;font-size:13px;color:var(--color-muted);margin-top:2px}
.writing-body{overflow-y:auto;overscroll-behavior:contain;min-height:0;padding:16px 28px 8px}
#writing-hint{font-size:13px;line-height:1.6;margin:0 0 8px;color:var(--color-muted)}
.writing-progress{display:flex;align-items:center;justify-content:space-between;gap:20px;padding-bottom:12px;border-bottom:1px solid var(--color-rule);margin-bottom:16px}
#stroke-status{font-size:13px;font-weight:600;color:var(--color-ink);margin:0;flex-shrink:0;max-width:50%}
.stroke-steps{display:flex;align-items:center;gap:4px;overflow-x:auto;padding:3px;min-width:0}
.stroke-step{flex:0 0 44px;display:grid;place-items:center;min-height:44px;border:1px solid transparent;border-radius:6px;background:transparent;color:var(--color-muted);font-size:14px;cursor:pointer}
.stroke-step[aria-pressed=true]{border-color:var(--color-ink);background:var(--color-ink);color:var(--color-surface)}
.writing-tabs{display:none}
.writing-layout{display:grid;grid-template-columns:minmax(0,240px) minmax(0,1fr);gap:40px;align-items:start}
.writing-practice,.stroke-order{min-width:0}
.writing-layout h3{font-size:14px;font-weight:600;line-height:1.5;margin:0 0 12px;color:var(--color-ink)}
.stroke-demo{width:100%;aspect-ratio:1;border-radius:8px;background:var(--color-paper-2);display:grid;place-items:center;border:1px solid var(--color-rule)}
.writing-layout .writing-stage{width:min(100%,max(240px,calc(100dvh - 510px)),340px);max-width:none;margin:0 auto;aspect-ratio:1;border-radius:8px;background:var(--color-surface)}
.writing-stage::before,.writing-stage::after{display:none}
.writing-stage #writing-pad{cursor:default}
.kana-diagram{display:block;width:100%;height:100%;overflow:visible}
.kana-stroke{fill:none;stroke:var(--color-rule);stroke-width:3.6;stroke-linecap:round;stroke-linejoin:round}
.stroke-written{stroke:var(--color-ink)}
.stroke-current{stroke:var(--color-accent)}
.stroke-arrow{fill:none;stroke:var(--color-accent-ink);stroke-width:1.2;stroke-linecap:round;stroke-linejoin:round}
.stroke-start circle{fill:var(--color-ink);stroke:var(--color-surface);stroke-width:.8}
.stroke-number{font:700 6px var(--font-body);fill:var(--color-surface);stroke:none}
.stroke-end{fill:var(--color-surface);stroke:var(--color-ink);stroke-width:1.2}
.stroke-pen circle{fill:var(--color-accent);stroke:var(--color-surface);stroke-width:1.6}
.is-playing .stroke-demo .stroke-arrows{visibility:hidden}
#writing-guide .trace-diagram{width:100%;height:100%}
.trace-diagram .kana-stroke{stroke:var(--color-rule);stroke-width:2.4}
.trace-diagram .stroke-current{stroke:var(--color-accent);stroke-width:2.8;opacity:.6}
.trace-diagram .stroke-arrow{stroke:var(--color-surface);stroke-width:1}
.trace-diagram .stroke-written{stroke:var(--color-canvas-rule)}
#stroke-instruction{font-size:13px;line-height:1.65;margin:16px 0 0;color:var(--color-muted)}
.stroke-all{display:inline-flex;align-items:center;min-height:44px;margin-top:4px;padding:8px 0;background:transparent;color:var(--color-accent);font-size:13px;text-decoration:underline;text-underline-offset:3px}
.writing-practice>p{font-size:12px;line-height:1.6;color:var(--color-muted);margin:12px 0}
.writing-practice .writing-tools{display:flex;align-items:center;flex-wrap:wrap;gap:8px;margin:12px 0 0}
.writing-practice .writing-tools .btn{flex:0 0 auto;min-height:44px;font-size:13px;padding:8px 12px;white-space:nowrap}
.writing-practice .writing-tools .check-label{display:flex;flex:0 0 auto;align-items:center;gap:8px;width:auto;min-height:44px;font-size:13px;margin:0 0 0 auto}
#writing-instructions summary{display:list-item;min-height:44px;padding:12px 0;font-size:13px;font-weight:500;cursor:pointer}
#writing-instructions{margin:0;padding:0;border-top:1px solid var(--color-rule);font-size:13px}
#stroke-last{font-size:13px;line-height:1.6;color:var(--color-success);margin:16px 0 0}
.stroke-controls{flex:none;display:flex;align-items:center;gap:8px;padding:16px 28px;border-top:1px solid var(--color-rule);background:var(--color-surface)}
.stroke-controls .btn{min-height:48px;padding:12px 16px;white-space:nowrap;font-size:13px;line-height:1.3;border-radius:6px}
.stroke-controls .stroke-back,.stroke-controls .stroke-replay{width:48px;flex-shrink:0;padding:12px}
.stroke-controls #stroke-next{margin-left:auto;min-width:200px;justify-content:space-between}
.stroke-controls svg{width:18px;height:18px;flex-shrink:0}
.stroke-back svg{transform:rotate(180deg)}
.writing-modal:has(.stroke-order[data-state=error]) #stroke-status{color:var(--color-error)}
.writing-progress:has(#stroke-steps:empty) #stroke-status{max-width:100%}
.stroke-order[data-state=success] .stroke-demo{border-color:var(--color-canvas-rule)}
.stroke-order[data-state=loading] .stroke-demo{background:var(--color-paper-2)}
.writing-free .writing-progress,.writing-free .writing-tabs,.writing-free .stroke-controls{display:none}
.writing-free .writing-layout{grid-template-columns:1fr}
.writing-free .writing-practice{width:min(100%,380px);margin:auto}
.writing-modal button:disabled{opacity:.45;cursor:not-allowed}
.writing-modal :is(button,a,summary):focus-visible{outline:2px solid var(--color-focus);outline-offset:2px}
.writing-modal button:active:not(:disabled){transform:translateY(1px)}
@media(hover:hover){.stroke-step:hover:not([aria-pressed=true]),.stroke-controls .btn.secondary:hover,.writing-tabs button:hover{background:var(--color-paper-2)}.stroke-all:hover{color:var(--color-accent-hover)}.stroke-controls #stroke-next:hover:not(:disabled){background:var(--color-accent-hover)}}
@media(max-width:700px){
 .writing-modal{width:100%;max-width:100%;height:100dvh;max-height:100dvh;margin:0;border:0;border-radius:0;padding:0}
 .writing-modal-head{padding:16px 20px;padding-top:max(16px,env(safe-area-inset-top));gap:12px}
 .writing-modal-head h2{font-size:18px}.writing-heading{gap:12px}#writing-symbol{font-size:34px}
 .writing-body{padding:16px 20px 8px}
 #writing-hint{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap;margin:0}
 .writing-progress{gap:12px;margin:0;padding:0 0 12px;border:0}
 #stroke-status{font-size:12px}
 .writing-tabs{display:flex;align-items:center;gap:0;margin-bottom:20px;border-bottom:1px solid var(--color-rule)}
 .writing-tabs button{flex:1;min-height:48px;padding:12px 8px;font-size:14px;background:transparent;color:var(--color-muted);border-bottom:2px solid transparent}
 .writing-tabs button[aria-selected=true]{color:var(--color-ink);border-bottom-color:var(--color-accent);font-weight:600}
 .writing-layout{display:block}.writing-layout h3{display:none}
 .writing-modal[data-pane=example] .writing-practice{display:none}
 .writing-modal[data-pane=practice] .stroke-order{display:none}
 .stroke-demo,.writing-layout .writing-stage{width:min(100%,max(220px,calc(100dvh - 400px)),360px);margin-inline:auto}
 #stroke-instruction{margin:16px auto 0;max-width:360px;font-size:13px}
 .stroke-all{margin:4px 0 0}
 .stroke-controls{padding:12px 20px;padding-bottom:max(12px,env(safe-area-inset-bottom));gap:8px}
 .stroke-controls #stroke-next{min-width:0;flex:1;justify-content:center;font-size:12px;padding-inline:12px;gap:8px}
 .stroke-controls #stroke-next svg{display:none}
}
@media(max-width:360px){.writing-body{padding-inline:16px}.writing-modal-head{padding-inline:16px}.stroke-controls{padding-inline:16px}}
@media(prefers-reduced-motion:reduce){.writing-modal button:active:not(:disabled){transform:none}}
