/* The library lives outside instrument canvases. Each world is presentation only. */
.theme-tools{position:relative}
.theme-picker[hidden]{display:none!important}
.theme-library-toggle{display:flex;align-items:center;gap:7px;min-width:148px;min-height:39px;padding:6px 10px!important;text-align:left}
.theme-library-toggle small{font:9px/1.1 monospace;letter-spacing:1px;text-transform:uppercase;opacity:.75}
.theme-library-toggle span{font:13px/1.1 Georgia,serif;white-space:nowrap}
.theme-library-toggle b{margin-left:auto;font-size:11px}
.theme-library[hidden]{display:none!important}
:root[data-theme][data-appearance] body .theme-library{position:absolute;top:calc(100% + 9px);right:0;z-index:60;width:min(430px,calc(100vw - 24px));max-height:min(75dvh,640px);overflow:auto;padding:0;background:var(--ui-solid);color:var(--ui-ink);border:1px solid var(--ui-etch);box-shadow:0 18px 50px var(--ui-shadow)}
.theme-library-heading{position:sticky;top:0;z-index:1;display:flex;align-items:center;justify-content:space-between;gap:8px;padding:14px;background:var(--ui-solid);border-bottom:1px solid var(--ui-etch)}
.theme-library-heading strong{font:11px/1.2 monospace;letter-spacing:2px}.theme-library-heading small{display:block;margin-top:5px;font:10px monospace;color:var(--ui-muted)}
:root[data-theme][data-appearance] body .theme-library-close{min-width:38px;min-height:38px;padding:0;font-size:25px}
.theme-library-groups{padding:5px 10px 12px}
.theme-library-group{border-bottom:1px solid var(--ui-etch)}
.theme-library-group summary{display:flex;justify-content:space-between;gap:8px;align-items:center;padding:12px 3px;cursor:pointer;list-style:none}
.theme-library-group summary::-webkit-details-marker{display:none}
.theme-library-group summary:before{content:'+';width:16px;font:15px monospace;color:var(--ui-mark)}
.theme-library-group[open] summary:before{content:'−'}
.theme-library-group summary strong{margin-right:auto;font:12px Georgia,serif}.theme-library-group summary span{font:9px monospace;color:var(--ui-muted)}
.theme-library-group p{padding:0 8px 12px;margin:0;color:var(--ui-muted);font:11px/1.5 monospace}
.theme-library-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:6px;padding:0 0 11px}
:root[data-theme][data-appearance] body .theme-library-grid button{position:relative;display:grid;grid-template-columns:15px 1fr;grid-template-rows:auto auto;column-gap:8px;min-height:72px;padding:9px;text-align:left;border:1px solid var(--ui-etch);background:var(--ui-panel);color:var(--ui-ink);box-shadow:none;border-radius:3px}
.theme-library-grid button .theme-swatch{grid-row:1/3;width:10px;height:100%;min-height:42px;background:var(--theme-swatch);border:1px solid var(--ui-etch)}
.theme-library-grid button strong{font:13px/1.1 Georgia,serif}.theme-library-grid button small{font:9px/1.3 monospace;color:var(--ui-muted)}
:root[data-theme][data-appearance] body .theme-library-grid button[aria-current=true]{border:2px solid var(--ui-mark);background:var(--ui-paper)}
.theme-world-label{display:none}
:root[data-theme-generation=new] body{transition:background-color .16s,color .16s}
:root[data-theme-generation=new] body :is(header,aside,.monitor,.command-rail,.scope-dock,.field-dock){transition:background-color .16s,border-color .16s,box-shadow .16s}
:root[data-theme-generation=new] body .theme-world-label{display:block;margin:4px 0 8px;padding:6px 12px;width:max-content;max-width:100%;font:9px monospace;letter-spacing:2px;text-transform:uppercase;color:var(--ui-mark);border:1px solid var(--ui-etch);background:var(--ui-panel)}
:root[data-theme-generation=new] body .workspace-tabs{border:1px solid var(--ui-etch);background:var(--ui-paper)}
:root[data-theme-generation=new] body .workspace-tabs button{color:var(--ui-muted);min-height:36px}
:root[data-theme-generation=new] body .workspace-tabs button[aria-pressed=true]{color:var(--ui-ink);border-color:var(--ui-mark);background:var(--ui-panel)}
:root[data-theme-generation=new] body :is(.scope-dock,.field-dock){color:var(--ui-ink);border:1px solid var(--ui-etch);background:var(--ui-panel);box-shadow:inset 0 1px var(--ui-highlight),0 6px 18px var(--ui-shadow)}
:root[data-theme-generation=new] body :is(.scope-heading h2,.field-heading h2){color:var(--ui-ink);font-family:var(--world-display,Georgia,serif)}
:root[data-theme-generation=new] body :is(.scope-heading p,.field-heading p,.field-note,.scope-fields label,.field-controls label){color:var(--ui-muted)}
:root[data-theme-generation=new] body :is(.scope-kicker,.field-heading span,#scopeStatus,#fieldStatus){color:var(--ui-mark)}
:root[data-theme-generation=new] body :is(.scope-fields select,.scope-fields input[type=search],.scope-fields input[type=text],.field-controls select,.field-object-finder input[type=search]){background:var(--ui-paper);color:var(--ui-ink);border-color:var(--ui-etch)}
:root[data-theme-generation=new] body :is(.scope-fields output,.field-controls output){color:var(--ui-mark)}
:root[data-theme-generation=new] body :is(.scope-options,.field-palette-panel,.instrument-scenes,.object-matches){background:var(--ui-paper);border-color:var(--ui-etch)}
:root[data-theme-generation=new] body .instrument-scenes button{background:var(--ui-panel);color:var(--ui-ink);border-color:var(--ui-etch)}
:root[data-theme-generation=new] body .instrument-scenes button[aria-pressed=true]{border-color:var(--ui-mark);box-shadow:inset 0 0 0 1px var(--ui-mark)}
:root[data-theme-generation=new] body .object-matches button{background:var(--ui-panel);color:var(--ui-ink);border-color:var(--ui-etch)}
:root[data-theme-generation=new] body :is(.scope-knob,.knob){filter:none}

/* HARDWARE / EFFECTS — a new cast-metal stompbox, not the preserved LEADR body. */
:root[data-theme=stompbox][data-appearance=dark]{--ui-paper:#151b1d;--ui-panel:#263034;--ui-solid:#263034;--ui-ink:#f4eddd;--ui-muted:#b7b9ad;--ui-mark:#f2aa60;--ui-flare:#f18a59;--ui-etch:#81908c;--ui-disc:#c6c7ba;--ui-disc-line:#363e3e;--ui-chrome:#485458;--ui-highlight:#ffffff35;--ui-shadow:#0009}
:root[data-theme=stompbox][data-appearance=light]{--ui-paper:#d4d5c8;--ui-panel:#e7e6d7;--ui-solid:#e7e6d7;--ui-ink:#202c30;--ui-muted:#505d5d;--ui-mark:#8a4319;--ui-flare:#9a4a2c;--ui-etch:#6f7d77;--ui-disc:#b7baaf;--ui-disc-line:#273437;--ui-chrome:#b2b9b2;--ui-highlight:#ffffffa9;--ui-shadow:#28343955}
:root[data-theme=stompbox] body{--world-display:'Arial Narrow',Arial,sans-serif;background:repeating-linear-gradient(90deg,#ffffff07 0 1px,transparent 1px 44px),linear-gradient(145deg,var(--ui-chrome),var(--ui-paper));font-family:'Arial Narrow',Arial,sans-serif}
:root[data-theme=stompbox] body:before{border:3px double var(--ui-etch);border-radius:15px;inset:6px}
:root[data-theme=stompbox] body header{background:linear-gradient(180deg,var(--ui-chrome),var(--ui-panel) 48%,var(--ui-paper));border-bottom:4px solid var(--ui-etch);box-shadow:inset 0 2px var(--ui-highlight),0 4px 0 var(--ui-shadow)}
:root[data-theme=stompbox] body .identity{font:bold 23px/1 var(--world-display);letter-spacing:3px}
:root[data-theme=stompbox] body .identity small{font:9px monospace;letter-spacing:1px}
:root[data-theme=stompbox] body :is(aside,.scope-dock,.field-dock,.command-rail){border:3px solid var(--ui-etch);border-radius:14px;background:linear-gradient(155deg,var(--ui-chrome),var(--ui-panel) 28%,var(--ui-paper));box-shadow:inset 0 2px var(--ui-highlight),inset 0 -2px var(--ui-shadow),0 8px 19px var(--ui-shadow)}
:root[data-theme=stompbox] body :is(.rack-heading,.scope-heading,.field-heading){padding:14px;border-bottom:3px double var(--ui-etch);background:var(--ui-paper)}
:root[data-theme=stompbox] body :is(.rack-tabs,.workspace-tabs){padding:5px;border:2px inset var(--ui-etch);border-radius:3px;background:var(--ui-paper)}
:root[data-theme=stompbox] body :is(button,select,.scope-fields select,.field-controls select){border-radius:5px;font-family:'Arial Narrow',Arial,sans-serif;font-weight:700;text-transform:uppercase;letter-spacing:.4px;box-shadow:inset 0 1px var(--ui-highlight),0 2px 0 var(--ui-shadow)}
:root[data-theme=stompbox] body :is(.knob:before,.scope-knob){background:radial-gradient(circle at 32% 24%,#fff9,transparent 32%),repeating-conic-gradient(from 3deg,var(--ui-disc) 0 10deg,var(--ui-etch) 10deg 11deg);border:2px solid var(--ui-disc-line);box-shadow:inset 0 0 0 5px var(--ui-disc),0 4px 7px var(--ui-shadow)}
:root[data-theme=stompbox] body :is(.knob-pointer,.scope-knob:after){stroke:var(--ui-flare);background:var(--ui-flare)}
:root[data-theme=stompbox] body .monitor{border:10px ridge var(--ui-etch);border-radius:11px;box-shadow:0 0 0 3px var(--ui-paper),0 12px 24px var(--ui-shadow)}
:root[data-theme=stompbox] body .monitor:after{border-radius:2px;border-color:var(--ui-mark)}
:root[data-theme=stompbox] body :is(.screen-top span,.screen-bottom span,.theme-world-label){font:bold 10px monospace;text-transform:uppercase;color:var(--ui-mark);background:var(--ui-paper);border:1px solid var(--ui-etch)}
:root[data-theme=stompbox] body .audio-meters i{height:8px;background:repeating-linear-gradient(90deg,transparent 0 5px,var(--ui-paper) 5px 6px),linear-gradient(90deg,var(--ui-mark),var(--ui-flare))}
:root[data-theme=stompbox] body :is(.instrument-scenes,.scope-options,.field-palette-panel){border:2px inset var(--ui-etch);border-radius:4px}

/* FANTASY — a readable celestial score rather than a novelty wallpaper. */
:root[data-theme=light-wizard][data-appearance=light]{--ui-paper:#e9e3d3;--ui-panel:#f5efdf;--ui-solid:#f5efdf;--ui-ink:#352b44;--ui-muted:#625873;--ui-mark:#653f8d;--ui-flare:#9e537b;--ui-etch:#a993bd;--ui-disc:#e3d6be;--ui-disc-line:#775891;--ui-chrome:#d8c9dd;--ui-highlight:#ffffffdf;--ui-shadow:#46305848}
:root[data-theme=light-wizard][data-appearance=dark]{--ui-paper:#171525;--ui-panel:#28243b;--ui-solid:#28243b;--ui-ink:#f4e9d5;--ui-muted:#c2b5cc;--ui-mark:#d1b4ff;--ui-flare:#efaad0;--ui-etch:#806c9a;--ui-disc:#3a334a;--ui-disc-line:#ecd6a5;--ui-chrome:#392d50;--ui-highlight:#ffffff30;--ui-shadow:#07050cab}
:root[data-theme=light-wizard] body{--world-display:Georgia,'Times New Roman',serif;background:radial-gradient(circle at 85% 8%,color-mix(in srgb,var(--ui-mark) 20%,transparent),transparent 30%),repeating-radial-gradient(circle at 8% 80%,transparent 0 60px,color-mix(in srgb,var(--ui-etch) 10%,transparent) 61px 62px),var(--ui-paper)}
:root[data-theme=light-wizard] body:before{border:1px solid var(--ui-etch);border-radius:50% 5% 45% 5% / 6% 3% 6% 3%;inset:8px}
:root[data-theme=light-wizard] body header{background:linear-gradient(90deg,var(--ui-panel),var(--ui-chrome),var(--ui-panel));border-bottom:2px solid var(--ui-etch)}
:root[data-theme=light-wizard] body .identity{font:small-caps 26px Georgia,serif;letter-spacing:4px}
:root[data-theme=light-wizard] body :is(aside,.scope-dock,.field-dock){border:2px double var(--ui-etch);border-radius:22px 5px 22px 5px;background:linear-gradient(125deg,var(--ui-panel),var(--ui-paper));box-shadow:inset 0 0 0 5px var(--ui-panel),inset 0 0 0 6px var(--ui-etch),0 9px 22px var(--ui-shadow)}
:root[data-theme=light-wizard] body :is(.rack-heading,.scope-heading,.field-heading){padding:16px;border-bottom:1px solid var(--ui-etch);background:radial-gradient(circle at 90% 50%,color-mix(in srgb,var(--ui-flare) 19%,transparent),transparent 50%)}
:root[data-theme=light-wizard] body :is(.rack-heading strong,.scope-heading h2,.field-heading h2,.section-title h2){font-family:Georgia,serif;font-variant:small-caps;letter-spacing:1px}
:root[data-theme=light-wizard] body .rack-tabs{border-bottom:1px solid var(--ui-etch);background:var(--ui-panel)}
:root[data-theme=light-wizard] body :is(button,select,.scope-fields select,.field-controls select){border-radius:14px 3px 14px 3px;font-family:Georgia,serif;box-shadow:inset 0 1px var(--ui-highlight)}
:root[data-theme=light-wizard] body :is(.knob:before,.scope-knob){background:radial-gradient(circle at 50% 50%,var(--ui-disc) 0 40%,var(--ui-chrome) 41% 63%,var(--ui-etch) 64% 66%,var(--ui-disc) 67%);border:1px solid var(--ui-mark);box-shadow:0 0 0 3px var(--ui-panel),0 0 0 4px var(--ui-etch)}
:root[data-theme=light-wizard] body :is(.knob-halo,.knob-sigil){stroke:var(--ui-mark);opacity:.85}
:root[data-theme=light-wizard] body .monitor{border:3px double var(--ui-mark);border-radius:32px 5px 32px 5px;box-shadow:0 0 0 6px var(--ui-panel),0 0 0 7px var(--ui-etch),0 9px 24px var(--ui-shadow)}
:root[data-theme=light-wizard] body :is(.screen-top span,.screen-bottom span,.theme-world-label){font:italic 11px Georgia,serif;color:var(--ui-mark);background:var(--ui-panel);border:1px solid var(--ui-etch)}
:root[data-theme=light-wizard] body .instrument-scenes button{border-radius:13px 3px 13px 3px}
:root[data-theme=light-wizard] body .audio-meters i{background:linear-gradient(90deg,var(--ui-mark),var(--ui-flare));height:3px}

/* GAME SYSTEMS — original early 3D menu language, no borrowed branding. */
:root[data-theme=early-console][data-appearance=dark]{--ui-paper:#10192d;--ui-panel:#1c2d4d;--ui-solid:#1c2d4d;--ui-ink:#e5f5ff;--ui-muted:#aac7dd;--ui-mark:#72d7f9;--ui-flare:#f396d7;--ui-etch:#7292b4;--ui-disc:#6c85b0;--ui-disc-line:#d9eaf7;--ui-chrome:#3b5180;--ui-highlight:#d0eeff38;--ui-shadow:#050d20aa}
:root[data-theme=early-console][data-appearance=light]{--ui-paper:#c7d9ee;--ui-panel:#e6f0fa;--ui-solid:#e6f0fa;--ui-ink:#1a2e4d;--ui-muted:#445e7d;--ui-mark:#125c87;--ui-flare:#8f3d7b;--ui-etch:#6b90b6;--ui-disc:#b7cde4;--ui-disc-line:#24557b;--ui-chrome:#acc4e2;--ui-highlight:#ffffffbe;--ui-shadow:#21375d48}
:root[data-theme=early-console] body{--world-display:Trebuchet MS,Arial,sans-serif;background:linear-gradient(145deg,transparent 35%,color-mix(in srgb,var(--ui-flare) 12%,transparent) 36% 37%,transparent 38%),radial-gradient(ellipse at 70% 0%,var(--ui-chrome),transparent 55%),var(--ui-paper);font-family:Trebuchet MS,Arial,sans-serif}
:root[data-theme=early-console] body:before{border:1px solid var(--ui-mark);border-radius:3px;inset:7px}
:root[data-theme=early-console] body header{background:linear-gradient(125deg,var(--ui-paper),var(--ui-chrome) 55%,var(--ui-panel));border-bottom:2px solid var(--ui-mark)}
:root[data-theme=early-console] body .identity{font:bold 23px Trebuchet MS,Arial,sans-serif;letter-spacing:5px}
:root[data-theme=early-console] body :is(aside,.scope-dock,.field-dock,.command-rail){border:1px solid var(--ui-mark);border-radius:4px 18px 4px 18px;background:linear-gradient(155deg,var(--ui-panel),var(--ui-paper));box-shadow:inset 1px 1px var(--ui-highlight),0 10px 28px var(--ui-shadow)}
:root[data-theme=early-console] body :is(.rack-heading,.scope-heading,.field-heading){padding:15px;border-bottom:1px solid var(--ui-mark);background:linear-gradient(90deg,var(--ui-chrome),transparent)}
:root[data-theme=early-console] body :is(.rack-heading strong,.scope-heading h2,.field-heading h2){font-family:Trebuchet MS,Arial,sans-serif;letter-spacing:2px;text-transform:uppercase}
:root[data-theme=early-console] body :is(.rack-tabs,.workspace-tabs){background:var(--ui-paper);border:1px solid var(--ui-etch);border-radius:3px}
:root[data-theme=early-console] body :is(button,select,.scope-fields select,.field-controls select){border:1px solid var(--ui-etch);border-radius:2px 9px 2px 9px;font-family:Trebuchet MS,Arial,sans-serif;box-shadow:inset 0 1px var(--ui-highlight),0 2px 4px var(--ui-shadow)}
:root[data-theme=early-console] body :is(.knob:before,.scope-knob){background:radial-gradient(circle at 30% 20%,var(--ui-highlight),transparent 40%),linear-gradient(145deg,var(--ui-disc),var(--ui-chrome) 48%,var(--ui-paper) 49% 55%,var(--ui-disc));border:1px solid var(--ui-mark);box-shadow:0 3px 7px var(--ui-shadow)}
:root[data-theme=early-console] body :is(.knob-halo,.knob-sigil,.knob-pointer){stroke:var(--ui-mark)}
:root[data-theme=early-console] body .monitor{border:2px solid var(--ui-mark);border-radius:4px 20px 4px 20px;box-shadow:0 0 0 4px var(--ui-panel),0 0 0 5px var(--ui-mark),0 10px 22px var(--ui-shadow)}
:root[data-theme=early-console] body :is(.screen-top span,.screen-bottom span,.theme-world-label){font:bold 10px Trebuchet MS,Arial,sans-serif;letter-spacing:1px;color:var(--ui-mark);background:var(--ui-panel);border:1px solid var(--ui-etch)}
:root[data-theme=early-console] body .instrument-scenes button{border-radius:2px 9px 2px 9px}
:root[data-theme=early-console] body .audio-meters i{height:7px;background:repeating-linear-gradient(90deg,transparent 0 7px,var(--ui-paper) 7px 8px),linear-gradient(90deg,var(--ui-mark),var(--ui-flare))}

@media(max-width:760px){.theme-library{left:0;right:auto!important}.theme-library-toggle{min-width:130px}.theme-world-label{margin-top:7px!important}:root[data-theme-generation=new] body :is(.scope-dock,.field-dock){padding:13px}:root[data-theme-generation=new] body :is(.scope-heading,.field-heading){padding:8px}:root[data-theme-generation=new] body .rack-tabs{grid-template-columns:repeat(3,minmax(0,1fr))}:root[data-theme-generation=new] body .rack-tabs button{min-width:0;padding:8px 2px;font-size:10px;overflow-wrap:anywhere}}
@media(max-width:410px){.theme-library-grid{grid-template-columns:1fr}.theme-library{width:calc(100vw - 48px)!important}}
@media(prefers-reduced-motion:reduce){:root[data-theme-generation=new] body,:root[data-theme-generation=new] body :is(header,aside,.monitor,.command-rail,.scope-dock,.field-dock){transition:none}}
