:root{font-family:system-ui,-apple-system,"Segoe UI","Noto Sans TC","PingFang TC",sans-serif;color:#17202a;background:#f4f1ea;font-synthesis:none;--accent:#8b3a2b;--border:#d9d2c4;--muted:#746c62}
*{box-sizing:border-box}body{margin:0}main{max-width:1480px;margin:auto;padding:18px}button,input,select{font:inherit}button,select{cursor:pointer}button{border:1px solid #bbb3a5;border-radius:7px;background:#faf9f6;padding:7px 11px;color:inherit;font-size:.84rem}button:hover{border-color:var(--accent)}button:focus-visible,a:focus-visible,select:focus-visible,input:focus-visible{outline:3px solid #b2674f;outline-offset:3px}button[aria-pressed=true],.primary{background:var(--accent);border-color:var(--accent);color:white}button:disabled{opacity:.5;cursor:wait}select{border:1px solid #bbb3a5;background:white;border-radius:6px;padding:7px;max-width:100%}input[type=checkbox]{accent-color:var(--accent);width:16px;height:16px;margin:0 5px 0 0}
.topbar{display:flex;justify-content:space-between;align-items:flex-start;gap:20px;margin-bottom:17px}h1{font-size:clamp(1.8rem,3vw,2.7rem);letter-spacing:-.04em;margin:5px 0 0}.topbar p{color:var(--muted);font-size:.9rem;margin:5px 0}.backLink{color:var(--accent);font-size:.82rem;font-weight:750;text-decoration:none}.headerActions{display:flex;align-items:center;gap:7px;flex-wrap:wrap}.previewLabel{font-size:.72rem;color:var(--muted);padding:6px}.panel{padding:15px;background:white;border:1px solid var(--border);border-radius:11px;box-shadow:0 4px 14px #4c3a2710;margin-bottom:13px}.viewTabs{display:flex;gap:6px;margin-bottom:16px}.viewTabs button{font-weight:750;padding:8px 16px}.controlGrid{display:grid;grid-template-columns:2.2fr 1fr 1.6fr 1.2fr;gap:15px;padding-bottom:14px;border-bottom:1px solid #e9e3d8}fieldset{border:0;padding:0;margin:0;min-width:0}legend,h2{font-size:.95rem;font-weight:750;margin:0 0 8px}legend{padding:0}.choices{display:flex;flex-direction:column;gap:8px}.choices label{display:flex;align-items:center;font-size:.85rem;line-height:1.4}.levelChoices{display:grid;grid-template-columns:1fr 1fr;gap:6px 10px}.levelChoices span{margin-left:5px}.textButton{border:0;background:none;color:var(--accent);padding:5px 0;font-size:.77rem;text-decoration:underline;text-underline-offset:3px}.selectLabel{display:flex;flex-direction:column;font-size:.76rem;gap:4px;margin-bottom:7px}.help{color:#625c54;font-size:.78rem;line-height:1.5;margin:6px 0}.sectionHead,.resultsHead{display:flex;align-items:center;justify-content:space-between;gap:10px}.sectionHead{padding-top:13px}h2{margin-bottom:4px}.selectorLayout{display:grid;grid-template-columns:minmax(320px,510px) 1fr;gap:24px}.matrixPanel{max-width:510px}.prefixRow{display:flex;align-items:center;gap:9px;margin:7px 0;font-size:.77rem}.prefixRow>span{width:89px;flex-shrink:0}.prefixButtons{display:flex;gap:6px}.prefixButtons button{min-width:43px}.toneMatrix{border-collapse:separate;border-spacing:5px;width:100%;table-layout:fixed;margin-left:-5px}.toneMatrix th:first-child{width:94px}.toneMatrix th{font-weight:600;font-size:.8rem}.toneMatrix button{width:100%;padding:9px 2px;min-height:39px}.toneMatrix tbody th{text-align:center;color:var(--muted)}.patternPanel{padding-top:4px}.patternChips{display:flex;gap:5px;flex-wrap:wrap;max-height:130px;overflow:auto;margin:9px 0}.patternChips button{padding:5px 9px;font-size:.79rem}.patternChips .summaryChip{font-size:.8rem;color:var(--accent);font-weight:700}.allPatternList{max-height:210px;overflow:auto;display:grid;grid-template-columns:repeat(auto-fill,minmax(95px,1fr));gap:7px;padding:10px 2px}.allPatternList label{font-size:.78rem;display:flex;align-items:center}details summary{font-size:.8rem;cursor:pointer;color:var(--accent)}.goRow{display:flex;align-items:center;gap:16px;margin-top:12px}.primary{padding:9px 29px;font-weight:800;letter-spacing:.04em}.sortControl{display:flex;align-items:center;gap:8px;font-size:.78rem}.resultsHead h2{font-size:1.1rem}.resultsPanel{padding-bottom:12px}.tableViewport{overflow:auto;max-height:70vh;min-height:170px;border:1px solid var(--border);border-radius:7px;margin-top:10px;overscroll-behavior:contain;scrollbar-gutter:stable}.resultsTable{border-collapse:separate;border-spacing:0;width:100%;min-width:700px;font-size:.86rem;text-align:center}.resultsTable th,.resultsTable td{padding:8px 11px;border-bottom:1px solid #e8e3db;white-space:pre-line}.resultsTable thead th{position:sticky;top:0;z-index:3;background:#ebe5d9;font-size:.77rem;line-height:1.3;font-weight:750;white-space:normal}.resultsTable thead button{padding:2px 4px;background:none;border:0;font-weight:750;font-size:inherit;border-radius:3px}.resultsTable thead th[aria-sort]{color:#54251b}.resultsTable tbody tr:not(.erhua):not(.sectionRow):hover{background:#faf8f3}.han{font-size:1.15rem;min-width:90px}.pinyin{font-size:.95rem;min-width:135px}.alternate .pinyin{font-style:italic}.erhua{background:#e0f2fe}.sectionRow th{padding:0;background:#f2eee7;text-align:left}.sectionToggle{display:block;width:100%;text-align:left;border:0;border-radius:0;font-size:.85rem;padding:10px 13px;background:transparent;font-weight:750}.sectionToggle:hover{background:#e8e1d5}.partition td{background:#eaf4fa;font-size:.77rem;text-align:left;font-weight:700;color:#37566a;padding:7px 14px}.standard{font-size:.7rem;color:#625c54;min-width:95px}.alias{display:block;font-size:.72rem;color:var(--muted);margin-top:3px}.empty{padding:30px!important;color:var(--muted);text-align:center}.emptyMark{color:#938779}.basis{font-size:.65rem;color:#746c62;display:block;margin-top:2px}.renderProgress{color:var(--muted)}footer{display:flex;justify-content:space-between;gap:12px;flex-wrap:wrap;color:var(--muted);font-size:.72rem;padding:8px 3px 25px}dialog{width:min(820px,calc(100% - 24px));max-height:85vh;overflow:auto;border:1px solid var(--border);border-radius:12px;padding:22px;color:#17202a;box-shadow:0 20px 80px #17202a40}dialog::backdrop{background:#17202a77}.dialogHead{display:flex;justify-content:space-between;align-items:center;gap:15px;position:sticky;top:-22px;background:white;padding:8px 0;z-index:2}dialog h2{font-size:1.35rem}dialog h3{font-size:1rem;margin:24px 0 7px}dialog p{font-size:.88rem;line-height:1.65;margin:7px 0}dialog a{color:var(--accent)}.guideTable{width:100%;border-collapse:collapse;font-size:.85rem;text-align:center}.guideTable td,.guideTable th{border:1px solid var(--border);padding:8px}.guideTable th{background:#eee7db}.sourceItem{margin:19px 0;border-bottom:1px solid #e8e3db;padding-bottom:14px}.sourceItem h3{margin:0 0 4px}.sourceItem p{font-size:.82rem}.publicationNote{border-top:1px solid var(--border);padding-top:15px;color:#625c54}[hidden]{display:none!important}
@media(max-width:850px){main{padding:12px}.controlGrid{grid-template-columns:1.4fr 1fr;gap:16px}.selectorLayout{grid-template-columns:1fr;gap:9px}.matrixPanel{max-width:550px}.headerActions{justify-content:flex-end}.previewLabel{width:100%;text-align:right}.topbar{gap:8px}.panel{padding:12px}.resultsHead{align-items:flex-start}.sortControl{flex-direction:column;align-items:flex-start;gap:4px}.resultsTable th,.resultsTable td{padding:8px}.tableViewport{max-height:65vh}.patternPanel{max-width:100%}}
@media(max-width:420px){main{padding:9px}.levelChoices{grid-template-columns:1fr}.controlGrid{grid-template-columns:1fr 1fr}.topbar h1{font-size:1.8rem}.headerActions button{padding:6px;font-size:.75rem}.toneMatrix{border-spacing:3px}.toneMatrix th:first-child{width:78px}.prefixRow>span{width:77px}.prefixButtons button{min-width:39px}.help{font-size:.75rem}.resultsHead{flex-direction:column}.sortControl{flex-direction:row;align-items:center}.goRow{gap:10px}}
@media(prefers-reduced-motion:reduce){*{scroll-behavior:auto!important}}
.resultsTable{table-layout:fixed}
.resultsTable thead button{white-space:pre}
.languageControl{font-size:.73rem;display:flex;gap:8px;border:1px solid var(--border);border-radius:7px;padding:5px 8px}.languageControl legend{font-size:.7rem;margin:0}.languageControl label{display:flex;align-items:center}.guideTable{max-width:620px;table-layout:fixed}.guideTable th,.guideTable td{padding:7px 5px;white-space:pre-line}.readingsButton{display:block;margin:2px auto 0;font-size:.7rem}.regionLabel{font-weight:600}.patternChips{max-height:180px}.headerActions{max-width:420px}
@media(max-width:420px){.prefixButtons{gap:4px}.prefixButtons button{min-width:34px;padding:7px 4px}.prefixRow>span{width:66px}.languageControl{width:100%;justify-content:flex-end;border:0;padding:0}.headerActions{max-width:128px}.guideTable{font-size:.75rem}.guideTable th,.guideTable td{padding:6px 3px}}

/* The results section occupies a complete viewport; its controls remain visible. */
.resultsPanel{height:100vh;height:100dvh;display:flex;flex-direction:column;min-height:0;overflow:hidden}.resultsHead,.resultsPanel>#resultNote{flex:none}.tableViewport,.matrixViewport{flex:1;min-height:0;max-height:none!important;overflow:auto;overscroll-behavior:auto;scrollbar-gutter:stable}.resultControls{display:flex;align-items:center;justify-content:flex-end;gap:12px;flex-wrap:wrap}.matrixViewport{border:1px solid var(--border);border-radius:7px;margin-top:10px}.patternActions{display:flex;flex-wrap:wrap;gap:7px;margin:8px 0 12px}.patternActions button{font-size:.8rem}#matrixControls{display:flex;gap:8px;align-items:center}.practiceGrid{width:100%;min-width:950px;border-collapse:separate;border-spacing:0;table-layout:fixed}.practiceGrid th:first-child{width:82px}.practiceGrid th{position:sticky;top:0;background:#ebe5d9;z-index:2;padding:9px;font-size:.85rem}.practiceGrid tbody th{left:0;z-index:1;overflow-wrap:anywhere;white-space:normal}.practiceGrid td{vertical-align:top;border-right:1px solid var(--border);border-bottom:1px solid var(--border);padding:10px;text-align:center}.practicePattern{font-size:.78rem;font-weight:700;margin-bottom:7px}.practiceEntry{padding:8px 2px;border-bottom:1px solid #e9e3d8}.practiceEntry .pinyin{min-width:0;white-space:pre-line}.practiceEntry .han{min-width:0}.practiceEntries .alternate .pinyin{font-style:italic}.cellNext{margin-top:4px}.cellNext:disabled{cursor:default}#practiceMatrix:focus-visible{outline:3px solid #b2674f;outline-offset:2px}
@media(max-width:700px){.resultsHead{flex-direction:column;align-items:stretch}.resultControls{justify-content:flex-start;gap:7px}.resultControls .sortControl{font-size:.74rem;flex-direction:column;align-items:flex-start}.resultControls select{padding:5px;max-width:145px}#matrixControls{align-items:flex-end}.resultsPanel{padding:9px}.practiceGrid{min-width:850px}}

/* Wide desktop reading surfaces; small screens retain native dialog scrolling. */
#guide,#sources{box-sizing:border-box;width:min(1440px,calc(100% - 32px));max-height:calc(100vh - 32px);max-height:calc(100dvh - 32px);overflow:auto}
#guideContent,#sourceList{display:grid;gap:18px 28px}.guideSection{min-width:0}.guideSection h3{margin:0 0 7px}.guideSection p{margin:6px 0}.sourceItem{margin:0;padding:0 0 12px;min-width:0}.sourceItem a{overflow-wrap:anywhere}.viewSwitch{max-width:20rem}.viewSwitch .help{display:block;margin:4px 0 0;font-size:.72rem}.viewSwitch button:disabled{cursor:default}
@media(min-width:1000px){#guideContent,#sourceList{grid-template-columns:repeat(2,minmax(0,1fr))}#guide .dialogHead,#sources .dialogHead{margin-bottom:12px}.guideSection:nth-child(2){grid-column:2;grid-row:1 / span 2}}
@media(max-width:600px){#guide,#sources{width:calc(100% - 20px);max-height:calc(100dvh - 20px);padding:16px}#guideContent,#sourceList{gap:16px}.viewSwitch{max-width:100%}}

.visuallyHidden{position:absolute!important;width:1px!important;height:1px!important;padding:0!important;margin:-1px!important;overflow:hidden!important;clip-path:inset(50%)!important;white-space:nowrap!important;border:0!important}
.practiceGrid td{border-right:2px solid #9a8c78;border-bottom:2px solid #9a8c78;padding:0}.practiceGrid tbody th{border-right:2px solid #9a8c78;border-bottom:2px solid #9a8c78}.practiceGrid td.isEmpty{background:#e4e2df}
.practiceCell{box-sizing:border-box;height:16rem;padding:.6rem;display:grid;grid-template-rows:1.3rem minmax(0,1fr) 1.5rem 2rem;gap:.35rem;min-width:0}.practiceCell.tenEntries{height:40rem}
.practiceCell .practicePattern{margin:0}.practiceCell .practiceEntries{min-width:0;min-height:0;overflow:auto;overscroll-behavior:contain}.practiceCell.tenEntries .practiceEntries{display:grid;grid-template-rows:repeat(5,minmax(0,1fr));grid-auto-flow:column;grid-template-columns:repeat(2,minmax(0,1fr));gap:.25rem .5rem}
.practiceEntries .practiceEntry{border:0;padding:.3rem .1rem;min-width:0;overflow:auto;overflow-wrap:anywhere}.practiceEntry .han{font-size:1.1rem;overflow-wrap:anywhere}.practiceEntry .pinyin{white-space:pre-line;line-height:1.45}.practiceEntry .matrixReadingsCount{display:inline;margin:0;padding:0;border:0;font:inherit;line-height:inherit;white-space:nowrap;vertical-align:baseline}
.practiceCell .practicePageCount{margin:0;font-size:.7rem;white-space:nowrap}.practiceCell .cellNext{box-sizing:border-box;align-self:center;justify-self:center;margin:0;height:2rem;min-width:4.25rem;padding:.2rem .5rem}.practiceCell .cellNext:focus-visible,.matrixReadingsCount:focus-visible{outline:2px solid #8b3a2b;outline-offset:2px}
.practiceGrid[data-page-size="10"]{min-width:1300px}.practiceGrid[data-page-size="10"] th:first-child{width:82px}

@media(max-width:700px){
  .mobilePracticeControls{display:flex;flex-wrap:wrap;gap:.6rem;padding:.65rem;background:#ebe5d9}
  .mobilePracticeControls label{display:flex;flex-direction:column;gap:.25rem;font-size:.8rem;min-width:3.8rem}
  .mobilePracticeControls select{min-height:2.75rem}
  .mobilePracticeCards{display:grid;gap:.75rem;padding:.65rem;min-width:0}
  .mobilePracticeCard{border:1px solid var(--border);border-radius:7px;min-width:0;background:white}
  .mobilePracticeCard.isEmpty{background:#e4e2df;padding:.5rem}
  .mobilePracticeCard.isEmpty .practiceCell{display:none}
  .mobilePracticeCard .practiceCell,.mobilePracticeCard .practiceCell.tenEntries{height:auto;display:grid;grid-template-columns:minmax(0,1fr) auto;grid-template-rows:auto auto auto;align-items:center}
  .mobilePracticeCard .practicePattern{font-size:1rem;grid-row:1;grid-column:1}
  .mobilePracticeCard .practiceEntries,.mobilePracticeCard .practiceCell.tenEntries .practiceEntries{display:block;overflow:visible;grid-row:3;grid-column:1/-1}
  .mobilePracticeCard .practiceEntry{overflow:visible;padding:.5rem .1rem;border-bottom:1px solid #e9e3d8}
  .mobilePracticeCard .cellNext{min-height:2.75rem;grid-row:1;grid-column:2}.mobilePracticeCard .practicePageCount{grid-row:2;grid-column:1/-1}
  #practiceMatrix{scrollbar-gutter:auto;overflow-x:hidden}
  .resultsPanel.mobileMatrixActive{height:auto;overflow:visible}
  .mobileMatrixActive #practiceMatrix{flex:none;overflow:visible;max-height:none}
}

/* Compact practice cards: pattern, example, reading, then position and arrow. */
.practiceCell,.practiceCell.tenEntries,.mobilePracticeCard .practiceCell,.mobilePracticeCard .practiceCell.tenEntries{height:auto;min-height:0;padding:.4rem;display:flex;flex-direction:column;gap:0;align-items:stretch}
.practiceCell .practicePattern{margin:0;line-height:1.3}
.practiceCell .practiceEntries{overflow:visible;flex:none}
.practiceCell .practiceEntry,.mobilePracticeCard .practiceEntry{margin:0;padding:0;border:0;overflow:visible;line-height:1.3}
.practiceCell .practiceEntry .han,.practiceCell .practiceEntry .pinyin{margin:0;line-height:1.3}
.practiceCell .practicePager{display:flex;align-items:center;justify-content:center;gap:.35rem;line-height:1.3}
.practiceCell .practicePageCount{margin:0;font-size:.7rem;line-height:1.3}
.practiceCell .cellNext,.mobilePracticeCard .cellNext{height:1.5rem;min-height:1.5rem;min-width:1.6rem;margin:0;padding:0 .25rem;font-size:1rem;line-height:1;align-self:auto;justify-self:auto}
.practiceCell.tenEntries .practiceEntries{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));grid-template-rows:none;grid-auto-flow:row;gap:.35rem .5rem}
