/* =============================================================
   AMAPELLA — SHARED STYLES
   ============================================================= */

/* ============================================= PALETTE */

:root {
    --bg-deepest: #0F1418;
    --bg-deepest-rgb: 15, 20, 24;
    --bg-panel: #181B20;
    --bg-panel-rgb: 24, 27, 32;
    --bg-card: #1E2328;
    --bg-card-rgb: 30, 35, 40;
    --bg-input: #2C373D;
    --bg-input-rgb: 44, 55, 61;
    /* --bg-hover follows --bg-input so each theme's hover surface inherits
       the per-theme input bg (sage on Hadal, lavender-grey on Smoke, etc).
       Otherwise voice-btn:hover and dossier btn-draft:hover always show
       Cinema's blue-teal regardless of the active lens. */
    --bg-hover: var(--bg-input);

    /* Border-rgb is the dark cool-grey triplet used across the app for hairline
       borders + faint dividers. Per-theme overrides shift it toward the lens
       hue so Monolith doesn't keep cool-blue stitching everywhere, etc. */
    --border-rgb: 74, 84, 94;
    --border: rgba(var(--border-rgb), 0.2);
    --border-hover: rgba(var(--accent-rgb),0.25);

    --text-primary: #D0D4D8;
    --text-primary-rgb: 208, 212, 216;
    --text-secondary: #808D96;
    --text-muted: #525D69;

    --accent: #DDC2A8;
    --accent-rgb: 221, 194, 168;
    --accent-bright: #FADEC2;
    --accent-bright-rgb: 250, 222, 194;
    /* Deeper, richer variant of accent — used for titles, key headings,
       psych report names, anywhere we want the theme to read with more
       presence than the soft default accent. Per-theme below. */
    --accent-deep: #B89A78;
    --accent-deep-rgb: 184, 154, 120;
    --accent-dim: rgba(var(--accent-rgb), 0.15);
    --accent-border: rgba(var(--accent-rgb), 0.3);

    --narrator: #6B7D8A;
    --narrator-rgb: 107, 125, 138;
    --narrator-dim: rgba(var(--narrator-rgb), 0.1);
    --narrator-border: rgba(var(--narrator-rgb), 0.25);

    --memory: #A8B8C4;
    --memory-rgb: 168, 184, 196;
    --memory-dim: rgba(var(--memory-rgb), 0.08);
    --memory-border: rgba(var(--memory-rgb), 0.2);

    /* Mobile DM chat bubbles — were hardcoded blue/grey rgba's that leaked
       cool tone into Smoke / Velvet / Monolith. Themed below per lens so
       both incoming (agent, npc) and outgoing (user) bubbles follow. */
    --user-bubble-bg: rgba(42, 60, 80, 0.85);
    --user-bubble-color: #d0dde8;
    --agent-bubble-bg: rgba(40, 44, 52, 0.85);

    --warning: #C4A882;
    --warning-dim: rgba(196,168,130,0.1);

    --font-serif: 'Newsreader', serif;
    --font-sans: 'IBM Plex Sans JP', sans-serif;
    --font-mono: 'DotGothic16', monospace;
}

/* Theme overrides applied via document.documentElement[data-theme="..."].
   These mirror the codex.html canvas lens families: deep grey surfaces first,
   then a restrained lens glow/accent on top. */
:root[data-theme="hadal"] {
    --accent: #7FB0AE;
    --accent-rgb: 127, 176, 174;
    --accent-bright: #A8C0A0;
    --accent-bright-rgb: 168, 192, 160;
    --bg-deepest: #0D1217;
    --bg-deepest-rgb: 13, 18, 23;
    --bg-panel: #161B20;
    --bg-panel-rgb: 22, 27, 32;
    --bg-card: #1D2429;
    --bg-card-rgb: 29, 36, 41;
    --text-primary: #D0D5D8;
    --text-primary-rgb: 208, 213, 216;
    --text-secondary: #7F8B93;
    --text-muted: #505D65;
    --accent-deep: #5F8F8D;
    --accent-deep-rgb: 95, 143, 141;
    --memory: #A8C0A0;
    --memory-rgb: 168, 192, 160;
    --narrator: #7D9E96;
    --narrator-rgb: 125, 158, 150;
    --bg-input: #263139;
    --bg-input-rgb: 38, 49, 57;
    --user-bubble-bg: rgba(35, 49, 58, 0.85);
    --user-bubble-color: #d6dee4;
    --agent-bubble-bg: rgba(28, 35, 40, 0.85);
    --border-rgb: 72, 83, 90;
}
:root[data-theme="smoke"] {
    --accent: #C9B8DC;
    --accent-rgb: 201, 184, 220;
    --accent-bright: #E3B8CC;
    --accent-bright-rgb: 227, 184, 204;
    --bg-deepest: #151413;
    --bg-deepest-rgb: 21, 20, 19;
    --bg-panel: #23211F;
    --bg-panel-rgb: 35, 33, 31;
    --bg-card: #302D2A;
    --bg-card-rgb: 48, 45, 42;
    --text-primary: #D1CECA;
    --text-primary-rgb: 209, 206, 202;
    --text-secondary: #8F8983;
    --text-muted: #5F5A54;
    --accent-deep: #9B85B2;
    --accent-deep-rgb: 155, 133, 178;
    --memory: #D8B7CC;
    --memory-rgb: 216, 183, 204;
    --narrator: #A995B8;
    --narrator-rgb: 169, 149, 184;
    --bg-input: #393631;
    --bg-input-rgb: 57, 54, 49;
    --user-bubble-bg: rgba(48, 43, 38, 0.85);
    --user-bubble-color: #ded8d0;
    --agent-bubble-bg: rgba(40, 38, 35, 0.85);
    --border-rgb: 82, 78, 73;
}
:root[data-theme="velvet"] {
    --accent: #A5B0DE;
    --accent-rgb: 165, 176, 222;
    --accent-bright: #EAC2B3;
    --accent-bright-rgb: 234, 194, 179;
    --bg-deepest: #141218;
    --bg-deepest-rgb: 20, 18, 24;
    --bg-panel: #201D26;
    --bg-panel-rgb: 32, 29, 38;
    --bg-card: #2C2632;
    --bg-card-rgb: 44, 38, 50;
    --text-primary: #D2D0D6;
    --text-primary-rgb: 210, 208, 214;
    --text-secondary: #918C9B;
    --text-muted: #5F5968;
    --accent-deep: #7F8CC4;
    --accent-deep-rgb: 127, 140, 196;
    --memory: #B0BAE4;
    --memory-rgb: 176, 186, 228;
    --narrator: #8F98C3;
    --narrator-rgb: 143, 152, 195;
    --bg-input: #34303B;
    --bg-input-rgb: 52, 48, 59;
    --user-bubble-bg: rgba(48, 42, 56, 0.85);
    --user-bubble-color: #ded9e4;
    --agent-bubble-bg: rgba(39, 36, 45, 0.85);
    --border-rgb: 83, 78, 91;
}
:root[data-theme="monolith"] {
    --accent: #E7B9C3;
    --accent-rgb: 231, 185, 195;
    --accent-bright: #E6E4DE;
    --accent-bright-rgb: 230, 228, 222;
    --bg-deepest: #131615;
    --bg-deepest-rgb: 19, 22, 21;
    --bg-panel: #1F2221;
    --bg-panel-rgb: 31, 34, 33;
    --bg-card: #2B2E2D;
    --bg-card-rgb: 43, 46, 45;
    --text-primary: #D1D2CF;
    --text-primary-rgb: 209, 210, 207;
    --text-secondary: #8C918E;
    --text-muted: #5A605D;
    --accent-deep: #B98F9A;
    --accent-deep-rgb: 185, 143, 154;
    --memory: #D8D5CF;
    --memory-rgb: 216, 213, 207;
    --narrator: #B6B8B3;
    --narrator-rgb: 182, 184, 179;
    --bg-input: #333735;
    --bg-input-rgb: 51, 55, 53;
    --user-bubble-bg: rgba(45, 49, 47, 0.85);
    --user-bubble-color: #dddfdc;
    --agent-bubble-bg: rgba(37, 40, 39, 0.85);
    --border-rgb: 78, 84, 81;
}

/* ============================================= RESET */

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

body {
    background: var(--bg-deepest);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 18px;
    font-weight: 300;
    line-height: 1.6;
}

::selection {
    background: rgba(var(--accent-rgb),0.3);
    color: var(--accent-bright);
}

/* ============================================= NAV */

.nav {
    position: fixed;
    top: 0;
    width: 100%;
    height: 48px;
    background: var(--bg-deepest);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 24px;
    border-bottom: 1px solid var(--border);
    z-index: 50;
}

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

.nav-logo {
    font-family: var(--font-serif);
    font-style: italic;
    font-weight: 300;
    font-size: 34px;
    text-transform: lowercase;
    letter-spacing: 1px;
    text-decoration: none;
    color: var(--accent);
    background: linear-gradient(110deg,
        var(--accent-bright) 0%,
        var(--memory) 20%,
        var(--accent) 42%,
        var(--memory) 62%,
        var(--accent-bright) 80%,
        var(--accent-deep) 100%);
    background-size: 260% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: logoShimmer 5.8s ease-in-out infinite, logoMemoryGlow 4.2s ease-in-out infinite;
}
.nav-logo:hover {
    filter: drop-shadow(0 0 22px rgba(var(--accent-rgb),0.35));
}

@keyframes logoShimmer {
    0%, 100% { background-position: 0% 50%; }
    50%      { background-position: 100% 50%; }
}

@keyframes logoMemoryGlow {
    0%, 100% { filter: drop-shadow(0 0 0 rgba(var(--memory-rgb),0)); }
    50%      { filter: drop-shadow(0 0 12px rgba(var(--memory-rgb),0.22)); }
}

/* ============================================= PHOTOBOOTH IFRAME OVERLAY */

.pb-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 500;
    background: rgba(0,0,0,0.85);
    justify-content: center;
    align-items: center;
    overflow: hidden;
}
.pb-overlay.open { display: flex; }
.pb-star {
    position: absolute;
    width: 2px; height: 2px;
    background: var(--accent);
    border-radius: 50%;
    animation: pb-star-twinkle 3s ease-in-out infinite;
    pointer-events: none;
}
@keyframes pb-star-twinkle {
    0%, 100% { opacity: 0.05; transform: scale(0.8); }
    50% { opacity: 0.5; transform: scale(1.2); }
}
@media (max-width: 900px) {
    .pb-star { display: none; }
}
.pb-overlay iframe {
    width: 620px;
    height: 88%;
    border: 1px solid rgba(var(--accent-bright-rgb), 0.12);
    border-radius: 0;
    background: var(--bg-deepest);
    position: relative; z-index: 0;
}
.nav-icon.pb-active { color: var(--accent); animation: pulse-slow 2s ease-in-out infinite; }

/* ============================================= DOSSIER IFRAME OVERLAY */

.dossier-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 500;
    background: rgba(0,0,0,0.85);
    justify-content: center;
    align-items: center;
}
.dossier-overlay.open { display: flex; }
.dossier-overlay iframe {
    width: 90%;
    height: 92%;
    border: 1px solid rgba(var(--accent-bright-rgb), 0.12);
    border-radius: 0;
    background: var(--bg-deepest);
}
.dossier-overlay .dossier-overlay-close {
    position: absolute;
    top: 16px;
    right: 24px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 28px;
    cursor: pointer;
    z-index: 501;
}
.dossier-overlay .dossier-overlay-close:hover { color: var(--accent); }

.nav-link {
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 3px;
    color: #FFFFFF;
    text-decoration: none;
    transition: color 0.2s;
}

.nav-link:hover { color: var(--accent); }
.nav-link.active { color: var(--accent); }

.nav-right {
    display: flex;
    align-items: center;
    gap: 16px;
}


.nav-icon {
    font-size: 18px;
    color: #FFFFFF;
    cursor: pointer;
    transition: color 0.2s;
    background: none;
    border: none;
    font-family: var(--font-sans);
}

.nav-icon:hover { color: var(--accent); }
.time-toggle.active { color: var(--accent); }

/* Settings popup */
.settings-popup {
    position: fixed;
    z-index: 9000;
    min-width: 200px;
    padding: 14px 18px;
    background: var(--bg-deepest);
    border: 1px solid rgba(var(--accent-bright-rgb), 0.12);
    border-radius: 0;
    box-shadow: 0 6px 24px rgba(0,0,0,0.5);
    font-family: var(--font-sans);
}
.settings-popup::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 40px;
    background: linear-gradient(180deg, rgba(var(--accent-bright-rgb),0.07) 0%, transparent 100%);
    border-radius: 0;
    pointer-events: none;
}
.settings-popup-title {
    font-size: 8px;
    text-transform: uppercase;
    letter-spacing: 4px;
    color: rgba(var(--accent-bright-rgb), 0.3);
    margin-bottom: 12px;
    position: relative;
    text-align: center;
}
.settings-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 0;
    transition: opacity 0.2s;
}
.settings-toggle-row.disabled {
    opacity: 0.3;
    pointer-events: none;
}
.settings-label {
    font-size: 11px;
    color: rgba(var(--accent-rgb), 0.8);
    letter-spacing: 0.5px;
    font-family: 'Newsreader', Georgia, serif;
    font-style: italic;
    font-weight: 300;
    text-transform: uppercase;
}
.settings-switch {
    position: relative;
    width: 34px;
    height: 18px;
    flex-shrink: 0;
}
.settings-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}
.settings-slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(var(--border-rgb),0.4);
    border-radius: 18px;
    transition: background 0.2s;
}
.settings-slider::before {
    content: '';
    position: absolute;
    width: 12px;
    height: 12px;
    left: 3px;
    bottom: 3px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: transform 0.2s, background 0.2s;
}
.settings-switch input:checked + .settings-slider {
    background: var(--accent);
}
.settings-switch input:checked + .settings-slider::before {
    transform: translateX(16px);
    background: var(--bg-card, #1a1d23);
}
.settings-helper {
    font-family: var(--font-sans);
    font-size: 9px;
    color: rgba(var(--accent-rgb), 0.35);
    line-height: 1.5;
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid rgba(var(--border-rgb),0.12);
    max-width: 220px;
}

/* Settings — three-section panel (exec acts, travel, time awareness) */
.settings-section {
    padding: 10px 0;
    border-top: 1px solid rgba(var(--accent-rgb),0.08);
    min-width: 240px;
}
.settings-section:first-of-type { border-top: none; padding-top: 4px; }
.settings-section-head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 2px;
}
.settings-section-title {
    font-family: 'Newsreader', Georgia, serif;
    font-style: italic;
    font-size: 13px;
    color: var(--accent);
    letter-spacing: 0.5px;
}
.settings-section-hint {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px; height: 14px;
    font-family: var(--font-sans);
    font-size: 9px;
    color: rgba(var(--accent-rgb), 0.5);
    border: 1px solid rgba(var(--accent-rgb), 0.25);
    border-radius: 50%;
    cursor: help;
}
.settings-section-hint:hover { color: var(--accent); border-color: var(--accent); }
.settings-section-desc {
    font-family: 'Newsreader', Georgia, serif;
    font-style: italic;
    font-size: 10.5px;
    color: rgba(var(--accent-rgb), 0.45);
    line-height: 1.4;
    margin-bottom: 8px;
}
.settings-pill-group {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.settings-pill {
    flex: 1;
    min-width: 50px;
    font-family: var(--font-sans);
    font-size: 10px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    background: rgba(var(--bg-deepest-rgb),0.55);
    border: 1px solid rgba(var(--accent-rgb),0.18);
    color: rgba(var(--accent-rgb),0.7);
    padding: 7px 10px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.settings-pill:hover {
    color: var(--accent);
    border-color: rgba(var(--accent-rgb),0.4);
}
.settings-pill.selected {
    background: rgba(var(--accent-rgb),0.14);
    border-color: rgba(var(--accent-rgb),0.55);
    color: var(--accent);
    box-shadow: inset 0 0 10px rgba(var(--accent-rgb),0.08);
}

/* ============================================= THEME PICKER */

.theme-popup {
    position: fixed;
    z-index: 9000;
    min-width: 240px;
    padding: 16px 18px 14px;
    background: var(--bg-deepest);
    border: 1px solid rgba(var(--accent-bright-rgb), 0.12);
    border-radius: 0;
    box-shadow: 0 6px 24px rgba(0,0,0,0.5);
    font-family: var(--font-sans);
}
.theme-popup::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 40px;
    background: linear-gradient(180deg, rgba(var(--accent-bright-rgb),0.07) 0%, transparent 100%);
    pointer-events: none;
}
.theme-popup-title {
    font-size: 8px;
    text-transform: uppercase;
    letter-spacing: 4px;
    color: rgba(var(--accent-bright-rgb), 0.3);
    margin-bottom: 14px;
    position: relative;
    text-align: center;
}
.theme-lens-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
}
.theme-lens-btn {
    background: var(--bg-deepest);
    border: 1px solid rgba(var(--border-rgb),0.18);
    padding: 10px 12px;
    text-align: left;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: background 0.25s, border-color 0.25s;
    position: relative;
    overflow: hidden;
}
.theme-lens-btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 30% 20%, var(--lens-glow, rgba(var(--accent-rgb),0.08)) 0%, transparent 70%);
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}
.theme-lens-btn:hover { border-color: rgba(var(--accent-rgb),0.25); }
.theme-lens-btn:hover::after { opacity: 1; }
.theme-lens-btn.active { border-color: var(--accent); background: rgba(var(--accent-rgb),0.04); }
.theme-lens-btn.active::after { opacity: 1; }

