/* =========================================================
   NIBI STUDIO — BROADCAST DECK & LOYALTY LEDGER STYLESHEET
   ========================================================= */

@font-face {
    font-family: 'Space Grotesk';
    src: url('/fonts/space-grotesk-latin.woff2') format('woff2');
    font-weight: 500 700;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'IBM Plex Sans';
    src: url('/fonts/ibm-plex-sans-400.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'IBM Plex Sans';
    src: url('/fonts/ibm-plex-sans-600.woff2') format('woff2');
    font-weight: 500 600;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'IBM Plex Mono';
    src: url('/fonts/ibm-plex-mono-500.woff2') format('woff2');
    font-weight: 400 600;
    font-style: normal;
    font-display: swap;
}

:root {
    --bg-canvas: #080b10;
    --bg-panel: #10151e;
    --bg-surface: #161d29;
    --bg-hover: #1d2636;
    --border-line: #2d3848;
    --border-focus: #38a1ff;

    --ink-primary: #f1f5f9;
    --ink-secondary: #94a3b8;
    --ink-muted: #64748b;

    --accent-cyan: #22b8cf;
    --accent-blue: #2563eb;
    --accent-blue-hover: #3b82f6;
    --accent-gold: #e09f3e;
    --accent-green: #2da44e;
    --accent-green-hover: #3fb950;
    --accent-red: #da3633;
    --accent-twitch: #7c3aed;

    --font-display: 'Space Grotesk', system-ui, -apple-system, sans-serif;
    --font-body: 'IBM Plex Sans', system-ui, -apple-system, sans-serif;
    --font-mono: 'IBM Plex Mono', Consolas, monospace;

    --radius-sm: 6px;
    --radius-md: 10px;
}

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

html, body {
    height: 100%;
    background-color: var(--bg-canvas);
    color: var(--ink-primary);
    font-family: var(--font-body);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

[hidden] {
    display: none !important;
}

/* Woodland Spirit Line Vector Field (Full-Bleed Zero-Seam SVG + GPU Counter-Weave) */
.spirit-bg {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

.spirit-bg::before,
.spirit-bg::after {
    content: '';
    position: absolute;
    inset: -12%;
    background-repeat: no-repeat;
    background-position: center;
    background-size: cover;
    will-change: transform;
}

/* Layer 1: Heavy Deep-Teal Formlines (7.5px-9px) + Medium Echo Contours + Independent Gliding Nodes */
.spirit-bg::before {
    opacity: 0.34;
    background-image: var(--spirit-svg-deep, url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1600 1000' preserveAspectRatio='xMidYMid slice' fill='none'%3E%3Cg stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath id='p1' d='M-200 180 C 180 40, 420 340, 820 170 C 1180 20, 1420 290, 1800 140' stroke='%230b3b59' stroke-width='9'/%3E%3Cpath id='p2' d='M-200 520 C 220 360, 540 690, 940 490 C 1280 320, 1500 610, 1800 470' stroke='%230e4f6e' stroke-width='7.5'/%3E%3Cpath id='p3' d='M-200 840 C 260 960, 580 670, 980 820 C 1320 940, 1540 720, 1800 830' stroke='%230b3b59' stroke-width='8.5'/%3E%3Cpath d='M-200 204 C 185 68, 425 364, 825 194 C 1185 44, 1425 314, 1800 164' stroke='%23146c8a' stroke-width='3.2'/%3E%3Cpath d='M-200 494 C 215 334, 535 664, 935 464 C 1275 294, 1495 584, 1800 444' stroke='%231985a1' stroke-width='2.8'/%3E%3Cpath d='M-200 814 C 255 934, 575 644, 975 794 C 1315 914, 1535 694, 1800 804' stroke='%23146c8a' stroke-width='3.5'/%3E%3Cpath id='p4' d='M260 -150 C 140 180, 440 420, 310 740 C 230 930, 350 1060, 290 1180' stroke='%23115e7a' stroke-width='5'/%3E%3Cpath id='p5' d='M1180 -150 C 1320 190, 1020 460, 1160 790 C 1240 960, 1110 1080, 1170 1180' stroke='%230e4f6e' stroke-width='6'/%3E%3Cg%3E%3Ccircle r='11' fill='%23080b10' stroke='%2322b8cf' stroke-width='3.5'/%3E%3Ccircle r='4' fill='%2322b8cf'/%3E%3CanimateMotion dur='26s' begin='-5s' repeatCount='indefinite'%3E%3Cmpath href='%23p1'/%3E%3C/animateMotion%3E%3C/g%3E%3Cg%3E%3Ccircle r='13' fill='%23080b10' stroke='%231985a1' stroke-width='4'/%3E%3CanimateMotion dur='32s' begin='-14s' repeatCount='indefinite' keyPoints='1;0' keyTimes='0;1' calcMode='linear'%3E%3Cmpath href='%23p2'/%3E%3C/animateMotion%3E%3C/g%3E%3Cg%3E%3Ccircle r='9.5' fill='%23080b10' stroke='%2322b8cf' stroke-width='3'/%3E%3Ccircle r='3.2' fill='%2338bdf8'/%3E%3CanimateMotion dur='29s' begin='-9s' repeatCount='indefinite'%3E%3Cmpath href='%23p3'/%3E%3C/animateMotion%3E%3C/g%3E%3Cg%3E%3Ccircle r='9' fill='%23080b10' stroke='%2322b8cf' stroke-width='3'/%3E%3CanimateMotion dur='22s' begin='-7s' repeatCount='indefinite'%3E%3Cmpath href='%23p4'/%3E%3C/animateMotion%3E%3C/g%3E%3Cg%3E%3Ccircle r='10' fill='%23080b10' stroke='%2338bdf8' stroke-width='2.8'/%3E%3CanimateMotion dur='25s' begin='-12s' repeatCount='indefinite' keyPoints='1;0' keyTimes='0;1' calcMode='linear'%3E%3Cmpath href='%23p5'/%3E%3C/animateMotion%3E%3C/g%3E%3C/g%3E%3C/svg%3E"));
    animation: spiritWeaveDeep 24s ease-in-out infinite alternate;
}

/* Layer 2: Fine Bright Cyan & Ice Spirit Veins + Independent Counter-Traveling Beads */
.spirit-bg::after {
    opacity: 0.28;
    background-image: var(--spirit-svg-fine, url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1600 1000' preserveAspectRatio='xMidYMid slice' fill='none'%3E%3Cg stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath id='f1' d='M-200 320 C 160 470, 520 150, 890 330 C 1240 500, 1480 210, 1800 350' stroke='%2322b8cf' stroke-width='2.2'/%3E%3Cpath id='f2' d='M-200 680 C 190 530, 530 830, 910 660 C 1260 500, 1510 770, 1800 640' stroke='%2338bdf8' stroke-width='1.6'/%3E%3Cpath id='f3' d='M-200 95 C 240 210, 610 -20, 990 110 C 1310 220, 1550 30, 1800 120' stroke='%2322b8cf' stroke-width='1.4'/%3E%3Cpath d='M-200 338 C 160 488, 520 168, 890 348 C 1240 518, 1480 228, 1800 368' stroke='%2367e8f9' stroke-width='0.9' stroke-opacity='0.7'/%3E%3Cpath d='M-200 696 C 190 546, 530 846, 910 676 C 1260 516, 1510 786, 1800 656' stroke='%2322b8cf' stroke-width='1.1' stroke-opacity='0.8'/%3E%3Cpath id='f4' d='M680 -150 C 830 190, 530 520, 700 860 C 770 1000, 660 1100, 710 1180' stroke='%2322b8cf' stroke-width='1.8' stroke-opacity='0.85'/%3E%3Cg%3E%3Ccircle r='7.5' fill='%23080b10' stroke='%2367e8f9' stroke-width='2.2'/%3E%3CanimateMotion dur='19s' begin='-3s' repeatCount='indefinite'%3E%3Cmpath href='%23f1'/%3E%3C/animateMotion%3E%3C/g%3E%3Cg%3E%3Ccircle r='5' fill='%2322b8cf'/%3E%3CanimateMotion dur='23s' begin='-11s' repeatCount='indefinite' keyPoints='1;0' keyTimes='0;1' calcMode='linear'%3E%3Cmpath href='%23f3'/%3E%3C/animateMotion%3E%3C/g%3E%3Cg%3E%3Ccircle r='8.5' fill='%23080b10' stroke='%2322b8cf' stroke-width='2.4'/%3E%3Ccircle r='3' fill='%2367e8f9'/%3E%3CanimateMotion dur='21s' begin='-8s' repeatCount='indefinite' keyPoints='1;0' keyTimes='0;1' calcMode='linear'%3E%3Cmpath href='%23f2'/%3E%3C/animateMotion%3E%3C/g%3E%3Cg%3E%3Ccircle r='5.5' fill='%23080b10' stroke='%2367e8f9' stroke-width='2'/%3E%3CanimateMotion dur='17s' begin='-6s' repeatCount='indefinite'%3E%3Cmpath href='%23f4'/%3E%3C/animateMotion%3E%3C/g%3E%3C/g%3E%3C/svg%3E"));
    animation: spiritWeaveFine 18s ease-in-out infinite alternate;
}

@keyframes spiritWeaveDeep {
    0% {
        transform: translate3d(-3%, -2%, 0) scale(1);
    }
    50% {
        transform: translate3d(2%, 3%, 0) scale(1.04);
    }
    100% {
        transform: translate3d(4%, -2.5%, 0) scale(1.01);
    }
}

@keyframes spiritWeaveFine {
    0% {
        transform: translate3d(4%, 2.5%, 0) scale(1.03);
    }
    50% {
        transform: translate3d(-3%, -2%, 0) scale(1);
    }
    100% {
        transform: translate3d(-4%, 3%, 0) scale(1.05);
    }
}

h1, h2, h3, h4 {
    font-family: var(--font-display);
    color: var(--ink-primary);
    letter-spacing: -0.01em;
}

code, pre, .mono {
    font-family: var(--font-mono);
}

/* Accessible Focus Rings (3:1+ Contrast) */
:focus-visible {
    outline: 2px solid var(--border-focus);
    outline-offset: 2px;
}

/* Scrollbars */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-canvas);
}
::-webkit-scrollbar-thumb {
    background: var(--border-line);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--ink-muted);
}

/* =========================================================
   1. AUTHENTICATION SCREEN
   ========================================================= */
.auth-shell {
    position: relative;
    z-index: 2;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.auth-panel {
    width: 100%;
    max-width: 420px;
    background: rgba(16, 21, 30, 0.76);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: var(--radius-md);
    padding: 36px 32px;
    backdrop-filter: blur(6px) saturate(180%);
    -webkit-backdrop-filter: blur(6px) saturate(180%);
    box-shadow:
        inset 0 1px 0 #ffffff5c,
        0 20px 48px -12px rgba(0, 0, 0, 0.72);
}

body:has(#lg) .auth-panel {
    backdrop-filter: url(#lg) blur(3px) saturate(180%);
}

.brand-mark {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    padding-bottom: 18px;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border-line);
}

.brand-mark h1 {
    font-size: 1.55rem;
    font-weight: 700;
}

.brand-tag {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--accent-cyan);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.or-rule {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 22px 0;
    color: var(--ink-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}
.or-rule::before, .or-rule::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-line);
}

/* =========================================================
   2. MAIN STUDIO SHELL (TOPBAR + WORKSPACE VIEWS)
   ========================================================= */
.studio-shell {
    position: relative;
    z-index: 2;
    display: grid;
    grid-template-rows: 58px minmax(0, 1fr);
    height: 100vh;
    overflow: hidden;
}

.topbar {
    position: relative;
    z-index: 10;
    background: rgba(16, 21, 30, 0.78);
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    backdrop-filter: blur(6px) saturate(180%);
    -webkit-backdrop-filter: blur(6px) saturate(180%);
    box-shadow:
        inset 0 1px 0 #ffffff5c,
        0 8px 24px -8px rgba(0, 0, 0, 0.65);
}

body:has(#lg) .topbar {
    backdrop-filter: url(#lg) blur(3px) saturate(180%);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 24px;
}

.studio-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.15rem;
    color: var(--ink-primary);
}

.studio-logo-dot {
    display: inline-block;
    width: 16px;
    height: 23px;
    flex-shrink: 0;
    transform: translateY(-1px);
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 34' fill='none'%3E%3Cdefs%3E%3ClinearGradient id='ndg' x1='3' y1='4' x2='21' y2='31' gradientUnits='userSpaceOnUse'%3E%3Cstop offset='0%25' stop-color='%2300b4ff'/%3E%3Cstop offset='52%25' stop-color='%230099f7'/%3E%3Cstop offset='100%25' stop-color='%2300e5a3'/%3E%3C/linearGradient%3E%3ClinearGradient id='ndh' x1='5' y1='8' x2='12' y2='29' gradientUnits='userSpaceOnUse'%3E%3Cstop offset='0%25' stop-color='%23ffffff' stop-opacity='0.88'/%3E%3Cstop offset='65%25' stop-color='%23e0f7ff' stop-opacity='0.52'/%3E%3Cstop offset='100%25' stop-color='%23ffffff' stop-opacity='0.0'/%3E%3C/linearGradient%3E%3C/defs%3E%3Cpath d='M13.2 0.8 C12.4 7.6, 17.6 13.8, 20.6 19.6 C22.9 24.1, 21.3 31.8, 12.2 32.8 C3.6 33.6, 0.8 25.8, 3.3 19.2 C5.7 12.8, 11.2 6.8, 13.2 0.8 Z' fill='url(%23ndg)'/%3E%3Cpath d='M11.6 6.8 C9.4 13.0, 4.9 18.2, 4.7 23.6 C4.5 27.6, 7.6 30.2, 10.6 29.3 C13.2 28.5, 13.1 24.2, 11.4 19.8 C9.8 15.6, 10.4 10.9, 11.6 6.8 Z' fill='url(%23ndh)'/%3E%3C/svg%3E");
    filter: drop-shadow(0 0 8px rgba(0, 196, 255, 0.45));
}

.primary-nav {
    position: relative;
    isolation: isolate;
    display: flex;
    align-items: center;
    gap: 4px;
}

.nav-tab {
    position: relative;
    z-index: 1;
    background: transparent;
    border: 1px solid transparent;
    color: var(--ink-secondary);
    padding: 7px 14px;
    border-radius: var(--radius-sm);
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 0.88rem;
    cursor: pointer;
    transition: color 0.18s ease, background 0.15s ease, border-color 0.15s ease;
}

.nav-tab:hover {
    color: var(--ink-primary);
    background: var(--bg-surface);
}

.nav-tab[aria-selected="true"] {
    color: var(--ink-primary);
    background: var(--bg-surface);
    border-color: var(--border-line);
}

/* Zero-JS CSS Anchor Positioning Gliding Navbar Pill */
@supports (anchor-name: --nav-active) {
    .primary-nav {
        anchor-scope: --nav-target;
    }
    .nav-tab:hover,
    .nav-tab[aria-selected="true"] {
        background: transparent;
        border-color: transparent;
    }
    .primary-nav:not(:has(.nav-tab:hover)) .nav-tab[aria-selected="true"],
    .primary-nav .nav-tab:hover {
        anchor-name: --nav-target;
    }
    .primary-nav::before {
        content: '';
        position: absolute;
        z-index: 0;
        position-anchor: --nav-target;
        top: anchor(top);
        bottom: anchor(bottom);
        left: anchor(left);
        right: anchor(right);
        background: var(--bg-surface);
        border: 1px solid var(--border-line);
        border-radius: var(--radius-sm);
        box-shadow:
            inset 0 1px 0 #ffffff33,
            inset 0 -1px 0 #0004,
            0 4px 12px -4px rgba(0, 0, 0, 0.55);
        pointer-events: none;
        transition:
            left 0.24s cubic-bezier(0.22, 1, 0.36, 1),
            right 0.24s cubic-bezier(0.22, 1, 0.36, 1),
            top 0.24s cubic-bezier(0.22, 1, 0.36, 1),
            bottom 0.24s cubic-bezier(0.22, 1, 0.36, 1);
    }
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-pill {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--ink-secondary);
    padding: 5px 10px;
    background: var(--bg-surface);
    border: 1px solid var(--border-line);
    border-radius: var(--radius-sm);
}

/* =========================================================
   3. OVERLAY MANAGER & SCENE EDITOR LAYOUTS
   ========================================================= */
.workspace-view {
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
}

.workspace-view:has(> .overlays-layout) {
    overflow: hidden;
}

.workspace-view[hidden] {
    display: none !important;
}

/* Asymmetric 260px Folder Tree + Main Content Grid */
.overlays-layout {
    display: grid;
    grid-template-columns: 270px minmax(0, 1fr);
    height: 100%;
}

.folder-rail {
    background: var(--bg-panel);
    border-right: 1px solid var(--border-line);
    padding: 18px 14px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow-y: auto;
}

.rail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.rail-title {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--ink-secondary);
    font-weight: 600;
}

.folder-tree {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.folder-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    color: var(--ink-secondary);
    cursor: pointer;
    border: 1px solid transparent;
    font-size: 0.9rem;
}

.folder-item:hover {
    background: var(--bg-surface);
    color: var(--ink-primary);
}

.folder-item.active {
    background: var(--bg-surface);
    color: var(--ink-primary);
    border-color: var(--border-line);
    font-weight: 600;
}

.folder-swatch {
    width: 9px;
    height: 9px;
    border-radius: 2px;
    flex-shrink: 0;
}

.folder-name-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex: 1;
}

