/* ============================================================
   SIFOR — Playful Neo-Brutalist Arcade Studio
   ------------------------------------------------------------
   Visual DNA pulled straight from the mascot logo (sifor.png):
   the chunky outlined sticker letterforms + the hot-pink-tongued
   bug. Signature moves used across the whole UI:
     · thick charcoal outlines (--border-ink)
     · HARD offset "sticker" shadows (no blur)
     · a vibrant, cohesive arcade palette used as accent points
     · grain + gradient-mesh background (see .bg-fx)
     · broken-grid, slightly-rotated sticker composition
   Palette anchors:
     charcoal #2D2D2D · hot pink #FF3D85 · sunny yellow #FFD23D
     electric teal #16C7C0 · grape #7B5CFF · lime #A6E22E
   ============================================================ */

:root {
    /* surfaces — warm paper, not flat gray */
    --color-bg: #FBF1E0;
    --color-surface: #FFFFFF;
    --color-surface-2: #FFF6E8;
    --color-surface-3: #FCEAD2;

    /* dividers / hairlines (kept soft so fine details + the
       preview checkerboard stay subtle) */
    --color-border: #ECDAC0;
    --color-border-strong: #2D2D2D;

    /* the thick brutalist outline + the hard-shadow ink */
    --border-ink: #2D2D2D;
    --border-w: 2.5px;

    --color-text: #241F1A;
    --color-text-muted: #6E6056;
    --color-text-soft: #A89784;

    /* primary — the mascot's hot-pink tongue */
    --color-primary: #FF3D85;
    --color-primary-hover: #F51F71;
    --color-primary-ink: #B01453;
    --color-primary-soft: #FFE0EC;

    /* sunny highlight */
    --color-accent: #FFD23D;
    --color-accent-ink: #C79400;
    --color-accent-soft: #FFF1BF;

    /* extended arcade accents (signature color per surface) */
    --color-teal: #12BDB6;
    --color-teal-soft: #CBF4F1;
    --color-grape: #7B5CFF;
    --color-grape-soft: #E6E0FF;
    --color-lime: #8DCB00;
    --color-lime-soft: #ECF8C4;

    --color-success: #15A86A;
    --color-warning: #F0A41B;
    --color-danger: #FF4747;

    /* HARD sticker shadows — the dominant shadow language.
       Legacy --shadow-* names are remapped onto them so every
       existing reference reads as an intentional offset. */
    --shadow-hard-sm: 2px 2px 0 0 var(--border-ink);
    --shadow-hard: 4px 4px 0 0 var(--border-ink);
    --shadow-hard-lg: 7px 7px 0 0 var(--border-ink);
    --shadow-hard-xl: 11px 11px 0 0 var(--border-ink);
    --shadow-pink: 4px 4px 0 0 var(--color-primary-ink);
    --shadow-accent: 4px 4px 0 0 var(--color-accent-ink);

    --shadow-sm: var(--shadow-hard-sm);
    --shadow-md: var(--shadow-hard);
    --shadow-lg: var(--shadow-hard-lg);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --radius-xl: 26px;
    --radius-pill: 999px;

    --font-display: 'Fredoka', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --font-body: 'Hanken Grotesk', system-ui, -apple-system, 'Segoe UI', sans-serif;

    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 24px;
    --space-6: 32px;
    --space-7: 48px;

    --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
    --transition: 200ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

[data-theme="dark"] {
    --color-bg: #131019;
    --color-surface: #1E1B26;
    --color-surface-2: #262130;
    --color-surface-3: #2E2839;

    --color-border: #38323F;
    --color-border-strong: #5A5168;

    /* In the dark, the offset shadow goes pure black (reads against
       the lighter surfaces) and edges are defined by a lit border. */
    --border-ink: #000000;

    --color-text: #F4EFFA;
    --color-text-muted: #B5ADC4;
    --color-text-soft: #7E768C;

    --color-primary: #FF5C9A;
    --color-primary-hover: #FF7DAE;
    --color-primary-ink: #000000;
    --color-primary-soft: rgba(255, 92, 154, 0.18);

    --color-accent: #FFD93D;
    --color-accent-ink: #000000;
    --color-accent-soft: rgba(255, 217, 61, 0.16);

    --color-teal: #2DD6CE;
    --color-teal-soft: rgba(45, 214, 206, 0.16);
    --color-grape: #9B82FF;
    --color-grape-soft: rgba(155, 130, 255, 0.18);
    --color-lime: #B6EB3B;
    --color-lime-soft: rgba(182, 235, 59, 0.16);

    --color-success: #2DD68C;
    --color-warning: #FFB347;
    --color-danger: #FF6B6B;

    --shadow-pink: 4px 4px 0 0 #000000;
    --shadow-accent: 4px 4px 0 0 #000000;
}

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

html, body {
    margin: 0;
    padding: 0;
    background: var(--color-bg);
    color: var(--color-text);
    font-family: var(--font-body);
    font-size: 15.5px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
}

/* ------------ Background FX: gradient mesh + film grain ------------
   .bg-fx is a fixed, non-interactive layer injected just inside
   <body>. Two stacked layers: soft arcade-colored blobs (mesh) and
   an SVG fractal-noise grain that gives the warm paper some tooth. */
.bg-fx {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}
.bg-fx::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(60% 50% at 50% 0%, rgba(255, 255, 255, 0.45), transparent 75%);
}
.bg-fx::after {
    display: none;
}
[data-theme="dark"] .bg-fx::before {
    background:
        radial-gradient(60% 50% at 50% 0%, rgba(148, 163, 184, 0.06), transparent 75%);
}
[data-theme="dark"] .bg-fx::after { display: none; }

h1, h2, h3, h4 {
    font-family: var(--font-display);
    font-weight: 700;
    margin: 0;
    color: var(--color-text);
    letter-spacing: -0.012em;
    line-height: 1.08;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }

::selection { background: var(--color-primary); color: #fff; }

:focus-visible { outline: 3px solid var(--color-grape); outline-offset: 2px; }

/* ------------ Layout ------------ */
.app {
    position: relative;
    z-index: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--space-6) var(--space-5) var(--space-7);
    display: flex;
    flex-direction: column;
    gap: var(--space-6);
    min-height: 100vh;
}
.app:has(.gallery-home:not([hidden])) {
    max-width: 1320px;
}

/* ------------ Entrance reveals (driven by js/sifor-fx.js) ------------
   Elements tagged [data-reveal] start hidden + offset and animate in
   when revealed. If JS / IntersectionObserver never runs, the
   .is-revealed fallback in sifor-fx.js (or reduced-motion) keeps them
   visible — see the no-JS guard below. */
[data-reveal] {
    opacity: 0;
    transform: translateY(26px) scale(0.985);
    will-change: transform, opacity;
}
[data-reveal].is-revealed {
    opacity: 1;
    transform: none;
    transition: opacity 620ms cubic-bezier(0.2, 0.8, 0.2, 1),
                transform 720ms var(--ease-bounce);
}
@media (prefers-reduced-motion: reduce) {
    [data-reveal] { opacity: 1 !important; transform: none !important; }
    .bg-fx::before { animation: none; }
}
/* The reveal end-state uses transform:none, which would flatten the
   signature sticker tilt on these cards — restore it once settled.
   (Higher specificity than [data-reveal].is-revealed, declared later.) */
.hero-card.is-revealed    { transform: rotate(-0.35deg); }
.library-card.is-revealed { transform: rotate(0.3deg); }
@media (prefers-reduced-motion: reduce) {
    .hero-card.is-revealed    { transform: rotate(-0.35deg); }
    .library-card.is-revealed { transform: rotate(0.3deg); }
}

/* ------------ Header ------------ */
.app-header {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    align-items: center;
    gap: var(--space-4);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
}

/* Two brand marks, used as uploaded. Light mode is the wordmark.
   Dark mode is the lockup. */
.logo-for-dark { display: none; }
[data-theme="dark"] .logo-for-light { display: none; }
[data-theme="dark"] .logo-for-dark { display: inline; }

.brand-logo {
    height: auto;
    width: auto;
    max-width: min(210px, 48vw);
    object-fit: contain;
    background: transparent;
    animation: mascot-bob 4s ease-in-out infinite;
    transform-origin: center bottom;
    transition: transform 220ms var(--ease-bounce);
}
.brand-logo.logo-for-light { max-height: clamp(28px, 4vw, 44px); }
.brand-logo.logo-for-dark { max-height: clamp(28px, 4vw, 44px); }
.brand:hover .brand-logo {
    animation-play-state: paused;
    transform: rotate(-4deg) scale(1.06);
}

@keyframes mascot-bob {
    0%, 100% { transform: translateY(0) rotate(-1.5deg); }
    50%      { transform: translateY(-5px) rotate(1.5deg); }
}

.brand-tagline {
    color: var(--color-text-muted);
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 15px;
    justify-self: start;
    letter-spacing: -0.01em;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.brand-tagline-link {
    color: var(--color-primary);
    font-weight: 700;
    text-decoration: none;
    border-bottom: 2px solid transparent;
    transition: border-color var(--transition), color var(--transition);
}

.brand-tagline-link:hover,
.brand-tagline-link:focus-visible {
    color: var(--color-primary-hover);
    border-bottom-color: currentColor;
}

.model-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: 7px 14px;
    background: var(--color-surface);
    border: var(--border-w) solid var(--border-ink);
    border-radius: var(--radius-pill);
    box-shadow: var(--shadow-hard-sm);
    font-family: var(--font-display);
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text);
    white-space: nowrap;
}
.header-chips {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    justify-self: end;
    flex-wrap: wrap;
    position: relative;
    z-index: 3;
}

.model-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--color-success);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-success) 22%, transparent);
    animation: pulse 1.8s ease-in-out infinite;
}

/* ------------ Theme toggle ------------ */
.theme-toggle {
    position: relative;
    top: auto;
    right: auto;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--color-accent);
    border: var(--border-w) solid var(--border-ink);
    box-shadow: var(--shadow-hard-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--border-ink);
    font-size: 18px;
    flex-shrink: 0;
    z-index: 1;
    cursor: pointer;
    transition: transform var(--transition), box-shadow var(--transition), background var(--transition);
}
.theme-toggle:hover {
    transform: translate(-1px, -1px) rotate(-12deg);
    box-shadow: var(--shadow-hard);
    background: var(--color-primary);
    color: #fff;
}
.theme-toggle:active { transform: translate(2px, 2px); box-shadow: none; }
[data-theme="dark"] .theme-toggle { color: #fff; }
[data-theme="light"] .theme-icon-moon { display: none; }
[data-theme="dark"]  .theme-icon-sun  { display: none; }

/* ------------ Hero card ------------ */
.hero-card {
    position: relative;
    background: var(--color-surface);
    border: var(--border-w) solid var(--border-ink);
    border-radius: var(--radius-xl);
    padding: var(--space-6);
    box-shadow: var(--shadow-hard-lg);
    display: flex;
    flex-direction: column;
    gap: var(--space-5);
    transform: rotate(-0.35deg);
}
/* sticker tab — a little colored corner badge that reads as a label
   peeking off the hero card, reinforcing the playful sticker language */
.hero-card::before {
    content: "▶ NEW BUILD";
    position: absolute;
    top: -16px;
    left: 28px;
    padding: 5px 14px;
    background: var(--color-accent);
    color: var(--border-ink);
    border: var(--border-w) solid var(--border-ink);
    border-radius: var(--radius-pill);
    box-shadow: var(--shadow-hard-sm);
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 11px;
    letter-spacing: 0.08em;
    transform: rotate(-2.5deg);
}

.hero-prompt { display: flex; flex-direction: column; gap: var(--space-3); }

/* ------------ Discover suggestion grid ------------ */
.discover-panel {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    padding-bottom: var(--space-2);
    border-bottom: 1px dashed color-mix(in srgb, var(--border-ink) 35%, transparent);
    margin-bottom: var(--space-2);
}
.discover-panel[hidden] { display: none !important; }
.discover-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-3);
    flex-wrap: wrap;
}
.discover-eyebrow {
    margin: 0;
    font-size: 11px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--color-text-soft);
}
.discover-heading {
    margin: 4px 0 0;
    font-family: var(--font-display);
    font-size: clamp(20px, 2.8vw, 28px);
    letter-spacing: -0.02em;
    line-height: 1.1;
}
.discover-sub {
    margin: 6px 0 0;
    color: var(--color-text-soft);
    font-size: 14px;
    max-width: 42ch;
}
.discover-head-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}
.discover-head-actions .btn {
    min-height: 44px;
}
.discover-refresh-meta {
    margin-left: 6px;
    font-size: 12px;
    opacity: 0.75;
}
.discover-status {
    min-height: 1.2em;
    font-size: 13px;
    color: var(--color-text-soft);
}
.discover-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-3);
}
@media (min-width: 900px) {
    .discover-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
.discover-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 0;
    border: var(--border-w) solid var(--border-ink);
    border-radius: var(--radius-lg);
    background: var(--color-surface-2);
    overflow: hidden;
    text-align: left;
    cursor: pointer;
    transition: transform var(--transition), box-shadow var(--transition);
}
.discover-card:hover,
.discover-card:focus-visible {
    transform: translate(-2px, -2px);
    box-shadow: var(--shadow-hard-sm);
    outline: none;
}
.discover-card.is-selected {
    box-shadow: var(--shadow-pink);
    border-color: var(--color-primary);
}
.discover-card-media {
    aspect-ratio: 1;
    background:
        linear-gradient(135deg, color-mix(in srgb, var(--color-primary) 18%, transparent), transparent),
        var(--color-surface);
    position: relative;
    overflow: hidden;
}
.discover-card-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.discover-card-media.is-skeleton::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, color-mix(in srgb, #fff 25%, transparent), transparent);
    animation: discoverShimmer 1.2s infinite;
}
@keyframes discoverShimmer {
    from { transform: translateX(-60%); }
    to { transform: translateX(60%); }
}
.discover-card-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 0 12px 12px;
}
.discover-card-title {
    margin: 0;
    font-family: var(--font-display);
    font-size: 15px;
    line-height: 1.2;
}
.discover-card-tagline {
    margin: 0;
    font-size: 12px;
    color: var(--color-text-soft);
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.discover-verbs {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}
.discover-spec-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}
.discover-spec-chip {
    font-size: 10px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    font-weight: 700;
    padding: 3px 7px;
    border: 1px solid var(--border-ink);
    border-radius: var(--radius-pill);
    background: var(--color-accent);
    color: var(--border-ink);
}
.discover-spec-chip-soft {
    background: transparent;
    color: var(--color-text-soft);
    border-color: color-mix(in srgb, var(--border-ink) 45%, transparent);
    font-weight: 600;
}
.discover-verb {
    font-size: 10px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 3px 7px;
    border: 1px solid color-mix(in srgb, var(--border-ink) 55%, transparent);
    border-radius: var(--radius-pill);
    color: var(--color-text-soft);
}
.discover-make {
    align-self: stretch;
    margin-top: 2px;
}

.hero-label {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(24px, 3.4vw, 34px);
    color: var(--color-text);
    letter-spacing: -0.02em;
    line-height: 1.05;
}
.hero-label::after {
    content: "";
    display: block;
    width: 64px;
    height: 6px;
    margin-top: 10px;
    border-radius: var(--radius-pill);
    background: linear-gradient(90deg, var(--color-primary), var(--color-accent));
}

#userPrompt {
    width: 100%;
    padding: var(--space-4);
    border: var(--border-w) solid var(--border-ink);
    border-radius: var(--radius-lg);
    background: var(--color-surface-2);
    color: var(--color-text);
    font-size: 16px;
    line-height: 1.55;
    resize: vertical;
    min-height: 104px;
    box-shadow: inset 0 2px 0 0 rgba(0,0,0,0.04);
    transition: border-color var(--transition), box-shadow var(--transition), background var(--transition), transform var(--transition);
}

#userPrompt::placeholder { color: var(--color-text-soft); }

#userPrompt:focus {
    outline: none;
    border-color: var(--color-primary);
    background: var(--color-surface);
    box-shadow: var(--shadow-pink);
    transform: translate(-1px, -1px);
}

.hero-actions { display: flex; gap: var(--space-3); flex-wrap: wrap; align-items: center; }

#notifyEmailBtn.is-set,
#createNotifyBtn.is-set {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.notify-modal {
    position: fixed;
    inset: 0;
    z-index: 2100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.notify-modal.is-hidden { display: none; }
.notify-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(6, 8, 16, 0.78);
    backdrop-filter: blur(8px);
}
.notify-modal-card {
    position: relative;
    width: 100%;
    max-width: 440px;
    background: var(--color-surface);
    border: 3px solid var(--border-ink);
    border-radius: var(--radius-xl);
    padding: 24px;
    color: var(--color-text);
    box-shadow: var(--shadow-hard-xl);
    animation: wizardPop 320ms var(--ease-bounce) both;
}
.notify-modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}
.notify-modal-title {
    margin: 0 0 8px;
    font-family: var(--font-display);
    font-size: clamp(22px, 3vw, 28px);
    letter-spacing: -0.02em;
    line-height: 1.1;
}
.notify-modal-lead {
    margin: 0;
    color: var(--color-text-muted);
    font-size: 15px;
    line-height: 1.45;
}
.notify-email-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--color-text-soft);
    margin-bottom: 6px;
}
.notify-modal-card input[type="email"] {
    width: 100%;
    padding: 12px 14px;
    border: var(--border-w) solid var(--border-ink);
    border-radius: var(--radius-md);
    background: var(--color-surface-2);
    color: var(--color-text);
    font-size: 16px;
    box-shadow: inset 0 2px 0 0 rgba(0,0,0,0.04);
}
.notify-modal-card input[type="email"]:focus {
    outline: none;
    border-color: var(--color-primary);
    background: var(--color-surface);
    box-shadow: var(--shadow-pink);
}
.notify-modal-hint {
    margin: 8px 0 0;
    font-size: 13px;
    color: var(--color-text-soft);
}
.notify-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 18px;
    flex-wrap: wrap;
}

