/* ---------- tokens ---------- */
:root {
    color-scheme: light;
    --bg: #fbfcfe;
    --surface: #ffffff;
    --surface-2: #f0f2f5;
    --line: #dde1e7;
    --ink: #1a1d23;
    --muted: #5d6573;
    --accent: #3d5afe;
    --accent-ink: #ffffff;
    --accent-soft: rgba(61, 90, 254, .1);
    --ok: #1e8e3e;
    --warn: #a86b00;
    --danger: #c7332c;
    --coffee: #ffdd00;
    --coffee-ink: #1a1a1a;

    --grid: #e4ecf6;
    --note-red: #c42a22;
    --note-blue: #1846b0;
    --pencil: #7b7b7b;
    --h-yellow: rgba(255, 224, 50, .55);
    --h-pink: rgba(255, 130, 170, .35);
    --h-green: rgba(110, 215, 110, .38);
    --h-blue: rgba(110, 175, 255, .32);
    --postit: #fff1a0;
    --postit-ink: #3b3216;

    --hand: "Segoe Print", "Bradley Hand", "Chalkboard SE", "Comic Neue", "Comic Sans MS", cursive;
    --ui: system-ui, "Segoe UI", Roboto, sans-serif;
    --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .08), 0 4px 12px rgba(16, 24, 40, .06);
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;
        --bg: #12151c; --surface: #1a1f29; --surface-2: #232937; --line: #323a4b;
        --ink: #e7e9ef; --muted: #a2abbb; --accent: #8c9eff; --accent-ink: #10131a;
        --accent-soft: rgba(140, 158, 255, .14); --ok: #6fcf87; --warn: #f0b44c; --danger: #ff8b7d;
        --grid: #1c2231; --note-red: #ff8b7d; --note-blue: #9fbcff; --pencil: #9aa0ac;
        --h-yellow: rgba(255, 214, 60, .24); --h-pink: rgba(255, 120, 165, .24);
        --h-green: rgba(110, 215, 110, .22); --h-blue: rgba(110, 175, 255, .24);
        --shadow: none;
    }
}
:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #12151c; --surface: #1a1f29; --surface-2: #232937; --line: #323a4b;
    --ink: #e7e9ef; --muted: #a2abbb; --accent: #8c9eff; --accent-ink: #10131a;
    --accent-soft: rgba(140, 158, 255, .14); --ok: #6fcf87; --warn: #f0b44c; --danger: #ff8b7d;
    --grid: #1c2231; --note-red: #ff8b7d; --note-blue: #9fbcff; --pencil: #9aa0ac;
    --h-yellow: rgba(255, 214, 60, .24); --h-pink: rgba(255, 120, 165, .24);
    --h-green: rgba(110, 215, 110, .22); --h-blue: rgba(110, 175, 255, .24);
    --shadow: none;
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; color: var(--ink); font: 15px/1.5 var(--ui); min-height: 100vh; display: flex; flex-direction: column;
       background-color: var(--bg);
       background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
       background-size: 20px 20px; background-attachment: fixed; }