.folder-name-wrap span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.folder-count {
    font-family: var(--font-mono);
    font-size: 0.74rem;
    color: var(--ink-muted);
}

/* Main Overlay Deck Area */
.deck-main {
    padding: 24px 28px;
    overflow-y: auto;
    container-type: inline-size;
}

.deck-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding-bottom: 18px;
    margin-bottom: 22px;
    border-bottom: 1px solid var(--border-line);
}

.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
    gap: 16px;
}

@container (max-width: 640px) {
    .cards-grid {
        grid-template-columns: 1fr;
    }
}

.scene-card {
    background: var(--bg-panel);
    border: 1px solid var(--border-line);
    border-radius: var(--radius-md);
    padding: 18px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 16px;
    transition: border-color 0.15s;
}

.scene-card:hover {
    border-color: var(--ink-muted);
}

.scene-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-mono);
    font-size: 0.76rem;
    color: var(--ink-secondary);
    margin-top: 4px;
}

.card-btn-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* =========================================================
   4. FULLSCREEN SCENE & WIDGET EDITOR (3-COLUMN)
   ========================================================= */
.scene-editor-layout {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr) 350px;
    height: 100%;
    background: var(--bg-canvas);
}

.editor-side {
    background: var(--bg-panel);
    border-right: 1px solid var(--border-line);
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.editor-side-right {
    background: var(--bg-panel);
    border-left: 1px solid var(--border-line);
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.panel-head {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.panel-scroll {
    padding: 16px;
    overflow-y: auto;
    flex: 1;
}

.layer-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 9px 10px;
    background: var(--bg-surface);
    border: 1px solid var(--border-line);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    cursor: pointer;
}

.layer-row.selected {
    border-color: var(--border-focus);
}

.canvas-stage-wrap {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    padding: 16px;
    gap: 12px;
}

.stage-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: var(--bg-panel);
    border: 1px solid var(--border-line);
    border-radius: var(--radius-sm);
    padding: 8px 14px;
}

.stage-viewport {
    flex: 1;
    position: relative;
    background-color: #05070a;
    background-image:
        linear-gradient(45deg, #0d121a 25%, transparent 25%),
        linear-gradient(-45deg, #0d121a 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #0d121a 75%),
        linear-gradient(-45deg, transparent 75%, #0d121a 75%);
    background-size: 24px 24px;
    background-position: 0 0, 0 12px, 12px -12px, -12px 0;
    border: 1px solid var(--border-line);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.stage-canvas {
    position: absolute;
    top: 0;
    left: 0;
    transform-origin: top left;
    outline: 1px solid var(--accent-cyan);
    background: transparent;
}

.stage-layer-box {
    position: absolute;
    border: 1px dashed rgba(56, 161, 255, 0.45);
    cursor: move;
    user-select: none;
}

.stage-layer-box.selected {
    border: 2px solid var(--accent-cyan);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.8);
}

.stage-layer-box iframe {
    width: 100%;
    height: 100%;
    border: none;
    pointer-events: none;
    background: transparent;
}

.layer-tag {
    position: absolute;
    top: 0;
    left: 0;
    background: rgba(8, 11, 16, 0.88);
    color: var(--accent-cyan);
    font-family: var(--font-mono);
    font-size: 18px;
    padding: 4px 10px;
    pointer-events: none;
}

/* =========================================================
   5. LOYALTY ENGINE LAYOUT (SIDEBAR SUB-NAV + PANEL)
   ========================================================= */
.loyalty-layout {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    height: 100%;
}

.subnav-btn {
    width: 100%;
    text-align: left;
    background: transparent;
    border: 1px solid transparent;
    color: var(--ink-secondary);
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.subnav-btn:hover {
    background: var(--bg-surface);
    color: var(--ink-primary);
}

.subnav-btn.active {
    background: var(--bg-surface);
    color: var(--ink-primary);
    border-color: var(--border-line);
    font-weight: 600;
}

.split-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
}

.section-block {
    background: var(--bg-panel);
    border: 1px solid var(--border-line);
    border-radius: var(--radius-md);
    padding: 20px;
    margin-bottom: 20px;
}

.section-block h3 {
    font-size: 1.02rem;
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-line);
}

/* Data Tables */
.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.data-table th {
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ink-secondary);
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-line);
}

.data-table td {
    padding: 11px 12px;
    border-bottom: 1px solid var(--border-line);
    font-size: 0.9rem;
}

/* =========================================================
   6. FORMS, INPUTS & BUTTONS (:has() + accent-color)
   ========================================================= */
.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 14px;
}