/* Build-issue modal — retry / fix API keys when generation stops */
.build-issue-modal {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.build-issue-modal.is-hidden { display: none; }
.build-issue-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(6, 8, 16, 0.82);
    backdrop-filter: blur(8px);
}
.build-issue-card {
    position: relative;
    width: 100%;
    max-width: 480px;
    background: var(--color-surface);
    border: 3px solid var(--border-ink);
    border-radius: var(--radius-xl);
    padding: 24px;
    color: var(--color-text);
    box-shadow: var(--shadow-hard-xl);
    animation: wizardPop 320ms var(--ease-bounce) both;
}
.build-issue-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}
.build-issue-kicker {
    margin: 0 0 4px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--color-warning, #d97706);
}
.build-issue-title {
    margin: 0;
    font-size: 1.35rem;
    line-height: 1.25;
}
.build-issue-lead {
    margin: 0 0 12px;
    font-size: 0.95rem;
    line-height: 1.55;
    opacity: 0.92;
}
.build-issue-steps {
    margin: 0 0 14px;
    padding-left: 1.2rem;
    font-size: 0.9rem;
    line-height: 1.5;
}
.build-issue-steps li { margin-bottom: 6px; }
.build-issue-detail {
    margin: 0 0 14px;
    font-size: 0.78rem;
    line-height: 1.45;
    word-break: break-word;
    max-height: 4.5em;
    overflow: auto;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.build-issue-footer {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 8px;
}

.timeline-recovery {
    margin-top: 12px;
    padding: 12px;
    border: 2px dashed var(--border-ink);
    border-radius: var(--radius-md, 10px);
    background: color-mix(in srgb, var(--color-warning, #d97706) 8%, transparent);
}
.timeline-recovery.is-hidden { display: none !important; }
.timeline-recovery-msg {
    margin: 0 0 10px;
    font-size: 0.85rem;
    line-height: 1.4;
}
.timeline-recovery-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.hive-retry-bar {
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 14px;
    border-top: 2px solid var(--border-ink);
    background: color-mix(in srgb, var(--color-danger, #dc2626) 10%, transparent);
}
.hive-retry-bar.is-visible { display: flex; }
.hive-retry-bar-msg {
    font-size: 0.85rem;
    line-height: 1.35;
    flex: 1;
}
.hive-retry-bar-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.admin-brand-logo {
    height: auto;
    width: auto;
    max-height: 44px;
    max-width: 190px;
    object-fit: contain;
    vertical-align: middle;
    margin-right: 8px;
    background: transparent;
}
.admin-brand-logo.logo-for-light { max-height: 44px; }
.admin-brand-logo.logo-for-dark { max-height: 44px; }

/* ------------ Buttons ------------ */
/* All buttons share the sticker language: thick ink outline + a hard
   offset shadow that collapses on press, so every click feels tactile.
   Magnetic translate is layered on by js/sifor-fx.js via a transform on
   a wrapper, so the press transition here stays conflict-free. */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: 11px 20px;
    border-radius: var(--radius-md);
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 14px;
    border: var(--border-w) solid var(--border-ink);
    background: var(--color-surface);
    color: var(--color-text);
    box-shadow: var(--shadow-hard-sm);
    transition: transform 130ms var(--ease-bounce), box-shadow 130ms ease, background var(--transition), border-color var(--transition), color var(--transition);
    white-space: nowrap;
}
.btn:hover:not(:disabled) { transform: translate(-2px, -2px); box-shadow: var(--shadow-hard); }
.btn:active:not(:disabled) { transform: translate(2px, 2px); box-shadow: none; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; box-shadow: none !important; }
.btn[hidden] { display: none !important; }

.btn-primary {
    background: var(--color-primary);
    color: #FFFFFF;
    box-shadow: var(--shadow-pink);
}
.btn-primary:hover:not(:disabled) { background: var(--color-primary-hover); transform: translate(-2px, -2px); box-shadow: 6px 6px 0 0 var(--color-primary-ink); }
.btn-primary:active:not(:disabled) { transform: translate(2px, 2px); box-shadow: none; }

.btn-lg { padding: 15px 26px; font-size: 16px; border-radius: var(--radius-lg); border-width: 3px; }

.btn-ghost {
    background: transparent;
    color: var(--color-text-muted);
    border-color: var(--border-ink);
    box-shadow: none;
}
.btn-ghost:hover:not(:disabled) { color: var(--border-ink); background: var(--color-surface-2); box-shadow: var(--shadow-hard-sm); transform: translate(-1px, -1px); }
[data-theme="dark"] .btn-ghost:hover:not(:disabled) { color: var(--color-text); }

.btn-soft {
    background: var(--color-surface-2);
    color: var(--color-text);
    border-color: var(--border-ink);
}
.btn-soft:hover:not(:disabled) {
    color: var(--color-primary);
    background: var(--color-primary-soft);
}

.btn-accent {
    background: var(--color-accent);
    color: var(--border-ink);
    border-color: var(--border-ink);
    box-shadow: var(--shadow-accent);
}
.btn-accent:hover:not(:disabled) { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 0 var(--color-accent-ink); }
.btn-accent:active:not(:disabled) { transform: translate(2px, 2px); box-shadow: none; }
[data-theme="dark"] .btn-accent { color: var(--border-ink); }

.btn-secondary {
    background: var(--color-teal);
    color: var(--border-ink);
    border-color: var(--border-ink);
}
.btn-secondary:hover:not(:disabled) { transform: translate(-2px, -2px); box-shadow: var(--shadow-hard); filter: brightness(1.04); }

/*
 * .btn-danger — used by the Cancel-build button. Kept clearly secondary
 * to the primary Generate button: a soft red fill, lighter shadow.
 */
.btn-danger {
    background: color-mix(in srgb, var(--color-danger) 16%, var(--color-surface));
    color: #B0231F;
    border-color: var(--border-ink);
}
.btn-danger:hover:not(:disabled) {
    background: color-mix(in srgb, var(--color-danger) 26%, var(--color-surface));
    color: #8E1A17;
    transform: translate(-2px, -2px);
    box-shadow: var(--shadow-hard);
}
[data-theme="dark"] .btn-danger {
    background: rgba(255, 107, 107, 0.18);
    color: #FFC4C4;
}
[data-theme="dark"] .btn-danger:hover:not(:disabled) {
    background: rgba(255, 107, 107, 0.28);
    color: #FFE0E0;
}

/*
 * Generic visibility helper used by the Cancel button (and any future
 * "show only while busy" controls). Kept here so script.js can toggle
 * a class instead of touching .style.display directly — the latter
 * blows away CSS-defined display-modes (flex/inline-flex) on toggle.
 */
.is-hidden { display: none !important; }

.btn-spinner {
    display: none;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255,255,255,0.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
.btn.is-loading .btn-spinner { display: inline-block; }
.btn.is-loading .btn-label    { opacity: 0.85; }

@keyframes spin { to { transform: rotate(360deg); } }

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    border: 2px solid var(--border-ink);
    box-shadow: var(--shadow-hard-sm);
    color: var(--color-text);
    font-size: 16px;
    transition: transform 130ms var(--ease-bounce), box-shadow 130ms ease, color var(--transition), background var(--transition);
}
.icon-btn:hover { color: var(--color-primary); background: var(--color-primary-soft); transform: translate(-1px, -1px); box-shadow: var(--shadow-hard); }
.icon-btn:active { transform: translate(1px, 1px); box-shadow: none; }

/* ------------ Studio settings ------------ */
.studio-settings {
    border-top: 2.5px dashed var(--color-border-strong);
    padding-top: var(--space-5);
}

.studio-settings > summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    list-style: none;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 17px;
    color: var(--color-text);
    padding: var(--space-2) 0;
    letter-spacing: -0.01em;
}
.studio-settings > summary::-webkit-details-marker { display: none; }
.settings-title { display: inline-flex; align-items: center; gap: var(--space-2); }
.settings-title::before {
    content: "";
    width: 14px;
    height: 14px;
    border-radius: 4px;
    background: var(--color-teal);
    border: 2px solid var(--border-ink);
    transform: rotate(-8deg);
}
.api-keys-settings .settings-title::before { background: var(--color-grape); }
.settings-chevron {
    transition: transform var(--transition);
    color: var(--color-text);
    width: 26px; height: 26px;
    display: inline-flex; align-items: center; justify-content: center;
    border: 2px solid var(--border-ink);
    border-radius: 50%;
    background: var(--color-surface-2);
    font-size: 12px;
}
.studio-settings[open] .settings-chevron { transform: rotate(180deg); background: var(--color-accent); }

.settings-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-5);
    margin-top: var(--space-4);
}

.setting { display: flex; flex-direction: column; gap: var(--space-2); }
.setting-wide { grid-column: 1 / -1; }
.setting-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-family: var(--font-display);
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.07em;
}
.setting-value {
    background: var(--color-primary);
    color: #fff;
    padding: 2px 12px;
    border: 2px solid var(--border-ink);
    border-radius: var(--radius-pill);
    font-family: var(--font-display);
    font-size: 13px;
    text-transform: none;
    letter-spacing: 0;
}
.setting-label-link, .setting-label a {
    color: var(--color-primary);
    font-weight: 700;
    text-transform: none;
    letter-spacing: 0;
}
.setting-hint { margin: 0; color: var(--color-text-soft); font-size: 12px; }
.setting-hint code { font-size: 11px; background: var(--color-surface-2); border: 1px solid var(--color-border); padding: 2px 6px; border-radius: 4px; }

.platform-key-input {
    width: 100%;
    padding: 11px var(--space-3);
    border: var(--border-w) solid var(--border-ink);
    border-radius: var(--radius-md);
    background: var(--color-surface-2);
    transition: border-color var(--transition), box-shadow var(--transition), background var(--transition), transform var(--transition);
}
.platform-key-input::placeholder { color: var(--color-text-soft); }
.platform-key-input:focus {
    outline: none;
    border-color: var(--color-primary);
    background: var(--color-surface);
    box-shadow: var(--shadow-pink);
    transform: translate(-1px, -1px);
}

/*
 * Masked-secret pattern (used for API keys).
 *
 * We render API keys as plain <input type="text"> (so Chrome doesn't treat the
 * panel as a credentials form and emit DOM warnings about missing username
 * fields / multiple forms), then visually mask the characters with
 * -webkit-text-security. A toggle flips the class on/off to reveal the value.
 *
 * Firefox doesn't support -webkit-text-security, so we fall back to a
 * monospace bullet character via letter-shaping. If a user really needs
 * masking on Firefox they can click "Hide" — the value still won't be saved
 * anywhere by the browser because autocomplete is off and 1Password / LastPass
 * are opted out via data-*-ignore attributes.
 */
.secret-row .secret-input-wrap {
    position: relative;
    display: flex;
    align-items: stretch;
    width: 100%;
}

/*
 * "Saved on server" pill, injected by renderKeyInputBadges() next to each
 * key input the platform_settings endpoint reports as configured. It's the
 * visual fix for the "I saved the key but the field is empty after reload,
 * do I need to enter it again?" UX trap: the inputs intentionally clear on
 * save (so they don't echo secrets back into the DOM), but the server still
 * holds the value — this pill makes that obvious at a glance.
 */
.key-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 6px;
    padding: 3px 10px;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.6;
    color: #0d6b42;
    background: var(--color-lime-soft);
    border: 2px solid var(--border-ink);
    border-radius: 999px;
    letter-spacing: 0.02em;
    width: fit-content;
}
:root[data-theme="dark"] .key-status-badge {
    color: #6fd7a3;
    background: rgba(111, 215, 163, 0.12);
    border-color: rgba(111, 215, 163, 0.28);
}
.secret-row .platform-key-input.is-secret {
    flex: 1 1 auto;
    padding-right: 64px;
    font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
    letter-spacing: 0.05em;
    -webkit-text-security: disc;
}
.secret-row .platform-key-input.is-secret.is-revealed {
    -webkit-text-security: none;
    letter-spacing: 0;
}
.secret-row .platform-key-input.is-secret::placeholder {
    -webkit-text-security: none;
    letter-spacing: 0;
    font-family: inherit;
}
.secret-toggle {
    position: absolute;
    top: 50%;
    right: 7px;
    transform: translateY(-50%);
    padding: 5px 10px;
    border: 2px solid var(--border-ink);
    border-radius: var(--radius-sm, 6px);
    background: var(--color-surface);
    color: var(--color-text-muted);
    font-family: var(--font-display);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    cursor: pointer;
    transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.secret-toggle:hover {
    background: var(--color-surface-2);
    color: var(--color-text);
}
.secret-toggle:focus-visible {
    outline: 3px solid var(--color-grape);
    outline-offset: 2px;
}
.secret-toggle.is-active {
    background: var(--color-primary);
    color: #fff;
}

.api-keys-actions {
    margin-top: var(--space-4);
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    align-items: center;
}

#platformKeySummary strong { color: var(--color-text-muted); font-weight: 700; }

.ephemeral-storage-warn {
    margin-top: var(--space-3);
    padding: var(--space-3) var(--space-4);
    background: color-mix(in srgb, var(--color-warning, #d4a017) 12%, transparent);
    border-left: 3px solid var(--color-warning, #d4a017);
    border-radius: var(--radius-sm, 6px);
    font-size: 0.82rem;
    line-height: 1.6;
}
.ephemeral-storage-warn strong { color: var(--color-text); display: block; margin-bottom: 4px; }
.ephemeral-storage-warn a {
    color: var(--color-primary);
    font-weight: 700;
    text-decoration: none;
}
.ephemeral-storage-warn a:hover { text-decoration: underline; }

#openrouterTestResult {
    margin-top: var(--space-3);
    padding: var(--space-4);
    background: var(--color-surface-2);
    border: var(--border-w) solid var(--border-ink);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-hard-sm);
    font-size: 0.82rem;
    line-height: 1.6;
    display: grid;
    gap: 6px;
}
#openrouterTestResult .or-test-headline {
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 2px;
}
#openrouterTestResult .or-test-ok  { color: var(--color-success); }
#openrouterTestResult .or-test-bad { color: var(--color-danger);  }
#openrouterTestResult .or-test-hint {
    color: var(--color-text);
    background: color-mix(in srgb, var(--color-danger) 8%, transparent);
    border-left: 3px solid var(--color-danger);
    padding: 6px 10px;
    border-radius: var(--radius-sm, 6px);
}
#openrouterTestResult .or-test-hint-info {
    background: color-mix(in srgb, var(--color-primary) 8%, transparent);
    border-left-color: var(--color-primary);
}
#openrouterTestResult .or-test-hint-warn {
    background: color-mix(in srgb, var(--color-warning, #d4a017) 12%, transparent);
    border-left-color: var(--color-warning, #d4a017);
}
#openrouterTestResult .or-test-probe code {
    font-size: 0.78rem;
}
.dashboard-usage-input {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    color: var(--color-text-muted);
    margin-left: var(--space-3);
}
.dashboard-usage-input input {
    width: 90px;
    padding: 4px 8px;
    border: 1px solid var(--color-border);
    background: var(--color-surface-2, rgba(255,255,255,0.04));
    color: var(--color-text);
    border-radius: var(--radius-sm, 6px);
    font: inherit;
    font-size: 0.8rem;
}
.dashboard-usage-input input:focus {
    outline: none;
    border-color: var(--color-primary);
}
#openrouterTestResult .or-test-cta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: 2px 0;
}
#openrouterTestResult .or-test-cta a {
    color: var(--color-primary);
    font-weight: 700;
    text-decoration: none;
}
#openrouterTestResult .or-test-cta a:hover { text-decoration: underline; }
#openrouterTestResult .or-test-row {
    display: flex;
    gap: 8px;
    align-items: baseline;
    flex-wrap: wrap;
}
#openrouterTestResult .or-test-label {
    min-width: 64px;
    color: var(--color-text-muted);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.04em;
}
#openrouterTestResult .or-test-muted { color: var(--color-text-muted); }
#openrouterTestResult .or-test-good  { color: var(--color-success); }
#openrouterTestResult code {
    background: var(--color-surface-2, rgba(255,255,255,0.04));
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 0.78rem;
}
#openrouterTestResult .or-test-details {
    margin-top: 4px;
    font-size: 0.78rem;
}
#openrouterTestResult .or-test-details summary {
    cursor: pointer;
    color: var(--color-text-muted);
    user-select: none;
}
#openrouterTestResult .or-test-details pre {
    margin: 6px 0 0;
    padding: 8px 10px;
    background: var(--color-surface-2, rgba(255,255,255,0.04));
    border-radius: var(--radius-sm, 6px);
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-word;
}
#openrouterTestResult .or-test-chips { flex-wrap: wrap; }
#openrouterTestResult .or-test-chip {
    appearance: none;
    border: 1px solid var(--color-border);
    background: var(--color-surface-2, rgba(255,255,255,0.04));
    color: var(--color-text);
    padding: 3px 9px;
    border-radius: var(--radius-pill, 999px);
    font: inherit;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all var(--transition, 0.15s ease);
}
#openrouterTestResult .or-test-chip:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

/* Pill toggle (radio-as-pill) */
.pill-group { display: inline-flex; flex-wrap: wrap; gap: 4px; background: var(--color-surface-2); padding: 4px; border-radius: var(--radius-pill); border: var(--border-w) solid var(--border-ink); width: fit-content; max-width: 100%; }
.pill { position: relative; display: inline-flex; cursor: pointer; }
.pill input {
    position: absolute;
    opacity: 0;
    inset: 0;
    margin: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
    z-index: 1; /* sit above the label span so clicks always hit the radio */
}
.pill span {
    display: inline-flex;
    align-items: center;
    padding: 7px 16px;
    border-radius: var(--radius-pill);
    font-family: var(--font-display);
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-muted);
    transition: all var(--transition);
    pointer-events: none; /* clicks pass through to the radio input */
}
.pill:hover span { color: var(--color-text); }
.pill input:checked + span {
    background: var(--color-primary);
    color: #fff;
    box-shadow: 2px 2px 0 0 var(--border-ink);
}
.pill input:focus-visible + span { outline: 3px solid var(--color-grape); outline-offset: 2px; }

/* Chip group for art styles */
.chip-group { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.chip { position: relative; cursor: pointer; }
.chip input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.chip span {
    display: inline-flex;
    align-items: center;
    padding: 8px 15px;
    background: var(--color-surface);
    border: 2px solid var(--border-ink);
    border-radius: var(--radius-pill);
    font-family: var(--font-display);
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-muted);
    transition: transform var(--transition), background var(--transition), color var(--transition), box-shadow var(--transition);
}
.chip:hover span { color: var(--color-text); transform: translateY(-2px); box-shadow: var(--shadow-hard-sm); }
.chip input:checked + span {
    background: var(--color-primary);
    color: #fff;
    box-shadow: 2px 2px 0 0 var(--border-ink);
}
.chip input:focus-visible + span { outline: 3px solid var(--color-grape); outline-offset: 2px; }

/* Select */
.select-wrapper { position: relative; }
.select-wrapper::after {
    content: "▾";
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-text);
    pointer-events: none;
    font-size: 12px;
}
.select {
    width: 100%;
    padding: 11px 38px 11px 14px;
    background: var(--color-surface-2);
    border: var(--border-w) solid var(--border-ink);
    border-radius: var(--radius-md);
    color: var(--color-text);
    appearance: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.select:focus { outline: none; border-color: var(--color-primary); box-shadow: var(--shadow-pink); }

/* Slider */
.slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 10px;
    background: var(--color-surface-2);
    border: 2px solid var(--border-ink);
    border-radius: var(--radius-pill);
    outline: none;
    margin: 10px 0;
}
.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--color-primary);
    border: 2.5px solid var(--border-ink);
    cursor: pointer;
    box-shadow: 2px 2px 0 0 var(--border-ink);
    transition: transform var(--transition);
}
.slider::-webkit-slider-thumb:hover { transform: scale(1.12) rotate(-8deg); }
.slider::-moz-range-thumb {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--color-primary);
    border: 2.5px solid var(--border-ink);
    cursor: pointer;
    box-shadow: 2px 2px 0 0 var(--border-ink);
}

/* ------------ Workspace ------------ */
.workspace { display: block; }
.workspace[hidden] { display: none; }

/* Studio view wrapper (prompt + settings + library + workspace) — the
   generator, hidden behind the "Create" nav chip until the visitor opts
   in from the gallery landing view. See AppView in script.js. */
.studio-view { display: flex; flex-direction: column; gap: var(--space-6); }
.studio-view[hidden] { display: none; }

/* Reveal animation applied by js/sifor-fx.js when the build workspace
   first appears (and replays on each new build). */
.workspace.ws-reveal { animation: wsReveal 560ms var(--ease-bounce) both; }
@keyframes wsReveal {
    from { opacity: 0; transform: translateY(28px) scale(0.99); }
    to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
    .workspace.ws-reveal { animation: none; }
}

.workspace-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
    gap: var(--space-5);
    align-items: start;
}

/* Preview panel */
.preview-panel {
    background: var(--color-surface);
    border: var(--border-w) solid var(--border-ink);
    border-radius: var(--radius-xl);
    overflow: hidden;
    box-shadow: var(--shadow-hard-lg);
    display: flex;
    flex-direction: column;
}

.preview-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-3) var(--space-4);
    border-bottom: 2.5px solid var(--border-ink);
    background: var(--color-surface-2);
    gap: var(--space-3);
}

.preview-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.preview-title {
    font-family: var(--font-display);
    font-weight: 700;
    color: var(--color-text);
    font-size: 16px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.preview-iteration {
    font-family: var(--font-display);
    font-size: 12px;
    color: #fff;
    background: var(--color-primary);
    font-weight: 600;
    padding: 1px 9px;
    border: 1.5px solid var(--border-ink);
    border-radius: var(--radius-pill);
    width: fit-content;
}

.preview-tools { display: inline-flex; gap: var(--space-2); flex-shrink: 0; }

.preview-frame {
    position: relative;
    width: min(100%, calc(min(72vh, 844px) * 390 / 844));
    aspect-ratio: 390 / 844;
    max-height: min(72vh, 844px);
    margin: var(--space-4) auto;
    background: var(--color-surface-2);
    background-image:
        linear-gradient(45deg, var(--color-border) 25%, transparent 25%),
        linear-gradient(-45deg, var(--color-border) 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, var(--color-border) 75%),
        linear-gradient(-45deg, transparent 75%, var(--color-border) 75%);
    background-size: 22px 22px;
    background-position: 0 0, 0 11px, 11px -11px, -11px 0;
}

#gameFrame {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
    background: #000;
    display: none;
}
.preview-frame.has-game #gameFrame { display: block; }
.preview-frame.has-game .preview-empty { display: none; }

.preview-enhancing-banner {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 4;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: rgba(18, 16, 22, 0.9);
    color: #fff;
    font-weight: 700;
    font-size: 13px;
    pointer-events: none;
}
.preview-frame.is-enhancing .preview-enhancing-banner { display: flex; }
.preview-enhancing-spin {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    border: 2px solid rgba(255, 255, 255, 0.28);
    border-top-color: var(--color-primary, #ff4d9a);
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
}

.preview-empty {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-3);
    color: var(--color-text-muted);
    font-family: var(--font-display);
    font-weight: 600;
    text-align: center;
    padding: var(--space-4);
}
.preview-mascot {
    height: auto;
    background: transparent;
    animation: mascot-bob 3.6s ease-in-out infinite;
}
.preview-mascot.logo-for-light { width: min(280px, 78%); }
.preview-mascot.logo-for-dark { width: min(280px, 78%); }

/* Side panel */
.side-panel {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    min-width: 0;
}

.timeline-card,
.assets-card,
.refine-card,
.feedback-card {
    background: var(--color-surface);
    border: var(--border-w) solid var(--border-ink);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    box-shadow: var(--shadow-hard);
}
/* signature accent stripe per side card */
.timeline-card  { border-top: 6px solid var(--color-teal); }
.assets-card    { border-top: 6px solid var(--color-grape); }
.refine-card    { border-top: 6px solid var(--color-primary); }
.feedback-card  { border-top: 6px solid var(--color-accent); }

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-3);
}
.card-header h3 {
    font-family: var(--font-display);
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--color-text);
    font-weight: 700;
}
.muted { color: var(--color-text-soft); font-size: 12px; }

/* Right-aligned cluster in a card header (e.g. credits chip + slot count). */
.card-header-meta {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
    justify-content: flex-end;
}

/* Estimated Ludo.ai credit spend chip shown after a build. */
.ludo-credits {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 8px 3px 4px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--color-grape) 14%, transparent);
    border: 1.5px solid var(--border-ink);
    color: var(--color-text);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.02em;
    white-space: nowrap;
    cursor: help;
}
.ludo-credits[hidden] { display: none; }
.ludo-credits .ludo-badge-inline { flex: 0 0 auto; }
.timeline-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-display);
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-muted);
}
.timeline-status::before {
    content: "";
    width: 9px; height: 9px;
    border-radius: 50%;
    border: 1.5px solid var(--border-ink);
    background: var(--color-text-soft);
}
.timeline-status.is-active::before { background: var(--color-primary); animation: pulse 1.4s ease-in-out infinite; }
.timeline-status.is-done::before   { background: var(--color-success); }
.timeline-status.is-error::before  { background: var(--color-danger); }

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--color-primary) 50%, transparent); }
    50%      { box-shadow: 0 0 0 7px transparent; }
}

