@font-face{font-family:"Practice Charis";src:url('/sound-chart/assets/fonts/Charis-Regular.woff2') format('woff2');font-display:swap}
@font-face{font-family:"Guanhua Zimu";src:url('/sound-chart/assets/fonts/GuanhuaZimu-Regular.ttf');font-display:swap}
@font-face{font-family:"Musa Handwriting";src:url('/sound-chart/assets/fonts/ZhouheiMusaFangzi-Bold.otf');font-display:swap}
@font-face{font-family:"canIPA Mandarin";src:url('/sound-chart/assets/fonts/canIPA-Mandarin-Subset.ttf');font-display:swap}
:root{font-family:system-ui,-apple-system,"Segoe UI",sans-serif;color:#26333b;background:#f5f2eb;accent-color:#8b3a2b;font-synthesis:none;--accent:#8b3a2b;--muted:#6d706b;--border:#ddd8ce}
*{box-sizing:border-box}body{margin:0}button,input,select,textarea{font:inherit}button,select,input[type=number],input[type=text],input[type=search],textarea{border:1px solid #ccc7bc;border-radius:7px;background:#fff;color:inherit}button{cursor:pointer;padding:8px 11px;font-size:.82rem;font-weight:650;min-height:36px}button:hover{border-color:var(--accent);background:#f9f0e9}button:disabled{opacity:.45;cursor:default}button.primary{background:var(--accent);color:#fff;border-color:var(--accent)}button.primary:hover{background:#6b2d21}button:focus-visible,a:focus-visible,input:focus-visible,select:focus-visible,summary:focus-visible,textarea:focus-visible{outline:3px solid #b76b42;outline-offset:3px}input,select,textarea{min-width:0}input[type=number],input[type=text],input[type=search],select{padding:8px;width:100%;min-height:37px}input[type=color]{width:100%;height:37px;border:1px solid var(--border);border-radius:7px;background:#fff;padding:4px}textarea{width:100%;resize:vertical;padding:10px;line-height:1.7;font-size:1rem}a{color:var(--accent)}h2{font-size:.98rem;margin:0 0 10px}p{line-height:1.6}.appShell{max-width:1560px;margin:auto;padding:25px clamp(14px,3vw,38px) 45px}.intro{margin:25px 0}.intro p{font-size:1.22rem;font-weight:650;margin:0 0 5px;letter-spacing:-.02em}.intro>span{color:var(--muted);font-size:.9rem}.workspace{display:grid;grid-template-columns:350px minmax(0,1fr);gap:24px;align-items:start}.controls{display:grid;gap:12px;min-width:0}.controlPanel{border:1px solid var(--border);border-radius:12px;background:#fff;padding:18px}.controlPanel summary{font-size:.93rem;font-weight:750;cursor:pointer;list-style-position:outside;margin-left:15px}.controlPanel[open] summary{margin-bottom:20px}.controlGrid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:13px 12px}.field{display:flex;flex-direction:column;gap:6px;font-size:.77rem;font-weight:650;min-width:0}.field.wide{grid-column:1/-1}.field>span{line-height:1.35}.field select{font-size:.83rem;font-weight:400}.check{display:flex;gap:8px;align-items:flex-start;font-size:.78rem;line-height:1.45;font-weight:500;grid-column:1/-1}.check input{margin:3px 0 0}.help{font-size:.75rem;line-height:1.55;color:var(--muted);font-weight:400}.help:empty{display:none}.textField{margin-top:18px}.smallActions{display:flex;gap:7px;align-items:center;flex-wrap:wrap}.smallActions>button{font-size:.73rem;padding:6px 9px;min-height:32px}.presetGrid{display:grid;grid-template-columns:1fr 1fr;gap:7px}.presetGrid button{font-size:.75rem;text-align:left;background:#f9f7f2;border-color:#e4ded2}.presetGrid button.active{border-color:var(--accent);background:#f3e8dc;color:var(--accent)}#gridPicker{display:flex;align-items:center;gap:12px;text-align:left;width:100%;margin-bottom:17px;margin-top:3px;padding:10px}#chosenGridThumb{height:36px;width:40px;display:flex;flex:none;justify-content:center}#chosenGridThumb svg{height:100%;max-width:100%}#chosenGridLabel{flex:1}#chosenGridLabel small{display:block;font-weight:450;margin-top:3px}#characterCount{margin-left:auto}.previewPanel{min-width:0;border:1px solid #d6d2c8;border-radius:13px;overflow:hidden;background:#ebe8e0}.previewToolbar{display:flex;justify-content:space-between;gap:15px;align-items:center;background:#fff;padding:15px 18px;border-bottom:1px solid var(--border)}.previewToolbar h2{margin:0 0 3px}.previewToolbar .help{font-size:.7rem}.previewToolbar>button{flex:none}.pageNavigation{display:flex;align-items:center;gap:8px;padding:12px 18px;font-size:.78rem}.pageNavigation>button{min-width:34px;padding:6px}.pageNavigation>label{display:flex;align-items:center;gap:7px}.pageNavigation input{width:52px;padding:6px;text-align:center;min-height:34px}.zoomControl{margin-left:auto}.zoomControl select{width:100px;padding:6px;min-height:34px;font-size:.75rem}.previewViewport{overflow:auto;padding:10px 26px 26px;min-height:300px;max-height:950px}.previewViewport svg{display:block;background:#fff;box-shadow:0 5px 20px #493e251c;max-width:none}#pagePreview{width:100%;margin:auto}#pagePreview.fit svg{width:100%;height:auto}.printHelp{margin:0;padding:0 20px 18px}.notice{padding:10px 12px;margin:12px 0;border-radius:8px;background:#fff5dd;color:#75541c;font-size:.78rem;line-height:1.55}#previewError,#appStatus{margin:0 18px 14px}.strokePanel{background:#fff;border-top:1px solid var(--border);padding:20px}.strokeHead{display:flex;align-items:flex-start;justify-content:space-between;gap:16px}.strokeHead>div{max-width:520px}.strokeHead p{margin:0}.strokeHead>.field{width:160px;flex:none}.strokeCharacters{display:flex;gap:5px;flex-wrap:wrap;margin:12px 0;max-height:165px;overflow:auto}.strokeCharacters>button{font-size:1.15rem;min-width:34px;min-height:38px;padding:3px;position:relative}.strokeCharacters>button.missing{border-style:dashed;color:#918a80}.strokeCharacters>button[aria-pressed=true]{border-color:var(--accent);background:#f5e7db}.strokePlayer{display:flex;gap:20px;align-items:center}.strokeCanvas{width:180px;max-width:40%;flex:none;aspect-ratio:1;border:1px solid #e2d7ce;background:linear-gradient(45deg,transparent 49.7%,#e8e0d7 49.7%,#e8e0d7 50.3%,transparent 50.3%),linear-gradient(-45deg,transparent 49.7%,#e8e0d7 49.7%,#e8e0d7 50.3%,transparent 50.3%);position:relative}.strokeCanvas:before,.strokeCanvas:after{content:'';position:absolute;background:#e8e0d7;pointer-events:none}.strokeCanvas:before{left:50%;top:0;height:100%;width:1px}.strokeCanvas:after{top:50%;left:0;height:1px;width:100%}.strokeCanvas svg{width:100%;height:100%;position:relative;z-index:1}.strokeActions{min-width:0;flex:1}.strokeActions>.field{margin-top:12px;max-width:160px}.strokeActions .help{margin-bottom:0}.strokeCanvas .unavailable{position:absolute;inset:0;display:grid;place-items:center;font-size:4rem;color:#998e82}dialog{border:1px solid var(--border);border-radius:16px;max-width:min(720px,calc(100vw - 28px));max-height:calc(100dvh - 36px);padding:24px;color:inherit;box-shadow:0 25px 70px #0003}dialog::backdrop{background:#26333b66;backdrop-filter:blur(2px)}dialog p,dialog li{font-size:.9rem;line-height:1.7}.dialogHead{display:flex;justify-content:space-between;align-items:center;gap:20px;margin-bottom:18px}.dialogHead h2{font-size:1.2rem;margin:0}#gridDialog{width:700px}#gridOptions h3{font-size:.75rem;text-transform:uppercase;letter-spacing:.06em;color:var(--muted);margin:20px 0 9px}.gridCards{display:grid;grid-template-columns:repeat(4,1fr);gap:8px}.gridOption{display:flex;flex-direction:column;align-items:center;justify-content:flex-start;gap:9px;padding:12px 6px;font-size:.72rem;line-height:1.35;text-align:center;min-height:125px}.gridOption svg{width:45px;height:48px}.gridOption small{font-size:.7rem;font-weight:400}.gridOption[aria-pressed=true]{border:2px solid var(--accent);background:#faf0e7}.gridOption span{display:block}.savePanel .smallActions{margin-top:12px}#printPages{display:none}[hidden]{display:none!important}
@media(min-width:1150px){.previewToolbar{position:sticky;top:0;z-index:2}.previewViewport{max-height:1000px}}
@media(max-width:1000px){.workspace{grid-template-columns:300px minmax(0,1fr);gap:14px}.controlPanel{padding:14px}.appShell{padding:18px 14px}.strokeHead{flex-direction:column}.strokeHead>.field{width:100%}.strokePlayer{flex-direction:column;align-items:stretch}.strokeCanvas{max-width:100%;align-self:center}.previewToolbar{flex-wrap:wrap}.zoomControl>span{display:none}.previewViewport{padding:8px 14px 18px}}
@media(max-width:740px){.workspace{grid-template-columns:1fr}.controls{grid-template-columns:1fr}.previewPanel{grid-row:2}.previewViewport{max-height:none}.intro{margin:15px 0 20px}.toolHeaderActions{flex-wrap:wrap!important}.toolHeaderActions .toolLanguage{margin-left:auto!important}.strokePlayer{flex-direction:row}.strokeCanvas{width:140px;max-width:36%}.gridCards{grid-template-columns:repeat(3,1fr)}.appShell .toolHeader h1{font-size:2.1rem!important}.previewToolbar{position:static}.previewToolbar>button{margin-left:auto}.pageNavigation{padding:10px 12px;gap:6px}.pageNavigation .zoomControl select{width:94px}.controlPanel summary{padding:3px 0}.controlGrid{gap:15px}.strokePanel{padding:16px}}
@media(max-width:390px){.strokePlayer{flex-direction:column}.strokeCanvas{max-width:100%;width:160px}.gridCards{grid-template-columns:repeat(2,1fr)}.pageNavigation{flex-wrap:wrap}.zoomControl{margin-left:auto}.previewToolbar{padding:12px}.pageNavigation label>span{font-size:.7rem}}
@media print{html,body{margin:0!important;padding:0!important;background:#fff!important}body>*{display:none!important}body>#printPages{display:block!important}#printPages>.printedPage{display:block;break-after:page;page-break-after:always;margin:0;padding:0;line-height:0;overflow:hidden}#printPages>.printedPage:last-child{break-after:auto;page-break-after:auto}#printPages svg{display:block;margin:0;padding:0}*{-webkit-print-color-adjust:exact;print-color-adjust:exact}dialog{display:none!important}}
@media(prefers-reduced-motion:reduce){*{scroll-behavior:auto!important}}

.mobileTools{display:none}.mobileTools a{text-decoration:none;font-weight:700;font-size:.85rem;padding:10px 18px;border-radius:7px;background:#fff;color:#8b3a2b}.mobileTools a:last-child{background:#8b3a2b;color:#fff}@media(max-width:740px){.mobileTools{position:fixed;bottom:0;left:0;right:0;z-index:5;display:flex;justify-content:center;gap:12px;padding:8px 12px calc(8px + env(safe-area-inset-bottom));border-top:1px solid #d6d2c8;background:#f5f2ebf2;backdrop-filter:blur(8px)}.appShell{padding-bottom:95px}#previewHeading,#text{scroll-margin-top:16px}}

/* The settings and preview have independent scrolling; paper choices stay in
   the settings column and never dim or cover the live worksheet. */
.workspace{margin-top:20px;--workspace-height:calc(100dvh - 150px)}
.controls{max-height:var(--workspace-height);overflow:auto;overscroll-behavior:contain;scrollbar-gutter:stable;padding-right:5px;align-content:start}
.previewPanel{max-height:var(--workspace-height);overflow:auto;overscroll-behavior:contain;scrollbar-gutter:stable}
.previewToolbar{position:sticky;top:0;z-index:3}
.previewViewport{max-height:calc(var(--workspace-height) - 145px);min-height:220px}
.paperPicker{border:1px solid var(--border);border-radius:9px;background:#faf8f3;margin:-5px 0 18px;padding:10px;max-width:100%;box-shadow:none}
.paperPicker .dialogHead{gap:8px;margin-bottom:8px}.paperPicker .dialogHead h2{font-size:.85rem}
.paperPicker .dialogHead button{font-size:.72rem;padding:4px 7px;min-height:30px}
#gridOptions{max-height:42dvh;overflow:auto;overscroll-behavior:contain;padding:2px}
#gridOptions h3{font-size:.69rem;margin:12px 0 7px}.gridCards{grid-template-columns:repeat(2,minmax(0,1fr));gap:6px}
.gridOption{flex-direction:row;min-height:57px;padding:7px 5px;gap:6px;font-size:.67rem;text-align:left;align-items:center;border-width:2px;border-color:transparent}
.gridOption svg{width:30px;height:32px;flex:none}.gridOption span{min-width:0}.gridOption[aria-pressed=true]{border-width:2px}
#editAnnotations{margin-top:12px}.copyHint,.manualHint{grid-column:1/-1;margin:0;font-size:.72rem}.diagramSettings{grid-column:1/-1}
@media(max-width:1100px){.workspace{grid-template-columns:300px minmax(0,1fr);gap:14px}}
@media(max-width:740px){.workspace{display:flex;flex-direction:column;gap:12px}.previewPanel{order:-1;width:100%;max-height:47dvh;position:sticky;top:8px;z-index:2}.previewViewport{max-height:calc(47dvh - 126px);min-height:130px;padding:8px 14px 14px}.previewToolbar{padding:9px 12px}.pageNavigation{padding:7px 12px}.printHelp{display:none}.controls{width:100%;max-height:65dvh;padding-right:2px}.paperPicker #gridOptions{max-height:36dvh}.gridCards{grid-template-columns:repeat(2,minmax(0,1fr))}.toolHeader{margin-bottom:0}.strokePanel{position:relative}.mobileTools{display:none}.appShell{padding-bottom:22px}}
@media print{.controls,.previewPanel{max-height:none;overflow:visible}}

.previewViewport{position:relative}#pagePreview [data-source-start]{cursor:text}#pagePreview [data-source-start]:hover{paint-order:stroke;stroke:#8b3a2b33;stroke-width:.18}#pagePreview [data-source-start]:focus{outline:none;paint-order:stroke;stroke:#8b3a2b66;stroke-width:.25}.editingSource{opacity:0!important}
#previewEditLayer{position:absolute;z-index:4;border:2px solid var(--accent);border-radius:6px;background:#fff;box-shadow:0 4px 18px #0002;padding:3px}
#previewTextEditor{display:block;resize:vertical;padding:2px 4px;border:0;box-shadow:none;border-radius:0;line-height:1.25;min-height:42px;background:#fff;color:#26333b;font-weight:400;white-space:pre-wrap}
.previewEditButtons{display:flex;justify-content:flex-end;gap:4px;border-top:1px solid #eee;padding-top:3px}.previewEditButtons button{font:600 11px system-ui,sans-serif;min-height:24px;padding:3px 7px}
@media print{#previewEditLayer{display:none!important}.editingSource{opacity:initial!important}}

#gridDialog{width:100%;min-width:0;max-width:100%}.controlPanel{min-width:0}.gridOption span{overflow-wrap:anywhere}

/* On small screens both panes share the remaining viewport without sticky
   overlap. Each pane scrolls independently, including the paper picker. */
@media(max-width:740px){
 .appShell{padding:12px 12px 16px}.appShell .toolHeader h1{font-size:1.45rem!important;line-height:1.08!important}.toolHeader{gap:7px!important;margin-bottom:10px!important}
 .toolHeaderActions{justify-content:flex-start!important;gap:6px!important}.toolHeaderActions>button{font-size:.7rem;min-height:29px;padding:5px 8px}.toolHeaderActions .toolLanguage{width:100%!important;flex:1 0 100%!important;gap:10px!important;margin-left:0!important}.toolLanguage legend{position:absolute!important;width:1px;height:1px;overflow:hidden;clip-path:inset(50%)}
 .workspace{display:grid;grid-template-columns:minmax(0,1fr);grid-template-rows:minmax(0,1fr) minmax(0,1fr);height:var(--workspace-height);gap:10px;margin-top:10px;align-items:stretch}
 .previewPanel{grid-row:1;order:initial;height:100%;min-height:0;max-height:none;position:relative;top:auto;overflow:auto}.controls{grid-row:2;height:100%;min-height:0;max-height:none;overflow:auto}
 .previewToolbar{flex-wrap:nowrap;padding:8px 10px;gap:8px}.previewToolbar h2{font-size:.83rem;margin:0}#pageMetrics{display:none}.previewToolbar .smallActions{flex-wrap:nowrap;gap:5px}.previewToolbar button{font-size:.65rem;padding:5px 7px;min-height:30px;white-space:nowrap}.pageNavigation{padding:6px 9px;gap:5px}.pageNavigation input{width:43px}.zoomControl select{width:87px!important}
 .previewViewport{min-height:0;max-height:none;padding:6px 12px 12px}.paperPicker #gridOptions{max-height:30dvh}.strokePanel{padding:12px}
}

/* Every settings section is always open; only the settings pane scrolls. */
.paperPicker{margin:0;background:#fff;padding:18px;border-radius:12px}
#gridOptions,.paperPicker #gridOptions{max-height:none!important;overflow:visible!important;overscroll-behavior:auto}
.controlPanel>h2{font-size:.93rem;margin:0 0 18px}
/* This is the native editing surface on the paper, not a popup. */
#previewEditLayer{border:0;border-radius:0;padding:0;background:transparent;box-shadow:none;z-index:2}
#previewTextEditor{display:block;border:0;outline:0!important;box-shadow:none;padding:0;margin:0;min-height:0;resize:none;border-radius:0;white-space:pre-wrap;overflow-wrap:anywhere;word-break:normal;overflow:visible;cursor:text;caret-color:#8b3a2b}
#pagePreview [data-annotation-index]{cursor:pointer;pointer-events:all}
#pagePreview [data-annotation-index]:hover{fill:#8b3a2b;paint-order:stroke;stroke:#8b3a2b33;stroke-width:.12}
#annotationEditLayer{position:absolute;z-index:6;border:1px solid #b76b42;border-radius:8px;background:#fff;padding:12px;box-shadow:0 4px 18px #0002}
#annotationEditLayer .smallActions{justify-content:flex-end;margin-top:9px}
@media print{#annotationEditLayer,#previewEditLayer{display:none!important}}

.strokeCharacters>button.substituted{border-color:#ba8a35;background:#fff7e8}.strokeCharacters sup{font-size:9px;line-height:1;vertical-align:top;margin-left:2px}#strokeModelNotice{margin:9px 0 0}

/* Full-card selection keeps native radio semantics without a visible dot. */
.layoutOptions{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:6px;margin-bottom:18px}
.layoutOption{position:relative;display:flex;flex-direction:column;align-items:center;gap:4px;min-width:0;padding:7px 3px 9px;border:2px solid var(--border);border-radius:8px;background:#fff;cursor:pointer;text-align:center;color:#26333b}
.layoutOption:hover{border-color:var(--accent);background:#f9f0e9}
.layoutOption:has(input:checked){border-color:var(--accent);background:#faf0e7}
.layoutOption:has(input:focus-visible){outline:3px solid #b76b42;outline-offset:3px}
.layoutOption>input,.layoutDescription{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);clip-path:inset(50%);white-space:nowrap;border:0}
.layoutOption>input:focus-visible{outline:0}
.layoutThumbnail{display:block;width:100%;max-width:72px;height:84px;flex:none}
.layoutPaperShadow{fill:#26333b12}
.layoutPaper{fill:#fff;stroke:#aaa89f;stroke-width:1}
.layoutRuling{fill:none;stroke:#e5e4de;stroke-width:.65}
.layoutModels{fill:currentColor;font:500 15px system-ui,sans-serif}
.layoutArrow{fill:none;stroke:var(--accent);stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
.layoutName{font-size:.65rem;font-weight:650;line-height:1.35;white-space:nowrap}
.layoutSubtitle{font-size:.64rem;font-weight:500;line-height:1.35;white-space:nowrap}
@media(min-width:1101px){.workspace{grid-template-columns:460px minmax(0,1fr)}}
@media(max-width:1100px){.layoutOptions{grid-template-columns:repeat(2,minmax(0,1fr))}.layoutName{font-size:.73rem}.layoutSubtitle{font-size:.69rem}}

/* Keep the format constraint adjacent to the stroke-step toggle, even when disabled. */
.controlGrid>.fieldHelp{grid-column:1/-1;margin:-7px 0 0;padding-left:24px}

/* Sample choices are explicit text replacements, independent of page presets. */
#sampleDialog{width:min(640px,calc(100vw - 28px))}
#sampleOptions{display:grid;gap:10px}
.sampleOption{border:1px solid var(--border);border-radius:9px;padding:0 12px 10px;background:#faf8f3}
.sampleOption>button{display:flex;flex-direction:column;align-items:flex-start;gap:7px;width:100%;border:0;background:transparent;padding:12px 0 0;text-align:left}
.sampleOption>button strong{font-size:.88rem;color:var(--accent)}
.samplePreview{font-weight:400;font-size:.95rem;line-height:1.6;white-space:pre-wrap;overflow-wrap:anywhere}
[data-sample="passage"] .samplePreview{max-height:4.8em;overflow:hidden}
.sampleSource{display:inline-block;margin-top:6px}
