/* ==========================================================================
   Kitchen Visualizer — styles
   Layout:  ≥1024px  preview left + sticky configurator right
            <1024px  stacked; preview sticks to the top while you pick
   ========================================================================== */

:root {
    --brand: #000000 !important;
    --brand-ink: #000000;
    --brand-soft: #f3ece1;
    --bg: #f5f5f5;
    --surface: #ffffff;
    --surface-2: #f5f5f5;
    --ink: #1f1b16;
    --ink-2: #000;
    --ink-3: #000;
    --line: #e7e1d8;
    --line-2: #d8d0c4;
    --radius: 14px;
    --radius-sm: 10px;
    --shadow: 0 1px 2px rgba(31, 27, 22, .05), 0 8px 24px -12px rgba(31, 27, 22, .18);
    --shadow-lg: 0 24px 60px -20px rgba(31, 27, 22, .35);
    --topbar-h: 68px;
    --gutter: clamp(16px, 2.4vw, 32px);
    --config-w: 400px;
    --scene-w: 340px;
    --font: "Raleway", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --font-display: "Raleway";
    --ease: cubic-bezier(.2, .7, .2, 1);
}

*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    color: var(--ink);
    background: #fff;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

img, canvas, svg { display: block; max-width: 100%; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }

svg:not(.fill) { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
svg.fill { fill: currentColor; }

:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.vh {
    position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip {
    position: absolute; left: 12px; top: -60px; z-index: 100;
    background: var(--ink); color: #fff; padding: 10px 14px; border-radius: 8px; text-decoration: none;
    transition: top .2s;
}
.skip:focus { top: 12px; }

.eyebrow {
    font-size: 11px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3);display: none;
}
.muted { color: var(--ink-3); font-weight: 400; }

/* ---------------------------------------------------------------- buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: 35px; padding: 0 18px; border-radius: 999px;
    border: 1px solid var(--line-2); background: var(--surface);
    font-weight: 600; font-size: 12px; white-space: nowrap;
    transition: background .15s, border-color .15s, color .15s, transform .15s;
}
.btn svg { width: 18px; height: 18px; flex: none; }
.btn:hover { border-color: var(--ink-3); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.primary:hover { background: #000; }
.btn.ghost { background: transparent; }
.btn[disabled] { opacity: .55; pointer-events: none; }

.icon-btn {
    display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px;
    border: 0; background: rgba(255, 255, 255, .92); color: var(--ink);
    box-shadow: 0 2px 10px rgba(0, 0, 0, .15);
    backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
    transition: background .15s, color .15s;
}
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn:hover { background: #fff; }
.icon-btn[aria-pressed="true"] { background: var(--ink); color: #fff; }

/* ---------------------------------------------------------------- topbar */
.topbar {
    position: sticky; top: 0; z-index: 30;
    height: var(--topbar-h);
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    padding: 0 var(--gutter);
    background: #fff;
    backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px);
    border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark {
    display: grid; place-items: center; width: 40px; height: 40px; flex: none;
    border-radius: 12px; background: var(--brand); color: #fff;
}
.brand-mark svg { width: 22px; height: 22px; }
.brand-name { font-size: 20px; font-weight: 600; text-transform: uppercase; color: var(--brand); }
.brand-title { font-family: var(--font-display); font-weight: 600; font-size: 20px; line-height: 1.15; letter-spacing: -.01em; }
.topbar-actions { display: flex; gap: 8px; flex: none; }

/* ---------------------------------------------------------------- app grid */
.app {
    display: grid;
    grid-template-columns: minmax(0, 1fr) var(--config-w);
    gap: var(--gutter);
    padding: var(--gutter);
    max-width: 1500px;
    margin: 80px auto 0px;
    align-items: start;
}

/* right-hand column: the material card + the Switch Scene card */
.rail {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: var(--gutter);
    align-self: start;
    min-width: 0;
    max-width: 100%;
}
.rail > .config { flex: 0 1 var(--config-w); min-width: 0; max-width: 100%; }
.rail > .scene-switch { flex: 0 1 var(--scene-w); min-width: 0; max-width: 100%; }

/* ---------------------------------------------------------------- preview */
.preview { min-width: 0; display: flex; flex-direction: column; gap: 16px; }

.stage-wrap {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 10px;
}

.stage {
    position: relative;
    --ar: 1.7778;
    /* aspect-ratio: var(--ar); */
    aspect-ratio: 1 / 0.6;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: #ece7df;
    isolation: isolate;
}
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.stage #cv { cursor: default; touch-action: manipulation; }
.stage #cv.pickable { cursor: pointer; }
.stage .overlay { pointer-events: none; }

.stage-loading {
    position: absolute; inset: 0; display: grid; place-items: center;
    background: rgba(236, 231, 223, .35);
    opacity: 0; visibility: hidden; transition: opacity .2s, visibility .2s;
    pointer-events: none;
}
.stage-loading.on { opacity: 1; visibility: visible; }
.stage.empty .stage-loading { background: #f5f5f5; }
.spinner {
    width: 34px; height: 34px; border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, .7); border-top-color: var(--brand);
    animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.progress { position: absolute; left: 0; right: 0; top: 0; height: 3px; opacity: 0; transition: opacity .25s; pointer-events: none; }
.progress.on { opacity: 1; }
.progress i { display: block; height: 100%; width: 0; background: var(--brand); transition: width .25s var(--ease); }

.stage-tools { position: absolute; top: 12px; right: 12px; display: flex; gap: 8px; z-index: 3; }

.share-pop {
    position: absolute; top: 70px; right: 22px;
    display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
    max-width: min(140px, calc(100vw - 48px));
    padding: 10px; border-radius: 14px;
    background: rgba(255,255,255,.97); border: 1px solid var(--line);
    box-shadow: var(--shadow-lg);
    z-index: 5;
}
.share-pop[hidden] { display: none; }
.share-pop .act { height: 35px; }
.share-sep { flex-basis: 100%; height: 1px; background: var(--line); }
.share-row { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; flex-basis: 100%; }
.share-row.actions-col { flex-direction: column; align-items: stretch; }
.share-row.actions-col .act { width: 100%; justify-content: flex-start; }
.share-row + .share-row { border-top: 1px solid var(--line); padding-top: 8px; }

.stage-hint {
    position: absolute; left: 12px; bottom: 12px;
    display: inline-flex; align-items: center; gap: 8px;
    padding: 7px 12px 7px 10px; border-radius: 999px;
    background: rgba(20, 17, 13, .72); color: #fff; font-size: 12.5px; font-weight: 500;
    backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
    pointer-events: none; transition: opacity .4s;
}
.stage-hint svg { width: 16px; height: 16px; }
.stage-hint.off { opacity: 0; }

.hover-tag {
    position: absolute; top: 0; left: 0; transform: translate(-50%, calc(-100% - 14px));
    padding: 6px 10px; border-radius: 8px; background: var(--ink); color: #fff;
    font-size: 12px; font-weight: 600; white-space: nowrap; pointer-events: none;
    opacity: 0; 
}
.hover-tag.on { opacity: 1; }
.hover-tag small { font-weight: 400; opacity: .75; margin-left: 4px; }

/* view switch */
.view-switch { display: flex; gap: 10px; padding: 10px 0 0; }
.view-btn {
    flex: 1 1 0; min-width: 0; display: flex; align-items: center; gap: 10px;
    padding: 6px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface-2);
    text-align: left; transition: border-color .15s, background .15s, box-shadow .15s;
}
.view-btn img { width: 72px; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 7px; flex: none; background: #e6e0d7; }
.view-btn b { display: block; font-size: 13.5px; font-weight: 600; }
.view-btn span { display: block; font-size: 12px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.view-btn:hover { border-color: var(--line-2); }
.view-btn[aria-selected="true"] { border-color: var(--ink); background: var(--surface);
     /* box-shadow: inset 0 0 0 1px var(--ink);  */
    }

/* summary */
.summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px;}
.sum {
    display: flex; align-items: center; gap: 10px; min-width: 0;
    padding: 8px 10px 8px 8px; border-radius: 12px;
    background: var(--surface); border: 1px solid var(--line);
    text-align: left; transition: border-color .15s, box-shadow .15s;
}
.sum:hover { border-color: var(--line-2); }
.sum[aria-current="true"] { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.sum .thumb { width: 40px; height: 40px; border-radius: 8px; flex: none; overflow: hidden; background: #ddd; }
.sum .thumb img { width: 100%; height: 100%; object-fit: cover; }
.sum .txt { min-width: 0; }
.sum .txt small { display: block; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
.sum .txt b { display: block; font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* action buttons (used inside the canvas Share popup) */
.act {
    display: inline-flex; align-items: center; gap: 8px;
    height: 35px; padding: 0 14px; border-radius: 999px;
    border: 1px solid var(--line); background: var(--surface);
    font-size: 13px; font-weight: 500; color: var(--ink-2);
    transition: border-color .15s, color .15s, background .15s;
}
.act svg { width: 17px; height: 17px; }
.act:hover { border-color: var(--line-2); color: var(--ink); }
.act.round { width: 35px; padding: 0; justify-content: center; }

/* ---------------------------------------------------------------- configurator */
.config {
    position: sticky; top: calc(var(--topbar-h) + var(--gutter));
    max-height: calc(100vh - var(--topbar-h) - var(--gutter) * 2);
    max-height: calc(100dvh - var(--topbar-h) - var(--gutter) * 2);
    display: flex; flex-direction: column;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.config-head { padding: 20px 10px 4px; }
.config-head h2 { font-family: var(--font-display); font-weight: 600; font-size: 22px; letter-spacing: -.01em; }
.config-head p { color: var(--ink-2); font-size: 13.5px; margin-top: 2px; }

/* ---- standalone card used by the Switch Scene panel ---- */
.card {
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
}

.card-scene-switch {
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--surface);
    padding: 20px 10px 0;
}

.card-head h2 { font-family: var(--font-display); font-weight: 600; font-size: 22px; letter-spacing: -.01em; }
.card-head p { color: var(--ink-2); font-size: 13.5px; margin-top: 2px; }
/* the scene picker now lives inside its own card */
.card .scene-picker { padding: 12px 0 0; }
.scene-heading { font-size: 13.5px; font-weight: 600; color: var(--ink); }
.scene-current { font-size: 12.5px; color: var(--ink-3); margin-top: 2px; }
.scene-list { display: flex; gap: 12px; padding: 10px 0 2px; }
/* Each scene tile = TWO images side-by-side (Full View | Close Up). */
.scene-tile {
    display: grid; grid-template-columns: 1fr 1fr;
    width: 200px; max-width: 100%;
    aspect-ratio: 16 / 9;
    padding : 5px;
    border: 1.5px solid var(--line-2); border-radius: var(--radius-sm);
    overflow: hidden; background: #eee; box-sizing: border-box;
    transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.scene-tile.on { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); padding : 5px;}
.scene-half {
    position: relative; display: block; min-width: 0; min-height: 0;
    margin: 0; padding: 0; border: 0; background: #eee;
    cursor: pointer; touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none; -webkit-user-select: none;
}
.scene-half + .scene-half { border-left: 1px solid rgba(255,255,255,.75); }
.scene-half img {
    width: 100%; height: 100%; object-fit: cover; display: block;
    pointer-events: none;
}
.scene-half .cap {
    position: absolute; left: 0; right: 0; bottom: 0;
    padding: 14px 4px 5px; font-size: 10px; font-weight: 700;
    letter-spacing: .06em; text-transform: uppercase; color: #fff; text-align: center;
    background: linear-gradient(transparent, rgba(0,0,0,.65));
    pointer-events: none;
    display: none;
}
.scene-half.on::after {
    content: ""; position: absolute; inset: 0; pointer-events: none;
}
.scene-half.on .cap { text-decoration: underline; text-underline-offset: 2px; }
.scene-half:focus-visible { outline: 2px solid var(--ink); outline-offset: -3px; }

/* surface tabs */
.tabs {
    display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px;
    padding: 15px 10px 0;
}
.tab {
    position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px;
    padding: 8px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface-2);
    font-size: 13px; font-weight: 500; color: var(--ink-2);
    transition: border-color .15s, background .15s, color .15s;
}
.tab .chip { width: 100%; height: 40px; border-radius:5px; overflow: hidden; background: #ddd; box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--line); }
.tab .chip img { width: 100%; height: 100%; object-fit: cover; }
.tab:hover { border-color: var(--line-2); color: var(--ink); }
.tab[aria-selected="true"] { border-color: var(--ink); background: var(--surface); color: var(--ink); 
    /* box-shadow: inset 0 0 0 1px var(--ink);  */
}
.tab[aria-selected="true"] .chip { box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--brand); }
.tab.flash { animation: flash .6s var(--ease); }
@keyframes flash { 40% { background: var(--brand-soft); } }

/* panel */
.panel { display: flex; flex-direction: column; min-height: 0; flex: 1; padding: 16px 0 0; }
.panel-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; padding: 0 10px; }
.panel-sel { font-family: var(--font-display); font-size: 19px; font-weight: 600; margin-top: 2px; }
.count { font-size: 12px; color: var(--ink-3); white-space: nowrap; }

.filters { display: flex; gap: 6px; padding: 12px 10px;  scrollbar-width: none; 
overflow-x: none;
}
.filters::-webkit-scrollbar { display: none; }
.fchip {
    flex: none; height: 32px; padding: 0 12px; border-radius: 999px;
    border: 1px solid var(--line); background: var(--surface);
    font-size: 12.5px; font-weight: 500; color: var(--ink-2);
    transition: background .15s, color .15s, border-color .15s;
}
.fchip:hover { border-color: var(--line-2); color: var(--ink); }
.fchip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }

.grid {
    display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px;
    padding: 14px 10px 20px; overflow-y: auto; min-height: 0; flex: 1;
    align-content: start; overscroll-behavior: contain;
}
.sw {
    position: relative; display: flex; flex-direction: column; gap: 6px; min-width: 0;
    padding: 0; border: 0; background: none; text-align: left;
}
.sw .img {
    position: relative; display: block; aspect-ratio: 1; border-radius: 12px; overflow: hidden;
    background: #e6e0d7; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .06);
    transition: box-shadow .15s, transform .2s var(--ease);
}
.sw .img img { width: 100%; height: 100%; object-fit: cover; transition: opacity .3s, transform .4s var(--ease); }
.sw .img img.loading { opacity: 0; }
.sw:hover .img img { transform: scale(1.05); }
.sw .nm { font-size: 12.5px; font-weight: 500; line-height: 1.25; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.sw .fam { font-size: 11px; color: var(--ink-3); margin-top: -4px; }
.sw .tick {
    position: absolute; top: 8px; right: 8px; width: 24px; height: 24px; border-radius: 50%;
    display: grid; place-items: center; background: var(--ink); color: #fff;
    transform: scale(0); transition: transform .2s var(--ease);
}
.sw .tick svg { width: 14px; height: 14px; stroke-width: 2.4; }
.sw .new { position: absolute; left: 8px; top: 8px; padding: 2px 7px; border-radius: 999px; background: var(--brand); color: #fff; font-size: 10.5px; font-weight: 700; letter-spacing: .04em; }
.sw[aria-checked="true"] .img { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--ink); }
.sw[aria-checked="true"] .tick { transform: scale(1); }
.sw[aria-checked="true"] .nm { color: var(--ink); font-weight: 600; }
.sw:focus-visible { outline: none; }
.sw:focus-visible .img { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--brand); }

.empty { grid-column: 1 / -1; padding: 28px 12px; text-align: center; color: var(--ink-3); font-size: 13.5px; border: 1px dashed var(--line-2); border-radius: 12px; }
.empty button { margin-top: 8px; border: 0; background: none; color: var(--brand); font-weight: 600; text-decoration: underline; }

/* ---------------------------------------------------------------- footer */
.foot {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px;
    max-width: 1680px; margin: 0 auto; padding: 8px var(--gutter) 28px;
    color: var(--ink-3); font-size: 13px;display: none;
}
.foot a { color: var(--ink-2); font-weight: 500; }
.counters { display: flex; gap: 20px; }
.counters b { color: var(--ink); margin-left: 4px; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- lightbox */
.lb {
    position: fixed; inset: 0; z-index: 60; display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 56px 16px 16px; background: rgba(15, 12, 9, .94);
    animation: fade .2s var(--ease);
}
.lb-inner { width: 100%; flex: 1; min-height: 0; display: grid; place-items: center; }
.lb-inner canvas { max-width: 100%; max-height: 85vh; width: auto; height: auto; border-radius: 8px; box-shadow: var(--shadow-lg); }
.lb-inner .spinner { border-color: rgba(255, 255, 255, .2); border-top-color: #fff; }
.lb-close {
    position: absolute; top: 90px; right: 12px; width: 44px; height: 44px; border-radius: 50%;
    display: grid; place-items: center; border: 0; background: rgba(255, 255, 255, .12); color: #fff;
}
.lb-close svg { width: 22px; height: 22px; }
.lb-close:hover { background: rgba(255, 255, 255, .22); }
.lb-cap { color: rgba(255, 255, 255, .75); font-size: 13px; text-align: center; padding-top: 12px; max-width: 900px; }

/* ---------------------------------------------------------------- modal */
.modal {
    position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 16px;
    background: rgba(15, 12, 9, .5); animation: fade .2s var(--ease);
}
.modal-card {
    width: min(440px, 100%); background: var(--surface); border-radius: 18px; padding: 24px;
    box-shadow: var(--shadow-lg); display: flex; flex-direction: column; gap: 6px;
    animation: pop .25s var(--ease);
}
.modal-card h3 { font-family: var(--font-display); font-size: 22px; font-weight: 600; }
.modal-card > p { color: var(--ink-2); font-size: 14px; margin-bottom: 10px; }
.modal-card label { font-size: 13px; font-weight: 600; margin-top: 8px; }
.modal-card input, .modal-card textarea {
    width: 100%; padding: 11px 12px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--surface-2);
    font-size: 15px; resize: vertical;
}
.modal-card input:focus, .modal-card textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }

/* ---------------------------------------------------------------- toast */
.toast {
    position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 80;
    transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
    padding: 11px 18px; border-radius: 999px; background: var(--ink); color: #fff; font-size: 14px; font-weight: 500;
    box-shadow: var(--shadow-lg); transition: opacity .2s, transform .25s var(--ease);
    max-width: calc(100vw - 32px); text-align: center;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

#printArea { display: none; }

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 1080px) {
    :root { --config-w: 360px; }
    .summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}


/* medium widths: keep the material card width; stack Switch Scene beneath it */
@media (min-width: 1024px) and (max-width: 1499px) {
    .rail { flex-direction: column; width: min(var(--config-w), 100%); max-width: 100%; }
    .rail > .config, .rail > .scene-switch { flex: 0 0 auto; width: 100%; max-width: 100%; }
}

/* stacked layout */
@media (max-width: 1023px) {
    :root { --topbar-h: 60px; }

    .app { grid-template-columns: minmax(0, 1fr); gap: 16px; }
    .preview { display: contents; }
    .stage-wrap {
        position: sticky; top: var(--topbar-h); z-index: 20;
        margin: calc(var(--gutter) * -1) calc(var(--gutter) * -1) 0;
        border-radius: 0; border-width: 0 0 1px; padding: 8px var(--gutter) 10px;
        box-shadow: 0 10px 20px -18px rgba(0, 0, 0, .4);
        order: 1;
    }
    .stage { width: min(100%, calc(48vh * var(--ar))); width: min(100%, calc(48dvh * var(--ar))); margin: 0 auto; }
    .rail { display: contents; }
    .rail > .config { order: 3; flex: 0 0 auto; width: 100%; max-width: 100%; }
    .rail > .scene-switch { order: 4; flex: 0 0 auto; width: 100%; max-width: 100%; }
    .config { position: static; max-height: none; overflow: visible; }
    .grid { overflow: visible; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); }
    .summary { order: 2; grid-template-columns: repeat(4, minmax(0, 1fr)); }
    /* Switch-scenes card: full width, tiles fit the screen */
    .scene-switch { width: 100%; max-width: 100%; }
    .scene-switch .scene-list { grid-template-columns: minmax(0, 1fr); }
    .scene-tile { aspect-ratio: 21 / 9; }
}

@media (max-width: 767px) {
    body { font-size: 14px; }
    .brand-mark { width: 36px; height: 36px; border-radius: 10px; }
    .brand-title { font-size: 17px; }
    .brand-name { font-size: 10px; }
    .topbar-actions .btn { height: 38px; padding: 0 12px; }
    .topbar-actions .btn.ghost span { display: none; }
    .topbar-actions .btn.ghost { width: 38px; padding: 0; }
    .card-head h2 { font-family: var(--font-display); font-weight: 600; font-size: 16px !important; letter-spacing: -.01em; }

    .stage-wrap { padding: 6px 12px 8px; margin: -16px -16px 0; }
    .app { padding: 16px; }
    .stage { width: min(100%, calc(40vh * var(--ar))); width: min(100%, calc(40dvh * var(--ar))); }
    .stage-tools { top: 8px; right: 8px; gap: 6px; }
    .icon-btn { width: 34px; height: 34px; border-radius: 10px; }
    .icon-btn svg { width: 17px; height: 17px; }
    .stage-hint { left: 8px; bottom: 8px; font-size: 11.5px; padding: 5px 10px 5px 8px; }

    .view-switch { gap: 6px; }
    .view-btn { padding: 4px; gap: 8px; }
    .view-btn img { width: 48px; }
    .view-btn b { font-size: 12.5px; }
    .view-btn span { display: none; }
    .muted { color: var(--ink-3); font-weight: 400; font-size: 14px !important; }

    .config-head { padding: 16px 16px 0; }
    .config-head h2 { font-size: 16px !important; }
    .card { padding: 16px; }
    .card .scene-picker { padding: 10px 0 0; }
    .scene-switch .scene-list { gap: 10px; }
    .scene-tile { aspect-ratio: 16 / 9; }
    .scene-half { min-height: 88px; }
    .tabs { padding: 14px 16px 0; gap: 5px; }
    .tab { font-size: 11.5px; padding: 7px 2px 8px; }
    .tab .chip { width: 28px; height: 28px; }
    .panel-head { padding: 0 16px; }
    .panel-sel { font-size: 17px; }
    .filters { padding: 10px 16px 0; }
    .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; padding: 12px 16px 16px; }

    .summary { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
    .sum .thumb { width: 34px; height: 34px; }

    .share-pop .act { justify-content: center; padding: 0 8px; }

    .foot { flex-direction: column; align-items: flex-start; padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
    .counters { gap: 14px; flex-wrap: wrap; }
    .hover-tag { display: none; }
}

@media (max-width: 767px) {
    .brand-name { display: none; }
    .topbar-actions .btn.primary span { display: none; }
    .topbar-actions .btn.primary { width: 38px; padding: 0; }
    .tab { font-size: 10.5px; }
}

/* short landscape phones: don't let the sticky preview eat the screen */
@media (max-width: 1023px) and (max-height: 500px) {
    .stage-wrap { position: relative; top: 0; }
    .stage { width: min(100%, calc(70vh * var(--ar))); }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------------------------------------------------------------- print */
@media print {
    body { background: #fff; }
    body > *:not(#printArea) { display: none !important; }
    #printArea { display: block !important; font-family: var(--font); color: #000; }
    #printArea h2 { font-family: var(--font-display); font-size: 20px; margin: 0 0 12px; }
    #printArea img { width: 100%; margin: 0 0 10px; page-break-inside: avoid; }
    #printArea ul { list-style: none; padding: 0; margin: 8px 0; columns: 2; font-size: 13px; }
    #printArea li { margin: 0 0 4px; }
    #printArea .link { font-size: 10px; word-break: break-all; color: #555; }
}



#tabs {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

#tabs .tab {
    min-height: 72px;
    padding: 9px 8px;
    border: 1px solid #e5e5e5;
    border-radius: 10px;
    background: #fff;
    color: #111;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
    transition: all .2s ease;
}

#tabs .tab:hover {
    border-color: #111;
}

#tabs .tab[aria-selected="true"] {
    background: #111;
    border-color: #111;
    color: #fff;
}

/* Icon container */
#tabs .icon-chip {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent !important;
}

/* SVG */
#tabs .icon-chip svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Floor icon uses filled tiles */
#tabs .icon-chip svg path {
    fill: none;
}

#tabs .tab > span:last-child {
    font-size: 12px;
    font-weight: 500;
    line-height: 1.2;
}

@Media only screen and (min-width: 1150px) and (max-width: 1450px) {
    .app{
        padding:10px 20px;
    }
}