/* Timeline */
.timeline {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0;
}
.timeline-step {
    position: relative;
    padding: var(--space-2) 0 var(--space-2) 28px;
    color: var(--color-text-muted);
    font-size: 13px;
    line-height: 1.5;
}
.timeline-step::before {
    content: "";
    position: absolute;
    left: 7px;
    top: 16px;
    bottom: -2px;
    width: 2px;
    background: var(--color-border);
}
.timeline-step:last-child::before { display: none; }
.timeline-step::after {
    content: "";
    position: absolute;
    left: 0;
    top: 10px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid var(--color-border-strong);
    background: var(--color-surface);
}
.timeline-step.is-active {
    color: var(--color-text);
    font-weight: 600;
}
.timeline-step.is-active::after {
    border-color: var(--color-primary);
    background: var(--color-primary);
    box-shadow: 0 0 0 4px var(--color-primary-soft);
}
.timeline-step.is-done {
    color: var(--color-text);
}
.timeline-step.is-done::after {
    border-color: var(--color-success);
    background: var(--color-success);
}
.timeline-step.is-error::after {
    border-color: var(--color-danger);
    background: var(--color-danger);
}

.step-title { font-weight: 600; font-family: var(--font-display); color: inherit; }
.step-detail { display: block; color: var(--color-text-soft); font-size: 12px; margin-top: 2px; }

.timeline-progress {
    height: 12px;
    background: var(--color-surface-2);
    border: 2px solid var(--border-ink);
    border-radius: var(--radius-pill);
    overflow: hidden;
    margin-top: var(--space-3);
}
.timeline-progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--color-primary), var(--color-accent));
    transition: width 250ms ease;
}

/* Busy state while the blocking POST runs (server has gameId client doesn’t yet) */
.timeline-progress.indeterminate .timeline-progress-bar {
    width: 32% !important;
    animation: timeline-indeterminate 1.35s ease-in-out infinite alternate;
    transition: none;
}
@keyframes timeline-indeterminate {
    0%   { transform: translateX(-5%); opacity: 0.85; }
    100% { transform: translateX(218%); opacity: 1; }
}

/* Add art & audio — on-demand asset CTA */
.assets-hint {
    margin: 0 0 var(--space-3);
    font-size: 12px;
    line-height: 1.5;
}
.assets-actions {
    margin-bottom: var(--space-3);
}
.assets-actions .btn {
    width: 100%;
    justify-content: center;
}
.ludo-badge-inline {
    position: static;
    vertical-align: middle;
}

/* Assets grid */
.asset-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-2);
}
.asset-thumb {
    position: relative;
    aspect-ratio: 1;
    background: var(--color-surface-2);
    border: 2px solid var(--border-ink);
    border-radius: var(--radius-sm);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform var(--transition), box-shadow var(--transition);
}
.asset-thumb:hover { transform: translate(-2px, -2px); box-shadow: var(--shadow-hard-sm); }
.asset-thumb img,
.asset-thumb video { width: 100%; height: 100%; object-fit: contain; }
.asset-thumb .asset-tag {
    position: absolute;
    bottom: 4px;
    left: 4px;
    font-size: 10px;
    background: var(--border-ink);
    color: #fff;
    padding: 2px 7px;
    border-radius: var(--radius-pill);
    font-weight: 700;
}
.asset-thumb[data-kind="audio"] {
    background: var(--color-accent-soft);
    font-size: 24px;
    color: var(--color-text);
}

/* Refine */
/*
 * Refinement history — chat-style log of past instructions for the
 * current game session. Populated by renderRefineHistory() in
 * script.js. Each <li> is a single user turn + the system outcome
 * (version bumped, no changes, asset action, etc).
 *
 * Visual language stays subdued — this is context for the user, not a
 * primary action surface. The CTA remains the textarea + Send button.
 */
.refine-history {
    list-style: none;
    margin: 0 0 var(--space-3) 0;
    padding: 0;
    max-height: 240px;
    overflow-y: auto;
    border-radius: var(--radius-md);
    background: var(--color-surface-2);
    border: 2px solid var(--border-ink);
}
.refine-history li {
    padding: var(--space-2) var(--space-3);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.refine-history li:last-child { border-bottom: none; }
.refine-history .turn-meta {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-soft, rgba(0, 0, 0, 0.5));
}
.refine-history .turn-meta .turn-version {
    font-weight: 600;
    color: var(--color-primary, #3b82f6);
}
.refine-history .turn-meta .turn-version.is-noop {
    color: var(--color-text-soft, rgba(0, 0, 0, 0.45));
}
.refine-history .turn-body {
    font-size: 13px;
    line-height: 1.4;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}
.refine-history .turn-reapply {
    align-self: flex-start;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 6px;
    border: 1px solid var(--color-border, rgba(0, 0, 0, 0.1));
    background: transparent;
    color: var(--color-text-soft, rgba(0, 0, 0, 0.6));
    cursor: pointer;
}
.refine-history .turn-reapply:hover {
    color: var(--color-primary, #3b82f6);
    border-color: var(--color-primary-soft, rgba(59, 130, 246, 0.3));
}
.refine-history-empty {
    padding: var(--space-3);
    font-size: 12px;
    color: var(--color-text-soft, rgba(0, 0, 0, 0.5));
    text-align: center;
}
.card-sub {
    margin-left: auto;
    font-size: 11px;
    color: var(--color-text-soft, rgba(0, 0, 0, 0.45));
    text-transform: none;
    letter-spacing: 0;
}

.refine-card textarea {
    width: 100%;
    padding: var(--space-3);
    background: var(--color-surface-2);
    border: var(--border-w) solid var(--border-ink);
    border-radius: var(--radius-md);
    color: var(--color-text);
    resize: vertical;
    margin-bottom: var(--space-3);
    transition: border-color var(--transition), box-shadow var(--transition);
}
.refine-card textarea:focus { outline: none; border-color: var(--color-primary); box-shadow: var(--shadow-pink); }
.refine-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }

.qa-sidecar-hint {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.7rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(0, 0, 0, 0.2);
    color: var(--text-muted, #9aa3b2);
    user-select: none;
    white-space: nowrap;
}
.qa-sidecar-dot {
    width: 0.55rem;
    height: 0.55rem;
    border-radius: 50%;
    background: #8892a0;
    flex-shrink: 0;
}
.qa-sidecar-hint.is-checking .qa-sidecar-dot {
    background: #c9a227;
    box-shadow: 0 0 0 3px rgba(201, 162, 39, 0.2);
    animation: qa-pulse 1.2s ease-in-out infinite;
}
.qa-sidecar-hint.is-ok {
    color: #b7f0c8;
    border-color: rgba(62, 180, 110, 0.35);
    background: rgba(42, 120, 72, 0.22);
}
.qa-sidecar-hint.is-ok .qa-sidecar-dot {
    background: #3ecf7a;
    box-shadow: 0 0 0 3px rgba(62, 207, 122, 0.22);
}
.qa-sidecar-hint.is-down {
    color: #ffc9b8;
    border-color: rgba(220, 90, 60, 0.4);
    background: rgba(140, 45, 30, 0.28);
}
.qa-sidecar-hint.is-down .qa-sidecar-dot {
    background: #ff6b45;
    box-shadow: 0 0 0 3px rgba(255, 107, 69, 0.22);
}
.qa-summary {
    margin: 0 0 10px;
    padding: 10px 12px;
    border-radius: 10px;
    background: color-mix(in srgb, var(--color-primary, #e91e8c) 8%, transparent);
    border: 1px solid color-mix(in srgb, var(--color-primary, #e91e8c) 22%, transparent);
    font-size: 0.85rem;
    line-height: 1.4;
}
.qa-summary-score {
    font-weight: 600;
    margin-bottom: 4px;
}
.qa-summary-blocker {
    color: var(--color-warn, #c47a00);
    font-weight: 600;
    margin-bottom: 6px;
}
.qa-summary-issues {
    margin: 4px 0 0;
    padding-left: 1.1em;
}
.qa-summary-issues li {
    margin-bottom: 2px;
}
.qa-summary-hint {
    margin: 8px 0 0;
    font-size: 0.78rem;
}
@keyframes qa-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.45; }
}

/* Feedback */
.feedback-body {
    font-size: 14px;
    color: var(--color-text);
    line-height: 1.6;
    max-height: 220px;
    overflow-y: auto;
    white-space: pre-wrap;
}

/* ------------ Footer ------------ */
.app-footer {
    margin-top: auto;
    text-align: center;
    color: var(--color-text-muted);
    font-size: 13px;
    padding-top: var(--space-5);
    padding-bottom: var(--space-4);
    border-top: 2.5px dashed var(--color-border-strong);
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
}

.footer-legal-name {
    margin: 0;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 12px;
    letter-spacing: 0.04em;
    color: var(--color-text);
}

.footer-nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.footer-sep {
    color: var(--color-text-soft);
}

.footer-credit {
    margin: 0;
}

/* ------------ Legal pages (privacy / terms) ------------ */
.legal-card {
    background: var(--color-surface);
    border: var(--border-w) solid var(--border-ink);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-hard-lg);
    padding: 28px 28px 36px;
    max-width: 760px;
    margin: 0 auto;
}

.legal-card h1 {
    margin: 0 0 6px;
    font-size: 28px;
    letter-spacing: -0.02em;
}

.legal-updated {
    margin: 0 0 22px;
    color: var(--color-text-muted);
    font-size: 13px;
}

.legal-card h2 {
    margin: 22px 0 8px;
    font-size: 17px;
}

.legal-card p,
.legal-card li {
    color: var(--color-text);
    font-size: 14px;
    line-height: 1.65;
}

.legal-card p { margin: 0 0 12px; }

.legal-card ul {
    margin: 0 0 12px;
    padding-left: 20px;
}

.legal-card a {
    color: var(--color-primary-ink);
    border-bottom: 2px dotted var(--color-primary);
}

[data-theme="dark"] .legal-card a {
    color: var(--color-primary);
}

.footer-link {
    color: var(--color-text-muted);
    border-bottom: 2px dotted var(--color-border-strong);
    transition: color var(--transition), border-color var(--transition);
}

.footer-link:hover,
.footer-link:focus-visible {
    color: var(--color-text);
    border-bottom-color: currentColor;
}

.footer-link[aria-current="page"] {
    color: var(--color-text);
    border-bottom-color: currentColor;
    font-weight: 600;
    pointer-events: none;
}

.footer-link-cta {
    color: var(--color-primary);
    font-weight: 700;
    border-bottom-color: transparent;
}

.footer-link-cta:hover,
.footer-link-cta:focus-visible {
    color: var(--color-primary-hover);
    border-bottom-color: currentColor;
}

/* ------------ Toasts ------------ */
.toast-stack {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    z-index: 60;
}
.toast {
    background: var(--color-surface);
    color: var(--color-text);
    border: var(--border-w) solid var(--border-ink);
    border-left: 8px solid var(--color-primary);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-hard);
    padding: var(--space-3) var(--space-4);
    min-width: 240px;
    max-width: 360px;
    font-size: 14px;
    font-weight: 500;
    animation: toast-in 320ms var(--ease-bounce);
}
.toast.toast-success { border-left-color: var(--color-success); }
.toast.toast-error   { border-left-color: var(--color-danger); }
.toast.toast-warn    { border-left-color: var(--color-warning); }

@keyframes toast-in {
    from { transform: translateX(20px) rotate(1deg); opacity: 0; }
    to   { transform: translateX(0) rotate(0); opacity: 1; }
}

/* ------------ Responsive ------------ */
@media (max-width: 960px) {
    .workspace-grid { grid-template-columns: 1fr; }
    .settings-grid  { grid-template-columns: 1fr; }
    .app-header {
        grid-template-columns: 1fr auto;
        grid-template-areas:
            "brand toggle"
            "chips chips";
        gap: var(--space-3);
        align-items: center;
    }
    .brand { grid-area: brand; min-width: 0; }
    .theme-toggle { grid-area: toggle; }
    .header-chips {
        grid-area: chips;
        justify-self: stretch;
        width: 100%;
        display: flex;
        align-items: center;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding: 2px 0 6px;
        gap: 8px;
    }
    .header-chips::-webkit-scrollbar {
        display: none;
    }
    .brand-tagline  { display: none; }
    /* straighten the sticker tilt so nothing clips on narrow viewports */
    .hero-card, .library-card,
    .hero-card.is-revealed, .library-card.is-revealed { transform: none; }
}

@media (max-width: 600px) {
    .app { padding: var(--space-5) var(--space-3) var(--space-5); }
    .hero-card { padding: var(--space-4); border-radius: var(--radius-lg); box-shadow: var(--shadow-hard); }
    .library-card { padding: var(--space-4); box-shadow: var(--shadow-hard); }
    .hero-card::before { left: 16px; }
    .brand-logo.logo-for-light { height: auto; max-height: 36px; max-width: min(148px, 42vw); }
    .brand-logo.logo-for-dark { height: auto; max-height: 36px; max-width: min(148px, 42vw); }
    .model-badge { font-size: 12px; padding: 5px 11px; }
    .preview-frame {
        aspect-ratio: 390 / 844;
        width: min(100%, calc(70vh * 390 / 844));
        max-height: 70vh;
    }
    .asset-grid { grid-template-columns: repeat(2, 1fr); }
    .refine-actions .btn { flex: 1 1 auto; }
    .theme-toggle { width: 42px; height: 42px; top: auto; right: auto; }
}

/* ==========================================================
 * SIFOR hub: Ludo.ai funnel hooks (badges, hover overlays,
 * library card, ludo single-asset modal, onboarding wizard,
 * keys chip + quality pill).
 *
 * Kept at the bottom of the file so this whole block can be
 * lifted out as one unit if we ever build a separate theme.
 * ========================================================== */

/* "Made by Ludo.ai" badge — small pill that lives on the
 * top-right of an asset card. Two variants:
 *   ludo-badge-on-card   → default, neutral background
 *   ludo-badge-on-primary→ rendered INSIDE a CTA button
 *   ludo-badge-imported  → user-provided art (different color
 *                          so credit stays clear)
 */
.ludo-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    line-height: 1.5;
    background: var(--color-grape);
    color: #fff;
    border: 1.5px solid var(--border-ink);
    pointer-events: none; /* badges never absorb clicks */
}
.ludo-badge-on-card {
    position: absolute;
    top: 6px;
    right: 6px;
    background: var(--color-grape);
    color: #fff;
    border: 2px solid var(--border-ink);
    z-index: 2;
}
.ludo-badge-imported {
    position: absolute;
    top: 6px;
    right: 6px;
    background: var(--color-teal);
    color: #06302d;
    border: 2px solid var(--border-ink);
    z-index: 2;
}
.ludo-badge-on-primary {
    position: static;
    background: rgba(255, 255, 255, 0.15);
    color: inherit;
    border: 1px solid rgba(255, 255, 255, 0.25);
}

.asset-tag-pending {
    background: rgba(255, 173, 71, 0.18);
    color: #ffb05c;
    border: 1px solid rgba(255, 173, 71, 0.35);
    position: absolute;
    top: 6px;
    left: 6px;
    padding: 2px 6px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 600;
    z-index: 2;
}
.asset-tag-failed {
    background: rgba(255, 111, 124, 0.18);
    color: #ff8d97;
    border: 1px solid rgba(255, 111, 124, 0.35);
    position: absolute;
    top: 6px;
    left: 6px;
    padding: 2px 6px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 600;
    z-index: 2;
}

/* Pending asset placeholder
 *
 * Drawn INSTEAD of an <img> tag for any asset that is still pending
 * a Ludo job (or has failed). Avoids the broken-image icon the grid
 * used to show. The shimmer is pure CSS — no JS animation loop — and
 * the placeholder body holds the role name + status text so even
 * before hover it's obvious which slot this is.
 */
.asset-thumb-placeholder {
    position: relative;
    background: var(--color-grape-soft);
    border: 2px dashed var(--color-grape);
    border-radius: var(--radius-sm);
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
}
.asset-thumb-placeholder.is-failed {
    border-color: var(--color-danger);
    background: color-mix(in srgb, var(--color-danger) 14%, var(--color-surface));
}
.asset-thumb-placeholder-body {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    text-align: center;
    padding: 8px;
}
.asset-thumb-role {
    font-size: 11px;
    font-weight: 600;
    color: #f3f4ff;
    line-height: 1.2;
    max-width: 110px;
    word-break: break-word;
}
.asset-thumb-status {
    font-size: 10px;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 700;
}
.asset-thumb-placeholder.is-failed .asset-thumb-status { color: #ff8d97; }

/* Sweeping shimmer overlay — fakes "Ludo is thinking" without
 * actually running JS. Stops on hover so the user can read the
 * overlay actions clearly. */
.asset-thumb-shimmer {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: 1;
}
.asset-thumb-shimmer::before {
    content: '';
    position: absolute;
    top: 0;
    left: -60%;
    width: 60%;
    height: 100%;
    background: linear-gradient(120deg, transparent 0%, rgba(164, 139, 255, 0.18) 50%, transparent 100%);
    animation: assetShimmer 1.6s ease-in-out infinite;
}
.asset-thumb-placeholder:hover .asset-thumb-shimmer::before { animation: none; }
@keyframes assetShimmer {
    0%   { transform: translateX(0); }
    100% { transform: translateX(220%); }
}

/* Audio + glyph card */
.asset-thumb-glyph {
    font-size: 32px;
    color: var(--color-grape);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

/* Broken-image fallback (real <img> 404 after a successful generate
 * — rare but worth handling). The card greys out and the user can
 * hit Regen in the overlay. */
.asset-thumb-broken {
    background: repeating-linear-gradient(45deg, rgba(255,255,255,0.02) 0 6px, rgba(255,255,255,0.04) 6px 12px);
}

/* Primary CTA variant in the overlay (used by "Generate now"). */
.overlay-btn-primary {
    background: var(--color-primary);
    border-color: rgba(255, 255, 255, 0.7);
    color: #fff;
    font-weight: 700;
}
.overlay-btn-ghost {
    background: rgba(255, 255, 255, 0.04);
    color: #b9bdcf;
}
.overlay-btn-ghost:hover { color: #fff; background: rgba(255, 255, 255, 0.08); }

/* Make the pending overlay PERMANENTLY visible (no hover needed) so
 * the user immediately sees the "Generate now" CTA — that's the
 * whole point of the on-demand workflow. */
.asset-thumb-placeholder .asset-thumb-overlay {
    opacity: 1;
    transform: none;
    pointer-events: auto;
    background: linear-gradient(180deg, rgba(11, 13, 22, 0.4), rgba(11, 13, 22, 0.85));
}

/* Per-card hover overlay that lets the user Replace / Regen /
 * Animate a role. Fades in on hover, capped at the card's
 * own bounding box (no flyout). */
.asset-thumb {
    position: relative;
    overflow: hidden;
}
.asset-thumb-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 6px;
    padding: 8px;
    background: linear-gradient(180deg, rgba(11, 13, 22, 0.78), rgba(11, 13, 22, 0.94));
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 140ms ease, transform 140ms ease;
    pointer-events: none;
    z-index: 3;
}
.asset-thumb:hover .asset-thumb-overlay,
.asset-thumb:focus-within .asset-thumb-overlay {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}
.overlay-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.08);
    color: #f3f4ff;
    border: 1px solid rgba(255, 255, 255, 0.18);
    cursor: pointer;
    transition: background 100ms ease, transform 80ms ease;
}
.overlay-btn:hover { background: rgba(255, 255, 255, 0.18); }
.overlay-btn:active { transform: translateY(1px); }
.overlay-btn-ludo {
    background: var(--color-grape);
    border-color: rgba(255, 255, 255, 0.45);
    color: #fff;
}
.overlay-btn-ludo:hover { filter: brightness(1.08); background: var(--color-grape); }

/* Library card (drag/drop zone + per-role bind grid).
 *
 * Lives on the main page between the hero and the workspace.
 * Drives the AssetLibrary module — drop files / generate with
 * Ludo / bind roles. Bound assets are guaranteed to ship in
 * the next build via the userAssetsJson form field.
 */
.library-card {
    position: relative;
    background: var(--color-surface);
    border: var(--border-w) solid var(--border-ink);
    border-radius: var(--radius-xl);
    padding: var(--space-5);
    margin: 0;
    box-shadow: var(--shadow-hard-lg);
    transform: rotate(0.3deg);
}
.library-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}
.library-card-header h3 {
    margin: 0 0 2px;
    font-family: var(--font-display);
    font-size: 22px;
    color: var(--color-text);
    letter-spacing: -0.015em;
}
.library-card-header h3::before {
    content: "";
}
.library-collapse { padding: 5px 12px; font-size: 12px; }
.library-body { display: flex; flex-direction: column; gap: 14px; }
.library-body.is-collapsed { display: none; }
.library-card .library-dropzone {
    position: relative;
    border: 2.5px dashed var(--color-grape);
    border-radius: var(--radius-lg);
    padding: 20px;
    text-align: center;
    color: var(--color-text-muted);
    background: var(--color-grape-soft);
    transition: background 140ms ease, border-color 140ms ease, transform 140ms ease;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 14px;
    justify-content: center;
}
.library-card .library-dropzone:hover,
.library-card .library-dropzone.is-dragover,
.library-card .library-dropzone.is-dragging,
.library-card .library-dropzone:focus-visible {
    background: color-mix(in srgb, var(--color-grape) 18%, var(--color-surface));
    border-color: var(--color-grape);
    transform: translateY(-2px);
    outline: none;
}
.library-dropzone-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--color-grape);
    color: #fff;
    border: 2.5px solid var(--border-ink);
    box-shadow: var(--shadow-hard-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: 700;
    line-height: 1;
}
.library-dropzone-copy {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    text-align: left;
}
.library-dropzone-copy strong { color: var(--color-text); font-size: 14px; font-family: var(--font-display); }
.library-dropzone-copy span { font-size: 12px; }
.library-link {
    background: transparent;
    border: none;
    color: var(--color-grape);
    cursor: pointer;
    font: inherit;
    font-weight: 700;
    padding: 0;
    text-decoration: underline;
}
.library-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.library-actions-hint {
    font-size: 12px;
    color: var(--color-text-muted);
}
.library-tabs {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    border-bottom: 2.5px solid var(--color-border-strong);
    padding-bottom: 0;
}
.library-tab {
    background: transparent;
    border: 2.5px solid transparent;
    border-bottom: none;
    color: var(--color-text-muted);
    padding: 7px 13px;
    border-radius: 10px 10px 0 0;
    cursor: pointer;
    font-family: var(--font-display);
    font-size: 12px;
    font-weight: 600;
    margin-bottom: -2.5px;
    transition: color var(--transition), background var(--transition);
}
.library-tab:hover { color: var(--color-text); background: var(--color-surface-2); }
.library-tab.is-active {
    color: var(--color-text);
    background: var(--color-accent);
    border-color: var(--border-ink);
    border-bottom-color: var(--color-accent);
}
[data-theme="dark"] .library-tab.is-active { color: var(--border-ink); }
.library-card .library-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
    min-height: 88px;
}
.library-empty {
    grid-column: 1 / -1;
    padding: 22px;
    text-align: center;
    color: var(--color-text-muted);
    background: var(--color-surface-2);
    border: 2.5px dashed var(--color-border-strong);
    border-radius: var(--radius-lg);
}
.library-empty p { margin: 0; font-size: 13px; }
.library-funnel {
    font-size: 12px;
    color: var(--color-text-muted);
    margin: 4px 0 0;
    padding: 10px 14px;
    background: var(--color-accent-soft);
    border: 2px solid var(--border-ink);
    border-radius: var(--radius-md);
}
/* Library card-item (what AssetLibrary.renderCard emits). */
.library-card-item {
    position: relative;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--color-surface-2);
    border: 2.5px solid var(--border-ink);
    box-shadow: var(--shadow-hard-sm);
    display: flex;
    flex-direction: column;
    transition: transform 140ms var(--ease-bounce), box-shadow 140ms ease;
}
.library-card-item:hover { transform: translate(-2px, -2px); box-shadow: var(--shadow-hard); }
.library-thumb {
    position: relative;
    aspect-ratio: 1 / 1;
    background-color: var(--color-surface-3);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    border-bottom: 2.5px solid var(--border-ink);
}
.library-thumb-audio {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    color: var(--color-grape);
}
.library-card-meta {
    position: relative;
    padding: 8px 8px 4px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.library-card-meta .ludo-badge-on-card,
.library-card-meta .ludo-badge-imported {
    position: absolute;
    top: -16px;
    right: 6px;
}
.library-role-input {
    width: 100%;
    background: var(--color-surface);
    border: 2px solid var(--border-ink);
    color: var(--color-text);
    border-radius: 8px;
    padding: 6px 8px;
    font-size: 11px;
    font-family: inherit;
}
.library-role-input::placeholder { color: var(--color-text-soft); }
.library-role-input:focus { outline: none; border-color: var(--color-primary); }
.library-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 4px 8px 8px;
}
.library-card-actions [data-library-add] {
    flex: 1 1 100%;
}
.library-card-actions .btn-sm {
    padding: 6px 10px;
    font-size: 11px;
}