.field label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--ink-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.field:has(input:focus, select:focus, textarea:focus) > label {
    color: var(--border-focus);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="url"],
select,
textarea {
    width: 100%;
    padding: 9px 12px;
    background: var(--bg-surface);
    border: 1px solid var(--border-line);
    border-radius: var(--radius-sm);
    color: var(--ink-primary);
    font-family: inherit;
    font-size: 0.92rem;
}

input[type="color"] {
    width: 100%;
    height: 38px;
    padding: 2px;
    background: var(--bg-surface);
    border: 1px solid var(--border-line);
    border-radius: var(--radius-sm);
    cursor: pointer;
}

input[type="checkbox"],
input[type="radio"],
input[type="range"] {
    accent-color: var(--accent-cyan);
    cursor: pointer;
}

.check-row {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--ink-primary);
    cursor: pointer;
    font-size: 0.9rem;
    user-select: none;
}

/* Tactile Toggle Switch on Setting Checkboxes (leaves admin-bundle-cb as standard checklist) */
.check-row input[type="checkbox"]:not(.admin-bundle-cb) {
    appearance: none;
    -webkit-appearance: none;
    position: relative;
    width: 38px;
    height: 22px;
    flex-shrink: 0;
    border-radius: 999px;
    background: var(--bg-canvas);
    border: 1px solid var(--border-line);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.55);
    transition: background 0.2s ease, border-color 0.2s ease;
}