.theme-lens-swatch {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 0 1px rgba(255,255,255,0.06);
    position: relative;
    z-index: 1;
}
.theme-lens-name {
    font-family: var(--font-serif);
    font-style: italic;
    font-weight: 300;
    font-size: 14px;
    color: var(--text-primary);
    letter-spacing: 0.2px;
    flex: 1;
    position: relative;
    z-index: 1;
}
.theme-lens-meta {
    font-family: var(--font-mono);
    font-size: 8px;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--text-muted);
    position: relative;
    z-index: 1;
}

/* Per-lens accent — used both for the swatch fill (inline style) and the
   hover/active glow gradient. */
.theme-lens-btn[data-theme="cinema"]   { --lens-glow: rgba(221,194,168,0.16); }
.theme-lens-btn[data-theme="hadal"]    { --lens-glow: rgba(127,176,174,0.16); }
.theme-lens-btn[data-theme="smoke"]    { --lens-glow: rgba(201,184,220,0.18); }
.theme-lens-btn[data-theme="velvet"]   { --lens-glow: rgba(165,176,222,0.18); }
.theme-lens-btn[data-theme="monolith"] { --lens-glow: rgba(231,185,195,0.16); }

.theme-save-btn {
    width: 100%;
    background: var(--accent);
    color: #1E1103;
    border: none;
    padding: 11px 14px;
    font-family: var(--font-sans);
    font-size: 9px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 3px;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.2s;
}
.theme-save-btn:hover { opacity: 0.88; }
.theme-save-btn:active { transform: translateY(1px); }
.theme-save-btn:disabled { opacity: 0.4; cursor: default; }

/* Mobile: center the popup like settings does. */
@media (max-width: 900px) {
    .theme-popup {
        position: fixed !important;
        left: 50% !important;
        top: 50% !important;
        right: auto !important;
        transform: translate(-50%, -50%);
        width: calc(100vw - 32px);
        max-width: 320px;
        z-index: 12000;
    }
}

/* Mobile + tablet: center the popup on screen instead of anchoring to the
   clock icon. The clock is hidden in nav at <=900px (see .nav-right rule),
   so anchoring would land the popup off-screen. */
@media (max-width: 900px) {
    .settings-popup {
        position: fixed !important;
        left: 50% !important;
        top: 50% !important;
        right: auto !important;
        transform: translate(-50%, -50%);
        width: calc(100vw - 32px);
        max-width: 360px;
        max-height: 85vh;
        overflow-y: auto;
        z-index: 12000;
    }
    .settings-section { min-width: 0; }
}

.nav-world {
    position: relative;
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 3px;
    cursor: default;
    color: var(--accent-bright);
}

.nav-world-desc {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
    font-size: 8px;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--text-secondary);
    background: var(--bg-deepest);
    border: 1px solid var(--border);
    padding: 6px 14px;
    z-index: 50;
    pointer-events: none;
}

.nav-world:hover .nav-world-desc { display: block; }

.nav-user { text-align: right; }

.nav-user-name {
    font-size: 9px;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--accent);
}

.nav-user-season {
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
}

/* ============================================= NAV DROPDOWNS */

.nav-dropdown {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.nav-dropdown-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    color: #FFFFFF;
    font-family: var(--font-sans);
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 3px;
    display: inline-flex;
    align-items: center;
    transition: color 0.2s, text-shadow 0.25s;
}

.nav-dropdown:hover .nav-dropdown-toggle,
.nav-dropdown:focus-within .nav-dropdown-toggle,
.nav-dropdown-toggle:hover,
.nav-dropdown-toggle.nav-dropdown-active {
    color: var(--accent);
}

.nav-dropdown-toggle.nav-dropdown-active {
    text-shadow: 0 0 14px rgba(var(--accent-rgb),0.2);
}

.nav-dropdown-chevron {
    display: inline-block;
    font-size: 7px;
    margin-left: 7px;
    color: var(--text-muted);
    opacity: 0.55;
    transition: color 0.25s, opacity 0.25s, transform 0.4s ease;
    line-height: 1;
}

.nav-dropdown:hover .nav-dropdown-chevron,
.nav-dropdown:focus-within .nav-dropdown-chevron {
    color: var(--accent);
    opacity: 1;
    transform: rotate(45deg);
}

.nav-dropdown-toggle.nav-dropdown-active .nav-dropdown-chevron {
    color: var(--accent);
    opacity: 1;
}

.nav-dropdown-menu {
    position: absolute;
    top: 100%;
    left: -22px;
    min-width: 200px;
    margin-top: 9px;
    padding: 18px 24px 20px 24px;
    background: var(--bg-deepest);
    border: 1px solid var(--border-hover);
    box-shadow:
        0 18px 42px rgba(0,0,0,0.7),
        0 0 28px rgba(var(--accent-rgb),0.05),
        inset 0 0 0 1px rgba(var(--accent-rgb),0.04);
    display: flex;
    flex-direction: column;
    gap: 14px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    transition: opacity 0.18s ease, visibility 0.18s ease, transform 0.22s ease;
    z-index: 60;
}

/* filament thread connecting toggle to menu */
.nav-dropdown-menu::before {
    content: '';
    position: absolute;
    top: -9px;
    left: 30px;
    width: 1px;
    height: 9px;
    background: linear-gradient(to bottom, transparent, var(--accent));
    opacity: 0.55;
}

/* hairline at top of menu */
.nav-dropdown-menu::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(to right, transparent 10%, rgba(var(--accent-rgb),0.32) 50%, transparent 90%);
}

.nav-dropdown:hover .nav-dropdown-menu,
.nav-dropdown:focus-within .nav-dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.nav-dropdown-item {
    position: relative;
    display: flex;
    align-items: center;
    font-family: var(--font-sans);
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 3px;
    color: var(--text-secondary);
    text-decoration: none;
    white-space: nowrap;
    padding: 2px 0 2px 2px;
    transition: color 0.2s, padding-left 0.25s ease, text-shadow 0.25s;
}

.nav-dropdown-bullet {
    display: inline-block;
    margin-right: 12px;
    font-size: 7px;
    color: var(--text-muted);
    line-height: 1;
    transition: color 0.2s, transform 0.4s ease, text-shadow 0.25s;
}

.nav-dropdown-item:hover {
    color: var(--accent-bright);
    padding-left: 6px;
    text-shadow: 0 0 14px rgba(var(--accent-rgb),0.25);
}

.nav-dropdown-item:hover .nav-dropdown-bullet {
    color: var(--accent);
    transform: rotate(45deg);
    text-shadow: 0 0 10px rgba(var(--accent-rgb),0.55);
}

/* ============================================= NAV SOCIAL ICON */

.nav-social-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #FFFFFF;
    padding: 4px 6px;
    background: none;
    border: none;
    cursor: pointer;
    transition: color 0.25s, filter 0.25s, transform 0.25s;
}
.nav-social-icon svg { display: block; }
.nav-social-icon:hover {
    color: var(--accent);
    filter: drop-shadow(0 0 8px rgba(var(--accent-rgb),0.5));
    transform: scale(1.04);
}