main { flex: 1; width: 100%; max-width: 1560px; margin: 0 auto; padding: 20px 24px 32px; }
h1 { margin: 0 0 6px; font-size: 1.7rem; line-height: 1.2; }
h2, h3 { margin: 0; }
h3 { font-size: .95rem; margin: 16px 0 8px; }
a { color: var(--accent); }
code { font-family: var(--mono); font-size: .88em; background: var(--surface-2); padding: 1px 4px; border-radius: 4px; }
kbd { font: 11px var(--mono); opacity: .7; margin-left: 6px; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.help { margin: 6px 0 0; font-size: .85rem; color: var(--muted); }
.lead { margin: 0; max-width: 75ch; color: var(--muted); }
.center { text-align: center; }
.error { color: var(--danger); }
.warn { color: var(--warn); }

input, textarea, select { font: inherit; color: var(--ink); background: var(--surface); width: 100%;
    border: 1px solid var(--line); border-radius: 7px; padding: 7px 9px; }
textarea { resize: vertical; min-height: 44px; line-height: 1.4; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type=checkbox] { width: auto; accent-color: var(--accent); margin: 0; }
input[type=file] { border: 0; padding: 0; background: none; color: var(--muted); font-size: .85rem; }
label { display: block; font-size: .85rem; color: var(--muted); }
label > span:first-child { display: block; margin-bottom: 3px; }
.lbl { margin-bottom: 4px; }

button, .btn { font: inherit; font-size: .9rem; font-weight: 600; cursor: pointer; border-radius: 8px; padding: 8px 14px;
    border: 1px solid transparent; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    text-decoration: none; line-height: 1.2; white-space: nowrap; }
button:disabled { cursor: default; opacity: .45; }
.primary { background: var(--accent); color: var(--accent-ink); }
.primary:not(:disabled):hover { filter: brightness(1.08); }
.secondary { background: var(--surface); color: var(--ink); border-color: var(--line); }
.secondary:not(:disabled):hover { background: var(--surface-2); }
.ghost { background: transparent; color: var(--ink); }
.ghost:not(:disabled):hover { background: var(--surface-2); }
.icon { padding: 6px 9px; }
.danger { color: var(--danger); }
.danger-bg { background: var(--danger); color: #fff; }
.coffee { background: var(--coffee); color: var(--coffee-ink); }
.coffee:hover { filter: brightness(.96); }
.buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px;
        box-shadow: var(--shadow); min-width: 0; }
details.card > summary { cursor: pointer; list-style: none; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::after { content: "▸"; float: right; color: var(--muted); transition: transform .15s; }
details.card[open] > summary::after { transform: rotate(90deg); }
details.card[open] > summary { margin-bottom: 12px; }
.card-title { font-size: 1rem; font-weight: 650; display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
details.card > summary.card-title { display: block; margin-bottom: 0; }
.step { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; font-size: .75rem;
        background: var(--accent-soft); color: var(--accent); }
.sub-details { margin-top: 10px; }
.sub-details > summary { cursor: pointer; font-size: .85rem; color: var(--muted); }
.sub-details[open] > summary { margin-bottom: 8px; }
.badge, .chip, .count { display: inline-block; font-size: .75rem; padding: 2px 8px; border-radius: 999px;
    background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge.ok { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.count:empty { display: none; }
.chip { max-width: 240px; overflow: hidden; text-overflow: ellipsis; vertical-align: middle; }
.chip.ok::before { content: "● "; color: var(--ok); }
.chip.warn::before { content: "● "; color: var(--warn); }

/* ---------- top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
          padding: 10px 24px; background: color-mix(in srgb, var(--surface) 88%, transparent);
          backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.brand { font-weight: 750; font-size: 1.1rem; color: var(--ink); text-decoration: none; white-space: nowrap; }
.brand-mark { color: var(--accent); }
.brand-name { font-family: var(--hand); font-weight: 700; }
.topbar .brand-name { font-size: 1.2rem; color: var(--note-red); }
.tabs { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; flex: 1; }
.tabs a { padding: 7px 12px; border-radius: 8px; color: var(--muted); text-decoration: none; font-weight: 600;
          font-size: .9rem; white-space: nowrap; }
.tabs a:hover { background: var(--surface-2); color: var(--ink); }
.tabs a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
.top-actions { display: flex; align-items: center; gap: 6px; }
.banner { margin: 0; padding: 10px 24px; background: color-mix(in srgb, var(--danger) 12%, var(--surface)); }

/* ---------- create ---------- */
.create-grid { display: grid; gap: 20px; align-items: start;
               grid-template-columns: minmax(300px, 380px) minmax(0, 1fr) minmax(220px, 260px); }
.controls { display: flex; flex-direction: column; gap: 12px; }
.stage { position: sticky; top: 76px; min-width: 0; }
.rail { display: flex; flex-direction: column; gap: 30px; padding-top: 8px; }

.preset-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.component { border-top: 1px solid var(--line); margin-top: 10px; padding-top: 8px; }
.component input[type=text] { margin-top: 4px; }
.generate-row { display: flex; gap: 8px; margin-top: 12px; align-items: stretch; }
.generate-row .primary { flex: 1; padding: 11px 14px; font-size: 1rem; }
.count-field { display: flex; align-items: center; gap: 2px; width: 74px; border: 1px solid var(--line);
               border-radius: 8px; padding-left: 8px; background: var(--surface); }
.count-field span { margin: 0 !important; display: inline !important; }
.count-field input { border: 0; padding: 6px 4px; box-shadow: none !important; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.inline { display: flex; gap: 4px; }
.check-field { display: flex; align-items: center; gap: 8px; margin-top: 10px; color: var(--ink); }
.grid2 .seed-field, .grid2 .check-field { grid-column: 1 / -1; }
.grid2 .check-field { margin-top: 0; }
.aspect { display: flex; gap: 4px; margin-bottom: 10px; flex-wrap: wrap; }
.aspect button { padding: 4px 9px; font-size: .8rem; background: var(--surface-2); color: var(--ink); }
.aspect button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }
.lora { display: grid; grid-template-columns: 1fr 70px auto; gap: 6px; align-items: end;
        border-top: 1px solid var(--line); margin-top: 10px; padding-top: 10px; }
.lora .source { grid-column: 1 / -1; }
.drop-zone { display: grid; place-items: center; gap: 6px; padding: 14px; border: 2px dashed var(--line);
             border-radius: 8px; text-align: center; cursor: pointer; color: var(--muted); }
.drop-zone input { max-width: 100%; }
.drop-zone input + span { display: none; }
body.dragging .drop-zone, .drop-zone:hover { border-color: var(--accent); background: var(--accent-soft); }
.input-preview { display: flex; gap: 10px; align-items: center; margin: 10px 0; }
.input-preview img { width: 88px; height: 88px; object-fit: cover; border-radius: 6px; }
.input-preview div { display: flex; flex-direction: column; gap: 6px; }

.status-bar { margin-bottom: 10px; }
#status { margin: 0 0 6px; font-size: .9rem; min-height: 1.5em; }
progress { width: 100%; height: 6px; appearance: none; border: 0; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
progress::-webkit-progress-bar { background: var(--surface-2); }
progress::-webkit-progress-value { background: var(--accent); transition: width .2s; }
progress::-moz-progress-bar { background: var(--accent); }
.frame { display: grid; place-items: center; border: 1px solid var(--line); border-radius: var(--radius);
         min-height: 360px; aspect-ratio: 1 / 1; max-height: calc(100vh - 260px); width: 100%; overflow: hidden; }
.frame.has-image { aspect-ratio: auto; background: var(--surface-2); }
.frame canvas { max-width: 100%; max-height: calc(100vh - 262px); display: block; }
.stage-actions { margin-top: 10px; }
.recent-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.recent { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 6px; }
.recent:empty::before { content: attr(data-empty); font-size: .85rem; color: var(--muted); grid-column: 1 / -1; }
.thumb { padding: 0; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; aspect-ratio: 1;
         background: var(--surface-2); cursor: pointer; display: block; width: 100%; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb:hover { border-color: var(--accent); }
.log-details { margin-top: 16px; }
.log-details summary { cursor: pointer; font-size: .85rem; color: var(--muted); }
#log { font: 12px/1.45 var(--mono); height: 220px; overflow: auto; white-space: pre-wrap; margin-top: 8px;
       background: var(--surface-2); border-radius: 8px; padding: 8px; }
#log .debug, #log .verbose { opacity: .7; }

/* ---------- notebook accents ---------- */
.paper { background-color: var(--surface);
         background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
         background-size: 20px 20px; }
.note { font-family: var(--hand); font-weight: 700; font-size: 1.5rem; line-height: 1.15;
        transform: rotate(var(--tilt, -2deg)); transform-origin: left top; }
.note.red { color: var(--note-red); } .note.blue { color: var(--note-blue); }
.note.pencil { color: var(--pencil); font-weight: 600; }
.note .sub { display: block; margin-top: 8px; font-weight: 400; font-size: 1.05rem; line-height: 1.3; color: var(--note-blue); }
.note.blue .sub { color: var(--ink); }
.tilt-l { --tilt: -3deg; } .tilt-r { --tilt: 2deg; }
.mark { padding: 0 .22em; border-radius: .35em .7em .45em .6em; -webkit-box-decoration-break: clone; box-decoration-break: clone;
        background: linear-gradient(100deg, transparent 1%, var(--h) 3%, var(--h) 97%, transparent 99%); }
.m-yellow { --h: var(--h-yellow); } .m-pink { --h: var(--h-pink); } .m-green { --h: var(--h-green); } .m-blue { --h: var(--h-blue); }
.ink path, .ink circle, .ink rect { fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.empty { display: grid; justify-items: center; text-align: center; gap: 4px; --tilt: -2deg; transform-origin: center; padding: 20px; }
.empty .sub { color: var(--pencil); }
.postit { position: relative; background: var(--postit); color: var(--postit-ink); font-family: var(--hand);
          padding: 20px 16px 14px; transform: rotate(2deg); box-shadow: 0 12px 14px -10px rgba(0, 0, 0, .45); }
.postit::before { content: ""; position: absolute; top: -10px; left: 50%; width: 64px; height: 20px;
                  transform: translateX(-50%) rotate(-3deg); background: rgba(255, 255, 255, .6); border: 1px solid rgba(0, 0, 0, .06); }
.postit h2 { margin: 0 0 6px; font-size: 1.25rem; text-decoration: underline; text-underline-offset: 4px; }
.postit ol { margin: 0; padding-left: 1.3em; font-size: 1.05rem; line-height: 1.3; }
.postit li { margin: 3px 0; }

/* setup panel */
.setup-panel { margin-bottom: 20px; padding: 0; border-left: 4px solid var(--note-red); }
.setup-panel > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 16px; }
.setup-panel > summary::-webkit-details-marker { display: none; }
details.setup-panel > summary::after { content: none; }
details.setup-panel[open] > summary { margin-bottom: 0; }
.setup-title { font-weight: 650; }
.setup-toggle { margin-left: auto; color: var(--muted); font-size: .85rem; }
.setup-toggle::before { content: attr(data-hide) " "; }
.setup-panel:not([open]) .setup-toggle::before { content: attr(data-show) " "; }
.setup-toggle::after { content: "▾"; display: inline-block; transition: transform .15s; }
.setup-panel:not([open]) .setup-toggle::after { transform: rotate(-90deg); }
.setup-body { display: grid; grid-template-columns: minmax(0, 1fr) 240px; gap: 24px; padding: 0 16px 16px; align-items: start; }
.setup-adapter { margin: 0 0 8px; font-weight: 600; }
.setup-note { margin-top: 10px; }

/* diagnostics */
.diag-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-top: 10px;
            padding-top: 10px; border-top: 1px solid var(--line); }
.diag-row .check-field { margin: 0; font-size: .85rem; }
.link { background: none; border: 0; padding: 0; color: var(--accent); font-weight: 600; font-size: .85rem; text-decoration: underline; text-underline-offset: 3px; }
.diag { max-width: 560px; }
.diag form { padding: 22px 22px 18px; }
.diag h2 { font-size: 1.25rem; margin-bottom: 8px; }
.diag p { margin: 0 0 10px; }
.diag-lists { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; padding: 12px 14px; border-radius: 8px; background: var(--surface-2); margin-bottom: 10px; }
.diag-lists h3 { margin: 0 0 4px; font-size: .9rem; }
.diag-lists ul { margin: 0; padding-left: 1.1em; font-size: .88rem; }
.diag-lists li { margin: 3px 0; }
.diag-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.diag-foot .buttons { margin: 0; }
.diag-foot .note { font-size: 1.3rem; }

/* sponsor / house-promo slots (no third-party ad scripts) */
.promo-slot:empty { display: none; }
.promo { display: block; border: 1px dashed var(--line); border-radius: var(--radius); padding: 14px; background: var(--surface);
         color: var(--ink); text-decoration: none; font-size: .9rem; }
.promo:hover { border-color: var(--accent); }
.promo .promo-label { display: block; font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 6px; }
.promo strong { display: block; margin-bottom: 4px; }
.promo-slot.wide { margin-top: 24px; }
.promo-slot.wide .promo { display: flex; gap: 16px; align-items: center; justify-content: space-between; flex-wrap: wrap; }

/* ---------- views ---------- */
.view-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; margin-bottom: 18px; }
.view-head .note { max-width: 260px; flex: none; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.toolbar input[type=search] { flex: 1 1 220px; width: auto; }
.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; margin-top: 14px; }
.gallery-grid .thumb { position: relative; }
.gallery-grid .thumb .cap { position: absolute; inset: auto 0 0 0; padding: 18px 8px 6px; font-size: .75rem; color: #fff; text-align: left;
    background: linear-gradient(transparent, rgba(0, 0, 0, .7)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    opacity: 0; transition: opacity .15s; }
.gallery-grid .thumb:hover .cap, .gallery-grid .thumb:focus-visible .cap { opacity: 1; }
.empty-card { border: 1px solid var(--line); border-radius: var(--radius); display: grid; place-items: center; min-height: 260px; margin-top: 14px; }

.bench-grid { display: grid; grid-template-columns: minmax(0, 380px) minmax(0, 1fr); gap: 20px; align-items: start; }
.bench-result { margin-top: 14px; padding: 14px; border-radius: 8px; background: var(--accent-soft); }
.bench-result .big { font-size: 2rem; font-weight: 750; line-height: 1.1; }
.table-wrap { overflow-x: auto; }
.table { border-collapse: collapse; width: 100%; font-size: .88rem; }
.table th, .table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table th { font-size: .78rem; color: var(--muted); font-weight: 600; }
.table td.num { font-variant-numeric: tabular-nums; }
.table .dim { color: var(--muted); }
.table tr.you td { background: var(--accent-soft); }

.apps-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.app-card { display: flex; flex-direction: column; gap: 6px; }
.app-card h2 { font-size: 1.15rem; }
.app-card ul { margin: 6px 0 12px; padding-left: 1.2em; flex: 1; }
.app-card li { margin: 4px 0; }
.app-card .btn, .app-card button { align-self: flex-start; }
.app-card.featured { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.app-icon { font-size: 1.8rem; }
.app-tag { margin: 0; font-size: .8rem; font-weight: 600; color: var(--warn); }
.app-tag.ok { color: var(--ok); }
.support-card { margin-top: 24px; display: flex; gap: 24px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.support-card p { max-width: 60ch; }
.support-card .note { max-width: 260px; }

.help-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.prose ol { margin: 0; padding-left: 1.3em; }
.prose li { margin: 8px 0; }
.prose ul { margin: 6px 0; padding-left: 1.2em; }
.cached-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 0;
              border-bottom: 1px solid var(--line); font-size: .85rem; }
.cached-row span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.licenses details { border-bottom: 1px solid var(--line); padding: 6px 0; }
.licenses summary { cursor: pointer; font-weight: 600; font-size: .9rem; }
.licenses summary a { font-weight: 400; font-size: .8rem; margin-left: 4px; }
.licenses pre { font: 11.5px/1.45 var(--mono); white-space: pre-wrap; background: var(--surface-2); border-radius: 6px;
                padding: 10px; max-height: 320px; overflow: auto; margin: 8px 0 4px; }
.copyright { font-weight: 600; }
.footer { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; padding: 16px; font-size: .8rem; color: var(--muted); border-top: 1px solid var(--line); }

/* ---------- dialogs ---------- */
dialog { border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--ink); padding: 0; }
dialog::backdrop { background: rgba(8, 10, 15, .7); }
.viewer { width: min(1200px, 96vw); max-height: 94vh; }
.viewer-body { display: grid; grid-template-columns: minmax(0, 1fr) 320px; max-height: 94vh; }
.viewer-image { background: #0b0d12; display: grid; place-items: center; min-height: 300px; }
.viewer-image img { max-width: 100%; max-height: 94vh; display: block; }
.viewer-side { padding: 14px 16px; overflow: auto; display: flex; flex-direction: column; gap: 10px; }
.viewer-nav { display: flex; justify-content: flex-end; gap: 4px; }
.viewer-prompt { margin: 0; white-space: pre-wrap; word-break: break-word; max-height: 30vh; overflow: auto; }
.meta { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; font-size: .82rem; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; word-break: break-word; }
.viewer-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; }
.confirm { max-width: 420px; }
.confirm form { padding: 18px; }
.confirm p { margin: 0; }
.confirm .buttons { justify-content: flex-end; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 50; background: var(--ink); color: var(--bg);
         padding: 10px 16px; border-radius: 8px; font-size: .9rem; box-shadow: 0 8px 24px rgba(0, 0, 0, .25); max-width: calc(100vw - 32px); }

/* ---------- responsive ---------- */
@media (max-width: 1280px) {
    .create-grid { grid-template-columns: minmax(300px, 380px) minmax(0, 1fr); }
    .rail { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); align-items: start; gap: 24px; }
}
@media (max-width: 900px) {
    main { padding: 16px; }
    .topbar { padding: 8px 16px; gap: 8px; }
    .tabs { order: 3; flex-basis: 100%; }
    .top-actions { margin-left: auto; }
    .chip { display: none; }
    .create-grid, .bench-grid, .help-grid, .setup-body, .diag-lists { grid-template-columns: 1fr; }
    .setup-note { display: none; }
    .stage { position: static; }
    .frame { min-height: 0; max-height: none; }
    .frame canvas { max-height: 70vh; }
    .apps-grid { grid-template-columns: 1fr; }
    .viewer-body { grid-template-columns: 1fr; overflow: auto; }
    .viewer-image img { max-height: 60vh; }
    .hide-sm { display: none !important; }
    .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 6px; }
    kbd { display: none; }
}
@media (max-width: 520px) {
    #coffeeTop span:last-child { display: none; }
    .grid2 { gap: 8px; }
}