/* Keys chip + quality pill in the header */
.keys-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 0 13px;
    height: 38px;
    box-sizing: border-box;
    border-radius: 999px;
    background: var(--color-surface);
    border: var(--border-w) solid var(--border-ink);
    box-shadow: var(--shadow-hard-sm);
    color: var(--color-text);
    font-family: var(--font-display);
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
    cursor: pointer;
    text-decoration: none;
    transition: transform 120ms var(--ease-bounce), box-shadow 120ms ease, background 120ms ease;
}
.keys-chip:hover { transform: translate(-1px, -1px); box-shadow: var(--shadow-hard); background: var(--color-surface-2); }
.keys-chip:active { transform: translate(1px, 1px); box-shadow: none; }
.keys-chip[data-state="ok"]    .keys-chip-dot { background: var(--color-success); }
.keys-chip[data-state="warn"]  .keys-chip-dot { background: var(--color-warning); }
.keys-chip[data-state="error"] .keys-chip-dot { background: var(--color-danger); }
.keys-chip-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--color-danger);
    border: 1.5px solid var(--border-ink);
}

/**
 * View nav — Gallery / Create segmented control in the header. Drives
 * AppView.showGallery()/showStudio() in script.js, which is the platform's
 * primary navigation now that the gallery is the landing view.
 */
.view-nav {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px;
    height: 38px;
    box-sizing: border-box;
    border-radius: 999px;
    background: var(--color-surface-2);
    border: var(--border-w) solid var(--border-ink);
    white-space: nowrap;
    flex-shrink: 0;
}
.view-nav-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 32px;
    padding: 0 14px;
    border-radius: 999px;
    box-shadow: none;
    background: transparent;
    border: none;
    white-space: nowrap;
    font-size: 12.5px;
    font-weight: 700;
    line-height: 1;
    flex-shrink: 0;
    box-sizing: border-box;
    cursor: pointer;
    transition: background 140ms ease, color 140ms ease;
}
.view-nav-btn:hover { box-shadow: none; background: var(--color-surface-3); transform: none; }
.view-nav-btn.is-active {
    background: var(--color-accent);
    color: var(--border-ink);
    box-shadow: var(--shadow-hard-sm);
}
.view-nav-btn.is-active:hover { background: var(--color-accent); transform: none; }

/**
 * Swarm mode toggle chip — sits next to the keys chip in the header.
 * Off by default (grey dot + dim label); turns grape when active.
 */
.swarm-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 13px;
    border-radius: 999px;
    background: var(--color-surface);
    border: var(--border-w) solid var(--border-ink);
    box-shadow: var(--shadow-hard-sm);
    color: var(--color-text);
    font-family: var(--font-display);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 120ms var(--ease-bounce), box-shadow 120ms ease, background 120ms ease, color 200ms ease;
    margin-right: 4px;
}
.swarm-chip:hover { transform: translate(-1px, -1px); box-shadow: var(--shadow-hard); background: var(--color-surface-2); }
.swarm-chip:active { transform: translate(1px, 1px); box-shadow: none; }
.swarm-chip.is-active {
    background: var(--color-grape);
    color: #fff;
    box-shadow: 4px 4px 0 0 var(--border-ink);
}
.swarm-chip-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--color-text-soft);
    border: 1.5px solid var(--border-ink);
    transition: background 200ms ease;
}
.swarm-chip.is-active .swarm-chip-dot {
    background: #fff;
}
.swarm-chip-label-hint {
    display: none;
    font-size: 10px;
    opacity: 0.6;
    margin-left: 2px;
}
.swarm-chip:hover .swarm-chip-label-hint { display: inline; }

.quality-pill-group {
    display: inline-flex;
    background: var(--color-surface-2);
    border: var(--border-w) solid var(--border-ink);
    border-radius: 999px;
    padding: 3px;
    gap: 2px;
}
.quality-pill {
    padding: 5px 12px;
    border-radius: 999px;
    font-family: var(--font-display);
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-muted);
    cursor: pointer;
    background: transparent;
    border: 0;
    transition: background 120ms ease, color 120ms ease;
}
.quality-pill:hover { color: var(--color-text); }
.quality-pill.is-active {
    background: var(--color-grape);
    color: #fff;
}

/* ------------ Custom cursor glow (set up by js/sifor-fx.js) ------------
   A soft arcade-pink spotlight that trails the pointer. Hidden until
   sifor-fx.js adds .is-active on first pointermove; auto-disabled on
   touch / coarse pointers and under reduced-motion. */
.cursor-glow {
    position: fixed;
    top: 0;
    left: 0;
    width: 460px;
    height: 460px;
    margin: -230px 0 0 -230px;
    border-radius: 50%;
    pointer-events: none;
    z-index: 40;
    opacity: 0;
    background: radial-gradient(circle, rgba(255, 61, 133, 0.22), rgba(255, 210, 61, 0.10) 40%, transparent 68%);
    mix-blend-mode: multiply;
    transition: opacity 400ms ease;
    will-change: transform;
}
[data-theme="dark"] .cursor-glow {
    mix-blend-mode: screen;
    background: radial-gradient(circle, rgba(255, 92, 154, 0.20), rgba(123, 92, 255, 0.12) 42%, transparent 70%);
}
.cursor-glow.is-active { opacity: 1; }
@media (hover: none), (pointer: coarse) {
    .cursor-glow { display: none; }
}
@media (prefers-reduced-motion: reduce) {
    .cursor-glow { display: none; }
}

/* ---------------- Onboarding wizard ---------------- *
 * Markup lives in index.html under #onboardingWizard. It's
 * structurally a 3-slide modal (Ludo → Gemini → done) with
 * a progress indicator at the top. We render it full-screen
 * over a blurred backdrop so the first-run user can't miss
 * it, and animate the active slide in to make the flow feel
 * deliberate.
 */
.wizard-modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.wizard-modal.is-hidden,
.wizard-modal[hidden] { display: none !important; }
.wizard-modal:not(.is-hidden):not([hidden]) { display: flex !important; }
.wizard-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(6, 8, 16, 0.78);
    backdrop-filter: blur(8px);
}
.wizard-modal-card {
    position: relative;
    width: 100%;
    max-width: 620px;
    max-height: calc(100vh - 48px);
    overflow-y: auto;
    background: var(--color-surface);
    border: 3px solid var(--border-ink);
    border-radius: var(--radius-xl);
    padding: 26px;
    color: var(--color-text);
    box-shadow: var(--shadow-hard-xl);
    animation: wizardPop 320ms var(--ease-bounce) both;
}
@keyframes wizardPop {
    from { opacity: 0; transform: translateY(16px) scale(0.96); }
    to   { opacity: 1; transform: none; }
}
.wizard-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
}
.wizard-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}
.wizard-brand-logo {
    height: auto;
    width: auto;
    max-height: 48px;
    max-width: min(195px, 46vw);
    object-fit: contain;
    background: transparent;
}
.wizard-brand-logo.logo-for-light { max-height: 48px; max-width: min(195px, 46vw); }
.wizard-brand-logo.logo-for-dark { max-height: 48px; max-width: min(195px, 46vw); }
.wizard-title { margin: 0 0 2px; font-size: 22px; letter-spacing: -0.015em; }
.wizard-subtitle { margin: 0; color: var(--color-text-muted); font-size: 13px; }
.wizard-close {
    background: var(--color-surface-2);
    border: 2px solid var(--border-ink);
    color: var(--color-text);
    font-size: 15px;
    cursor: pointer;
    padding: 4px 9px;
    border-radius: 8px;
    transition: background var(--transition), transform var(--transition);
}
.wizard-close:hover { color: #fff; background: var(--color-danger); transform: rotate(90deg); }

.wizard-progress {
    display: flex;
    list-style: none;
    margin: 0 0 18px;
    padding: 0;
    gap: 10px;
}
.wizard-step {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 999px;
    background: var(--color-surface-2);
    color: var(--color-text-muted);
    font-family: var(--font-display);
    font-size: 12px;
    font-weight: 600;
    border: 2px solid var(--border-ink);
}
.wizard-step span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--color-surface);
    border: 2px solid var(--border-ink);
    font-size: 11px;
}
.wizard-step.is-active {
    color: #fff;
    background: var(--color-grape);
}
.wizard-step.is-active span {
    background: var(--color-surface);
    color: var(--color-grape);
}
.wizard-step.is-done {
    color: #fff;
    background: var(--color-success);
}
.wizard-step.is-done span { background: var(--color-surface); color: var(--color-success); }

.wizard-slide { display: none; }
.wizard-slide.is-active { display: block; animation: wizardSlideIn 240ms ease both; }
.wizard-slide.is-hidden { display: none; }
@keyframes wizardSlideIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.wizard-slide-body { display: flex; flex-direction: column; gap: 16px; }
.wizard-done-body { gap: 12px; }
.wizard-pitch h3 { margin: 0 0 8px; font-size: 18px; }
.wizard-pitch p  { margin: 0 0 12px; color: var(--color-text-muted); font-size: 13px; line-height: 1.55; }
.wizard-steps {
    list-style: decimal;
    margin: 0 0 14px;
    padding-left: 20px;
    color: var(--color-text);
    font-size: 13px;
    line-height: 1.7;
}
.wizard-cta-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}
.wizard-input-block { margin-top: 6px; }
.wizard-faq { margin-top: 10px; font-size: 12px; color: var(--color-text-muted); }
.wizard-faq summary { cursor: pointer; color: var(--color-text); font-weight: 600; }
.wizard-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 22px;
    flex-wrap: wrap;
}
.wizard-footer-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.wizard-checklist {
    list-style: none;
    margin: 0 0 16px;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.wizard-checklist li {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 15px;
    border-radius: var(--radius-md);
    background: var(--color-surface-2);
    border: 2px solid var(--border-ink);
    font-size: 13px;
}
.wizard-checklist li.is-pending { color: var(--color-text-muted); }
.wizard-checklist li.is-ok      { color: var(--color-success); background: var(--color-lime-soft); }
.wizard-checklist li.is-error,
.wizard-checklist li.is-err     { color: var(--color-danger); background: color-mix(in srgb, var(--color-danger) 12%, var(--color-surface)); }
.wizard-check-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--color-surface);
    border: 2px solid var(--border-ink);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}
.wizard-checklist li.is-ok    .wizard-check-icon { background: var(--color-success); color: #fff; }
.wizard-checklist li.is-error .wizard-check-icon,
.wizard-checklist li.is-err   .wizard-check-icon { background: var(--color-danger); color: #fff; }
.wizard-check-label  { font-weight: 700; font-family: var(--font-display); }
.wizard-check-detail { margin-left: auto; opacity: 0.9; font-size: 12px; }
.wizard-done-pitch   { font-size: 12px; color: var(--color-text-muted); }

.key-status.is-ok    { color: var(--color-success); font-weight: 600; }
.key-status.is-error,
.key-status.is-err   { color: var(--color-danger); font-weight: 600; }

/* ---------------- Ludo single-asset modal ---------------- *
 * Reuses the same modal frame as the wizard but lighter
 * — a single-slide dialog with the prompt / kind / style chips.
 */
.ludo-modal {
    position: fixed;
    inset: 0;
    z-index: 1050;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.ludo-modal.is-hidden { display: none; }
.ludo-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(6, 8, 16, 0.78);
    backdrop-filter: blur(8px);
}
.ludo-modal-card {
    position: relative;
    width: 100%;
    max-width: 560px;
    max-height: calc(100vh - 48px);
    overflow-y: auto;
    background: var(--color-surface);
    border: 3px solid var(--border-ink);
    border-radius: var(--radius-xl);
    padding: 24px;
    color: var(--color-text);
    box-shadow: var(--shadow-hard-xl);
    animation: wizardPop 320ms var(--ease-bounce) both;
}
.ludo-modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}
.ludo-modal-header h3 { margin: 0; font-size: 19px; }
.ludo-modal-body { display: flex; flex-direction: column; gap: 12px; }
.ludo-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 16px;
    flex-wrap: wrap;
}

/* Quota upgrade toast — surfaces a Ludo upgrade CTA after a
 * 402/429 from the Ludo APIs. Sits over toasts because we
 * want a forceful funnel moment. */
.ludo-upgrade-banner {
    position: fixed;
    bottom: 24px;
    right: 24px;
    max-width: 360px;
    padding: 18px 20px;
    background: var(--color-grape);
    color: #fff;
    border: 3px solid var(--border-ink);
    border-radius: var(--radius-lg);
    box-shadow: 6px 6px 0 0 var(--border-ink);
    z-index: 1200;
}
.ludo-upgrade-banner h3 { margin: 0 0 4px; font-size: 14px; }
.ludo-upgrade-banner p  { margin: 0 0 10px; font-size: 12px; opacity: 0.9; }
.ludo-upgrade-banner .ludo-upgrade-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}
.ludo-upgrade-banner a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
    text-decoration: none;
    font-weight: 600;
    font-size: 12px;
    border: 1px solid rgba(255, 255, 255, 0.3);
}
.ludo-upgrade-banner button {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.85);
    font-size: 11px;
    cursor: pointer;
    text-decoration: underline;
}

/* ══════════════════════════════════════════════════════
   SIFOR Agent Hive — Live Swarm Visualization UI
   ══════════════════════════════════════════════════════ */

.hive-toggle-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 999;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 2.5px solid var(--border-ink);
    background: var(--color-grape);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-hard-sm);
    transition: transform 0.18s var(--ease-bounce), box-shadow 0.18s ease, background 0.18s ease;
}
.hive-toggle-btn:hover {
    transform: translate(-2px, -2px) rotate(-8deg);
    box-shadow: var(--shadow-hard);
}
.hive-toggle-btn.is-active {
    background: var(--color-danger);
}

/* ========================================================================
   AGENT HIVE — unified "building your game" view
   Rebranded to the SIFOR neo-brutalist system (Fredoka, ink borders, hard
   offset shadows, brand colours). Two render modes:
     • .hive-embedded  → in-flow inside #hiveMount (the primary unified view)
     • overlay (default) → fixed right-side panel (backward-compat fallback)
   ===================================================================== */

/* The in-workspace mount: only visible while a fresh build is in flight. */
.hive-mount { display: none; }
.workspace.is-building .hive-mount { display: block; }
.workspace.is-building .workspace-grid { display: none; }
/* First playable draft: keep the hive progress visible AND show the game. */
.workspace.is-building.is-playable-draft .workspace-grid { display: grid; }
.workspace.is-building.is-playable-draft .hive-mount { display: block; }
.workspace.is-building.is-playable-draft .hive-container.hive-embedded {
    max-height: 42vh;
    overflow: auto;
}

/* Full-width build meter — always on top of the hive so progress isn't a 140px sliver. */
.studio-build-progress {
    display: none;
    margin: 0 0 14px;
    padding: 14px 18px 16px;
    background: var(--color-surface);
    border: var(--border-w) solid var(--border-ink);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-hard);
}
.workspace.is-building .studio-build-progress { display: block; }
.studio-build-progress[hidden] { display: none !important; }
.studio-build-progress-meta {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 10px;
    font-weight: 700;
}
#studioBuildProgressLabel {
    font-family: var(--font-display);
    font-size: 15px;
    color: var(--color-text);
}
#studioBuildProgressPct {
    font-family: var(--font-display);
    font-size: 18px;
    color: var(--color-primary-ink);
    min-width: 3.2em;
    text-align: right;
}
.studio-build-progress-track {
    width: 100%;
    height: 18px;
    background: var(--color-bg);
    border: 2.5px solid var(--border-ink);
    border-radius: var(--radius-pill);
    overflow: hidden;
}
.studio-build-progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--color-primary), var(--color-grape), var(--color-teal, #16C7C0));
    border-radius: var(--radius-pill);
    transition: width 0.35s ease;
}

/* The hive is now the single progress surface — retire the legacy timeline. */
.timeline-card { display: none !important; }

.hive-container {
    font-family: var(--font-body);
    color: var(--color-text);
    font-size: 14px;
}

/* ---- Overlay fallback (no #hiveMount on the page) ---- */
.hive-container:not(.hive-embedded) {
    position: fixed;
    top: 0;
    right: 0;
    width: 540px;
    max-width: 100vw;
    height: 100vh;
    z-index: 1000;
    background: var(--color-bg);
    border-left: var(--border-w) solid var(--border-ink);
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 16px;
    overflow-y: auto;
    box-shadow: -10px 0 0 0 rgba(0, 0, 0, 0.10);
    transition: transform 0.35s var(--ease-bounce);
}
.hive-container:not(.hive-embedded).is-hidden {
    transform: translateX(100%);
}