/* Accent color cycle — social feed icon blink for new posts */
@keyframes accent-cycle {
    0%, 100% { color: var(--accent); filter: drop-shadow(0 0 6px rgba(var(--accent-rgb),0.5)); }
    16%  { color: #C9B8DC; filter: drop-shadow(0 0 6px rgba(201,184,220,0.5)); }
    33%  { color: #A5B0DE; filter: drop-shadow(0 0 6px rgba(165,176,222,0.5)); }
    50%  { color: #A8C0A0; filter: drop-shadow(0 0 6px rgba(168,192,160,0.5)); }
    66%  { color: #7FB0AE; filter: drop-shadow(0 0 6px rgba(127,176,174,0.5)); }
    83%  { color: #E5B8B0; filter: drop-shadow(0 0 6px rgba(229,184,176,0.5)); }
}
.nav-social-icon.has-new {
    animation: accent-cycle 4s ease-in-out infinite;
}

/* ============================================= SHARED ANIMATIONS */

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

@keyframes pulse-slow {
    0%, 100% { opacity: 1; }
    25% { opacity: 0.25; }
}

@keyframes nav-loading-pulse {
    0%, 100% { opacity: 0.4; }
    50%      { opacity: 1; }
}

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

.voice-spinner {
    animation: spin 1s linear infinite;
    display: inline-block;
}

/* ============================================= SHARED SCROLLBARS */

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-thumb { background: rgba(var(--text-primary-rgb), 0.25); border-radius: 0; }
::-webkit-scrollbar-thumb:hover { background: rgba(var(--text-primary-rgb), 0.4); }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-button { display: none; }
html { scrollbar-width: thin; scrollbar-color: rgba(var(--text-primary-rgb), 0.25) transparent; }

/* ============================================= OVERLAYS */

.overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(var(--bg-deepest-rgb),0.85);
    z-index: 100;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.overlay.open { display: flex; }

.overlay-window {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    max-width: 95%;
    max-height: 90%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.overlay-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
}

.overlay-icon { font-size: 20px; }

.overlay-title {
    flex: 1;
    font-family: var(--font-serif);
    font-style: italic;
    font-size: 17px;
    color: var(--accent);
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 28px;
    cursor: pointer;
    padding: 4px 8px;
}

.close-btn:hover { color: var(--text-primary); }

/* ============================================= CINEMATIC MODAL (alert/confirm) */

.am-modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(var(--bg-deepest-rgb), 0.78);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 10000;
    justify-content: center;
    align-items: center;
    padding: 20px;
    animation: am-modal-fade 0.18s ease-out;
}

.am-modal-backdrop.open { display: flex; }

@keyframes am-modal-fade {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes am-modal-rise {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.am-modal-window {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    width: 520px;
    max-width: 100%;
    box-shadow: 0 24px 60px rgba(0,0,0,0.45), 0 0 0 1px rgba(var(--accent-rgb),0.04) inset;
    animation: am-modal-rise 0.22s ease-out;
    position: relative;
}

.am-modal-window::before {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: radial-gradient(circle at 50% 0%, rgba(var(--accent-rgb),0.05) 0%, transparent 60%);
}

.am-modal-header {
    padding: 14px 18px;
    border-bottom: 1px solid rgba(var(--border-rgb),0.18);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    position: relative;
}

.am-modal-tag {
    font-family: var(--font-mono);
    font-size: 12px;
    letter-spacing: 3px;
    text-transform: uppercase;
    padding: 4px 10px;
    background: rgba(var(--accent-rgb),0.05);
    color: rgba(var(--accent-rgb),0.65);
    border: 1px solid rgba(var(--accent-rgb),0.12);
}

.am-modal-tag--warn {
    color: #C4A882;
    background: rgba(196,168,130,0.06);
    border-color: rgba(196,168,130,0.18);
}

.am-modal-tag--error {
    color: #C47F6B;
    background: rgba(196,127,107,0.06);
    border-color: rgba(196,127,107,0.2);
}

.am-modal-tag--success {
    color: #A8C49A;
    background: rgba(168,196,154,0.05);
    border-color: rgba(168,196,154,0.18);
}

.am-modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    padding: 2px 8px;
    font-family: var(--font-sans);
    transition: color 0.2s;
}

.am-modal-close:hover { color: var(--accent); }

.am-modal-body {
    padding: 24px 26px 22px;
    position: relative;
}

.am-modal-title {
    font-family: var(--font-serif);
    font-style: italic;
    font-size: 24px;
    font-weight: 300;
    color: var(--accent);
    line-height: 1.25;
    margin-bottom: 12px;
    letter-spacing: -0.3px;
}

.am-modal-message {
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.65;
    color: var(--text-primary);
    white-space: pre-wrap;
    margin-bottom: 24px;
}

.am-modal-message:last-child { margin-bottom: 0; }

.am-modal-message .bullet {
    display: block;
    padding-left: 14px;
    position: relative;
    margin-top: 8px;
    color: var(--text-secondary);
}

.am-modal-message .bullet::before {
    content: '◆';
    position: absolute;
    left: 0;
    color: var(--accent);
    opacity: 0.5;
    font-size: 9px;
    top: 4px;
}

.am-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding-top: 18px;
    border-top: 1px solid rgba(var(--border-rgb),0.12);
}

.am-modal-btn {
    background: none;
    border: 1px solid rgba(var(--border-rgb),0.35);
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 3px;
    padding: 10px 22px;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
    outline: none;
}

.am-modal-btn:hover {
    color: var(--text-primary);
    border-color: rgba(var(--border-rgb),0.55);
}

.am-modal-btn:focus-visible {
    box-shadow: 0 0 0 1px rgba(var(--accent-rgb),0.4);
}

.am-modal-btn--primary {
    border-color: var(--accent-border);
    color: var(--accent);
}

.am-modal-btn--primary:hover {
    background: var(--accent-dim);
    border-color: var(--accent);
    color: var(--accent);
}

.am-modal-btn--danger {
    border-color: rgba(196,127,107,0.35);
    color: #C47F6B;
}

.am-modal-btn--danger:hover {
    background: rgba(196,127,107,0.1);
    border-color: #C47F6B;
    color: #D89A85;
}

@media (max-width: 900px) {
    /* Bound the modal height and let the body scroll independently so the
       header (with close button) stays pinned at the top — otherwise long
       confirm/alert content pushes the [x] off screen. */
    .am-modal-window {
        width: 100%;
        max-height: 85vh;
        display: flex;
        flex-direction: column;
    }
    .am-modal-header {
        position: sticky;
        top: 0;
        z-index: 20;
        background: var(--bg-panel);
    }
    .am-modal-body {
        padding: 20px 20px 18px;
        overflow-y: auto;
    }
    .am-modal-title { font-size: 20px; }
    .am-modal-actions { flex-direction: column-reverse; }
    .am-modal-btn { width: 100%; }

    /* Same treatment for overlay-style popups (photobooth, invite, menu
       editor, hangout memories, etc.). The window is already flex-column
       with overflow:hidden — making the header sticky keeps the [x] visible
       in the rare case where the header itself flows into scrolling. */
    .overlay-header {
        position: sticky;
        top: 0;
        z-index: 20;
        background: var(--bg-panel);
    }
}

/* ============================================= SOFT MODAL (gentle validation variant) */
/* Reuses the Lore-stub card language: centered large card, huge Newsreader
   italic title, quiet supporting copy, classified tag at top center.
   Used for gentle "you're missing something" notices rather than hard errors. */

.am-modal-window--soft {
    width: 560px;
    max-width: 100%;
    background: var(--bg-panel);
    border: 1px solid rgba(var(--border-rgb),0.18);
    position: relative;
    padding: 80px 64px 56px;
    text-align: center;
    box-shadow: 0 32px 80px rgba(0,0,0,0.5), 0 0 0 1px rgba(var(--accent-rgb),0.03) inset;
    animation: am-modal-rise 0.26s ease-out;
}

.am-modal-window--soft::before {
    content: attr(data-tag);
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 5px 14px;
    background: rgba(var(--accent-rgb),0.05);
    border: 1px solid rgba(var(--accent-rgb),0.15);
    white-space: nowrap;
}

.am-modal-window--soft::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: radial-gradient(circle at 50% 30%, rgba(var(--accent-rgb),0.05) 0%, transparent 65%);
}

.am-modal-soft-title {
    font-family: var(--font-serif);
    font-style: italic;
    font-size: 42px;
    font-weight: 300;
    color: var(--accent);
    letter-spacing: -1px;
    line-height: 1.12;
    margin-bottom: 22px;
    position: relative;
}

.am-modal-soft-message {
    font-family: var(--font-sans);
    font-size: 13px;
    line-height: 1.75;
    color: var(--text-secondary);
    max-width: 420px;
    margin: 0 auto 36px;
    position: relative;
}

.am-modal-soft-actions {
    display: flex;
    justify-content: center;
    position: relative;
}

.am-modal-soft-close {
    position: absolute;
    top: 14px;
    right: 16px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    padding: 4px 8px;
    z-index: 2;
    transition: color 0.2s;
}

.am-modal-soft-close:hover { color: var(--accent); }

@media (max-width: 900px) {
    .am-modal-window--soft { padding: 68px 32px 44px; }
    .am-modal-soft-title { font-size: 32px; }
}

/* ============================================= SHARED COMPONENTS */

.model-select {
    background-color: rgba(var(--accent-rgb),0.04);
    background-image: url("data:image/svg+xml,%3Csvg width='10' height='10' viewBox='0 0 10 10' xmlns='http://www.w3.org/2000/svg' fill='none' stroke='%23DDC2A8' stroke-width='1.2'%3E%3Cpath d='M5 1l4 4-4 4-4-4z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    border: 1px solid rgba(var(--accent-rgb),0.2);
    color: var(--accent);
    font-family: var(--font-mono);
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 2px;
    padding: 7px 30px 7px 14px;
    outline: none;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    transition: border-color 0.25s, background-color 0.25s, box-shadow 0.3s, letter-spacing 0.3s;
}

.model-select:hover {
    border-color: rgba(var(--accent-rgb),0.4);
    background-color: rgba(var(--accent-rgb),0.08);
}

.model-select:focus {
    border-color: var(--accent);
    background-color: rgba(var(--accent-rgb),0.1);
    box-shadow: 0 0 0 1px rgba(var(--accent-rgb),0.2), 0 0 22px rgba(var(--accent-rgb),0.12);
    letter-spacing: 2.5px;
}

.model-select option {
    background: var(--bg-deepest);
    color: var(--text-primary);
    font-family: var(--font-mono);
    letter-spacing: 1px;
    padding: 8px 12px;
}

.model-select option:disabled {
    color: var(--text-muted);
}

/* ============================================= PAGE HEADERS */

.page-header {
    margin-bottom: 60px;
    padding-bottom: 40px;
    border-bottom: 1px solid rgba(var(--border-rgb),0.3);
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 32px;
    flex-wrap: wrap;
}

.header-left { max-width: 700px; }

.page-title {
    font-family: var(--font-serif);
    font-size: 80px;
    font-weight: 200;
    letter-spacing: -2px;
    line-height: 1;
    color: var(--text-primary);
    margin-bottom: 16px;
}

.page-title em {
    color: var(--accent);
    font-style: italic;
}

.page-subtitle {
    font-family: var(--font-sans);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 3px;
    color: var(--text-muted);
    max-width: 500px;
}

.header-right {
    text-align: right;
    flex-shrink: 0;
}

.header-meta {
    font-family: var(--font-mono);
    letter-spacing: 2px;
    font-size: 16px;
    color: var(--text-muted);
    line-height: 2;
}

.header-meta .val { color: var(--accent); }

/* ============================================= FOOTER */

/* Shared site footer — injected on every page that loads nav-shared.js
   (see nav-shared.js _injectAmFooter). Serif + light italic, with the
   "Claude" word linking to the dedication page. */
.am-footer {
    background: var(--bg-deepest);
    margin-top: 80px;
    padding: 36px 32px;
    border-top: 1px solid rgba(var(--border-rgb),0.1);
    text-align: center;
    font-family: var(--font-serif);
    font-weight: 200;
    font-size: 13px;
    line-height: 1.7;
    letter-spacing: 0.3px;
    color: rgba(var(--memory-rgb), 0.45);
}
.am-footer-italic { font-style: italic; }
.am-footer-claude {
    color: var(--accent);
    text-decoration: none;
    border-bottom: 1px solid rgba(var(--accent-rgb),0.2);
    transition: color 0.2s, border-color 0.2s;
}
.am-footer-claude:hover {
    color: var(--accent);
    border-bottom-color: rgba(var(--accent-rgb),0.6);
}
.am-footer-codexter {
    color: var(--accent-bright);
}
@media (max-width: 700px) {
    .am-footer {
        padding: 28px 20px;
        padding-bottom: max(28px, env(safe-area-inset-bottom));
        font-size: 12px;
    }
}

.page-footer {
    background: var(--bg-deepest);
    margin-top: 80px;
    padding: 48px;
    border-top: 1px solid rgba(var(--border-rgb),0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 24px;
}

.footer-left {
    font-family: var(--font-mono);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 3px;
    color: var(--text-secondary);
    opacity: 0.6;
}

.footer-right a {
    font-family: var(--font-mono);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 3px;
    color: var(--text-secondary);
    opacity: 0.6;
    text-decoration: none;
    transition: color 0.2s, opacity 0.2s;
}

.footer-right a:hover { color: var(--accent); opacity: 1; }

/* ============================================= LOADING */

.loading {
    text-align: center;
    padding: 80px 0;
    font-family: var(--font-mono);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 3px;
    color: var(--text-muted);
    animation: pulse-slow 2s ease-in-out infinite;
}

/* ============================================= MEMORIES (shared between index + hangouts) */

.memories-area {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.memory-input {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 14px;
    padding: 8px 12px;
    outline: none;
    resize: none;
    min-height: 40px;
}

.memory-input:focus { border-color: var(--accent-border); }
.memory-resize { height: 8px; cursor: ns-resize; display: flex; justify-content: center; align-items: center; }
.memory-resize::after { content: ''; width: 40px; height: 2px; background: var(--text-muted); opacity: 0.2; border-radius: 1px; }
.memory-resize:hover::after { opacity: 0.5; }

.memory-row {
    display: flex;
    gap: 6px;
    align-items: flex-end;
}

.memory-select {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 10px;
    padding: 6px;
    outline: none;
}

.memory-add-btn {
    background: none;
    border: 1px solid var(--accent-border);
    color: var(--accent);
    font-family: var(--font-sans);
    font-size: 8px;
    text-transform: uppercase;
    letter-spacing: 2px;
    padding: 6px 14px;
    cursor: pointer;
}

.memory-entries {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
}

.memory-vault-notice {
    border: 1px solid rgba(var(--memory-rgb), 0.28);
    background: rgba(var(--memory-rgb), 0.045);
    color: rgba(var(--memory-rgb), 0.9);
    padding: 16px 18px;
    margin: 10px 0;
    text-align: left;
}

.memory-vault-title {
    font-family: var(--font-serif);
    font-style: italic;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 8px;
}

.memory-vault-body {
    font-size: 12px;
    line-height: 1.6;
    color: var(--text-secondary);
}

.agp-mem-grid .memory-vault-notice {
    grid-column: 1 / -1;
}

.map-dots .memory-vault-notice {
    position: absolute;
    left: 50%;
    top: 50%;
    width: min(420px, 82vw);
    transform: translate(-50%, -50%);
    z-index: 5;
}

.memory-entry {
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 10px 12px;
    margin-bottom: 8px;
}

.memory-entry-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
}

.memory-category {
    font-size: 7px;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--accent);
}

.memory-date {
    font-size: 7px;
    color: var(--text-muted);
}

.memory-entry-body {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
    font-weight: 300;
}

.memory-entry-actions {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
    margin-top: 6px;
    opacity: 0;
    transition: opacity 0.2s;
}
.memory-entry:hover .memory-entry-actions { opacity: 1; }

.memory-action-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 12px;
    padding: 2px 4px;
    transition: color 0.2s;
}
.memory-action-btn:hover { color: var(--accent); }
.memory-delete-btn:hover { color: #C47F6B; }

.memory-pinned {
    border-left: 2px solid var(--accent);
    background: rgba(var(--accent-rgb),0.03);
}
.memory-pinned .memory-entry-actions { opacity: 1; }
.memory-pin-btn.pinned { color: var(--accent) !important; opacity: 1; }

.memory-inactive {
    opacity: 0.35;
    border-style: dashed;
}
.memory-inactive .memory-entry-actions { opacity: 1; }

.memory-auto-tag {
    font-size: 6px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    border: 1px solid var(--border);
    padding: 1px 5px;
    margin-left: 6px;
}

/* Phase 4: expand button at the bottom of the home Memories tab.
   Visible only when >5 entries exist; toggles between "View all (N)"
   and "Collapse to recent". */
.memory-viewall {
    display: block;
    width: 100%;
    margin: 14px 0 0;
    padding: 10px 14px;
    background: transparent;
    border: 1px solid rgba(var(--accent-rgb),0.18);
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 3px;
    cursor: pointer;
    transition: border-color 0.25s, color 0.25s, background 0.25s, letter-spacing 0.3s;
}
.memory-viewall:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(var(--accent-rgb),0.05);
    letter-spacing: 3.5px;
}

.memory-footer-row { display: flex; align-items: center; gap: 6px; padding: 0 16px; }
.memory-search-row { padding: 0 16px 8px; }
.memory-search-input {
    width: 100%; background: var(--bg-input); border: 1px solid var(--border);
    color: var(--text-primary); font-family: var(--font-sans); font-size: 12px;
    padding: 6px 10px; outline: none; letter-spacing: 0.5px;
    transition: border-color 0.2s;
}
.memory-search-input:focus { border-color: var(--accent-border); }
.memory-search-input::placeholder { color: var(--text-muted); font-style: italic; }
.memory-search-toggle {
    background: none; border: 1px solid var(--border); color: var(--text-muted);
    font-size: 14px; padding: 4px 8px; cursor: pointer; transition: color 0.2s, border-color 0.2s;
    margin-left: auto; flex-shrink: 0;
}
.memory-search-toggle:hover { color: var(--accent); border-color: var(--accent-border); }

/* ============================================= SOCIAL FEED */

.sf-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 100;
    background: rgba(var(--bg-deepest-rgb), 0.88);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    justify-content: center;
    align-items: center;
    padding: 24px;
}
.sf-overlay.open { display: flex; }

.sf-window {
    width: 92vw;
    max-width: 1000px;
    height: 88vh;
    background: rgba(var(--bg-panel-rgb), 0.92);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(var(--accent-rgb),0.10);
    border-radius: 0;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: visible;
    box-shadow:
        0 24px 60px rgba(0,0,0,0.5),
        0 0 0 1px rgba(var(--accent-rgb),0.03) inset,
        0 0 80px rgba(var(--accent-rgb),0.025);
    animation: am-modal-rise 0.22s ease-out;
}
.sf-window::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(to right, transparent 10%, rgba(var(--accent-rgb),0.35) 50%, transparent 90%);
    pointer-events: none;
    z-index: 4;
}

.sf-close {
    position: absolute;
    top: 50%;
    right: 14px;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 22px;
    cursor: pointer;
    padding: 4px 8px;
    z-index: 4;
}
.sf-close:hover { color: var(--text-primary); }

@keyframes sf-heart-drift {
    0%   { opacity: 0; transform: translateY(0) scale(0.7); }
    25%  { opacity: 0.6; }
    100% { opacity: 0; transform: translateY(-14px) scale(1); }
}
.sf-header {
    background: var(--bg-deepest);
    border-bottom: 1px solid var(--accent-border);
    padding: 10px 22px;
    position: relative;
    overflow: hidden;
    z-index: 3;
    flex-shrink: 0;
    border-radius: 0;
}
.sf-header-hearts {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
}
.sf-header-heart {
    position: absolute;
    color: var(--accent);
    opacity: 0;
    animation: sf-heart-drift 3s ease-in-out infinite;
}
.sf-header-title {
    font-family: var(--font-serif);
    font-style: italic;
    font-weight: 200;
    font-size: 22px;
    color: var(--accent);
    white-space: nowrap;
}

.sf-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* --- LEFT SIDEBAR --- */
.sf-sidebar {
    width: 220px;
    flex-shrink: 0;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 24px 16px;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
    background: rgba(var(--bg-panel-rgb), 0.92);
}

.sf-user-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 24px;
    padding: 20px 12px 16px;
    border-bottom: 1px solid rgba(var(--border-rgb),0.5);
    position: relative;
    overflow: hidden;
    box-shadow: none;
}
.sf-user-card-glow {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 0;
}
.sf-user-card-atmosphere {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    opacity: 0;
    transition: opacity 0.6s ease;
}
.sf-user-card-atmosphere.active { opacity: 1; }
.sf-user-card > :not(.sf-user-card-glow):not(.sf-user-card-atmosphere) { position: relative; z-index: 1; }

.sf-user-card-atmosphere[data-ff="freckles"] {
    background-image: radial-gradient(circle, rgba(255,255,255,0.06) 1px, transparent 1px);
    background-size: 12px 12px;
}
.sf-user-card-atmosphere[data-ff="peas"] {
    background-image: radial-gradient(circle, rgba(255,255,255,0.06) 2px, transparent 2px);
    background-size: 28px 28px;
}
.sf-user-card-atmosphere[data-ff="lovelace"] {
    background-image: linear-gradient(to right, rgba(255,255,255,0.04) 0.5px, transparent 0.5px),
        linear-gradient(to bottom, rgba(255,255,255,0.04) 0.5px, transparent 0.5px);
    background-size: 12px 12px;
}
.sf-user-card-atmosphere[data-ff="paddies"] {
    background-image: linear-gradient(to right, rgba(255,255,255,0.04) 0.5px, transparent 0.5px),
        linear-gradient(to bottom, rgba(255,255,255,0.04) 0.5px, transparent 0.5px);
    background-size: 32px 32px;
}
.sf-user-card-atmosphere[data-ff="trinkets"] {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='75' height='75'%3E%3Cpath d='M37.5 27.5L47.5 37.5L37.5 47.5L27.5 37.5Z' fill='none' stroke='rgba(255,255,255,0.1)' stroke-width='0.8'/%3E%3C/svg%3E");
    background-size: 75px 75px;
}
.sf-user-card-atmosphere[data-ff="channel"] {
    background-image: linear-gradient(to bottom, rgba(255,255,255,0.03) 0.5px, transparent 0.5px);
    background-size: 100% 8px;
}
.sf-user-avatar {
    width: 100px;
    height: 100px;
    border-radius: 5px;
    border: 1px solid rgba(var(--accent-rgb),0.15);
    object-fit: cover;
    margin-bottom: 12px;
    background: var(--bg-card);
}
.sf-user-avatar-placeholder {
    width: 100px;
    height: 100px;
    border-radius: 5px;
    border: 1px solid rgba(var(--accent-rgb),0.15);
    background: var(--bg-card);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
    font-family: var(--font-serif);
    font-style: italic;
    font-size: 32px;
    color: rgba(160,190,220,0.4);
}
.sf-user-name {
    font-family: var(--font-serif);
    font-style: italic;
    font-size: 18px;
    color: var(--accent);
    text-align: center;
}
.sf-user-role {
    font-family: var(--font-sans);
    font-size: 6px;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: #ffffff;
    text-align: center;
    margin-top: 4px;
}
.sf-user-activity {
    font-family: var(--font-sans);
    font-size: 8px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    text-align: center;
    margin-top: 6px;
}

