:root {
    --bg: #07070c;
    --bg-2: #0d0d16;
    --panel: rgba(255, 255, 255, 0.035);
    --panel-solid: #0f0f19;
    --line: rgba(255, 255, 255, 0.08);
    --line-2: rgba(255, 255, 255, 0.14);
    --text: #ececf4;
    --muted: #8d8da8;
    --dim: #5d5d75;
    --accent: #a78bfa;
    --accent-2: #f472b6;
    --accent-3: #fb923c;
    --grad: linear-gradient(120deg, #8b5cf6, #ec4899 55%, #fb923c);
    --radius: 14px;
    --font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --display: 'Space Grotesk', 'Inter', sans-serif;
    --mono: 'JetBrains Mono', ui-monospace, Menlo, monospace;
    color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body {
    background: var(--bg);
    color: var(--text);
    font: 14px/1.45 var(--font);
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    overflow-x: hidden;
}
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- ambient background ---------- */
.aurora { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.aurora i {
    position: absolute; width: 60vmax; height: 60vmax; border-radius: 50%;
    filter: blur(90px); opacity: .22; mix-blend-mode: screen;
    animation: ui-drift 28s ease-in-out infinite alternate;
}
.aurora i:nth-child(1) { background: #7c3aed; top: -25vmax; left: -15vmax; }
.aurora i:nth-child(2) { background: #db2777; top: -10vmax; right: -25vmax; animation-delay: -9s; animation-duration: 34s; }
.aurora i:nth-child(3) { background: #ea580c; bottom: -35vmax; left: 25vw; opacity: .12; animation-delay: -17s; }
@keyframes ui-drift {
    to { transform: translate(8vmax, 6vmax) scale(1.15); }
}

/* ---------- top bar ---------- */
.topbar {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; gap: 20px;
    padding: 12px 20px;
    background: rgba(7, 7, 12, 0.72);
    backdrop-filter: blur(16px) saturate(140%);
    -webkit-backdrop-filter: blur(16px) saturate(140%);
    border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; flex-shrink: 0; }
.brand-mark {
    width: 30px; height: 18px; border-radius: 999px; background: var(--grad);
    box-shadow: 0 0 18px rgba(236, 72, 153, .55), inset 0 1px 0 rgba(255,255,255,.5);
}
.brand-name { font: 700 17px/1 var(--display); letter-spacing: -.01em; }
.beta-badge {
    font: 700 10px/1 var(--mono); letter-spacing: .12em;
    padding: 4px 7px; border-radius: 6px;
    color: #fff; background: var(--grad);
    box-shadow: 0 0 14px rgba(236, 72, 153, .5);
    animation: ui-glow 2.4s ease-in-out infinite;
}
@keyframes ui-glow { 50% { box-shadow: 0 0 22px rgba(251, 146, 60, .7); } }
.tagline { margin: 0; color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tagline em {
    font-style: normal; font-weight: 700;
    background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.top-actions { margin-left: auto; display: flex; gap: 8px; flex-shrink: 0; }

/* ---------- UI buttons ---------- */
.ui-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    height: 34px; padding: 0 14px; border-radius: 10px;
    background: rgba(255,255,255,.06); border: 1px solid var(--line-2);
    font-weight: 600; font-size: 13px; text-decoration: none; cursor: pointer;
    transition: background .2s, border-color .2s, transform .15s;
    white-space: nowrap;
}
.ui-btn:hover { background: rgba(255,255,255,.11); border-color: rgba(255,255,255,.24); }
.ui-btn:active { transform: translateY(1px) scale(.98); }
.ui-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ui-btn.ghost { background: transparent; }
.ui-btn.coffee { background: #ffdd00; border-color: transparent; color: #1a1400; box-shadow: 0 6px 18px -8px rgba(255, 221, 0, .7); }
.ui-btn.coffee:hover { background: #ffe94d; border-color: transparent; }
.coffee-link { color: #ffdd00; text-decoration: none; }
.coffee-link:hover { text-decoration: underline; }
.ui-btn.primary {
    background: var(--grad); border-color: transparent; color: #fff;
    box-shadow: 0 6px 20px -6px rgba(236, 72, 153, .7), inset 0 1px 0 rgba(255,255,255,.35);
}
.ui-btn.primary:hover { filter: brightness(1.1); }
.ui-btn.small { height: 30px; padding: 0 11px; font-size: 12px; }
.ui-btn.icon-only { width: 34px; padding: 0; font-size: 16px; }
.ui-btn:disabled { opacity: .35; pointer-events: none; }
.ui-btn:hover .dice { display: inline-block; animation: ui-roll .5s ease; }
@keyframes ui-roll { to { transform: rotate(360deg); } }

/* ---------- layout ---------- */
.app {
    display: grid;
    grid-template-columns: 380px minmax(0, 1fr);
    gap: 20px;
    padding: 20px;
    max-width: 1680px;
    margin: 0 auto;
}
.panel {
    position: sticky; top: 79px;
    height: calc(100vh - 99px);
    overflow-y: auto;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: rgba(13, 13, 22, 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,.15) transparent;
}
.workspace { display: flex; flex-direction: column; gap: 20px; min-width: 0; }

/* ---------- panel sections ---------- */
.sec { border-bottom: 1px solid var(--line); }
.sec:last-child { border-bottom: 0; }
.sec > summary {
    list-style: none; cursor: pointer;
    display: flex; align-items: center; gap: 12px;
    padding: 15px 18px;
    font: 600 14px/1 var(--display);
    user-select: none;
    transition: background .2s;
}
.sec > summary::-webkit-details-marker { display: none; }
.sec > summary:hover { background: rgba(255,255,255,.03); }
.sec > summary::after {
    content: ''; margin-left: auto; width: 8px; height: 8px;
    border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
    transform: rotate(-45deg); transition: transform .25s;
}
.sec[open] > summary::after { transform: rotate(45deg); }
.sec-icon {
    width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center;
    background: rgba(255,255,255,.05); border: 1px solid var(--line); font-size: 14px;
}
.sec[open] .sec-icon { background: var(--grad); border-color: transparent; box-shadow: 0 0 14px rgba(236,72,153,.4); }
.sec-body { padding: 4px 18px 20px; display: flex; flex-direction: column; gap: 14px; }

/* ---------- fields ---------- */
.field { display: flex; flex-direction: column; gap: 7px; }
.field-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.field label, .field .lbl { font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: .01em; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }

.txt, .sel, .num {
    background: rgba(0,0,0,.35); border: 1px solid var(--line-2); border-radius: 9px;
    padding: 8px 10px; width: 100%; outline: none;
    transition: border-color .2s, box-shadow .2s;
}
.txt:focus, .sel:focus, .num:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(167,139,250,.2); }
.sel { appearance: none; -webkit-appearance: none; cursor: pointer;
    background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
    background-position: calc(100% - 15px) 52%, calc(100% - 10px) 52%;
    background-size: 5px 5px; background-repeat: no-repeat; padding-right: 28px;
}
.sel option, .sel optgroup { background: var(--panel-solid); }
.num {
    width: 62px; padding: 3px 6px; text-align: right; font: 500 12px var(--mono);
    border-radius: 7px; -moz-appearance: textfield;
}
.num::-webkit-inner-spin-button { opacity: .4; }
.unit { color: var(--dim); font: 500 11px var(--mono); margin-left: -4px; }
.num-wrap { display: flex; align-items: center; gap: 6px; }

/* range */
.rng {
    -webkit-appearance: none; appearance: none; width: 100%; height: 18px; background: transparent; cursor: pointer; margin: 0;
    --p: 50%;
}
.rng::-webkit-slider-runnable-track {
    height: 4px; border-radius: 4px;
    background: linear-gradient(90deg, var(--accent) 0, var(--accent-2) var(--p), rgba(255,255,255,.1) var(--p));
}
.rng::-moz-range-track { height: 4px; border-radius: 4px; background: rgba(255,255,255,.1); }
.rng::-moz-range-progress { height: 4px; border-radius: 4px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.rng::-webkit-slider-thumb {
    -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; margin-top: -6px;
    background: #fff; border: 0; box-shadow: 0 0 0 4px rgba(167,139,250,.25), 0 2px 6px rgba(0,0,0,.5);
    transition: box-shadow .15s, transform .15s;
}
.rng::-moz-range-thumb {
    width: 16px; height: 16px; border-radius: 50%; background: #fff; border: 0;
    box-shadow: 0 0 0 4px rgba(167,139,250,.25), 0 2px 6px rgba(0,0,0,.5);
}
.rng:hover::-webkit-slider-thumb, .rng:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 6px rgba(167,139,250,.35), 0 2px 6px rgba(0,0,0,.5); transform: scale(1.08); }
.rng:focus { outline: none; }

/* segmented */
.seg {
    display: flex; padding: 3px; gap: 3px; border-radius: 10px;
    background: rgba(0,0,0,.35); border: 1px solid var(--line);
    flex-wrap: wrap;
}
.seg button {
    flex: 1 1 0; min-width: 0; padding: 6px 8px; border: 0; border-radius: 7px; background: transparent;
    font-size: 12px; font-weight: 600; color: var(--muted); cursor: pointer; transition: background .2s, color .2s;
    white-space: nowrap;
}
.seg button:hover { color: var(--text); }
.seg button.on { background: rgba(255,255,255,.1); color: #fff; box-shadow: inset 0 1px 0 rgba(255,255,255,.08), 0 1px 3px rgba(0,0,0,.4); }
.seg.chips button { flex: 0 0 auto; min-width: 36px; font-size: 14px; }

/* toggle */
.tgl { display: flex; align-items: center; justify-content: space-between; gap: 10px; cursor: pointer; }
.tgl span { font-size: 13px; font-weight: 600; color: var(--text); }
.tgl input { position: absolute; opacity: 0; pointer-events: none; }
.tgl i {
    position: relative; width: 38px; height: 22px; border-radius: 999px; flex-shrink: 0;
    background: rgba(255,255,255,.1); border: 1px solid var(--line-2); transition: background .25s;
}
.tgl i::after {
    content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
    background: #fff; transition: transform .25s cubic-bezier(.3,1.5,.5,1); box-shadow: 0 1px 3px rgba(0,0,0,.4);
}
.tgl input:checked + i { background: var(--grad); border-color: transparent; }
.tgl input:checked + i::after { transform: translateX(16px); }
.tgl input:focus-visible + i { outline: 2px solid var(--accent); outline-offset: 2px; }

/* color */
.clr { display: flex; align-items: center; gap: 8px; }
.swatch {
    position: relative; width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0; overflow: hidden;
    border: 1px solid var(--line-2);
    background: repeating-conic-gradient(#555 0 25%, #888 0 50%) 0 0 / 10px 10px;
}
.swatch b { position: absolute; inset: 0; }
.swatch input { position: absolute; inset: -6px; width: calc(100% + 12px); height: calc(100% + 12px); opacity: 0; cursor: pointer; }
.clr .txt { font: 500 12px var(--mono); padding: 8px; min-width: 0; }
.alpha { width: 74px; flex-shrink: 0; }
.alpha .rng::-webkit-slider-runnable-track { background: linear-gradient(90deg, transparent, var(--c, #fff)), repeating-conic-gradient(#555 0 25%, #888 0 50%) 0 0 / 8px 8px; }
.alpha .rng::-moz-range-track { background: linear-gradient(90deg, transparent, var(--c, #fff)); }

/* gradient editor */
.grad-bar {
    position: relative; height: 34px; border-radius: 9px; cursor: copy;
    border: 1px solid var(--line-2);
    background: repeating-conic-gradient(#555 0 25%, #888 0 50%) 0 0 / 10px 10px;
    margin: 4px 7px 10px;
}
.grad-bar .fill { position: absolute; inset: 0; border-radius: 8px; }
.stop-handle {
    position: absolute; top: 50%; width: 18px; height: 40px; margin-left: -9px; transform: translateY(-50%);
    border-radius: 7px; border: 3px solid #fff; cursor: grab; touch-action: none;
    box-shadow: 0 2px 8px rgba(0,0,0,.6), inset 0 0 0 1px rgba(0,0,0,.25);
    transition: transform .15s;
}
.stop-handle.is-sel { transform: translateY(-50%) scale(1.15); box-shadow: 0 0 0 3px var(--accent), 0 2px 10px rgba(0,0,0,.6); }
.stop-handle:active { cursor: grabbing; }
.stop-list { display: flex; flex-direction: column; gap: 8px; }
.stop-row { display: flex; align-items: center; gap: 8px; padding: 6px; border-radius: 10px; border: 1px solid transparent; }
.stop-row.is-sel { border-color: var(--line-2); background: rgba(255,255,255,.03); }
.stop-row .clr { flex: 1; min-width: 0; }
.stop-row .num { width: 52px; }
.x-btn {
    width: 26px; height: 26px; flex-shrink: 0; border-radius: 7px; border: 1px solid var(--line); background: transparent;
    color: var(--muted); cursor: pointer; font-size: 15px; line-height: 1;
}
.x-btn:hover { color: #fca5a5; border-color: rgba(252,165,165,.4); background: rgba(252,165,165,.08); }
.x-btn:disabled { opacity: .25; pointer-events: none; }
.add-btn {
    border: 1px dashed var(--line-2); background: transparent; border-radius: 10px; padding: 9px; cursor: pointer;
    color: var(--muted); font-weight: 600; font-size: 12px; transition: all .2s;
}
.add-btn:hover { color: var(--text); border-color: var(--accent); background: rgba(167,139,250,.06); }

/* angle dial */
.dial-row { display: flex; align-items: center; gap: 14px; }
.dial {
    position: relative; width: 52px; height: 52px; border-radius: 50%; flex-shrink: 0; cursor: grab; touch-action: none;
    background: radial-gradient(circle, rgba(0,0,0,.5) 55%, transparent 56%), conic-gradient(from 0deg, var(--accent), var(--accent-2), var(--accent-3), var(--accent));
    box-shadow: 0 0 0 1px var(--line-2), 0 4px 14px rgba(0,0,0,.4);
}
.dial::after {
    content: ''; position: absolute; left: 50%; top: 6px; width: 3px; height: 20px; margin-left: -1.5px; border-radius: 2px;
    background: #fff; transform-origin: 50% 20px; transform: rotate(var(--a, 0deg));
    box-shadow: 0 0 8px rgba(255,255,255,.8);
}
.dial-presets { display: flex; flex-wrap: wrap; gap: 4px; }
.dial-presets button {
    width: 28px; height: 24px; border-radius: 6px; border: 1px solid var(--line); background: rgba(0,0,0,.3);
    color: var(--muted); cursor: pointer; font-size: 12px;
}
.dial-presets button:hover { color: #fff; border-color: var(--line-2); }

/* shadow cards */
.card {
    border: 1px solid var(--line); border-radius: 12px; padding: 12px; background: rgba(0,0,0,.2);
    display: flex; flex-direction: column; gap: 12px;
}
.card-head { display: flex; align-items: center; gap: 8px; }
.card-head .ttl { font: 600 12px var(--mono); color: var(--muted); margin-right: auto; }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
    padding: 5px 10px; border-radius: 999px; border: 1px solid var(--line-2); background: rgba(255,255,255,.03);
    font-size: 11px; font-weight: 600; color: var(--muted); cursor: pointer; transition: all .2s;
}
.chip:hover { color: #fff; border-color: var(--accent); background: rgba(167,139,250,.1); }
.hint { font-size: 11.5px; color: var(--dim); margin: -4px 0 0; }
.sub-head { font: 600 11px var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--dim); margin-top: 6px; }

/* ---------- stage ---------- */
.stage {
    position: relative; min-height: 470px; border-radius: 22px; overflow: hidden;
    border: 1px solid var(--line);
    display: flex; flex-direction: column;
    --mx: 50%; --my: 40%;
    transition: background-color .4s;
}
.stage::before {
    content: ''; position: absolute; inset: 0; pointer-events: none; z-index: 0;
    background: radial-gradient(600px circle at var(--mx) var(--my), rgba(255,255,255,.07), transparent 45%);
}
.stage > * { position: relative; z-index: 1; }
.stage[data-bg="void"] {
    background-color: #0a0a12;
    background-image:
        radial-gradient(ellipse at 50% 45%, rgba(124,58,237,.18), transparent 60%),
        linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px);
    background-size: 100% 100%, 32px 32px, 32px 32px;
    background-position: center;
}
.stage[data-bg="aurora"] {
    background: linear-gradient(125deg, #4c1d95, #be185d, #ea580c, #0e7490, #4c1d95);
    background-size: 400% 400%;
    animation: ui-pan 16s ease infinite;
}
@keyframes ui-pan { 50% { background-position: 100% 50%; } }
.stage[data-bg="paper"] {
    background-color: #f6f7fb;
    background-image: radial-gradient(rgba(15,23,42,.12) 1px, transparent 1px);
    background-size: 22px 22px;
}
.stage[data-bg="clay"] { background: #e0e5ec; }
.stage[data-bg="checker"] { background: repeating-conic-gradient(#2a2a35 0 25%, #1c1c25 0 50%) 0 0 / 24px 24px; }
.stage[data-bg="paper"]::before, .stage[data-bg="clay"]::before { background: radial-gradient(600px circle at var(--mx) var(--my), rgba(255,255,255,.6), transparent 45%); }
.stage[data-bg="paper"] .state-strip figcaption, .stage[data-bg="clay"] .state-strip figcaption,
.stage[data-bg="paper"] .stage-toolbar, .stage[data-bg="clay"] .stage-toolbar { color: #475569; }
.stage[data-bg="paper"] .contrast, .stage[data-bg="clay"] .contrast { background: rgba(255,255,255,.7); color: #334155; border-color: rgba(15,23,42,.1); }
.stage[data-bg="paper"] .state-strip, .stage[data-bg="clay"] .state-strip { border-color: rgba(15,23,42,.08); background: rgba(255,255,255,.35); }

.stage-toolbar {
    display: flex; align-items: center; gap: 16px; padding: 14px 16px; color: var(--muted); font-size: 12px;
}
.live-dot { display: inline-flex; align-items: center; gap: 7px; font: 600 11px var(--mono); letter-spacing: .1em; text-transform: uppercase; }
.live-dot::before {
    content: ''; width: 8px; height: 8px; border-radius: 50%; background: #22c55e;
    box-shadow: 0 0 0 0 rgba(34,197,94,.6); animation: ui-ping 2s infinite;
}
@keyframes ui-ping { 70% { box-shadow: 0 0 0 8px rgba(34,197,94,0); } 100% { box-shadow: 0 0 0 0 rgba(34,197,94,0); } }
.zoom { display: flex; align-items: center; gap: 8px; }
.zoom .rng { width: 110px; }
.zoom output { font: 500 11px var(--mono); width: 38px; }
.stage-bgs { margin-left: auto; display: flex; gap: 6px; }
.stage-bgs button {
    width: 22px; height: 22px; border-radius: 50%; cursor: pointer; border: 2px solid rgba(255,255,255,.25); padding: 0;
    transition: transform .2s, border-color .2s;
}
.stage-bgs button:hover { transform: scale(1.15); }
.stage-bgs button.on { border-color: #fff; box-shadow: 0 0 0 2px var(--accent); }
.stage-bgs [data-bg="void"] { background: #0a0a12; }
.stage-bgs [data-bg="aurora"] { background: linear-gradient(135deg, #7c3aed, #db2777, #ea580c); }
.stage-bgs [data-bg="paper"] { background: #f6f7fb; }
.stage-bgs [data-bg="clay"] { background: #e0e5ec; }
.stage-bgs [data-bg="checker"] { background: repeating-conic-gradient(#555 0 25%, #999 0 50%) 0 0 / 8px 8px; }

.stage-center { flex: 1; display: grid; place-items: center; padding: 40px 20px; min-height: 260px; }
.zoom-wrap { transition: transform .25s cubic-bezier(.2,.8,.2,1); display: flex; justify-content: center; width: 100%; }

.state-strip {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px;
    border-top: 1px solid var(--line); background: rgba(0,0,0,.18);
}
.state-strip figure { margin: 0; padding: 18px 8px 12px; display: flex; flex-direction: column; align-items: center; gap: 10px; min-width: 0; }
.pv-cell { height: 64px; display: grid; place-items: center; max-width: 100%; }
.pv-cell > * { transform: scale(.72); pointer-events: none; }
.state-strip figcaption { font: 600 10px var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--dim); }

.contrast {
    position: absolute; right: 14px; bottom: 112px; z-index: 2;
    font: 500 11px var(--mono); color: var(--muted);
    padding: 6px 10px; border-radius: 8px; border: 1px solid var(--line); background: rgba(0,0,0,.45);
    backdrop-filter: blur(6px);
}
.contrast b { color: #fff; }
.stage[data-bg="paper"] .contrast b, .stage[data-bg="clay"] .contrast b { color: #0f172a; }
.contrast .pass { color: #4ade80; }
.contrast .fail { color: #f87171; }

/* ---------- code ---------- */
.code-card { border: 1px solid var(--line); border-radius: 18px; background: rgba(10,10,18,.8); overflow: hidden; }
.code-head { display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.tabs { display: flex; gap: 4px; }
.tab {
    border: 0; background: transparent; padding: 7px 12px; border-radius: 8px; cursor: pointer;
    font: 600 12px var(--mono); color: var(--muted);
}
.tab.active { background: rgba(255,255,255,.08); color: #fff; }
.code-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.code {
    margin: 0; padding: 18px 20px; max-height: 420px; overflow: auto;
    font: 12.5px/1.7 var(--mono); color: #c9c9db; tab-size: 2;
    scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.15) transparent;
}
.code .c-com { color: #6b6b85; font-style: italic; }
.code .c-sel { color: #f472b6; }
.code .c-at { color: #c084fc; }
.code .c-prop { color: #7dd3fc; }
.code .c-num { color: #fdba74; }
.code .c-col { color: #86efac; }
.code .c-str { color: #fde68a; }
.code .c-tag { color: #f472b6; }
.code .c-attr { color: #7dd3fc; }
.code .c-pun { color: #6b6b85; }
.code .c-sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin: 0 4px -1px 0; box-shadow: inset 0 0 0 1px rgba(255,255,255,.25); }

/* ---------- presets ---------- */
.section-head { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
.section-head h2 { margin: 0; font: 700 22px/1.1 var(--display); letter-spacing: -.02em; }
.section-head p { margin: 0; color: var(--muted); font-size: 13px; }
.preset-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-bottom: 14px; }
.preset-cats { display: flex; flex-wrap: wrap; gap: 6px; flex: 1 1 520px; }
.preset-cat {
    display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: 999px; cursor: pointer;
    border: 1px solid var(--line); background: var(--panel); color: var(--muted); font-size: 12px; font-weight: 600;
    transition: color .15s, border-color .15s, background .15s;
}
.preset-cat span { color: var(--dim); font-weight: 500; font-variant-numeric: tabular-nums; }
.preset-cat:hover { color: var(--text); border-color: var(--line-2); }
.preset-cat[aria-pressed="true"] { color: #fff; border-color: var(--accent); background: rgba(167,139,250,.14); }
.preset-cat[aria-pressed="true"] span { color: var(--accent); }
.preset-cat:focus-visible, .preset-more:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.preset-search {
    flex: 0 1 240px; min-width: 0; height: 34px; padding: 0 12px; border-radius: 10px;
    border: 1px solid var(--line); background: var(--panel-solid); color: var(--text);
}
.preset-search:focus { outline: none; border-color: var(--accent); }
.preset-empty { grid-column: 1 / -1; margin: 24px 0; color: var(--muted); text-align: center; }
.preset-more {
    display: block; margin: 16px auto 0; height: 38px; padding: 0 20px; border-radius: 999px; cursor: pointer;
    border: 1px solid var(--line-2); background: var(--panel); color: var(--text); font-weight: 600;
}
.preset-more:hover { border-color: var(--accent); background: rgba(167,139,250,.1); }
.preset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.preset {
    position: relative; display: flex; flex-direction: column; border-radius: 16px; overflow: hidden; cursor: pointer;
    border: 1px solid var(--line); background: #0b0b14; text-align: left; padding: 0;
    transition: transform .25s cubic-bezier(.2,.8,.2,1), border-color .25s, box-shadow .25s;
}
.preset:hover { transform: translateY(-3px); border-color: var(--line-2); box-shadow: 0 16px 40px -16px rgba(0,0,0,.8); }
.preset:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.preset-view { height: 120px; display: grid; place-items: center; padding: 12px; overflow: hidden; }
.preset-view > * { transform: scale(.82); pointer-events: none; }
.preset:hover .preset-view > * { pointer-events: none; }
.preset-view[data-bg="aurora"] { background: linear-gradient(125deg, #4c1d95, #be185d, #ea580c); }
.preset-view[data-bg="paper"] { background: #f6f7fb; }
.preset-view[data-bg="clay"] { background: #e0e5ec; }
.preset-view[data-bg="void"] { background: radial-gradient(ellipse at 50% 60%, rgba(124,58,237,.15), transparent 70%), #0a0a12; }
.preset-meta { padding: 10px 14px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.preset-meta b { font: 600 13px var(--display); }
.preset-meta span { font-size: 11px; color: var(--dim); }

/* ---------- footer ---------- */
.footer {
    display: flex; flex-wrap: wrap; gap: 10px 28px; justify-content: space-between;
    padding: 20px 24px 28px; max-width: 1680px; margin: 0 auto;
    color: var(--dim); font-size: 12px;
}
.footer strong { color: var(--text); font-family: var(--mono); }
kbd {
    font: 500 10.5px var(--mono); padding: 2px 5px; border-radius: 5px; border: 1px solid var(--line-2);
    background: rgba(255,255,255,.04); color: var(--muted);
}

/* ---------- toast & confetti ---------- */
.toast {
    position: fixed; left: 50%; bottom: 28px; z-index: 60; transform: translate(-50%, 20px); opacity: 0;
    padding: 11px 18px; border-radius: 12px; font-weight: 600; font-size: 13px;
    background: rgba(20,20,32,.92); border: 1px solid var(--line-2); backdrop-filter: blur(10px);
    box-shadow: 0 16px 40px -10px rgba(0,0,0,.7);
    transition: opacity .25s, transform .35s cubic-bezier(.2,1.4,.4,1);
    pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.confetti { position: fixed; inset: 0; z-index: 50; pointer-events: none; width: 100vw; height: 100vh; }

/* ---------- share dialog ---------- */
.share-dlg {
    width: min(560px, calc(100vw - 32px)); padding: 20px; border-radius: 20px;
    border: 1px solid var(--line-2); background: #0f0f19; color: var(--text);
    box-shadow: 0 30px 80px -20px rgba(0,0,0,.8);
}
.share-dlg[open] { display: flex; flex-direction: column; gap: 14px; animation: ui-pop .3s cubic-bezier(.2,1.2,.4,1); }
.share-dlg::backdrop { background: rgba(5,5,10,.6); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
@keyframes ui-pop { from { opacity: 0; transform: translateY(10px) scale(.97); } }
.share-head { display: flex; align-items: center; justify-content: space-between; }
.share-head h2 { margin: 0; font: 700 19px/1.1 var(--display); letter-spacing: -.01em; }
.share-head form { margin: 0; }
.share-thumb {
    position: relative; aspect-ratio: 1200 / 630; border-radius: 12px; overflow: hidden;
    border: 1px solid var(--line-2); display: grid; place-items: center;
    background: repeating-linear-gradient(110deg, rgba(255,255,255,.03) 0 12px, transparent 12px 24px), #0a0a12;
}
.share-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.share-status { position: relative; z-index: 1; padding: 8px 12px; border-radius: 9px; font-size: 12.5px; color: var(--muted); text-align: center; max-width: 85%; }
.share-status:empty { display: none; }
.share-thumb img:not([hidden]) + .share-status { background: rgba(0,0,0,.65); color: #fff; align-self: end; margin-bottom: 10px; }
.share-dlg .hint { margin: -4px 0 0; }
.share-link { display: flex; gap: 8px; }
.share-link .txt { font: 500 12.5px var(--mono); min-width: 0; }
.share-social { display: flex; flex-wrap: wrap; gap: 8px; }
.share-social a:not([href]) { opacity: .35; pointer-events: none; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
    .app { grid-template-columns: 1fr; }
    .panel { position: static; height: auto; order: 2; }
    .workspace { order: 1; display: contents; }
    .stage { order: 1; }
    .code-card { order: 3; }
    .presets { order: 4; }
    .tagline { display: none; }
}
@media (max-width: 640px) {
    .app { padding: 12px 16px; gap: 16px; }
    .topbar { padding: 10px 16px; gap: 10px; }
    .brand-name { display: none; }
    .top-actions .ghost { display: none; }
    .top-actions #random { padding: 0 10px; }
    .top-actions .coffee { padding: 0 10px; }
    .top-actions .coffee-label { display: none; }
    .stage { min-height: 400px; }
    .zoom { display: none; }
    .state-strip { grid-template-columns: repeat(2, 1fr); }
    .contrast { bottom: auto; top: 50px; }
    .kbd-hints { display: none; }
    .preset-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
    .preset-search { flex: 1 1 100%; }
}
@media (prefers-reduced-motion: reduce) {
    .aurora i, .beta-badge, .stage[data-bg="aurora"], .live-dot::before { animation: none; }
}

/* ---------- about / FAQ (crawlable page content below the editor) ---------- */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
h1.tagline { font-weight: 400; }
.section-head p a { color: var(--accent); text-underline-offset: 3px; }
.about { max-width: 960px; margin: 24px auto 0; padding: 36px 24px 8px; border-top: 1px solid var(--line); color: #cfcfe0; font-size: 15px; line-height: 1.7; }
.about h2 { margin: 36px 0 14px; font: 700 22px/1.2 var(--display); letter-spacing: -.02em; color: var(--text); }
.about-intro h2 { margin-top: 0; font-size: 26px; }
.about-intro p { margin: 0; max-width: 760px; }
.about-steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 24px; }
.about-steps > div { padding: 16px 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.about-steps b { font: 600 15px var(--display); color: var(--text); }
.about-steps p { margin: 6px 0 0; font-size: 13.5px; line-height: 1.55; color: var(--muted); }
.about-styles { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
.about-styles a {
    display: inline-block; padding: 7px 13px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--panel);
    font-size: 13px; font-weight: 600; text-decoration: none;
}
.about-styles a:hover { border-color: var(--accent); background: rgba(167,139,250,.12); }
.about-faq details { border-bottom: 1px solid var(--line); padding: 12px 0; }
.about-faq summary { cursor: pointer; font-weight: 600; color: var(--text); }
.about-faq summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.about-faq p { margin: 8px 0 2px; color: var(--muted); }
.about-faq a { color: var(--accent); }
@media (max-width: 640px) {
    .about { padding: 28px 16px 4px; }
    .about-steps { grid-template-columns: 1fr; }
}