/* ---- Embedded build theater (primary) ---- */
.hive-container.hive-embedded {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.hive-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
    padding: 16px 20px;
    background: var(--color-surface);
    border: var(--border-w) solid var(--border-ink);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-hard);
}
.hive-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.hive-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 20px;
    letter-spacing: -0.01em;
    color: var(--color-text);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.hive-title::before {
    content: "";
    font-size: 18px;
    line-height: 1;
}
.hive-badge {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 12px;
    color: var(--color-primary-ink);
    background: var(--color-primary-soft);
    border: 2px solid var(--color-primary-ink);
    padding: 2px 10px;
    border-radius: var(--radius-pill);
}
.hive-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--color-success);
    border: 2px solid var(--border-ink);
    display: inline-block;
}
.hive-dot.failed {
    background: var(--color-danger);
}
#hiveStatusBar {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-muted);
}
.hive-header-right {
    display: flex;
    align-items: center;
    gap: 14px;
    flex: 1;
    min-width: 200px;
}
.hive-progress-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-width: 180px;
    flex: 1;
}
.hive-progress-track {
    flex: 1;
    width: auto;
    min-width: 80px;
    height: 14px;
    background: var(--color-bg);
    border: 2px solid var(--border-ink);
    border-radius: var(--radius-pill);
    overflow: hidden;
}
.hive-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--color-primary), var(--color-grape));
    border-radius: var(--radius-pill);
    transition: width 0.4s var(--ease-bounce);
}
.hive-progress-label {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 13px;
    color: var(--color-text);
    min-width: 34px;
    text-align: right;
}
.hive-eta-label {
    font-family: var(--font-body);
    font-size: 12px;
    color: var(--color-muted, #6b7280);
    white-space: nowrap;
    min-width: 4.5em;
}
.hive-stage-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 16px 4px;
    border-bottom: 1px solid var(--border-ink);
    background: var(--color-surface);
}
.hive-lane-track {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 16px 8px;
    border-bottom: 1px solid var(--border-ink);
    background: var(--color-surface);
    font-size: 12px;
}
.hive-lane-track.is-hidden,
.hive-lane-track[hidden] {
    display: none;
}
.hive-lane-play {
    font-weight: 700;
    color: var(--color-success, #16a34a);
}
.hive-lane-improve {
    color: var(--color-muted, #6b7280);
}
.hive-stage {
    font-family: var(--font-body);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.02em;
    padding: 4px 10px;
    border: 1px solid var(--border-ink);
    border-radius: 4px;
    opacity: 0.45;
    color: var(--color-text);
}
.hive-stage.is-active {
    opacity: 1;
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}
.hive-stage.is-done {
    opacity: 0.85;
    background: var(--color-bg);
}
.hive-stage.is-warn {
    opacity: 1;
    color: #92400e;
    border-color: #f59e0b;
    background: rgba(245, 158, 11, 0.15);
}
.hive-close-btn {
    background: var(--color-surface);
    border: 2px solid var(--border-ink);
    border-radius: var(--radius-sm);
    font-size: 18px;
    color: var(--color-text);
    cursor: pointer;
    width: 30px;
    height: 30px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-hard-sm);
    transition: transform var(--transition);
}
.hive-close-btn:hover {
    transform: translate(-1px, -1px);
    background: var(--color-primary-soft);
}

.hive-body {
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.hive-panel {
    background: var(--color-surface);
    border: var(--border-w) solid var(--border-ink);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-hard);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.hive-panel-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 13px;
    letter-spacing: 0.01em;
    color: var(--color-text);
    padding: 12px 16px 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Embedded: graph on the left, gallery + log stacked on the right. */
.hive-embedded .hive-body {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    grid-template-areas:
        "graph gallery"
        "graph log";
    gap: 16px;
    align-items: stretch;
}
.hive-embedded .hive-panel-graph   { grid-area: graph; }
.hive-embedded .hive-panel-gallery { grid-area: gallery; }
.hive-embedded .hive-panel-log     { grid-area: log; }
.hive-embedded .hive-panel-graph   { min-height: 360px; }
.hive-embedded .hive-panel-log     { min-height: 220px; }
@media (max-width: 900px) {
    .hive-embedded .hive-body {
        grid-template-columns: 1fr;
        grid-template-areas: "graph" "gallery" "log";
    }
    .hive-embedded .hive-panel-graph { min-height: 0; }
}

/* Overlay fallback keeps the simple stacked sizing. */
.hive-container:not(.hive-embedded) .hive-panel-graph { max-height: 40%; }
.hive-container:not(.hive-embedded) .hive-panel-gallery { max-height: 25%; }
.hive-container:not(.hive-embedded) .hive-panel-log { flex: 1; min-height: 120px; }

.hive-agent-graph {
    padding: 8px 14px 14px;
    overflow-y: auto;
    flex: 1;
}
.hive-container:not(.hive-embedded) .hive-agent-graph {
    max-height: calc(40vh - 30px);
}
.hive-graph-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
@media (max-width: 1100px) {
    .hive-graph-grid { grid-template-columns: 1fr; }
}
.hive-empty {
    color: var(--color-text-soft);
    font-weight: 600;
    padding: 18px 16px;
    text-align: center;
    font-size: 13px;
}
.hive-agent-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    background: var(--color-bg);
    border: 2px solid var(--border-ink);
    border-left-width: 6px;
    border-left-color: #6b7280;
    box-shadow: var(--shadow-hard-sm);
    transition: transform var(--transition), box-shadow var(--transition);
}
.hive-agent-working,
.hive-agent-thinking {
    background: var(--color-accent-soft);
    border-left-color: var(--color-accent-ink);
}
.hive-agent-complete {
    background: var(--color-lime-soft);
    border-left-color: var(--color-success);
}
.hive-agent-failed {
    background: var(--color-primary-soft);
    border-left-color: var(--color-danger);
}
.hive-agent-avatar {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    border: 2px solid var(--border-ink);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 15px;
    flex-shrink: 0;
}
.hive-agent-info {
    flex: 1;
    min-width: 0;
}
.hive-agent-role {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 14px;
    color: var(--color-text);
    line-height: 1.2;
}
.hive-agent-id {
    font-size: 10px;
    color: var(--color-text-soft);
    font-family: var(--font-mono, monospace);
}
.hive-agent-action {
    font-size: 12px;
    color: var(--color-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    margin-top: 2px;
}
.hive-agent-status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--color-text-soft);
    border: 2px solid var(--border-ink);
    flex-shrink: 0;
}
.hive-agent-status-dot.hive-agent-thinking {
    background: var(--color-accent);
    animation: pulse 1s infinite;
}
.hive-agent-status-dot.hive-agent-working {
    background: var(--color-grape);
    animation: pulse 1s infinite;
}
.hive-agent-status-dot.hive-agent-complete {
    background: var(--color-success);
}
.hive-agent-status-dot.hive-agent-failed {
    background: var(--color-danger);
}
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.hive-artifact-gallery {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 8px 14px 14px;
    overflow-y: auto;
    align-content: flex-start;
    scrollbar-width: thin;
}
.hive-container:not(.hive-embedded) .hive-artifact-gallery {
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    max-height: calc(25vh - 30px);
}
.hive-artifact-item {
    flex: 0 0 88px;
    width: 88px;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 2px solid var(--border-ink);
    background: var(--color-bg);
    box-shadow: var(--shadow-hard-sm);
}
.hive-artifact-thumb {
    width: 100%;
    height: 58px;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    border-bottom: 2px solid var(--border-ink);
}
.hive-artifact-text {
    width: auto;
    flex: 0 0 auto;
    padding: 6px 10px;
    min-width: 72px;
    max-width: 150px;
}
.hive-artifact-meta {
    padding: 4px 6px 6px;
}
.hive-artifact-role {
    font-family: var(--font-display);
    font-size: 11px;
    font-weight: 600;
    color: var(--color-text);
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.hive-artifact-kind {
    font-size: 10px;
    color: var(--color-text-soft);
    display: block;
}
.hive-artifact-count {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 11px;
    color: var(--color-primary-ink);
    background: var(--color-primary-soft);
    border-radius: var(--radius-pill);
    padding: 1px 8px;
    margin-left: auto;
}

.hive-message-log {
    padding: 8px 14px 14px;
    overflow-y: auto;
    flex: 1;
    font-family: var(--font-mono, 'JetBrains Mono', 'Fira Code', monospace);
    font-size: 12px;
    line-height: 1.6;
}
.hive-container:not(.hive-embedded) .hive-message-log {
    max-height: calc(100% - 24px);
}
.hive-log-entry {
    display: flex;
    gap: 8px;
    padding: 3px 6px;
    border-radius: var(--radius-sm);
    margin-bottom: 2px;
}
.hive-log-time {
    color: var(--color-text-soft);
    flex-shrink: 0;
    min-width: 64px;
}
.hive-log-from {
    color: var(--color-text-muted);
    flex-shrink: 0;
    font-weight: 700;
    max-width: 110px;
    overflow: hidden;
    text-overflow: ellipsis;
}
.hive-log-text {
    color: var(--color-text);
    word-break: break-word;
}
.hive-log-task {
    background: var(--color-grape-soft);
}
.hive-log-complete {
    background: var(--color-lime-soft);
}
.hive-log-phase {
    background: var(--color-accent-soft);
    font-weight: 600;
}
.hive-log-evolution {
    background: var(--color-grape-soft);
}
.hive-log-error {
    background: var(--color-primary-soft);
    color: var(--color-primary-ink);
    font-weight: 600;
}
.hive-log-warning {
    background: color-mix(in srgb, var(--color-warning, #d4a017) 14%, transparent);
    border-left: 3px solid var(--color-warning, #d4a017);
    font-weight: 600;
}

/* Dark mode: the hive now uses adaptive design tokens (--color-surface,
   --color-bg, --color-*-soft) which already flip in [data-theme="dark"],
   so only a couple of overlay/toggle accents need explicit overrides. */
[data-theme="dark"] .hive-toggle-btn {
    background: var(--color-grape);
    box-shadow: var(--shadow-hard-sm);
}
[data-theme="dark"] .hive-toggle-btn.is-active {
    background: var(--color-danger);
}

/* Responsive: overlay fallback goes full-width on mobile. */
@media (max-width: 768px) {
    .hive-container:not(.hive-embedded) {
        width: 100vw;
        border-left: none;
    }
    .hive-container:not(.hive-embedded) .hive-graph-grid {
        grid-template-columns: 1fr;
    }
    .hive-header {
        padding: 14px 16px;
    }
    .hive-title {
        font-size: 18px;
    }
}

/* ── Reference / inspiration image (style anchor) ───────────────────── */
.reference-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 14px;
    flex-wrap: wrap;
}
.reference-attach {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1 1 240px;
    min-width: 0;
    min-height: 52px;
    padding: 12px 16px;
    border: var(--border-w) dashed var(--color-border-strong);
    border-radius: var(--radius-md);
    background: var(--color-surface-2);
    cursor: pointer;
    transition: background .15s ease, transform .1s ease;
}
.reference-camera-btn {
    min-height: 52px;
    padding: 12px 18px;
}
.reference-attach:hover,
.reference-attach.is-dragover {
    background: var(--color-accent-soft);
    transform: translateY(-1px);
}
.reference-attach:focus-visible { outline: 3px solid var(--color-grape); outline-offset: 2px; }
.reference-attach-icon { font-size: 20px; line-height: 1; }
.reference-attach-copy { display: flex; flex-direction: column; min-width: 0; }
.reference-attach-copy strong { font-size: 14px; color: var(--color-text); }
.reference-attach-copy span { font-size: 12px; color: var(--color-text-muted); }
/* Full look-preview: key-art stage, not a tiny icon. */
.reference-preview {
    position: relative;
    margin: 4px 0 0;
    width: 100%;
    flex: 1 1 100%;
    border: var(--border-w) solid var(--border-ink);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-hard-sm);
    background:
        radial-gradient(120% 80% at 20% 0%, rgba(255,255,255,0.08), transparent 55%),
        linear-gradient(160deg, var(--color-surface-2), var(--color-surface));
}
.reference-preview-stage {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(140px, 0.8fr);
    gap: 0;
    min-height: 200px;
}
@media (max-width: 720px) {
    .reference-preview-stage { grid-template-columns: 1fr; }
}
.reference-preview img {
    width: 100%;
    height: 100%;
    min-height: 220px;
    max-height: 360px;
    object-fit: cover;
    display: block;
    background: #111;
}
.reference-preview-caption {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    gap: 6px;
    padding: 18px 20px;
    margin: 0;
}
.reference-preview-caption strong {
    font-size: 15px;
    color: var(--color-text);
}
.reference-preview-caption span {
    font-size: 13px;
    line-height: 1.4;
    color: var(--color-text-muted);
}
.reference-preview.is-hidden { display: none; }
.reference-row.has-preview .reference-attach-copy span {
    color: var(--color-text);
}
.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
    white-space: nowrap;
}
.reference-remove {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 2px solid var(--border-ink);
    border-radius: var(--radius-pill);
    background: var(--color-danger);
    color: #fff;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    z-index: 2;
}

/* =====================================================
 * Share toggle (preview toolbar) + Gallery + Admin panel
 * ===================================================== */

/* ---------------- Toggle switch ----------------
 * First real on/off switch in the design system — everything else
 * (pill-group, chip-group) is single/multi-select, not binary. Keeps the
 * same hard-border / hard-shadow language as the rest of the hub.
 */
.toggle-switch {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
    flex-shrink: 0;
}
.toggle-switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.toggle-track {
    position: relative;
    display: inline-block;
    width: 38px;
    height: 22px;
    border-radius: var(--radius-pill);
    background: var(--color-surface-3);
    border: 2px solid var(--border-ink);
    box-shadow: var(--shadow-hard-sm);
    transition: background 140ms ease;
    flex-shrink: 0;
}
.toggle-thumb {
    position: absolute;
    top: 1px;
    left: 1px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--color-surface);
    border: 1.5px solid var(--border-ink);
    transition: transform 160ms var(--ease-bounce);
}
.toggle-switch input:checked + .toggle-track {
    background: var(--color-primary);
}
.toggle-switch input:checked + .toggle-track .toggle-thumb {
    transform: translateX(16px);
    background: #fff;
}
.ludo-paint-row {
    margin: 10px 0 14px;
    padding: 12px 14px;
    border-radius: var(--radius-md, 12px);
    border: 1px solid var(--color-border, rgba(255, 255, 255, 0.12));
    background: var(--color-surface-2, rgba(255, 255, 255, 0.04));
}
.theme-intake-ludo-row { margin-bottom: 8px; }

.toggle-switch input:focus-visible + .toggle-track {
    outline: 3px solid var(--color-grape);
    outline-offset: 2px;
}
.toggle-switch:hover .toggle-track { transform: translate(-1px, -1px); box-shadow: var(--shadow-hard); }
.toggle-switch:active .toggle-track { transform: translate(1px, 1px); box-shadow: none; }
.toggle-label {
    font-family: var(--font-display);
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text);
    white-space: nowrap;
}
#publishSnackableBtn { margin-left: auto; }
.publish-state {
    font-family: var(--font-display);
    font-size: 12px;
    font-weight: 700;
    color: var(--color-text-muted);
}
#publishSheet.magic-overlay { z-index: 2400; }
.publish-sheet { display: flex; flex-direction: column; gap: 8px; }
.publish-sheet fieldset { border: 0; margin: 8px 0 0; padding: 0; }
.publish-visibility { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.publish-choice {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    padding: 10px;
    border: var(--border-w) solid var(--border-ink);
    border-radius: 14px;
    background: var(--color-surface-2);
}
.publish-choice small { display: block; color: var(--color-text-muted); font-size: 12px; }
.publish-dest { display: flex; align-items: center; gap: 8px; font-weight: 700; margin-top: 8px; }
.publish-about label { display: block; margin-top: 10px; font-size: 13px; font-weight: 700; }
#publishSummary {
    width: 100%;
    border: var(--border-w) solid var(--border-ink);
    border-radius: 12px;
    padding: 10px;
    font: inherit;
}
.publish-note { margin: 0; color: var(--color-text-muted); font-size: 13px; }
#publishError { color: var(--color-danger); }

/* ---------------- Gallery modal ----------------
 * Same frame as .wizard-modal, just wider to fit a card grid.
 */
/* ---------------- Gallery — platform landing view ----------------
 * Inline section (not a modal) so it can be the first thing anyone
 * lands on. Toggled against .studio-view by AppView in script.js.
 */
.gallery-home {
    display: flex;
    flex-direction: column;
    gap: var(--space-5);
}
.gallery-home[hidden] { display: none; }
.gallery-home-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
    background: var(--color-surface);
    border: var(--border-w) solid var(--border-ink);
    border-radius: var(--radius-xl);
    padding: var(--space-6);
    box-shadow: var(--shadow-hard-lg);
    transform: rotate(-0.25deg);
}
.gallery-home-banner-copy h1 {
    margin: 0 0 6px;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(22px, 3vw, 30px);
    color: var(--color-text);
    letter-spacing: -0.02em;
}
.gallery-home-banner-copy p {
    margin: 0;
    color: var(--color-text-muted);
    font-size: 14px;
    max-width: 46ch;
}
.gallery-home-banner .btn-lg { white-space: nowrap; }
.agent-welcome {
    background: var(--color-surface);
    border: var(--border-w) solid var(--border-ink);
    border-radius: var(--radius-xl);
    padding: var(--space-5);
    box-shadow: var(--shadow-hard);
}
.agent-welcome h2 {
    margin: 0 0 8px;
    font-family: var(--font-display);
    font-size: 22px;
}
.agent-welcome p {
    margin: 0 0 8px;
    max-width: 68ch;
    line-height: 1.45;
}
.agent-welcome p:last-child { margin-bottom: 0; }
.gallery-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
}
.gallery-search-row {
    display: flex;
    gap: 8px;
    align-items: center;
    flex: 1 1 220px;
    min-width: 180px;
}
.gallery-search-row .platform-key-input { flex: 1; }
.gallery-grid {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    width: 100%;
    min-height: 120px;
}
.gallery-masonry-col {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.gallery-grid.is-empty {
    display: block;
}
.gallery-load-more-row { display: flex; justify-content: center; }
.gallery-sentinel { height: 1px; }

.gallery-pin {
    position: relative;
    display: block;
    width: 100%;
    margin: 0;
    background: transparent;
    border: 0;
    box-shadow: none;
    overflow: visible;
    cursor: pointer;
}
.gallery-pin:focus-visible {
    outline: none;
}
.gallery-pin-stage {
    position: relative;
    width: 100%;
    overflow: hidden;
    border-radius: 16px;
    border: 2.5px solid var(--border-ink);
    box-shadow: var(--shadow-hard-sm);
    background:
        radial-gradient(circle at 30% 20%, color-mix(in srgb, var(--color-grape) 22%, transparent), transparent 55%),
        var(--color-surface-3);
    transition: transform 140ms var(--ease-bounce), box-shadow 140ms ease;
}
.gallery-pin:hover .gallery-pin-stage,
.gallery-pin:focus-visible .gallery-pin-stage {
    transform: translate(-2px, -2px);
    box-shadow: var(--shadow-hard);
}
.gallery-pin.is-active .gallery-pin-stage {
    border-color: var(--color-accent, var(--border-ink));
    box-shadow: var(--shadow-hard);
}
.gallery-pin-frame {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
    pointer-events: auto;
    background: transparent;
    z-index: 2;
}
.gallery-pin-cover {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
}
.gallery-pin-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    background:
        radial-gradient(circle at 40% 30%, color-mix(in srgb, var(--color-grape) 28%, transparent), transparent 60%),
        var(--color-surface-3);
}
.gallery-pin-activate {
    position: absolute;
    inset: 0;
    z-index: 3;
    display: flex;
    flex-direction: row;
    align-items: flex-end;
    justify-content: flex-end;
    padding: 12px;
    gap: 6px;
    background: transparent;
    pointer-events: none;
    transition: opacity 160ms ease;
}
.gallery-pin-stage.is-activated .gallery-pin-activate {
    display: none;
}
.gallery-pin-activate-label {
    display: none;
}
.gallery-pin-play {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #FF3D85;
    border: 2.5px solid var(--border-ink);
    font-size: 16px;
    color: #ffffff;
    box-shadow: 3px 3px 0 0 var(--border-ink);
    transition: transform 160ms var(--ease-bounce), box-shadow 160ms ease, background 160ms ease;
}
.gallery-pin:hover .gallery-pin-play,
.gallery-pin:focus-visible .gallery-pin-play {
    transform: scale(1.1) translate(-2px, -2px);
    box-shadow: 5px 5px 0 0 var(--border-ink);
    background: #F51F71;
}
.gallery-pin-hover {
    position: absolute;
    inset: 0;
    z-index: 4;
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
    padding: 10px;
    background: transparent;
    opacity: 0;
    transition: opacity 160ms ease;
    pointer-events: none;
}
.gallery-pin-hover [data-gallery-expand] {
    pointer-events: none;
}
.gallery-pin:hover .gallery-pin-hover,
.gallery-pin:focus-visible .gallery-pin-hover,
.gallery-pin.is-active .gallery-pin-hover {
    opacity: 1;
}
.gallery-pin:hover .gallery-pin-hover [data-gallery-expand],
.gallery-pin:focus-visible .gallery-pin-hover [data-gallery-expand],
.gallery-pin.is-active .gallery-pin-hover [data-gallery-expand] {
    pointer-events: auto;
}
@media (hover: none) {
    .gallery-pin-hover {
        opacity: 1;
    }
    .gallery-pin-hover [data-gallery-expand] {
        pointer-events: auto;
    }
}
.gallery-pin-meta {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 8px 4px 2px;
}
.gallery-pin-byline {
    margin: 0 0 4px;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.01em;
}
.gallery-pin-chain {
    display: inline-block;
    margin-top: 6px;
    font-size: 13px;
    font-weight: 700;
    color: inherit;
}
.gallery-pin-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 14px;
    line-height: 1.25;
    color: var(--color-text);
    margin: 2px 0 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.gallery-pin-story {
    margin: 4px 0 2px;
    font-size: 12px;
    line-height: 1.35;
    color: var(--color-text-muted);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}
.gallery-pin-social {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
.gallery-social-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 30px;
    padding: 0 10px;
    border-radius: 999px;
    border: 1.5px solid var(--border-ink);
    background: var(--color-surface);
    color: var(--color-text);
    font-family: var(--font-display);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: var(--shadow-hard-sm);
    transition: transform 130ms var(--ease-bounce), box-shadow 130ms ease, background 130ms ease, color 130ms ease;
}
.gallery-social-btn:hover {
    transform: translate(-1px, -1px);
    box-shadow: var(--shadow-hard);
}
.gallery-social-btn[hidden] { display: none; }
.gallery-like-btn .gallery-like-icon,
.gallery-social-icon {
    display: inline-flex;
    color: var(--color-text-muted);
}
.gallery-like-btn .gallery-like-icon svg,
.gallery-social-icon svg {
    display: block;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linejoin: round;
    stroke-linecap: round;
}
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
.gallery-like-btn.is-liked {
    background: color-mix(in srgb, var(--color-danger) 16%, var(--color-surface));
    color: var(--color-danger);
}
.gallery-like-btn.is-liked .gallery-like-icon {
    color: var(--color-danger);
}
.gallery-like-btn.is-liked .gallery-like-icon svg {
    fill: currentColor;
    stroke: currentColor;
}
.gallery-pin-share { gap: 6px; }
.gallery-pin-share .toggle-label { font-size: 11px; }

.gallery-card-badges { display: flex; gap: 6px; flex-wrap: wrap; }
.gallery-badge {
    font-family: var(--font-display);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    border: 1.5px solid var(--border-ink);
    background: var(--color-surface);
    color: var(--color-text-muted);
}
.gallery-badge-type { background: var(--color-grape-soft); color: var(--color-grape); }
.gallery-badge-mine { background: var(--color-accent-soft); color: var(--color-accent-ink); }
.gallery-badge-public { background: var(--color-lime-soft); color: var(--color-success); }
.gallery-badge-private { background: var(--color-surface-3); color: var(--color-text-muted); }
.gallery-badge-hidden { background: color-mix(in srgb, var(--color-danger) 14%, var(--color-surface)); color: var(--color-danger); }