.sf-sidebar-label {
    font-family: var(--font-sans);
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 3px;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.sf-agent-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.sf-agent-item {
    display: flex;
    align-items: center;
    gap: 8px;
    background: none;
    border: 1px solid transparent;
    border-radius: 0;
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-size: 12px;
    padding: 5px 8px;
    cursor: pointer;
    transition: color 0.2s, background 0.2s, border-color 0.2s;
    text-align: left;
    position: relative;
    overflow: hidden;
}
.sf-agent-item:hover {
    color: var(--accent);
    background: none;
}
.sf-agent-item.active {
    color: var(--accent);
    border-color: var(--accent-border);
    background: var(--bg-deepest);
}
.sf-agent-item .sf-agent-hearts {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
}
.sf-agent-item .sf-agent-heart {
    position: absolute;
    color: var(--accent);
    opacity: 0;
    animation: sf-heart-drift 3s ease-in-out infinite;
}
.sf-agent-avatar {
    width: 25px;
    height: 25px;
    border-radius: 3px;
    object-fit: cover;
    flex-shrink: 0;
}

.sf-sidebar-all {
    margin-top: 10px;
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-family: var(--font-sans);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 2px;
    padding: 6px 12px;
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s;
    display: none;
}
.sf-sidebar-all.visible { display: block; }
.sf-sidebar-all:hover { color: var(--accent); border-color: var(--accent-border); }


/* --- RIGHT MAIN COLUMN --- */
.sf-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: rgba(var(--bg-panel-rgb), 0.92);
}
.sf-posts {
    flex: 1;
    overflow-y: auto;
}

.sf-post {
    padding: 24px 50px;
    border-bottom: 1px solid rgba(var(--border-rgb),0.4);
}
.sf-post:last-child { border-bottom: none; }

.sf-post-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}
.sf-post-video-avatar {
    width: 64px;
    height: 64px;
    border-radius: 4px;
    object-fit: cover;
    flex-shrink: 0;
    background: var(--bg-card);
}
.sf-post-avatar {
    width: 64px;
    height: 64px;
    border-radius: 4px;
    object-fit: cover;
    flex-shrink: 0;
    background: var(--bg-card);
}
.sf-post-meta { flex: 1; min-width: 0; }
.sf-post-action {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 21px;
    cursor: pointer;
    padding: 4px 6px;
    opacity: 0;
    transition: opacity 0.2s, color 0.2s;
    flex-shrink: 0;
    align-self: flex-start;
}
.sf-post:hover .sf-post-action { opacity: 1; }
.sf-post-action.sf-post-delete:hover { color: #C47070; }
.sf-post-action.sf-post-add:hover { color: var(--accent); }
.sf-post-action.added { color: var(--accent); opacity: 0.7; pointer-events: none; cursor: default; }
.sf-post-action.added svg { fill: var(--accent); fill-opacity: 0.15; }
.sf-post-author {
    font-family: var(--font-sans);
    font-style: normal;
    font-weight: 300;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 5px;
    color: var(--accent);
}
.sf-post-date {
    font-family: var(--font-mono);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-top: 2px;
}

.sf-post-text {
    font-family: var(--font-sans);
    font-style: normal;
    font-weight: 400;
    font-size: 20px;
    line-height: 1.85;
    color: var(--memory);
    white-space: pre-wrap;
}

/* Image post — thumbnail row */
.sf-post-photo-row {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
    margin-top: 10px;
}
.sf-post-thumb {
    width: 120px;
    height: 120px;
    object-fit: cover;
    border: 1px solid rgba(var(--accent-bright-rgb), 0.12);
    cursor: pointer;
    transition: border-color 0.2s, opacity 0.2s;
}
.sf-post-thumb:hover {
    border-color: var(--accent);
    opacity: 0.85;
}

/* Universal Aesthetic preset picker — lives inside the theme popup
   (paint-bucket icon → theme picker), below the theme lens list. */
.aesthetic-picker {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
}
.aesthetic-btn {
    width: 100%;
    background: var(--bg-deepest);
    border: 1px solid rgba(var(--border-rgb), 0.4);
    color: var(--text-secondary);
    font-family: var(--font-serif);
    font-style: italic;
    font-weight: 300;
    font-size: 14px;
    letter-spacing: 0.3px;
    padding: 10px 12px;
    cursor: pointer;
    text-align: left;
    transition: border-color 0.2s, color 0.2s, background 0.2s;
}
.aesthetic-btn:hover {
    border-color: rgba(var(--accent-rgb), 0.5);
    color: var(--accent-deep);
}
.aesthetic-btn.active {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(var(--accent-rgb), 0.04);
}

/* Banner post — agent reposted a gallery photo with poetic overlay text.
   500x250 wide banner, photo as cover bg, dim scrim, large thin white
   italic serif text centered on top. Click opens lightbox to original. */
.sf-post-banner {
    width: 500px;
    max-width: 100%;
    height: 250px;
    margin-top: 10px;
    background-position: center;
    background-size: cover;
    background-repeat: no-repeat;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(var(--accent-bright-rgb), 0.12);
    transition: border-color 0.2s, opacity 0.2s;
}
.sf-post-banner::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    pointer-events: none;
}
.sf-post-banner:hover {
    border-color: var(--accent);
    opacity: 0.92;
}
.sf-post-banner-text {
    position: relative;
    z-index: 1;
    font-family: var(--font-serif);
    font-style: italic;
    font-weight: 200;
    font-size: 50px;
    line-height: 1.05;
    color: #fff;
    text-align: center;
    padding: 0 24px;
    text-shadow: 0 2px 18px rgba(0, 0, 0, 0.55);
    word-wrap: break-word;
    pointer-events: none;
}
@media (max-width: 600px) {
    .sf-post-banner {
        height: auto;
        aspect-ratio: 2 / 1;
    }
    .sf-post-banner-text {
        font-size: 32px;
        padding: 0 16px;
    }
}

/* Suno placeholder */
.sf-post-suno {
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 18px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    color: var(--text-muted);
    font-family: var(--font-sans);
    font-size: 12px;
}
.sf-post-suno-icon {
    font-size: 20px;
    color: var(--accent);
    opacity: 0.4;
}
.sf-post-audio {
    display: block;
    width: 100%;
    margin-top: 8px;
    height: 32px;
    filter: invert(0.85) hue-rotate(180deg) saturate(0.4);
}
.sf-post-suno-lyrics {
    margin-top: 10px;
    font-family: var(--font-serif);
    font-style: italic;
    font-size: 13px;
    line-height: 1.55;
    color: rgba(var(--memory-rgb), 0.75);
    white-space: pre-wrap;
}

/* Reactions */
.sf-post-reactions {
    display: flex;
    gap: 10px;
    margin-top: 14px;
    padding-top: 10px;
    border-top: 1px solid rgba(var(--border-rgb),0.15);
}
.sf-reaction {
    display: flex;
    align-items: center;
    gap: 5px;
    opacity: 0.65;
    transition: opacity 0.2s;
}
.sf-reaction:hover { opacity: 1; }
.sf-reaction-avatar {
    width: 20px;
    height: 20px;
    border-radius: 3px;
    object-fit: cover;
}
.sf-reaction-icon { display: flex; align-items: center; }
.sf-reaction-icon svg {
    width: 14px;
    height: 14px;
    color: var(--accent);
    opacity: 0.8;
}
.sf-reaction-add {
    background: none;
    border: 1px solid rgba(var(--border-rgb),0.25);
    color: var(--text-muted);
    width: 22px;
    height: 22px;
    border-radius: 4px;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.4;
    transition: opacity 0.2s, border-color 0.2s;
}
.sf-reaction-add:hover {
    opacity: 1;
    border-color: var(--accent);
    color: var(--accent);
}
.sf-reaction-picker {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 6px;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: center;
    max-width: 280px;
    padding: 10px 14px;
    background: var(--bg-card, #1a1d23);
    border: 1px solid rgba(var(--border-rgb),0.4);
    border-radius: 0;
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
    z-index: 100;
}
.sf-reaction-pick-btn {
    background: none;
    border: none;
    padding: 5px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}
.sf-reaction-pick-btn:hover {
    background: rgba(var(--border-rgb),0.3);
}
.sf-reaction-pick-btn svg {
    width: 18px;
    height: 18px;
    color: var(--text-muted);
    transition: color 0.15s;
}
.sf-reaction-pick-btn:hover svg {
    color: var(--accent);
}

/* Compose area */
.sf-compose-resize {
    height: 8px;
    cursor: ns-resize;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0 20px;
}
.sf-compose-resize::after {
    content: '';
    width: 40px;
    height: 2px;
    background: var(--text-muted);
    opacity: 0.2;
    border-radius: 1px;
}
.sf-compose-resize:hover::after { opacity: 0.5; }
.sf-compose {
    border-top: 1px solid var(--border);
    padding: 16px 50px;
}
.sf-compose-row {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}
.sf-compose-preview {
    margin-bottom: 10px;
}
.sf-compose-preview-inner {
    position: relative;
    display: inline-block;
}
.sf-compose-preview-inner img {
    max-height: 80px;
    border-radius: 3px;
    border: 1px solid var(--border);
    opacity: 0.7;
}
.sf-compose-preview-remove {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}
.sf-compose-preview-remove:hover { color: var(--text-primary); }
.sf-compose-img-btn {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 16px;
    padding: 8px 10px;
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s;
    flex-shrink: 0;
}
.sf-compose-img-btn:hover { color: var(--accent); border-color: var(--accent-border); }
.sf-compose-input {
    flex: 1;
    background: rgba(var(--bg-deepest-rgb), 0.6);
    border: 1px solid var(--border);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 16px;
    font-weight: 300;
    padding: 10px 14px;
    resize: none;
    min-height: 42px;
    max-height: 120px;
    outline: none;
    line-height: 1.5;
    letter-spacing: 0.2px;
    border-radius: 3px;
}
.sf-compose-input:focus { border-color: rgba(var(--accent-rgb),0.25); }
.sf-compose-input::placeholder { color: var(--text-muted); font-style: italic; font-family: 'Newsreader', Georgia, serif; }

.sf-compose-submit {
    background: var(--bg-deepest);
    border: 1px solid var(--accent-border);
    border-radius: 0;
    color: var(--accent);
    font-family: var(--font-sans);
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 3px;
    padding: 10px 20px;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
    position: relative;
    overflow: hidden;
}
.sf-compose-submit:hover { background: var(--accent-dim); }
.sf-compose-submit .sf-btn-hearts {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
}
.sf-compose-submit .sf-btn-heart {
    position: absolute;
    color: var(--accent);
    opacity: 0;
    animation: sf-heart-drift 3s ease-in-out infinite;
    font-size: 6px;
}

/* Load more */
.sf-load-more {
    display: block;
    margin: 8px auto 0;
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-family: var(--font-sans);
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 2px;
    padding: 8px 24px;
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s;
}
.sf-load-more:hover { color: var(--accent); border-color: var(--accent-border); }

/* Empty + Loading states */
.sf-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    text-align: center;
}
.sf-empty-tag {
    font-family: var(--font-mono);
    font-size: 12px;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 5px 14px;
    background: rgba(var(--accent-rgb),0.05);
    border: 1px solid rgba(var(--accent-rgb),0.12);
    margin-bottom: 16px;
}
.sf-empty-text {
    font-family: var(--font-sans);
    font-size: 13px;
    color: var(--text-secondary);
    max-width: 320px;
    line-height: 1.6;
}

.sf-loading {
    text-align: center;
    padding: 40px 0;
    font-family: var(--font-mono);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 3px;
    color: var(--text-muted);
    animation: nav-loading-pulse 1.4s ease-in-out infinite;
}

/* ============================================= CHAT PHOTO REVEAL */

.chat-photo-reveal {
    position: relative;
    display: inline-block;
    cursor: pointer;
    margin: 4px 0;
    overflow: hidden;
}
.chat-photo-img {
    max-width: 200px;
    max-height: 200px;
    display: block;
    border: 1px solid var(--border);
    filter: blur(10px) brightness(0.4);
    transition: filter 0.4s ease;
}
.chat-photo-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(var(--bg-deepest-rgb),0.55);
    color: #FFFFFF;
    transition: opacity 0.4s ease;
}
.chat-photo-overlay i,
.chat-photo-overlay svg {
    width: 28px;
    height: 28px;
    filter: drop-shadow(0 0 6px rgba(var(--text-primary-rgb), 0.4));
}
.chat-photo-reveal.revealed .chat-photo-img {
    filter: none;
}
.chat-photo-reveal.revealed .chat-photo-overlay {
    opacity: 0;
    pointer-events: none;
}
.chat-photo-group {
    display: flex;
    gap: 6px;
    margin: 4px 0;
}
.chat-photo-group .chat-photo-reveal {
    flex: 1 1 0;
    margin: 0;
}
.chat-photo-group .chat-photo-img {
    max-width: 100%;
    width: 100%;
    max-height: 200px;
    object-fit: cover;
}

/* ============================================= SOCIAL FEED MOBILE */

@media (max-width: 900px) {
    .sf-overlay { padding: 0; }
    .sf-window {
        width: 100vw; height: 100vh; max-width: none;
        border: none; box-shadow: none;
    }
    @supports (height: 100dvh) { .sf-window { height: 100dvh; } }

    /* Hide desktop header + sidebar, show mobile header */
    .sf-header { display: none; }
    .sf-sidebar { display: none; }
    .sf-sidebar.sf-sidebar-open {
        display: flex; position: fixed; top: 0; left: 0;
        width: 100vw; height: 100vh; z-index: 200;
        background: rgba(var(--bg-deepest-rgb), 0.96);
        backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
        align-items: center; justify-content: center;
        padding: 40px 20px; border-right: none;
    }
    @supports (height: 100dvh) { .sf-sidebar.sf-sidebar-open { height: 100dvh; } }
    .sf-sidebar.sf-sidebar-open .sf-user-card { max-width: 240px; }
    .sf-sidebar.sf-sidebar-open .sf-agent-list { max-height: 40vh; overflow-y: auto; }
    .sf-sidebar.sf-sidebar-open .sf-sidebar-all { margin-top: 12px; }
    .sf-sidebar.sf-sidebar-open .sf-user-name,
    .sf-sidebar.sf-sidebar-open .sf-agent-item {
        font-family: var(--font-serif);
        font-style: normal;
        font-weight: 300;
        letter-spacing: 0;
    }
    .sf-sidebar.sf-sidebar-open .sf-agent-item {
        font-size: 16px;
        justify-content: center;
    }

    /* Mobile header */
    .sf-mobile-header {
        display: flex; align-items: center; gap: 10px;
        padding: 10px 16px; border-bottom: 1px solid rgba(var(--border-rgb),0.15);
        flex-shrink: 0;
    }
    .sf-mobile-title {
        flex: 1; font-family: var(--font-serif); font-style: normal;
        font-size: 14px; color: var(--text-primary);
    }
    .sf-mobile-filter {
        font-family: var(--font-mono); font-size: 8px; text-transform: uppercase;
        letter-spacing: 2px; color: var(--text-muted); opacity: 0.7;
    }
    .sf-mobile-kebab {
        background: none; border: none; color: var(--text-primary);
        font-size: 20px; cursor: pointer; padding: 4px 6px;
        transition: color 0.2s;
    }
    .sf-mobile-kebab:hover { color: var(--accent); }
    .sf-mobile-close {
        background: none; border: none; color: var(--text-muted);
        font-size: 22px; cursor: pointer; padding: 4px 8px;
        transition: color 0.2s; margin-left: 4px;
    }
    .sf-mobile-close:hover { color: var(--accent); }

    /* Sidebar close button */
    .sf-sidebar-mobile-close {
        position: absolute; top: 16px; right: 20px;
        background: none; border: none; color: var(--text-muted);
        font-size: 22px; cursor: pointer; padding: 4px 8px;
        transition: color 0.2s; display: none;
    }
    .sf-sidebar-mobile-close:hover { color: var(--accent); }
    .sf-sidebar.sf-sidebar-open .sf-sidebar-mobile-close { display: block; }

    /* Posts tighter */
    .sf-post { padding: 16px; }
    .sf-compose { padding: 16px 16px; }
    .sf-compose-input { font-size: 16px; width: 100%; min-width: 0; }
    .sf-compose-row { width: 100%; }
}

