/* PETSCII Graphics Lab editor styles. Keep artwork colors separate from interface chrome. */
/* Shared interface tokens. Artwork palette values must not depend on these. */
:root{
 --ui-case-bg:#d4cbb7;
 --ui-control-highlight:#fffaf0;
 --ui-selected-text:#19283b;
 --ui-selected-border:#a18a48;
 --ui-panel-bg:#e5ddcb;
 --ui-bezel-highlight:#e7dfcf;
 --ui-control-bg:#eee7d6;
 --ui-text:#23344b;
 --ui-control-border:#8a8d8d;
 --ui-selected-bg:#ffdf70;
 --ui-heading:#26364a;
 --ui-control-hover:#fff6e4;
 --ui-focus-border:#526f86;
}

:root{font-family:system-ui,-apple-system,sans-serif;color-scheme:light;background:var(--ui-case-bg);color:var(--ui-text)}
*{box-sizing:border-box}
html,body{height:100%;margin:0}
button,select,textarea,input{font:inherit}
#quickPlay{min-width:44px}
button,select{border:1px solid var(--case-edge);background:var(--case-raised);color:var(--case-text);border-radius:9px;min-height:44px;padding:8px 11px}
button{cursor:pointer}
button:disabled{cursor:default;opacity:.5}
button:focus-visible,select:focus-visible{outline:3px solid var(--ui-focus-border);outline-offset:2px}
button.active:not(.color-grid button){
 background:var(--key-active);color:var(--text-on-accent);border-color:var(--key-active-edge);
 box-shadow:var(--key-pressed-shadow);transform:translateY(2px);
}
button:hover{border-color:var(--ui-focus-border)}
.app{display:flex;flex-direction:column;height:100dvh;overflow:hidden}
header{height:61px;flex:none;display:flex;align-items:center;gap:12px;padding:8px 14px;background:var(--case-bg)}
h1{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-size:1.08rem;line-height:1.2;margin:0}
.subtitle{font-size:.72rem;color:var(--case-muted);margin-top:3px}
#toggle{font-size:1.12rem;min-width:43px}
.layout{display:flex;flex:1;min-height:0;position:relative}
.sidebar{width:300px;flex:none;overflow-y:auto;overscroll-behavior:contain;background:var(--case-surface);border-right:1px solid var(--case-edge);padding:10px;transition:width .2s ease,padding .2s ease;scrollbar-width:thin}
.sidebar.closed{width:0;padding:0;border:0;overflow:hidden}
/* Ink/background pickers are flush color tiles — not chrome buttons — so VIC and dense TED grids both read as one continuous palette. */
.color-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:0;margin:10px 0;border:1px solid var(--case-edge);border-radius:0;overflow:hidden;isolation:isolate}
.color-grid button{
 min-width:0;min-height:0;aspect-ratio:1;width:100%;height:auto;padding:0;margin:0;
 border:0;border-radius:0;font-weight:700;font-size:.72rem;line-height:1;
 box-shadow:none;transform:none;background-image:none;
}
.color-grid button:hover,.color-grid button:active,.color-grid button:focus-visible{
 box-shadow:none;transform:none;filter:none;
}
.color-grid button[aria-pressed=true]{
 outline:none;position:relative;z-index:1;
 box-shadow:inset 0 0 0 2px #fff,inset 0 0 0 4px #000;
}
.color-grid button:focus-visible{outline:2px solid var(--ui-focus-border);outline-offset:-2px;z-index:2}
.color-chip{display:inline-block;width:14px;height:14px;border:1px solid var(--case-edge);border-radius:3px;vertical-align:middle;margin-right:4px}#glyphPreview{background:var(--art-bg)}.glyph{color:var(--art-ink)}
.glyph-filter{display:flex;align-items:center;gap:6px;min-height:44px;flex:1}.glyph-filter input{flex:none}
.glyph-family{grid-column:1/-1;font-size:.78rem;color:var(--case-text);margin:12px 0 3px;font-weight:600}
.palette{display:grid;grid-template-columns:repeat(auto-fill,minmax(42px,1fr));gap:5px;padding:2px}
.glyph{height:44px;font-size:23px;padding:0;display:flex;align-items:center;justify-content:center;position:relative}
.glyph small{position:absolute;right:3px;bottom:1px;font:9px ui-monospace,monospace;color:var(--case-muted)}
.glyph canvas{pointer-events:none}
.palette:not(.show-codes) .glyph small{display:none}
.sidebar.closed{visibility:hidden}
input[type=checkbox]{width:20px;height:20px;vertical-align:middle}
a{color:var(--case-text)}
.row{display:flex;gap:7px;flex-wrap:wrap;margin:9px 0}
.row button{flex:1}
.field{display:flex;flex-direction:column;gap:5px;flex:1;min-width:85px}
label{font-size:.77rem;color:var(--case-muted)}
.field select{width:100%}
.field input[type=number]{width:100%;min-height:44px;padding:8px 11px;border:1px solid var(--case-edge);background:var(--case-raised);color:var(--case-text);border-radius:9px}
input[type=text]{width:100%;min-width:0;min-height:44px;padding:8px 11px;border:1px solid var(--case-edge);background:var(--case-raised);color:var(--case-text);border-radius:9px}
textarea{resize:vertical;width:100%;min-height:80px;background:var(--case-surface);color:var(--case-text);border:1px solid var(--case-edge);border-radius:8px;font:12px/1.45 ui-monospace,monospace;padding:8px}
.note{font-size:.72rem;color:var(--case-muted);line-height:1.45}
/* Stage/monitor colors live in the monitor section below; keep structure here. */
.stage{min-width:0;min-height:0;flex:1;display:flex;flex-direction:column;padding:12px;gap:9px}
.stagebar{display:flex;align-items:center;justify-content:space-between;gap:8px;flex:none;min-height:30px;flex-wrap:nowrap}
.stage-canvas-view{display:flex;align-items:center;justify-content:center;gap:8px;flex:1 1 auto;min-width:0}
.stage-canvas-view select{
 font-size:.72rem;line-height:1.2;padding:0 6px;height:28px;min-height:28px;max-height:28px;
 border:1px solid var(--case-edge);border-radius:7px;background:var(--case-surface);color:var(--case-text);
 max-width:7.5rem;flex-shrink:1}