.check-row input[type="checkbox"]:not(.admin-bundle-cb)::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #cbd5e1;
    box-shadow:
        inset 0 1px 0 #ffffff80,
        0 2px 4px rgba(0, 0, 0, 0.55);
    transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1), width 0.15s ease, background 0.2s ease;
}

.check-row:active input[type="checkbox"]:not(.admin-bundle-cb)::after {
    width: 19px;
}

.check-row input[type="checkbox"]:not(.admin-bundle-cb):checked {
    background: var(--accent-cyan);
    border-color: var(--accent-cyan);
}

.check-row input[type="checkbox"]:not(.admin-bundle-cb):checked::after {
    background: #ffffff;
    transform: translateX(16px);
}

.check-row:active input[type="checkbox"]:not(.admin-bundle-cb):checked::after {
    transform: translateX(13px);
}

/* Overhead-Lit 4-Layer Buttons + Physical Press State */
.btn {
    --btn-cast: rgba(0, 0, 0, 0.55);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-line);
    background: linear-gradient(180deg, #1d2636 0%, var(--bg-surface) 100%);
    color: var(--ink-primary);
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    text-decoration: none;
    box-shadow:
        inset 0 1px 0 #ffffff59,
        inset 0 -2px 0 #0003,
        0 1px 2px #0006,
        0 8px 24px -6px var(--btn-cast);
    transition:
        background 0.15s ease,
        border-color 0.15s ease,
        transform 0.12s cubic-bezier(0.22, 1, 0.36, 1),
        box-shadow 0.15s ease,
        border-radius 0.2s cubic-bezier(0.22, 1, 0.36, 1),
        padding 0.2s cubic-bezier(0.22, 1, 0.36, 1);
}

.btn:hover {
    background: linear-gradient(180deg, #243044 0%, var(--bg-hover) 100%);
    border-color: var(--ink-muted);
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(1px);
    box-shadow:
        inset 0 2px 4px #0006,
        inset 0 -1px 0 #ffffff22,
        0 1px 1px #0006,
        0 2px 6px -2px var(--btn-cast);
}

.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
}