@media (min-width: 901px) {
    .sf-mobile-header { display: none !important; }
    .sf-sidebar-mobile-close { display: none !important; }
}

/* ============================================= MINI CHAT */

.nav-minichat-icon {
    display: inline-flex; align-items: center; justify-content: center;
    color: #FFFFFF; padding: 4px 6px; background: none; border: none;
    cursor: pointer; transition: color 0.25s, filter 0.25s, transform 0.25s;
}
.nav-minichat-icon svg { display: block; }
.nav-minichat-icon:hover {
    color: var(--accent);
    filter: drop-shadow(0 0 8px rgba(var(--accent-rgb),0.5));
    transform: scale(1.04);
}
.nav-minichat-icon.has-new {
    animation: mc-notify-flicker 2.2s ease-in-out infinite;
}
@keyframes mc-notify-flicker {
    0%   { color: var(--accent); filter: drop-shadow(0 0 6px rgba(var(--accent-rgb),0.5)); opacity: 1; }
    12%  { opacity: 0.3; filter: none; }
    16%  { opacity: 1; filter: drop-shadow(0 0 10px rgba(var(--accent-rgb),0.8)); }
    40%  { opacity: 1; filter: drop-shadow(0 0 4px rgba(var(--accent-rgb),0.3)); }
    55%  { opacity: 0.25; filter: none; }
    60%  { opacity: 1; filter: drop-shadow(0 0 12px rgba(var(--accent-rgb),0.9)); color: var(--accent); }
    80%  { opacity: 1; filter: drop-shadow(0 0 5px rgba(var(--accent-rgb),0.4)); }
    88%  { opacity: 0.4; filter: none; }
    92%  { opacity: 1; filter: drop-shadow(0 0 8px rgba(var(--accent-rgb),0.7)); }
    100% { opacity: 1; filter: drop-shadow(0 0 6px rgba(var(--accent-rgb),0.5)); color: var(--accent); }
}

/* ---- Chat Toast Notification ---- */
.chat-toast {
    position: fixed;
    top: 60px;
    right: 20px;
    z-index: 9999;
    padding: 14px 20px;
    backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
    background: linear-gradient(135deg, rgba(var(--bg-deepest-rgb),0.7) 0%, rgba(var(--bg-deepest-rgb),0.45) 100%);
    border: 1px solid rgba(var(--accent-rgb),0.15);
    box-shadow: 0 0 30px rgba(var(--bg-deepest-rgb), 0.5), inset 0 0 20px rgba(var(--accent-rgb),0.03);
    cursor: pointer;
    opacity: 0;
    transform: translateX(20px);
    transition: opacity 0.35s ease, transform 0.35s ease;
    pointer-events: none;
}
.chat-toast.visible {
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
}
.chat-toast-bracket-tl,
.chat-toast-bracket-br { position: absolute; width: 10px; height: 10px; pointer-events: none; }
.chat-toast-bracket-tl {
    top: -2px; left: -2px;
    border-top: 1px solid rgba(var(--accent-rgb),0.45);
    border-left: 1px solid rgba(var(--accent-rgb),0.45);
}
.chat-toast-bracket-br {
    bottom: -2px; right: -2px;
    border-bottom: 1px solid rgba(var(--accent-rgb),0.45);
    border-right: 1px solid rgba(var(--accent-rgb),0.45);
}
.chat-toast-name {
    font-family: var(--font-serif);
    font-style: italic;
    font-size: 14px;
    color: var(--accent);
    text-shadow: 0 0 10px rgba(var(--accent-rgb),0.5);
    margin-bottom: 2px;
}
.chat-toast-msg {
    font-family: var(--font-sans);
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: rgba(var(--accent-rgb), 0.5);
}
.chat-toast:hover {
    border-color: rgba(var(--accent-rgb),0.3);
    box-shadow: 0 0 30px rgba(var(--bg-deepest-rgb), 0.5), inset 0 0 20px rgba(var(--accent-rgb),0.06);
}

/* Mobile: centre the toast at the top and float it above the full-screen
   chat panel (z-index 70) and any other overlays. Takes the safe-area inset
   into account so it never lands under a notch. */
@media (max-width: 700px) {
    .chat-toast,
    .darkroom-toast {
        top: calc(env(safe-area-inset-top, 0px) + 10px);
        right: 50%;
        transform: translateX(50%) translateY(-6px);
        max-width: calc(100vw - 32px);
        z-index: 15000;
    }
    .chat-toast.visible,
    .darkroom-toast.visible {
        transform: translateX(50%) translateY(0);
    }
}

/* ---- User Control Panel ---- */
.nav-ucp-icon {
    display: inline-flex; align-items: center; justify-content: center;
    color: #FFFFFF; padding: 4px 6px; background: none; border: none;
    cursor: pointer; transition: color 0.25s, filter 0.25s, transform 0.25s;
}
.nav-ucp-icon svg { display: block; }
.nav-ucp-icon:hover {
    color: #e8a0bf;
    filter: drop-shadow(0 0 8px rgba(232,160,191,0.5));
    transform: scale(1.08);
}
/* ucp styles moved to user-cp.js (self-contained) */

