:root{font-family:Inter,-apple-system,BlinkMacSystemFont,"Segoe UI","PingFang SC","Microsoft YaHei",sans-serif;color:#173a32;background:#f4f5ef;font-synthesis:none;--ink:#173a32;--muted:#78857c;--green:#174e40;--lime:#d8ee9b;--line:#dce2d6;--white:#fffefa;--soft:#edf0e7}
*{box-sizing:border-box}body{margin:0}button,input,select,textarea{font:inherit}button,a,input,select,summary{-webkit-tap-highlight-color:transparent}button{cursor:pointer;touch-action:manipulation;border:0;color:inherit;background:none;min-height:44px}button:disabled{opacity:.35;cursor:default}button:focus-visible,a:focus-visible,summary:focus-visible{outline:3px solid #92b784;outline-offset:3px}input,textarea,select{color:var(--ink);border:1px solid var(--line);background:var(--white);border-radius:12px;padding:12px;min-height:44px;max-width:100%;font-size:16px}input:focus,textarea:focus,select:focus{outline:2px solid #91af78}a{color:var(--green)}h1,h2,h3,p{margin:0}h1{font-size:32px;letter-spacing:-1px;line-height:1.25;font-weight:650}h2{font-size:20px}h3{font-size:16px}p{line-height:1.7}small{font-size:12px}svg{display:block}.shell{max-width:1060px;margin:auto;padding:0 36px 110px}.topbar{height:100px;display:flex;align-items:center;justify-content:space-between;border-bottom:1px solid var(--line);margin-bottom:32px}.brand{display:flex;gap:10px;align-items:center;text-decoration:none;font-size:21px;font-weight:750}.brand-mark{display:grid;place-items:center;width:42px;height:42px;border-radius:14px;background:var(--green);color:var(--lime);font-size:32px;font-weight:400}.brand-caption{display:block;font:9px monospace;letter-spacing:1.7px;margin-top:4px}.quiet{color:#65756a;font-size:12px;padding:0 12px}.quiet span{margin-left:6px}.eyebrow{font:11px ui-monospace,SFMono-Regular,monospace;letter-spacing:1.6px;color:var(--muted);margin-bottom:9px}.intro{display:flex;align-items:center;justify-content:space-between;margin-bottom:26px}.intro p{font-size:13px;color:var(--muted);margin-top:10px}.tag{font-size:11px;border:1px solid var(--line);padding:7px 10px;border-radius:20px;white-space:nowrap}.workspace{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,.85fr);gap:22px;align-items:start}.card{border:1px solid var(--line);background:var(--white);border-radius:24px;padding:24px;min-width:0}.card+.card{margin-top:16px}.card-title{display:flex;align-items:center;justify-content:space-between;margin-bottom:16px;gap:8px}.step{font:11px ui-monospace,monospace;color:var(--muted);letter-spacing:1px}.muted{color:var(--muted)}.small{font-size:12px;line-height:1.65}.hint{margin-top:16px;font-size:12px;line-height:1.65;color:var(--muted)}.row{display:flex;gap:8px;align-items:center;flex-wrap:wrap}.spread{justify-content:space-between}.mono{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-variant-numeric:tabular-nums}.btn{border:1px solid var(--line);background:var(--white);border-radius:12px;padding:10px 16px;font-size:13px;font-weight:600}.primary{background:var(--green);border-color:var(--green);color:#fff}.soft{background:var(--soft)}.full{width:100%}.segmented{background:#e8ede2;border-radius:13px;padding:4px;display:flex;gap:3px}.segmented button{flex:1;border-radius:10px;padding:9px 10px;min-height:38px;font-size:12px;white-space:nowrap}.segmented button.active{background:var(--white);box-shadow:0 1px 4px #28402512;font-weight:650}.bottom-nav{position:fixed;bottom:20px;left:50%;transform:translateX(-50%);display:flex;gap:4px;width:440px;max-width:calc(100% - 28px);padding:6px;background:#fffefaee;border:1px solid #dce2d6;border-radius:22px;backdrop-filter:blur(16px);box-shadow:0 10px 40px #193b3220;z-index:5}.bottom-nav button{flex:1;display:flex;align-items:center;justify-content:center;gap:8px;height:54px;border-radius:15px;font-size:13px;position:relative}.bottom-nav button.active{background:var(--green);color:#e5f7be}.nav-icon{font-size:22px}.bottom-nav i{position:absolute;right:9px;top:6px;font:10px monospace;background:#d8ee9b;color:var(--ink);border-radius:8px;padding:2px 4px}.template-main{font-size:27px;font-weight:550;letter-spacing:1px;display:flex;align-items:center;justify-content:space-between;border:1px solid var(--line);background:var(--soft);border-radius:15px;width:100%;padding:15px 18px;min-height:68px}.template-main .chevron{font-size:18px;color:var(--muted)}.recent-templates{display:flex;gap:6px;margin-top:10px;overflow:auto;scrollbar-width:none}.recent-templates button{flex-shrink:0;border:1px solid var(--line);font-size:13px;border-radius:10px;padding:6px 12px;min-height:38px}.recent-templates button.selected{background:#e7efdc;border-color:#9db489}.target-field{display:flex;align-items:center;gap:12px;margin:18px 0 14px}.target-field label{font-size:13px;white-space:nowrap}.target-field input{width:100%;min-width:0;flex:1;font-size:32px;line-height:1;font-weight:600;text-align:right;border:0;border-bottom:1px solid var(--line);border-radius:0;background:transparent;padding:8px 2px;height:58px;outline:none}.keypad{display:grid;grid-template-columns:repeat(3,1fr);gap:8px}.keypad button{border:1px solid var(--line);border-radius:14px;background:#f6f7f0;height:61px;font-size:25px;font-weight:500}.keypad button:active{background:var(--lime);transform:scale(.97)}.keypad .key-action{font-size:14px;color:#627568}.next{margin-top:10px;width:100%;background:var(--green);color:white;border-radius:14px;min-height:52px;font-size:14px}.result{background:var(--green);border:1px solid var(--green);color:#fff;border-radius:24px;padding:25px;min-height:237px;position:relative;overflow:hidden}.result .step{color:#b2c7b8}.result-status{display:flex;align-items:center;gap:7px;font-size:11px;color:#bed2c5}.status-dot{display:inline-block;width:6px;height:6px;background:var(--lime);border-radius:50%}.result-empty{font-size:25px;font-weight:550;margin:28px 0 14px;color:#e5eedd;line-height:1.4}.result .small{color:#b6cec0}.answer-digits{display:flex;gap:8px;margin:25px 0 15px;flex-wrap:wrap}.answer-digit{min-width:52px;height:64px;display:grid;place-items:center;background:var(--lime);color:#173a32;border-radius:13px;font:600 37px ui-monospace,monospace}.answer-equation{font-size:17px;color:#e9f0dd;overflow-wrap:anywhere}.answer-meta{display:flex;align-items:center;justify-content:space-between;margin-top:20px;color:#b6cec0;font-size:11px}.answer-meta button{color:#e2f0d7;min-height:32px;border:1px solid #557a68;border-radius:8px;padding:4px 10px;font-size:11px}.note-card{margin-top:16px;border:1px solid var(--line);border-radius:20px;padding:20px}.note-card h3{font-size:13px;margin-bottom:8px}.note-card p{font-size:12px;color:var(--muted)}.number-badge{width:24px;height:24px;background:var(--soft);border-radius:8px;display:inline-grid;place-items:center;font:12px monospace;margin-right:6px}.symbol-row{display:flex;gap:10px;justify-content:center;margin:12px 0}.symbol{display:grid;place-items:center;width:57px;height:57px;border:1px solid var(--line);border-radius:14px;background:var(--soft);font-size:31px;position:relative}.symbol sup{position:absolute;right:6px;bottom:4px;font:9px monospace;color:#68756a}.symbol.empty{border-style:dashed;color:#b3beb0}.pipe-arrow{text-align:center;color:#b3c2b2;font-size:23px;margin:10px 0}.layer{background:var(--soft);padding:12px;border-radius:16px;margin-top:9px}.layer-head{display:flex;align-items:center;justify-content:space-between;gap:6px;font-size:12px}.layer .segmented{padding:2px;background:#dfe5d7}.layer .segmented button{padding:5px 9px;min-height:32px;font-size:11px}.code-button{font:500 25px ui-monospace,monospace;letter-spacing:9px;width:100%;padding-left:15px;border-radius:10px;margin-top:6px}.code-button.selected{background:#d9eabf;outline:1px solid #96af80}.pipe-keypad{display:grid;grid-template-columns:repeat(4,1fr);gap:7px;margin-top:13px}.pipe-keypad button{background:var(--soft);border:1px solid var(--line);border-radius:12px;height:53px;font-size:24px}.pipe-result-path{display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin:20px 0}.code-answer{font:600 27px ui-monospace,monospace;color:var(--lime);letter-spacing:4px}.trace{margin-top:15px;display:grid;gap:9px;font-size:12px}.trace div{display:flex;align-items:center;gap:10px}.trace code{font-size:17px;letter-spacing:5px;color:#ebf4de}.details{font-size:12px;margin-top:10px}.details summary{cursor:pointer;padding:8px 0;color:var(--muted)}.details input{width:100%;font:14px ui-monospace,monospace}.pipe-options{display:grid;gap:9px;margin-top:14px}.pipe-options button{color:#eef3e7;background:#ffffff0a;border:1px solid #ffffff26;border-radius:10px;text-align:left;padding:9px 12px;font:15px ui-monospace,monospace;min-height:44px}.memory-board{position:relative;aspect-ratio:1.45;background:#e9eee1;border:1px solid #cbd6c1;border-radius:18px;overflow:hidden;touch-action:none;background-image:linear-gradient(#c6d2be44 1px,transparent 1px),linear-gradient(90deg,#c6d2be44 1px,transparent 1px);background-size:25% 25%;user-select:none}.memory-board::after{content:'↑ 上方';position:absolute;top:12px;left:50%;transform:translateX(-50%);font-size:10px;color:#8b9b7f;pointer-events:none}.pad-placeholder{position:absolute;inset:0;display:grid;place-content:center;text-align:center;color:#88977f;font-size:13px;gap:6px;pointer-events:none}.pad-placeholder strong{font-size:35px;font-weight:400;color:#afbf9f}.memory-marker{position:absolute;transform:translate(-50%,-50%);display:grid;place-items:center;min-width:35px;height:35px;padding:0 5px;border-radius:50%;background:var(--green);color:#edf8c3;box-shadow:0 0 0 4px #fafff4aa;font:650 16px ui-monospace,monospace;pointer-events:none}.memory-marker.highlight{background:#bed874;color:#163d31}.memory-marker.muted-marker{opacity:.25}.memory-path{position:absolute;inset:0;width:100%;height:100%;pointer-events:none}.sequence-list{display:flex;gap:7px;flex-wrap:wrap;margin-top:16px}.sequence-list button{border:1px solid var(--line);background:var(--soft);border-radius:10px;padding:5px 11px;font-size:12px;min-height:38px}.sequence-list button.active{background:var(--lime);border-color:#a0b678}.memory-counter{font:500 56px ui-monospace,monospace;color:var(--lime);margin:16px 0}.memory-tools{display:flex;gap:8px;margin-top:14px}.memory-tools button{flex:1;padding:10px 8px}.shape-tabs{margin-bottom:20px}.grid-pair{display:grid;grid-template-columns:1fr 1fr;gap:16px}.grid-label{display:flex;align-items:center;justify-content:space-between;min-height:37px;font-size:12px;margin-bottom:6px}.pixel-grid{display:grid;gap:3px;background:#e6ebdf;padding:8px;border-radius:12px;touch-action:none;user-select:none}.pixel-grid button{min-height:0;aspect-ratio:1;border-radius:4px;background:#f9fbf2;padding:0;touch-action:none}.pixel-grid button.on{background:var(--green)}.pixel-grid button.difference{box-shadow:inset 0 0 0 2px #ca805e}.pixel-grid.readonly button.on{background:#82a05e}.grid-settings{display:flex;align-items:center;gap:8px;margin-top:14px;font-size:12px;flex-wrap:wrap}.grid-settings input{width:62px;padding:6px;min-height:36px}.shape-result{margin-top:18px;padding:16px;border-radius:14px;background:#e9efde;display:flex;gap:12px;align-items:center;justify-content:space-between}.shape-result strong{font-size:21px}.shape-result p{font-size:12px;color:#78856b}.shape-result.negative{background:#f5e9df;color:#975939}.edge-pad{background:#e9eee1;border:1px solid var(--line);border-radius:14px;touch-action:none;user-select:none;width:100%;aspect-ratio:1}.edge-pad circle{fill:#a5b899}.edge-pad circle.selected{fill:#2c6549;stroke:#d5eda3;stroke-width:4}.edge-pad line{stroke:#204f3d;stroke-width:5;stroke-linecap:round;pointer-events:none}.edge-pad .ghost{stroke:#a4b78d;stroke-dasharray:3 4;stroke-width:1;pointer-events:none}.edge-result{max-width:200px;margin:14px auto 0}.operator{font-size:25px;font-weight:600}.sheet-heading{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-bottom:20px}.sheet-heading button{font-size:23px;width:44px;background:var(--soft);border-radius:50%}dialog{color:var(--ink);border:1px solid var(--line);border-radius:24px;padding:25px;background:var(--white);width:560px;max-width:calc(100% - 24px);max-height:88dvh;box-shadow:0 15px 80px #15362a30}dialog::backdrop{background:#193b3260;backdrop-filter:blur(4px)}.template-grid{display:grid;grid-template-columns:1fr 1fr;gap:8px;margin:10px 0 20px}.template-grid button{border:1px solid var(--line);background:var(--soft);border-radius:10px;padding:10px;font-size:15px;min-height:48px}.template-grid button.selected{background:var(--lime);border-color:#a8be84}.custom-input{width:100%;font:19px ui-monospace,monospace;margin:10px 0}.custom-toolbar{display:flex;gap:6px;flex-wrap:wrap}.custom-toolbar button{background:var(--soft);border-radius:9px;min-width:40px;font-size:18px}.sources{line-height:1.8;font-size:13px}.sources p{margin:12px 0}.sources a{overflow-wrap:anywhere}.sources ul{padding-left:20px}.sources li{margin:9px 0}.source-table{width:100%;border-collapse:collapse;margin:14px 0;font-size:12px}.source-table td,.source-table th{text-align:left;padding:10px 6px;border-bottom:1px solid var(--line)}#toast{position:fixed;left:50%;transform:translateX(-50%) translateY(20px);bottom:110px;background:#183f35;color:white;padding:10px 16px;border-radius:12px;font-size:13px;pointer-events:none;opacity:0;transition:.15s;z-index:20;max-width:85%;text-align:center}#toast.visible{opacity:1;transform:translateX(-50%) translateY(0)}.error-text{font-size:12px;color:#a45c3e;margin-top:10px}.pair-card{grid-column:1/-1}.switch-note{margin:12px 0;color:var(--muted);font-size:12px}.tiny-btn{min-height:32px;font-size:11px;border-radius:7px;background:var(--soft);padding:4px 8px}.checkbox{display:flex;align-items:center;gap:6px;font-size:12px}.checkbox input{min-height:20px;width:18px;accent-color:var(--green)}
@media(min-width:760px){.shape-workspace{grid-template-columns:1.2fr .75fr}.shape-workspace .card{padding:28px}.memory-workspace{grid-template-columns:1.2fr .75fr}.wide-card{grid-column:1/-1}.keyboard-tip{display:block;margin-top:15px;text-align:center;color:var(--muted);font-size:11px}}
@media(max-width:759px){.shell{padding:0 18px calc(105px + env(safe-area-inset-bottom))}.topbar{height:76px;margin-bottom:23px}.brand{font-size:19px}.brand-mark{width:36px;height:36px;font-size:28px;border-radius:12px}.brand-caption{font-size:8px}.quiet{padding:0;font-size:11px}.intro{margin-bottom:20px;align-items:flex-start}.intro p{font-size:12px;margin-top:7px}h1{font-size:28px}.tag{font-size:10px;padding:6px 8px;margin-top:7px}.workspace{display:flex;flex-direction:column;gap:14px}.workspace>div,.workspace>section{width:100%}.card{padding:18px;border-radius:20px}.result{padding:20px;border-radius:20px;min-height:0}.result-empty{font-size:21px;margin:20px 0 10px}.answer-digits{margin:17px 0 12px}.answer-digit{height:52px;min-width:45px;font-size:31px}.answer-meta{margin-top:12px}.digit-workspace{gap:13px}.digit-workspace .input-column{display:contents}.digit-workspace .result-column{display:contents}.digit-workspace .digit-card{order:1}.digit-workspace .result{order:2}.digit-workspace .keypad-card{order:3}.digit-workspace .note-card{order:4}.digit-workspace .keyboard-tip{display:none}.digit-card{padding:16px 18px}.digit-card .card-title{margin-bottom:10px}.template-main{font-size:24px;padding:11px 14px;min-height:53px}.recent-templates{margin-top:8px}.recent-templates button{font-size:12px;min-height:32px;padding:5px 10px}.target-field{margin:10px 0 0}.target-field input{font-size:28px;height:42px;padding:3px}.keypad-card{padding:0;border:0;background:none;margin:0!important}.keypad{gap:7px}.keypad button{height:51px;border-radius:12px;background:var(--white);font-size:23px}.next{min-height:48px;margin-top:8px}.note-card{display:none}.bottom-nav{bottom:calc(10px + env(safe-area-inset-bottom));padding:5px;border-radius:19px}.bottom-nav button{height:52px;gap:5px;font-size:12px}.nav-icon{font-size:21px}.memory-board{aspect-ratio:1.2}.memory-workspace .result{padding:16px 20px}.memory-counter{font-size:32px;margin:8px 0}.memory-workspace .result .small{font-size:11px}.grid-pair{gap:12px}.pixel-grid{gap:2px;padding:6px}.shape-tabs{margin-bottom:15px}.shape-workspace .note-card{display:block}.pipe-keypad{position:sticky;bottom:85px}.code-answer{font-size:25px}.card+.card{margin-top:14px}.shape-result{padding:13px;margin-top:14px}dialog{padding:20px;border-radius:22px}.template-grid button{font-size:14px}.memory-tools{gap:6px}.memory-tools button{font-size:12px}.eyebrow{font-size:10px;margin-bottom:7px}.result-status{font-size:10px}}
@media(max-width:360px){.shell{padding-left:12px;padding-right:12px}.symbol{width:49px;height:49px}.card{padding:14px}.intro .tag{display:none}.keypad button{height:47px}.grid-pair{gap:8px}.template-grid button{font-size:12px}.answer-digit{min-width:38px}.answer-digits{gap:5px}}
@media(prefers-reduced-motion:reduce){*{transition:none!important}}
@media(max-width:759px){
  .digit-workspace .result,.digit-workspace .keypad-card{width:100%}
  .topbar{height:64px;margin-bottom:17px}.intro{margin-bottom:17px}.intro p{margin-top:5px}.intro h1{font-size:26px}.intro .eyebrow{margin-bottom:5px}
  .digit-card .card-title{display:none}.digit-card{padding:14px 16px}.digit-workspace .result{padding:16px 18px}.digit-workspace .result-empty{font-size:20px;margin:10px 0 6px}.digit-workspace .answer-digits{margin:12px 0 8px}.digit-workspace .answer-digit{height:44px;min-width:42px;font-size:29px;border-radius:10px}.digit-workspace .answer-meta{margin-top:6px}.digit-workspace .answer-equation{font-size:15px}.digit-workspace .keypad button{height:46px}.digit-workspace .next{min-height:44px;margin-top:7px}.digit-workspace{gap:11px}
}
.trace-details{margin-top:12px}.trace-details summary{font-size:11px;color:#b7cdbe;cursor:pointer;min-height:25px;padding-top:5px}
@media(max-width:759px){
  .shell:has(.digit-workspace) .topbar{height:54px;margin-bottom:12px}.shell:has(.digit-workspace) .intro{margin-bottom:13px}.digit-card{padding:12px 16px}.digit-workspace .result{padding:14px 18px}
  .pipe-workspace>div{display:contents}.pipe-workspace #pipe-result{order:-1;position:sticky;top:8px;width:100%;z-index:3;box-shadow:0 7px 18px #163b321c;max-height:270px;overflow:auto;padding:16px 20px}.pipe-workspace .pipe-result-path{margin:12px 0 8px}.pipe-workspace .result-empty{margin:10px 0;font-size:20px}.pipe-workspace .trace-details{margin-top:5px}.pipe-workspace .pipe-keypad{position:static}.pipe-workspace .symbol-row{margin:7px 0}.pipe-workspace .pipe-arrow{margin:3px 0}.pipe-workspace .card-title{margin-bottom:9px}
}
@media(max-width:759px){.intro .tag{display:none}.intro h1{letter-spacing:-.7px}.intro>div{width:100%}.grid-pair .grid-label{font-size:11px}}
html{scroll-padding-bottom:100px}button,input,summary{scroll-margin-top:170px;scroll-margin-bottom:105px}
@media(max-width:759px){.edge-result{max-width:160px}.shape-workspace .result{display:none}.shape-workspace .note-card{margin-top:0}.pipe-workspace .card-title .segmented button{min-height:44px;min-width:44px}}
@media(max-width:759px) and (max-height:820px){.shell:has(.digit-workspace) .intro .eyebrow{display:none}.shell:has(.digit-workspace) .intro p{display:none}.shell:has(.digit-workspace) .intro h1{font-size:22px}.shell:has(.digit-workspace) .intro{margin-bottom:10px}.digit-workspace .answer-meta{font-size:10px}.digit-workspace .result{padding:12px 16px}}
@media(min-width:760px){.topbar{height:84px;margin-bottom:24px}.digit-card{padding:20px}.digit-card .card-title button{min-height:32px}.digit-card .template-main{min-height:58px;padding:10px 16px}.digit-card .target-field{margin:12px 0 7px}.keypad-card{padding:18px}.keypad-card .keypad button{height:48px}.keypad-card .next{min-height:48px}}
/* Keep preset selection open and in a stable order; no dialog round trip. */
.structure-heading{display:flex;justify-content:space-between;align-items:center;margin-bottom:8px}
.structure-heading button{min-height:32px}
.structure-picker{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:6px;max-height:244px;overflow-y:auto;overscroll-behavior:contain;scrollbar-width:thin;scrollbar-color:#a8ba96 transparent;padding:2px 5px 2px 2px;touch-action:pan-y}
.structure-picker button{min-height:44px;padding:8px 3px;border:1px solid var(--line);border-radius:10px;background:var(--soft);font-size:14px;white-space:nowrap;scroll-margin:5px}
.structure-picker button.selected{background:var(--lime);border-color:#8da76c;box-shadow:inset 0 0 0 1px #8da76c;font-weight:650}
.structure-picker button:active{background:#c8e392}
.structure-caption{display:flex;justify-content:space-between;gap:6px;margin-top:9px;font-size:11px;color:var(--muted)}
.structure-caption strong{color:var(--ink);font-weight:550}
@media(max-width:759px){
  .shell:has(.digit-workspace) .intro{display:none}
  .structure-picker{max-height:218px;gap:5px;padding-right:3px}
  .structure-picker button{font-size:12px;min-height:44px}
  .structure-heading{margin-bottom:5px}
  .structure-caption{font-size:10px;margin-top:7px}
  .digit-workspace .result:has(.answer-digits){display:grid;grid-template-columns:minmax(0,1fr) auto;gap:6px 8px;align-items:center;padding:12px 16px}
  .digit-workspace .result:has(.answer-digits) .result-status{display:none}
  .digit-workspace .result:has(.answer-digits) .answer-digits{grid-column:1;grid-row:1;margin:0;gap:5px}
  .digit-workspace .result:has(.answer-digits) .answer-equation{grid-column:1;grid-row:2;font-size:12px}
  .digit-workspace .result:has(.answer-digits) .answer-meta{grid-column:2;grid-row:1 / span 2;display:flex;flex-direction:column;gap:9px;align-items:flex-end;margin:0;font-size:9px;max-width:130px}
  .digit-workspace .result:has(.answer-digits) .answer-digit{min-width:34px;height:39px;font-size:26px}
}
@media(max-width:359px){.structure-picker button{font-size:11px}.structure-picker{gap:4px}.digit-workspace .result:has(.answer-digits) .answer-meta{max-width:100px}}
@media(max-width:759px){
  .structure-picker{max-height:clamp(120px,calc(100dvh - 656px),218px)}
  .digit-workspace .result:not(:has(.answer-digits)){padding:12px 16px}
  .digit-workspace .result:not(:has(.answer-digits)) .result-status{display:none}
  .digit-workspace .result:not(:has(.answer-digits)) .result-empty{font-size:18px;margin:0 0 4px}
  .digit-workspace .result:not(:has(.answer-digits)) .small{font-size:11px;line-height:1.4}
}
/* Two-level arithmetic tree and directly editable given values. */
.fork-heading{display:flex;align-items:center;justify-content:space-between;margin-bottom:7px}
.fork-heading .quiet{min-height:32px}
.fork-roots{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:6px}
.fork-roots button{background:var(--soft);border:1px solid var(--line);border-radius:12px;padding:7px 2px;min-height:56px}
.fork-roots strong{display:block;font:600 24px ui-monospace,monospace;line-height:1.1}
.fork-roots small{display:block;font-size:10px;margin-top:4px;color:var(--muted)}
.fork-roots button.active{background:var(--green);border-color:var(--green);color:var(--lime)}
.fork-roots button.active small{color:#c1d5b5}
.fork-connector{display:flex;align-items:center;gap:8px;margin:6px 0;font-size:10px;color:var(--muted)}
.fork-connector>span:first-child{color:#91a97f;font-size:15px;margin-left:12px}
.fork-leaves{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:6px;padding-left:10px;border-left:2px solid #d4dfc7}
.fork-leaves button{background:var(--soft);border:1px solid var(--line);border-radius:10px;padding:8px 2px;min-height:44px;white-space:nowrap;font-size:14px;scroll-margin:6px}
.fork-leaves button.selected{background:var(--lime);border-color:#8fa96a;box-shadow:inset 0 0 0 1px #8fa96a}
.operand-editor{display:flex;align-items:center;justify-content:center;gap:5px;flex-wrap:wrap;margin-top:14px;padding-top:14px;border-top:1px solid var(--line)}
.operand{display:flex;flex-direction:column;align-items:center;justify-content:center;min-width:43px;min-height:53px;border:1px dashed #aabf94;border-radius:10px;background:#f1f5e9;font:600 25px ui-monospace,monospace;padding:3px 7px;position:relative}
.operand small{font:9px sans-serif;color:#799168;margin-top:2px}
.operand.given{background:#e2e6df;border-style:solid;border-color:#bac7b2}
.operand.editing{outline:3px solid #6e9560;outline-offset:2px;background:var(--lime)}
.operand-operator{font-size:22px;letter-spacing:1px;color:#5b745f}
.operand-caption{display:flex;align-items:center;justify-content:space-between;gap:5px;min-height:30px;font-size:11px;color:var(--muted);margin-top:4px}
.operand-caption .quiet{min-height:30px;font-size:11px;padding:0 2px}
.operand-caption strong{color:var(--green);font-size:11px;font-weight:550}
.keypad-mode{display:flex;align-items:center;justify-content:space-between;gap:8px;font-size:11px;color:var(--muted);margin-bottom:9px;min-height:26px}
.keypad-mode .checkbox{font-size:11px;white-space:nowrap}
.keypad-mode .checkbox input{margin:0}
.keypad .keypad-next{background:var(--green);border-color:var(--green);color:var(--lime);font-size:14px}
.target-extra{min-width:32px;font-size:18px;padding:0}
.target-field.inactive{opacity:.55}
.answer-position{display:flex;flex-direction:column;align-items:center;gap:4px}
.answer-position>small{font-size:9px;color:#bfd5b8}
.answer-digit.answer-given{background:#49675a;color:#d1ded3;font-size:29px}
.answer-position:has(.answer-given)>small{color:#9eb1a3}
.answer-controls{display:flex;gap:5px}
#digit-countdown{color:#d7e9b7;font-size:11px;font-variant-numeric:tabular-nums;min-height:15px}
.digit-time-track{position:absolute;bottom:0;left:0;right:0;height:3px;background:#ffffff10}
#digit-countdown-bar{height:100%;width:100%;background:#c4e585;transform-origin:left center;transition:transform .1s linear}
.digit-card .target-field{margin:4px 0 0}
@media(max-width:759px){
  .digit-card{padding:10px 13px}.fork-heading{margin-bottom:4px}.fork-heading .step{font-size:10px}
  .fork-roots{gap:5px}.fork-roots button{min-height:50px;padding:5px 1px}.fork-roots strong{font-size:21px}.fork-roots small{font-size:9px;margin-top:3px}
  .fork-connector{margin:4px 0;font-size:9px;line-height:14px}.fork-connector>span:first-child{font-size:14px}
  .fork-leaves{gap:5px;padding-left:7px}.fork-leaves button{font-size:12px;min-height:44px;padding:6px 1px}
  .operand-editor{margin-top:10px;padding-top:10px;gap:4px}.operand{min-height:46px;min-width:39px;font-size:22px;padding:2px 5px}.operand-operator{font-size:18px}
  .operand-caption{margin-top:2px;font-size:10px;min-height:26px}.operand-caption .quiet{min-height:26px;font-size:10px}.operand-caption strong{font-size:10px}
  .keypad-mode{font-size:10px;margin-bottom:6px;gap:4px}.keypad-mode .checkbox{font-size:10px}.target-extra{min-width:28px}
  .digit-workspace .result:has(.answer-digits){padding:11px 13px;gap:5px 7px}
  .digit-workspace .result:has(.answer-digits) .answer-digit{min-width:32px;height:34px;font-size:24px;padding:0 3px}
  .digit-workspace .result:has(.answer-digits) .answer-given{font-size:21px}.digit-workspace .result:has(.answer-digits) .answer-meta{gap:6px;max-width:118px}
  .digit-workspace .result:has(.answer-digits) .answer-equation{font-size:11px}.answer-position{gap:2px}.answer-position>small{font-size:8px}.answer-meta .answer-controls button{padding:3px 8px;font-size:10px;min-height:30px}
  #digit-countdown{font-size:10px}
}
@media(max-width:359px){.fork-leaves button{font-size:11px}.operand{min-width:35px}.operand-editor{gap:3px}.operand-operator{font-size:17px}.keypad-mode>span{font-size:9px}.digit-workspace .result:has(.answer-digits) .answer-meta{max-width:105px}}
.fork-heading .checkbox{font-size:11px;gap:4px}.fork-heading .checkbox input{margin:0;width:16px;min-height:16px}
@media(max-width:759px){
  .fork-leaves{grid-template-columns:repeat(4,minmax(0,1fr));padding-left:5px;gap:5px}
  .fork-leaves button{font-size:11px;letter-spacing:-.3px}
  .digit-card{padding:8px 13px}.operand-editor{margin-top:8px;padding-top:8px}
  .digit-workspace .keypad button{height:44px}.fork-heading .checkbox{font-size:10px}
  .shell:has(.digit-workspace) .topbar{height:48px}
}
@media(max-width:359px){.fork-leaves button{font-size:10px}.fork-leaves{gap:4px}.fork-heading .step{font-size:9px}.fork-roots small{font-size:8px}}
.operand-caption>span:last-child{display:flex;gap:10px}.operand-caption>strong{font-size:10px}
/* A stationary number pad, with only the steps above it scrolling. */
body:has(.digit-workspace){overflow:hidden}
.shell:has(.digit-workspace){max-width:660px;height:100dvh;padding:0 14px}
.shell:has(.digit-workspace) .topbar{height:58px;margin:0 0 10px}
.digit-workspace{--dock-height:266px;--dock-bottom:calc(84px + env(safe-area-inset-bottom,0px));display:block}
.digit-stage{position:fixed;top:76px;bottom:calc(var(--dock-bottom) + var(--dock-height) + 10px);left:50%;transform:translateX(-50%);width:min(600px,calc(100% - 28px));overflow:auto;overscroll-behavior:contain;overflow-anchor:none;scrollbar-width:thin;padding-bottom:8px}
.digit-dock.card{position:fixed;left:50%;transform:translateX(-50%);bottom:var(--dock-bottom);width:min(600px,calc(100% - 28px));height:var(--dock-height);padding:10px 12px;margin:0;border-radius:20px;z-index:4;box-shadow:0 -8px 26px #173a320b;display:grid;grid-template-rows:40px 1fr;gap:10px}
.digit-dock-field{display:flex;align-items:center;gap:8px;min-width:0;border-bottom:1px solid var(--line)}
.dock-label{font-size:11px;color:var(--muted);white-space:nowrap}
#digit-entry{flex:1;min-width:0;font-size:25px;font-weight:650;text-align:right;white-space:nowrap;overflow:auto;scrollbar-width:none}
.digit-dock .keypad{gap:6px;grid-template-rows:repeat(4,1fr);min-height:0}
.digit-dock .keypad button{height:44px;min-height:44px;font-size:23px;border-radius:11px}
.digit-dock .keypad .key-action{font-size:12px}
.digit-dock .target-extra{min-width:32px;height:40px;min-height:40px}
.digit-steps{display:flex;align-items:center;justify-content:space-between;gap:3px;margin-bottom:12px;font-size:11px;color:var(--muted);white-space:nowrap}
.digit-steps .current{color:var(--green);font-weight:700}
.digit-stage-heading{display:flex;justify-content:space-between;align-items:center;gap:5px;margin-bottom:8px;font-size:13px}
.digit-stage-heading .quiet{padding:0 3px;min-height:36px}
.digit-stage .digit-card{padding:14px;border-radius:18px}
.digit-stage .operand-editor{margin-top:0;padding-top:0;border:0}
.digit-stage .operand-caption{min-height:40px;line-height:1.6}
.digit-clear-option{font-size:11px;color:var(--muted);margin-top:6px;min-height:28px}
.digit-stage .result{margin-top:10px;min-height:0;border-radius:18px}
.digit-stage-hint{font-size:11px;color:var(--muted);margin:12px 4px}
.target-start{padding:24px 20px!important;text-align:center}
.target-start h2{font-size:22px;margin:12px 0 5px}
.target-start p{color:var(--muted);font-size:12px}
.target-preview{font-size:48px;line-height:1.3;margin:18px 0 0;overflow-wrap:anywhere}
.digit-stage .custom-input{width:100%;margin-top:12px}
.digit-stage .custom-toolbar{flex-wrap:wrap}
.shell:has(.digit-workspace) .bottom-nav{bottom:calc(10px + env(safe-area-inset-bottom,0px))}
@media(max-width:359px){.digit-stage{top:68px}.digit-steps{font-size:10px}.digit-stage .digit-card{padding:10px}.target-start h2{font-size:19px}.target-preview{font-size:36px}.digit-stage-heading{font-size:11px}.digit-stage-heading .quiet{font-size:11px}.digit-dock.card{padding-left:10px;padding-right:10px}}
/* Direct entry: the formula picker is available without a next-step action. */
.digit-stage-heading .checkbox{font-size:11px;white-space:nowrap;gap:4px}
.digit-stage-heading .checkbox input{width:16px;min-height:16px;margin:0}
.digit-stage-heading .quiet strong{font-size:21px;margin-left:5px}
.quick-hint{margin-top:10px;color:var(--muted);font-size:11px}
@media(max-height:650px){
  .digit-stage{top:62px}
  .digit-stage-heading{margin-bottom:3px}
  .digit-stage-heading .quiet{min-height:28px}
  .digit-stage .digit-card{padding:8px 10px}
  .digit-stage .operand-caption{min-height:28px;font-size:10px}
  .digit-stage .result{margin-top:6px}
}
@media(max-height:650px){
  .shell:has(.digit-workspace) .topbar{visibility:hidden}
  .digit-stage{top:10px}
  .digit-stage .digit-card:has(.operand-editor){display:grid;grid-template-columns:minmax(0,1fr) 40px;gap:4px}
  .digit-stage .digit-card:has(.operand-editor) .operand-caption{margin:0;min-height:44px}
  .digit-stage .operand-caption>span{display:none}
  .digit-stage .operand-caption .quiet{font-size:10px;line-height:1.4;min-height:44px;padding:0}
}
/* Compact working surfaces; help lives in the information sheet. */
.shell:not(:has(.digit-workspace)){padding:0 12px 92px}
.shell:not(:has(.digit-workspace)) .topbar{height:52px;margin-bottom:8px}
.workspace:not(.digit-workspace){gap:8px}
.workspace:not(.digit-workspace) .card{padding:10px;border-radius:16px}
.workspace:not(.digit-workspace) .card-title{margin-bottom:4px}
.pipe-workspace,.memory-workspace,.shape-workspace{display:block;max-width:760px;margin:auto}
.pipe-workspace #pipe-result{position:relative;top:auto;order:initial;max-height:none;overflow:visible;box-shadow:none;min-height:0;padding:8px 10px;margin-top:8px;border-radius:12px;z-index:auto}
.pipe-workspace #pipe-result[hidden]{display:none}
.pipe-workspace .pipe-result-path{margin:4px 0;gap:6px}
.pipe-workspace .result-empty{font-size:16px;margin:2px 0}
.pipe-workspace .trace-details{margin-top:2px}
.pipe-workspace .trace-details summary{min-height:44px;display:flex;align-items:center}
.pipe-workspace .symbol-row{margin:3px 0;gap:8px}
.pipe-workspace .symbol{width:52px;height:52px}
.pipe-workspace .pipe-arrow{margin:0;font-size:16px;line-height:18px}
.pipe-workspace .pipe-keypad{margin-top:6px}
.pipe-workspace .pipe-keypad button{height:48px}
.pipe-workspace .layer{padding:6px 8px;margin-top:6px;border-radius:12px}
.pipe-workspace .layer .segmented button{min-height:44px;padding:4px 9px}
.pipe-workspace .details summary{min-height:44px;display:flex;align-items:center;padding:3px 0}
.pipe-workspace .details{margin-top:2px}
.pipe-workspace .quiet,.pipe-workspace .tiny-btn{min-height:44px;padding:0 6px}
.pipe-workspace .card-title .segmented button{min-height:44px;min-width:44px}
.memory-summary{display:flex;justify-content:space-between;gap:10px;padding:6px 10px;font-size:12px;color:var(--muted)}
.memory-summary strong{color:var(--green)}
.memory-workspace .memory-tools{gap:6px;margin-top:8px}
.memory-workspace .sequence-list{gap:5px;margin-top:8px}
.memory-workspace .sequence-list:empty{display:none}
.memory-workspace .sequence-list button{min-height:44px}
.shape-tabs{max-width:760px;margin:0 auto 8px}
.shape-tabs button{min-height:44px}
.shape-workspace .grid-pair{gap:8px}
.shape-workspace .grid-label{margin-bottom:3px}
.shape-workspace .tiny-btn{min-height:44px}
.shape-workspace .pixel-grid{padding:5px}
.shape-workspace .grid-settings{margin-top:8px}
.shape-workspace .shape-result{margin-top:8px;padding:8px 10px}
.shape-workspace .shape-result strong{font-size:17px}
.shape-workspace .segmented button{min-height:44px}
.digit-stage .digit-card{padding:8px 10px}
.digit-stage .fork-heading{margin-bottom:3px}
.digit-stage .quick-hint{margin-top:6px;font-size:10px}
.pipe-workspace .card-title{margin:4px 0!important}
.pipe-workspace #pipe-result .pipe-result-path{padding-right:54px}
.pipe-workspace .trace-details:not([open]){position:absolute;right:8px;top:7px;margin:0}
.pipe-workspace .trace-details[open]{margin-top:3px}
.pipe-workspace .trace-details summary{font-size:11px;padding:0 6px}
.pipe-workspace .trace-details[open] .trace{margin-top:2px}
.pipe-options-details summary{min-height:44px;display:flex;align-items:center;font-size:12px;cursor:pointer}
.pipe-options-details .pipe-options{margin-top:2px}

/* Shape identity is conveyed by silhouette, not color. */
.pipe-workspace .symbol:not(.empty),.pipe-workspace .pipe-keypad button{color:#333}
/* Pipe controls stay anchored while rows, layers and results update above. */
body:has(.pipe-workspace){overflow:hidden}
.shell:has(.pipe-workspace){height:100dvh;padding:0 12px}
.pipe-workspace{--pipe-dock-height:216px;--pipe-dock-bottom:calc(84px + env(safe-area-inset-bottom,0px));display:block}
.pipe-stage{position:fixed;top:60px;bottom:calc(var(--pipe-dock-bottom) + var(--pipe-dock-height) + 8px);left:50%;transform:translateX(-50%);width:min(600px,calc(100% - 24px));overflow:auto;overscroll-behavior:contain;overflow-anchor:none;scrollbar-width:thin;padding-bottom:5px}
.pipe-workspace .pipe-dock.card{position:fixed;bottom:var(--pipe-dock-bottom);left:50%;transform:translateX(-50%);width:min(600px,calc(100% - 24px));height:var(--pipe-dock-height);margin:0;padding:8px 10px;z-index:4;display:grid;grid-template-rows:40px 1fr;gap:8px;border-radius:18px}
.pipe-dock-heading{display:flex;align-items:center;justify-content:space-between;gap:8px;font-size:11px}
.pipe-dock-heading>span{color:var(--muted);font-size:10px}
.pipe-dock-heading .quiet{min-height:40px}
.pipe-workspace .pipe-keypad{position:static;display:grid;grid-template-columns:repeat(2,minmax(0,1fr));grid-template-rows:repeat(2,1fr);gap:8px;margin:0;min-height:0}
.pipe-workspace .pipe-keypad button{height:72px;min-height:44px;font-size:32px}
.pipe-workspace .pipe-stage .card{padding:8px}
.pipe-stage .row.spread{min-height:36px}
.pipe-stage .row.spread button{min-height:36px}
.pipe-stage .symbol-row{margin:2px 0}
.pipe-stage .pipe-arrow{font-size:12px;line-height:12px}
.pipe-stage .card-title .checkbox{font-size:11px}
.pipe-timer{display:flex;align-items:center;justify-content:space-between;font-size:10px;color:#d7e9b7;border-top:1px solid #ffffff20;margin-top:4px}
.pipe-timer .quiet{color:#d7e9b7;min-height:32px}
.shell:has(.pipe-workspace) .bottom-nav{bottom:calc(10px + env(safe-area-inset-bottom,0px))}
@media(max-height:650px){.shell:has(.pipe-workspace) .topbar{visibility:hidden}.pipe-stage{top:8px}}
.pipe-workspace>.pipe-stage{display:block}
.pipe-layer-inputs{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:6px}
.pipe-workspace .direct-layer{margin:0;padding:0;background:transparent;min-width:0}
.layer-entry{display:flex;position:relative;min-width:0}
.layer-input{width:100%;min-width:0;min-height:64px;padding:5px 2px;border:1px solid var(--line);border-radius:10px;background:var(--soft);display:flex;flex-direction:column;justify-content:center;gap:5px}
.layer-input>span{font-size:11px;color:var(--muted)}
.layer-input strong{font-size:20px;letter-spacing:1px}
.layer-input.selected{border-color:var(--green);box-shadow:inset 0 0 0 1px var(--green)}
.layer-entry:has(.layer-clear){padding-bottom:32px}
.layer-clear{position:absolute;bottom:0;right:0;height:32px;min-height:32px;width:100%;font-size:18px;color:var(--muted)}
.pipe-layer-inputs .details{font-size:10px}.pipe-layer-inputs input{font-size:12px;padding:6px;min-width:0}
.pipe-layer-inputs:has(>.layer:only-child){grid-template-columns:1fr}
.pipe-layer-inputs:has(>.layer:nth-child(2):last-child){grid-template-columns:repeat(2,minmax(0,1fr))}
.layer-entry:has(.layer-clear){padding-bottom:44px}.layer-clear{height:44px;min-height:44px}
.pipe-dock-heading #pipe-entry{font-variant-numeric:tabular-nums}
.pipe-combination-head,.pipe-combination-row{display:grid;grid-template-columns:repeat(var(--layers),minmax(0,1fr));gap:6px;text-align:center}
.pipe-combination-head{font-size:10px;color:#b6cec0;padding:5px 2px}
.pipe-workspace .pipe-combinations{max-height:220px;overflow:auto;overscroll-behavior:contain;gap:4px}
.pipe-workspace .pipe-combinations button{text-align:center;padding:5px 2px;font-size:14px;min-height:44px}
.pipe-dock-heading:has([data-action="pipe-candidates-done"]:not([hidden])){gap:4px}
.pipe-dock-heading [data-action="pipe-candidates-done"]{padding:0 5px;color:var(--green);font-weight:600}
.pipe-workspace .pipe-result-path.pipe-path-preview{display:none}

.candidate-actions{display:flex;flex-wrap:wrap;gap:0 4px}
.candidate-actions .quiet{min-height:44px;padding:0 4px;font-size:11px}
.pipe-layer-inputs input{width:100%;min-height:44px;font-variant-numeric:tabular-nums}
.pipe-layers-title{flex-wrap:wrap}
.pipe-layers-title .segmented{flex:1;min-width:245px}
.pipe-layers-title .segmented button{min-width:0;padding:6px 3px}
.pipe-result-note{padding:4px 0 6px;color:#b6cec0}
@media(max-width:480px){.pipe-layer-inputs{grid-template-columns:repeat(2,minmax(0,1fr))}.pipe-combination-head,.pipe-combination-row{gap:2px}.pipe-workspace .pipe-combinations button{font-size:11px}}