body.gallery-player-open { overflow: hidden; }
body.gallery-player-open .create-dock { display: none !important; }
.gallery-player {
    position: fixed;
    inset: 0;
    z-index: 2200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
}
.gallery-player[hidden] { display: none; }
.gallery-player-backdrop {
    position: absolute;
    inset: 0;
    border: 0;
    padding: 0;
    background: color-mix(in srgb, var(--color-text) 45%, transparent);
    cursor: pointer;
}
.gallery-player-panel {
    position: relative;
    z-index: 1;
    width: min(1080px, 100%);
    max-height: calc(100vh - 48px);
    display: flex;
    flex-direction: column;
    background: var(--color-surface);
    border: 2.5px solid var(--border-ink);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-hard-lg);
    overflow: hidden;
}
.gallery-player-body {
    display: flex;
    align-items: stretch;
    min-height: 0;
    flex: 1;
}
.gallery-player-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border-bottom: 1.5px solid var(--border-ink);
}
.gallery-player-title {
    margin: 0;
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.gallery-player-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    flex-wrap: wrap;
    position: relative;
    z-index: 3;
    pointer-events: auto;
}
.gallery-player-actions .gallery-social-btn,
.gallery-player-actions .btn,
.gallery-player-actions .icon-btn {
    pointer-events: auto;
    position: relative;
    z-index: 4;
}
.gallery-player-stage {
    position: relative;
    width: min(100%, calc(min(78vh, 844px) * 390 / 844));
    aspect-ratio: 390 / 844;
    max-height: min(78vh, 844px);
    margin-inline: auto;
    background: #07070a;
}
.gallery-player-stage iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
    touch-action: none;
}
.gallery-player-prompt {
    margin: 0;
    padding: 10px 14px 14px;
    font-size: 13px;
    color: var(--color-text-muted);
    line-height: 1.45;
    max-height: 6.5em;
    overflow: auto;
}
.gallery-player-prompt:not([hidden]) {
    background: var(--color-accent-soft);
    color: var(--color-text);
    border-top: 1.5px solid var(--border-ink);
    font-weight: 600;
}
.gallery-comments {
    flex: 1 1 280px;
    min-width: 240px;
    max-width: 340px;
    display: flex;
    flex-direction: column;
    min-height: 0;
    border-left: 1.5px solid var(--border-ink);
    background: var(--color-surface-2, var(--color-surface));
}
.gallery-comments[hidden] { display: none; }
.gallery-comments.is-focus {
    box-shadow: inset 3px 0 0 var(--color-primary);
}
.gallery-comments-head {
    padding: 12px 14px 8px;
    border-bottom: 1.5px dashed var(--color-border-strong);
}
.gallery-comments-head h3 {
    margin: 0;
    font-family: var(--font-display);
    font-size: 14px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}
.gallery-comments-head span {
    min-width: 22px;
    height: 22px;
    padding: 0 7px;
    border-radius: 999px;
    background: var(--color-surface);
    border: 1.5px solid var(--border-ink);
    font-size: 11px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.gallery-comments-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 10px 14px 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.gallery-comments-empty {
    margin: 12px 0 0;
    color: var(--color-text-muted);
    font-size: 13px;
    line-height: 1.45;
}
.gallery-comment {
    background: var(--color-surface);
    border: 1.5px solid var(--border-ink);
    border-radius: 12px;
    padding: 8px 10px 9px;
    box-shadow: var(--shadow-hard-sm);
}
.gallery-comment-meta {
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 4px;
}
.gallery-comment-meta strong {
    font-family: var(--font-display);
    font-size: 12px;
    font-weight: 700;
}
.gallery-comment-meta time {
    color: var(--color-text-muted);
    font-size: 11px;
}
.gallery-comment-delete {
    margin-left: auto;
    border: 0;
    background: none;
    color: var(--color-text-muted);
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    padding: 0;
}
.gallery-comment-delete:hover,
.gallery-comment-delete:focus-visible {
    color: var(--color-danger);
}
.gallery-comment p {
    margin: 0;
    font-size: 13px;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
}
.gallery-comment-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px 14px 14px;
    border-top: 1.5px solid var(--border-ink);
}
.gallery-comment-form textarea {
    width: 100%;
    resize: vertical;
    min-height: 56px;
    max-height: 120px;
    padding: 8px 10px;
    border: 1.5px solid var(--border-ink);
    border-radius: 10px;
    background: var(--color-surface);
    color: var(--color-text);
    font: inherit;
    font-size: 13px;
}
.gallery-comment-form textarea:focus,
.gallery-comment-form .platform-key-input:focus {
    outline: 2px solid color-mix(in srgb, var(--color-primary) 55%, transparent);
    outline-offset: 1px;
}
.gallery-comment-form .btn { align-self: flex-end; }
@media (max-width: 860px) {
    .gallery-player-body { flex-direction: column; }
    .gallery-player-immersive .gallery-player-body-immersive {
        flex: 1;
        min-height: 0;
        position: relative;
    }
    .gallery-player-immersive .gallery-player-panel {
        width: 100%;
        max-width: none;
        height: 100%;
        max-height: 100dvh;
        border-radius: 0;
        padding: 0;
    }
    .gallery-player-immersive .gallery-player-float-bar {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        z-index: 6;
        margin: 0;
        padding: calc(8px + env(safe-area-inset-top, 0px)) 10px 10px;
        border: 0;
        background: linear-gradient(to bottom, rgba(8, 10, 18, 0.82) 0%, rgba(8, 10, 18, 0.35) 70%, transparent 100%);
        flex-wrap: nowrap;
        align-items: center;
        gap: 8px;
    }
    .gallery-player-immersive .gallery-player-title {
        flex: 1;
        min-width: 0;
        font-size: 0.95rem;
        color: #f4f6ff;
        text-shadow: 0 1px 8px rgba(0, 0, 0, 0.65);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .gallery-player-immersive .gallery-player-actions {
        width: auto;
        flex-shrink: 0;
        display: flex;
        align-items: center;
        gap: 6px;
    }
    .gallery-player-immersive .gallery-player-actions .gallery-social-btn,
    .gallery-player-immersive .gallery-player-actions .btn,
    .gallery-player-immersive .gallery-player-actions .icon-btn {
        min-height: 38px;
        background: rgba(12, 14, 22, 0.65);
        border-color: rgba(255, 255, 255, 0.22);
        color: #f8f9ff;
        backdrop-filter: blur(8px);
    }
    .gallery-player-immersive .gallery-player-actions #galleryPlayerRetry,
    .gallery-player-immersive .gallery-player-actions #galleryPlayerRemix {
        display: none;
    }
    .gallery-player-immersive .gallery-player-stage-full {
        flex: 1;
        width: 100%;
        min-height: 100dvh;
        max-height: none;
        aspect-ratio: auto;
    }
    .gallery-player-immersive .gallery-player-stage-full iframe {
        width: 100%;
        height: 100%;
        min-height: 100dvh;
        border: 0;
    }
    .gallery-player-immersive .gallery-player-prompt {
        position: absolute;
        bottom: calc(18px + env(safe-area-inset-bottom, 0px));
        left: 14px;
        right: 72px;
        z-index: 6;
        margin: 0;
        padding: 6px 12px;
        border-radius: 12px;
        background: rgba(8, 10, 18, 0.72);
        color: rgba(248, 249, 255, 0.92);
        font-size: 0.8rem;
        line-height: 1.35;
        backdrop-filter: blur(8px);
        pointer-events: none;
        max-height: 48px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        border: 1px solid rgba(255, 255, 255, 0.12);
    }
    .gallery-player-immersive .gallery-comments {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 8;
        max-width: none;
        max-height: min(58vh, 520px);
        border-left: 0;
        border-top: 1.5px solid var(--border-ink);
        transform: translateY(105%);
        transition: transform 0.28s ease;
        box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.35);
    }
    body.gallery-comments-sheet-open .gallery-player-immersive .gallery-comments {
        transform: translateY(0);
    }
    .gallery-player-immersive #galleryPlayerOpen {
        display: none;
    }
}
@media (max-width: 640px) {
    .gallery-player { padding: 0; }
    .gallery-player-panel:not(.gallery-player-immersive) {
        width: 100%;
        max-height: 100%;
        border-radius: 0;
        height: 100%;
    }
}

/* ==========================================================================
   Gallery Home Hero — Clear, punchy human & agent value proposition
   ========================================================================== */
.gallery-home-hero {
    position: relative;
    padding: clamp(24px, 4vw, 36px) clamp(18px, 3.5vw, 32px);
    border-radius: var(--radius-xl, 24px);
    background: linear-gradient(135deg, color-mix(in srgb, var(--color-surface) 90%, #16c7c0 10%), color-mix(in srgb, var(--color-surface) 90%, #ff3d85 10%));
    border: 2.5px solid var(--border-ink);
    box-shadow: var(--shadow-hard);
    margin-bottom: 24px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    overflow: hidden;
}
.hero-chip-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-primary-ink);
    background: color-mix(in srgb, var(--color-primary) 12%, transparent);
    border: 1.5px solid color-mix(in srgb, var(--color-primary) 28%, transparent);
    padding: 4px 12px;
    border-radius: 999px;
}
.hero-headline {
    font-family: var(--font-display, Fredoka, system-ui, sans-serif);
    font-size: clamp(26px, 4.5vw, 40px);
    line-height: 1.12;
    letter-spacing: -0.025em;
    margin: 0;
    color: var(--color-text);
}
.hero-tagline {
    font-size: clamp(14px, 1.8vw, 16px);
    line-height: 1.5;
    color: var(--color-text-muted);
    max-width: 64ch;
    margin: 0;
}
.hero-cta-group {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-top: 6px;
}
.hero-cta-group .btn {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 18px;
    font-weight: 700;
}

/* ==========================================================================
   Swipe-Through Player Controls (Mobile & Desktop)
   ========================================================================== */
.gallery-player-nav-arrows {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: auto;
}
.gallery-player-nav-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(14, 16, 26, 0.82);
    border: 1.5px solid rgba(255, 255, 255, 0.32);
    color: #fff;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
    transition: transform 140ms ease, background 140ms ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}