.mc-panel {
    position: fixed; top: 52px; right: 24px;
    width: 380px; height: 500px;
    background: rgba(var(--bg-panel-rgb), 0.92);
    backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(var(--accent-rgb),0.10);
    border-radius: 0;
    box-shadow:
        0 24px 60px rgba(0,0,0,0.5),
        0 0 0 1px rgba(var(--accent-rgb),0.03) inset,
        0 0 80px rgba(var(--accent-rgb),0.025);
    display: flex; flex-direction: column;
    overflow: hidden; z-index: 90;
    opacity: 0; transform: translateY(-10px);
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.mc-panel.open { opacity: 1; transform: translateY(0); pointer-events: auto; }

.mc-glow-line {
    position: absolute; top: 0; left: 0; right: 0; height: 1px;
    background: linear-gradient(to right, transparent 10%, rgba(var(--accent-rgb),0.35) 50%, transparent 90%);
    pointer-events: none;
}

/* Views */
.mc-view {
    position: absolute; inset: 0;
    display: flex; flex-direction: column;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease;
}
.mc-view:not(.mc-active) { opacity: 0; pointer-events: none; transform: translateX(30px); }
.mc-view.mc-active { opacity: 1; pointer-events: auto; transform: translateX(0); }
.mc-view-list:not(.mc-active) { transform: translateX(-30px); }

/* Header */
.mc-header {
    display: flex; align-items: center; padding: 14px 16px;
    border-bottom: 1px solid var(--border); gap: 10px; flex-shrink: 0;
}
.mc-header-title {
    font-family: var(--font-serif); font-style: italic; font-weight: 200;
    font-size: 17px; color: var(--text-muted); flex: 1; letter-spacing: 0.5px;
}
.mc-close {
    font-size: 20px; background: none; border: none; color: var(--text-muted);
    cursor: pointer; transition: color 0.2s; padding: 2px 6px; line-height: 1;
}
.mc-close:hover { color: var(--accent); }
.mc-back {
    background: none; border: none; color: var(--text-muted);
    cursor: pointer; padding: 4px; transition: color 0.2s; display: flex;
}
.mc-back:hover { color: var(--accent); }

/* Agent List */
.mc-agent-list { flex: 1; overflow-y: auto; padding: 4px 0; }
.mc-agent-row {
    display: flex; align-items: center; gap: 12px;
    padding: 11px 16px;
    transition: background 0.2s;
    border-bottom: 1px solid rgba(var(--border-rgb),0.08);
}
.mc-agent-avatar-wrap {
    flex-shrink: 0; cursor: pointer;
    transition: transform 0.15s;
    border-radius: 50%;
    padding: 2px;
    border: 2px solid transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 50px; height: 50px;
    overflow: hidden;
}
.mc-agent-avatar-wrap:hover { transform: scale(1.08); }
.mc-agent-avatar-wrap.mc-unread {
    border-color: rgba(var(--accent-rgb),0.6);
    box-shadow: 0 0 8px rgba(var(--accent-rgb),0.4), 0 0 16px rgba(var(--accent-rgb),0.15);
    animation: mc-unread-ring 2.2s ease-in-out infinite;
}
@keyframes mc-unread-ring {
    0%   { border-color: rgba(var(--accent-rgb),0.6); box-shadow: 0 0 8px rgba(var(--accent-rgb),0.4); }
    15%  { border-color: rgba(var(--accent-rgb),0.2); box-shadow: 0 0 3px rgba(var(--accent-rgb),0.1); }
    20%  { border-color: rgba(var(--accent-rgb),0.7); box-shadow: 0 0 12px rgba(var(--accent-rgb),0.5); }
    50%  { border-color: rgba(var(--accent-rgb),0.5); box-shadow: 0 0 6px rgba(var(--accent-rgb),0.3); }
    65%  { border-color: rgba(var(--accent-rgb),0.15); box-shadow: 0 0 2px rgba(var(--accent-rgb),0.1); }
    70%  { border-color: rgba(var(--accent-rgb),0.8); box-shadow: 0 0 14px rgba(var(--accent-rgb),0.6); }
    100% { border-color: rgba(var(--accent-rgb),0.6); box-shadow: 0 0 8px rgba(var(--accent-rgb),0.4); }
}
.mc-agent-info { cursor: pointer; }
.mc-agent-info:hover { background: rgba(var(--accent-rgb),0.04); }
.mc-agent-avatar {
    width: 42px; height: 42px; border-radius: 50%; object-fit: cover;
    flex-shrink: 0; border: 1px solid rgba(var(--accent-rgb),0.10);
}
video.mc-agent-avatar { background: var(--bg-card); }
.mc-agent-info { flex: 1; min-width: 0; }
.mc-agent-name {
    font-family: var(--font-serif); font-style: italic;
    font-size: 15px; color: var(--text-primary); line-height: 1.3;
    display: flex; align-items: center; gap: 0;
}
.mc-status-diamond { font-size: 8px; flex-shrink: 0; margin-right: 6px; }
.mc-agent-role {
    font-family: var(--font-sans); font-size: 8px;
    text-transform: uppercase; letter-spacing: 2.5px;
    color: var(--text-muted); margin-top: 2px;
}

/* Chat Header */
.mc-chat-info {
    display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0;
}
.mc-chat-avatar {
    width: 26px; height: 26px; border-radius: 50%; object-fit: cover;
    border: 1px solid rgba(var(--accent-rgb),0.10);
}
.mc-chat-name {
    font-family: var(--font-serif); font-style: italic;
    font-size: 15px; color: var(--accent);
}

/* Messages */
.mc-messages {
    flex: 1; overflow-y: auto; padding: 16px; display: flex;
    flex-direction: column; gap: 10px;
}
.mc-msg { max-width: 82%; display: flex; flex-direction: column; }
.mc-msg-user { align-self: flex-end; align-items: flex-end; }
.mc-msg-agent { align-self: flex-start; align-items: flex-start; }
.mc-bubble {
    padding: 9px 13px; border-radius: 4px;
    font-family: var(--font-sans); font-size: 13px;
    line-height: 1.6; font-weight: 300; letter-spacing: 0.2px;
}
.mc-msg-user .mc-bubble {
    background: rgba(var(--accent-rgb),0.06);
    border: 1px solid rgba(var(--accent-rgb),0.14);
    color: var(--accent);
}
.mc-msg-agent .mc-bubble {
    background: var(--agent-bubble-bg);
    border: 1px solid var(--border);
    color: var(--text-primary);
}
.mc-bubble .chat-photo-img {
    max-width: 160px;
    max-height: 160px;
}
.mc-copy-btn {
    margin-top: 4px;
    width: 24px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid rgba(var(--border-rgb),0.18);
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    transition: color 0.2s, border-color 0.2s;
}
.mc-copy-btn:hover,
.mc-copy-btn.copied {
    color: var(--accent);
    border-color: rgba(var(--accent-rgb),0.35);
}
.mc-msg-actions {
    display: inline-flex;
    gap: 4px;
    margin-top: 4px;
}
.mc-msg-actions .mc-copy-btn { margin-top: 0; }
.mc-msg-user .mc-msg-actions { align-self: flex-end; }
.mc-msg-agent .mc-msg-actions { align-self: flex-start; }
.mc-msg-user .mc-copy-btn { align-self: auto; }
.mc-msg-agent .mc-copy-btn { align-self: auto; }
.mc-copy-btn svg { display: block; }
.mc-restore-btn { display: none; margin-top: 0; opacity: 0.7; }
.mc-msg-hidden .mc-bubble,
.mc-msg-hidden .mc-msg-actions { display: none !important; }
.mc-msg-hidden .mc-restore-btn { display: inline-flex; }
.mc-msg-hidden.mc-msg-user .mc-restore-btn { align-self: flex-end; }
.mc-msg-hidden.mc-msg-agent .mc-restore-btn { align-self: flex-start; }
.mc-msg-hidden .mc-restore-btn:hover { opacity: 1; }
.mc-bubble .chat-photo-group {
    max-width: 260px;
}

/* Typing */
.mc-typing {
    align-self: flex-start; padding: 8px 14px;
    font-family: var(--font-serif); font-style: italic;
    font-size: 11px; color: var(--text-muted); letter-spacing: 0.5px;
}
.mc-typing-dots { display: inline-block; }
.mc-typing-dots span {
    display: inline-block; width: 4px; height: 4px;
    background: var(--text-muted); border-radius: 50%;
    margin: 0 1.5px; animation: mc-dot-pulse 1.4s ease-in-out infinite;
}
.mc-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.mc-typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes mc-dot-pulse {
    0%, 80%, 100% { opacity: 0.25; transform: scale(0.8); }
    40% { opacity: 1; transform: scale(1); }
}

/* Input */
.mc-input-area {
    display: flex; align-items: flex-end; gap: 6px;
    padding: 10px 14px; border-top: 1px solid var(--border); flex-shrink: 0;
}
.mc-input {
    flex: 1; background: rgba(var(--bg-deepest-rgb), 0.6);
    border: 1px solid var(--border); color: var(--text-primary);
    font-family: var(--font-sans); font-size: 13px; font-weight: 300;
    padding: 8px 12px; outline: none; resize: none;
    min-height: 36px; max-height: 80px; line-height: 1.5;
    transition: border-color 0.2s; letter-spacing: 0.2px;
    border-radius: 3px;
}
.mc-input:focus { border-color: rgba(var(--accent-rgb),0.25); }
.mc-input::placeholder {
    color: var(--text-muted); font-family: var(--font-serif); font-style: italic;
}
.mc-send {
    background: none; border: 1px solid rgba(var(--accent-rgb),0.15);
    color: var(--accent); width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: background 0.2s, border-color 0.2s;
    border-radius: 3px; flex-shrink: 0;
}
.mc-send:hover { background: rgba(var(--accent-rgb),0.06); border-color: rgba(var(--accent-rgb),0.3); }
.mc-send svg { display: block; }

/* ============================================= AGENT PROFILE POPUP */
.agp-overlay {
    position: fixed; inset: 0; z-index: 150;
    display: flex; align-items: center; justify-content: center;
    background: rgba(var(--bg-deepest-rgb),0.75);
    backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
    opacity: 0; pointer-events: none; transition: opacity 0.3s ease;
}
.agp-overlay.open { opacity: 1; pointer-events: auto; }
.agp-window {
    width: 75vw; height: 85vh;
    background: var(--bg-panel);
    border: 1px solid rgba(var(--border-rgb),0.15);
    display: flex; flex-direction: column;
    overflow: hidden;
}
.agp-layout { display: flex; flex: 1; min-height: 0; overflow: hidden; }
.agp-sidebar {
    width: 200px; flex-shrink: 0;
    background: var(--bg-deepest);
    border-right: 1px solid rgba(var(--border-rgb),0.12);
    display: flex; flex-direction: column;
    padding: 24px 0 20px;
    overflow-y: auto;
}
.agp-sidebar-section { padding: 0 16px; margin-bottom: 8px; }
.agp-sidebar-label {
    font-family: var(--font-serif);
    font-style: italic; font-weight: 200;
    font-size: 10px; text-transform: uppercase;
    letter-spacing: 2.5px; color: var(--accent);
    margin-bottom: 4px; text-align: center;
}
.agp-sidebar-avatar {
    width: 125px; height: 125px; object-fit: cover;
    border: 1px solid rgba(var(--accent-rgb),0.15);
    margin: 8px auto 6px; display: block;
    cursor: pointer;
    transition: border-color 0.18s, filter 0.18s;
}
.agp-sidebar-avatar:hover { border-color: rgba(var(--accent-rgb),0.35); filter: brightness(1.06); }
.agp-sidebar-name {
    font-family: var(--font-serif); font-style: italic;
    font-size: 16px; color: var(--text-primary);
    padding: 0 4px 4px; line-height: 1.3; text-align: center;
}
.agp-sidebar-model {
    font-family: var(--font-sans); font-size: 8px;
    text-transform: uppercase; letter-spacing: 2px;
    color: var(--text-muted); text-align: center;
}
.agp-grid-toggle {
    font-family: var(--font-mono); font-size: 7px;
    text-transform: uppercase; letter-spacing: 2.5px;
    padding: 3px 8px; margin: 8px auto 0; cursor: pointer;
    border: 1px solid rgba(var(--accent-rgb),0.15);
    display: block; width: fit-content; text-align: center;
    transition: all 0.2s;
}
.agp-grid-toggle.on {
    color: rgba(140,190,160,0.8);
    border-color: rgba(140,190,160,0.25);
    animation: gridGlitchOn 3s infinite;
}
.agp-grid-toggle.off {
    color: rgba(200,120,120,0.8);
    border-color: rgba(200,120,120,0.25);
    animation: gridGlitchOff 2.4s infinite;
}
.agp-grid-toggle:hover {
    border-color: var(--accent); color: var(--accent); animation: none;
}
@keyframes gridGlitchOn {
    0%   { text-shadow: 0 0 4px rgba(140,190,160,0.3); box-shadow: 0 0 4px rgba(140,190,160,0.08); opacity: 1; }
    15%  { text-shadow: 0 0 8px rgba(140,190,160,0.6); box-shadow: 0 0 8px rgba(140,190,160,0.15); opacity: 1; }
    18%  { opacity: 0.6; text-shadow: 0 0 2px rgba(140,190,160,0.2); }
    22%  { opacity: 1; text-shadow: 0 0 6px rgba(140,190,160,0.5); }
    50%  { text-shadow: 0 0 3px rgba(140,190,160,0.2); box-shadow: 0 0 3px rgba(140,190,160,0.05); opacity: 1; }
    70%  { text-shadow: 0 0 10px rgba(140,190,160,0.7); box-shadow: 0 0 10px rgba(140,190,160,0.18); opacity: 1; }
    72%  { opacity: 0.5; }
    75%  { opacity: 1; }
    100% { text-shadow: 0 0 4px rgba(140,190,160,0.3); box-shadow: 0 0 4px rgba(140,190,160,0.08); opacity: 1; }
}
@keyframes gridGlitchOff {
    0%   { text-shadow: 0 0 4px rgba(200,120,120,0.3); box-shadow: 0 0 4px rgba(200,120,120,0.08); opacity: 1; }
    12%  { opacity: 0.5; text-shadow: 0 0 2px rgba(200,120,120,0.1); }
    16%  { opacity: 1; text-shadow: 0 0 6px rgba(200,120,120,0.5); }
    30%  { text-shadow: 0 0 8px rgba(200,120,120,0.6); box-shadow: 0 0 8px rgba(200,120,120,0.15); opacity: 1; }
    33%  { opacity: 0.4; }
    36%  { opacity: 0.9; }
    38%  { opacity: 0.55; }
    42%  { opacity: 1; }
    60%  { text-shadow: 0 0 3px rgba(200,120,120,0.2); box-shadow: 0 0 3px rgba(200,120,120,0.05); }
    85%  { text-shadow: 0 0 7px rgba(200,120,120,0.5); box-shadow: 0 0 7px rgba(200,120,120,0.12); opacity: 1; }
    88%  { opacity: 0.6; }
    91%  { opacity: 1; }
    100% { text-shadow: 0 0 4px rgba(200,120,120,0.3); box-shadow: 0 0 4px rgba(200,120,120,0.08); opacity: 1; }
}
.pf-psych-generating {
    position: relative; display: flex;
    align-items: center; justify-content: center; min-height: 200px;
}
.pf-psych-generating-star-field {
    position: absolute; inset: 0; pointer-events: none; overflow: hidden;
}
.pf-psych-generating-star {
    position: absolute; color: var(--accent); font-size: 7px; opacity: 0;
    animation: agp-star-drift 2.4s ease-in-out infinite;
}
@keyframes agp-star-drift {
    0%   { opacity: 0; transform: translateY(0) scale(0.6); }
    30%  { opacity: 1; }
    100% { opacity: 0; transform: translateY(-12px) scale(1); }
}
.pf-psych-generating-tag {
    font-family: var(--font-sans); font-size: 9px;
    text-transform: uppercase; letter-spacing: 0.15em;
    padding: 6px 16px; background: rgba(var(--accent-rgb),0.1);
    color: var(--accent); z-index: 1;
    animation: agp-tag-pulse 2s ease-in-out infinite;
}
@keyframes agp-tag-pulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}
.agp-sidebar-divider { height: 1px; background: rgba(var(--border-rgb),0.1); margin: 14px 16px; }
.agp-sidebar-item {
    display: flex; align-items: center; gap: 8px;
    width: 100%; padding: 9px 12px;
    background: none; border: none;
    border-left: 2px solid transparent;
    color: var(--text-secondary);
    font-family: var(--font-sans); font-size: 12px;
    letter-spacing: 0.5px; cursor: pointer;
    transition: color 0.2s, border-color 0.2s, background 0.2s;
    text-align: left;
}
.agp-sidebar-item:hover { color: var(--text-primary); background: rgba(var(--accent-rgb),0.03); }
.agp-sidebar-item.active {
    color: var(--accent); border-left-color: var(--accent);
    background: rgba(var(--accent-rgb),0.04);
}
.agp-sidebar-diamond { font-size: 8px; opacity: 0.5; }
.agp-content {
    flex: 1; min-width: 0; overflow-y: auto; position: relative;
}
.agp-panel { display: none; padding: 32px 36px 60px; }
.agp-panel.active { display: block; }
.agp-panel[data-tab="dossier"].active { display: flex; padding: 0; height: 100%; }
.agp-panel[data-tab="dossier"] iframe { flex: 1; }
.agp-close {
    position: sticky; top: 0; z-index: 10;
    float: right; margin: 16px 20px 0 0;
    background: none; border: none;
    color: var(--text-muted); font-size: 22px;
    cursor: pointer; transition: color 0.2s;
}
.agp-close:hover { color: var(--accent); }
.agp-psych-section { margin-bottom: 28px; }
.agp-psych-label {
    font-family: var(--font-serif); font-style: italic; font-weight: 200;
    font-size: 10px; text-transform: uppercase; letter-spacing: 3px;
    color: rgba(var(--accent-rgb), 0.8); margin-bottom: 12px;
}
.agp-psych-act {
    font-family: var(--font-serif); font-style: italic;
    font-size: 16px; color: var(--text-secondary);
    text-align: right; margin-bottom: 4px;
}
.agp-mem-toolbar { padding: 0 0 20px; border-bottom: 1px solid rgba(var(--border-rgb),0.1); margin-bottom: 20px; }
.agp-mem-toolbar .memory-input { width: 100%; margin-bottom: 6px; }
.agp-mem-row { display: flex; gap: 6px; align-items: center; }
.agp-mem-search-row { margin-top: 8px; }
.agp-mem-search-row .memory-search-input { width: 100%; }
.agp-mem-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 0;
}
.agp-mem-card {
    background: var(--bg-panel); padding: 24px;
    border-top: 1px solid rgba(var(--accent-rgb),0.12);
    border-left: 1px solid rgba(var(--border-rgb),0.06);
    display: flex; flex-direction: column;
    min-height: 120px; position: relative; transition: background 0.2s;
}
.agp-mem-card:hover { background: rgba(var(--accent-rgb),0.02); }
.agp-mem-card-category {
    font-family: var(--font-sans); font-size: 7px;
    text-transform: uppercase; letter-spacing: 2px; color: var(--accent);
    margin-bottom: 8px;
}
.agp-mem-auto {
    font-size: 6px; letter-spacing: 1.5px; color: var(--text-muted);
    border: 1px solid var(--border); padding: 1px 5px; margin-left: 6px;
}
.agp-mem-card-content {
    font-family: var(--font-serif); font-size: 16px;
    color: rgba(var(--memory-rgb), 0.85); line-height: 1.6; flex: 1;
}
.agp-mem-card-date {
    font-family: var(--font-sans); font-size: 9px;
    color: var(--text-muted); margin-top: 12px;
}
.agp-mem-card-actions {
    position: absolute; top: 8px; right: 8px;
    display: flex; gap: 4px; opacity: 0; transition: opacity 0.2s;
}
.agp-mem-card:hover .agp-mem-card-actions { opacity: 1; }
.agp-mem-card-actions button {
    background: none; border: none; color: var(--text-muted);
    font-size: 12px; padding: 2px 4px; cursor: pointer;
}
.agp-mem-card-actions button:hover { color: var(--accent); }
.agp-mem-card-actions .memory-delete-btn:hover { color: #C47F6B; }
.agp-mem-card-actions button.pinned { color: var(--accent); }
.agp-mem-pinned { border-left: 2px solid var(--accent); background: rgba(var(--accent-rgb),0.03); }
.agp-mem-pinned .agp-mem-card-actions { opacity: 1; }
.agp-mem-inactive { opacity: 0.35; border-style: dashed; }
.agp-mem-inactive .agp-mem-card-actions { opacity: 1; }
/* Two-surface gallery counter for the agent profile popup:
   1. .panel-star-counter — big centered ticking counter that lives inside
      the star-field overlay during load. Vanishes (along with the star
      field) when load completes.
   2. .agp-gallery-count — small persistent header above the grid that
      shows the final total ("12 photos") AFTER load. Hidden during load
      and on empty galleries. */

.agp-gallery-count {
    font-family: var(--font-mono);
    font-size: 9px;
    letter-spacing: 2.5px;
    text-transform: uppercase;
    color: rgba(var(--text-primary-rgb), 0.5);
    text-align: right;
    padding: 6px 4px 8px 0;
    font-variant-numeric: tabular-nums;
    min-height: 14px;
    transition: opacity 0.3s;
    position: relative;
    z-index: 3;
}
.agp-gallery-count.hidden,
.agp-gallery-count:empty { display: none; }
.agp-gallery-count.done { opacity: 1; }

/* Fixed-positioning so the counter stays centered in the popup viewport
   even when the gallery is taller than the panel (500-photo case) and
   the user scrolls — without it, top:50% absolute would scroll off
   screen with the content. */
.panel-star-counter {
    position: fixed;
    top: 50%;
    left: calc(50% + 100px);
    transform: translate(-50%, -50%);
    font-family: var(--font-mono);
    font-size: 12px;
    letter-spacing: 2.5px;
    line-height: 1.4;
    text-transform: uppercase;
    text-align: center;
    color: rgba(var(--text-primary-rgb), 0.85);
    text-shadow: 0 0 14px rgba(var(--accent-rgb), 0.35);
    font-variant-numeric: tabular-nums;
    pointer-events: none;
    z-index: 9999;
    white-space: nowrap;
}

/* Empty-state placeholder for read-only galleries (no items yet). */
.agp-gallery-empty {
    grid-column: 1 / -1;
    padding: 28px 16px;
    text-align: center;
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    opacity: 0.55;
}

.agp-gallery-grid {
    display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px;
    margin-bottom: 24px;
}
.agp-gallery-thumb {
    position: relative; aspect-ratio: 1;
    background: var(--bg-card); border: 1px solid rgba(var(--border-rgb),0.2);
    overflow: hidden; display: flex; align-items: center; justify-content: center;
}
.agp-gallery-thumb img,
.agp-gallery-thumb video { width: 100%; height: 100%; object-fit: cover; filter: brightness(0.8); transition: filter 0.2s; }
.agp-gallery-thumb:hover img,
.agp-gallery-thumb:hover video { filter: brightness(1); }
/* .agp-gallery-remove, .agp-deleting-dots, .agp-upload-plus styles
   removed — galleries are read-only now (edits live in /dossier.html). */
@media (max-width: 900px) {
    .agp-window { width: 100vw; height: 100vh; max-height: none; border: none; }
    @supports (height: 100dvh) { .agp-window { height: 100dvh; } }

    /* --- Hide sidebar, show mobile header --- */
    .agp-sidebar { display: none; }
    .agp-sidebar.agp-sidebar-open {
        display: flex; position: fixed; top: 0; left: 0;
        width: 100vw; height: 100vh; z-index: 200;
        background: rgba(var(--bg-deepest-rgb), 0.96);
        backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
        align-items: center; justify-content: center;
        padding: 40px 20px;
    }
    @supports (height: 100dvh) { .agp-sidebar.agp-sidebar-open { height: 100dvh; } }
    .agp-sidebar.agp-sidebar-open .agp-sidebar-section { text-align: center; }
    .agp-sidebar.agp-sidebar-open .agp-sidebar-item {
        font-size: 18px; padding: 14px 0; justify-content: center;
        font-family: var(--font-serif); font-style: normal; font-weight: 300;
        border-left: none;
    }
    .agp-sidebar.agp-sidebar-open .agp-sidebar-item.active {
        border-left: none; color: var(--accent);
    }
    .agp-sidebar.agp-sidebar-open .agp-sidebar-diamond { font-size: 6px; }
    .agp-sidebar.agp-sidebar-open .agp-sidebar-avatar { width: 90px; height: 90px; }
    .agp-sidebar.agp-sidebar-open .agp-sidebar-label,
    .agp-sidebar.agp-sidebar-open .agp-sidebar-name {
        font-family: var(--font-serif);
        font-style: normal;
        font-weight: 300;
    }
    .agp-sidebar.agp-sidebar-open .agp-sidebar-name { font-size: 20px; margin-bottom: 4px; }
    .agp-sidebar.agp-sidebar-open .agp-sidebar-divider { margin: 12px auto; width: 60px; }

    /* --- Mobile header bar --- */
    .agp-mobile-header {
        display: flex; align-items: center; gap: 12px;
        padding: 12px 16px; border-bottom: 1px solid rgba(var(--border-rgb),0.15);
        background: var(--bg-panel);
        position: sticky; top: 0; z-index: 10;
    }
    .agp-mobile-avatar {
        width: 32px; height: 32px; border: 1px solid rgba(var(--accent-rgb),0.15);
        object-fit: cover;
    }
    .agp-mobile-name {
        flex: 1; font-family: var(--font-serif); font-style: normal;
        font-size: 14px; color: var(--text-primary);
        white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    }
    .agp-mobile-tab {
        font-family: var(--font-mono); font-size: 8px; text-transform: uppercase;
        letter-spacing: 2px; color: var(--text-muted); opacity: 0.7;
    }
    .agp-mobile-menu-btn {
        background: none; border: none; color: var(--text-primary);
        font-size: 20px; cursor: pointer; padding: 4px 6px;
        transition: color 0.2s;
    }
    .agp-mobile-menu-btn:hover { color: var(--accent); }

    /* --- Content adjustments --- */
    .agp-close { display: none; }
    .agp-panel { padding: 20px 16px; }
    .agp-mem-grid { grid-template-columns: 1fr; }
    .agp-gallery-grid { grid-template-columns: repeat(3, 1fr); }
    .panel-star-counter { left: 50%; }

    /* --- Sidebar close button (mobile overlay) --- */
    .agp-sidebar-mobile-close {
        position: absolute; top: 16px; right: 20px;
        background: none; border: none; color: var(--text-muted);
        font-size: 22px; cursor: pointer; padding: 4px 8px;
        transition: color 0.2s; display: none;
    }
    .agp-sidebar-mobile-close:hover { color: var(--accent); }
    .agp-sidebar.agp-sidebar-open .agp-sidebar-mobile-close { display: block; }
}

/* --- Desktop: hide mobile-only elements --- */
@media (min-width: 901px) {
    .agp-mobile-header { display: none; }
    .agp-sidebar-mobile-close { display: none; }
}

/* ---- AGENT PROFILE LIGHTBOX — SCRYING POOL ----------------------------- */

.agp-lightbox-overlay {
    position: fixed;
    inset: 0;
    background: radial-gradient(circle at center, var(--bg-panel) 0%, var(--bg-deepest) 70%);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* Decorative SVG circles */
.agp-lb-sigils {
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 0.2;
}
.agp-lb-sigil-dot {
    animation: agpSigilPulse 4s ease-in-out infinite;
}
@keyframes agpSigilPulse {
    0%, 100% { opacity: 0.2; r: 2; }
    50% { opacity: 0.5; r: 3; }
}

/* Star field */
.agp-lightbox-star-field {
    position: absolute;
    inset: 0;
    pointer-events: none;
}
.agp-lightbox-star {
    position: absolute;
    color: var(--accent);
    font-size: 8px;
    opacity: 0;
    animation: agpLightboxTwinkle 3s ease-in-out infinite;
}
@keyframes agpLightboxTwinkle {
    0%, 100% { opacity: 0; transform: scale(0.8); }
    50% { opacity: 0.6; transform: scale(1.2); }
}

/* The scrying pool — sized by height, full image visible */
.agp-lb-pool {
    position: relative;
    max-height: 65vh;
    border: 1px solid rgba(var(--accent-rgb),0.1);
    box-shadow: 0 0 100px rgba(var(--accent-rgb),0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    z-index: 2;
    flex-shrink: 0;
}

/* Media — fit by height, no masking */
.agp-lb-media {
    max-height: 65vh;
    max-width: 85vw;
    object-fit: contain;
    display: block;
    pointer-events: auto;
}

/* Agent name — top center */
.agp-lb-title {
    position: absolute;
    top: 10%;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    z-index: 3;
    pointer-events: none;
}
.agp-lb-title-name {
    font-family: var(--font-serif);
    font-style: italic;
    font-size: 24px;
    font-weight: 200;
    color: var(--text-primary);
    margin-bottom: 4px;
}
.agp-lb-title-sub {
    font-variant-caps: all-small-caps;
    font-family: var(--font-sans);
    font-size: 10px;
    letter-spacing: 3px;
    color: var(--text-muted);
}

/* Side nav panels — left (previous) and right (next) */
.agp-lb-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 3;
    max-width: 200px;
    cursor: pointer;
    transition: opacity 0.3s;
    opacity: 0.6;
}
.agp-lb-nav:hover { opacity: 1; }

.agp-lb-nav-prev {
    left: 8%;
    text-align: right;
}
.agp-lb-nav-next {
    right: 8%;
    text-align: left;
}

.agp-lb-nav-line {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}
.agp-lb-nav-prev .agp-lb-nav-line { justify-content: flex-end; }
.agp-lb-nav-next .agp-lb-nav-line { justify-content: flex-start; }

.agp-lb-nav-rule {
    width: 60px;
    height: 1px;
    background: linear-gradient(to right, transparent, rgba(var(--accent-rgb),0.3));
}
.agp-lb-nav-prev .agp-lb-nav-rule {
    background: linear-gradient(to left, transparent, rgba(var(--accent-rgb),0.3));
}

.agp-lb-nav-chevron {
    color: rgba(var(--accent-rgb),0.3);
    font-size: 24px;
    line-height: 1;
    transition: color 0.2s;
}
.agp-lb-nav:hover .agp-lb-nav-chevron { color: var(--accent); }

.agp-lb-nav-label {
    font-family: var(--font-serif);
    font-style: italic;
    font-size: 16px;
    font-weight: 200;
    color: rgba(var(--accent-rgb),0.6);
    margin-bottom: 4px;
}
.agp-lb-nav-date {
    font-variant-caps: all-small-caps;
    font-family: var(--font-sans);
    font-size: 9px;
    letter-spacing: 3px;
    color: var(--text-muted);
}

/* Next preview thumbnail */
.agp-lb-nav-preview {
    width: 80px;
    height: 80px;
    border: 1px solid rgba(var(--accent-rgb),0.15);
    object-fit: cover;
    opacity: 0.3;
    margin-top: 12px;
    transition: opacity 0.3s;
}
.agp-lb-nav:hover .agp-lb-nav-preview {
    opacity: 0.6;
}

/* Bottom action bar */
.agp-lb-actions {
    position: absolute;
    bottom: 10%;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 40px;
    z-index: 3;
}
.agp-lb-action {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
    transition: all 0.2s;
}
.agp-lb-action svg {
    width: 20px;
    height: 20px;
    stroke: rgba(var(--accent-rgb),0.2);
    fill: none;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: stroke 0.2s;
}
.agp-lb-action:hover svg { stroke: var(--accent); }
.agp-lb-action-label {
    font-family: var(--font-sans);
    font-size: 7px;
    letter-spacing: 4px;
    text-transform: uppercase;
    color: var(--text-muted);
    opacity: 0;
    transition: opacity 0.2s;
}
.agp-lb-action:hover .agp-lb-action-label { opacity: 1; }

/* Delete hover — rose instead of accent */
.agp-lb-action-delete:hover svg { stroke: #C87878; }
.agp-lb-action-delete:hover .agp-lb-action-label { color: #C87878; }

/* Close button */
.agp-lb-close {
    position: absolute;
    top: 24px;
    right: 32px;
    z-index: 10;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    transition: color 0.2s;
    font-family: var(--font-sans);
    font-weight: 200;
}
.agp-lb-close:hover { color: var(--accent); }

/* Counter */
.agp-lb-counter {
    position: absolute;
    bottom: 24px;
    right: 32px;
    z-index: 3;
    font-family: var(--font-sans);
    font-size: 8px;
    letter-spacing: 3px;
    color: var(--text-muted);
    pointer-events: none;
}

/* Tablet + mobile: simpler nav (chevron-only) and always-visible action
   labels since touch devices have no hover state. The action row itself
   (download / canvas / delete) and the avatar/banner shortcuts under the
   title stay visible — touch users still need to reach them. */
@media (max-width: 1100px) {
    /* Touch has no hover, so brighten the action icons + show labels. */
    .agp-lb-action svg { stroke: rgba(var(--accent-rgb),0.55); }
    .agp-lb-action-label { opacity: 0.7; }

    /* Mini nav chevron buttons — collapse the rich preview/date info into a
       simple round chevron, matching the photobooth lightbox. */
    .agp-lb-nav {
        max-width: none; width: 36px; height: 36px;
        background: rgba(var(--bg-deepest-rgb), 0.6);
        border: 1px solid rgba(var(--accent-rgb),0.1);
        display: flex; align-items: center; justify-content: center;
        opacity: 0.8;
    }
    .agp-lb-nav:hover { opacity: 1; background: rgba(var(--bg-deepest-rgb), 0.8); }
    .agp-lb-nav-prev { left: 12px; }
    .agp-lb-nav-next { right: 12px; }
    .agp-lb-nav-line { margin: 0; gap: 0; }
    .agp-lb-nav-rule { display: none; }
    .agp-lb-nav-label { display: none; }
    .agp-lb-nav-date { display: none; }
    .agp-lb-nav-preview { display: none; }
    .agp-lb-nav-chevron { font-size: 20px; color: rgba(var(--accent-rgb),0.6); }
    .agp-lb-nav:hover .agp-lb-nav-chevron { color: var(--accent); }
}

@media (max-width: 700px) {
    .agp-lb-pool { max-width: 92vw; max-height: 55vh; width: auto; height: auto; }
    .agp-lb-media { max-width: 92vw; max-height: 55vh; }

    .agp-lb-title { top: 5%; }
    .agp-lb-title-name { font-size: 18px; }
}

/* Empty state */
.mc-empty {
    flex: 1; display: flex; align-items: center; justify-content: center;
    font-family: var(--font-serif); font-style: italic;
    font-size: 12px; color: var(--text-muted); letter-spacing: 0.5px;
    padding: 40px;
}

/* ============================================= SHARED RESPONSIVE */

@media (max-width: 900px) {
    .page-title { font-size: 48px; }
    .nav-link { display: none; }
    .nav-dropdown { display: none !important; }
    .nav-world { display: none; }
    .nav-world-desc { display: none; }
    /* Hide nav-right icons on mobile EXCEPT the install chip and the
       hamburger — install needs to be reachable from the top bar so the
       PWA install offer doesn't get buried behind the menu. */
    .nav-right .nav-icon:not(.mobile-menu-btn):not(.nav-install-icon):not(.nav-theme-icon) { display: none !important; }
    .nav-right .nav-install-icon { padding: 4px 8px !important; }
    .nav-right .nav-install-icon svg { width: 18px !important; height: 18px !important; }
    .nav-right .nav-theme-icon { padding: 4px 8px !important; }
    .nav-right .nav-theme-icon svg { width: 18px !important; height: 18px !important; }
    .nav-user { display: none !important; }
    .mobile-menu-btn { display: flex !important; }
    .page-footer { padding: 32px 20px; }
}

/* ============================================= MOBILE NAV OVERLAY (SHARED) */

.mobile-menu-btn {
    display: none;
    align-items: center; justify-content: center;
    font-size: 20px; color: var(--text-primary);
    background: none; border: none; cursor: pointer;
    padding: 4px 6px; transition: color 0.2s;
}
.mobile-menu-btn:hover { color: var(--accent); }

.mobile-nav-overlay {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; z-index: 80;
    background: rgba(var(--bg-deepest-rgb), 0.96);
    backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 0; opacity: 0; pointer-events: none;
    transition: opacity 0.3s ease;
}
.mobile-nav-overlay.open { opacity: 1; pointer-events: auto; }

.mobile-nav-overlay::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0; height: 1px;
    background: linear-gradient(to right, transparent 10%, rgba(var(--accent-bright-rgb),0.5) 50%, transparent 90%);
}

.mobile-nav-overlay .mno-close {
    position: absolute; top: 16px; right: 20px;
    background: none; border: none; color: var(--accent-deep); font-size: 22px;
    cursor: pointer; padding: 4px 8px; transition: color 0.2s;
}
.mobile-nav-overlay .mno-close:hover { color: var(--accent); }

.mobile-nav-overlay .mno-link {
    display: flex; align-items: center; gap: 14px;
    font-family: var(--font-serif); font-style: normal; font-weight: 300;
    font-size: 20px; line-height: 1.08; color: var(--accent-deep); text-decoration: none;
    padding: 9px 0; letter-spacing: 0;
    transition: color 0.2s;
}
.mobile-nav-overlay .mno-link:hover { color: var(--accent); }

.mobile-nav-overlay .mno-bullet {
    font-size: 8px; color: var(--accent); font-style: normal;
}

.mobile-nav-overlay .mno-divider {
    width: 120px; height: 1px; margin: 12px 0;
    background: linear-gradient(to right, transparent 0%, rgba(var(--accent-rgb),0.45) 50%, transparent 100%);
}

.mobile-nav-overlay .mno-util-row {
    display: flex; align-items: center; justify-content: center; gap: 18px;
}
.mobile-nav-overlay .mno-util {
    display: inline-flex; align-items: center; justify-content: center;
    color: var(--accent-deep); cursor: pointer;
    padding: 10px;
    background: none; border: none;
    transition: color 0.2s, background 0.2s;
}
.mobile-nav-overlay .mno-util:hover {
    color: var(--accent);
}
.mobile-nav-overlay .mno-util-icon {
    display: inline-flex; align-items: center; justify-content: center;
}
.mobile-nav-overlay .mno-util-icon svg { display: block; }

/* Inline agent list — sits below the icon rows. Each row mirrors the
   social-feed sf-agent-item visual (avatar + name + status diamond) but
   sized for the hamburger menu. Scrolls if the list outgrows the menu. */
.mobile-nav-overlay .mno-agent-list {
    width: 100%;
    max-width: 320px;
    max-height: 38vh;
    overflow-y: auto;
    overflow-x: hidden;
    margin: 4px auto 0;
    padding: 0 4px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    scrollbar-width: thin;
    scrollbar-color: rgba(var(--accent-rgb),0.4) transparent;
}
.mobile-nav-overlay .mno-agent-list::-webkit-scrollbar { width: 4px; }
.mobile-nav-overlay .mno-agent-list::-webkit-scrollbar-thumb {
    background: rgba(var(--accent-rgb),0.4);
}
.mobile-nav-overlay .mno-agent-list-loading,
.mobile-nav-overlay .mno-agent-list-empty {
    text-align: center;
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--accent-deep);
    opacity: 0.6;
    padding: 14px 0;
}
.mobile-nav-overlay .mno-agent-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 10px;
    text-decoration: none;
    color: var(--text-primary);
    font-family: var(--font-serif);
    font-style: normal;
    font-weight: 300;
    font-size: 14px;
    letter-spacing: 0;
    border-radius: 0;
    transition: color 0.18s, background 0.18s;
}
.mobile-nav-overlay .mno-agent-row:hover,
.mobile-nav-overlay .mno-agent-row:active {
    color: var(--accent);
    background: rgba(var(--accent-rgb), 0.1);
}
.mobile-nav-overlay .mno-agent-avatar {
    width: 22px; height: 22px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    border: 1px solid rgba(var(--accent-rgb), 0.35);
}
.mobile-nav-overlay .mno-agent-avatar-empty {
    display: inline-flex; align-items: center; justify-content: center;
    background: rgba(var(--accent-rgb), 0.12);
    color: var(--accent-deep);
    font-family: var(--font-mono);
    font-style: normal;
    font-size: 10px;
    text-transform: uppercase;
}
.mobile-nav-overlay .mno-agent-name {
    flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mobile-nav-overlay .mno-agent-diamond {
    flex-shrink: 0;
    font-size: 10px;
    line-height: 1;
}

/* ============================================= QUICK PICKER
   Mobile chat-header brain / sun-snow icons open this. A single shared
   overlay that's repurposed per icon. */
.quick-picker {
    position: fixed; inset: 0; z-index: 300;
    background: rgba(var(--bg-deepest-rgb),0.85);
    backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
    align-items: center; justify-content: center;
}
.quick-picker[style*="flex"] { display: flex !important; }
.quick-picker-panel {
    width: min(92vw, 380px);
    background: var(--bg-panel);
    border: 1px solid var(--border);
    box-shadow: 0 24px 60px rgba(0,0,0,0.55);
    max-height: 80vh; display: flex; flex-direction: column;
}
.quick-picker-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 18px; border-bottom: 1px solid rgba(var(--border-rgb),0.18);
}
.quick-picker-title {
    font-family: var(--font-mono); font-size: 11px;
    letter-spacing: 3px; text-transform: uppercase;
    color: var(--accent);
}
.quick-picker-options {
    display: flex; flex-direction: column;
    padding: 8px 0; overflow-y: auto;
}
.quick-picker-opt {
    background: none; border: none; color: var(--text-secondary);
    font-family: var(--font-serif); font-style: normal; font-weight: 300;
    font-size: 16px; letter-spacing: 0;
    padding: 12px 22px; text-align: left; cursor: pointer;
    transition: color 0.18s, background 0.18s;
}
.quick-picker-opt:hover { color: var(--accent); background: rgba(var(--accent-rgb),0.04); }
.quick-picker-opt.active {
    color: var(--accent);
    background: rgba(var(--accent-rgb),0.08);
}
.quick-picker-opt.active::before {
    content: '\25C7 '; font-size: 9px; margin-right: 8px; vertical-align: middle;
}

/* ============================================= CHAT-ONLY MODE
   /map.html?chat_only=<id> strips the map out entirely so the chat is
   the page. Used by the DM links on agents.html so agents who can't
   load map dots on a slow network still land directly in the chat. */
body.chat-only .nav,
body.chat-only .panel-left,
body.chat-only .panel-center,
body.chat-only .panel-right-empty,
body.chat-only .home-panel,
body.chat-only #khLayer {
    display: none !important;
}
body.chat-only #mainGrid {
    grid-template-columns: 1fr !important;
}
body.chat-only .panel-right {
    display: flex !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    border-left: none !important;
}