.stage-view-guides{display:inline-flex;align-items:center;gap:4px;font-size:.72rem;color:var(--stage-caption);white-space:nowrap;cursor:pointer;user-select:none;-webkit-user-select:none}
.stage-view-guides input[type=checkbox]{width:17px;height:17px;margin:0;flex:none}
.stage-view-tap{display:inline-flex;align-items:center;gap:4px;font-size:.72rem;color:var(--stage-caption);white-space:nowrap;cursor:pointer;user-select:none;-webkit-user-select:none}
.stage-view-tap input[type=checkbox]{width:17px;height:17px;margin:0;flex:none}
.stage-view-tap.tool-slot-inactive{opacity:.42;cursor:not-allowed}
.sym-mirror-row{display:flex;align-items:center;gap:8px;margin-top:10px;min-height:38px;font-size:.85rem;cursor:pointer}
.sym-mirror-row input[type=checkbox]{width:20px;height:20px;margin:0;flex:none}
.sym-mirror-row.tool-slot-inactive{opacity:.42;cursor:not-allowed}
.stage-canvas-view #symmetryMenu::before{display:none}
.stage-canvas-view .stage-view-symmetry-label{font-size:.72rem;font-weight:600;color:var(--stage-caption);text-shadow:var(--stage-caption-shadow)}
.stage-canvas-view #symmetryMenu>summary{height:44px;padding:0 8px!important;color:var(--stage-caption);text-shadow:var(--stage-caption-shadow);background:transparent;border-color:transparent}
.stage-canvas-view #symmetryMenu>summary.symmetry-on{border-color:var(--sym-summary-on-border);background:var(--sym-summary-on-bg);color:var(--sym-summary-on-fg);text-shadow:none}
.status{font-size:.77rem;color:var(--case-text)}
#dimensions{font-size:.77rem;color:var(--stage-caption)}
.canvas-frame{flex:1;min-height:0;min-width:0;display:flex;align-items:center;justify-content:center;overflow:hidden;border-radius:12px;padding:9px;touch-action:none;overscroll-behavior:contain}
.canvas-frame.canvas-zoomed{align-items:flex-start;justify-content:flex-start;overflow:auto;touch-action:pan-x pan-y;-webkit-overflow-scrolling:touch}
.canvas-frame.canvas-zoomed canvas{flex-shrink:0;max-width:none;max-height:none}
canvas.preview-locked{cursor:default}
canvas{display:block;max-width:100%;max-height:100%;touch-action:none;user-select:none;-webkit-user-select:none;-webkit-touch-callout:none;cursor:crosshair;image-rendering:pixelated}
.stagefoot{font-size:.72rem;color:var(--case-muted);flex:none;text-align:center}
#quickglyph{font-size:1rem;color:var(--stage-caption)}
[hidden]{display:none!important}
.app-title{min-width:0;flex:1}
#glyphToggle{display:flex;align-items:center;gap:7px}
#glyphPreview{width:24px;height:24px;flex:none}
.tool-strip{position:sticky;top:-10px;z-index:2;background:var(--case-surface);padding:1px 0 8px}
.tool-strip .row{margin:0}
.sidebar button{font-size:.79rem;padding:8px 6px}
.sidebar select,.glyph-picker select{font-size:.84rem}
.tool-strip button{white-space:nowrap}
#cancelAnimationExport{width:100%;margin-top:7px;border-color:var(--ui-selected-border)}
.tool-group{border:1px solid var(--case-edge);border-radius:9px;margin-bottom:8px}
summary{cursor:pointer;min-height:44px;padding:12px 10px;font-size:.83rem;font-weight:600;color:var(--case-text)}
summary:focus-visible{outline:3px solid var(--ui-focus-border);outline-offset:-3px;border-radius:8px}
.group-body{padding:0 10px 10px}
.field+.field{margin-top:9px}
.row .field+.field{margin-top:0}
.full-width{width:100%}
.help-disclosure{border-top:1px solid var(--case-edge);margin-top:10px}
.help-disclosure>summary{font-size:.75rem;padding:12px 0}
.glossary-list dt{font-weight:600;margin:.65em 0 0}
.glossary-list dt:first-child{margin-top:0}
.glossary-list dd{margin:.25em 0 0;padding:0}
.summary-badge{float:right;font-size:.65rem;color:var(--case-text);font-weight:400;max-width:90px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.export-tabs{display:flex;gap:4px;margin:10px 0}
.export-tabs button{flex:1;min-width:0;padding:8px 3px;font-size:.77rem}
.export-tabs [aria-selected=true]{background:var(--key-active);color:var(--text-on-accent);border-color:var(--key-active-edge)}
[role=tabpanel]{padding-top:2px}
.motion-summary{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:6px;font-size:.72rem;color:var(--case-muted);margin-bottom:10px}
.motion-summary span{flex-basis:100%}
.motion-summary button{padding:6px 9px}
.glyph-picker{width:320px;flex:none;overflow-y:auto;overscroll-behavior:contain;background:var(--case-surface);padding:10px;border-left:1px solid var(--case-edge);scrollbar-width:thin}
.glyph-picker h2{font-size:.9rem;margin:0}
.picker-heading{position:sticky;top:-10px;background:var(--case-surface);padding:5px 0;z-index:1}
.picker-title{display:flex;align-items:center;justify-content:space-between;margin-bottom:8px}
.picker-heading .note{margin:5px 0}
.picker-heading button{min-width:42px}
#favoriteGlyph{flex:0 0 44px}
.glyph-backdrop{position:absolute;inset:0;z-index:6;border:0;border-radius:0;background:#0005;padding:0}
@media(max-width:1179px){
 .glyph-picker{position:absolute;right:10px;top:10px;bottom:10px;width:min(420px,calc(100% - 20px));border:1px solid var(--case-edge);border-radius:12px;z-index:7;box-shadow:0 10px 45px #0009}
}
@media(max-width:480px){header{gap:7px;padding:7px 8px}h1{font-size:.92rem}.subtitle{display:none}#glyphToggle{padding:7px;gap:4px}}
@media(max-width:690px){
 header{height:56px}
 .sidebar{position:absolute;left:0;top:0;bottom:0;z-index:5;width:min(320px,86vw);box-shadow:12px 0 30px #0008}
 .sidebar.closed{transform:translateX(-100%);width:min(320px,86vw);padding:14px;visibility:hidden}
 .stage{padding:8px}
 .stagefoot{font-size:.65rem}
}

.symmetry-on{border-radius:9px}#downloadPreview{width:100%;object-fit:contain}#saveFailure{color:var(--ui-accent);margin:0}
/* C64C case tokens (default). Monitor darkness stays separate from interface chrome. */
:root,html[data-ui-theme="c64c"]{
 --case-trim:var(--ui-case-bg);--case-seam:#8294a6;--case-highlight:var(--key-active);
 --case-bg:var(--ui-case-bg);--case-surface:var(--ui-control-bg);--case-raised:var(--ui-control-bg);
 --case-edge:var(--ui-control-border);--case-text:var(--ui-text);--case-muted:#45566d;
 --ui-ink:#23344b;--ui-ivory:#eee7d6;--ui-outline:#8a8d8d;
 --ui-accent:#c94e1a;--ui-accent-edge:#8c3215;
 --key-active:var(--ui-accent);--key-active-edge:var(--ui-accent-edge);
 --stage-caption:#293a4d;--stage-caption-shadow:0 1px #fff7;
 --help-panel-bg:#f1eadc;--help-panel-fg:#26364a;--help-panel-border:#9c9689;
 --header-shine:#e4dcc9;--header-border-top:#eee8d9;--header-inset:#f8f1e3;--header-title:#26344b;
 --header-control-bg:#293b56;--header-control-fg:#f8f8f4;--header-control-border:#667a90;
 --strip-control-bg:#253651;--strip-control-fg:#f7f9ff;--strip-control-border:#6e829b;
 --panel-well:#f1eadc;--panel-well-border:#aaa294;--chrome-label:#35475a;
 --stage-wash-top:#e9e1d0;--stage-wash-mid:#d3c9b5;--stage-wash-bottom:#bcb29f;
 --theme-color:#d4cbb7;
 /* Semantic roles (aliases → current C64C look). */
 --surface-panel:var(--ui-panel-bg);--surface-well:var(--panel-well);--surface-field:var(--ui-field-bg);
 --text:var(--ui-text);--text-muted:var(--case-muted);--text-status:var(--ui-heading);--text-on-accent:#fff9ee;
 --select-bg:var(--ui-field-bg);--select-border:var(--ui-field-border);
 --control-raised-shadow:inset 0 1px var(--ui-control-highlight),0 2px 0 #9b9589;
 --sym-divider:#8d887e;--sym-divider-shine:#fff8e8;
 --sym-summary-bg:#e6dfd1;--sym-summary-fg:#293a4c;--sym-summary-border:#99958e;
 --sym-summary-on-bg:var(--key-active);--sym-summary-on-fg:var(--text-on-accent);--sym-summary-on-border:var(--key-active-edge);
 --glyph-key-bg:linear-gradient(155deg,#fff9eb 0%,#eee5d2 72%,#d6cbb7 100%);
 --glyph-key-bg-hover:#fff8e7;--glyph-key-border:#8f8a80;--glyph-key-border-hover:#5b7793;
 --glyph-key-text:#24364c;--glyph-key-code:#485a6e;
 --glyph-key-shadow:inset 1px 1px #fffdf5,inset -1px -1px #b9b09f,0 2px 0 #9d9587;
 --glyph-key-selected-bg:var(--key-active);--glyph-key-selected-border:var(--key-active-edge);
 --glyph-key-selected-text:var(--text-on-accent);
 --glyph-key-selected-shadow:var(--key-pressed-shadow);
 --glyph-key-selected-code:var(--text-on-accent);
 --glyph-rom-filter:invert(1);--glyph-rom-filter-selected:brightness(0) invert(1);
 --pin-raised-shadow:0 2px 0 #a49b8c;
 --key-pressed-shadow:inset 0 3px 6px #61240b70,inset 0 1px 2px #fff5,0 1px 0 #f8edda;
 --header-title-shadow:0 1px #fff8;
 --ui-field-bg:#f7f0e3;--ui-field-border:#938a7a;--ui-field-disabled-bg:#ded7c9;
 --ui-field-disabled-text:#596372;--ui-control-shadow:#a69e90;
 --monitor-crt:#0b1228;--help-example-bg:#e8e0d0;
 color-scheme:light;
}

/* C128 appearance: light gray/beige case with cooler trim. Artwork tokens untouched. */
html[data-ui-theme="c128"]{
 --ui-case-bg:#c5c0b4;
 --ui-control-highlight:#f5f2ea;
 --ui-selected-text:#1a2414;
 --ui-selected-border:#6a8a4a;
 --ui-panel-bg:#d6d1c6;
 --ui-bezel-highlight:#ddd8ce;
 --ui-control-bg:#e0dcd2;
 --ui-text:#2a2a2a;
 --ui-control-border:#7a7a72;
 --ui-selected-bg:#9ec27a;
 --ui-heading:#222222;
 --ui-control-hover:#ebe7de;
 --ui-focus-border:#4a6a8a;
 --ui-field-bg:#f0ece4;
 --ui-field-border:#8a867c;
 --ui-field-disabled-bg:#d2cec5;
 --ui-field-disabled-text:#5a5a5a;
 --ui-control-shadow:#9a968c;
 --case-trim:#6b6b6b;--case-seam:#8a8a8a;--case-highlight:var(--ui-selected-bg);
 --case-bg:var(--ui-case-bg);--case-surface:var(--ui-panel-bg);--case-raised:var(--ui-control-bg);
 --case-edge:var(--ui-control-border);--case-text:var(--ui-text);--case-muted:#555555;
 --ui-ink:var(--ui-text);--ui-ivory:var(--ui-control-bg);--ui-outline:var(--ui-control-border);
 --ui-accent:#5a7a9a;--ui-accent-edge:#3a5a7a;
 --key-active:var(--ui-selected-bg);--key-active-edge:var(--ui-selected-border);
 --stage-caption:#333333;--stage-caption-shadow:0 1px #fff6;
 --help-panel-bg:#e8e4da;--help-panel-fg:#2a2a2a;--help-panel-border:#8a867c;
 --header-shine:#d8d3c8;--header-border-top:#ebe7de;--header-inset:#f5f2ea;--header-title:#222222;
 --header-control-bg:#3a4550;--header-control-fg:#f5f5f0;--header-control-border:#6a7580;
 --strip-control-bg:#343e48;--strip-control-fg:#f5f5f0;--strip-control-border:#6a7580;
 --panel-well:#e8e4da;--panel-well-border:#8a867c;--chrome-label:#333333;
 --stage-wash-top:#ddd8ce;--stage-wash-mid:#c5c0b4;--stage-wash-bottom:#b0aba0;
 --theme-color:#c5c0b4;
 --surface-panel:var(--ui-panel-bg);--surface-well:var(--panel-well);--surface-field:var(--ui-field-bg);
 --text:var(--ui-text);--text-muted:var(--case-muted);--text-status:var(--ui-heading);--text-on-accent:var(--ui-selected-text);
 --select-bg:var(--ui-field-bg);--select-border:var(--ui-field-border);
 --control-raised-shadow:inset 0 1px var(--ui-control-highlight),0 2px 0 var(--ui-control-shadow);
 --sym-divider:#8a867c;--sym-divider-shine:#ebe7de;
 --sym-summary-bg:var(--ui-control-bg);--sym-summary-fg:var(--ui-text);--sym-summary-border:var(--ui-control-border);
 --sym-summary-on-bg:var(--key-active);--sym-summary-on-fg:var(--text-on-accent);--sym-summary-on-border:var(--key-active-edge);
 --glyph-key-bg:linear-gradient(155deg,#f5f2ea 0%,#e0dcd2 72%,#c5c0b4 100%);
 --glyph-key-bg-hover:#ebe7de;--glyph-key-border:#8a867c;--glyph-key-border-hover:var(--ui-selected-border);
 --glyph-key-text:#2a2a2a;--glyph-key-code:#555555;
 --glyph-key-shadow:inset 1px 1px #f5f2ea,inset -1px -1px #9a968c,0 2px 0 #8a867c;
 --glyph-key-selected-bg:var(--key-active);--glyph-key-selected-border:var(--key-active-edge);
 --glyph-key-selected-text:var(--text-on-accent);
 --glyph-key-selected-shadow:var(--key-pressed-shadow);
 --glyph-key-selected-code:var(--text-on-accent);
 --glyph-rom-filter:invert(1);--glyph-rom-filter-selected:brightness(0) invert(1);
 --pin-raised-shadow:0 2px 0 var(--ui-control-shadow);
 --key-pressed-shadow:inset 0 3px 6px #4a6a3270,inset 0 1px 2px #fff5,0 1px 0 #ebe7de;
 --header-title-shadow:0 1px #fff6;
 --monitor-crt:#0b1228;--help-example-bg:#ddd8ce;
 color-scheme:light;
}

/* Plus/4 appearance: dark charcoal enclosure with contrasting controls. */
html[data-ui-theme="plus4"]{
 --ui-case-bg:#2f2f2f;
 --ui-control-highlight:#555555;
 --ui-selected-text:#1a1014;
 --ui-selected-border:#a03868;
 --ui-panel-bg:#3a3a3a;
 --ui-bezel-highlight:#4a4a4a;
 --ui-control-bg:#454545;
 --ui-text:#e8e8e8;
 --ui-control-border:#6a6a6a;
 --ui-selected-bg:#c94e8a;
 --ui-heading:#f0f0f0;
 --ui-control-hover:#505050;
 --ui-focus-border:#8ab4d4;
 --ui-field-bg:#262626;
 --ui-field-border:#6a6a6a;
 --ui-field-disabled-bg:#333333;
 --ui-field-disabled-text:#9a9a9a;
 --ui-control-shadow:#1a1a1a;
 --case-trim:#1a1a1a;--case-seam:#555555;--case-highlight:var(--key-active);
 --case-bg:var(--ui-case-bg);--case-surface:var(--ui-panel-bg);--case-raised:var(--ui-control-bg);
 --case-edge:var(--ui-control-border);--case-text:var(--ui-text);--case-muted:#a8a8a8;
 --ui-ink:var(--ui-text);--ui-ivory:var(--ui-control-bg);--ui-outline:var(--ui-control-border);
 --ui-accent:#c94e8a;--ui-accent-edge:#8c3258;
 --key-active:var(--ui-accent);--key-active-edge:var(--ui-accent-edge);
 --stage-caption:#d0d0d0;--stage-caption-shadow:none;
 --help-panel-bg:#3a3a3a;--help-panel-fg:#e8e8e8;--help-panel-border:#6a6a6a;
 --header-shine:#3a3a3a;--header-border-top:#505050;--header-inset:#2a2a2a;--header-title:#f0f0f0;
 --header-control-bg:#5a5a5a;--header-control-fg:#f5f5f5;--header-control-border:#7a7a7a;
 --strip-control-bg:#505050;--strip-control-fg:#f5f5f5;--strip-control-border:#7a7a7a;
 --panel-well:#333333;--panel-well-border:#6a6a6a;--chrome-label:#d0d0d0;
 --stage-wash-top:#3a3a3a;--stage-wash-mid:#2f2f2f;--stage-wash-bottom:#262626;
 --theme-color:#2f2f2f;
 --surface-panel:var(--ui-panel-bg);--surface-well:var(--panel-well);--surface-field:var(--ui-field-bg);
 --text:var(--ui-text);--text-muted:var(--case-muted);--text-status:var(--ui-heading);--text-on-accent:#fff9ee;
 --select-bg:var(--ui-field-bg);--select-border:var(--ui-field-border);
 --control-raised-shadow:inset 0 1px var(--ui-control-highlight),0 2px 0 var(--ui-control-shadow);
 --sym-divider:#6a6a6a;--sym-divider-shine:#505050;
 --sym-summary-bg:var(--ui-control-bg);--sym-summary-fg:var(--ui-text);--sym-summary-border:var(--ui-control-border);
 --sym-summary-on-bg:var(--key-active);--sym-summary-on-fg:var(--text-on-accent);--sym-summary-on-border:var(--key-active-edge);
 --glyph-key-bg:linear-gradient(155deg,#5a5a5a 0%,#4a4a4a 72%,#3a3a3a 100%);
 --glyph-key-bg-hover:#555555;--glyph-key-border:#6a6a6a;--glyph-key-border-hover:#8ab4d4;
 --glyph-key-text:#f0f0f0;--glyph-key-code:#c0c0c0;
 --glyph-key-shadow:inset 1px 1px #6a6a6a,inset -1px -1px #2a2a2a,0 2px 0 #1a1a1a;
 --glyph-key-selected-bg:var(--key-active);--glyph-key-selected-border:var(--key-active-edge);
 --glyph-key-selected-text:var(--text-on-accent);
 --glyph-key-selected-shadow:var(--key-pressed-shadow);
 --glyph-key-selected-code:var(--text-on-accent);
 /* Light ROM pixels on charcoal keys; invert only when selected (white on pink). */
 --glyph-rom-filter:none;--glyph-rom-filter-selected:brightness(0) invert(1);
 --pin-raised-shadow:0 2px 0 var(--ui-control-shadow);
 --key-pressed-shadow:inset 0 3px 6px #61240b70,inset 0 1px 2px #fff5,0 1px 0 #3a3a3a;
 --header-title-shadow:none;
 --monitor-crt:#0b1228;--help-example-bg:#2a2a2a;
 color-scheme:dark;
}

#machineMenu{position:relative;align-self:center}
#machineMenu>summary{list-style:none;border:1px solid var(--case-edge);border-radius:9px;padding:0 11px;font-size:.8rem;cursor:pointer}
#machineMenu>summary::-webkit-details-marker{display:none}
.machine-menu{position:absolute;left:0;top:calc(100% + 6px);width:min(280px,calc(100vw - 24px));box-sizing:border-box;padding:14px;background:var(--case-surface);border:1px solid var(--case-edge);z-index:12;border-radius:10px;box-shadow:0 10px 35px #0008}
@media(prefers-reduced-motion:reduce){.sidebar{transition:none}}

/* Keep frequent actions stable; occasional controls live in separate surfaces. */
button,select,.field input[type=number]{min-height:44px}
.drawing-strip{display:flex;flex-wrap:wrap;align-items:center;justify-content:center;gap:6px;padding:7px 10px;flex:none;background:var(--case-bg);z-index:8;overflow:visible}
.drawing-strip button,.drawing-strip summary{white-space:nowrap}
.drawing-strip summary:not(.tool-mode-trigger){padding:10px;list-style:none}
#inkPopover,#canvasPopover{position:fixed;inset:auto;margin:0;width:min(320px,calc(100vw - 16px));max-height:calc(100dvh - 145px);overflow:auto;background:var(--case-surface);color:var(--case-text);border:1px solid var(--case-edge);border-radius:12px;padding:14px;box-shadow:0 10px 35px #0008}
#canvasPopover{width:min(360px,calc(100vw - 16px))}
#inkPopover h2,#canvasPopover h2{font-size:.9rem;margin:0}#inkPopover .color-grid{margin-bottom:0}#inkPopover .color-grid button{font-size:.7rem}#inkSelection{margin:8px 0 0}
#canvasPopover .replace-fieldset{margin:10px 0 0;border:1px solid var(--case-edge);border-radius:8px;padding:10px}
#canvasPopover .replace-fieldset legend{font-size:.8rem;padding:0 4px}
#canvasPopover .note{margin:6px 0 10px}
#symmetryMenu{position:relative;border:1px solid var(--case-edge);border-radius:9px}
.tool-popover{position:absolute;top:100%;right:0;background:var(--case-surface);border:1px solid var(--case-edge);padding:14px;width:210px;border-radius:9px;box-shadow:0 10px 30px #0008;z-index:14}
.tool-mode-popover{width:auto;min-width:0;padding:6px;z-index:15}
.tool-mode-bar{display:flex;flex-direction:row;flex-wrap:nowrap;align-items:center;gap:4px}
.tool-mode-bar .tool-mode-option{flex:0 0 auto;border-radius:9px}
.tool-mode-bar .tool-mode-option[aria-pressed=true],
.tool-mode-menu>summary.tool-mode-trigger.active{
 background:var(--key-active);color:var(--text-on-accent);border-color:var(--key-active-edge);
 box-shadow:var(--key-pressed-shadow);transform:translateY(2px);
}
.tool-mode-bar .tool-mode-option[aria-pressed=true] svg,
.tool-mode-menu>summary.tool-mode-trigger.active svg{stroke:currentColor}
#projectMenu{position:relative}
#projectMenu>summary{list-style:none;border:1px solid var(--case-edge);border-radius:9px;padding:11px;font-size:.8rem}
.project-menu{position:absolute;left:0;top:calc(100% + 6px);width:min(340px,calc(100vw - 24px));box-sizing:border-box;max-height:calc(100dvh - 80px);overflow:auto;padding:14px;background:var(--case-surface);border:1px solid var(--case-edge);z-index:12;border-radius:10px;box-shadow:0 10px 35px #0008}
.project-menu .row:has(>button[hidden]){display:none}
.project-name{display:flex;align-items:center;gap:6px}.project-name input{flex:1;width:0}.project-name span{font-size:.8rem;flex:none}
.project-menu fieldset{min-width:0;margin:0 0 12px;padding:10px;border:1px solid var(--case-edge);border-radius:8px}.project-menu fieldset:last-child{margin-bottom:0}.project-menu legend{font-size:.8rem;font-weight:700}.project-menu input{box-sizing:border-box;max-width:100%;min-width:0}.project-menu .row{flex-direction:column}.project-menu .save-hint{font-size:.72rem;line-height:1.4;margin:6px 0}
#saveStatus{position:relative;font-size:.68rem}
.preview-banner{display:flex;align-items:center;justify-content:space-between;gap:8px;color:var(--stage-caption);font-size:.8rem}
.preview-banner button{font-size:.75rem}
.reference-overlay-bar{flex-wrap:wrap;row-gap:6px}
.replace-fieldset{margin-top:10px}
.replace-ink-pair{display:flex;flex-direction:column;gap:10px}
.replace-ink-slot{display:flex;flex-direction:column;align-items:stretch}
.replace-ink-slot .replace-ink-grid{margin:4px 0 0}
#canvasPopover .replace-ink-grid button{font-size:.7rem}
.replace-glyph-pair{display:flex;gap:10px;flex-wrap:wrap}
.replace-glyph-slot{display:flex;flex-direction:column;gap:4px;align-items:flex-start}
.replace-glyph-label{font-size:.8rem;color:var(--stage-caption)}
.replace-glyph-btn{display:flex;align-items:center;gap:6px;min-height:38px;padding:4px 8px}
.reference-opacity{display:flex;align-items:center;gap:6px;font-size:.75rem}
.reference-opacity input{width:88px}
.task-progress:not(:has(#cancelAnimationExport:not([hidden]))):not(:has(#stageExportProgressWrap:not([hidden]))){display:none}
.task-progress .export-progress-wrap{margin-bottom:6px}
.export-progress-wrap{display:flex;flex-direction:column;gap:6px;margin:8px 0}
#exportProgressWrap{margin-top:6px}
.export-progress{width:100%;height:10px;appearance:none;-webkit-appearance:none;border:1px solid var(--ui-control-border);border-radius:6px;background:var(--ui-control-bg);overflow:hidden}
.export-progress::-webkit-progress-bar{background:var(--ui-control-bg);border-radius:6px}
.export-progress::-webkit-progress-value{background:var(--ui-focus-border);border-radius:5px}
.export-progress::-moz-progress-bar{background:var(--ui-focus-border);border-radius:5px}
.export-progress.export-progress-indeterminate::-webkit-progress-value{background:repeating-linear-gradient(90deg,var(--ui-focus-border) 0 12px,transparent 12px 20px);animation:export-progress-pulse 1s linear infinite}
.export-progress.export-progress-indeterminate::-moz-progress-bar{background:repeating-linear-gradient(90deg,var(--ui-focus-border) 0 12px,transparent 12px 20px);animation:export-progress-pulse 1s linear infinite}
@keyframes export-progress-pulse{from{background-position:0 0}to{background-position:20px 0}}
.export-progress-label{font-size:.78rem;font-weight:600;color:var(--text-status)}
#cancelAnimationExport{width:auto;margin:0}
dialog{color:var(--case-text);background:var(--case-surface);border:1px solid var(--case-edge);border-radius:14px;width:min(820px,calc(100vw - 24px));max-height:calc(100dvh - 24px);padding:18px;overscroll-behavior:contain}
dialog::backdrop{background:#0009}
.dialog-heading{display:flex;justify-content:space-between;align-items:center;gap:12px}.dialog-heading h2{font-size:1.1rem;margin:0}
.download-layout:has(#downloadFigure[hidden]){grid-template-columns:minmax(0,1fr)}
.download-layout{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:24px}
#downloadFigure{margin:16px 0;padding:14px;background:var(--case-surface);border-radius:10px;align-self:start;min-width:0}
#c64TimingOverrideWrap label{display:flex;align-items:center;gap:8px;min-height:44px}
#downloadPreview,#resizePreview{width:auto;height:auto;max-height:260px;margin:auto;cursor:default}
#resizePreview{max-height:110px}#downloadDimensions{margin-top:12px}
.glyph canvas{background:#000!important}.glyph{color:#fff}
#glyphPin{font-size:.75rem;padding:7px}
#glyphPin{display:inline-flex;align-items:center;justify-content:center;min-width:42px;min-height:42px;color:var(--ui-text);background:var(--ui-control-bg);border:1px solid var(--ui-control-border);border-radius:8px;box-shadow:var(--pin-raised-shadow)}
#glyphPin svg{display:block;pointer-events:none}
#glyphPin[aria-pressed=true]{background:var(--key-active);color:var(--text-on-accent);border-color:var(--key-active-edge);box-shadow:var(--key-pressed-shadow);transform:translateY(2px)}
.picker-title h2{margin-right:auto}.glyph-picker.pinned{position:static;width:300px;border-radius:0;box-shadow:none;flex:none}
#downloadPreview{width:100%;object-fit:contain}
@media(max-width:800px){.drawing-strip{gap:4px}.tool-label{display:none}.drawing-strip button{padding:8px 10px}}
@media(max-width:600px){#downloadOpen{font-size:.76rem;padding:8px}#projectMenu>summary{padding:11px 7px}.download-layout{grid-template-columns:1fr;gap:0}#downloadFigure{order:-1;margin:10px 0}#downloadPreview{max-height:120px}#downloadDescription{display:none}#quickPlay{min-width:44px;padding:8px}.drawing-strip{padding:6px 5px}#glyphToggle{padding:7px}#glyphToggle span{display:none}#inkQuick{padding:8px}#inkChip{margin:0}.app-title .subtitle{display:none}}

.animation-section,.sidebar-section{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:6px;margin:0 0 8px;padding:6px;border:1px solid var(--case-edge);border-radius:8px;min-width:0}
.animation-section legend,.sidebar-section legend{font-size:.8rem;font-weight:600;color:var(--case-text);padding:0 5px}
.animation-section .field{min-width:0;margin:0}.animation-section .field+.field{margin-top:0}
.animation-section label{min-height:1.3em;display:flex;align-items:end;line-height:1.3}
.animation-section select{min-width:0;padding-inline:5px;width:100%}
#animationEffect,#animationColor{width:100%}
#animationMovement>.field:first-of-type,#animationColors>.field:first-of-type,#animationTimeline>.field,#animationTimeline>.row{grid-column:1/-1}
#animationTimeline>.row{margin:0}#animationTimeline label{min-height:0}
#scrollOptions,#waveOptions,#colorWaveOptions,#parallaxOptions,#fieldOptions{display:contents}
#introMotionHelp{grid-column:1/-1;margin:0}
.animation-section .wave-length{grid-column:1}
#animationTimeline>.cycle-rate{grid-column:auto}
#animationTimeline .cycle-rate label{min-height:2.6em}
.sidebar-section>.row,.sidebar-section>.color-grid,.sidebar-section>button,.sidebar-section>#resizeDraft{grid-column:1/-1}
.sidebar-section>.row{margin:0}.sidebar-section>.color-grid{margin:4px 0}
.sidebar-section .field{min-width:0}
.sidebar-section select{min-width:0;padding-inline:5px}
@media(min-width:691px){.animation-section{grid-template-columns:repeat(auto-fit,minmax(min(95px,100%),1fr))}}

/* Enclosure chrome: one winning paint layer from theme tokens. */
body{background:var(--ui-case-bg);color:var(--case-text)}
.app{background:var(--ui-case-bg)}
header{background:linear-gradient(180deg,var(--header-shine) 0%,var(--ui-case-bg) 100%);color:var(--case-text);border-top:5px solid var(--header-border-top);border-bottom:3px solid var(--case-seam);box-shadow:inset 0 -1px var(--header-inset)}
header h1{color:var(--header-title);font-weight:800;text-shadow:var(--header-title-shadow)}
header .subtitle{color:var(--case-muted)}
.drawing-strip{background:var(--ui-case-bg);border-bottom:3px solid var(--case-seam);box-shadow:inset 0 1px var(--header-border-top)}
.sidebar,.glyph-picker{background:var(--ui-case-bg);color:var(--case-text);border-color:var(--case-edge)}
.sidebar label,.glyph-picker label,.sidebar .note,.glyph-picker .note{color:var(--case-muted)}
.sidebar summary,.glyph-picker summary,.sidebar legend,.glyph-picker h2{color:var(--header-title)}
.sidebar .tool-group,.sidebar .animation-section,.sidebar .sidebar-section,.glyph-picker .tool-group{background:var(--panel-well);border-color:var(--panel-well-border)}
.sidebar .tool-strip,.glyph-picker .picker-heading{background:var(--ui-case-bg)}
.sidebar .summary-badge{color:var(--chrome-label)}
dialog{border:4px solid var(--ui-case-bg);box-shadow:0 18px 65px #000a}
@media(max-width:690px){.sidebar{box-shadow:12px 0 30px #0008}}


/* Hardware key palette: raised controls; accent keys when pressed. */
header button,header select,header #projectMenu>summary,header #machineMenu>summary,
.drawing-strip button,.drawing-strip summary,
.sidebar button:not(.color-grid button):not(.glyph),
.sidebar select,.sidebar input[type=number],.sidebar input[type=text],
.glyph-picker button:not(.glyph),.glyph-picker select{
 background:var(--ui-control-bg);color:var(--ui-text);border:1px solid var(--ui-control-border);
 box-shadow:var(--control-raised-shadow);
}
header button:hover,.drawing-strip button:hover,.sidebar button:not(.color-grid button):hover,.glyph-picker button:hover{
 background:var(--ui-control-hover);border-color:var(--ui-focus-border);
}
header button:active,.drawing-strip button:active,.sidebar button:not(.color-grid button):active,.glyph-picker button:active,
.preview-banner button:active{
 box-shadow:inset 0 2px 3px #0002;transform:translateY(1px);
}
header button[aria-pressed=true],.drawing-strip button[aria-pressed=true],
.drawing-strip button.active,.sidebar button.active,
.sidebar button[aria-pressed=true]:not(.color-grid button),
.glyph-picker button.active,.export-tabs [aria-selected=true],
.project-menu button[aria-pressed=true],dialog button[aria-pressed=true],
.project-menu button.active,dialog button.active,
#motionPreview[aria-pressed=true],
#c64Preview[aria-pressed=true]{
 background:var(--key-active);color:var(--text-on-accent);border-color:var(--key-active-edge);
 box-shadow:var(--key-pressed-shadow);transform:translateY(2px);
}
.sidebar .glyph-family,.glyph-picker .glyph-family,
.sidebar .group-body,.sidebar .field label,.glyph-picker .note,
.sidebar .note,.glyph-picker h2,.sidebar legend{color:var(--ui-heading)}
.sidebar .tool-group,.sidebar .animation-section,.sidebar .sidebar-section{
 background:var(--surface-well);border-color:var(--panel-well-border);
}
.sidebar .tool-group>summary,.sidebar .animation-section legend,.sidebar .sidebar-section legend{
 color:var(--ui-heading);
}
.glyph-picker .glyph{background:var(--glyph-key-bg);color:var(--glyph-key-text);border-color:var(--glyph-key-border);box-shadow:none}
.glyph-picker .glyph:hover{background:var(--glyph-key-bg-hover)}
/* Keep swatches as pure color fills even under hardware-key chrome rules. */
.color-grid button,.color-grid button:hover,.color-grid button:active,
.sidebar .color-grid button,.sidebar .color-grid button:hover,
#inkPopover .color-grid button,#inkPopover .color-grid button:hover,
#inkPopover .color-grid button:not([aria-pressed=true]):not(.active):not(:disabled){
 background-image:none;border:0;border-radius:0;box-shadow:none;transform:none;
}


/* Select menus follow theme field tokens (inherit color-scheme from html theme). */
select,header select,.sidebar select,.glyph-picker select,dialog select,
.animation-section select,.sidebar-section select{
 color-scheme:inherit;
 background-color:var(--select-bg);
 color:var(--ui-text);
 border:1px solid var(--select-border);
 box-shadow:var(--control-raised-shadow);
}
select option,select optgroup{background:var(--ui-control-highlight);color:var(--ui-text)}
select:hover,header select:hover,.sidebar select:hover,.glyph-picker select:hover,dialog select:hover{
 background-color:var(--ui-control-highlight);border-color:var(--ui-focus-border);
}
select:disabled{background-color:var(--ui-field-disabled-bg);color:var(--ui-field-disabled-text);opacity:1}

/* PETSCII keycaps: token-driven; C64C ivory / Plus/4 charcoal via --glyph-key-*. */
.glyph-picker .palette .glyph{
 background:var(--glyph-key-bg);
 color:var(--glyph-key-text);border:1px solid var(--glyph-key-border);border-radius:6px;
 box-shadow:var(--glyph-key-shadow);
 padding:3px 3px 5px;min-height:44px;height:44px;
}
.glyph-picker .palette .glyph canvas{
 width:28px!important;height:28px!important;background:transparent!important;
 filter:var(--glyph-rom-filter);
}
.glyph-picker .palette .glyph:hover{background:var(--glyph-key-bg-hover);border-color:var(--glyph-key-border-hover)}
.glyph-picker .palette .glyph.active,
.glyph-picker .palette .glyph[aria-pressed=true]{
 background:var(--glyph-key-selected-bg);color:var(--glyph-key-selected-text);border-color:var(--glyph-key-selected-border);
 box-shadow:var(--glyph-key-selected-shadow);
}
.glyph-picker .palette .glyph.active canvas,
.glyph-picker .palette .glyph[aria-pressed=true] canvas{
 filter:var(--glyph-rom-filter-selected);
 mix-blend-mode:normal;
}
.glyph-picker .palette .glyph small{color:var(--glyph-key-code);font-weight:700;right:3px;bottom:1px}
.glyph-picker .palette .glyph.active small,
.glyph-picker .palette .glyph[aria-pressed=true] small{color:var(--glyph-key-selected-code)}
.glyph-picker .palette .glyph:focus-visible{outline:3px solid var(--ui-focus-border);outline-offset:2px}


/* Enclosure surfaces: panels, popovers, dialogs — token-driven for all themes. */
.sidebar,.glyph-picker,.picker-heading,.tool-strip,
.project-menu,.machine-menu,.tool-popover,#inkPopover,#canvasPopover,dialog{
 background:var(--ui-panel-bg);color:var(--ui-heading);border-color:var(--panel-well-border);
}
.sidebar .tool-group,.sidebar .animation-section,.sidebar .sidebar-section,
.project-menu fieldset{
 background:var(--panel-well);color:var(--ui-heading);border-color:var(--panel-well-border);
}
.sidebar summary,.glyph-picker summary,.project-menu summary,
.project-menu legend,dialog legend,dialog h2,
.sidebar label,.glyph-picker label,.project-menu label,dialog label,
.sidebar .note,.glyph-picker .note,.project-menu .note,.machine-menu .note,dialog .note,
.sidebar .motion-summary,.sidebar .motion-summary span,
.sidebar .summary-badge,.project-menu .save-hint{
 color:var(--chrome-label);
}
.sidebar .tool-strip{background:var(--ui-panel-bg)}
.picker-heading{background:var(--ui-panel-bg)}
.project-menu input:not([type=checkbox]),dialog input:not([type=checkbox]),
.project-menu textarea,dialog textarea,.sidebar textarea{
 background:var(--ui-field-bg);color:var(--ui-heading);border:1px solid var(--ui-field-border);
}
.project-menu button,dialog button,#inkPopover button,#canvasPopover button,.tool-popover button{
 background:var(--ui-control-bg);color:var(--ui-text);border:1px solid var(--ui-control-border);
}
.project-menu button:hover,dialog button:hover,#inkPopover button:hover,#canvasPopover button:hover,.tool-popover button:hover{
 background:var(--ui-control-hover);border-color:var(--ui-focus-border);
}
/* Pressed/active accent for menus/dialogs is set with the hardware-key pressed rule above. */
.help-disclosure{border-color:var(--panel-well-border)}
#downloadFigure{background:var(--ui-control-bg)}
#downloadPreview,#resizePreview{background:repeating-conic-gradient(var(--panel-well-border) 0 25%,var(--ui-field-bg) 0 50%) 0/16px 16px}
/* Status / export feedback — readable on every theme surface. */
dialog .status,
#downloadDialog #exportBadge,#downloadDialog #downloadStatus,
#downloadDialog .motion-summary,#downloadDialog .note{
 color:var(--text-status);
}
dialog .status{font-weight:600}
dialog .status[role="status"]{min-height:1.2em}
#downloadDialog #exportBadge{font-weight:700}
dialog input:not([type=checkbox]):not([type=radio]):not([type=range]){
 background:var(--surface-field);color:var(--text);border:1px solid var(--select-border);box-shadow:none;
}
dialog input:not([type=checkbox]):not([type=radio]):not([type=range]):focus{
 outline:3px solid var(--ui-focus-border);outline-offset:1px;
}
/* Symmetry summary colors (geometry in shell.css). */
#symmetryMenu{border:0;border-radius:0;background:transparent}
#symmetryMenu::before{
 content:"";position:absolute;left:-9px;top:6px;bottom:6px;width:1px;
 background:var(--sym-divider);box-shadow:1px 0 var(--sym-divider-shine);pointer-events:none;
}
#symmetryMenu>summary{
 color:var(--sym-summary-fg);background:var(--sym-summary-bg);border:1px solid var(--sym-summary-border);
}
#symmetryMenu>summary.symmetry-on{
 color:var(--sym-summary-on-fg);background:var(--sym-summary-on-bg);border-color:var(--sym-summary-on-border);
 box-shadow:var(--key-pressed-shadow);transform:translateY(2px);
}


/* Monitor surround, readable stage labels, and contextual help. */
.stage{
 background:linear-gradient(145deg,var(--stage-wash-top) 0%,var(--stage-wash-mid) 54%,var(--stage-wash-bottom) 100%);
 border-left:2px solid var(--header-border-top);
 box-shadow:inset 3px 3px 6px #fff9,inset -4px -4px 8px #71695745;
}
.canvas-frame{
 border:solid var(--ui-bezel-highlight);border-width:11px 12px 13px;
 border-radius:22px;
 background:var(--monitor-crt);
 box-shadow:0 0 0 2px var(--panel-well-border),0 0 0 5px var(--stage-wash-top),
 inset 0 4px 13px #000c,inset 4px 0 9px #0008,
 0 7px 16px #62594955;
}
.stagebar,.stagefoot,.stagebar #dimensions,.stagebar #status,.stagebar #quickglyph,.stage-canvas-view,.stage-view-guides,.stage-view-tap,.stage-canvas-view .stage-view-symmetry-label,
.stage #stageHint,.preview-banner,#previewLabel{
 color:var(--stage-caption);text-shadow:var(--stage-caption-shadow);
}
.drawing-strip .tool-hint,.drawing-strip .drawing-hint,
.drawing-strip label,.drawing-strip span:not(.tool-label),
.drawing-strip .hint{color:var(--stage-caption)}
header #saveStatus,header .status,header .note{color:var(--chrome-label)}
.context-help{
 background:var(--help-panel-bg);color:var(--help-panel-fg);border:2px solid var(--help-panel-border);
 box-shadow:0 12px 30px #1a233650;
}
.context-help h3,.context-help p,.context-help li{color:var(--help-panel-fg)}
.context-help button,.preview-banner button,
#motionPreview,#c64Preview,
.stage .preview-banner #returnDrawing,.stagebar>.help-trigger,
.stagebar .help-trigger,.help-section .help-trigger{
 background:var(--ui-control-bg);color:var(--ui-text);border:1px solid var(--ui-control-border);
}
.stagebar .help-trigger:hover,.help-section .help-trigger:hover{
 background:var(--ui-control-hover);border-color:var(--ui-focus-border);
}
.stagebar .help-trigger[aria-expanded=true],.help-section .help-trigger[aria-expanded=true]{
 background:var(--key-active);color:var(--text-on-accent);border-color:var(--key-active-edge);
 box-shadow:var(--key-pressed-shadow);transform:translateY(2px);
}
.context-help .help-control,.context-help .help-key{
 border:1px solid var(--help-panel-border);background:var(--ui-control-bg);color:var(--ui-text);
 box-shadow:0 2px 0 var(--ui-control-shadow);
}
.context-help .help-key{background:var(--ui-field-bg);border-color:var(--ui-field-border)}
.context-help .help-example{background:var(--help-example-bg);color:var(--help-panel-fg)}
dialog details>summary,dialog .help-disclosure>summary,
dialog details>summary::marker{color:var(--chrome-label)}
dialog details>summary:hover{color:var(--header-title)}
@media(max-width:690px){.canvas-frame{border-width:7px 8px 9px;border-radius:15px}}


/* Final CRT bezel geometry (desktop and narrow screens). */
.canvas-frame{
 border-width:15px 17px 19px;
 border-color:var(--ui-bezel-highlight) #b9af9e #a69c8b #ded5c4;
 border-radius:26px;
 box-shadow:
  0 0 0 2px #8b8172,
  0 0 0 6px var(--ui-bezel-highlight),
  0 4px 0 7px #a79b89,
  0 12px 18px 5px #554c3e70,
  inset 0 6px 15px #000d,
  inset 6px 0 12px #0009;
}
@media(max-width:690px){
 .canvas-frame{border-width:9px 10px 12px;border-radius:18px;
 box-shadow:0 0 0 2px #8b8172,0 0 0 4px var(--ui-bezel-highlight),0 3px 0 5px #a79b89,0 8px 12px #554c3e65,inset 0 4px 10px #000b}
}


/* Shared form-control system: recessed fields and raised buttons (tokens per theme). */
:is(.sidebar,.glyph-picker,.project-menu,.machine-menu,dialog,.tool-popover,#inkPopover,#canvasPopover)
:is(input:not([type=checkbox]):not([type=radio]):not([type=color]):not([type=range]):not([type=file]),
    textarea,select){
 background-color:var(--ui-field-bg);
 color:var(--ui-text);
 border:1px solid var(--ui-field-border);
 border-radius:9px;
 box-shadow:inset 0 1px 2px #70675a25;
}
:is(.sidebar,.glyph-picker,.project-menu,.machine-menu,dialog,.tool-popover,#inkPopover,#canvasPopover)
:is(input:not([type=checkbox]):not([type=radio]):not([type=color]):not([type=range]):not([type=file]),
    textarea,select):disabled{
 background-color:var(--ui-field-disabled-bg);
 color:var(--ui-field-disabled-text);
 opacity:1;
}
:is(.sidebar,.glyph-picker,.project-menu,.machine-menu,dialog,.tool-popover,#inkPopover,#canvasPopover)
:is(input:not([type=checkbox]):not([type=radio]):not([type=color]):not([type=range]):not([type=file]),
    textarea,select):focus-visible{
 outline:3px solid var(--ui-focus-border);
 outline-offset:2px;
}
:is(.project-menu,.machine-menu,dialog,.tool-popover,#inkPopover,#canvasPopover) button:not(.color-grid button):not([aria-pressed=true]):not(.active):not(:disabled){
 background:var(--ui-control-bg);
 color:var(--ui-text);
 border-color:var(--ui-control-border);
}
:is(.project-menu,.machine-menu,dialog,.tool-popover,#inkPopover,#canvasPopover) button:not(.color-grid button):disabled{
 background:var(--ui-field-disabled-bg);
 color:var(--ui-field-disabled-text);
 opacity:1;
}

/* Machine modes: Plus/4 TED picker is 1 black + 15 chroma × 8 luma, flush like VIC.
   Black alone on row 1 so each chroma keeps a clean L0–L7 row (index 0 would otherwise shift every band). */
.color-grid.ted-grid{grid-template-columns:repeat(8,minmax(0,1fr));gap:0}
.color-grid.ted-grid>button:first-child{
 grid-column:1/-1;width:12.5%;max-width:12.5%;justify-self:start;aspect-ratio:1;height:auto;
}
.color-grid.ted-grid button{overflow:hidden;font-size:.58rem}
#inkPopover .color-grid.ted-grid button{font-size:.55rem}
/* Raskin review L4: summaries in animation sections use the full width. */
.animation-section>.note{grid-column:1/-1}