.btn-primary {
    --btn-cast: rgba(37, 99, 235, 0.5);
    background: linear-gradient(180deg, #3b82f6 0%, var(--accent-blue) 100%);
    border-color: #1d4ed8;
    color: #ffffff;
}
.btn-primary:hover {
    --btn-cast: rgba(59, 130, 246, 0.65);
    background: linear-gradient(180deg, #60a5fa 0%, var(--accent-blue-hover) 100%);
    border-color: var(--accent-blue-hover);
}

.btn-success {
    --btn-cast: rgba(45, 164, 78, 0.48);
    background: linear-gradient(180deg, #3fb950 0%, var(--accent-green) 100%);
    border-color: #238636;
    color: #ffffff;
}
.btn-success:hover {
    --btn-cast: rgba(63, 185, 80, 0.62);
    background: linear-gradient(180deg, #56d364 0%, var(--accent-green-hover) 100%);
    border-color: var(--accent-green-hover);
}

.btn-twitch {
    --btn-cast: rgba(124, 58, 237, 0.52);
    width: 100%;
    padding: 11px 16px;
    background: linear-gradient(180deg, #8b5cf6 0%, var(--accent-twitch) 100%);
    border-color: #6d28d9;
    color: #ffffff;
}
.btn-twitch:hover {
    --btn-cast: rgba(139, 92, 246, 0.68);
    background: linear-gradient(180deg, #9f7aea 0%, #8b5cf6 100%);
    border-color: #8b5cf6;
}

.btn-danger {
    --btn-cast: rgba(218, 54, 51, 0.2);
    background: rgba(218, 54, 51, 0.1);
    border-color: var(--accent-red);
    color: #ff7b72;
}
.btn-danger:hover {
    --btn-cast: rgba(218, 54, 51, 0.52);
    background: linear-gradient(180deg, #f85149 0%, var(--accent-red) 100%);
    border-color: #f85149;
    color: #ffffff;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 0.78rem;
}

/* Squishy Expressive Button Groups */
.btn-group-squishy {
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.btn-group-squishy > .btn {
    border-radius: 4px;
}

.btn-group-squishy > .btn:first-child {
    border-top-left-radius: 10px;
    border-bottom-left-radius: 10px;
}

.btn-group-squishy > .btn:last-child {
    border-top-right-radius: 10px;
    border-bottom-right-radius: 10px;
}

@media (prefers-reduced-motion: no-preference) {
    .btn-group-squishy > .btn:hover {
        padding-inline: 15px;
        border-radius: 10px;
    }
    .btn-group-squishy > .btn:active {
        padding-inline: 17px;
        border-radius: 12px;
    }
}

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    border: 1px solid var(--border-line);
    background: var(--bg-surface);
    color: var(--ink-secondary);
}

.badge-pending {
    border-color: var(--accent-gold);
    color: var(--accent-gold);
}

.badge-live {
    border-color: var(--accent-green);
    color: var(--accent-green-hover);
}

/* =========================================================
   7. NATIVE TOP-LAYER <dialog> MODALS & CODE IDE
   ========================================================= */
dialog.nibi-dialog {
    margin: auto;
    width: min(92vw, 560px);
    max-height: 88vh;
    background: var(--bg-panel);
    color: var(--ink-primary);
    border: 1px solid var(--border-line);
    border-radius: var(--radius-md);
    padding: 0;
}

dialog.nibi-dialog.dialog-wide {
    width: min(95vw, 1080px);
    height: 86vh;
}

dialog.nibi-dialog.modal-xl {
    width: min(95vw, 1160px);
    height: min(88vh, 780px);
    max-height: 90vh;
}

dialog.nibi-dialog[open] {
    display: flex;
    flex-direction: column;
}

dialog.nibi-dialog::backdrop {
    background: rgba(4, 6, 10, 0.78);
}

@media (prefers-reduced-motion: no-preference) {
    dialog.nibi-dialog {
        opacity: 0;
        transform: translateY(8px);
        transition: opacity 0.16s ease, transform 0.16s ease, overlay 0.16s ease, display 0.16s ease;
        transition-behavior: allow-discrete;
    }
    dialog.nibi-dialog[open] {
        opacity: 1;
        transform: translateY(0);
    }
    @starting-style {
        dialog.nibi-dialog[open] {
            opacity: 0;
            transform: translateY(8px);
        }
    }
}

.dialog-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-line);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.dialog-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.dialog-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border-line);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.ide-tabs {
    display: flex;
    gap: 6px;
    border-bottom: 1px solid var(--border-line);
    margin-bottom: 12px;
}

.ide-tab {
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--ink-secondary);
    padding: 8px 14px;
    font-family: var(--font-mono);
    font-size: 0.82rem;
    cursor: pointer;
}

.ide-tab.active {
    color: var(--accent-cyan);
    border-bottom-color: var(--accent-cyan);
}

.CodeMirror {
    height: 100% !important;
    min-height: 380px;
    border: 1px solid var(--border-line);
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 13px;
}

.toast-bar {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    background: rgba(16, 21, 30, 0.82);
    border: 1px solid var(--accent-cyan);
    color: var(--ink-primary);
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    backdrop-filter: blur(6px) saturate(180%);
    -webkit-backdrop-filter: blur(6px) saturate(180%);
    box-shadow:
        inset 0 1px 0 #ffffff5c,
        0 12px 28px -6px rgba(0, 0, 0, 0.7);
}

body:has(#lg) .toast-bar {
    backdrop-filter: url(#lg) blur(3px) saturate(180%);
}

/* =========================================================
   8. WIDGET DIRECTORY TILES & BREADCRUMB BAR
   ========================================================= */
.breadcrumb-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 18px;
    font-family: var(--font-mono);
    font-size: 0.82rem;
    color: var(--ink-secondary);
}

.crumb-btn {
    background: transparent;
    border: 1px solid transparent;
    color: var(--ink-secondary);
    font-family: var(--font-mono);
    font-size: 0.82rem;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.crumb-btn:hover {
    background: var(--bg-surface);
    color: var(--ink-primary);
    border-color: var(--border-line);
}

.crumb-btn.current {
    color: var(--accent-cyan);
    font-weight: 600;
    cursor: default;
}

.dir-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}

.dir-tile {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    background: var(--bg-panel);
    border: 1px solid var(--border-line);
    border-radius: var(--radius-md);
    color: var(--ink-primary);
    text-align: left;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.dir-tile:hover {
    background: var(--bg-surface);
    border-color: var(--border-focus);
}

.dir-tile-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.dir-icon {
    width: 18px;
    height: 18px;
    color: var(--accent-cyan);
    flex-shrink: 0;
}

.dir-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 0.96rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dir-subtext {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--ink-secondary);
}

/* =========================================================
   9. STAGGERED UNFOLDING FAB MENU (popover + @starting-style)
   ========================================================= */
.fab-wrap {
    position: relative;
    display: inline-flex;
}

.fab-trigger {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 999px;
}

.fab-plus {
    display: inline-block;
    font-size: 1.4rem;
    font-weight: 500;
    line-height: 1;
    transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Rotate + into × automatically while the native popover is open */
.fab-wrap:has(:popover-open) .fab-plus {
    transform: rotate(45deg);
}

.fab-menu {
    margin: 0;
    padding: 6px;
    border: none;
    background: transparent;
    overflow: visible;
    position: fixed;
    inset: auto;
    top: calc(anchor(bottom) + 8px);
    right: anchor(right);
}

.fab-menu:popover-open {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
}

.fab-pill {
    border-radius: 999px;
    padding: 9px 16px;
    white-space: nowrap;
}

@media (prefers-reduced-motion: no-preference) {
    .fab-menu {
        transition: overlay 0.28s ease-out, display 0.28s ease-out;
        transition-behavior: allow-discrete;
    }

    .fab-pill {
        opacity: 0;
        translate: 0 -14px;
        scale: 0.84;
        transition:
            opacity 0.2s cubic-bezier(0.22, 1, 0.36, 1),
            translate 0.22s cubic-bezier(0.22, 1, 0.36, 1),
            scale 0.22s cubic-bezier(0.22, 1, 0.36, 1),
            background 0.15s ease,
            border-color 0.15s ease,
            box-shadow 0.15s ease;
    }

    .fab-menu:popover-open .fab-pill {
        opacity: 1;
        translate: 0 0;
        scale: 1;
        transition-delay: calc(var(--i, 0) * 55ms);
    }

    @starting-style {
        .fab-menu:popover-open .fab-pill {
            opacity: 0;
            translate: 0 -14px;
            scale: 0.84;
        }
    }
}

/* =========================================================
   10. VARIABLE ICON AXIS FAVORITE BUTTON (FILL 0 -> FILL 1)
   ========================================================= */
.material-symbols-rounded {
    font-family: 'Material Symbols Rounded';
    font-weight: normal;
    font-style: normal;
    font-size: 20px;
    line-height: 1;
    display: inline-block;
    white-space: nowrap;
    direction: ltr;
    -webkit-font-smoothing: antialiased;
    font-variation-settings: 'FILL' 0, 'wght' 420, 'GRAD' 0, 'opsz' 20;
    transition:
        font-variation-settings 0.24s cubic-bezier(0.22, 1, 0.36, 1),
        transform 0.24s cubic-bezier(0.34, 1.56, 0.64, 1),
        color 0.18s ease;
}

.card-head-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.fav-btn {
    width: 30px;
    height: 30px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-line);
    background: var(--bg-surface);
    color: var(--ink-secondary);
    cursor: pointer;
    box-shadow:
        inset 0 1px 0 #ffffff33,
        inset 0 -1px 0 #0004,
        0 2px 6px -2px rgba(0, 0, 0, 0.5);
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.12s ease;
}

.fav-btn:hover {
    background: var(--bg-hover);
    border-color: var(--ink-muted);
    color: #fda4af;
}

.fav-btn:hover .material-symbols-rounded {
    font-variation-settings: 'FILL' 0, 'wght' 540, 'GRAD' 50, 'opsz' 20;
    transform: scale(1.08);
}

.fav-btn:active {
    transform: translateY(1px);
}

.fav-btn[aria-pressed="true"] {
    background: rgba(244, 63, 94, 0.14);
    border-color: rgba(251, 113, 133, 0.55);
    color: #fb7185;
}

.fav-btn[aria-pressed="true"] .material-symbols-rounded {
    font-variation-settings: 'FILL' 1, 'wght' 600, 'GRAD' 25, 'opsz' 20;
    transform: scale(1.12);
}

.scene-card:has(.fav-btn[aria-pressed="true"]) {
    border-color: rgba(251, 113, 133, 0.38);
}

/* =========================================================
   11. TOP 10 QUICK-ACCESS FAVORITES SHELF (CSS SCROLL SNAP)
   ========================================================= */
.quick-strip {
    margin-bottom: 22px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--border-line);
}

.quick-strip-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.quick-strip-label {
    font-family: var(--font-mono);
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--ink-secondary);
}

.quick-strip-track {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 6px;
    scroll-snap-type: x mandatory;
    overscroll-behavior-x: contain;
}

.quick-chip {
    scroll-snap-align: start;
    flex: 0 0 236px;
    background: var(--bg-panel);
    border: 1px solid var(--border-line);
    border-radius: var(--radius-md);
    padding: 11px 13px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 10px;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.quick-chip:first-child {
    border-color: rgba(34, 184, 207, 0.55);
}

.quick-chip:hover {
    background: var(--bg-surface);
    border-color: var(--border-focus);
}

.quick-chip-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.quick-rank {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--accent-cyan);
    padding: 1px 6px;
    border-radius: 4px;
    background: rgba(34, 184, 207, 0.12);
    border: 1px solid rgba(34, 184, 207, 0.3);
}

.quick-uses {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--ink-muted);
}

.quick-chip-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 0.92rem;
    color: var(--ink-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.quick-chip-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* =========================================================
   12. STANDALONE CUSTOMIZER TEST TRIGGER FAB (⚡)
   ========================================================= */
.fab-trigger-test {
    --btn-cast: rgba(34, 184, 207, 0.45);
    width: 34px;
    height: 34px;
    background: linear-gradient(180deg, #22b8cf 0%, #0e7490 100%);
    border-color: #0891b2;
    color: #ffffff;
}

.fab-trigger-test:hover {
    --btn-cast: rgba(34, 184, 207, 0.65);
    background: linear-gradient(180deg, #38d9a9 0%, #22b8cf 100%);
    border-color: #22b8cf;
}

.fab-bolt {
    display: inline-block;
    font-size: 0.98rem;
    line-height: 1;
    transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.fab-wrap:has(:popover-open) .fab-bolt {
    transform: scale(1.18) rotate(-12deg);
}

.fab-cmd-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px 6px 12px;
    border-radius: 999px;
    background: rgba(16, 21, 30, 0.94);
    border: 1px solid var(--border-line);
    box-shadow:
        inset 0 1px 0 #ffffff33,
        0 10px 24px -6px rgba(0, 0, 0, 0.72);
}

.fab-cmd-bar input {
    width: 155px;
    padding: 5px 8px;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    border-radius: 999px;
}

/* =========================================================
   STOREFRONT & OVERHEAD-LIT PRIMARY ACTION BEVEL
   ========================================================= */
.btn-primary {
    --btn-bg: var(--accent-cyan, #22b8cf);
    color: #061017;
    font-weight: 700;
    border-color: color-mix(in oklab, var(--btn-bg), white 18%);
    background: linear-gradient(
        color-mix(in oklab, var(--btn-bg), white 14%),
        var(--btn-bg)
    );
    box-shadow:
        inset 0 1px 0 #ffffff59,
        inset 0 -2px 0 #0003,
        0 1px 2px #0006,
        0 8px 24px -6px color-mix(in srgb, var(--btn-bg) 55%, transparent);
}

.btn-primary:active {
    translate: 0 1px;
    box-shadow: inset 0 2px 4px #0004;
}

.store-shell {
    max-width: 1160px;
    margin: 0 auto;
    padding-bottom: 64px;
}

.store-header-bar {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    padding-bottom: 18px;
    margin-bottom: 22px;
    border-bottom: 1px solid var(--border-line);
}

.store-catalog-layout {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 18px;
}

.store-pack-row {
    grid-column: span 6;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 16px;
    padding: 22px;
    background: var(--bg-panel);
    border: 1px solid var(--border-line);
    border-radius: var(--radius-md);
}

.store-pack-row.is-featured {
    grid-column: span 12;
    display: grid;
    grid-template-columns: 1.35fr 1fr;
    align-items: center;
    gap: 24px;
    background: linear-gradient(160deg, rgba(17, 25, 36, 0.96), rgba(10, 15, 22, 0.98));
}

.store-price-tag {
    font-family: var(--font-mono);
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--ink-primary);
}

.store-widget-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

.store-chip {
    font-family: var(--font-mono);
    font-size: 0.74rem;
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    border: 1px solid var(--border-line);
    color: var(--ink-secondary);
}

.store-demo-stage {
    position: relative;
    flex: 1;
    min-height: 0;
    width: 100%;
    background-color: #0b0f15;
    background-image:
        linear-gradient(45deg, #131a24 25%, transparent 25%),
        linear-gradient(-45deg, #131a24 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #131a24 75%),
        linear-gradient(-45deg, transparent 75%, #131a24 75%);
    background-size: 24px 24px;
    background-position: 0 0, 0 12px, 12px -12px, -12px 0;
    overflow: hidden;
}

.store-demo-stage iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 1920px;
    height: 1080px;
    border: 0;
    transform-origin: top left;
    pointer-events: none;
}

.preview-fab-dock {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 5;
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
    max-width: min(620px, calc(100% - 28px));
}

@media (max-width: 860px) {
    .store-pack-row,
    .store-pack-row.is-featured {
        grid-column: span 12;
        grid-template-columns: 1fr;
    }
}

dialog.nibi-dialog.modal-checkout {
    margin: auto;
    width: min(640px, 94vw);
    max-height: 90vh;
    padding: 0;
    background: linear-gradient(170deg, #111924 0%, #0a0f16 100%);
    border: 1px solid rgba(34, 184, 207, 0.34);
    border-radius: 16px;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.12),
        0 28px 70px -12px rgba(0, 0, 0, 0.92),
        0 0 42px -14px rgba(34, 184, 207, 0.35);
    color: var(--ink-primary);
    overflow: hidden;
}

dialog.nibi-dialog.modal-checkout::backdrop {
    background: rgba(3, 6, 11, 0.84);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
}

.checkout-modal-header {
    padding: 16px 22px;
    background: rgba(8, 12, 18, 0.75);
    border-bottom: 1px solid rgba(148, 163, 184, 0.14);
}

.checkout-eyebrow {
    display: block;
    font-family: var(--font-mono);
    font-size: 0.68rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent-cyan);
}

.checkout-modal-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 16px;
    scrollbar-width: thin;
    scrollbar-color: rgba(148, 163, 184, 0.28) transparent;
}

.stripe-embedded-mount {
    border-radius: 12px;
    overflow: hidden;
    min-height: 360px;
}

/* =========================================================
   MULTI-ITEM CART, SAPPHIRE CART BUTTON & DYNAMIC BUNDLE UI
   ========================================================= */

.btn-cart {
    --btn-bg: #2563eb;
    color: #f8fafc;
    font-weight: 600;
    border-color: color-mix(in oklab, var(--btn-bg), white 22%);
    background: linear-gradient(
        color-mix(in oklab, var(--btn-bg), white 14%),
        var(--btn-bg)
    );
    box-shadow:
        inset 0 1px 0 #ffffff59,
        inset 0 -2px 0 #0004,
        0 1px 2px #0006,
        0 8px 22px -6px rgba(37, 99, 235, 0.58);
}

.btn-cart:hover {
    --btn-bg: #3b82f6;
    border-color: #60a5fa;
    background: linear-gradient(
        color-mix(in oklab, #3b82f6, white 14%),
        #2563eb
    );
}

.btn-cart:active {
    translate: 0 1px;
    box-shadow: inset 0 2px 4px #0006;
}

.btn-cart.in-cart {
    --btn-bg: #b47b2a;
    color: #fffbeb;
    border-color: #e09f3e;
    background: linear-gradient(
        color-mix(in oklab, #d99535, white 12%),
        #9a671f
    );
    box-shadow:
        inset 0 1px 0 #ffffff55,
        inset 0 -2px 0 #0005,
        0 1px 2px #0006,
        0 8px 20px -6px rgba(224, 159, 62, 0.45);
}

.cart-count-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: rgba(6, 12, 20, 0.65);
    border: 1px solid rgba(255, 255, 255, 0.24);
    font-family: var(--font-mono);
    font-size: 0.73rem;
    font-weight: 700;
    color: #ffffff;
}

.store-price-stack {
    display: flex;
    align-items: baseline;
    gap: 8px;
    white-space: nowrap;
}

.store-price-old {
    font-family: var(--font-mono);
    font-size: 0.92rem;
    color: var(--ink-muted);
    text-decoration: line-through;
}

.bundle-upgrade-callout {
    margin-top: 10px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    background: rgba(34, 184, 207, 0.09);
    border: 1px solid rgba(34, 184, 207, 0.35);
    color: #a5f3fc;
    font-family: var(--font-mono);
    font-size: 0.77rem;
}

dialog.nibi-dialog.modal-cart {
    margin: auto;
    width: min(560px, 94vw);
    max-height: 86vh;
    padding: 0;
    background: linear-gradient(170deg, #111924 0%, #0a0f16 100%);
    border: 1px solid rgba(59, 130, 246, 0.38);
    border-radius: 16px;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.12),
        0 28px 70px -12px rgba(0, 0, 0, 0.92);
    color: var(--ink-primary);
    overflow: hidden;
}

dialog.nibi-dialog.modal-cart::backdrop {
    background: rgba(3, 6, 11, 0.82);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
}

.cart-modal-body {
    flex: 1;
    min-height: 140px;
    max-height: calc(86vh - 150px);
    overflow-y: auto;
    padding: 18px 22px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.cart-line-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    padding: 12px 14px;
    background: var(--bg-surface);
    border: 1px solid var(--border-line);
    border-radius: var(--radius-sm);
}

.cart-smart-banner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    background: rgba(224, 159, 62, 0.11);
    border: 1px solid rgba(224, 159, 62, 0.45);
    font-size: 0.83rem;
    color: #fde68a;
}

.cart-modal-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 22px;
    background: rgba(8, 12, 18, 0.82);
    border-top: 1px solid rgba(148, 163, 184, 0.14);
}

.bundle-parts-drawer {
    grid-column: 1 / -1;
    margin-top: 6px;
    padding-top: 14px;
    border-top: 1px solid var(--border-line);
}

.bundle-parts-drawer summary {
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--ink-primary);
    padding: 6px 2px;
}

.bundle-parts-drawer summary::-webkit-details-marker {
    display: none;
}

.bundle-parts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(255px, 1fr));
    gap: 12px;
    margin-top: 12px;
}