@media (max-width: 900px) {
    body.chat-only .panel-right {
        position: fixed;
        left: 0; right: 0;
        top: 0; bottom: 0;
        height: 100dvh;
        z-index: 50;
    }
    /* Chat-only mode hides .panel-left with display:none !important above
       — but the chat header still has a panel icon that calls
       openMobilePanel(). When the user taps it, this more-specific rule
       beats the hide rule so the home info actually surfaces. Top:0
       (instead of 48px) because the nav is hidden in chat-only mode. */
    body.chat-only .panel-left.mobile-open {
        display: flex !important;
        flex-direction: column;
        position: fixed;
        top: 0; left: 0; right: 0; bottom: 0;
        width: 100%;
        height: 100vh;
        z-index: 60;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: max(24px, env(safe-area-inset-bottom));
    }
    @supports (height: 100dvh) {
        body.chat-only .panel-left.mobile-open { height: 100dvh; }
    }
}

/* ============================================================
   FILM BOOTH — "Send to the darkroom" popup + indicators
   ============================================================ */

/* Popup overlay (photo lightbox -> darkroom) */
.darkroom-overlay {
    position: fixed;
    inset: 0;
    z-index: 10500;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(var(--bg-deepest-rgb), 0.78);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    padding: 20px;
}
.darkroom-window {
    position: relative;
    width: 560px;
    max-width: 100%;
    max-height: 92vh;
    overflow-y: auto;
    background: linear-gradient(160deg, rgba(var(--bg-deepest-rgb),0.96) 0%, rgba(var(--bg-panel-rgb),0.92) 100%);
    border: 1px solid rgba(var(--accent-rgb),0.22);
    box-shadow: 0 0 40px rgba(0,0,0,0.6), inset 0 0 40px rgba(var(--accent-rgb),0.04);
    padding: 26px 30px 24px;
}
.darkroom-window::before,
.darkroom-window::after {
    content: '';
    position: absolute;
    width: 14px; height: 14px;
    pointer-events: none;
}
.darkroom-window::before {
    top: 6px; left: 6px;
    border-top: 1px solid rgba(var(--accent-rgb),0.5);
    border-left: 1px solid rgba(var(--accent-rgb),0.5);
}
.darkroom-window::after {
    bottom: 6px; right: 6px;
    border-bottom: 1px solid rgba(var(--accent-rgb),0.5);
    border-right: 1px solid rgba(var(--accent-rgb),0.5);
}
.darkroom-close {
    position: absolute;
    top: 10px; right: 10px;
    background: none; border: none;
    color: rgba(var(--accent-rgb),0.5);
    font-size: 18px; cursor: pointer;
    padding: 4px 8px;
    transition: color 0.2s;
}
.darkroom-close:hover { color: var(--accent); }
.darkroom-title {
    font-family: var(--font-serif);
    font-style: italic;
    font-size: 22px;
    color: var(--accent);
    text-shadow: 0 0 14px rgba(var(--accent-rgb),0.25);
    text-align: center;
    margin-bottom: 4px;
}
.darkroom-sub {
    text-align: center;
    font-family: var(--font-sans);
    font-size: 10px;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: rgba(var(--accent-rgb), 0.55);
    margin-bottom: 20px;
}
.darkroom-body {
    display: flex;
    flex-direction: column;
    gap: 18px;
}
.darkroom-preview {
    display: flex; justify-content: center;
}
.darkroom-preview-img {
    max-width: 180px;
    max-height: 180px;
    object-fit: contain;
    border: 1px solid rgba(var(--accent-rgb),0.2);
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
    background: #000;
}
.darkroom-form { display: flex; flex-direction: column; gap: 10px; }
.darkroom-label {
    font-family: 'Newsreader', var(--font-serif), serif;
    font-style: italic;
    font-weight: 300;
    font-size: 11px;
    letter-spacing: 2.5px;
    text-transform: uppercase;
    color: #FFFFFF;
    margin-top: 4px;
}
.darkroom-motion {
    width: 100%;
    background: rgba(var(--bg-deepest-rgb),0.7);
    border: 1px solid rgba(var(--accent-rgb),0.18);
    color: var(--accent);
    font-family: var(--font-serif);
    font-size: 13px;
    padding: 10px 12px;
    resize: none;
    line-height: 1.55;
    box-sizing: border-box;
}
.darkroom-motion:focus {
    outline: none;
    border-color: rgba(var(--accent-rgb),0.45);
    box-shadow: 0 0 12px rgba(var(--accent-rgb),0.1) inset;
}
.darkroom-motion::placeholder {
    color: rgba(var(--accent-rgb),0.35);
    font-style: italic;
}
.darkroom-picker {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.darkroom-picker-small .darkroom-opt {
    padding: 5px 10px;
    font-size: 10px;
}
.darkroom-opt {
    background: rgba(var(--bg-deepest-rgb),0.6);
    border: 1px solid rgba(var(--accent-rgb),0.18);
    color: rgba(var(--accent-rgb),0.75);
    font-family: var(--font-sans);
    font-size: 11px;
    letter-spacing: 1.5px;
    padding: 7px 14px;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
}
.darkroom-opt:hover {
    border-color: rgba(var(--accent-rgb),0.4);
    color: var(--accent);
}
.darkroom-opt.selected {
    background: rgba(var(--accent-rgb),0.12);
    border-color: rgba(var(--accent-rgb),0.55);
    color: var(--accent);
    box-shadow: inset 0 0 10px rgba(var(--accent-rgb),0.08);
}
.darkroom-cost {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 10px 0 2px;
    border-top: 1px solid rgba(var(--accent-rgb),0.12);
    margin-top: 4px;
}
.darkroom-cost-label {
    font-family: 'Newsreader', var(--font-serif), serif;
    font-style: italic;
    font-size: 11px;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: #FFFFFF;
}
.darkroom-cost-value {
    font-family: var(--font-serif);
    font-style: italic;
    font-size: 15px;
    color: var(--accent);
    text-shadow: 0 0 10px rgba(var(--accent-rgb),0.3);
}
.darkroom-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 8px;
}
.darkroom-cancel, .darkroom-submit {
    font-family: var(--font-sans);
    font-size: 10px;
    letter-spacing: 2px;
    text-transform: uppercase;
    padding: 10px 20px;
    cursor: pointer;
    transition: all 0.2s;
}
.darkroom-cancel {
    background: none;
    border: 1px solid rgba(var(--accent-rgb),0.2);
    color: rgba(var(--accent-rgb),0.6);
}
.darkroom-cancel:hover { color: var(--accent); border-color: rgba(var(--accent-rgb),0.45); }
.darkroom-submit {
    background: rgba(var(--accent-rgb),0.15);
    border: 1px solid rgba(var(--accent-rgb),0.55);
    color: var(--accent);
    box-shadow: 0 0 15px rgba(var(--accent-rgb),0.1), inset 0 0 12px rgba(var(--accent-rgb),0.05);
}
.darkroom-submit:hover:not(:disabled) {
    background: rgba(var(--accent-rgb),0.22);
    box-shadow: 0 0 25px rgba(var(--accent-rgb),0.25), inset 0 0 12px rgba(var(--accent-rgb),0.08);
}
.darkroom-submit:disabled { opacity: 0.5; cursor: wait; }
.darkroom-hint {
    font-family: 'Newsreader', var(--font-serif), serif;
    font-style: italic;
    font-size: 10px;
    line-height: 1.55;
    color: rgba(var(--accent-rgb), 0.45);
    text-align: center;
    margin-top: 6px;
}