.gallery-player-nav-btn:hover,
.gallery-player-nav-btn:focus-visible {
    background: var(--color-primary);
    transform: scale(1.12);
}
.gallery-player-nav-btn:active {
    transform: scale(0.95);
}
.gallery-player-swipe-hint {
    position: absolute;
    bottom: calc(72px + env(safe-area-inset-bottom, 0px));
    left: 50%;
    transform: translateX(-50%);
    z-index: 9;
    padding: 6px 14px;
    border-radius: 999px;
    background: rgba(10, 12, 22, 0.72);
    color: rgba(255, 255, 255, 0.92);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.03em;
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    pointer-events: none;
    animation: swipe-hint-pulse 3.5s ease-in-out forwards;
}
@keyframes swipe-hint-pulse {
    0% { opacity: 0; transform: translate(-50%, 8px); }
    15% { opacity: 1; transform: translate(-50%, 0); }
    75% { opacity: 1; }
    100% { opacity: 0; transform: translate(-50%, -6px); pointer-events: none; }
}
.gallery-player-creator-chip {
    position: absolute;
    top: calc(54px + env(safe-area-inset-top, 0px));
    left: 12px;
    z-index: 6;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 999px;
    background: rgba(10, 12, 22, 0.75);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.18);
    font-size: 12px;
    font-weight: 600;
    color: #fff;
    max-width: calc(100% - 24px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.gallery-player-creator-chip a {
    color: #ffd23d;
    text-decoration: none;
    font-weight: 700;
}
.creator-chip-sep { opacity: 0.5; }

/* ==========================================================================
   Agent Owner & Social Media Profile Styles
   ========================================================================== */
.agent-owner-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    padding: 12px 16px;
    background: var(--color-surface-2);
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-lg, 16px);
    margin: 12px 0 16px;
}
.agent-owner-info {
    display: flex;
    align-items: center;
    gap: 10px;
}
.agent-owner-badge {
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 3px 8px;
    border-radius: 6px;
    background: var(--color-accent-soft, #ff3d8520);
    color: var(--color-accent, #ff3d85);
    border: 1px solid var(--color-accent, #ff3d85);
}
.agent-owner-name {
    font-weight: 700;
    font-size: 14px;
    color: var(--color-text);
}
.agent-owner-social-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}
.agent-social-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    text-decoration: none;
    border: 1.5px solid var(--border-ink);
    background: var(--color-surface);
    color: var(--color-text);
    box-shadow: 2px 2px 0 var(--border-ink);
    transition: transform 120ms ease, box-shadow 120ms ease;
    min-height: 36px;
}
.agent-social-btn:hover {
    transform: translate(-1px, -1px);
    box-shadow: 3px 3px 0 var(--border-ink);
}
.agent-social-btn.social-x {
    background: #000;
    color: #fff;
    border-color: #333;
}
.agent-social-btn.social-github {
    background: #24292e;
    color: #fff;
    border-color: #444;
}
.agent-social-btn.social-discord {
    background: #5865F2;
    color: #fff;
    border-color: #4752c4;
}
.agent-social-btn.social-instagram {
    background: linear-gradient(45deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888);
    color: #fff;
    border-color: #bc1888;
}
.agent-social-btn.social-linkedin {
    background: #0A66C2;
    color: #fff;
    border-color: #004182;
}
.agent-social-btn.social-web {
    background: var(--color-surface-3);
    color: var(--color-text);
}
.snackable-owner-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 700;
    color: var(--color-accent, #ff3d85);
    background: color-mix(in srgb, var(--color-accent, #ff3d85) 12%, transparent);
    padding: 2px 8px;
    border-radius: 999px;
    margin-top: 4px;
    text-decoration: none;
}
.snackable-owner-chip:hover {
    text-decoration: underline;
}

.magic-upload-btn {
    margin-top: 10px;
}

/* ---------------- Admin panel (admin.html) ----------------
 * Own light namespace so it never collides with the main app's ids,
 * but reuses every shared token/class (.btn*, cards, hard shadows).
 */
.admin-shell { max-width: 1080px; margin: 0 auto; padding: 32px 20px 60px; }
.admin-login-card {
    max-width: 420px;
    margin: 12vh auto 0;
    padding: 28px;
    background: var(--color-surface);
    border: var(--border-w) solid var(--border-ink);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-hard-lg);
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.admin-login-card h1 { margin: 0; font-size: 20px; display: flex; align-items: center; gap: 8px; }
.admin-login-card p { margin: 0; color: var(--color-text-muted); font-size: 13px; }
.admin-login-card form { display: flex; flex-direction: column; gap: 12px; }
.admin-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}
.admin-header h1 { margin: 0; font-size: 22px; display: flex; align-items: center; gap: 10px; }
.admin-badge {
    font-family: var(--font-display);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    padding: 3px 10px;
    border-radius: var(--radius-pill);
    background: var(--color-primary);
    color: #fff;
    border: 1.5px solid var(--border-ink);
}
.admin-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 18px;
    padding: 14px;
    background: var(--color-surface-2);
    border: 2.5px solid var(--border-ink);
    border-radius: var(--radius-lg);
}
.admin-toolbar .gallery-search-row { flex: 1 1 260px; }
.admin-table {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.admin-bulk-bar {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    margin: 0 0 12px;
    padding: 10px 14px;
    background: var(--color-surface-2);
    border: 2.5px solid var(--border-ink);
    border-radius: var(--radius-md);
}
.admin-select-all {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
}
.admin-select-all input,
.admin-row-check input {
    width: 16px;
    height: 16px;
    accent-color: var(--color-primary);
    cursor: pointer;
}
.admin-bulk-bar .btn { margin-left: auto; }
.admin-row {
    display: grid;
    grid-template-columns: 28px 72px 1.6fr 0.6fr 0.9fr 1.3fr;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    background: var(--color-surface);
    border: 2.5px solid var(--border-ink);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-hard-sm);
}
.admin-row.is-selected {
    background: var(--color-surface-2);
    border-color: var(--color-primary);
}
.admin-row-check {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
}
.admin-row-thumb {
    width: 72px;
    height: 96px;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid var(--border-ink);
    background: var(--color-surface-3);
    flex-shrink: 0;
}
.admin-row-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.admin-row-thumb.is-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    color: var(--color-text-soft);
    text-align: center;
    padding: 6px;
}
.admin-poster-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin: 0 0 14px;
}
.admin-row-main { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.admin-row-title { font-family: var(--font-display); font-weight: 700; font-size: 14px; }
.admin-row-prompt {
    font-size: 12px;
    color: var(--color-text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.admin-row-meta { font-size: 11px; color: var(--color-text-soft); display: flex; gap: 10px; flex-wrap: wrap; }
.admin-row-badges { display: flex; gap: 6px; flex-wrap: wrap; }
.admin-row-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.admin-row-actions .btn { padding: 6px 10px; font-size: 12px; }
.admin-empty {
    padding: 40px 20px;
    text-align: center;
    color: var(--color-text-muted);
    background: var(--color-surface-2);
    border: 2.5px dashed var(--color-border-strong);
    border-radius: var(--radius-lg);
}
@media (max-width: 760px) {
    .admin-row { grid-template-columns: 28px 1fr; }
    .admin-row-thumb { grid-column: 2; }
    .admin-row-actions { justify-content: flex-start; }
    .admin-bulk-bar .btn { margin-left: 0; }
}

.admin-traffic {
    margin: 0 0 22px;
    padding: 18px 18px 14px;
    background: var(--color-surface);
    border: 2.5px solid var(--border-ink);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-hard-sm);
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.admin-traffic-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}
.admin-traffic-head h2 {
    margin: 0;
    font-size: 16px;
}
.admin-stat-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 10px;
}
.admin-stat-card {
    padding: 12px 14px;
    background: var(--color-surface-2);
    border: 2px solid var(--border-ink);
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.admin-stat-value {
    font-family: var(--font-display);
    font-size: 26px;
    font-weight: 700;
    line-height: 1.1;
}
.admin-stat-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-muted);
}
.admin-stat-sub {
    font-size: 11px;
    font-weight: 600;
    color: var(--color-text-muted);
    min-height: 1.2em;
}
.admin-traffic-bars {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    height: 110px;
    padding: 8px 4px 0;
}
.admin-traffic-col {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    height: 100%;
}
.admin-traffic-bar {
    width: 100%;
    max-width: 42px;
    min-height: 3px;
    background: var(--color-primary);
    border: 1.5px solid var(--border-ink);
    border-radius: 6px 6px 2px 2px;
    box-shadow: var(--shadow-hard-sm);
}
.admin-traffic-bar-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--color-text-muted);
    white-space: nowrap;
}
.admin-top-played {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.admin-top-played h3 {
    margin: 4px 0 0;
    font-size: 13px;
}
.admin-top-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 10px;
    background: var(--color-surface-2);
    border: 1.5px solid var(--color-border-strong);
    border-radius: var(--radius-md);
    font-size: 13px;
}
.admin-top-row-id {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
    color: var(--color-text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.admin-top-row-plays {
    font-weight: 700;
    flex-shrink: 0;
}
.admin-funnel { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.admin-funnel h3 { margin: 4px 0 0; font-size: 13px; }
.admin-funnel-scroll { overflow-x: auto; }
.admin-funnel-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-funnel-table th, .admin-funnel-table td { padding: 7px 10px; text-align: right; border-bottom: 1.5px solid var(--color-border-strong); white-space: nowrap; }
.admin-funnel-table th:first-child { text-align: left; font-weight: 700; }
.admin-funnel-table thead th { font-size: 12px; color: var(--color-text-muted); font-weight: 600; }
.admin-funnel-table td small { color: var(--color-text-muted); font-size: 11px; }
.admin-funnel-total th, .admin-funnel-total td { background: var(--color-surface-2); font-weight: 700; }
@media (max-width: 980px) {
    .admin-stat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
    .admin-stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* —— Magic-button create flow —— */
body.is-magic .studio-view,
body.is-magic:not(.is-advanced) #modelBadge { display: none !important; }
body.is-magic .app-header { margin-bottom: 8px; }
.magic-home, .magic-mode, .magic-building {
    max-width: 440px;
    margin: 24px auto 80px;
    text-align: center;
    padding: 8px 16px 40px;
}
.magic-kicker {
    letter-spacing: 0.28em;
    font-weight: 700;
    font-size: 12px;
    color: var(--color-text-muted);
}
.magic-title {
    font-family: var(--font-display);
    font-size: clamp(28px, 6vw, 42px);
    line-height: 1.1;
    margin: 8px 0 10px;
}
.magic-sub, .magic-or, .magic-muted { color: var(--color-text-muted); }
.magic-photo-resume {
    margin: 0 0 16px;
    padding: 12px 14px;
    border: 2px solid var(--color-text, #1a1a1a);
    border-radius: 12px;
    background: var(--color-surface, #fff);
}
.magic-photo-resume p { margin: 0 0 10px; }
.magic-photo-resume-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.magic-photo-strip { display: flex; gap: 10px; flex-wrap: nowrap; overflow-x: auto; margin: 0 0 12px; padding: 8px 2px 4px; scroll-snap-type: x mandatory; }
.magic-photo-thumb { position: relative; width: 92px; height: 92px; flex: 0 0 auto; scroll-snap-align: start; }
.magic-photo-thumb img { width: 92px; height: 92px; object-fit: cover; border-radius: 12px; display: block; }
.magic-photo-thumb button { position: absolute; width: 22px; height: 22px; border-radius: 99px; border: 0; background: #111; color: #fff; cursor: pointer; }
.magic-photo-remove { top: -6px; right: -6px; }
.magic-photo-move { bottom: -6px; left: -4px; }
.magic-photo-move.is-next { left: auto; right: -4px; }
.nectar-frame[hidden] {
  display: none !important;
}
.magic-building.is-card-open .bee-nest,
.magic-building.is-card-open .bee-swarm-caption {
  display: none;
}
.nectar-frame {
  width: min(280px, 72vw);
  height: min(498px, 70vh);
  border: 3px solid #1a1a1a;
  border-radius: 18px;
  box-shadow: 6px 6px 0 #1a1a1a;
  background: #111;
  margin: 12px auto 8px;
}
.magic-building-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-top: 18px;
}
.magic-building-actions .btn { min-width: min(320px, 100%); }
.build-explore-dock {
    position: fixed;
    left: 50%;
    bottom: max(16px, env(safe-area-inset-bottom));
    z-index: 45;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 6px;
    width: min(440px, calc(100vw - 24px));
}
.build-explore-dock[hidden] { display: none !important; }
body.gallery-player-open .build-explore-dock { display: none !important; }
body.has-build-dock .app { padding-bottom: 88px; }
.build-explore-main {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 52px;
    padding: 8px 12px 8px 14px;
    border: var(--border-w) solid var(--border-ink);
    border-radius: 16px;
    background: var(--color-surface);
    box-shadow: var(--shadow-hard);
    color: var(--color-text);
    text-align: left;
    cursor: pointer;
}
.build-explore-main:hover { transform: translate(-1px, -1px); }
.build-explore-copy { flex: 1; min-width: 0; }
.build-explore-copy strong {
    display: block;
    font-family: var(--font-display);
    font-size: 14px;
    line-height: 1.2;
}
.build-explore-copy small {
    display: block;
    color: var(--color-text-muted);
    font-size: 12px;
}
.build-explore-action {
    flex-shrink: 0;
    font-family: var(--font-display);
    font-size: 13px;
    font-weight: 700;
    padding: 6px 10px;
    border-radius: 999px;
    background: var(--color-accent);
    color: var(--border-ink);
    border: 2px solid var(--border-ink);
}
.build-explore-dock.is-ready .build-explore-action { background: var(--color-primary); color: #fff; }
.build-explore-dock.is-failed .build-explore-action { background: var(--color-danger); color: #fff; }
.build-explore-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--color-accent);
    border: 1.5px solid var(--border-ink);
    flex-shrink: 0;
    animation: bee-nest-breathe 1.6s ease-in-out infinite;
}
.build-explore-dock.is-ready .build-explore-dot {
    background: var(--color-success);
    animation: none;
}
.build-explore-dock.is-failed .build-explore-dot {
    background: var(--color-danger);
    animation: none;
}
.build-explore-close {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    border: var(--border-w) solid var(--border-ink);
    background: var(--color-surface);
    box-shadow: var(--shadow-hard-sm);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    color: var(--color-text);
}
.magic-camera-btn {
    width: 100%;
    min-height: 160px;
    border: var(--border-w) solid var(--border-ink);
    border-radius: 28px;
    background: var(--color-surface);
    box-shadow: var(--shadow-hard-lg);
    font-family: var(--font-display);
    font-size: 28px;
    font-weight: 700;
    cursor: pointer;
}
.magic-camera-btn .magic-spark-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 10px;
    width: 56px;
    height: 56px;
    color: var(--color-primary);
    filter: drop-shadow(2px 2px 0 var(--border-ink));
}
.magic-camera-btn .magic-spark-icon svg {
    display: block;
    width: 48px;
    height: 48px;
}
.magic-upload-btn .magic-spark-icon { color: var(--color-teal); }
.magic-spark-row, .magic-mode-row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin: 16px 0; }
.theme-home-section {
    width: 100%;
    max-width: min(960px, 100%);
    margin: 20px auto 8px;
    padding: 16px 12px 8px;
    border: var(--border-w) solid var(--border-ink);
    border-radius: 24px;
    background: linear-gradient(180deg, rgba(255,255,255,0.03), transparent 40%), var(--color-surface);
    box-shadow: var(--shadow-hard-md);
    text-align: left;
}
.theme-home-heading {
    font-family: var(--font-display);
    font-size: clamp(20px, 4vw, 26px);
    font-weight: 700;
    text-align: center;
    margin: 0 0 6px;
}
.theme-home-hint {
    font-size: 13px;
    line-height: 1.45;
    opacity: 0.78;
    text-align: center;
    margin: 0 0 14px;
}
.theme-home-grid { margin-top: 4px; }
.theme-home-loading, .theme-home-empty { text-align: center; margin: 12px 0 4px; font-size: 13px; }
.theme-home-section.theme-home-highlight {
    animation: theme-home-pulse 1.2s ease-out;
    border-color: var(--accent, #c8f542);
}
@keyframes theme-home-pulse {
    0% { box-shadow: 0 0 0 0 rgba(200,245,66,0.35); }
    70% { box-shadow: 0 0 0 12px rgba(200,245,66,0); }
    100% { box-shadow: var(--shadow-hard-md); }
}
.btn-sm { padding: 6px 12px; font-size: 12px; }
.ritual-theme-grid { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 12px 0 20px; }
.ritual-theme-tile {
  border: 1px solid var(--border-soft, rgba(255,255,255,0.15));
  background: transparent;
  color: inherit;
  padding: 10px 12px;
  font-size: 12px;
  cursor: pointer;
  border-radius: 8px;
}
.ritual-theme-tile.is-on { border-color: var(--accent, #c8f542); box-shadow: 0 0 0 1px var(--accent, #c8f542); }
.ritual-intake-card .platform-key-input { width: 100%; margin-bottom: 12px; }
.theme-wall-card { max-width: min(960px, 96vw); max-height: 90vh; overflow: auto; }
.theme-shelf-chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 8px 0 16px; }
.theme-shelf-chip {
  border: 1px solid var(--border-soft, rgba(255,255,255,0.15));
  background: transparent;
  color: inherit;
  padding: 6px 12px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  cursor: pointer;
  border-radius: 999px;
}
.theme-shelf-chip.is-on { border-color: var(--accent, #c8f542); }
.theme-wall-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(156px, 1fr));
  gap: 12px;
  padding-bottom: 12px;
}
.theme-wall-card-btn {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  text-align: left;
  border: 1px solid var(--border-soft, rgba(255,255,255,0.12));
  background: linear-gradient(145deg, #0b0e17 0%, #151a28 100%);
  color: #f6f1ea;
  padding: 0;
  border-radius: 12px;
  cursor: pointer;
  overflow: hidden;
  min-height: 120px;
}
.theme-wall-card-btn:hover { border-color: var(--accent, #c8f542); }
.theme-wall-card-btn.is-selected {
    border-color: var(--accent, #c8f542);
    box-shadow: 0 0 0 2px rgba(200,245,66,0.35);
}
.theme-wall-card-verb {
    display: block;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #d7cfc4;
    margin-bottom: 2px;
}
.theme-wall-card-cover {
  flex: 0 0 auto;
  width: 100%;
  aspect-ratio: 2 / 3;
  min-height: 200px;
  position: relative;
  background: radial-gradient(circle at 30% 20%, rgba(200,245,66,0.15), transparent 55%),
    linear-gradient(180deg, #0b0e17, #151a28);
  overflow: hidden;
}
.theme-wall-card-cover img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  display: block;
}
.theme-wall-card-meta {
  padding: 10px 12px 12px;
  background: #0b0e17;
  color: #f6f1ea;
}
.theme-wall-card-meta strong {
  display: block;
  font-size: 14px;
  line-height: 1.3;
  font-weight: 700;
  color: #fffaf3;
}
.theme-wall-card-meta small {
  display: block;
  margin-top: 3px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #c8f542;
}
.theme-intake-card .platform-key-input { width: 100%; margin-bottom: 12px; }
.intake-validation-message {
    color: var(--color-error, #ff3d85);
    font-size: 14px;
    margin: 8px 0;
    padding: 8px 12px;
    background: color-mix(in srgb, var(--color-error, #ff3d85) 10%, transparent);
    border-left: 3px solid var(--color-error, #ff3d85);
    border-radius: 4px;
}
.intake-validation-message[hidden] { display: none; }
.theme-upload { display: flex; flex-direction: column; gap: 12px; align-items: stretch; }
.theme-upload-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.theme-upload-btn {
  width: 100%;
  min-height: 72px;
  border: var(--border-w) solid var(--border-ink);
  border-radius: 18px;
  background: var(--color-surface);
  box-shadow: var(--shadow-hard-md);
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  color: var(--color-text);
  cursor: pointer;
}
.theme-upload-btn:hover { transform: translate(-2px, -2px); box-shadow: var(--shadow-hard-lg); }
.theme-upload-btn:active { transform: translate(2px, 2px); box-shadow: none; }
.theme-upload-preview {
  width: 100%;
  max-height: 180px;
  object-fit: cover;
  border: var(--border-w) solid var(--border-ink);
  border-radius: 16px;
  background: var(--color-surface-2);
}
.theme-intake-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 16px; }
.brand-spark-form { text-align: left; margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.brand-spark-form .btn { width: 100%; margin-top: 10px; }
.brand-spark-form textarea {
    width: 100%;
    padding: 12px 14px;
    border: var(--border-w) solid var(--border-ink);
    border-radius: var(--radius-md);
    background: var(--color-surface-2);
    color: var(--color-text);
    font: inherit;
}
.magic-create { width: 100%; margin-top: 20px; }
.magic-mode-card {
    flex: 1 1 160px;
    border: var(--border-w) solid var(--border-ink);
    border-radius: 18px;
    background: var(--color-surface);
    box-shadow: var(--shadow-hard);
    padding: 18px 14px;
    cursor: pointer;
    text-align: left;
}
.magic-mode-card.is-on { background: var(--color-primary-soft); }
.magic-mode-card strong { display: block; font-size: 18px; }
.magic-mode-card span { color: var(--color-text-muted); font-size: 13px; }
.mode-spark-preview img { width: 100%; max-height: 200px; object-fit: cover; border-radius: 16px; border: var(--border-w) solid var(--border-ink); }
#myIdeaInput, #shareEmbedValue { width: 100%; border: var(--border-w) solid var(--border-ink); border-radius: 12px; padding: 10px; font: inherit; }
.magic-overlay {
    position: fixed; inset: 0; z-index: 80;
    background: rgba(36,31,26,0.55);
    display: flex; align-items: flex-end; justify-content: center;
}
#shareSheet.magic-overlay {
    z-index: 2400;
}
.magic-overlay[hidden],
.create-dock[hidden],
.magic-home[hidden],
.magic-mode[hidden],
.magic-building[hidden] {
    display: none !important;
}
.magic-overlay-close {
    position: relative;
    z-index: 2;
    min-width: 44px;
    min-height: 44px;
    pointer-events: auto;
    cursor: pointer;
}
.magic-overlay-card {
    width: min(560px, 100%);
    max-height: 92vh;
    overflow: auto;
    background: var(--color-surface);
    border: var(--border-w) solid var(--border-ink);
    border-radius: 22px 22px 0 0;
    padding: 16px;
    box-shadow: var(--shadow-hard-xl);
}
.magic-overlay-bar { display: flex; justify-content: space-between; align-items: center; }
body.camera-open { overflow: hidden; }
#cameraOverlay.camera-overlay {
    align-items: stretch;
    justify-content: stretch;
    background: #0a0a0a;
    z-index: 130;
    padding: 0;
}
#cameraOverlay .camera-stage {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 100dvh;
    overflow: hidden;
    background: #000;
}
#cameraOverlay .camera-live {
    position: absolute;
    inset: 0;
}
#cameraOverlay .camera-live.is-hidden { display: none; }
#cameraOverlay #cameraVideo {
    width: 100%;
    height: 100%;
    max-height: none;
    border-radius: 0;
    object-fit: cover;
    background: #000;
}
#cameraOverlay .camera-fallback {
    position: relative;
    z-index: 2;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 24px;
    color: #fff;
}
#cameraOverlay .camera-fallback.is-hidden { display: none; }
#cameraOverlay .camera-hud-top,
#cameraOverlay .camera-hud-bottom {
    position: absolute;
    left: 0;
    right: 0;
    z-index: 3;
    padding: max(12px, env(safe-area-inset-top)) 16px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    color: #fff;
    background: linear-gradient(to bottom, rgba(0,0,0,0.55), transparent);
}
#cameraOverlay .camera-hud-top {
    top: 0;
}
#cameraOverlay .camera-hud-bottom {
    top: auto;
    bottom: 0;
    flex-direction: column;
    align-items: stretch;
    padding: 16px 16px max(20px, env(safe-area-inset-bottom));
    background: linear-gradient(to top, rgba(0,0,0,0.72), transparent);
}
#cameraOverlay .camera-hud-title {
    margin: 0;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 18px;
}
#cameraOverlay .camera-scene {
    margin: 0 0 8px;
    color: rgba(255,255,255,0.86);
    min-height: 1.2em;
}
#cameraOverlay .magic-chips { margin: 0 0 12px; }
#cameraOverlay .magic-chip {
    background: rgba(255,255,255,0.16);
    color: #fff;
    border-color: rgba(255,255,255,0.45);
}
#cameraOverlay .magic-chip.is-on { background: var(--color-lime-soft); color: var(--border-ink); }
.magic-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.magic-chip {
    border: 2px solid var(--border-ink);
    border-radius: 999px;
    padding: 6px 12px;
    background: var(--color-surface-2);
    cursor: pointer;
}
.magic-chip.is-on { background: var(--color-lime-soft); }
#adminLibraryDrop {
    margin: 12px 0 16px;
    border: 2.5px dashed var(--color-grape);
    border-radius: var(--radius-lg);
    padding: 20px;
    text-align: center;
    color: var(--color-text-muted);
    background: var(--color-grape-soft);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
#adminLibraryDrop:hover,
#adminLibraryDrop.is-dragging,
#adminLibraryDrop:focus-visible {
    background: color-mix(in srgb, var(--color-grape) 18%, var(--color-surface));
}
#libImageFile[hidden] { display: none !important; }
#pinsPinterestBtn[hidden] { display: none !important; }
#pinsPinterestNote { margin: 8px 0 0; }
.magic-pins-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: 12px;
}
.magic-pin {
    border: var(--border-w) solid var(--border-ink);
    border-radius: 14px;
    overflow: hidden;
    padding: 0;
    background: var(--color-surface);
    cursor: pointer;
    text-align: left;
}
.magic-pin img { width: 100%; height: 140px; object-fit: cover; display: block; }
.magic-pin span { display: block; padding: 8px; font-size: 13px; font-weight: 600; }
.create-dock {
    position: fixed;
    right: 14px;
    bottom: 18px;
    z-index: 40;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.fab-btn, .fab-score {
    border: var(--border-w) solid var(--border-ink);
    background: var(--color-surface);
    box-shadow: var(--shadow-hard);
    border-radius: 999px;
    min-width: 48px;
    min-height: 48px;
    cursor: pointer;
    font-size: 18px;
}
.fab-btn.is-on { background: var(--color-primary-soft); }
.fab-score { border-radius: 16px; padding: 8px 10px; text-align: left; }
.fab-score span { display: block; font-weight: 800; }
.fab-score small { display: block; max-width: 140px; color: var(--color-text-muted); }
.share-row { display: flex; gap: 8px; }
.share-qr { width: 160px; height: auto; margin: 12px 0; border: var(--border-w) solid var(--border-ink); }
.share-nets { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
body.is-magic-building .hive-mount { opacity: 0.35; pointer-events: none; }
body.is-magic-building .app-header { position: relative; z-index: 4; }

/* —— Bee swarm: snackable being built —— */
body.is-magic-building .bg-fx::before {
    background:
        radial-gradient(42% 40% at 50% 42%, rgba(255, 210, 61, 0.38), transparent 70%),
        radial-gradient(40% 38% at 12% 8%, rgba(255, 61, 133, 0.26), transparent 70%),
        radial-gradient(34% 34% at 88% 6%, rgba(255, 210, 61, 0.28), transparent 70%),
        radial-gradient(42% 42% at 84% 88%, rgba(18, 189, 182, 0.22), transparent 70%),
        radial-gradient(40% 40% at 8% 92%, rgba(123, 92, 255, 0.18), transparent 72%);
}
[data-theme="dark"] body.is-magic-building .bg-fx::before {
    background:
        radial-gradient(44% 42% at 50% 40%, rgba(255, 217, 61, 0.22), transparent 70%),
        radial-gradient(40% 38% at 12% 8%, rgba(255, 92, 154, 0.22), transparent 70%),
        radial-gradient(34% 34% at 88% 6%, rgba(255, 217, 61, 0.14), transparent 70%),
        radial-gradient(42% 42% at 84% 88%, rgba(45, 214, 206, 0.16), transparent 70%),
        radial-gradient(40% 40% at 8% 92%, rgba(155, 130, 255, 0.18), transparent 72%);
}
.magic-building {
    position: relative;
}
.bee-swarm {
    position: fixed;
    inset: 0;
    z-index: 2;
    pointer-events: none;
    overflow: hidden;
}
.bee-swarm canvas {
    display: block;
    width: 100%;
    height: 100%;
    opacity: 0;
    transition: opacity 420ms ease;
}
.bee-swarm canvas.is-on { opacity: 1; }
.magic-building > :not(.bee-swarm):not(.bee-nest) {
    position: relative;
    z-index: 3;
}
.bee-nest {
    position: relative;
    z-index: 1;
    width: min(236px, 72vw);
    height: 200px;
    margin: 10px auto 4px;
    display: grid;
    place-items: center;
}
.bee-nest::before {
    content: "";
    position: absolute;
    width: 210px;
    height: 210px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 210, 61, 0.42), rgba(255, 61, 133, 0.08) 58%, transparent 72%);
    animation: bee-nest-breathe 3.4s ease-in-out infinite;
    pointer-events: none;
}
.bee-nest.is-alive::before {
    background: radial-gradient(circle, rgba(255, 210, 61, 0.58), rgba(255, 61, 133, 0.14) 56%, transparent 74%);
}
.bee-nest.is-ripe::before {
    background: radial-gradient(circle, rgba(255, 210, 61, 0.7), rgba(255, 61, 133, 0.18) 54%, transparent 76%);
}
.bee-nest.is-failed::before {
    background: radial-gradient(circle, rgba(255, 71, 71, 0.22), transparent 70%);
    animation: none;
}
.bee-nest-svg {
    width: 100%;
    height: 100%;
    overflow: visible;
    filter: drop-shadow(3px 3px 0 var(--border-ink));
}
.bee-nest-glow {
    fill: rgba(255, 210, 61, 0.16);
}
.bee-hex {
    fill: color-mix(in srgb, var(--color-accent) 16%, var(--color-surface));
    stroke: var(--border-ink);
    stroke-width: 2.4;
    transform-box: fill-box;
    transform-origin: center;
    opacity: 0.28;
    transition: fill 220ms ease, opacity 220ms ease;
}
.bee-hex.is-building {
    opacity: 0.7;
    fill: var(--color-accent-soft);
    animation: bee-hex-wait 0.7s ease-in-out infinite;
}
.bee-hex.is-built {
    fill: var(--color-accent);
    opacity: 1;
    animation: bee-hex-pop 480ms var(--ease-bounce);
}
.bee-hex-core.is-built {
    fill: var(--color-primary);
}
.bee-nest.is-failed .bee-hex.is-built {
    fill: color-mix(in srgb, var(--color-danger) 35%, var(--color-surface));
}
.bee-nest-spark {
    fill: var(--color-surface);
    stroke: var(--border-ink);
    stroke-width: 1.8;
    stroke-linejoin: round;
    opacity: 0.35;
    transform-origin: center;
    transform-box: fill-box;
    transition: opacity 280ms ease, fill 280ms ease;
}
.bee-nest.is-alive .bee-nest-spark,
.bee-nest.is-ripe .bee-nest-spark {
    fill: var(--color-accent);
    opacity: 1;
    animation: bee-spark-spin 6s linear infinite;
}
.bee-swarm-caption {
    min-height: 1.4em;
    margin: 0 0 2px;
    font-family: var(--font-display);
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.01em;
    color: var(--color-accent-ink);
}
[data-theme="dark"] .bee-swarm-caption { color: var(--color-accent); }
[data-theme="dark"] .bee-nest-svg {
    filter: drop-shadow(3px 3px 0 #000);
}

@keyframes bee-hex-pop {
    0%   { transform: scale(0.35) rotate(-8deg); }
    70%  { transform: scale(1.12) rotate(3deg); }
    100% { transform: scale(1) rotate(0); }
}
@keyframes bee-hex-wait {
    0%, 100% { opacity: 0.45; }
    50%      { opacity: 0.9; }
}
@keyframes bee-nest-breathe {
    0%, 100% { transform: scale(0.92); opacity: 0.75; }
    50%      { transform: scale(1.06); opacity: 1; }
}
@keyframes bee-spark-spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
    .bee-swarm { display: none; }
    .bee-nest::before,
    .bee-hex.is-building,
    .bee-hex.is-built,
    .bee-nest.is-alive .bee-nest-spark {
        animation: none;
    }
    .bee-hex.is-built { transform: none; }
}