.bundle-part-item {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 12px;
    padding: 14px;
    background: var(--bg-surface);
    border: 1px solid var(--border-line);
    border-radius: var(--radius-sm);
}

.bonus-exclusive-note {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 10px;
    padding: 5px 10px;
    border-radius: var(--radius-sm);
    background: rgba(34, 184, 207, 0.1);
    border: 1px solid rgba(34, 184, 207, 0.32);
    color: var(--accent-cyan);
    font-size: 0.78rem;
    font-weight: 600;
}

/* =========================================================
   3D STOREFRONT RING CAROUSEL (SLOT #1 = NEWEST RELEASE)
   ========================================================= */
.store-carousel-wrap {
    margin-bottom: 34px;
    padding: 20px 16px 24px;
    background: var(--bg-panel);
    border: 1px solid var(--border-line);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.store-carousel-scene {
    perspective: 1180px;
    display: grid;
    place-items: center;
    height: 396px;
    margin: 10px 0 22px;
}

.store-carousel-ring {
    --turn-deg: 0deg;
    position: relative;
    width: min(356px, 80vw);
    height: 354px;
    transform-style: preserve-3d;
    will-change: transform;
    transform: translateZ(calc(var(--r, 260px) * -0.35)) rotateY(var(--turn-deg));
    transition: transform 1.25s cubic-bezier(0.25, 0.1, 0.25, 1);
}

.store-ring-mini-stage {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(148, 163, 184, 0.18);
    background-color: #070a0f;
    background-image:
        linear-gradient(45deg, #101722 25%, transparent 25%),
        linear-gradient(-45deg, #101722 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #101722 75%),
        linear-gradient(-45deg, transparent 75%, #101722 75%);
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0;
    overflow: hidden;
    pointer-events: none;
}

.store-ring-mini-stage iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 1920px;
    height: 1080px;
    border: 0;
    transform-origin: top left;
    pointer-events: none;
}

.store-ring-stage-idle {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--ink-muted);
    letter-spacing: 0.04em;
    background: radial-gradient(circle at 50% 50%, rgba(34, 184, 207, 0.08), rgba(7, 10, 15, 0.85));
}

.store-ring-live-tag {
    position: absolute;
    bottom: 6px;
    left: 8px;
    z-index: 2;
    padding: 2px 7px;
    border-radius: 4px;
    background: rgba(6, 10, 16, 0.82);
    border: 1px solid rgba(34, 184, 207, 0.32);
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--accent-cyan);
    letter-spacing: 0.05em;
}

.store-ring-card {
    position: absolute;
    inset: 0;
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 10px;
    background: linear-gradient(165deg, #0d131c 0%, #070b10 100%);
    border: 1px solid rgba(148, 163, 184, 0.16);
    border-radius: var(--radius-md);
    box-shadow: 0 18px 40px -14px rgba(0, 0, 0, 0.82);
    transform: rotateY(calc(var(--i) * 360deg / var(--n, 1))) translateZ(var(--r, 240px));
    cursor: pointer;
    user-select: none;
    transition: border-color 0.35s ease, box-shadow 0.35s ease, background 0.35s ease;
}

.store-ring-card:not(.is-front) > * {
    filter: brightness(0.62);
    transition: filter 0.85s ease;
}

.store-ring-card.is-front {
    background: linear-gradient(165deg, #15202e 0%, #0c121b 100%);
    border-color: var(--accent-cyan);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.14),
        0 22px 48px -12px rgba(0, 0, 0, 0.9),
        0 0 32px -10px rgba(34, 184, 207, 0.5);
    cursor: default;
}

.store-ring-kicker {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--accent-cyan);
}

.store-carousel-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.store-squishy-nav {
    display: flex;
    gap: 8px;
    width: 240px;
}

.store-squishy-nav button {
    flex: 1;
    height: 38px;
    border-radius: 20px;
    transition:
        flex-grow 0.4s cubic-bezier(0.2, 0, 0, 1),
        border-radius 0.4s cubic-bezier(0.2, 0, 0, 1);
}

.store-squishy-nav button:active {
    flex-grow: 1.5;
    border-radius: 10px;
}

.store-ring-dots {
    display: flex;
    gap: 6px;
    align-items: center;
}

.store-ring-dot {
    width: 8px;
    height: 8px;
    padding: 0;
    border-radius: 999px;
    border: 0;
    background: var(--border-line);
    cursor: pointer;
    transition: width 0.25s ease, background 0.25s ease;
}

.store-ring-dot[aria-selected="true"] {
    width: 22px;
    background: var(--accent-cyan);
}

/* =========================================================
   6-MONTH PROFILE DELETION VAULT & DANGER ZONE
   ========================================================= */
.danger-zone-block {
    border-color: rgba(218, 54, 51, 0.38);
    background: linear-gradient(180deg, rgba(218, 54, 51, 0.06) 0%, var(--bg-panel) 100%);
}

.restore-vault-box {
    margin-top: 16px;
    padding: 14px;
    border-radius: var(--radius-sm);
    background: rgba(224, 159, 62, 0.1);
    border: 1px solid rgba(224, 159, 62, 0.45);
}

.fav-heart-svg {
    width: 17px;
    height: 17px;
    fill: currentColor;
    fill-opacity: 0;
    stroke: currentColor;
    stroke-width: 2;
    transition: fill-opacity 0.24s ease, transform 0.24s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.fav-btn:hover .fav-heart-svg { transform: scale(1.08); }
.fav-btn[aria-pressed="true"] .fav-heart-svg { fill-opacity: 1; transform: scale(1.12); }

.skeleton {
    border-radius: var(--radius-md);
    background: linear-gradient(90deg, #121822 25%, #1c2636 50%, #121822 75%);
    background-size: 200% 100%;
    border: 1px solid var(--border-line);
}
@media (prefers-reduced-motion: no-preference) {
    .skeleton { animation: skeleton-shimmer 1.5s ease-in-out infinite; }
}
@keyframes skeleton-shimmer {
    to { background-position: -200% 0; }
}

.legal-footer-links {
    margin-top: 20px;
    padding-top: 14px;
    border-top: 1px solid var(--border-line);
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 8px;
    font-size: 0.76rem;
    color: var(--ink-muted);
}
.store-legal-bar { margin-top: 36px; }
.legal-link-btn {
    background: none;
    border: none;
    padding: 0;
    color: var(--ink-secondary);
    font: inherit;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 3px;
}
.legal-link-btn:hover { color: var(--accent-cyan); }