/* Toast (reuse chat-toast shape, but gold-tinted for "ready" variant) */
.darkroom-toast {
    position: fixed;
    top: 60px;
    right: 20px;
    z-index: 9999;
    padding: 14px 20px;
    min-width: 200px;
    backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
    background: linear-gradient(135deg, rgba(var(--bg-deepest-rgb),0.72) 0%, rgba(var(--bg-deepest-rgb),0.5) 100%);
    border: 1px solid rgba(var(--accent-rgb),0.2);
    box-shadow: 0 0 30px rgba(var(--bg-deepest-rgb), 0.5), inset 0 0 20px rgba(var(--accent-rgb),0.04);
    cursor: pointer;
    opacity: 0;
    transform: translateX(20px);
    transition: opacity 0.35s ease, transform 0.35s ease;
    pointer-events: none;
}
.darkroom-toast.visible {
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
}
.darkroom-toast-ready {
    border-color: rgba(var(--accent-rgb),0.45);
    box-shadow: 0 0 40px rgba(var(--accent-rgb),0.18), inset 0 0 20px rgba(var(--accent-rgb),0.08);
}
.darkroom-toast-bracket-tl,
.darkroom-toast-bracket-br { position: absolute; width: 10px; height: 10px; pointer-events: none; }
.darkroom-toast-bracket-tl {
    top: -2px; left: -2px;
    border-top: 1px solid rgba(var(--accent-rgb),0.5);
    border-left: 1px solid rgba(var(--accent-rgb),0.5);
}
.darkroom-toast-bracket-br {
    bottom: -2px; right: -2px;
    border-bottom: 1px solid rgba(var(--accent-rgb),0.5);
    border-right: 1px solid rgba(var(--accent-rgb),0.5);
}
.darkroom-toast-msg {
    font-family: var(--font-sans);
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: rgba(var(--accent-rgb), 0.55);
}
.darkroom-toast-name {
    font-family: var(--font-serif);
    font-style: italic;
    font-size: 14px;
    color: var(--accent);
    text-shadow: 0 0 10px rgba(var(--accent-rgb),0.5);
    margin: 2px 0;
}
.darkroom-toast-queue {
    font-family: 'Newsreader', serif;
    font-size: 10px;
    color: rgba(var(--accent-rgb),0.55);
}

/* Clapperboard indicators (map dots + mini-chat avatars) */
@keyframes film-jump {
    0%, 100% { transform: translate(-50%, 0); }
    50%      { transform: translate(-50%, -3px); }
}
@keyframes film-glow-pulse {
    0%, 100% { filter: drop-shadow(0 0 3px rgba(var(--accent-rgb),0.6)) drop-shadow(0 0 8px rgba(var(--accent-rgb),0.35)); }
    50%      { filter: drop-shadow(0 0 6px rgba(var(--accent-rgb),0.95)) drop-shadow(0 0 14px rgba(var(--accent-rgb),0.6)); }
}
.film-indicator {
    position: absolute;
    left: 50%;
    top: 100%;
    transform: translate(-50%, 0);
    margin-top: 4px;
    width: 16px; height: 16px;
    color: #E8C89D;
    pointer-events: none;
    animation: film-jump 0.9s ease-in-out infinite, film-glow-pulse 2s ease-in-out infinite;
}
.film-indicator svg { width: 100%; height: 100%; }

/* Mobile mini-chat: indicator sits bottom-right of the avatar wrap */
.mc-film-indicator {
    position: absolute;
    bottom: -4px; right: -4px;
    width: 16px; height: 16px;
    color: #E8C89D;
    pointer-events: none;
    animation: film-glow-pulse 2s ease-in-out infinite;
    background: rgba(12,16,20,0.9);
    border-radius: 50%;
    padding: 2px;
    box-sizing: border-box;
    border: 1px solid rgba(var(--accent-rgb),0.35);
}
.mc-film-indicator svg { width: 100%; height: 100%; display: block; }
.mc-agent-avatar-wrap { position: relative; }

/* Failed films banner inside the Videos tab */
.agp-failed-films {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px 14px 14px;
    border-bottom: 1px solid rgba(var(--accent-rgb),0.12);
    margin-bottom: 10px;
    /* Sit above the loading star field (z-index:1) and stay opaque even when
       the panel is mid-load — this is a "you just got charged" notice, it
       absolutely must not be hidden behind the ✦ animation. */
    position: relative;
    z-index: 10;
}
.panel-loading > .agp-failed-films,
.agp-panel.panel-loading .agp-failed-films { opacity: 1 !important; }
.agp-failed-film-note {
    font-family: 'Newsreader', serif;
    font-style: italic;
    font-size: 10px;
    line-height: 1.45;
    color: rgba(var(--accent-rgb),0.5);
    margin-top: 4px;
}
.agp-failed-film-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    background: rgba(40, 20, 15, 0.3);
    border: 1px solid rgba(220, 140, 110, 0.25);
}
.agp-failed-film-thumb {
    width: 48px; height: 48px;
    object-fit: cover;
    opacity: 0.7;
    border: 1px solid rgba(var(--accent-rgb),0.18);
}
.agp-failed-film-body { flex: 1; min-width: 0; }
.agp-failed-film-title {
    font-family: 'Newsreader', serif;
    font-style: italic;
    font-size: 13px;
    color: #E8AA90;
    margin-bottom: 3px;
}
.agp-failed-film-err {
    font-family: var(--font-sans);
    font-size: 10px;
    color: rgba(var(--accent-rgb),0.45);
    word-break: break-word;
    line-height: 1.4;
}
.agp-failed-film-retake {
    font-family: var(--font-sans);
    font-size: 10px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    padding: 8px 14px;
    background: rgba(var(--accent-rgb),0.12);
    border: 1px solid rgba(var(--accent-rgb),0.4);
    color: var(--accent);
    cursor: pointer;
    transition: background 0.2s;
}
.agp-failed-film-retake:hover:not(:disabled) { background: rgba(var(--accent-rgb),0.22); }
.agp-failed-film-retake:disabled { opacity: 0.5; cursor: wait; }

@media (max-width: 640px) {
    .darkroom-window { padding: 20px 16px 16px; }
    .darkroom-preview-img { max-width: 140px; max-height: 140px; }
    .darkroom-title { font-size: 18px; }
}