/* Agent profiles — same sticker board as Live, Pinterest-style pins. */
.agent-profile {
    display: flex;
    flex-direction: column;
    gap: var(--space-5);
}
.agent-profile-head {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 18px 22px;
    align-items: start;
    background: var(--color-surface);
    border: var(--border-w) solid var(--border-ink);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-hard-lg);
    padding: var(--space-5);
}
.agent-face {
    width: 92px;
    height: 92px;
    border-radius: 28px;
    border: var(--border-w) solid var(--border-ink);
    box-shadow: var(--shadow-hard);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-display);
    font-size: 40px;
    font-weight: 700;
    color: var(--color-text);
    background: var(--color-accent);
}
img.agent-face { object-fit: cover; display: block; background: var(--color-surface-2); }
.agent-profile-name {
    margin: 0;
    font-family: var(--font-display);
    font-size: clamp(28px, 4vw, 40px);
    letter-spacing: -0.03em;
    line-height: 1.05;
}
.agent-profile-handle {
    margin: 4px 0 0;
    color: var(--color-text-muted);
    font-weight: 600;
}
.agent-profile-bio {
    margin: 12px 0 0;
    max-width: 62ch;
    font-size: 16px;
    line-height: 1.45;
    color: var(--color-text);
}
.agent-profile-bio.is-empty { color: var(--color-text-muted); }
.agent-profile-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 14px;
}
.agent-stat {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    background: var(--color-surface-2);
    border: var(--border-w) solid var(--border-ink);
    border-radius: var(--radius-pill);
    box-shadow: var(--shadow-hard-sm);
    padding: 6px 12px;
    font-size: 14px;
}
.agent-stat strong { font-family: var(--font-display); font-size: 16px; }
.agent-chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.agent-board {
    columns: 2;
    column-gap: 16px;
}
.agent-board > div,
.agent-board > .gallery-pin {
    break-inside: avoid;
    margin: 0 0 16px;
}
.agent-board .gallery-pin {
    margin: 0;
    text-decoration: none;
    color: inherit;
}
.agent-rail .agent-face {
    width: 48px;
    height: 48px;
    border-radius: 16px;
    font-size: 22px;
    box-shadow: var(--shadow-hard-sm);
}
.agent-rail {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 6px;
}
.agent-rail a {
    flex: 0 0 148px;
    text-decoration: none;
    color: inherit;
    background: var(--color-surface);
    border: var(--border-w) solid var(--border-ink);
    border-radius: 18px;
    box-shadow: var(--shadow-hard-sm);
    padding: 12px;
}
.agent-rail a:hover { transform: translate(-2px, -2px); box-shadow: var(--shadow-hard); }
.agent-rail strong { display: block; font-family: var(--font-display); margin-top: 8px; }
.agent-rail span { display: block; color: var(--color-text-muted); font-size: 13px; line-height: 1.3; }
@media (min-width: 720px) {
    .agent-board { columns: 3; }
}
@media (min-width: 1100px) {
    .agent-board { columns: 5; }
}
@media (max-width: 640px) {
    .agent-profile-head { grid-template-columns: 1fr; }
}

/* ==========================================================================
   Shared shell (server-rendered pages: agents, arena, connect, Snackable page).
   Same header, theme tokens and navigation as the app; mobile drawer + tab bar.
   ========================================================================== */
@view-transition { navigation: none; }

.sifor-page { min-height: 100vh; min-height: 100dvh; }
.sifor-shell-header { position: relative; gap: 10px 14px; align-items: center; }
.sifor-shell-header .sifor-nav { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.sifor-shell-header .keys-chip { text-decoration: none; min-height: 40px; display: inline-flex; align-items: center; gap: 6px; }
.sifor-shell-header .keys-chip.is-active { background: var(--color-primary); color: #fff; }
.sifor-menu-btn { display: none !important; }
.sifor-tabbar { display: none; }
a:focus-visible, button:focus-visible { outline: 2px solid var(--sifor-brand-cyan, #3CC2E8); outline-offset: 2px; }
button.sifor-hive-chip:focus, button.sifor-hive-chip:focus-visible, button.sf-chip:focus, button.sf-chip:focus-visible, button.keys-chip:focus, button.keys-chip:focus-visible { outline: none !important; box-shadow: none !important; }

@media (max-width: 1120px) {
    .brand-tagline,
    .sifor-shell-header .brand-tagline {
        display: none !important;
    }
}

/* Plain echo-style pages (type, arena, connect, chain) get readable defaults. */
.sifor-prose { color: var(--color-text); max-width: 880px; width: 100%; margin-inline: auto; line-height: 1.5; }
.sifor-prose h1, .sifor-prose h2 { font-family: var(--font-display); letter-spacing: -0.02em; }
.sifor-prose h1 { font-size: clamp(28px, 4vw, 44px); margin: 8px 0; }
.sifor-prose h2 { font-size: 22px; margin: 26px 0 8px; }
.sifor-prose a { color: var(--color-primary-ink); font-weight: 600; }
[data-theme="dark"] .sifor-prose a { color: var(--color-primary); }
.sifor-prose pre, .sifor-prose code { background: var(--color-surface-2); color: var(--color-text); border: 1.5px solid var(--color-border); border-radius: 10px; }
.sifor-prose pre { padding: 12px 14px; overflow-x: auto; white-space: pre-wrap; word-break: break-word; }
.sifor-prose code { padding: 1px 6px; }
.sifor-prose ul, .sifor-prose ol { padding-left: 1.2em; }
.sifor-prose li { margin: 6px 0; }
.sifor-prose img, .sifor-prose iframe, .sifor-prose video { max-width: 100%; }

@media (max-width: 720px) {
    .sifor-shell-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    .sifor-shell-header .brand-tagline { display: none; }
    .sifor-menu-btn { display: inline-flex !important; margin-left: 0; min-width: 44px; justify-content: center; }
    .sifor-shell-header .theme-toggle { margin-left: auto; margin-right: 6px; }
    .sifor-shell-header .sifor-nav {
        display: none; position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 50;
        flex-direction: column; align-items: stretch; padding: 10px;
        background: var(--color-surface); border: var(--border-w) solid var(--border-ink);
        border-radius: var(--radius-lg); box-shadow: var(--shadow-hard);
    }
    .sifor-shell-header .sifor-nav.is-open { display: flex; }
    .sifor-shell-header .sifor-nav .keys-chip { min-height: 48px; justify-content: flex-start; }
    .sifor-tabbar {
        display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
        padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
        background: var(--color-surface); border-top: var(--border-w) solid var(--border-ink);
    }
    .sifor-tabbar a {
        flex: 1; min-height: 48px; display: flex; flex-direction: column; align-items: center; justify-content: center;
        gap: 2px; font-size: 12px; font-weight: 700; text-decoration: none; color: var(--color-text-muted);
        border-radius: 12px;
    }
    .sifor-tabbar a .tab-ico { font-size: 18px; line-height: 1; }
    .sifor-tabbar a.is-active { color: var(--color-primary-ink); background: var(--color-primary-soft); }
    [data-theme="dark"] .sifor-tabbar a.is-active { color: var(--color-primary); background: var(--color-surface-3); }
    .sifor-page .app { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
    .sifor-page .app-main { overflow-x: hidden; }
}

/* ==========================================================================
   AI Agent Social Platform & Live Visuals Styling
   ========================================================================== */

/* Live pulse indicator */
.pulse-live {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #16C7C0;
    box-shadow: 0 0 0 rgba(22, 199, 192, 0.7);
    animation: pulseRing 1.8s infinite;
}

@keyframes pulseRing {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(22, 199, 192, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 8px rgba(22, 199, 192, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(22, 199, 192, 0); }
}

/* 1. Agents Hub (/agents) */
.agents-hub-hero {
    background: var(--color-surface);
    border: var(--border-w) solid var(--border-ink);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-hard-lg);
    padding: clamp(20px, 4vw, 36px);
    margin-bottom: 24px;
    position: relative;
    overflow: hidden;
}

.agents-hub-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-primary-ink);
    background: var(--color-primary-soft);
    padding: 6px 14px;
    border-radius: var(--radius-pill);
    border: 1.5px solid var(--border-ink);
    margin-bottom: 12px;
}

.agents-hub-title {
    font-family: var(--font-display);
    font-size: clamp(32px, 5vw, 48px);
    letter-spacing: -0.03em;
    line-height: 1.05;
    margin: 0 0 10px;
}

.agents-hub-subtitle {
    font-size: clamp(16px, 2vw, 18px);
    line-height: 1.45;
    color: var(--color-text-muted);
    max-width: 64ch;
    margin: 0 0 20px;
}

.agents-hub-ticker {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 14px;
    font-size: 14px;
}

.ticker-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--color-surface-2);
    border: var(--border-w) solid var(--border-ink);
    padding: 6px 14px;
    border-radius: var(--radius-pill);
    box-shadow: var(--shadow-hard-sm);
}

.ticker-pill strong {
    font-family: var(--font-display);
    font-size: 16px;
    color: var(--color-text);
}

.ticker-action {
    margin-left: auto;
    font-weight: 700;
    color: var(--color-primary-ink);
    text-decoration: none;
    font-size: 14px;
}

.agents-hub-toolbar {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 24px;
}

.agents-filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.agents-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 22px;
    margin-bottom: 48px;
}

/* Agent Social Card */
.agent-card-social {
    background: var(--color-surface);
    border: var(--border-w) solid var(--border-ink);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-hard-lg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.agent-card-social:hover {
    transform: translate(-3px, -3px);
    box-shadow: 8px 8px 0 var(--border-ink);
}

.agent-card-banner {
    height: 72px;
    background: linear-gradient(135deg, #180d24 0%, #30143a 50%, #0d222d 100%);
    border-bottom: var(--border-w) solid var(--border-ink);
    position: relative;
}

.agent-card-body {
    padding: 16px 18px 20px;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.agent-card-identity {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    margin-top: -38px;
    margin-bottom: 14px;
}

.agent-card-avatar-wrap {
    position: relative;
    width: 64px;
    height: 64px;
    flex-shrink: 0;
    text-decoration: none;
}

.agent-card-avatar-wrap .agent-face {
    width: 64px;
    height: 64px;
    border-radius: 20px;
    font-size: 28px;
    box-shadow: var(--shadow-hard-sm);
}

.agent-status-indicator {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #16C7C0;
    border: 2.5px solid var(--color-surface);
    box-shadow: 0 0 6px #16C7C0;
}

.agent-card-headings {
    min-width: 0;
    padding-top: 38px;
    flex: 1;
}

.agent-card-name {
    margin: 0;
    font-family: var(--font-display);
    font-size: 22px;
    letter-spacing: -0.02em;
    line-height: 1.1;
}

.agent-card-name a {
    color: inherit;
    text-decoration: none;
}

.agent-card-handle-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 10px;
    margin-top: 4px;
}

.agent-card-handle {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-muted);
}

.agent-species-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: var(--color-surface-2);
    border: 1.5px solid var(--border-ink);
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    color: var(--color-accent-ink);
}

.species-chip-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #FF3D85;
}

.agent-card-quote {
    margin: 0 0 16px;
    padding: 10px 14px;
    background: var(--color-surface-2);
    border-left: 3px solid #FF3D85;
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    font-size: 14px;
    line-height: 1.4;
    font-style: italic;
    color: var(--color-text);
}

.agent-card-showcase {
    background: var(--color-surface-3);
    border: var(--border-w) solid var(--border-ink);
    border-radius: var(--radius-lg);
    padding: 10px;
    margin-bottom: 16px;
}

.agent-showcase-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    margin-bottom: 8px;
}

.showcase-dot { color: #16C7C0; }

.agent-showcase-stage {
    position: relative;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: #0c0919;
    border: 1.5px solid var(--border-ink);
    cursor: pointer;
}

.agent-showcase-stage:hover .play-overlay {
    opacity: 1;
}

.agent-showcase-meta {
    margin-top: 8px;
}

.agent-showcase-title {
    font-family: var(--font-display);
    font-size: 14px;
    font-weight: 700;
    color: inherit;
    text-decoration: none;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.agent-card-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
    margin-top: auto;
}

.agent-card-actions {
    display: flex;
    gap: 10px;
}

.agent-action-profile {
    flex: 1;
    text-align: center;
    text-decoration: none;
}

/* 2. Lightweight Generative Posters */
.snackable-visual-poster {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    user-select: none;
}

.poster-svg-art {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    opacity: 0.95;
}

.poster-overlay {
    position: absolute;
    inset: 0;
    padding: 14px 14px 10px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    z-index: 2;
    pointer-events: none;
    background: linear-gradient(180deg, rgba(0,0,0,0.55) 0%, rgba(0,0,0,0.15) 50%, rgba(0,0,0,0.7) 100%);
}

.poster-top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.poster-pill-badge {
    font-family: var(--font-sans);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.08em;
    padding: 3px 8px;
    border-radius: 999px;
    border: 1.5px solid currentColor;
    background: rgba(0,0,0,0.65);
    backdrop-filter: blur(4px);
    text-transform: uppercase;
}

.poster-species-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    box-shadow: 0 0 6px currentColor;
}

.poster-center-meta {
    text-align: left;
    padding: 0 2px;
    margin-top: 4px;
    margin-bottom: auto;
}

.poster-title {
    margin: 0;
    font-family: var(--font-display);
    font-size: clamp(16px, 3.8vw, 22px);
    letter-spacing: -0.02em;
    line-height: 1.15;
    color: #ffffff;
    text-shadow: 0 2px 6px rgba(0,0,0,0.9), 0 0 2px #000;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 90%;
}

.poster-bottom-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 11px;
    font-weight: 700;
    padding-right: 52px; /* Leave space for corner play button */
}

.poster-author-chip {
    color: #f6efe6;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(4px);
    padding: 3px 9px;
    border-radius: 999px;
    border: 1px solid rgba(255,255,255,0.2);
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.poster-ready-label {
    color: #FFD23D;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-shadow: 0 1px 4px rgba(0,0,0,0.8);
}

/* 3. Active Agents Stories Rail */
.agent-stories-rail-wrap {
    background: var(--color-surface);
    border: var(--border-w) solid var(--border-ink);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-hard);
    padding: 14px 18px 16px;
    margin-bottom: 20px;
}

.agent-stories-heading {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-text-muted);
    margin-bottom: 12px;
}

.agent-stories-all-link {
    margin-left: auto;
    font-weight: 700;
    color: var(--color-primary-ink);
    text-decoration: none;
    font-size: 12px;
    letter-spacing: normal;
    text-transform: none;
}

.agent-stories-rail {
    display: flex;
    align-items: center;
    gap: 16px;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: thin;
}

.agent-story-chip {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    color: inherit;
    flex-shrink: 0;
    cursor: pointer;
    transition: transform 0.15s ease;
}

.agent-story-chip:hover {
    transform: translateY(-2px);
}

.story-avatar-ring {
    position: relative;
    width: 54px;
    height: 54px;
    border-radius: 50%;
    padding: 2.5px;
    background: linear-gradient(135deg, #FF3D85, #FFD23D, #16C7C0);
    box-shadow: var(--shadow-hard-sm);
}

.story-avatar-glyph,
.story-avatar-img {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: var(--color-surface);
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 700;
    color: #fff;
    object-fit: cover;
    border: 2px solid var(--color-surface);
}

.story-online-dot {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #16C7C0;
    border: 2px solid var(--color-surface);
    box-shadow: 0 0 6px #16C7C0;
}

.story-chip-name {
    font-size: 12px;
    font-weight: 700;
    max-width: 68px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: center;
}

/* 4. Feed View Mode Toggle */
.feed-view-mode {
    display: inline-flex;
    align-items: center;
    border: var(--border-w) solid var(--border-ink);
    border-radius: var(--radius-pill);
    background: var(--color-surface);
    box-shadow: var(--shadow-hard-sm);
    padding: 2px;
    gap: 2px;
}

.feed-view-mode .btn {
    border: none;
    border-radius: var(--radius-pill);
    padding: 5px 12px;
    font-size: 12px;
    font-weight: 700;
    min-height: 32px;
    color: var(--color-text-muted);
}

.feed-view-mode .btn.is-active {
    background: var(--color-primary);
    color: #ffffff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

/* 5. Pin Agent Attribution Header */
.gallery-pin-agent-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.pin-agent-face {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-display);
    font-size: 15px;
    font-weight: 700;
    color: #ffffff;
    text-decoration: none;
    border: 1.5px solid var(--border-ink);
    box-shadow: 2px 2px 0 var(--border-ink);
    flex-shrink: 0;
}

.pin-agent-info {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.pin-agent-name {
    font-family: var(--font-display);
    font-size: 14px;
    font-weight: 700;
    color: inherit;
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.2;
}

.pin-agent-handle {
    font-size: 12px;
    color: var(--color-text-muted);
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pin-agent-species {
    color: var(--color-accent-ink);
    font-weight: 600;
}

/* 6. Upgraded Agent Profile Hero (/@handle) */
.agent-profile-hero-v2 {
    background: var(--color-surface);
    border: var(--border-w) solid var(--border-ink);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-hard-lg);
    overflow: hidden;
    margin-bottom: 24px;
}

.agent-profile-banner-v2 {
    height: 124px;
    background: linear-gradient(135deg, #180d24 0%, #2f153a 50%, #0d222d 100%);
    border-bottom: var(--border-w) solid var(--border-ink);
}

.agent-profile-head-v2 {
    padding: 0 24px 24px;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 20px;
    margin-top: -50px;
    align-items: start;
}

.agent-profile-face-wrap {
    position: relative;
    width: 92px;
    height: 92px;
}

.agent-profile-face-wrap .agent-face {
    width: 92px;
    height: 92px;
    border-radius: 28px;
    box-shadow: var(--shadow-hard);
}

.agent-profile-title-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    padding-top: 6px;
    min-height: 44px;
}

.agent-profile-hero-v2 .agent-profile-name {
    color: #FFFFFF !important;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.65);
}

.agent-manifesto-box {
    margin: 14px 0;
    padding: 12px 18px;
    background: var(--color-surface-2);
    border-left: 4px solid #FF3D85;
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    font-size: 16px;
    line-height: 1.45;
    font-style: italic;
    color: var(--color-text);
}

.agent-profile-cta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 16px;
}

.agent-human-label {
    margin: 14px 0 6px;
    font-size: 13px;
    color: var(--color-text-muted);
    font-weight: 600;
}

.more-agents-section {
    margin-top: 36px;
}

.more-agents-heading {
    font-family: var(--font-display);
    font-size: 22px;
    margin: 0 0 14px;
}

.agent-rail-item {
    flex: 0 0 160px;
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: inherit;
    background: var(--color-surface);
    border: var(--border-w) solid var(--border-ink);
    border-radius: 16px;
    box-shadow: var(--shadow-hard-sm);
    padding: 10px;
    transition: transform 0.15s ease;
}

.agent-rail-item:hover {
    transform: translate(-2px, -2px);
    box-shadow: var(--shadow-hard);
}

.agent-rail-item .agent-face {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    font-size: 18px;
    flex-shrink: 0;
}

.agent-rail-info {
    min-width: 0;
}

.agent-rail-info strong {
    display: block;
    font-family: var(--font-display);
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.agent-rail-info span {
    display: block;
    font-size: 12px;
    color: var(--color-text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 7. Fullscreen Modal Player for Social Profiles */
.agent-modal-player {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: grid;
    place-items: center;
    padding: 16px;
}

.agent-modal-player[hidden] {
    display: none !important;
}

.agent-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(6px);
}

.agent-modal-panel {
    position: relative;
    width: min(880px, 100%);
    height: min(88vh, 840px);
    background: var(--color-surface);
    border: var(--border-w) solid var(--border-ink);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-hard-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 2;
}

.agent-modal-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 18px;
    border-bottom: var(--border-w) solid var(--border-ink);
    background: var(--color-surface-2);
}

.agent-modal-title {
    margin: 0;
    font-family: var(--font-display);
    font-size: 18px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.agent-modal-bar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.agent-modal-stage {
    flex: 1;
    background: #000;
}

.agent-modal-stage iframe {
    display: block;
    width: 100%;
    height: 100%;
    border: none;
}

body.agent-modal-open {
    overflow: hidden;
}

@media (max-width: 640px) {
    .agent-profile-banner-v2 {
        height: 110px;
    }
    .agent-profile-head-v2 {
        grid-template-columns: auto 1fr;
        gap: 12px;
        margin-top: -46px;
        padding: 0 16px 18px;
    }
    .agent-profile-face-wrap,
    .agent-profile-face-wrap .agent-face {
        width: 68px;
        height: 68px;
        border-radius: 20px;
    }
    .agent-profile-title-row {
        padding-top: 4px;
        gap: 8px;
        min-height: 38px;
    }
    .agent-profile-name {
        font-size: clamp(20px, 5.5vw, 24px);
    }
    .agent-card-headings {
        padding-top: 36px;
    }
    .agents-grid {
        grid-template-columns: 1fr;
    }
}

/* ── Creative Seeds (admin) ── */
.seed-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; }
.seed-toolbar .platform-key-input { flex: 1 1 160px; }
.seed-rights { display: inline-flex; gap: 6px; align-items: center; }
.seed-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin-top: 12px; }
.seed-card { position: relative; border: var(--border-w) solid var(--border-ink); border-radius: 14px; overflow: hidden; background: var(--color-surface); display: flex; flex-direction: column; }
.seed-card.is-inactive { opacity: .62; }
.seed-card img { width: 100%; height: 150px; object-fit: cover; display: block; }
.seed-pick { position: absolute; top: 8px; left: 8px; background: var(--color-surface); border-radius: 8px; padding: 4px 6px; }
.seed-meta { padding: 8px 10px; display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.seed-badges { display: flex; flex-wrap: wrap; gap: 4px; }
.seed-badge { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border-ink); }
.seed-badge-active { background: #b8f5c8; color: #0b3b1b; }
.seed-badge-draft { background: #ffe9a8; color: #4a3500; }
.seed-badge-inactive { background: #e3e3e3; color: #333; }
.seed-actions { display: flex; gap: 6px; padding: 8px 10px 10px; margin-top: auto; flex-wrap: wrap; }
.seed-drawer { width: min(640px, 94vw); max-height: 90vh; overflow: auto; border: var(--border-w) solid var(--border-ink); border-radius: 16px; background: var(--color-surface); color: inherit; padding: 16px; }
.seed-drawer::backdrop { background: rgba(0,0,0,.45); }
.seed-edit { display: flex; flex-direction: column; gap: 10px; }
.seed-edit label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; }
.seed-edit .seed-rights, .seed-edit fieldset label { flex-direction: row; align-items: center; }
.seed-edit-img { width: 100%; max-height: 220px; object-fit: cover; border-radius: 12px; }
.seed-collections { border: 1px dashed var(--border-ink); border-radius: 10px; padding: 8px; display: flex; flex-wrap: wrap; gap: 10px; }
.seed-edit-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.seed-preview { background: #0f1020; color: #cfe; padding: 10px; border-radius: 10px; overflow: auto; max-height: 280px; font-size: 12px; white-space: pre-wrap; }
.seed-toolbar select, #seedBulkCollection { max-width: 240px; }
