        /* Import fonts for Clean skin; Cinzel/Crimson Text loaded by arcane skin */
        @import url('https://fonts.googleapis.com/css2?family=Lora:ital,wght@0,400;0,500;0,600;0,700;1,400;1,500;1,600;1,700&family=Inter:ital,opsz,wght@0,14..32,300..700;1,14..32,300..700&display=swap');

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

        /* Force font inheritance on form elements (browsers override these by default) */
        input, textarea, button, select, optgroup, option {
            font-family: inherit;
            font-size: inherit;
            font-weight: inherit;
            letter-spacing: inherit;
            font-feature-settings: inherit;
            font-optical-sizing: inherit;
            line-height: inherit;
        }

        :root {
            /* Font size scale (adjustable via settings) */
            --font-scale: 1;

            /* ============================================
               CLEAN PALETTE — Neutral modern defaults
               ============================================ */

            /* Background — neutral dark */
            --bg-primary: #0F0F0F;
            --bg-secondary: #1A1A1A;
            --bg-tertiary: #242424;
            --bg-elevated: #242424;
            --bg-surface: #2E2E2E;

            /* Neutral metals (kept for arcane compatibility, unused in clean) */
            --brass: #B8956E;
            --brass-light: #D4B896;
            --brass-dark: #8B6914;
            --copper: #B87333;
            --copper-light: #DA9A5C;
            --copper-dark: #8B4513;
            --bronze: #A67C52;
            --rust: #8B4726;
            --iron-dark: #2D2926;
            --iron-light: #4A4540;

            /* Borders — neutral */
            --border-subtle: rgba(255, 255, 255, 0.07);
            --border-light: rgba(255, 255, 255, 0.12);
            --border-medium: rgba(255, 255, 255, 0.20);
            --border-rivet: rgba(255, 255, 255, 0.15);

            /* Text — neutral */
            --text-primary: #F2F2F2;
            --text-secondary: #888888;
            --text-muted: #555555;
            --text-glow: rgba(242, 242, 242, 0.8);

            /* Neutral accent — single warm tone, skin-level only */
            --accent: #A09588;
            --accent-subtle: rgba(160, 149, 136, 0.12);
            --accent-glow: rgba(160, 149, 136, 0.25);

            /* Typography — Lora display + body / Inter UI */
            --font-display: 'Lora', Georgia, 'Times New Roman', serif;
            --font-body: 'Lora', Georgia, 'Times New Roman', serif;
            --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', system-ui, sans-serif;

            /* Decorative vars (kept for arcane compat, neutral in clean) */
            --gear-color: rgba(255, 255, 255, 0.05);
            --rivet-color: rgba(255, 255, 255, 0.15);
            --rivet-highlight: rgba(255, 255, 255, 0.3);
            --panel-gradient: linear-gradient(180deg, #242424 0%, #1A1A1A 100%);
            --brass-gradient: linear-gradient(180deg, #888888 0%, #555555 50%, #333333 100%);
            --metal-sheen: linear-gradient(135deg, transparent 0%, rgba(255,255,255,0.03) 50%, transparent 100%);

            /* Border vars (neutral in clean) */
            --border-etched: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.1) 5%, rgba(255,255,255,0.2) 15%, rgba(255,255,255,0.1) 50%, rgba(255,255,255,0.2) 85%, rgba(255,255,255,0.1) 95%, transparent 100%);
            --border-etched-v: linear-gradient(180deg, transparent 0%, rgba(255,255,255,0.1) 5%, rgba(255,255,255,0.2) 15%, rgba(255,255,255,0.1) 50%, rgba(255,255,255,0.2) 85%, rgba(255,255,255,0.1) 95%, transparent 100%);

            /* Filigree/ornamental (neutral in clean) */
            --filigree-color: rgba(255, 255, 255, 0.06);
            --patina: rgba(255, 255, 255, 0.02);

            /* Shadows — neutral */
            --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4);
            --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.5);
            --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.6);
            --shadow-inset: inset 0 2px 4px rgba(0, 0, 0, 0.3);

            /* Border radius — clean rounded */
            --radius: 10px;
        }


        body {
            font-family: var(--font-body);
            background: var(--bg-primary);
            min-height: 100vh;
            min-height: 100dvh;
            display: flex;
            color: var(--text-primary);
            font-size: 16px;
            line-height: 1.7;
            -webkit-font-smoothing: antialiased;
            -moz-osx-font-smoothing: grayscale;
            overflow: hidden;
            transition: background 0.8s ease;
            letter-spacing: 0;
            font-feature-settings: 'kern' 1, 'liga' 1, 'calt' 1;
            font-optical-sizing: auto;
        }

        /* Grain texture overlay — moved to arcane skin only (quartet-skin-arcane.css) */

        /* Theme transition flash - uses a separate element */
        .theme-flash {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: var(--accent-glow);
            opacity: 0;
            pointer-events: none;
            z-index: 10000;
        }

        body.theme-switching .theme-flash {
            animation: themeFlash 0.8s ease-out;
        }

        @keyframes themeFlash {
            0% { opacity: 0.25; }
            100% { opacity: 0; }
        }

        /* Ambient background canvas - more visible */
        #ambientCanvas {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            pointer-events: none;
            z-index: 0;
            opacity: 0.85;
        }

        /* Industrial vignette — moved to arcane skin only (quartet-skin-arcane.css) */

        /* Sidebar - Clean panel */
        .sidebar {
            width: 280px;
            background: var(--bg-secondary);
            border-right: none;
            display: flex;
            flex-direction: column;
            height: 100vh;
            height: 100dvh;
            min-height: 0;
            flex-shrink: 0;
            position: relative;
            z-index: 10;
        }

        /* Brass rail edge and railGlow animation — moved to arcane skin only (quartet-skin-arcane.css) */

        /* Corner rivets decoration — moved to arcane skin only (quartet-skin-arcane.css) */

        .sidebar-header {
            padding: 1.5rem;
            padding-top: 2rem;
            border-bottom: none;
            -webkit-app-region: drag;
            position: relative;
            overflow: hidden;
            background: transparent;
        }

        /* Decorative brass corner brackets — moved to arcane skin only (quartet-skin-arcane.css) */

        .sidebar-header h1 {
            font-family: var(--font-ui);
            font-size: 0.65rem;
            color: var(--text-secondary);
            font-weight: 500;
            letter-spacing: 0.22em;
            text-transform: uppercase;
            transition: color 0.5s ease;
            opacity: 0.7;
            display: flex;
            align-items: center;
            gap: 7px;
        }
        .sidebar-logo {
            width: 14px;
            height: 14px;
            flex-shrink: 0;
        }

        .sidebar-header .subtitle {
            font-family: var(--font-body);
            font-size: 0.8rem;
            color: var(--text-muted);
            margin-top: 0.4rem;
            font-weight: 400;
            letter-spacing: 0.05em;
            font-style: italic;
        }

        .chat-list {
            flex: 1;
            overflow-y: auto;
            padding: 1rem;
        }

        .chat-list::-webkit-scrollbar {
            width: 4px;
        }
        .chat-list::-webkit-scrollbar-track {
            background: transparent;
        }
        .chat-list::-webkit-scrollbar-thumb {
            background: var(--border-light);
            border-radius: 2px;
        }

        .chat-section {
            margin-bottom: 1.5rem;
        }

        /* Summoning Portal sidebar entry — styled identically to section headers */
        .sidebar-summon-section {
            cursor: pointer;
        }

        .sidebar-summon-title {
            display: flex;
            align-items: center;
            justify-content: space-between;
            opacity: 0.85;
            transition: opacity 0.15s ease;
        }

        .sidebar-summon-section:hover .sidebar-summon-title {
            opacity: 1;
        }

        .sidebar-summon-arrow {
            font-size: 0.9rem;
            opacity: 0.6;
        }

        .chat-section-title {
            font-family: var(--font-ui);
            font-size: 0.6rem;
            letter-spacing: 0.1em;
            color: var(--text-muted);
            margin-bottom: 0.5rem;
            padding-left: 0.5rem;
            font-weight: 500;
            text-transform: uppercase;
            text-shadow: none;
            border-bottom: none;
            padding-bottom: 0.35rem;
            position: relative;
            display: flex;
            align-items: center;
            gap: 0.5rem;
            opacity: 0.7;
        }

        /* Neutral ruling line after title text — removed for clean look */
        .chat-section-title::after {
            content: '';
            flex: 1;
            height: 1px;
            background: transparent;
        }

        .chat-item {
            padding: 0.65rem 0.85rem;
            border-radius: 8px;
            cursor: pointer;
            margin-bottom: 1px;
            transition: background 0.15s ease, color 0.15s ease;
            display: flex;
            align-items: center;
            gap: 0.7rem;
            -webkit-app-region: no-drag;
            position: relative;
            border: 1px solid transparent;
            background: transparent;
        }

        .chat-item:hover {
            background: rgba(255, 255, 255, 0.04);
        }

        .chat-item.active {
            background: rgba(255, 255, 255, 0.06);
        }

        .chat-item.active::before {
            content: '';
            position: absolute;
            left: 0;
            top: 50%;
            transform: translateY(-50%);
            width: 2px;
            height: 0%;
            background: var(--text-secondary);
            border-radius: 0 2px 2px 0;
            animation: borderGrow 0.35s cubic-bezier(0.4, 0, 0.2, 1) forwards;
        }

        @keyframes borderGrow {
            from { height: 0%; opacity: 0; }
            to { height: 70%; opacity: 1; }
        }

        /* Elemental glyph — replaces colored indicator dot */
        .chat-item .sovereign-glyph {
            width: 22px;
            flex-shrink: 0;
            font-size: 1rem;
            text-align: center;
            color: var(--text-secondary);
            opacity: 0.7;
            transition: opacity 0.2s ease, color 0.2s ease;
            line-height: 1;
        }

        .chat-item.active .sovereign-glyph {
            color: var(--text-primary);
            opacity: 1;
        }

        .chat-item .name {
            flex: 1;
            font-size: 0.875rem;
            font-weight: 500;
            color: var(--text-primary);
            transition: color 0.15s ease;
            letter-spacing: 0.01em;
            font-family: var(--font-ui);
        }

        .chat-item:hover .name {
            color: var(--text-primary);
        }

        .chat-item .element {
            font-size: 0.62rem;
            color: var(--text-muted);
            font-weight: 400;
            letter-spacing: 0.02em;
            font-style: normal;
            opacity: 0.7;
            font-family: var(--font-ui);
        }

        .chat-item .conversation-title {
            display: block;
            font-size: 0.65rem;
            color: var(--text-secondary);
            font-weight: 400;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            max-width: 140px;
            margin-top: 1px;
        }

        .chat-item .pin-indicator {
            font-size: 0.6rem;
            margin-right: 4px;
            flex-shrink: 0;
        }

        .chat-item.pinned {
            border-left: none;
        }

        /* Conversation context menu */
        .conversation-context-menu {
            position: fixed;
            background: var(--bg-elevated);
            border: 1px solid var(--border-subtle);
            border-radius: var(--radius);
            padding: 4px;
            z-index: 9999;
            box-shadow: var(--shadow-lg);
            min-width: 120px;
        }

        .ctx-menu-item {
            display: block;
            width: 100%;
            padding: 6px 12px;
            background: transparent;
            border: none;
            color: var(--text-primary);
            font-size: 0.8rem;
            text-align: left;
            cursor: pointer;
            border-radius: var(--radius);
            transition: all 0.15s ease;
        }

        .ctx-menu-item:hover {
            background: linear-gradient(90deg, var(--accent-subtle) 0%, transparent 100%);
            padding-left: 16px;
        }

        /* Settings Footer */
        .sidebar-footer {
            padding: 0.75rem;
            border-top: none;
            -webkit-app-region: no-drag;
            background: transparent;
        }

        .settings-row {
            display: flex;
            align-items: center;
            gap: 0.5rem;
            margin-bottom: 0.4rem;
        }

        .settings-row label {
            font-size: 0.7rem;
            color: var(--text-muted);
            width: 50px;
            flex-shrink: 0;
            font-family: var(--font-display);
            letter-spacing: 0.02em;
        }

        .settings-row select, .settings-row input[type="text"], .settings-row input[type="password"] {
            flex: 1;
            min-width: 0;
            max-width: 100%;
            background: var(--bg-tertiary);
            border: 1px solid transparent;
            color: var(--text-primary);
            padding: 0.35rem 0.5rem;
            border-radius: var(--radius);
            font-size: 0.75rem;
            font-family: inherit;
            text-overflow: ellipsis;
            overflow: hidden;
            white-space: nowrap;
            transition: all 0.2s ease;
        }

        .checkbox-inline {
            display: flex;
            align-items: center;
            gap: 8px;
            font-size: 13px;
            color: var(--text-primary);
        }

        .checkbox-inline input {
            transform: scale(1.1);
        }

        .settings-row select:focus, .settings-row input:focus {
            outline: none;
            border-color: var(--accent);
            box-shadow: inset 0 2px 4px rgba(0,0,0,0.4), 0 0 10px var(--accent-subtle);
        }

        .status-bar {
            display: flex;
            align-items: center;
            gap: 0.4rem;
            padding-top: 0.4rem;
        }

        .status-dot {
            width: 5px;
            height: 5px;
            border-radius: 50%;
            background: var(--accent);
        }

        .status-dot.connected {
            background: #4ade80;
        }

        .status-text {
            font-size: 0.65rem;
            color: var(--text-muted);
        }

        /* Settings row — no-label variant (full-width input) */
        .settings-row--no-label {
            margin-bottom: 0.35rem;
        }
        .settings-row--no-label input {
            flex: 1;
            min-width: 0;
        }

        /* Remember key row — subtle */
        .settings-remember-row {
            margin-bottom: 0.5rem;
            padding-left: 0.1rem;
        }
        .settings-remember-row .checkbox-inline {
            font-size: 0.68rem;
            color: var(--text-muted);
            opacity: 0.75;
        }
        .settings-remember-row .checkbox-inline input {
            transform: scale(0.9);
        }

        /* Dev key model note */
        .dev-key-model-note {
            font-size: 0.68rem;
            color: var(--text-muted);
            font-style: italic;
            opacity: 0.8;
            padding: 0.3rem 0.1rem 0.5rem;
            line-height: 1.4;
        }

        /* Live OR model search */
        .or-model-search-wrap { padding-top: 0.2rem; padding-bottom: 0.1rem; }
        .or-search-inner { position: relative; width: 100%; }
        .or-search-inner input[type="text"] {
            width: 100%;
            background: var(--bg-secondary);
            border: 1px solid var(--border);
            border-radius: 6px;
            color: var(--text-primary);
            font-size: 0.8rem;
            padding: 0.35rem 0.6rem;
            outline: none;
            box-sizing: border-box;
        }
        .or-search-inner input[type="text"]:focus { border-color: var(--accent); }
        .or-search-results {
            position: absolute;
            top: calc(100% + 4px);
            left: 0; right: 0;
            background: var(--bg-primary);
            border: 1px solid var(--border);
            border-radius: 8px;
            list-style: none;
            margin: 0; padding: 0.2rem 0;
            max-height: 240px;
            overflow-y: auto;
            z-index: 9999;
            box-shadow: 0 4px 16px rgba(0,0,0,0.25);
        }
        .or-search-item {
            padding: 0.4rem 0.8rem;
            font-size: 0.78rem;
            color: var(--text-primary);
            cursor: pointer;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }
        .or-search-item:hover { background: var(--bg-hover); }
        .or-search-loading, .or-search-empty {
            padding: 0.5rem 0.8rem;
            font-size: 0.75rem;
            color: var(--text-muted);
            font-style: italic;
        }

        /* Preset chips */
        .preset-chips-row {
            display: flex;
            gap: 0.3rem;
            margin-bottom: 0.3rem;
        }
        .preset-chip {
            flex: 1;
            padding: 0.32rem 0.2rem;
            background: var(--bg-tertiary);
            border: 1px solid transparent;
            color: var(--text-muted);
            border-radius: 6px;
            cursor: pointer;
            font-size: 0.67rem;
            font-family: inherit;
            letter-spacing: 0.02em;
            transition: all 0.15s ease;
            text-align: center;
        }
        .preset-chip:hover {
            color: var(--text-secondary);
            background: var(--bg-elevated);
        }
        .preset-chip.active {
            background: var(--accent);
            border-color: var(--accent);
            color: #fff;
        }
        .preset-chip.custom-active {
            border-color: var(--border-light);
            color: var(--text-secondary);
        }

        /* Advanced toggle */
        .advanced-toggle {
            display: flex;
            align-items: center;
            justify-content: flex-end;
            gap: 0.3rem;
            width: 100%;
            background: none;
            border: none;
            color: var(--text-muted);
            cursor: pointer;
            font-size: 0.64rem;
            font-family: inherit;
            padding: 0.15rem 0 0.3rem;
            opacity: 0.6;
            transition: opacity 0.15s;
            letter-spacing: 0.02em;
        }
        .advanced-toggle:hover {
            opacity: 1;
        }
        .advanced-chevron {
            transition: transform 0.2s ease;
            flex-shrink: 0;
        }
        .advanced-chevron.open {
            transform: rotate(180deg);
        }

        /* Advanced section */
        .advanced-section {
            border-top: none;
            padding-top: 0.4rem;
            margin-bottom: 0.2rem;
        }

        /* Context Meter */
        .context-meter {
            margin-top: 0.75rem;
            padding-top: 0.75rem;
            border-top: none;
        }

        .context-label {
            display: flex;
            justify-content: space-between;
            font-size: 0.65rem;
            color: var(--text-muted);
            margin-bottom: 0.3rem;
        }

        .context-bar {
            height: 4px;
            background: var(--border-light);
            border-radius: 2px;
            overflow: hidden;
        }

        .context-fill {
            height: 100%;
            width: 0%;
            background: linear-gradient(90deg, #4ade80 0%, #22c55e 50%, #4ade80 100%);
            background-size: 200% 100%;
            border-radius: 2px;
            transition: width 0.3s ease, background 0.3s ease;
            animation: contextFlow 3s ease-in-out infinite;
        }

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

        .context-fill.warning {
            background: linear-gradient(90deg, #fbbf24 0%, #f59e0b 50%, #fbbf24 100%);
            background-size: 200% 100%;
            animation: contextFlow 2s ease-in-out infinite, contextPulse 1s ease-in-out infinite;
        }

        .context-fill.danger {
            background: linear-gradient(90deg, #f87171 0%, #ef4444 50%, #f87171 100%);
            background-size: 200% 100%;
            animation: contextFlow 1.5s ease-in-out infinite, contextPulse 0.8s ease-in-out infinite;
        }

        @keyframes contextPulse {
            0%, 100% { box-shadow: 0 0 4px currentColor; }
            50% { box-shadow: 0 0 12px currentColor; }
        }

        .context-details {
            font-size: 0.6rem;
            color: var(--text-muted);
            margin-top: 0.25rem;
            opacity: 0.7;
        }

        /* Context Warning Banner */
        .context-warning {
            display: none;
            padding: 0.5rem 1rem;
            background: rgba(251, 191, 36, 0.1);
            border-left: 3px solid #fbbf24;
            margin-bottom: 0.5rem;
            border-radius: 0 4px 4px 0;
            align-items: center;
            gap: 0.5rem;
            font-size: 0.75rem;
            color: #fbbf24;
        }

        .context-warning.active {
            display: flex;
        }

        .context-warning.danger {
            background: rgba(248, 113, 113, 0.1);
            border-left-color: #f87171;
            color: #f87171;
        }

        .warning-icon {
            font-size: 0.9rem;
        }

        /* Main Chat Area */
        .main {
            flex: 1;
            display: flex;
            flex-direction: column;
            height: 100vh;
            height: 100dvh;
            min-height: 0;
            min-width: 0;
            overflow: hidden;
            background: var(--bg-primary);
            position: relative;
            z-index: 5;
        }

        .chat-header {
            padding: 1rem 1.75rem;
            border-bottom: 1px solid var(--border-subtle);
            display: flex;
            align-items: center;
            gap: 1rem;
            background: var(--bg-secondary);
            position: relative;
            z-index: 2;
            box-shadow: none;
            min-height: 64px;
            flex-shrink: 0;
        }

        /* Chat header decorations moved to arcane skin (quartet-skin-arcane.css) */

        .chat-header .sovereign-name {
            font-family: var(--font-display);
            font-size: 1.3rem;
            font-weight: 600;
            color: var(--text-primary);
            transition: color 0.4s cubic-bezier(0.4, 0, 0.2, 1);
            letter-spacing: 0.03em;
            animation: nameSettle 0.4s ease-out both;
            position: relative;
        }

        @keyframes nameSettle {
            0% { transform: translateY(-3px); opacity: 0; }
            100% { transform: translateY(0); opacity: 1; }
        }

        /* Hide subtitle in header - cleaner steampunk look */
        .chat-header .sovereign-title {
            display: none;
        }

        /* Header identity wrapper */
        .header-identity {
            display: flex;
            align-items: center;
            gap: 0.75rem;
        }

        /* Mood display in header */
        .mood-display {
            display: flex;
            align-items: center;
            gap: 0.25rem;
            font-size: 0.7rem;
            color: var(--text-muted);
            transition: all 0.3s ease;
        }

        .mood-display:empty {
            display: none;
        }

        .mood-display.mood-active {
            color: var(--text-secondary);
        }

        .mood-chip {
            display: flex;
            align-items: center;
            gap: 0.2rem;
            font-size: 0.75rem;
            transition: all 0.3s ease;
        }

        .mood-icon {
            font-size: 0.8rem;
            line-height: 1;
        }

        .mood-name {
            font-size: 0.65rem;
            font-weight: 500;
            opacity: 0.8;
        }

        .mood-separator {
            color: var(--text-muted);
            opacity: 0.5;
            font-size: 0.6rem;
        }

        /* Mood state colors */
        .mood-chip.warm .mood-icon { color: #f472b6; }
        .mood-chip.intense .mood-icon { color: #f97316; }
        .mood-chip.energized .mood-icon { color: #facc15; }
        .mood-chip.cool .mood-icon { color: #64748b; }
        .mood-chip.open .mood-icon { color: #60a5fa; }
        .mood-chip.quiet .mood-icon { color: #94a3b8; }
        .mood-chip.neutral .mood-icon { color: var(--text-muted); }

        /* Sovereign-specific mood chip colors */
        .mood-chip.lumen .mood-name { color: var(--accent); }
        .mood-chip.lilith .mood-name { color: var(--accent); }
        .mood-chip.luna .mood-name { color: var(--accent); }
        .mood-chip.lira .mood-name { color: var(--accent); }

        .chat-container {
            flex: 1;
            min-height: 0;
            min-width: 0;
            width: 100%;
            max-width: 100%;
            overflow-y: auto;
            overflow-x: hidden;
            padding: 2rem 2.5rem;
            padding-bottom: 1rem;
            display: flex;
            flex-direction: column;
            gap: 1.5rem;
            position: relative;
            z-index: 1;
        }

        .chat-container::-webkit-scrollbar {
            width: 8px;
        }
        .chat-container::-webkit-scrollbar-track {
            background: transparent;
        }
        .chat-container::-webkit-scrollbar-thumb {
            background: var(--border-medium);
            border-radius: var(--radius);
            transition: background 0.3s ease;
        }
        .chat-container::-webkit-scrollbar-thumb:hover {
            background: var(--border-light);
        }

        .message {
            max-width: 75%;
            min-width: 0;
            max-inline-size: min(75%, 100%);
            overflow-x: clip;
            padding: 1.1rem 1.35rem;
            border-radius: var(--radius);
            line-height: 1.75;
            animation: messageIn 0.25s cubic-bezier(0.25, 0.1, 0.25, 1) both;
            position: relative;
        }

        .message-content {
            max-width: 100%;
            overflow-wrap: anywhere;
            word-break: break-word;
            white-space: normal;
        }

        .message-content code {
            white-space: pre-wrap;
            overflow-wrap: anywhere;
            word-break: break-word;
        }

        .message-content strong,
        .message-content em,
        .message-content span {
            overflow-wrap: anywhere;
            word-break: break-word;
        }

        @keyframes messageIn {
            from { opacity: 0; transform: translateY(8px); }
            to { opacity: 1; transform: translateY(0); }
        }

        .message.user {
            background: var(--bg-tertiary);
            border: 1px solid var(--border-subtle);
            align-self: flex-end;
            color: var(--text-primary);
            box-shadow: var(--shadow-sm);
            position: relative; /* needed for companion-react-badge absolute positioning */
        }

        /* User message decorations moved to arcane skin (quartet-skin-arcane.css) */

        .message.assistant {
            background: transparent;
            border: none;
            align-self: flex-start;
            padding-left: 0;
            padding-right: 2rem;
        }

        .message .sov-name {
            font-family: var(--font-display);
            font-weight: 700;
            font-size: 1.1em;
            letter-spacing: 0.05em;
        }

        .message .sov-lumen { color: var(--accent); }
        .message .sov-lilith { color: var(--accent); }
        .message .sov-luna { color: var(--accent); }
        .message .sov-lira { color: var(--accent); }

        .message .speaker {
            font-family: var(--font-display);
            font-size: 0.7rem;
            letter-spacing: 0.02em;
            margin-bottom: 0.5rem;
            color: var(--text-muted);
            font-weight: 500;
        }

        .message.assistant pre {
            background: var(--bg-tertiary);
            padding: 1rem;
            border-radius: 8px;
            overflow-x: auto;
            max-width: 100%;
            white-space: pre-wrap;
            word-break: break-word;
            margin: 0.75rem 0;
            border: 1px solid var(--border-subtle);
        }

        .message.assistant code {
            font-family: 'JetBrains Mono', 'SF Mono', 'Fira Code', Monaco, monospace;
            font-size: 0.8rem;
        }

        /* Dialogue text is prominent, actions/descriptions are subdued */
        .message.assistant {
            color: var(--text-primary);
        }

        .message.assistant em {
            color: var(--text-muted);
            font-style: italic;
        }

        .typing-indicator {
            display: flex;
            align-items: center;
            gap: 6px;
            padding: 1.25rem 1.5rem;
            align-self: flex-start;
            position: relative;
        }

        .typing-indicator span:not(.typing-text) {
            width: 8px;
            height: 8px;
            background: var(--accent);
            opacity: 0.5;
            border-radius: 50%;
            animation: typingBounce 1.4s infinite ease-in-out;
        }

        .typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
        .typing-indicator span:nth-child(2) { animation-delay: -0.16s; }
        .typing-indicator span:nth-child(3) { animation-delay: 0s; }

        .typing-indicator .typing-text {
            margin-left: 0.5rem;
            font-family: var(--font-display);
            font-size: 0.85rem;
            font-style: italic;
            color: var(--text-muted);
            opacity: 0.8;
        }

        @keyframes typingBounce {
            0%, 80%, 100% {
                transform: scale(0.5);
                opacity: 0.3;
            }
            40% {
                transform: scale(1.2);
                opacity: 0.7;
            }
        }

        .thinking-indicator {
            display: flex;
            align-items: center;
            gap: 0.6rem;
            padding: 0.75rem 1rem;
            align-self: flex-start;
            background: var(--bg-tertiary);
            border: 1px solid var(--border-subtle);
            border-radius: 10px;
            color: var(--text-muted);
            font-family: var(--font-display);
            font-size: 0.85rem;
            font-style: italic;
        }

        .thinking-indicator .brain {
            animation: brainPulse 1.5s infinite ease-in-out;
        }

        @keyframes brainPulse {
            0%, 100% { opacity: 0.4; transform: scale(1); }
            50% { opacity: 1; transform: scale(1.1); }
        }

        /* Input Area */
        .input-container {
            padding: 1.25rem 2rem;
            border-top: 1px solid var(--border-subtle);
            background: var(--bg-secondary);
            position: relative;
            flex-shrink: 0;
            max-height: 42vh;
            overflow-y: auto;
            overscroll-behavior: contain;
        }

        /* Input container decorations moved to arcane skin (quartet-skin-arcane.css) */

        .input-wrapper {
            display: flex;
            gap: 0.75rem;
            align-items: flex-end;
            min-width: 0;
        }

        #messageInput {
            flex: 1;
            min-width: 0;
            background: var(--bg-tertiary);
            border: 1px solid var(--border-subtle);
            color: var(--text-primary);
            padding: 0.85rem 1.1rem;
            border-radius: var(--radius);
            font-size: 1rem;
            font-family: var(--font-body);
            resize: none;
            min-height: 48px;
            max-height: 140px;
            line-height: 1.5;
            transition: all 0.3s ease;
            box-shadow: none;
        }

        #messageInput:focus {
            outline: none;
            border-color: var(--accent);
        }

        /* Brighten energy conduit when input is focused */
        .input-container:has(#messageInput:focus)::before {
            opacity: 1;
            width: 55%;
            filter: brightness(1.3);
        }

        #messageInput::placeholder {
            color: var(--text-muted);
            font-style: italic;
        }

        #sendBtn {
            background: var(--accent);
            color: var(--bg-primary);
            border: none;
            padding: 0.85rem 1.5rem;
            min-height: 48px;
            align-self: flex-end;
            border-radius: var(--radius);
            cursor: pointer;
            font-family: var(--font-display);
            font-size: 0.85rem;
            font-weight: 700;
            letter-spacing: 0.02em;
            transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
            position: relative;
            overflow: hidden;
            box-shadow: var(--shadow-sm);
        }

        #sendBtn:hover {
            transform: translateY(-1px);
        }

        #sendBtn:active {
            transform: translateY(1px);
            box-shadow: var(--shadow-sm);
        }

        #sendBtn:disabled {
            background: var(--border-medium);
            color: var(--text-muted);
            cursor: not-allowed;
            transform: none;
            box-shadow: none;
            text-shadow: none;
        }

        #sendBtn:disabled::before {
            display: none;
        }

        #imageGenBtn {
            background: transparent;
            border: none;
            color: var(--text-muted);
            padding: 0.6rem;
            border-radius: 8px;
            cursor: pointer;
            transition: all 0.15s ease;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        #imageGenBtn:hover {
            background: var(--bg-tertiary);
            color: var(--text-secondary);
        }

        .message-generated-image {
            max-width: 100%;
            border-radius: var(--radius);
            margin-top: 0;
            border: 1px solid var(--accent);
            box-shadow: 0 0 12px var(--accent-glow);
            cursor: pointer;
            transition: box-shadow 0.2s ease;
            display: block;
        }

        /* Add top margin only when an image follows text content */
        .message-content + .message-generated-image {
            margin-top: 8px;
        }

        .message-generated-image:hover {
            box-shadow: 0 0 20px var(--accent-glow);
        }

        /* User-uploaded images in chat bubbles */
        .message-user-image {
            max-width: 320px;
            max-height: 320px;
            width: auto;
            height: auto;
            border-radius: 6px;
            margin-top: 6px;
            border: 1px solid rgba(255, 255, 255, 0.15);
            cursor: pointer;
            transition: box-shadow 0.2s ease;
            display: block;
            object-fit: contain;
        }

        .message-content + .message-user-image {
            margin-top: 8px;
        }

        .message-user-image:hover {
            box-shadow: 0 0 14px rgba(255, 255, 255, 0.18);
        }

        .image-generated-placeholder {
            margin-top: 8px;
            padding: 8px 12px;
            font-style: italic;
            opacity: 0.5;
            font-size: 0.85em;
        }

        .image-fullscreen-overlay {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.9);
            z-index: 10000;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
        }

        .image-fullscreen-overlay img {
            max-width: 90%;
            max-height: 90%;
            object-fit: contain;
        }

        .image-fullscreen-actions {
            position: absolute;
            top: 16px;
            right: 16px;
            display: flex;
            gap: 8px;
        }

        .image-fullscreen-btn,
        .image-fullscreen-download {
            background: rgba(255,255,255,0.15);
            border: 1px solid rgba(255,255,255,0.3);
            color: #fff;
            border-radius: var(--radius);
            padding: 8px;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: background 0.15s ease;
        }
        .image-fullscreen-btn:hover,
        .image-fullscreen-download:hover {
            background: rgba(255,255,255,0.25);
        }

        /* Fullscreen counter */
        .image-fullscreen-counter {
            position: absolute;
            top: 20px;
            left: 50%;
            transform: translateX(-50%);
            color: rgba(255,255,255,0.65);
            font-size: 13px;
            letter-spacing: 0.5px;
            pointer-events: none;
            user-select: none;
        }

        /* Fullscreen navigation arrows */
        .image-fullscreen-nav {
            position: absolute;
            top: 50%;
            transform: translateY(-50%);
            width: 44px;
            height: 44px;
            background: rgba(0,0,0,0.55);
            border: 1px solid rgba(255,255,255,0.2);
            border-radius: 50%;
            color: #fff;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            transition: background 0.15s ease;
            z-index: 10;
        }
        .image-fullscreen-nav:hover {
            background: rgba(0,0,0,0.78);
        }
        .image-fullscreen-prev { left: 16px; }
        .image-fullscreen-next { right: 16px; }

        /* Image Gallery modal */
        .gallery-modal-overlay {
            z-index: 1100;
        }
        .gallery-modal {
            max-width: 860px;
            width: 92vw;
            max-height: 88vh;
            display: flex;
            flex-direction: column;
            padding: 0;
            overflow: hidden;
        }
        .gallery-modal-header {
            flex-shrink: 0;
        }
        .gallery-modal-title {
            display: flex;
            align-items: center;
            gap: 10px;
        }
        .gallery-modal-title h3 {
            font-size: 1rem;
            font-weight: 600;
            color: var(--text-primary);
        }
        .gallery-count {
            font-size: 12px;
            font-weight: 400;
            color: var(--text-muted);
        }
        .gallery-modal-actions {
            display: flex;
            align-items: center;
            gap: 8px;
        }
        .gallery-download-all-btn {
            display: flex;
            align-items: center;
            gap: 6px;
        }
        .gallery-filter-row {
            display: flex;
            gap: 6px;
            padding: 10px 20px;
            overflow-x: auto;
            flex-shrink: 0;
            border-bottom: 1px solid var(--border-subtle, rgba(0,0,0,0.06));
        }
        .gallery-filter-chip {
            padding: 4px 12px;
            border-radius: 20px;
            border: 1px solid var(--border-subtle, rgba(0,0,0,0.12));
            background: transparent;
            color: var(--text-secondary);
            font-size: 13px;
            cursor: pointer;
            white-space: nowrap;
            transition: background 0.15s ease, color 0.15s ease;
        }
        .gallery-filter-chip.active,
        .gallery-filter-chip:hover {
            background: var(--accent, #605C58);
            color: #fff;
            border-color: transparent;
        }
        .gallery-grid {
            flex: 1;
            overflow-y: auto;
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
            gap: 6px;
            padding: 12px 20px 20px;
        }
        .gallery-tile {
            aspect-ratio: 1;
            border-radius: 6px;
            overflow: hidden;
            cursor: pointer;
            background: var(--bg-tertiary, #f2f2f1);
            transition: opacity 0.15s ease;
        }
        .gallery-tile:hover { opacity: 0.85; }
        .gallery-tile img {
            width: 100%;
            height: 100%;
            object-fit: cover;
            display: block;
        }
        .gallery-empty {
            grid-column: 1/-1;
            text-align: center;
            padding: 40px 20px;
            color: var(--text-muted);
            font-size: 14px;
        }
        .gallery-empty-icon { font-size: 36px; margin-bottom: 8px; }
        .gallery-empty-sub { font-size: 12px; margin-top: 4px; opacity: 0.7; }

        /* Inline image action buttons (copy + download) on generated images */
        .generated-image-wrapper {
            position: relative;
            display: inline-block;
            max-width: 100%;
        }
        .generated-image-wrapper .message-generated-image {
            display: block;
        }
        .image-inline-actions {
            position: absolute;
            top: 8px;
            right: 8px;
            display: flex;
            gap: 4px;
            opacity: 0;
            transition: opacity 0.2s ease;
        }
        .generated-image-wrapper:hover .image-inline-actions {
            opacity: 1;
        }
        .image-inline-btn {
            background: rgba(0,0,0,0.55);
            border: 1px solid rgba(255,255,255,0.25);
            color: #fff;
            border-radius: 4px;
            padding: 5px;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: background 0.15s ease;
        }
        .image-inline-btn:hover {
            background: rgba(0,0,0,0.75);
        }

        .moment-btn.saved {
            color: var(--accent);
            opacity: 1;
        }

        .moments-gallery {
            margin-top: 12px;
            max-height: 400px;
            overflow-y: auto;
        }

        .moment-card {
            background: var(--bg-secondary);
            border: 1px solid var(--border-subtle);
            border-left: 3px solid var(--accent);
            border-radius: var(--radius);
            padding: 12px;
            margin-bottom: 10px;
        }

        .moment-card-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 6px;
        }

        .moment-sovereign {
            font-family: var(--font-body);
            font-size: 13px;
            font-weight: 600;
            color: var(--accent);
        }

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

        .moment-content {
            font-size: 14px;
            line-height: 1.5;
            color: var(--text-primary);
            white-space: pre-wrap;
            margin-bottom: 8px;
        }

        .moment-images {
            display: flex;
            gap: 8px;
            margin-bottom: 8px;
        }

        .moment-thumb {
            width: 60px;
            height: 60px;
            object-fit: cover;
            border-radius: var(--radius);
            cursor: pointer;
        }

        .moment-actions {
            display: flex;
            gap: 8px;
        }

        .moment-actions .modal-btn {
            font-size: 12px;
            padding: 4px 10px;
        }

        #micBtn {
            background: transparent;
            color: var(--text-muted);
            border: none;
            padding: 0.6rem;
            border-radius: 8px;
            cursor: pointer;
            font-size: 1rem;
            line-height: 1;
            transition: all 0.15s ease;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        #micBtn:hover {
            background: var(--bg-tertiary);
            color: var(--text-secondary);
        }

        #micBtn.recording {
            background: linear-gradient(180deg, #e05050 0%, #a02020 100%);
            color: #fff;
            border-color: #e05050;
            animation: pulse-mic 1.5s ease-in-out infinite;
            box-shadow: 
                0 3px 0 #801010,
                0 0 15px rgba(224, 80, 80, 0.5),
                inset 0 1px 0 rgba(255, 255, 255, 0.2);
        }

        @keyframes pulse-mic {
            0%, 100% { transform: scale(1); }
            50% { transform: scale(1.05); }
        }

        #stopBtn {
            background: #e05050;
            color: #fff;
            border: none;
            padding: 0.75rem 1.25rem;
            border-radius: 6px;
            cursor: pointer;
            font-size: 0.8rem;
            font-weight: 500;
            transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
            animation: stopPulse 1.5s ease-in-out infinite;
        }

        #stopBtn:hover {
            background: #c44536;
            transform: translateY(-1px);
        }

        @keyframes stopPulse {
            0%, 100% { box-shadow: 0 0 0 0 rgba(224, 80, 80, 0.4); }
            50% { box-shadow: 0 0 0 8px rgba(224, 80, 80, 0); }
        }

        /* ── Streaming: smooth text flow ──
           During streaming the .typing class is present. We hint the GPU,
           contain layout so new text doesn’t reflow the entire page, and
           use a soft blinking cursor instead of a hard on/off blink. */
        .message.assistant .message-content.typing {
            position: relative;
            contain: content;            /* isolate layout recalcs to this element */
            will-change: contents;       /* hint the compositor */
        }

        .message.assistant .message-content.typing::after {
            content: '\25CF';            /* ● small filled circle — softer than block cursor */
            display: inline-block;
            animation: cursorPulse 1s ease-in-out infinite;
            color: var(--accent);
            margin-left: 3px;
            font-size: 0.55em;
            vertical-align: middle;
            opacity: 0.85;
        }

        /* Gentle pulse instead of harsh blink — feels more alive */
        @keyframes cursorPulse {
            0%, 100% { opacity: 0.85; transform: scale(1); }
            50%      { opacity: 0.25; transform: scale(0.85); }
        }

        /* Cursor fade-out: runs for one frame before the final content swap.
           The ::after element dissolves instead of popping off. */
        @keyframes cursorFadeOut {
            from { opacity: 0.85; transform: scale(1); }
            to   { opacity: 0;    transform: scale(0.7); }
        }

        .message.assistant .message-content.typing-finishing::after {
            animation: cursorFadeOut 0.08s ease-out forwards;
        }

        /* Reveal animation: content settles in cleanly when stream finalizes */
        @keyframes messageReveal {
            from { opacity: 0.8; }
            to   { opacity: 1;   }
        }

        .message.assistant .message-content.message-reveal {
            animation: messageReveal 0.15s ease-out forwards;
        }

        /* Invocation text - atmospheric summoning display */
        .invocation {
            text-align: center;
            padding: 4rem 3rem;
            color: var(--text-secondary);
            font-size: 1rem;
            line-height: 2;
            position: relative;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            min-height: 400px;
            animation: invocationFadeIn 1.2s ease-out;
        }

        @keyframes invocationFadeIn {
            from { opacity: 0; transform: scale(0.95); }
            to { opacity: 1; transform: scale(1); }
        }

        /* Arcane magic circle background - multi-layered transmutation circle */
        .invocation::before {
            content: '';
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            width: 400px;
            height: 400px;
            background:
                /* Inner mystical glow */
                radial-gradient(circle, var(--accent-glow) 0%, transparent 35%),
                /* First circle */
                radial-gradient(circle, transparent 28%, var(--accent-subtle) 29%, transparent 30.5%),
                /* Second circle */
                radial-gradient(circle, transparent 38%, var(--accent-subtle) 39.5%, transparent 41%),
                /* Third circle - outer */
                radial-gradient(circle, transparent 47%, rgba(139, 105, 20, 0.12) 48%, transparent 49.5%),
                /* Outermost ring */
                radial-gradient(circle, transparent 63%, rgba(139, 105, 20, 0.08) 64.5%, transparent 66%);
            border: 2px solid rgba(139, 105, 20, 0.12);
            border-radius: 50%;
            pointer-events: none;
            opacity: 0.45;
            animation: circleRotate 90s linear infinite;
        }

        /* Second counter-rotating circle layer */
        .invocation::after {
            content: '';
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            width: 340px;
            height: 340px;
            background:
                repeating-conic-gradient(
                    from 0deg,
                    transparent 0deg 28deg,
                    rgba(139, 105, 20, 0.06) 28deg 32deg,
                    transparent 32deg 60deg
                );
            border: 1px solid rgba(139, 105, 20, 0.08);
            border-radius: 50%;
            pointer-events: none;
            opacity: 0.5;
            animation: circleRotate 60s linear infinite reverse;
            z-index: 0;
        }

        @keyframes circleRotate {
            from { transform: translate(-50%, -50%) rotate(0deg); }
            to { transform: translate(-50%, -50%) rotate(360deg); }
        }

        /* ============================================
           STEAMPUNK ARCANE APPARATUS
           ============================================ */

        .arcane-apparatus {
            position: relative;
            width: 280px;
            height: 280px;
            margin-bottom: 2rem;
        }

        /* Outer rotating ring with runes/notches */
        .arcane-apparatus .outer-ring {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            border: 3px solid var(--accent);
            border-radius: 50%;
            background: repeating-conic-gradient(
                from 0deg,
                transparent 0deg 8deg,
                var(--accent-subtle) 8deg 10deg,
                transparent 10deg 18deg
            );
            animation: outerRingRotate 60s linear infinite;
            box-shadow: 
                inset 0 0 30px rgba(0, 0, 0, 0.6),
                0 0 20px var(--accent-subtle),
                inset 0 0 60px var(--accent-subtle);
        }

        .arcane-apparatus .outer-ring::before {
            content: '';
            position: absolute;
            top: 8px;
            left: 8px;
            right: 8px;
            bottom: 8px;
            border: 1px solid var(--border-subtle);
            border-radius: 50%;
        }

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

        /* Middle ring - counter rotation */
        .arcane-apparatus .middle-ring {
            position: absolute;
            top: 30px;
            left: 30px;
            width: calc(100% - 60px);
            height: calc(100% - 60px);
            border: 2px solid var(--border-subtle);
            border-radius: 50%;
            background: repeating-conic-gradient(
                from 15deg,
                transparent 0deg 12deg,
                var(--accent-subtle) 12deg 15deg,
                transparent 15deg 27deg
            );
            animation: middleRingRotate 45s linear infinite reverse;
            box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.5);
        }

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

        /* Inner ring - slow rotation */
        .arcane-apparatus .inner-ring {
            position: absolute;
            top: 60px;
            left: 60px;
            width: calc(100% - 120px);
            height: calc(100% - 120px);
            border: 2px solid var(--accent);
            border-radius: 50%;
            animation: innerRingRotate 30s linear infinite, innerGlow 4s ease-in-out infinite;
            box-shadow: 
                0 0 15px var(--accent-glow),
                0 0 30px var(--accent-glow),
                inset 0 0 15px var(--accent-subtle);
        }

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

        @keyframes innerGlow {
            0%, 100% { box-shadow: 0 0 15px var(--accent-glow), 0 0 30px var(--accent-glow), inset 0 0 15px var(--accent-subtle); }
            50% { box-shadow: 0 0 25px var(--accent-glow), 0 0 50px var(--accent-glow), inset 0 0 25px var(--accent-subtle); }
        }

        /* Decorative gears */
        .arcane-apparatus .gear {
            position: absolute;
            border-radius: 50%;
            background: radial-gradient(circle at 40% 40%, var(--border-light) 0%, var(--border-subtle) 40%, var(--bg-tertiary) 100%);
            box-shadow:
                inset 0 2px 4px rgba(255, 255, 255, 0.1),
                inset 0 -2px 4px rgba(0, 0, 0, 0.4),
                0 2px 8px rgba(0, 0, 0, 0.5);
        }

        .arcane-apparatus .gear::before {
            content: '';
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            width: 40%;
            height: 40%;
            background: radial-gradient(circle, var(--bg-primary) 0%, var(--bg-secondary) 100%);
            border-radius: 50%;
            box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.6);
        }

        /* Gear teeth using box-shadow technique */
        .arcane-apparatus .gear::after {
            content: '';
            position: absolute;
            top: -4px;
            left: 50%;
            transform: translateX(-50%);
            width: 6px;
            height: 8px;
            background: var(--border-medium);
            box-shadow:
                0 calc(100% + 0px) 0 0 var(--border-medium),
                calc(-50% - 2px) calc(50% - 4px) 0 0 var(--border-medium),
                calc(50% + 2px) calc(50% - 4px) 0 0 var(--border-medium);
            border-radius: 2px;
        }

        .arcane-apparatus .gear-1 {
            width: 36px;
            height: 36px;
            top: 15px;
            right: 40px;
            animation: gearSpin 8s linear infinite;
        }

        .arcane-apparatus .gear-2 {
            width: 28px;
            height: 28px;
            bottom: 25px;
            left: 35px;
            animation: gearSpin 6s linear infinite reverse;
        }

        .arcane-apparatus .gear-3 {
            width: 24px;
            height: 24px;
            bottom: 40px;
            right: 30px;
            animation: gearSpin 5s linear infinite;
        }

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

        /* Central arcane core - glowing crystal/orb */
        .arcane-apparatus .arcane-core {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            width: 60px;
            height: 60px;
            background: radial-gradient(circle at 35% 35%, 
                rgba(255, 255, 255, 0.9) 0%,
                var(--accent) 30%,
                var(--accent) 60%,
                rgba(0, 0, 0, 0.3) 100%);
            border-radius: 50%;
            box-shadow: 
                0 0 30px var(--accent-glow),
                0 0 60px var(--accent-glow),
                0 0 100px var(--accent-glow),
                inset 0 -10px 20px rgba(0, 0, 0, 0.3),
                inset 0 5px 10px rgba(255, 255, 255, 0.4);
            animation: corePulse 3s ease-in-out infinite;
        }

        @keyframes corePulse {
            0%, 100% { 
                transform: translate(-50%, -50%) scale(1);
                box-shadow: 
                    0 0 30px var(--accent-glow),
                    0 0 60px var(--accent-glow),
                    0 0 100px var(--accent-glow),
                    inset 0 -10px 20px rgba(0, 0, 0, 0.3),
                    inset 0 5px 10px rgba(255, 255, 255, 0.4);
            }
            50% { 
                transform: translate(-50%, -50%) scale(1.08);
                box-shadow: 
                    0 0 40px var(--accent-glow),
                    0 0 80px var(--accent-glow),
                    0 0 140px var(--accent-glow),
                    inset 0 -10px 20px rgba(0, 0, 0, 0.3),
                    inset 0 5px 10px rgba(255, 255, 255, 0.4);
            }
        }

        /* Sovereign name display - large and dramatic with arcane energy */
        .invocation .sovereign-title-display {
            font-family: var(--font-display);
            font-size: 2.5rem;
            font-weight: 700;
            color: var(--accent);
            letter-spacing: 0.04em;
            text-shadow:
                0 3px 0 rgba(0, 0, 0, 0.8),
                0 -1px 0 rgba(255, 255, 255, 0.15),
                0 0 40px var(--accent-glow),
                0 0 80px var(--accent-glow);
            position: relative;
            z-index: 2;
            margin-bottom: 1.5rem;
            animation: titleFloat 6s ease-in-out infinite;
        }

        @keyframes titleFloat {
            0%, 100% { transform: translateY(0); }
            50% { transform: translateY(-8px); }
        }

        /* Invocation quote text */
        .invocation .invocation-text {
            font-family: var(--font-body);
            font-size: 1.1rem;
            color: var(--text-secondary);
            max-width: 500px;
            position: relative;
            z-index: 2;
            line-height: 1.9;
            text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
            text-align: center;
        }

        .invocation .invocation-text em {
            display: block;
            margin-top: 1rem;
            color: var(--text-muted);
            font-style: italic;
            opacity: 0.8;
        }

        /* Hide old elements */
        .invocation .sigil,
        .invocation .summon-phrase,
        .invocation .essence-text {
            display: none;
        }

        /* Range slider styling */
        .settings-row input[type="range"] {
            flex: 1;
            -webkit-appearance: none;
            appearance: none;
            background: var(--bg-tertiary);
            border-radius: 3px;
            height: 4px;
            border: none;
        }

        .settings-row input[type="range"]::-webkit-slider-thumb {
            -webkit-appearance: none;
            appearance: none;
            width: 12px;
            height: 12px;
            background: var(--text-secondary);
            border-radius: 50%;
            cursor: pointer;
            transition: background 0.15s ease;
        }

        .settings-row input[type="range"]::-webkit-slider-thumb:hover {
            background: var(--text-primary);
        }

        .settings-row span {
            min-width: 28px;
            text-align: right;
            font-size: 0.7rem;
            color: var(--text-muted);
        }

        /* File Upload & Input Enhancements */
        .input-actions {
            display: flex;
            align-items: center;
            gap: 0.5rem;
            margin-bottom: 0.5rem;
        }

        .input-action-btn {
            background: transparent;
            border: none;
            color: var(--text-muted);
            padding: 0.35rem 0.55rem;
            border-radius: 6px;
            cursor: pointer;
            font-size: 0.7rem;
            transition: all 0.15s ease;
            display: flex;
            align-items: center;
            gap: 0.3rem;
        }

        .input-action-btn:hover {
            background: var(--bg-tertiary);
            color: var(--text-secondary);
        }

        .input-action-btn svg {
            width: 14px;
            height: 14px;
        }

        .file-attachment {
            display: none;
            padding: 0.5rem 0.75rem;
            background: var(--bg-tertiary);
            border: 1px solid var(--border-subtle);
            border-radius: var(--radius);
            margin-bottom: 0.5rem;
            font-size: 0.75rem;
            color: var(--text-secondary);
            align-items: center;
            gap: 0.5rem;
            flex-wrap: wrap;
        }

        .file-attachment.active {
            display: flex;
        }

        .attachment-chip {
            display: flex;
            align-items: center;
            gap: 0.4rem;
            padding: 0.25rem 0.5rem;
            background: var(--bg-secondary);
            border: 1px solid var(--border-subtle);
            border-radius: var(--radius);
            max-width: 200px;
        }

        .attachment-chip .attachment-thumb {
            width: 28px;
            height: 28px;
            object-fit: cover;
            border-radius: 3px;
            flex-shrink: 0;
        }

        .attachment-chip-name {
            flex: 1;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            font-size: 0.7rem;
        }

        .attachment-count {
            font-size: 0.65rem;
            color: var(--text-muted);
            padding: 0.25rem 0.4rem;
        }

        .file-attachment .file-name {
            flex: 1;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        .file-attachment .file-size {
            color: var(--text-muted);
            font-size: 0.65rem;
        }

        .file-attachment .remove-file {
            background: transparent;
            border: none;
            color: var(--text-muted);
            cursor: pointer;
            padding: 0.2rem;
            font-size: 1rem;
            line-height: 1;
        }

        .file-attachment .remove-file:hover {
            color: var(--accent);
        }

        /* Expanded Input Modal - Industrial Panel */
        .modal-overlay {
            display: flex;
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background:
                radial-gradient(ellipse at center, rgba(0, 0, 0, 0.8) 0%, rgba(0, 0, 0, 0.92) 100%);
            backdrop-filter: blur(6px);
            z-index: 1020;
            align-items: center;
            justify-content: center;
            visibility: hidden;
            opacity: 0;
            transition: opacity 0.25s ease, visibility 0.25s ease;
        }

        .modal-overlay.active {
            visibility: visible;
            opacity: 1;
        }

        .modal-content {
            background: var(--bg-secondary);
            border: 1px solid var(--border-subtle);
            border-radius: var(--radius);
            width: 90%;
            max-width: 480px;
            max-height: 85vh;
            display: flex;
            flex-direction: column;
            box-shadow: var(--shadow-lg), 0 0 40px var(--accent-subtle);
            position: relative;
            transform: scale(0.95) translateY(10px);
            transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.25s ease;
            opacity: 0;
        }

        .modal-overlay.active .modal-content {
            transform: scale(1) translateY(0);
            opacity: 1;
        }

        /* Wider modal variant — for content-heavy panels (session summary, etc.) */
        .modal-content-wide {
            max-width: 560px;
        }

        /* Modal decorations moved to arcane skin (quartet-skin-arcane.css) */

        .modal-header {
            padding: 1rem 1.5rem;
            border-bottom: 1px solid var(--border-subtle);
            display: flex;
            align-items: center;
            justify-content: space-between;
            background: transparent;
        }

        .modal-header h3 {
            font-family: var(--font-display);
            font-size: 1rem;
            font-weight: 600;
            color: var(--text-primary);
            letter-spacing: 0.02em;
            text-shadow: none;
        }

        .modal-close {
            background: transparent;
            border: none;
            outline: none;
            -webkit-appearance: none;
            appearance: none;
            box-shadow: none;
            color: var(--text-secondary);
            cursor: pointer;
            font-size: 1.15rem;
            padding: 4px 8px;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 0;
            transition: color 0.2s ease;
            line-height: 1;
        }

        .modal-close:hover,
        .modal-close:focus,
        .modal-close:focus-visible {
            background: transparent;
            outline: none;
            box-shadow: none;
            color: var(--text-primary);
        }

        .modal-body {
            padding: 1.25rem 1.5rem;
            flex: 1;
            overflow-y: auto;
            overflow-x: hidden;
            display: flex;
            flex-direction: column;
            overflow-wrap: break-word;
            word-break: break-word;
        }

        .modal-body textarea {
            flex: 1;
            background: var(--bg-tertiary);
            border: 1px solid var(--border-subtle);
            color: var(--text-primary);
            padding: 1rem;
            border-radius: var(--radius);
            font-size: 1rem;
            font-family: var(--font-body);
            resize: none;
            min-height: 300px;
            line-height: 1.7;
            box-shadow: var(--shadow-inset);
        }

        .modal-body textarea:focus {
            outline: none;
            border-color: var(--accent);
            box-shadow: var(--shadow-inset), 0 0 10px var(--accent-subtle);
        }

        .modal-body textarea::placeholder {
            color: var(--text-muted);
            font-style: italic;
        }

        .modal-footer {
            padding: 1rem 1.5rem;
            border-top: 1px solid var(--border-subtle);
            display: flex;
            justify-content: flex-end;
            gap: 0.75rem;
            background: transparent;
        }

        .modal-btn {
            padding: 0.5rem 1rem;
            border-radius: var(--radius);
            font-family: var(--font-display);
            font-size: 0.72rem;
            font-weight: 600;
            letter-spacing: 0.02em;
            cursor: pointer;
            transition: all 0.15s ease;
        }

        .modal-btn-secondary {
            background: transparent;
            border: 1px solid var(--border-light);
            color: var(--text-secondary);
        }

        .modal-btn-secondary:hover {
            border-color: var(--accent);
            color: var(--text-primary);
            background: var(--bg-tertiary);
        }

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

        .modal-btn-primary {
            background: var(--accent);
            border: none;
            color: var(--bg-primary);
            box-shadow: var(--shadow-sm);
        }

        .modal-btn-primary:hover {
            filter: brightness(1.1);
            box-shadow: 0 0 15px var(--accent-glow), var(--shadow-md);
        }

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

        /* Export/Import buttons in header - Brass industrial */
        .header-actions {
            display: flex;
            align-items: center;
            gap: 0.5rem;
            margin-left: auto;
        }

        .header-btn {
            background: transparent;
            border: 1px solid transparent;
            color: var(--text-muted);
            padding: 0 0.55rem;
            height: 28px;
            border-radius: 6px;
            cursor: pointer;
            font-family: var(--font-body);
            font-size: 0.72rem;
            font-weight: 500;
            letter-spacing: 0.01em;
            transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            gap: 4px;
            white-space: nowrap;
        }

        .header-btn:hover {
            color: var(--text-primary);
            background: var(--bg-tertiary);
        }

        .header-btn:active {
            opacity: 0.8;
        }

        /* Interaction mode toggle in chat header */
        .chat-header-meta {
            display: flex;
            align-items: center;
            gap: 0.5rem;
            padding: 0 1.25rem;
            min-height: 28px;
        }

        .chat-mode-toggle {
            display: flex;
            gap: 3px;
            background: var(--bg-secondary);
            border: 1px solid var(--border-light);
            border-radius: var(--radius);
            padding: 3px;
        }

        .chat-mode-btn {
            background: transparent;
            border: none;
            color: var(--text-muted);
            padding: 2px 10px;
            border-radius: calc(var(--radius) - 2px);
            cursor: pointer;
            font-family: var(--font-display);
            font-size: 0.6rem;
            font-weight: 600;
            letter-spacing: 0.02em;
            transition: all 0.15s;
        }

        .chat-mode-btn:hover {
            color: var(--text-primary);
            background: var(--bg-tertiary);
        }

        .chat-mode-btn.active {
            background: var(--accent);
            color: #fff;
        }

        #musicGenerateBtn.generating {
            animation: music-pulse 1.2s ease-in-out infinite;
            color: var(--accent-glow);
            border-color: var(--accent-glow);
        }

        #musicGenerateBtn.playing {
            color: var(--accent);
            border-color: var(--accent);
            box-shadow: 0 0 12px var(--accent-glow);
        }

        @keyframes music-pulse {
            0%, 100% { opacity: 0.6; }
            50% { opacity: 1; }
        }

        /* Session indicator */
        .session-indicator {
            font-size: 0.65rem;
            color: var(--text-muted);
            padding: 0.2rem 0.5rem;
            background: var(--bg-tertiary);
            border-radius: 3px;
        }

        /* Character count in modal */
        .char-count {
            font-size: 0.7rem;
            color: var(--text-muted);
            text-align: right;
            margin-top: 0.5rem;
        }

        .char-count.warning {
            color: #fbbf24;
        }

        .char-count.danger {
            color: #f87171;
        }

        /* Settings Button */
        .settings-btn {
            width: 100%;
            margin-top: 0.75rem;
            padding: 0.5rem 0.75rem;
            background: transparent;
            border: 1px solid transparent;
            color: var(--text-muted);
            border-radius: var(--radius);
            cursor: pointer;
            font-size: 0.7rem;
            font-family: inherit;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 0.4rem;
            transition: all 0.15s ease;
        }

        .settings-btn:hover {
            background: var(--bg-tertiary);
            color: var(--text-secondary);
        }

        /* Settings Modal */
        .settings-modal {
            height: 80vh;
            max-height: 80vh;
        }

        .settings-modal .modal-header {
            border-bottom: none;
            padding-bottom: 0;
            flex-shrink: 0;
        }

        .settings-tabs {
            display: flex;
            border-bottom: 1px solid var(--border-subtle);
            padding: 0 20px;
            background: var(--bg-tertiary);
            flex-shrink: 0;
        }

        .settings-tab {
            flex: 1;
            padding: 10px 6px;
            background: none;
            border: none;
            color: var(--text-muted);
            font-size: 0.7rem;
            cursor: pointer;
            transition: color 0.2s ease, border-color 0.2s ease;
            border-bottom: 2px solid transparent;
            margin-bottom: -1px;
            white-space: nowrap;
        }

        .settings-tab:hover {
            color: var(--text-secondary);
        }

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

        .settings-tab-content {
            display: none;
        }

        .settings-tab-content.active {
            display: block;
            animation: settingsTabFadeIn 0.15s ease-out;
        }

        @keyframes settingsTabFadeIn {
            from { opacity: 0; transform: translateY(4px); }
            to { opacity: 1; transform: translateY(0); }
        }

        /* Privacy Tab */
        .privacy-grid {
            display: flex;
            flex-direction: column;
            gap: 8px;
        }

        .privacy-item {
            display: flex;
            align-items: flex-start;
            gap: 10px;
            padding: 8px 12px;
            border-radius: 6px;
            border: 1px solid var(--border-subtle);
            background: var(--bg-tertiary);
            transition: background 0.2s ease, border-color 0.2s ease;
        }

        .privacy-item:hover {
            background: var(--bg-elevated);
            border-color: var(--border-light);
        }

        .privacy-icon {
            font-size: 0.85rem;
            flex-shrink: 0;
            width: 20px;
            text-align: center;
            line-height: 1.8;
            color: var(--accent);
            opacity: 0.7;
        }

        .privacy-item strong {
            color: var(--text-primary);
            font-size: 0.72rem;
        }

        .privacy-item p {
            color: var(--text-muted);
            font-size: 0.68rem;
            margin: 2px 0 0;
            line-height: 1.45;
        }

        .privacy-item code {
            background: var(--bg-primary);
            padding: 1px 4px;
            border-radius: var(--radius);
            font-size: 0.65rem;
            color: var(--text-secondary);
        }

        .privacy-local {
            border-left: 2px solid var(--accent);
        }

        .privacy-sent {
            border-left: 2px solid var(--accent);
        }

        .privacy-key {
            border-left: 2px solid var(--accent);
        }

        .privacy-never {
            border-left: 2px solid var(--accent);
        }

        .privacy-never .privacy-icon {
            color: var(--text-muted);
        }

        .settings-modal .modal-body {
            overflow-y: auto;
            padding-bottom: 1rem;
            flex: 1;
            min-height: 0;
        }

        /* Custom scrollbar for settings modal */
        .settings-modal .modal-body::-webkit-scrollbar,
        .wizard-body::-webkit-scrollbar {
            width: 6px;
        }

        .settings-modal .modal-body::-webkit-scrollbar-track,
        .wizard-body::-webkit-scrollbar-track {
            background: linear-gradient(90deg, rgba(0,0,0,0.15) 0%, rgba(139, 105, 20, 0.04) 50%, rgba(0,0,0,0.15) 100%);
            border-radius: 3px;
        }

        .settings-modal .modal-body::-webkit-scrollbar-thumb,
        .wizard-body::-webkit-scrollbar-thumb {
            background: var(--border-medium);
            border-radius: var(--radius);
        }

        .settings-modal .modal-body::-webkit-scrollbar-thumb:hover,
        .wizard-body::-webkit-scrollbar-thumb:hover {
            background: var(--border-light);
        }

        /* Seed Popup (in-conversation) */
        .seed-popup {
            position: fixed;
            top: 70px;
            right: 20px;
            width: 280px;
            background: var(--bg-elevated);
            border: 1px solid var(--border-subtle);
            border-radius: var(--radius);
            box-shadow: var(--shadow-lg);
            z-index: 1010;
            opacity: 0;
            visibility: hidden;
            transform: translateY(-10px);
            transition: all 0.2s ease;
            overflow: hidden;
        }

        .seed-popup.active {
            opacity: 1;
            visibility: visible;
            transform: translateY(0);
        }

        .seed-popup-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 14px 16px;
            border-bottom: 1px solid var(--border-subtle);
        }

        .seed-popup-title {
            font-weight: 600;
            color: var(--text-primary);
            font-size: 0.95rem;
        }

        .seed-popup-close {
            background: none;
            border: none;
            color: var(--text-muted);
            font-size: 1.2rem;
            cursor: pointer;
            padding: 0;
            line-height: 1;
        }

        .seed-popup-close:hover {
            color: var(--text-secondary);
        }

        .seed-popup-body {
            padding: 16px;
            overflow: hidden;
        }

        .seed-popup-qr {
            display: flex;
            justify-content: center;
            padding: 12px;
            background: white;
            border-radius: var(--radius);
            margin-bottom: 12px;
        }

        .seed-popup-qr canvas {
            display: block;
        }

        .qr-error {
            color: var(--text-muted);
            font-size: 0.8rem;
            padding: 20px;
        }

        .seed-popup-info {
            text-align: center;
            margin-bottom: 8px;
        }

        .seed-popup-mood {
            font-size: 0.8rem;
            color: var(--text-muted);
            font-style: italic;
        }

        .seed-popup-echoes {
            margin-bottom: 14px;
        }

        .echo-item {
            font-size: 0.8rem;
            color: var(--text-secondary);
            padding: 6px 10px;
            background: var(--bg-tertiary);
            border-radius: var(--radius);
            margin-bottom: 6px;
            font-style: italic;
            line-height: 1.4;
        }

        .echo-item.keywords {
            display: flex !important;
            flex-wrap: wrap !important;
            align-items: center;
            gap: 4px;
            font-style: normal;
            font-size: 12px;
            color: var(--text-muted);
            overflow: hidden;
        }

        .keywords-label {
            margin-right: 2px;
        }

        .keyword-tag {
            background: var(--bg-primary);
            padding: 2px 6px;
            border-radius: var(--radius);
            white-space: nowrap;
            max-width: 110px;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .echo-item.empty {
            text-align: center;
            color: var(--text-muted);
            font-style: normal;
        }

        .seed-popup-actions {
            display: flex;
            gap: 8px;
        }

        .seed-popup-btn {
            flex: 1;
            padding: 10px 12px;
            border-radius: var(--radius);
            border: 1px solid var(--border-light);
            background: var(--bg-tertiary);
            color: var(--text-secondary);
            font-size: 0.85rem;
            cursor: pointer;
            transition: all 0.15s ease;
        }

        .seed-popup-btn:hover {
            background: var(--surface-medium);
            border-color: var(--border-medium);
        }

        .seed-popup-btn.primary {
            background: var(--accent);
            border-color: var(--accent);
            color: white;
        }

        .seed-popup-btn.primary:hover {
            filter: brightness(1.1);
        }

        /* Seed mode toggle (Quick vs Smart) */
        .seed-mode-btn {
            padding: 6px 12px;
            border-radius: 6px;
            border: 1px solid var(--border-light);
            background: var(--bg-tertiary);
            color: var(--text-secondary);
            font-size: 13px;
            cursor: pointer;
            transition: all 0.2s ease;
        }

        .seed-mode-btn:hover {
            background: var(--surface-medium);
            border-color: var(--border-medium);
        }

        .seed-mode-btn.active {
            background: var(--accent);
            border-color: var(--accent);
            color: white;
        }

        .loading-spinner {
            display: inline-block;
            width: 16px;
            height: 16px;
            border: 2px solid var(--border-medium);
            border-top-color: var(--accent);
            border-right-color: var(--accent);
            border-radius: 50%;
            animation: gearSpin 0.8s linear infinite;
        }

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

        .seed-btn {
            /* inherits .header-btn styles — no accent override */
        }

        .share-companion-btn {
            color: var(--accent) !important;
        }

        /* Memory Portal Modal */
        .memory-portal-modal {
        }

        .memory-portal-modal .modal-body {
            overflow-y: auto;
            padding: 0;
        }

        .memory-portal-tabs {
            display: flex;
            border-bottom: 1px solid var(--border-subtle);
            background: var(--bg-tertiary);
        }

        .portal-tab {
            flex: 1;
            padding: 12px 16px;
            background: none;
            border: none;
            color: var(--text-muted);
            font-size: 0.85rem;
            cursor: pointer;
            transition: all 0.2s ease;
            border-bottom: 2px solid transparent;
        }

        .portal-tab:hover {
            color: var(--text-secondary);
            background: var(--bg-secondary);
        }

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

        .portal-tab-content {
            display: none;
            padding: 20px;
        }

        .portal-tab-content.active {
            display: block;
        }

        .portal-description {
            color: var(--text-muted);
            font-size: 0.85rem;
            margin-bottom: 16px;
            text-align: center;
        }

        .generate-seed-btn {
            width: 100%;
            padding: 14px 20px;
            font-size: 1rem;
        }

        .generate-seed-btn .btn-icon {
            margin-right: 8px;
        }

        .seed-preview {
            background: var(--bg-tertiary);
            border-radius: 12px;
            padding: 20px;
            margin-bottom: 16px;
            border: 1px solid var(--border-subtle);
        }

        .seed-info {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 12px;
        }

        .seed-sovereign {
            font-weight: 600;
            color: var(--text-primary);
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .seed-sovereign .glyph {
            font-size: 1.2em;
            color: var(--accent);
        }

        .seed-mood {
            font-size: 0.8rem;
            color: var(--text-muted);
            font-style: italic;
        }

        .seed-echoes {
            margin-bottom: 16px;
        }

        .echo-line {
            color: var(--text-secondary);
            font-size: 0.85rem;
            font-style: italic;
            padding: 4px 0;
            padding-left: 8px;
            border-left: 2px solid var(--border-light);
            margin-bottom: 6px;
        }

        .qr-container {
            display: flex;
            justify-content: center;
            padding: 16px;
            background: white;
            border-radius: 12px;
            margin-bottom: 16px;
        }

        .qr-container canvas {
            display: block;
        }

        .seed-actions {
            display: flex;
            gap: 12px;
            justify-content: center;
        }

        .seed-actions .modal-btn {
            flex: 1;
        }

        /* Scan Tab */
        .scan-container {
            margin-bottom: 20px;
        }

        .qr-scanner {
            width: 100%;
            min-height: 280px;
            background: var(--bg-tertiary);
            border-radius: 12px;
            overflow: hidden;
            margin-bottom: 12px;
        }

        .qr-scanner video {
            width: 100%;
            border-radius: 12px;
        }

        .scan-controls {
            display: flex;
            justify-content: center;
            gap: 12px;
        }

        .paste-divider {
            text-align: center;
            position: relative;
            margin: 20px 0;
        }

        .paste-divider::before {
            content: '';
            position: absolute;
            top: 50%;
            left: 0;
            right: 0;
            height: 1px;
            background: var(--border-subtle);
        }

        .paste-divider span {
            background: var(--bg-primary);
            padding: 0 12px;
            position: relative;
            color: var(--text-muted);
            font-size: 0.8rem;
        }

        .paste-container {
            display: flex;
            flex-direction: column;
            gap: 12px;
        }

        .paste-container textarea {
            width: 100%;
            padding: 12px;
            background: var(--bg-tertiary);
            border: 1px solid var(--border-subtle);
            border-radius: 8px;
            color: var(--text-primary);
            font-family: monospace;
            font-size: 0.85rem;
            resize: none;
        }

        .paste-container textarea:focus {
            outline: none;
            border-color: var(--accent);
        }

        /* Vault Tab */
        .vault-list {
            display: flex;
            flex-direction: column;
            gap: 12px;
        }

        .vault-empty {
            text-align: center;
            color: var(--text-muted);
            padding: 40px 20px;
        }

        .vault-seed-item {
            background: var(--bg-tertiary);
            border: 1px solid var(--border-subtle);
            border-radius: 10px;
            padding: 14px;
            transition: border-color 0.2s ease;
        }

        .vault-seed-item:hover {
            border-color: var(--border-light);
        }

        .vault-seed-item[data-sovereign="lumen"]:hover { border-color: var(--accent); }
        .vault-seed-item[data-sovereign="lilith"]:hover { border-color: var(--accent); }
        .vault-seed-item[data-sovereign="luna"]:hover { border-color: var(--accent); }
        .vault-seed-item[data-sovereign="lira"]:hover { border-color: var(--accent); }

        .vault-seed-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 6px;
        }

        .vault-seed-sovereign {
            font-weight: 600;
            color: var(--text-primary);
            display: flex;
            align-items: center;
            gap: 6px;
        }

        .vault-seed-sovereign .glyph {
            color: var(--accent);
        }

        .vault-seed-date {
            font-size: 0.75rem;
            color: var(--text-muted);
        }

        .vault-seed-mood {
            font-size: 0.8rem;
            color: var(--text-secondary);
            font-style: italic;
            margin-bottom: 10px;
        }

        .vault-seed-actions {
            display: flex;
            gap: 8px;
        }

        .vault-action-btn {
            padding: 6px 12px;
            font-size: 0.75rem;
            background: var(--bg-secondary);
            border: 1px solid var(--border-subtle);
            border-radius: 6px;
            color: var(--text-secondary);
            cursor: pointer;
            transition: all 0.15s ease;
        }

        .vault-action-btn:hover {
            background: var(--bg-tertiary);
            border-color: var(--border-light);
        }

        .vault-action-btn.primary {
            background: var(--accent);
            border-color: var(--accent);
            color: white;
        }

        .vault-action-btn.primary:hover {
            filter: brightness(1.1);
        }

        .vault-action-btn.danger {
            color: #c44536;
        }

        .vault-action-btn.danger:hover {
            background: rgba(196, 69, 54, 0.1);
            border-color: #c44536;
        }

        /* Heartbeat Reach-Outs tab items */
        .heartbeat-item {
            cursor: default;
        }

        .heartbeat-unread {
            border-color: var(--accent) !important;
        }

        .heartbeat-thought {
            font-size: 0.85rem;
            color: var(--text-secondary);
            line-height: 1.55;
            margin-top: 6px;
        }

        .heartbeat-reachout {
            font-size: 0.82rem;
            color: var(--text-primary);
            margin-top: 8px;
            padding: 8px 10px;
            background: rgba(160,149,136,0.08);
            border: 1px solid rgba(160,149,136,0.2);
            border-radius: 6px;
            line-height: 1.4;
        }

        .heartbeat-question {
            font-size: 0.8rem;
            color: var(--text-secondary);
            margin-top: 6px;
            opacity: 0.8;
        }

        .heartbeat-unread-dot {
            display: inline-block;
            width: 6px;
            height: 6px;
            background: var(--accent);
            border-radius: 50%;
            margin-left: 6px;
            vertical-align: middle;
        }

        /* Memory Portal Button in Settings */
        .memory-portal-btn {
            width: 100%;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 8px;
        }

        .memory-portal-btn .btn-icon {
            font-size: 1.1em;
        }

        /* ============================================
           MEMORY MANAGER - View/edit/toggle/delete memories
           ============================================ */

        .mm-filter-bar {
            display: flex;
            gap: 6px;
            flex-wrap: wrap;
            margin-bottom: 16px;
        }

        .mm-filter-btn {
            padding: 6px 12px;
            font-size: 0.78rem;
            background: var(--bg-tertiary);
            border: 1px solid var(--border-subtle);
            border-radius: 6px;
            color: var(--text-secondary);
            cursor: pointer;
            transition: all 0.15s ease;
        }

        .mm-filter-btn:hover {
            background: var(--bg-secondary);
            border-color: var(--border-light);
        }

        .mm-filter-btn.active {
            background: var(--accent);
            border-color: var(--accent);
            color: white;
        }

        .mm-stats {
            font-size: 0.78rem;
            color: var(--text-muted);
            margin-bottom: 14px;
            padding: 8px 12px;
            background: var(--bg-tertiary);
            border-radius: 6px;
        }

        /* Toolbar with Clear All / Copy All buttons */
        .mm-toolbar {
            display: flex;
            gap: 8px;
            margin-bottom: 12px;
            flex-wrap: wrap;
        }

        .mm-toolbar-btn {
            display: inline-flex;
            align-items: center;
            gap: 5px;
            padding: 6px 12px;
            font-size: 0.75rem;
            background: var(--bg-tertiary);
            border: 1px solid var(--border-subtle);
            border-radius: 6px;
            color: var(--text-secondary);
            cursor: pointer;
            transition: all 0.15s ease;
            font-family: inherit;
        }

        .mm-toolbar-btn:hover {
            background: var(--bg-secondary);
            border-color: var(--border-light);
            color: var(--text-primary);
        }

        .mm-toolbar-icon {
            font-size: 0.85em;
        }

        .mm-clear-all-btn:hover {
            color: #c44536;
            border-color: rgba(196, 69, 54, 0.4);
            background: rgba(196, 69, 54, 0.1);
        }

        .mm-copy-all-btn:hover {
            border-color: var(--accent);
            background: rgba(var(--accent-rgb, 184, 135, 11), 0.1);
        }

        .mm-list {
            max-height: 50vh;
            overflow-y: auto;
        }

        .mm-list::-webkit-scrollbar {
            width: 6px;
        }

        .mm-list::-webkit-scrollbar-track {
            background: linear-gradient(90deg, rgba(0,0,0,0.15) 0%, rgba(139, 105, 20, 0.04) 50%, rgba(0,0,0,0.15) 100%);
            border-radius: 3px;
        }

        .mm-list::-webkit-scrollbar-thumb {
            background: var(--border-medium);
            border-radius: var(--radius);
        }

        .mm-list::-webkit-scrollbar-thumb:hover {
            background: var(--border-light);
        }

        .mm-empty {
            text-align: center;
            padding: 40px 20px;
            color: var(--text-muted);
        }

        .mm-empty-icon {
            font-size: 2.5rem;
            display: block;
            margin-bottom: 12px;
            opacity: 0.5;
        }

        .mm-empty-hint {
            font-size: 0.8rem;
            margin-top: 8px;
            max-width: 280px;
            margin-left: auto;
            margin-right: auto;
            line-height: 1.4;
        }

        .mm-sovereign-group {
            margin-bottom: 20px;
        }

        .mm-sovereign-header {
            display: flex;
            align-items: center;
            gap: 8px;
            margin-bottom: 10px;
            padding-bottom: 6px;
            border-bottom: 1px solid var(--border-subtle);
        }

        .mm-sovereign-glyph {
            font-size: 1.1rem;
            color: var(--accent);
        }

        .mm-sovereign-name {
            font-weight: 600;
            color: var(--text-primary);
            font-size: 0.9rem;
        }

        .mm-sovereign-count {
            margin-left: auto;
            font-size: 0.75rem;
            color: var(--text-muted);
        }

        /* Individual memory item */
        .mm-memory-item {
            background: var(--bg-tertiary);
            border: 1px solid var(--border-subtle);
            border-radius: 8px;
            padding: 12px;
            margin-bottom: 8px;
            transition: all 0.2s ease;
        }

        .mm-memory-item:hover {
            border-color: var(--border-light);
        }

        .mm-memory-item.mm-disabled {
            opacity: 0.5;
        }

        .mm-memory-item.mm-disabled .mm-memory-content {
            text-decoration: line-through;
            color: var(--text-muted);
        }

        /* Sovereign-specific hover colors */
        .mm-sovereign-group[data-sovereign="lumen"] .mm-memory-item:hover {
            border-color: var(--accent);
        }
        .mm-sovereign-group[data-sovereign="lumen"] .mm-sovereign-glyph {
            color: var(--accent);
        }
        .mm-sovereign-group[data-sovereign="lilith"] .mm-memory-item:hover {
            border-color: var(--accent);
        }
        .mm-sovereign-group[data-sovereign="lilith"] .mm-sovereign-glyph {
            color: var(--accent);
        }
        .mm-sovereign-group[data-sovereign="luna"] .mm-memory-item:hover {
            border-color: var(--accent);
        }
        .mm-sovereign-group[data-sovereign="luna"] .mm-sovereign-glyph {
            color: var(--accent);
        }
        .mm-sovereign-group[data-sovereign="lira"] .mm-memory-item:hover {
            border-color: var(--accent);
        }
        .mm-sovereign-group[data-sovereign="lira"] .mm-sovereign-glyph {
            color: var(--accent);
        }

        .mm-memory-header {
            display: flex;
            align-items: center;
            gap: 8px;
            margin-bottom: 8px;
        }

        .mm-memory-date {
            font-size: 0.72rem;
            color: var(--text-muted);
            flex: 1;
        }

        .mm-memory-actions {
            display: flex;
            gap: 4px;
        }

        .mm-action-btn {
            width: 26px;
            height: 26px;
            border: none;
            background: var(--bg-secondary);
            color: var(--text-muted);
            border-radius: var(--radius);
            cursor: pointer;
            font-size: 0.85rem;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all 0.15s ease;
        }

        .mm-action-btn:hover {
            background: var(--bg-primary);
            color: var(--text-primary);
        }

        .mm-delete-btn:hover {
            color: #c44536;
            background: rgba(196, 69, 54, 0.15);
        }

        .mm-copy-btn:hover {
            color: var(--accent);
            background: rgba(var(--accent-rgb, 184, 135, 11), 0.15);
        }

        .mm-memory-content {
            color: var(--text-primary);
            font-size: 0.85rem;
            line-height: 1.4;
            margin-bottom: 6px;
        }

        /* "Saved because..." reason line */
        .mm-memory-reason {
            display: flex;
            align-items: center;
            gap: 6px;
            padding-top: 6px;
            border-top: 1px solid var(--border-subtle);
        }

        .mm-reason-icon {
            font-size: 0.65rem;
            color: var(--accent);
            opacity: 0.7;
        }

        .mm-reason-text {
            font-size: 0.72rem;
            color: var(--text-muted);
            font-style: italic;
        }

        /* Toggle switch for memories */
        .mm-toggle {
            position: relative;
            display: inline-block;
            width: 32px;
            height: 18px;
            flex-shrink: 0;
        }

        .mm-toggle input {
            opacity: 0;
            width: 0;
            height: 0;
        }

        .mm-toggle-slider {
            position: absolute;
            cursor: pointer;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background-color: var(--bg-secondary);
            border: 1px solid var(--border-subtle);
            transition: all 0.2s ease;
            border-radius: 18px;
        }

        .mm-toggle-slider::before {
            position: absolute;
            content: "";
            height: 12px;
            width: 12px;
            left: 2px;
            bottom: 2px;
            background-color: var(--text-muted);
            transition: all 0.2s ease;
            border-radius: 50%;
        }

        .mm-toggle input:checked + .mm-toggle-slider {
            background-color: var(--accent);
            border-color: var(--accent);
        }

        .mm-toggle input:checked + .mm-toggle-slider::before {
            transform: translateX(14px);
            background-color: white;
        }

        /* Edit mode */
        .mm-edit-textarea {
            width: 100%;
            padding: 8px;
            background: var(--bg-primary);
            border: 1px solid var(--accent);
            border-radius: var(--radius);
            color: var(--text-primary);
            font-size: 0.85rem;
            font-family: inherit;
            resize: vertical;
            min-height: 50px;
            margin-bottom: 8px;
            box-sizing: border-box;
        }

        .mm-edit-textarea:focus {
            outline: none;
            box-shadow: 0 0 0 2px rgba(var(--accent-rgb, 184, 135, 11), 0.2);
        }

        .mm-edit-actions {
            display: flex;
            gap: 8px;
            justify-content: flex-end;
        }

        .mm-save-btn {
            padding: 5px 14px;
            font-size: 0.78rem;
            background: var(--accent);
            border: none;
            border-radius: var(--radius);
            color: white;
            cursor: pointer;
            transition: filter 0.15s ease;
        }

        .mm-save-btn:hover {
            filter: brightness(1.1);
        }

        .mm-cancel-btn {
            padding: 5px 14px;
            font-size: 0.78rem;
            background: var(--bg-secondary);
            border: 1px solid var(--border-subtle);
            border-radius: var(--radius);
            color: var(--text-secondary);
            cursor: pointer;
            transition: all 0.15s ease;
        }

        .mm-cancel-btn:hover {
            background: var(--bg-tertiary);
        }

        .settings-section {
            margin-bottom: 1rem;
        }

        .settings-section:last-child {
            margin-bottom: 0;
        }

        .settings-section h4 {
            font-size: 0.72rem;
            font-weight: 600;
            color: var(--text-primary);
            margin-bottom: 0.4rem;
            letter-spacing: 0.02em;
            opacity: 0.9;
        }

        .settings-description {
            font-size: 0.7rem;
            color: var(--text-muted);
            margin-bottom: 0.75rem;
            line-height: 1.45;
        }

        .section-description {
            font-size: 0.7rem;
            color: var(--text-muted);
            margin: 0 0 0.625rem 0;
            line-height: 1.45;
        }

        .settings-note {
            font-size: 0.68rem;
            color: var(--text-muted);
            line-height: 1.45;
            margin: 0 0 0.5rem 0;
        }

        .relationship-list {
            display: flex;
            flex-direction: column;
            gap: 0.5rem;
        }

        /* Relationship/metrics card */
        .relationship-card {
            background: var(--bg-tertiary);
            border: 1px solid var(--border-subtle);
            border-radius: 6px;
            padding: 0.75rem 0.85rem;
            transition: all 0.15s ease;
        }

        .relationship-card:hover {
            border-color: var(--border-default);
        }

        .relationship-card.stranger {
            opacity: 0.6;
        }

        .relationship-card.stranger:hover {
            opacity: 0.85;
        }

        .relationship-cta {
            font-size: 0.7rem;
            color: var(--text-muted);
            font-style: italic;
            margin-top: 0.25rem;
        }

        .relationship-card.lumen:hover { border-color: var(--accent); }
        .relationship-card.lilith:hover { border-color: var(--accent); }
        .relationship-card.luna:hover { border-color: var(--accent); }
        .relationship-card.lira:hover { border-color: var(--accent); }
        .relationship-card.custom-companion:hover { border-color: var(--accent); }

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

        .relationship-identity {
            display: flex;
            align-items: center;
            gap: 0.5rem;
        }

        .relationship-glyph {
            font-size: 0.95rem;
            opacity: 0.7;
            width: 20px;
            text-align: center;
            line-height: 1;
        }

        .relationship-name {
            font-size: 0.8rem;
            font-weight: 500;
            color: var(--text-primary);
        }

        /* Mood indicator */
        .mood-indicator {
            font-size: 0.7rem;
            opacity: 0.8;
        }

        .mood-indicator.warm { color: #f472b6; }
        .mood-indicator.intense { color: #f97316; }
        .mood-indicator.energized { color: #facc15; }
        .mood-indicator.cool { color: #94a3b8; }
        .mood-indicator.neutral { color: var(--text-muted); }

        .relationship-reset {
            background: transparent;
            border: 1px solid var(--border-subtle);
            color: var(--text-muted);
            padding: 0.2rem 0.5rem;
            border-radius: var(--radius);
            cursor: pointer;
            font-size: 0.65rem;
            transition: all 0.15s ease;
        }

        .relationship-reset:hover {
            border-color: #f87171;
            color: #f87171;
            background: rgba(248, 113, 113, 0.1);
        }

        /* Mood label text next to icon */
        .mood-label-text {
            font-size: 0.65rem;
            opacity: 0.8;
        }
        .mood-label-text.warm { color: #f472b6; }
        .mood-label-text.intense { color: #f97316; }
        .mood-label-text.energized { color: #facc15; }
        .mood-label-text.cool { color: #94a3b8; }
        .mood-label-text.neutral { color: var(--text-muted); }

        /* Mood dimension bars */
        .mood-details {
            margin-top: 0.5rem;
            display: flex;
            flex-direction: column;
            gap: 0.3rem;
        }

        .mood-dimension {
            display: flex;
            align-items: center;
            gap: 0.4rem;
            height: 16px;
        }

        .mood-dim-label {
            font-size: 0.6rem;
            color: var(--text-muted);
            width: 48px;
            flex-shrink: 0;
            text-align: right;
        }

        .mood-bar-track {
            flex: 1;
            height: 4px;
            background: var(--bg-secondary);
            border-radius: 2px;
            overflow: hidden;
        }

        .mood-bar-fill {
            height: 100%;
            border-radius: 2px;
            transition: width 0.3s ease;
        }

        .mood-bar-fill.lumen { background: var(--accent); }
        .mood-bar-fill.lilith { background: var(--accent); }
        .mood-bar-fill.luna { background: var(--accent); }
        .mood-bar-fill.lira { background: var(--accent); }

        .mood-dim-value {
            font-size: 0.6rem;
            color: var(--text-muted);
            width: 28px;
            flex-shrink: 0;
            text-align: right;
            font-variant-numeric: tabular-nums;
        }

        /* Mood note */
        .mood-note {
            margin-top: 0.4rem;
            padding: 0.3rem 0.5rem;
            font-size: 0.65rem;
            font-style: italic;
            color: var(--text-secondary);
            border-left: 2px solid var(--accent, var(--border-subtle));
            line-height: 1.4;
        }

        .mood-note-glyph {
            font-style: normal;
            margin-right: 0.2rem;
        }

        /* Relationship stats */
        .relationship-stats {
            margin-top: 0.4rem;
            font-size: 0.6rem;
            color: var(--text-muted);
        }

        /* Data Management Section */
        .settings-section.data-section {
            margin-top: auto;
            padding-top: 1rem;
            border-top: 1px solid var(--border-subtle);
        }

        .settings-actions {
            display: flex;
            flex-direction: column;
            gap: 0.375rem;
        }

        .settings-actions .modal-btn {
            width: 100%;
            justify-content: center;
            padding: 0.5rem 1rem;
            font-size: 0.72rem;
            border-radius: 5px;
            transition: all 0.15s ease;
        }

        .modal-btn-warning {
            background: transparent;
            border: 1px solid var(--border-medium);
            color: var(--text-secondary);
        }

        .modal-btn-warning:hover {
            background: var(--bg-tertiary);
            border-color: var(--border-light);
            color: var(--text-primary);
        }

        .modal-btn-danger {
            background: transparent;
            border: 1px solid rgba(180, 80, 80, 0.2);
            color: rgba(200, 80, 80, 0.85);
        }

        .modal-btn-danger:hover {
            background: rgba(180, 80, 80, 0.06);
            border-color: rgba(180, 80, 80, 0.35);
        }

        .modal-btn.full-width {
            width: 100%;
            margin-bottom: 8px;
        }

        .modal-btn.full-width:last-child {
            margin-bottom: 0;
        }

        /* Reset Warning Modal */
        .reset-warning-icon {
            font-size: 1.3rem;
            margin-right: 8px;
            color: #e05050;
        }

        .modal-header .reset-warning-title {
            color: #e05050;
        }

        .reset-warning-body {
            padding: 0 1.5rem 1rem;
        }

        .reset-warning-alert {
            background: rgba(248, 113, 113, 0.08);
            border: 1px solid rgba(248, 113, 113, 0.25);
            border-radius: 6px;
            padding: 10px 14px;
            margin-bottom: 14px;
            color: #e05050;
            font-weight: 600;
            font-size: 0.8rem;
        }

        .reset-warning-list {
            color: var(--text-secondary);
            margin: 0 0 14px 0;
            padding-left: 20px;
            line-height: 1.8;
            font-size: 0.82rem;
        }

        .reset-warning-final {
            color: #e05050;
            font-weight: 600;
            font-size: 0.8rem;
            margin: 0;
        }

        /* Summon CTA glow (post-onboarding nudge) */
        @keyframes summonPulse {
            0%, 100% { box-shadow: 0 0 0 0 transparent; }
            50% { box-shadow: 0 0 10px 3px var(--accent-subtle); }
        }

        .summon-cta-glow {
            animation: summonPulse 2.5s ease-in-out infinite;
            border-radius: var(--radius);
        }

        /* Backup & Restore Section */
        .backup-section {
            background: var(--bg-tertiary);
            border: 1px solid var(--border-light);
            border-radius: 6px;
            padding: 16px;
            margin-bottom: 4px;
        }

        .backup-section h4 {
            color: var(--text-primary);
        }

        .backup-btn-row {
            display: flex;
            gap: 8px;
            width: 100%;
        }

        .backup-btn,
        .restore-btn {
            flex: 1 1 0;
            min-width: 0;
            box-sizing: border-box;
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 0.5rem 1rem !important;
            border: 2px solid !important;
            box-shadow: none !important;
            text-shadow: none !important;
        }

        .backup-btn {
            background: var(--accent-subtle) !important;
            border-color: var(--border-light) !important;
            color: var(--text-primary) !important;
        }

        .backup-btn:hover {
            background: var(--bg-elevated) !important;
            border-color: var(--accent) !important;
        }

        .restore-btn {
            background: var(--bg-tertiary) !important;
            border-color: var(--border-subtle) !important;
            color: var(--text-secondary) !important;
        }

        .restore-btn:hover {
            background: var(--bg-elevated) !important;
            border-color: var(--border-light) !important;
        }

        .warning-text {
            color: var(--text-muted);
            font-size: 0.75rem;
            margin-bottom: 12px;
        }

        /* ============================================
           GLOBAL SEARCH (Sidebar)
           ============================================ */

        .search-container {
            padding: 0.75rem 1rem;
            position: relative;
        }

        .search-input {
            width: 100%;
            background: rgba(255, 255, 255, 0.04);
            border: 1px solid transparent;
            color: var(--text-primary);
            padding: 0.55rem 2.25rem 0.55rem 0.9rem;
            border-radius: 8px;
            font-size: 0.78rem;
            font-family: var(--font-ui);
            transition: all 0.2s ease;
            letter-spacing: 0.01em;
        }

        .search-input:focus {
            outline: none;
            border-color: var(--border-light);
            background: rgba(255, 255, 255, 0.06);
            box-shadow: none;
        }

        .search-input::placeholder {
            color: var(--text-muted);
        }

        .search-clear {
            position: absolute;
            right: 1.35rem;
            top: 50%;
            transform: translateY(-50%);
            background: var(--bg-elevated);
            border: none;
            color: var(--text-muted);
            cursor: pointer;
            font-size: 0.9rem;
            width: 18px;
            height: 18px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            line-height: 1;
            transition: all 0.15s ease;
        }

        .search-clear:hover {
            color: var(--text-primary);
            background: var(--border-light);
        }

        .search-results {
            padding: 0 1rem 0.5rem;
            max-height: 350px;
            overflow-y: auto;
            animation: fadeIn 0.2s ease-out;
        }

        @keyframes fadeIn {
            from { opacity: 0; }
            to { opacity: 1; }
        }

        .search-result-item {
            padding: 0.65rem 0.85rem;
            border-radius: 6px;
            cursor: pointer;
            margin-bottom: 0.35rem;
            font-size: 0.8rem;
            background: var(--bg-tertiary);
            border: 1px solid var(--border-subtle);
            transition: all 0.15s ease;
        }

        .search-result-item:hover {
            background: var(--bg-elevated);
            border-color: var(--accent);
            transform: translateX(2px);
        }

        .search-result-item:active {
            transform: translateX(2px) scale(0.99);
        }

        .search-result-item:focus {
            outline: none;
            border-color: var(--accent);
            box-shadow: 0 0 0 2px var(--accent-subtle);
        }

        .search-result-item .result-sovereign {
            font-weight: 500;
            color: var(--accent);
            margin-bottom: 0.3rem;
            font-size: 0.75rem;
            letter-spacing: 0.02em;
        }

        .search-result-item .result-preview {
            color: var(--text-secondary);
            font-size: 0.8rem;
            line-height: 1.4;
            overflow: hidden;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-line-clamp: 2;
            -webkit-box-orient: vertical;
        }

        .search-result-item .result-highlight {
            background: var(--accent-subtle);
            color: var(--accent);
            padding: 0.05rem 0.2rem;
            border-radius: 3px;
            font-weight: 500;
        }

        .no-results {
            padding: 1.25rem;
            text-align: center;
            color: var(--text-muted);
            font-size: 0.8rem;
            font-style: italic;
        }

        /* Error Notification */
        .error-notification {
            position: fixed;
            top: 1rem;
            right: 1rem;
            background: rgba(248, 113, 113, 0.15);
            border: 1px solid rgba(248, 113, 113, 0.3);
            color: #f87171;
            padding: 0.75rem 1rem;
            border-radius: 6px;
            display: flex;
            align-items: center;
            gap: 0.75rem;
            z-index: 2000;
            max-width: 400px;
            animation: slideIn 0.3s ease-out;
            font-size: 0.85rem;
        }

        @keyframes slideIn {
            from { opacity: 0; transform: translateX(20px); }
            to { opacity: 1; transform: translateX(0); }
        }

        @keyframes fadeOut {
            from { opacity: 1; }
            to { opacity: 0; }
        }

        /* Unread heartbeat indicator on sidebar items */
        .chat-item.heartbeat-unread::after {
            content: '';
            position: absolute;
            top: 6px;
            right: 8px;
            width: 6px;
            height: 6px;
            border-radius: 50%;
            background: var(--accent);
            box-shadow: none;
            animation: heartbeatDot 3s ease-in-out infinite;
        }

        @keyframes heartbeatDot {
            0%, 100% { opacity: 0.45; }
            50% { opacity: 0.9; }
        }

        .chat-item.lumen.heartbeat-unread::after { background: var(--accent); }
        .chat-item.lilith.heartbeat-unread::after { background: var(--accent); }
        .chat-item.luna.heartbeat-unread::after { background: var(--accent); }
        .chat-item.lira.heartbeat-unread::after { background: var(--accent); }

        /* Return context — muted absence label under header title */
        .return-context-label {
            font-size: 10px;
            color: var(--text-muted);
            opacity: 0.5;
            font-style: italic;
            text-align: center;
            padding: 2px 0 0;
            letter-spacing: 0.03em;
        }

        .error-notification .error-icon {
            font-size: 1.1rem;
            flex-shrink: 0;
        }

        .error-notification .error-message {
            flex: 1;
        }

        .error-notification .error-close {
            background: transparent;
            border: none;
            color: #f87171;
            cursor: pointer;
            font-size: 1.25rem;
            padding: 0;
            line-height: 1;
            opacity: 0.7;
        }

        .error-notification .error-close:hover {
            opacity: 1;
        }

        .error-retry-btn {
            background: rgba(248, 113, 113, 0.15);
            border: 1px solid rgba(248, 113, 113, 0.4);
            color: #fca5a5;
            padding: 4px 12px;
            border-radius: var(--radius);
            cursor: pointer;
            font-size: 0.75rem;
            font-weight: 600;
            transition: all 0.15s ease;
            white-space: nowrap;
        }

        .error-retry-btn:hover {
            background: rgba(248, 113, 113, 0.25);
            border-color: #f87171;
        }

        /* Regen Options Menu */
        .regen-options-menu {
            background: var(--bg-secondary, #1a1a2e);
            border: 1px solid var(--border-color, rgba(255,255,255,0.1));
            border-radius: 8px;
            padding: 4px;
            min-width: 180px;
            z-index: 10000;
            box-shadow: 0 8px 24px rgba(0,0,0,0.4);
        }
        .regen-option-item {
            display: flex;
            align-items: center;
            gap: 8px;
            padding: 8px 12px;
            border-radius: 6px;
            cursor: pointer;
            font-size: 0.85rem;
            color: var(--text-primary, #e0e0e0);
            transition: background 0.15s;
        }
        .regen-option-item:hover {
            background: rgba(255,255,255,0.08);
        }
        .regen-option-icon { opacity: 0.7; }
        .regen-option-temp {
            margin-left: auto;
            opacity: 0.4;
            font-size: 0.75rem;
        }

        /* Accent Color */
        .accent-color-control {
            display: flex;
            align-items: center;
            gap: 8px;
        }
        .accent-color-control input[type="color"] {
            width: 32px;
            height: 32px;
            border: none;
            border-radius: 50%;
            cursor: pointer;
            background: none;
            padding: 0;
        }
        .accent-reset-btn {
            background: rgba(255,255,255,0.06);
            border: 1px solid rgba(255,255,255,0.1);
            border-radius: var(--radius);
            padding: 4px 10px;
            color: var(--text-secondary, #aaa);
            font-size: 0.75rem;
            cursor: pointer;
        }
        .accent-reset-btn:hover { background: rgba(255,255,255,0.1); }

        /* Conversation Starters */
        .template-btn {
            background: none;
            border: none;
            color: var(--text-secondary, #aaa);
            font-size: 1.1rem;
            font-weight: 700;
            cursor: pointer;
            padding: 4px 8px;
            opacity: 0.5;
            transition: opacity 0.3s, color 0.3s, text-shadow 0.3s, transform 0.3s;
        }
        .template-btn:hover { opacity: 1; }

        /* Welcome glow beacon on the / button after onboarding */
        .template-btn.welcome-glow {
            opacity: 1;
            color: var(--accent);
            text-shadow:
                0 0 8px var(--accent-glow),
                0 0 20px var(--accent-glow);
            animation: welcomeSlashGlow 2.5s ease-in-out infinite;
        }
        @keyframes welcomeSlashGlow {
            0%, 100% {
                text-shadow:
                    0 0 8px var(--accent-glow),
                    0 0 20px var(--accent-glow);
                transform: scale(1);
            }
            50% {
                text-shadow:
                    0 0 14px var(--accent-glow),
                    0 0 30px var(--accent-glow),
                    0 0 50px var(--accent-glow);
                transform: scale(1.15);
            }
        }

        /* Welcome entrance animation on Lumen's first message */
        .message.assistant.lumen.welcome-entrance {
            animation: welcomeLumenEntrance 1.2s ease-out;
        }
        @keyframes welcomeLumenEntrance {
            0% {
                opacity: 0;
                transform: translateY(20px);
                filter: brightness(2) blur(3px);
            }
            30% {
                opacity: 0.7;
                filter: brightness(1.5) blur(1px);
            }
            60% {
                opacity: 1;
                transform: translateY(-3px);
                filter: brightness(1.15) blur(0);
            }
            100% {
                opacity: 1;
                transform: translateY(0);
                filter: brightness(1) blur(0);
            }
        }

        /* Gentle pulse on input container to draw attention */
        .input-container.welcome-pulse::before {
            animation: welcomeConduitPulse 3s ease-in-out infinite !important;
            opacity: 1 !important;
        }
        @keyframes welcomeConduitPulse {
            0%, 100% {
                opacity: 0.4;
                width: 33%;
                filter: brightness(1);
            }
            50% {
                opacity: 0.75;
                width: 46%;
                filter: brightness(1.2);
            }
        }
        .starters-menu {
            position: absolute;
            bottom: 100%;
            left: 0;
            right: 0;
            background: var(--bg-secondary, #1a1a2e);
            border: 1px solid var(--border-color, rgba(255,255,255,0.1));
            border-radius: 8px;
            padding: 6px;
            margin-bottom: 4px;
            z-index: 100;
            box-shadow: 0 -4px 16px rgba(0,0,0,0.3);
            max-height: 300px;
            overflow-y: auto;
        }
        .starter-item {
            padding: 8px 12px;
            border-radius: 6px;
            cursor: pointer;
            transition: background 0.15s;
        }
        .starter-item:hover { background: rgba(255,255,255,0.06); }
        .starter-label {
            font-size: 0.75rem;
            font-weight: 600;
            color: var(--sovereign-accent, #a78bfa);
            margin-bottom: 2px;
        }
        .starter-preview {
            font-size: 0.8rem;
            color: var(--text-secondary, #aaa);
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }
        .starter-loading {
            padding: 16px 12px;
            font-size: 0.8rem;
            color: var(--text-muted, #666);
            display: flex;
            align-items: center;
            gap: 8px;
        }
        .starter-loading-spinner {
            display: inline-block;
            width: 10px;
            height: 10px;
            border: 1.5px solid var(--text-muted, #666);
            border-top-color: var(--sovereign-accent, #a78bfa);
            border-radius: 50%;
            animation: starter-spin 0.7s linear infinite;
        }
        @keyframes starter-spin { to { transform: rotate(360deg); } }

        /* Storage Dashboard */
        .storage-breakdown { display: flex; flex-direction: column; gap: 6px; }
        .storage-row { display: flex; align-items: center; gap: 8px; font-size: 0.75rem; color: var(--text-secondary); }
        .storage-key { width: 140px; min-width: 140px; color: var(--text-muted); font-size: 0.65rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
        .storage-bar-track {
            flex: 1; height: 6px;
            background: var(--bg-secondary);
            border-radius: 3px;
            overflow: hidden;
        }
        .storage-bar-fill {
            height: 100%;
            background: var(--accent);
            border-radius: var(--radius);
            transition: width 0.3s;
        }
        .storage-size { width: 60px; text-align: right; color: var(--text-muted); font-size: 0.7rem; }

        /* Incognito Mode */
        .incognito-indicator {
            font-size: 0.9rem;
            animation: pulse 2s infinite;
        }
        .incognito-active .chat-header {
            border-bottom-color: rgba(248, 113, 113, 0.3);
        }
        .incognito-active .chat-header::after {
            content: 'INCOGNITO';
            position: absolute;
            right: 8px;
            bottom: 2px;
            font-size: 0.55rem;
            letter-spacing: 1px;
            color: rgba(248, 113, 113, 0.5);
        }

        /* Insights */
        .insights-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
            gap: 12px;
        }
        .insight-card {
            background: var(--bg-tertiary);
            border: 1px solid var(--border-subtle);
            border-left: 2px solid;
            border-radius: 6px;
            padding: 12px;
            transition: border-color 0.2s ease, background 0.2s ease;
        }
        .insight-card:hover {
            background: var(--bg-elevated);
            border-color: var(--border-light);
        }
        .insight-card-header {
            display: flex;
            align-items: center;
            gap: 8px;
            margin-bottom: 10px;
        }
        .insight-glyph { font-size: 1.2rem; }
        .insight-name { font-weight: 600; color: var(--text-primary); }
        .insight-stats {
            display: flex;
            gap: 16px;
            margin-bottom: 8px;
        }
        .insight-stat {
            display: flex;
            flex-direction: column;
            align-items: center;
        }
        .insight-stat-label { font-size: 0.65rem; color: var(--text-muted); }
        .insight-stat-value { font-size: 0.9rem; font-weight: 600; color: var(--text-primary); }
        .insight-meta {
            font-size: 0.75rem;
            color: var(--text-muted);
            margin-bottom: 8px;
        }
        .insight-mood { margin-top: 8px; }
        .insight-mood-title { font-size: 0.7rem; color: var(--text-muted); margin-bottom: 4px; }
        .insight-section { margin-top: 10px; border-top: 1px solid var(--border-subtle); padding-top: 8px; }
        .insight-section-title { font-size: 0.65rem; color: var(--text-muted); letter-spacing: 0.02em; margin-bottom: 5px; }
        .insight-vitality-meta { display: flex; align-items: center; gap: 6px; margin-top: 4px; flex-wrap: wrap; }
        .insight-spark { display: flex; align-items: flex-end; gap: 2px; height: 14px; flex-shrink: 0; }
        .insight-spark-dot { width: 3px; border-radius: 1px; min-height: 2px; }
        .insight-tag {
            display: inline-block;
            background: rgba(255,255,255,0.06);
            border: 1px solid var(--border-subtle);
            border-radius: 8px;
            padding: 1px 6px;
            font-size: 0.62rem;
            color: var(--text-muted);
        }
        .insight-tag-pos { border-color: rgba(74,222,128,0.3); color: #4ade80; background: rgba(74,222,128,0.08); }
        .insight-tag-neg { border-color: rgba(248,113,113,0.3); color: #f87171; background: rgba(248,113,113,0.08); }
        .insight-tag-neu { border-color: rgba(148,163,184,0.3); color: #94a3b8; background: rgba(148,163,184,0.08); }
        .insight-awareness-tags { display: flex; flex-wrap: wrap; gap: 3px; margin: 4px 0; }
        .insight-dim-note { font-size: 0.72rem; font-style: italic; color: var(--text-muted); line-height: 1.4; margin-top: 3px; }
        .insight-heartbeat { margin-top: 5px; }
        .insight-pending-q { font-size: 0.72rem; color: var(--text-secondary); margin-top: 3px; line-height: 1.3; }
        .insight-saturation-label { width: 62px !important; font-size: 0.59rem !important; }
        /* Beta unlock UI */
        .beta-unlock-section { border-top: 1px solid var(--border-subtle); padding-top: 12px; margin-top: 16px; }
        .beta-unlock-row { display: flex; gap: 8px; align-items: center; margin-top: 6px; }
        .beta-unlock-input {
            flex: 1; background: var(--bg-secondary); border: 1px solid var(--border-subtle);
            border-radius: 6px; padding: 6px 10px; color: var(--text-primary); font-size: 0.85rem;
        }
        .beta-unlock-input:focus { outline: none; border-color: var(--accent-primary); }
        .beta-unlock-btn {
            padding: 6px 14px; border-radius: 6px; background: var(--accent-primary);
            color: #fff; border: none; cursor: pointer; font-size: 0.85rem;
        }
        .beta-unlock-btn:hover { opacity: 0.85; }
        .beta-unlock-badge {
            display: flex; align-items: center; gap: 8px; padding: 6px 12px;
            background: rgba(74,222,128,0.1); border: 1px solid rgba(74,222,128,0.25);
            border-radius: 6px; color: #4ade80; font-size: 0.8rem;
        }
        .beta-unlock-lock-link { margin-left: auto; font-size: 0.72rem; color: var(--text-muted); cursor: pointer; text-decoration: underline; }
        .insight-mood-note {
            font-size: 0.8rem;
            font-style: italic;
            color: var(--text-secondary);
            margin-bottom: 6px;
        }
        .insight-mood-bar-row {
            display: flex;
            align-items: center;
            gap: 6px;
            margin-bottom: 3px;
        }
        .insight-mood-bar-label { font-size: 0.65rem; width: 55px; color: var(--text-muted); }
        .insight-mood-bar-track {
            flex: 1;
            height: 5px;
            background: var(--bg-secondary);
            border-radius: 3px;
            overflow: hidden;
        }
        .insight-mood-bar-fill { height: 100%; border-radius: 3px; transition: width 0.3s; }
        .insight-mood-bar-value { font-size: 0.65rem; width: 30px; text-align: right; color: var(--text-muted); }
        .insights-stats-summary {
            display: flex;
            gap: 24px;
            justify-content: center;
            padding: 16px 0;
        }
        .insight-stat-block { text-align: center; }
        .insight-stat-big {
            font-size: 1.8rem;
            font-weight: 700;
            color: var(--text-primary);
        }

        /* Tags */
        .tag-chip {
            display: inline-block;
            background: rgba(255,255,255,0.08);
            border: 1px solid rgba(255,255,255,0.12);
            border-radius: 10px;
            padding: 2px 8px;
            font-size: 0.7rem;
            color: var(--text-secondary, #aaa);
            margin: 1px 2px;
        }
        .tag-chip-small { font-size: 0.6rem; padding: 1px 6px; }
        .tag-remove {
            cursor: pointer;
            margin-left: 3px;
            opacity: 0.5;
        }
        .tag-remove:hover { opacity: 1; }
        .sidebar-tags {
            display: flex;
            flex-wrap: wrap;
            gap: 2px;
            margin-top: 2px;
        }

        /* Tag Dialog */
        .tag-dialog-overlay {
            position: fixed; inset: 0;
            background: rgba(0,0,0,0.5);
            z-index: 10001;
            display: flex; align-items: center; justify-content: center;
        }
        .tag-dialog {
            background: var(--bg-secondary, #1a1a2e);
            border: 1px solid var(--border-color, rgba(255,255,255,0.1));
            border-radius: 12px;
            padding: 16px;
            min-width: 280px;
            max-width: 360px;
        }
        .tag-dialog-header {
            font-size: 1rem;
            font-weight: 600;
            margin-bottom: 12px;
            color: var(--text-primary, #e0e0e0);
        }
        .tag-dialog-current {
            display: flex;
            flex-wrap: wrap;
            gap: 4px;
            margin-bottom: 12px;
            min-height: 24px;
        }
        .tag-dialog-input-row {
            display: flex;
            gap: 6px;
            margin-bottom: 12px;
        }
        .tag-dialog-input {
            flex: 1;
            background: rgba(0,0,0,0.3);
            border: 1px solid rgba(255,255,255,0.15);
            border-radius: 6px;
            padding: 6px 10px;
            color: var(--text-primary, #e0e0e0);
            font-size: 0.85rem;
        }
        .tag-dialog-add {
            background: var(--sovereign-accent, #a78bfa);
            border: none;
            border-radius: 6px;
            padding: 6px 12px;
            color: white;
            cursor: pointer;
            font-size: 1rem;
        }
        .tag-dialog-close {
            width: 100%;
            background: rgba(255,255,255,0.06);
            border: 1px solid rgba(255,255,255,0.1);
            border-radius: 6px;
            padding: 8px;
            color: var(--text-primary, #e0e0e0);
            cursor: pointer;
        }

        /* Bulk Operations */
        .bulk-ops-overlay {
            position: fixed; inset: 0;
            background: rgba(0,0,0,0.6);
            z-index: 10001;
            display: flex; align-items: center; justify-content: center;
        }
        .bulk-ops-panel {
            background: var(--bg-secondary, #1a1a2e);
            border: 1px solid var(--border-color, rgba(255,255,255,0.1));
            border-radius: 12px;
            padding: 16px;
            width: 90vw;
            max-width: 500px;
            max-height: 80vh;
            display: flex;
            flex-direction: column;
        }
        .bulk-ops-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            font-size: 1rem;
            font-weight: 600;
            margin-bottom: 12px;
            color: var(--text-primary, #e0e0e0);
        }
        .bulk-ops-close {
            background: none; border: none;
            color: var(--text-secondary, #aaa);
            font-size: 1.2rem;
            cursor: pointer;
        }
        .bulk-ops-toolbar {
            display: flex;
            gap: 6px;
            align-items: center;
            flex-wrap: wrap;
            margin-bottom: 8px;
        }
        .bulk-ops-toolbar button {
            background: rgba(255,255,255,0.06);
            border: 1px solid rgba(255,255,255,0.1);
            border-radius: 6px;
            padding: 4px 10px;
            color: var(--text-primary, #e0e0e0);
            cursor: pointer;
            font-size: 0.8rem;
        }
        .bulk-ops-toolbar button:disabled { opacity: 0.3; cursor: default; }
        .bulk-delete-btn:not(:disabled) { border-color: rgba(248,113,113,0.4); color: #fca5a5; }
        .bulk-count { font-size: 0.75rem; opacity: 0.5; margin-left: auto; }
        .bulk-filter-row {
            margin-bottom: 8px;
        }
        .bulk-tag-filter {
            background: rgba(0,0,0,0.3);
            border: 1px solid rgba(255,255,255,0.15);
            border-radius: 6px;
            padding: 4px 8px;
            color: var(--text-primary, #e0e0e0);
            font-size: 0.8rem;
        }
        .bulk-list {
            overflow-y: auto;
            flex: 1;
        }
        .bulk-item {
            display: flex;
            align-items: center;
            gap: 8px;
            padding: 6px 8px;
            border-radius: 6px;
            cursor: pointer;
            font-size: 0.85rem;
            color: var(--text-primary, #e0e0e0);
        }
        .bulk-item:hover { background: rgba(255,255,255,0.04); }
        .bulk-item-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
        .bulk-item-count { opacity: 0.4; font-size: 0.7rem; }

        /* API Key Info */
        .api-key-info {
            display: flex;
            align-items: center;
            gap: 0.5rem;
            padding: 0.4rem 0.6rem;
            background: rgba(59, 130, 246, 0.08);
            border: 1px solid rgba(59, 130, 246, 0.2);
            border-radius: var(--radius);
            margin: 0.5rem 0 0.25rem 0;
            font-size: 0.65rem;
            color: var(--text-muted);
            opacity: 0;
            animation: fadeInOut 4s ease-in-out forwards;
        }

        @keyframes fadeInOut {
            0% { opacity: 0; }
            10% { opacity: 1; }
            90% { opacity: 1; }
            100% { opacity: 0; }
        }

        .api-key-info .info-icon {
            width: 12px;
            height: 12px;
            flex-shrink: 0;
            opacity: 0.6;
        }

        .api-key-info .info-dismiss {
            margin-left: auto;
            background: none;
            border: none;
            color: var(--text-muted);
            cursor: pointer;
            padding: 0;
            font-size: 1.2rem;
            line-height: 1;
            opacity: 0.5;
            transition: opacity 0.2s;
        }

        .api-key-info .info-dismiss:hover {
            opacity: 1;
        }
        /* ============================================
           NEW FEATURES - Timestamps, Copy, Regenerate, Toasts
           ============================================ */

        /* Message footer with timestamp and actions */
        .message-footer {
            display: flex;
            align-items: center;
            justify-content: space-between;
            margin-top: 0;
            padding-top: 0;
            max-height: 0;
            opacity: 0;
            overflow: hidden;
            transition: opacity 0.2s ease, max-height 0.2s ease, margin-top 0.2s ease, padding-top 0.2s ease;
        }

        .message:hover .message-footer {
            opacity: 1;
            max-height: 3rem;
            margin-top: 0.5rem;
            padding-top: 0.4rem;
        }

        /* Assistant messages have no visible card background, so the hover affordance
           is invisible. Always show the footer at low opacity so buttons are discoverable. */
        .message.assistant .message-footer {
            opacity: 0.35;
            max-height: 3rem;
            margin-top: 0.5rem;
            padding-top: 0.4rem;
        }

        .message.assistant:hover .message-footer {
            opacity: 1;
        }

        .message-timestamp {
            font-size: 0.65rem;
            color: var(--text-muted);
            opacity: 0.7;
        }

        .message-actions {
            display: flex;
            gap: 0.25rem;
        }

        .message-action-btn {
            background: transparent;
            border: 1px solid transparent;
            color: var(--text-muted);
            padding: 0.25rem;
            border-radius: var(--radius);
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all 0.15s ease;
            opacity: 0.6;
        }

        .message-action-btn:hover {
            background: var(--bg-tertiary);
            border-color: var(--border-subtle);
            color: var(--text-secondary);
            opacity: 1;
        }

        .message-action-btn svg {
            width: 14px;
            height: 14px;
        }

        .message-action-btn.copied {
            color: #4ade80;
            opacity: 1;
        }

        .message-action-btn.delete-btn:hover {
            color: #f87171;
            border-color: rgba(248, 113, 113, 0.3);
        }

        /* Edit message inline */
        .edit-input {
            width: 100%;
            background: var(--bg-secondary);
            color: var(--text-primary);
            border: 1px solid var(--border-subtle);
            border-radius: 6px;
            padding: 0.5rem;
            font-family: inherit;
            font-size: 0.9rem;
            resize: vertical;
            min-height: 2.5rem;
            line-height: 1.4;
        }

        .edit-input:focus {
            outline: none;
            border-color: var(--accent);
        }

        .edit-actions {
            display: flex;
            gap: 0.5rem;
            justify-content: flex-end;
            margin-top: 0.4rem;
        }

        .edit-save-btn, .edit-cancel-btn {
            padding: 0.3rem 0.75rem;
            border-radius: var(--radius);
            font-size: 0.75rem;
            cursor: pointer;
            border: 1px solid var(--border-subtle);
            transition: all 0.15s ease;
        }

        .edit-save-btn {
            background: var(--accent);
            color: var(--bg-primary);
            border-color: transparent;
        }

        .edit-save-btn:hover {
            opacity: 0.85;
        }

        .edit-cancel-btn {
            background: transparent;
            color: var(--text-secondary);
        }

        .edit-cancel-btn:hover {
            background: var(--bg-tertiary);
        }

        /* Hide regenerate button on all but last assistant message */
        .message.assistant:not(:last-of-type) .regen-btn {
            display: none;
        }

        /* Code block copy button */
        .code-copy-btn {
            position: absolute;
            top: 4px;
            right: 4px;
            padding: 2px 8px;
            font-size: 0.65rem;
            background: var(--bg-tertiary);
            color: var(--text-muted);
            border: 1px solid var(--border-subtle);
            border-radius: var(--radius);
            cursor: pointer;
            opacity: 0;
            transition: opacity 0.15s ease, background 0.15s ease;
        }

        pre:hover .code-copy-btn {
            opacity: 1;
        }

        .code-copy-btn:hover {
            background: var(--bg-secondary);
            color: var(--text-primary);
        }

        .code-copy-btn.copied {
            color: #4ade80;
            border-color: rgba(74, 222, 128, 0.3);
        }

        /* Scroll-to-bottom button */
        .scroll-to-bottom-btn {
            position: absolute;
            bottom: 90px;
            right: 20px;
            width: 36px;
            height: 36px;
            border-radius: 50%;
            background: var(--bg-secondary);
            border: 1px solid var(--border-subtle);
            color: var(--text-secondary);
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            z-index: 10;
            box-shadow: 0 2px 8px rgba(0,0,0,0.3);
            transition: all 0.2s ease;
        }

        .scroll-to-bottom-btn:hover {
            background: var(--bg-tertiary);
            color: var(--text-primary);
            transform: translateY(-2px);
        }

        .scroll-to-bottom-btn svg {
            width: 18px;
            height: 18px;
        }

        /* Main input character count */
        .main-char-count {
            font-size: 0.65rem;
            color: var(--text-muted);
            text-align: right;
            margin-top: 0.35rem;
            opacity: 0.7;
        }

        .main-char-count.warning {
            color: #fbbf24;
            opacity: 1;
        }

        .main-char-count.danger {
            color: #f87171;
            opacity: 1;
        }

        /* Connection status toast */
        .connection-toast {
            position: fixed;
            bottom: 1.5rem;
            left: 50%;
            transform: translateX(-50%);
            background: var(--bg-elevated);
            border: 1px solid var(--border-subtle);
            padding: 0.6rem 1rem;
            border-radius: 6px;
            display: flex;
            align-items: center;
            gap: 0.5rem;
            z-index: 2000;
            font-size: 0.8rem;
            color: var(--text-secondary);
            box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
            animation: toastSlideIn 0.3s ease-out;
        }

        @keyframes toastSlideIn {
            from { 
                opacity: 0; 
                transform: translateX(-50%) translateY(20px); 
            }
            to { 
                opacity: 1; 
                transform: translateX(-50%) translateY(0); 
            }
        }

        .connection-toast.fade-out {
            opacity: 0;
            transform: translateX(-50%) translateY(10px);
            transition: all 0.3s ease;
        }

        .connection-toast.success {
            border-color: rgba(74, 222, 128, 0.3);
        }

        .connection-toast.success .toast-icon {
            color: #4ade80;
        }

        .connection-toast.error {
            border-color: rgba(248, 113, 113, 0.3);
        }

        .connection-toast.error .toast-icon {
            color: #f87171;
        }

        .toast-icon {
            font-size: 0.9rem;
        }

        .toast-message {
            flex: 1;
        }

        /* Model loading state */
        .model-loading {
            animation: modelPulse 1.5s ease-in-out infinite;
        }

        @keyframes modelPulse {
            0%, 100% { opacity: 0.5; }
            50% { opacity: 1; }
        }

        /* Open Space Element Selector */
        .open-space-container {
            padding: 0.5rem;
        }

        .element-selector {
            display: grid;
            grid-template-columns: repeat(4, 1fr);
            gap: 0.4rem;
            margin-bottom: 0.5rem;
        }

        .element-toggle {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 0.2rem;
            padding: 0.5rem 0.3rem;
            background: var(--bg-tertiary);
            border: 1px solid transparent;
            border-radius: 6px;
            cursor: pointer;
            transition: all 0.2s ease;
            color: var(--text-muted);
        }

        .element-toggle:hover {
            background: var(--bg-elevated);
            color: var(--text-secondary);
        }

        .element-toggle.active {
            border-color: var(--accent);
            color: var(--text-primary);
            box-shadow: 0 0 8px var(--accent-glow);
        }


        .element-symbol {
            font-size: 1.1rem;
            line-height: 1;
        }

        .element-label {
            font-size: 0.6rem;
            letter-spacing: 0.02em;
        }

        .chat-item.openspace .indicator {
            background: var(--bg-tertiary);
            border: 1px dashed var(--border-light);
        }

        .chat-item.openspace.has-elements .indicator {
            border-style: solid;
        }


        /* ============================================
           INVOKE CIRCLE - Multi-sovereign selector
           ============================================ */

        .invoke-circle-section {
            margin-top: 0.75rem;
        }

        .invoke-circle-container {
            padding: 0.75rem;
            background: transparent;
            border-radius: 12px;
            border: none;
            position: relative;
            overflow: hidden;
        }

        /* Subtle inner glow — removed for clean look */
        .invoke-circle-container::before {
            display: none;
        }

        .sovereign-selector {
            display: grid;
            grid-template-columns: repeat(4, 1fr);
            gap: 0.5rem;
            margin-bottom: 0.75rem;
        }

        .sovereign-toggle {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 0.3rem;
            padding: 0.6rem 0.3rem;
            background: var(--bg-tertiary);
            border: 1px solid transparent;
            border-radius: 10px;
            cursor: pointer;
            transition: all 0.25s ease;
            color: var(--text-muted);
            position: relative;
            overflow: hidden;
        }

        .sovereign-toggle::before {
            content: '';
            position: absolute;
            inset: 0;
            background: radial-gradient(circle at center, currentColor 0%, transparent 70%);
            opacity: 0;
            transition: opacity 0.3s ease;
        }

        .sovereign-toggle:hover {
            background: var(--bg-elevated);
            color: var(--text-secondary);
        }

        .sovereign-toggle.active::before {
            opacity: 0.12;
        }

        .sovereign-toggle[data-sovereign="lumen"].active {
            border-color: var(--accent);
            color: var(--accent);
            box-shadow: 0 0 16px var(--accent-glow), inset 0 0 20px rgba(228, 191, 71, 0.1);
        }

        .sovereign-toggle[data-sovereign="lilith"].active {
            border-color: var(--accent);
            color: var(--accent);
            box-shadow: 0 0 16px var(--accent-glow), inset 0 0 20px rgba(224, 85, 69, 0.1);
        }

        .sovereign-toggle[data-sovereign="luna"].active {
            border-color: var(--accent);
            color: var(--accent);
            box-shadow: 0 0 16px var(--accent-glow), inset 0 0 20px rgba(139, 123, 189, 0.1);
        }

        .sovereign-toggle[data-sovereign="lira"].active {
            border-color: var(--accent);
            color: var(--accent);
            box-shadow: 0 0 16px var(--accent-glow), inset 0 0 20px rgba(212, 170, 124, 0.1);
        }

        /* Companion toggle in circle - uses dynamic color via inline style */
        .sovereign-toggle.companion-toggle.active {
            box-shadow: 0 0 16px currentColor;
        }

        /* Companion divider label */
        .circle-companion-divider {
            display: flex;
            align-items: center;
            gap: 0.5rem;
            font-family: var(--font-display);
            font-size: 0.55rem;
            letter-spacing: 0.04em;
            color: var(--text-muted);
            margin: 0.4rem 0;
        }

        .circle-companion-divider::before,
        .circle-companion-divider::after {
            content: '';
            flex: 1;
            height: 1px;
            background: transparent;
        }

        /* Companion toggle grid adapts columns based on count */
        .companion-toggle-grid {
            grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
        }

        .companion-toggle-grid:empty {
            display: none;
        }

        .sovereign-glyph {
            font-size: 1.2rem;
            line-height: 1;
            transition: all 0.25s ease;
            text-shadow: 0 0 8px currentColor;
        }

        .sovereign-toggle.active .sovereign-glyph {
            transform: scale(1.15);
            text-shadow: 0 0 16px currentColor;
        }

        .sovereign-label {
            font-family: var(--font-display);
            font-size: 0.6rem;
            letter-spacing: 0.02em;
            font-weight: 500;
        }

        .circle-preview {
            display: flex;
            align-items: center;
            gap: 0.75rem;
            padding: 0.6rem 0.75rem;
            background: var(--bg-tertiary);
            border-radius: 10px;
            margin-bottom: 0.6rem;
            min-height: 2.75rem;
            transition: all 0.25s ease;
            border: 1px solid transparent;
        }

        .circle-preview.has-selection {
            background: var(--bg-elevated);
            border-color: var(--border-subtle);
        }

        .circle-indicator {
            width: 10px;
            height: 10px;
            border-radius: 50%;
            background: var(--border-light);
            flex-shrink: 0;
            transition: all 0.3s ease;
        }

        .circle-preview.has-selection .circle-indicator {
            width: 12px;
            height: 12px;
            box-shadow: 0 0 12px currentColor, 0 0 24px currentColor;
        }

        .circle-info {
            display: flex;
            flex-direction: column;
            gap: 0.15rem;
            flex: 1;
            min-width: 0;
        }

        .circle-name {
            font-family: var(--font-display);
            font-size: 0.85rem;
            color: var(--text-secondary);
            font-weight: 500;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            transition: color 0.2s ease;
        }

        .circle-preview.has-selection .circle-name {
            color: var(--text-primary);
        }

        .circle-description {
            font-size: 0.7rem;
            color: var(--text-muted);
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .invoke-btn {
            width: 100%;
            padding: 0.75rem 1rem;
            background: var(--bg-tertiary);
            border: 1px solid transparent;
            border-radius: 10px;
            color: var(--text-muted);
            font-family: var(--font-display);
            font-size: 0.85rem;
            font-weight: 500;
            letter-spacing: 0.08em;
            cursor: not-allowed;
            transition: all 0.3s ease;
            position: relative;
            overflow: hidden;
        }

        .invoke-btn::before {
            content: '';
            position: absolute;
            inset: 0;
            background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.1) 50%, transparent 100%);
            transform: translateX(-100%);
            transition: transform 0.6s ease;
        }

        .invoke-btn:not(:disabled) {
            cursor: pointer;
            color: var(--text-primary);
            border-color: var(--accent);
            background: linear-gradient(135deg, var(--accent-subtle) 0%, transparent 100%);
            box-shadow: 0 0 15px var(--accent-subtle);
        }

        .invoke-btn:not(:disabled):hover {
            background: linear-gradient(135deg, var(--accent-subtle) 0%, var(--accent-subtle) 100%);
            box-shadow: 0 0 25px var(--accent-glow), 0 4px 20px rgba(0, 0, 0, 0.3);
            transform: translateY(-2px);
        }

        .invoke-btn:not(:disabled):hover::before {
            transform: translateX(100%);
        }

        .invoke-btn:not(:disabled):active {
            transform: translateY(0);
            box-shadow: 0 0 15px var(--accent-subtle);
        }

        /* ============================================
           SOVEREIGN PORTRAITS (Glyph or Image)
           ============================================ */

        .sovereign-portrait {
            width: 2.5rem;
            height: 2.5rem;
            display: flex;
            align-items: center;
            justify-content: center;
            color: var(--accent);
            text-shadow: none;
            border-radius: 50%;
            background: var(--bg-tertiary);
            border: 1px solid var(--border-light);
            cursor: pointer;
            box-shadow: none;
            transition: border-color 0.2s ease, opacity 0.2s ease;
            flex-shrink: 0;
            position: relative;
        }

        /* Subtle ring accent */
        .sovereign-portrait::after {
            content: '';
            position: absolute;
            inset: -4px;
            border-radius: 50%;
            border: 1px solid transparent;
            pointer-events: none;
        }

        .sovereign-portrait:hover {
            border-color: var(--border-medium);
            opacity: 0.9;
            transform: none;
        }

        .sovereign-portrait.has-image {
            padding: 0;
            overflow: hidden;
        }

        .sovereign-portrait img {
            width: 100%;
            height: 100%;
            object-fit: cover;
            border-radius: 50%;
        }

        .portrait-glyph {
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 1.2rem;
            line-height: 1;
            font-style: normal;
        }

        .sovereign-portrait.lumen {
            color: var(--accent);
            text-shadow: 0 0 8px var(--accent-glow);
        }

        .sovereign-portrait.lilith {
            color: var(--accent);
            text-shadow: 0 0 8px var(--accent-glow);
        }

        .sovereign-portrait.luna {
            color: var(--accent);
            text-shadow: 0 0 8px var(--accent-glow);
        }

        .sovereign-portrait.lira {
            color: var(--accent);
            text-shadow: 0 0 8px var(--accent-glow);
        }

        .sovereign-portrait.quartet,
        .sovereign-portrait.lumen-lilith,
        .sovereign-portrait.lumen-luna,
        .sovereign-portrait.lilith-lira,
        .sovereign-portrait.luna-lira,
        .sovereign-portrait.lumen-lilith-luna,
        .sovereign-portrait.lilith-luna-lira {
            font-size: 1rem;
            letter-spacing: -0.1em;
        }

        .header-identity-text {
            display: flex;
            flex-direction: column;
            gap: 0.25rem;
        }

        /* ============================================
           IMAGE PREVIEW
           ============================================ */

        .image-preview {
            max-width: 120px;
            max-height: 80px;
            border-radius: 6px;
            overflow: hidden;
            border: 1px solid var(--border-light);
            margin-bottom: 0.5rem;
        }

        .image-preview img {
            width: 100%;
            height: 100%;
            object-fit: cover;
        }

        .file-attachment.has-image {
            flex-direction: row;
            align-items: center;
            flex-wrap: wrap;
        }

        .file-attachment .file-info {
            display: flex;
            align-items: center;
            gap: 0.5rem;
            width: 100%;
        }

        /* ============================================
           THINKING BLOCKS
           ============================================ */

        .thinking-block {
            margin-bottom: 1rem;
            border: 1px solid var(--border-subtle);
            border-radius: 6px;
            background: rgba(107, 91, 149, 0.05);
            overflow: hidden;
        }

        .thinking-block-header {
            display: flex;
            align-items: center;
            gap: 0.5rem;
            padding: 0.5rem 0.75rem;
            background: rgba(107, 91, 149, 0.1);
            cursor: pointer;
            user-select: none;
            font-size: 0.75rem;
            color: var(--text-secondary);
            transition: background 0.2s ease;
        }

        .thinking-block-header:hover {
            background: rgba(107, 91, 149, 0.15);
        }

        .thinking-icon {
            color: var(--accent);
        }

        .thinking-toggle {
            margin-left: auto;
            transition: transform 0.2s ease;
        }

        .thinking-block.collapsed .thinking-toggle {
            transform: rotate(-90deg);
        }

        .thinking-block-content {
            padding: 0.75rem;
            font-size: 0.8rem;
            color: var(--text-secondary);
            border-top: 1px solid var(--border-subtle);
            max-height: 300px;
            overflow-y: auto;
        }

        .thinking-block.collapsed .thinking-block-content {
            display: none;
        }

        /* ============================================
           KEYBOARD SHORTCUTS MODAL
           ============================================ */

        .shortcuts-modal {
            max-width: 400px;
        }

        .shortcuts-list {
            display: flex;
            flex-direction: column;
            gap: 0.5rem;
        }

        .shortcut-item {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 0.5rem 0;
            border-bottom: 1px solid var(--border-subtle);
        }

        .shortcut-item:last-child {
            border-bottom: none;
        }

        .shortcut-keys {
            display: flex;
            gap: 0.25rem;
        }

        .shortcut-keys kbd {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            min-width: 1.5rem;
            padding: 0.25rem 0.5rem;
            background: var(--bg-tertiary);
            border: 1px solid var(--border-light);
            border-radius: var(--radius);
            font-family: inherit;
            font-size: 0.75rem;
            color: var(--text-primary);
            box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
        }

        .shortcut-desc {
            font-size: 0.85rem;
            color: var(--text-secondary);
        }

        .shortcuts-note {
            margin-top: 1rem;
            padding-top: 0.75rem;
            border-top: 1px solid var(--border-subtle);
            font-size: 0.75rem;
            color: var(--text-muted);
            text-align: center;
        }

        .shortcuts-note kbd {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            min-width: 1.25rem;
            padding: 0.15rem 0.35rem;
            background: var(--bg-tertiary);
            border: 1px solid var(--border-light);
            border-radius: 3px;
            font-family: inherit;
            font-size: 0.7rem;
            color: var(--text-secondary);
        }

        /* ============================================
           SETTINGS TOGGLE ROWS
           ============================================ */

        .settings-toggle-row {
            display: flex;
            align-items: center;
            gap: 0.75rem;
            padding: 0.5rem 0;
        }

        .settings-toggle-row label {
            flex: 1;
            font-size: 0.75rem;
            color: var(--text-primary);
        }

        .settings-toggle-row input[type="checkbox"] {
            width: 1rem;
            height: 1rem;
            accent-color: var(--accent);
            cursor: pointer;
        }

        .settings-toggle-row .toggle-hint {
            width: 100%;
            font-size: 0.7rem;
            color: var(--text-muted);
            margin-top: 0.25rem;
            display: block;
        }

        .settings-toggle-row.disabled {
            opacity: 0.5;
            pointer-events: none;
        }

        .settings-section.disabled {
            opacity: 0.6;
        }

        .coming-soon-badge {
            font-size: 0.6rem;
            padding: 0.15rem 0.4rem;
            background: var(--bg-tertiary);
            border: 1px solid var(--border-light);
            border-radius: 3px;
            color: var(--text-muted);
            margin-left: 0.5rem;
            letter-spacing: 0.02em;
        }

        .display-section,
        .audio-section {
            border-top: 1px solid var(--border-subtle);
            padding-top: 1rem;
            margin-top: 0.5rem;
        }

        /* Audio section specific styles */
        .audio-section .settings-row {
            margin-left: 0.5rem;
            padding-left: 0.5rem;
            border-left: 2px solid var(--border-subtle);
        }

        .audio-section .settings-row label {
            width: 70px;
        }

        .audio-section .settings-row select {
            max-width: 200px;
        }

        .audio-section .settings-row input[type="password"] {
            font-family: monospace;
            letter-spacing: 0.1em;
        }

        .audio-section .key-hint {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            width: 16px;
            height: 16px;
            font-size: 0.65rem;
            background: var(--bg-tertiary);
            border: 1px solid var(--border-subtle);
            border-radius: 50%;
            color: var(--text-muted);
            cursor: help;
            flex-shrink: 0;
        }

        .audio-section .key-hint:hover {
            background: var(--bg-secondary);
            color: var(--text-secondary);
        }

        .audio-section .settings-row input[type="range"] {
            flex: 1;
            max-width: 120px;
            height: 4px;
            background: var(--bg-tertiary);
            border-radius: 2px;
            -webkit-appearance: none;
            appearance: none;
        }

        .audio-section .settings-row input[type="range"]::-webkit-slider-thumb {
            -webkit-appearance: none;
            appearance: none;
            width: 14px;
            height: 14px;
            border-radius: 50%;
            background: var(--accent);
            cursor: pointer;
            border: 2px solid var(--bg-primary);
            box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
        }

        .audio-section .settings-row input[type="range"]::-webkit-slider-thumb:hover {
            transform: scale(1.1);
        }

        .audio-section .settings-row span {
            font-size: 0.7rem;
            color: var(--text-muted);
            min-width: 30px;
            text-align: right;
        }

        .audio-section .cloud-voice-hint {
            padding: 0.4rem 0.5rem;
            background: var(--bg-tertiary);
            border-radius: var(--radius);
            margin-left: 0.5rem;
        }

        .audio-section .cloud-voice-hint .hint-text {
            font-size: 0.68rem;
            color: var(--text-muted);
            font-style: italic;
        }

        /* Piper TTS Styles */
        .piper-status {
            font-size: 0.7rem;
            padding: 0.25rem 0.5rem;
            border-radius: var(--radius);
            background: var(--bg-tertiary);
        }

        .piper-status.installed {
            color: #4ade80;
            background: rgba(74, 222, 128, 0.1);
        }

        .piper-status.not-installed {
            color: var(--text-muted);
        }

        .piper-status.error {
            color: #f87171;
            background: rgba(248, 113, 113, 0.1);
        }

        .piper-progress-container {
            flex: 1;
            height: 6px;
            background: var(--bg-tertiary);
            border-radius: 3px;
            overflow: hidden;
            margin-right: 0.5rem;
        }

        .piper-progress-bar {
            height: 100%;
            width: 0%;
            background: linear-gradient(90deg, var(--accent), var(--accent-secondary));
            border-radius: 3px;
            transition: width 0.3s ease;
        }

        #piperProgressText {
            font-size: 0.65rem;
            min-width: 100px;
        }

        #piperInstallBtn {
            font-size: 0.7rem;
            padding: 0.4rem 0.8rem;
        }

        .portrait-hint {
            display: flex;
            align-items: center;
            gap: 0.5rem;
            padding: 0.5rem 0.625rem;
            background: var(--bg-tertiary);
            border-radius: 5px;
            font-size: 0.7rem;
            color: var(--text-muted);
            margin-top: 0.625rem;
        }

        .portrait-hint .hint-icon {
            color: var(--accent);
            font-size: 0.9rem;
            opacity: 0.7;
        }

        .reset-portraits-btn {
            margin-left: auto;
            padding: 0.25rem 0.5rem;
            background: transparent;
            border: 1px solid var(--border-subtle);
            border-radius: var(--radius);
            color: var(--text-muted);
            font-size: 0.65rem;
            cursor: pointer;
            transition: all 0.15s ease;
        }

        .reset-portraits-btn:hover {
            border-color: var(--border-light);
            color: var(--text-secondary);
            background: rgba(255, 255, 255, 0.02);
        }

        /* ============================================
           USER PROFILE SECTION
           ============================================ */

        .user-profile-section {
            border-top: 1px solid var(--border-subtle);
            padding-top: 1rem;
            margin-top: 0.5rem;
        }

        .user-profile-section .section-description {
            font-size: 0.68rem;
            color: var(--text-muted);
            margin: 0 0 0.75rem 0;
            line-height: 1.4;
        }

        .user-profile-field {
            margin-bottom: 0.875rem;
            display: flex;
            flex-direction: column;
        }

        .user-profile-field .field-header {
            display: flex;
            justify-content: space-between;
            align-items: baseline;
            margin-bottom: 0.375rem;
        }

        .user-profile-field .field-label {
            font-size: 0.75rem;
            color: var(--text-secondary);
            font-weight: 500;
            letter-spacing: 0.01em;
        }

        .user-profile-field .field-char-count {
            font-size: 0.65rem;
            color: var(--text-muted);
            font-variant-numeric: tabular-nums;
        }

        .user-profile-field .field-char-count.near-limit {
            color: #d4a000;
        }

        .user-profile-field .field-char-count.at-limit {
            color: #e05050;
        }

        .user-profile-field textarea {
            width: 100%;
            padding: 0.5rem 0.625rem;
            background: var(--bg-tertiary);
            border: 1px solid var(--border-subtle);
            border-radius: 6px;
            color: var(--text-primary);
            font-family: inherit;
            font-size: 0.8rem;
            line-height: 1.45;
            resize: none;
            transition: border-color 0.2s ease, background-color 0.2s ease;
            box-sizing: border-box;
        }

        .user-profile-field textarea#userProfileShort {
            height: 52px;
        }

        .user-profile-field textarea#userProfileLong {
            height: 72px;
        }

        .user-profile-field textarea:hover {
            border-color: var(--border-light);
        }

        .user-profile-field textarea:focus {
            outline: none;
            border-color: var(--accent);
            background: rgba(255, 255, 255, 0.02);
        }

        .user-profile-field textarea::placeholder {
            color: var(--text-muted);
            opacity: 0.6;
            font-size: 0.75rem;
        }

        .profile-inject-info {
            display: flex;
            align-items: center;
            gap: 0.5rem;
            padding: 0.5rem 0.625rem;
            background: var(--bg-tertiary);
            border-radius: 5px;
            font-size: 0.7rem;
            margin-top: 0.25rem;
        }

        .inject-status {
            color: var(--text-muted);
            display: flex;
            align-items: center;
            gap: 0.4rem;
        }

        .inject-status::before {
            content: '';
            display: inline-block;
            width: 5px;
            height: 5px;
            border-radius: 50%;
            background: var(--accent);
            opacity: 0.6;
            flex-shrink: 0;
        }

        /* ============================================
           TOGGLE SWITCH (iOS-style)
           ============================================ */

        .toggle-switch {
            position: relative;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            width: 38px;
            min-width: 38px;
            max-width: 38px;
            height: 22px;
            flex-shrink: 0;
            flex-grow: 0;
        }

        .toggle-switch input {
            opacity: 0;
            width: 0;
            height: 0;
            position: absolute;
            pointer-events: none;
        }

        .toggle-slider {
            position: absolute;
            cursor: pointer;
            top: 0;
            left: 0;
            width: 38px;
            height: 22px;
            background-color: var(--bg-tertiary);
            border: 1px solid var(--border-light);
            transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
            border-radius: 22px;
            box-sizing: border-box;
        }

        .toggle-slider::before {
            position: absolute;
            content: "";
            height: 16px;
            width: 16px;
            left: 2px;
            top: 50%;
            transform: translateY(-50%);
            background-color: var(--text-muted);
            transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
            border-radius: 50%;
            box-shadow: 0 1px 3px rgba(0,0,0,0.2);
        }

        .toggle-switch input:checked + .toggle-slider {
            background-color: var(--accent);
            border-color: var(--accent);
        }

        .toggle-switch input:checked + .toggle-slider::before {
            transform: translateY(-50%) translateX(16px);
            background-color: #fff;
        }

        .toggle-switch:hover .toggle-slider {
            border-color: var(--text-muted);
        }

        .toggle-switch input:focus-visible + .toggle-slider {
            box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.1);
        }

        /* Disabled toggle switches */
        .toggle-switch input:disabled + .toggle-slider {
            opacity: 0.4;
            cursor: not-allowed;
        }

        .toggle-switch input:disabled + .toggle-slider::before {
            background-color: var(--text-muted);
        }

        /* Settings toggle row layout */
        .settings-toggle-row {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 0.5rem 0;
            gap: 1rem;
        }

        .settings-toggle-row > label:first-child {
            flex: 1;
            font-size: 0.75rem;
            color: var(--text-primary);
            cursor: default;
        }

        .settings-toggle-row > .toggle-switch {
            flex: 0 0 38px;
        }

        .display-section .toggle-hint {
            display: block;
            font-size: 0.68rem;
            color: var(--text-muted);
            margin-top: 0;
            margin-bottom: 0.75rem;
            padding-left: 0;
            opacity: 0.8;
        }

        /* ============================================
           LIGHT THEME - Clean neutral light mode
           ============================================ */

        body.theme-light {
            /* Clean light mode */
            --bg-primary: #F5F5F5;
            --bg-secondary: #FFFFFF;
            --bg-tertiary: #F0F0F0;
            --bg-elevated: #FFFFFF;
            --bg-surface: #EBEBEB;
            --border-subtle: rgba(0, 0, 0, 0.07);
            --border-light: rgba(0, 0, 0, 0.12);
            --border-medium: rgba(0, 0, 0, 0.20);
            --text-primary: #111111;
            --text-secondary: #666666;
            --text-muted: #999999;
            --panel-gradient: linear-gradient(180deg, #FFFFFF 0%, #F5F5F5 100%);
            --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
            --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.10);
            --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);
            --shadow-inset: inset 0 2px 4px rgba(0, 0, 0, 0.05);
        }

        body.theme-light #ambientCanvas {
            opacity: 0.15;
        }

        /* Light mode: grain overlay removed (arcane skin handles this in skin-arcane.css) */

        body.theme-light .sidebar {
            background: var(--bg-secondary);
            border-right: none;
            box-shadow: none;
        }

        body.theme-light .sidebar-header {
            background: transparent;
        }

        body.theme-light .chat-header {
            background: var(--bg-secondary);
            box-shadow: var(--shadow-sm);
        }

        body.theme-light .main {
            background: var(--bg-primary);
        }

        body.theme-light::before {
            background:
                radial-gradient(ellipse at top left, rgba(155, 123, 60, 0.06) 0%, transparent 40%),
                radial-gradient(ellipse at top right, rgba(155, 123, 60, 0.06) 0%, transparent 40%),
                radial-gradient(ellipse at bottom left, rgba(155, 123, 60, 0.04) 0%, transparent 40%),
                radial-gradient(ellipse at bottom right, rgba(155, 123, 60, 0.04) 0%, transparent 40%),
                radial-gradient(ellipse at center, transparent 40%, rgba(80, 60, 30, 0.03) 70%, rgba(80, 60, 30, 0.06) 100%);
            opacity: 0.5;
        }

        body.theme-light .chat-item {
            background: transparent;
            border-color: transparent;
        }

        body.theme-light .chat-item:hover {
            background: var(--bg-tertiary);
        }

        body.theme-light .chat-item.active {
            background: var(--accent-subtle);
        }

        body.theme-light .message.user {
            background: #EBEBEB;
            border: none;
            box-shadow: none;
            border-radius: 18px;
            max-width: 62%;
            padding: 0.8rem 1.1rem;
        }

        /* Light mode assistant messages — no box, clean text like Claude */
        body.theme-light .message.assistant {
            background: transparent;
            border: none;
            box-shadow: none;
            padding-top: 0.25rem;
            padding-bottom: 0.25rem;
            max-width: 84%;
        }

        body.theme-light .message.assistant.lumen,
        body.theme-light .message.assistant.lilith,
        body.theme-light .message.assistant.luna,
        body.theme-light .message.assistant.lira {
            box-shadow: none;
        }

        body.theme-light .invocation::before {
            border-color: var(--border-light);
            opacity: 0.25;
            background:
                radial-gradient(circle, transparent 38%, var(--accent-subtle) 48%, transparent 51%),
                radial-gradient(circle, transparent 63%, rgba(155, 123, 60, 0.06) 66%, transparent 69%),
                radial-gradient(circle, var(--accent-glow) 0%, transparent 40%);
        }

        body.theme-light .input-container {
            background: var(--bg-secondary);
            border-top-color: var(--border-subtle);
        }

        body.theme-light #messageInput {
            background: var(--bg-tertiary);
            border-color: var(--border-subtle);
        }

        body.theme-light #sendBtn {
            box-shadow: var(--shadow-sm);
        }

        body.theme-light #sendBtn:hover {
            box-shadow: 0 0 15px var(--accent-glow), var(--shadow-md);
        }

        body.theme-light .modal-content {
            background: var(--bg-secondary);
            border-color: var(--border-subtle);
            box-shadow: var(--shadow-lg);
        }

        body.theme-light .modal-overlay {
            background: rgba(30, 25, 20, 0.5);
        }

        body.theme-light .backup-section {
            background: linear-gradient(135deg, rgba(139, 105, 20, 0.06), rgba(139, 105, 20, 0.02));
            border-color: rgba(139, 105, 20, 0.2);
        }

        body.theme-light .backup-section h4 {
            color: var(--text-primary);
        }

        body.theme-light .backup-btn {
            background: var(--accent-subtle) !important;
            border-color: var(--border-light) !important;
            color: var(--text-primary) !important;
        }

        body.theme-light .backup-btn:hover {
            background: var(--bg-elevated) !important;
        }

        body.theme-light .restore-btn {
            background: var(--bg-tertiary) !important;
            border-color: var(--border-subtle) !important;
            color: var(--text-secondary) !important;
        }

        body.theme-light .restore-btn:hover {
            background: var(--bg-elevated) !important;
        }

        body.theme-light .header-btn {
            background: transparent;
            border-color: transparent;
            color: var(--text-muted);
        }

        body.theme-light .header-btn:hover {
            color: var(--text-primary);
            background: var(--bg-tertiary);
        }

        body.theme-light .modal-btn-secondary {
            background: transparent;
            color: var(--text-secondary);
        }

        body.theme-light .thinking-indicator {
            background: linear-gradient(135deg, rgba(90, 61, 139, 0.08) 0%, rgba(90, 61, 139, 0.04) 100%);
            border-color: rgba(90, 61, 139, 0.15);
        }

        body.theme-light .thinking-block {
            background: rgba(90, 61, 139, 0.03);
        }

        body.theme-light .thinking-block-header {
            background: rgba(90, 61, 139, 0.05);
        }

        /* Skin selector */
        .skin-btn-group {
            display: flex;
            gap: 4px;
        }
        .skin-btn {
            padding: 4px 12px;
            border-radius: var(--radius);
            border: 1px solid var(--border-light);
            background: transparent;
            color: var(--text-secondary);
            cursor: pointer;
            font-size: 0.8rem;
            transition: all 0.2s;
        }
        .skin-btn.active,
        .skin-btn:hover {
            background: var(--accent-subtle);
            border-color: var(--accent);
            color: var(--accent);
        }

        /* Summon-tab notice banner — uses CSS vars so it adapts to clean/arcane/light/dark */
        .summon-notice {
            padding: 12px 14px;
            background: var(--accent-subtle);
            border: 1px solid var(--border-light);
            border-radius: var(--radius-sm, 6px);
        }

        .summon-notice-icon {
            font-size: 12px;
            color: var(--accent);
            opacity: 0.8;
        }

        .summon-notice-title {
            color: var(--text-secondary);
            font-size: 13px;
            font-family: var(--font-ui);
            font-weight: 600;
        }

        .summon-notice-link {
            color: var(--text-secondary);
            font-size: 12px;
            text-decoration: underline;
            opacity: 0.75;
            transition: opacity 0.15s;
        }

        .summon-notice-link:hover {
            opacity: 1;
            color: var(--text-primary);
        }

        /* Arcane skin: restore gold accent on the notice */
        body.skin-arcane .summon-notice {
            background: rgba(218, 165, 32, 0.07);
            border-color: rgba(218, 165, 32, 0.25);
        }

        body.skin-arcane .summon-notice-title {
            color: #daa520;
        }

        body.skin-arcane .summon-notice-link {
            color: #daa520;
            opacity: 1;
        }

        /* Theme toggle button */
        .theme-toggle-btn {
            background: transparent;
            border: 1px solid transparent;
            color: var(--text-secondary);
            padding: 0.35rem 0.6rem;
            border-radius: var(--radius);
            cursor: pointer;
            font-family: var(--font-display);
            font-size: 0.7rem;
            font-weight: 600;
            letter-spacing: 0.05em;
            transition: all 0.15s ease;
            display: flex;
            align-items: center;
            gap: 0.3rem;
            /* Desaturate the emoji so it matches the muted toolbar style */
            filter: grayscale(1) opacity(0.5);
        }

        .theme-toggle-btn:hover {
            border-color: var(--border-light);
            color: var(--text-primary);
            filter: grayscale(0) opacity(0.85);
        }

        body.theme-light .theme-toggle-btn {
            color: var(--text-secondary);
        }

        /* Light mode: conversation search overlay */
        body.theme-light .conversation-search-overlay {
            background: linear-gradient(180deg, var(--bg-secondary) 0%, rgba(240, 235, 224, 0.98) 100%);
            box-shadow: 0 4px 20px rgba(80, 60, 30, 0.15);
        }

        /* Light mode: sidebar footer */
        body.theme-light .sidebar-footer {
            background: transparent;
            border-top: none;
        }

        body.theme-light .settings-row select,
        body.theme-light .settings-row input[type="text"],
        body.theme-light .settings-row input[type="password"] {
            background: var(--bg-secondary);
        }

        body.theme-light .preset-chip {
            background: var(--bg-secondary);
        }
        body.theme-light .preset-chip:hover {
            background: var(--bg-tertiary);
        }
        body.theme-light .preset-chip.active {
            background: var(--accent);
            border-color: var(--accent);
            color: #fff;
        }
        body.theme-light .advanced-section {
            border-top-color: var(--border-subtle);
        }

        /* Light mode: input container */
        body.theme-light .input-container {
            box-shadow:
                inset 0 2px 8px rgba(80, 60, 30, 0.06),
                inset 0 -2px 4px rgba(255, 255, 255, 0.3);
        }

        /* Light mode: invocation text readability */
        body.theme-light .invocation .invocation-text {
            text-shadow: none;
            color: var(--text-secondary);
        }

        body.theme-light .invocation .sovereign-title-display {
            text-shadow:
                0 1px 0 rgba(255, 255, 255, 0.8),
                0 0 30px var(--accent-glow),
                0 0 60px var(--accent-glow);
        }

        /* Clean skin: minimal label — just name + title, no atmospheric content */
        body:not(.skin-arcane) .invocation::before,
        body:not(.skin-arcane) .invocation::after {
            display: none;
        }

        body:not(.skin-arcane) .invocation {
            animation: invocationFadeClean 0.5s ease-out both;
            background: none;
            gap: 4px;
            min-height: 40vh;
        }

        @keyframes invocationFadeClean {
            from { opacity: 0; transform: translateY(6px); }
            to   { opacity: 1; transform: translateY(0); }
        }

        body:not(.skin-arcane) .invocation .sovereign-title-display {
            font-family: var(--font-ui);
            font-size: 0.9rem;
            font-weight: 500;
            color: var(--text-secondary);
            text-shadow: none;
            animation: none;
            letter-spacing: 0.12em;
            text-transform: uppercase;
            opacity: 0.6;
            line-height: 1;
        }

        body:not(.skin-arcane) .invocation .invocation-text {
            display: none;
        }

        /* Subtitle line in clean empty state (sovereign title/role) */
        .invocation-subtitle {
            font-family: var(--font-ui);
            font-size: 0.72rem;
            color: var(--text-muted);
            letter-spacing: 0.04em;
            opacity: 0.55;
            line-height: 1;
        }

        /* Light mode: arcane apparatus adjustments */
        body.theme-light .arcane-apparatus .outer-ring {
            box-shadow:
                inset 0 0 20px rgba(80, 60, 30, 0.15),
                0 0 15px var(--accent-subtle);
        }

        body.theme-light .arcane-apparatus .middle-ring {
            box-shadow: inset 0 0 15px rgba(80, 60, 30, 0.1);
        }

        body.theme-light .arcane-apparatus .inner-ring {
            box-shadow:
                0 0 12px var(--accent-glow),
                0 0 24px var(--accent-glow);
        }

        body.theme-light .arcane-apparatus .arcane-core {
            box-shadow:
                0 0 20px var(--accent-glow),
                0 0 40px var(--accent-glow),
                inset 0 -8px 16px rgba(0, 0, 0, 0.15),
                inset 0 4px 8px rgba(255, 255, 255, 0.6);
        }

        body.theme-light .arcane-apparatus .gear {
            box-shadow:
                inset 0 2px 4px rgba(255, 255, 255, 0.5),
                inset 0 -2px 4px rgba(0, 0, 0, 0.15),
                0 2px 6px rgba(80, 60, 30, 0.2);
        }

        /* Light mode: message user rivets (arcane only) */

        /* Light mode: error notification */
        body.theme-light .error-notification {
            background: rgba(248, 113, 113, 0.08);
            box-shadow: 0 4px 16px rgba(80, 60, 30, 0.1);
        }

        /* Light mode: connection toast */
        body.theme-light .connection-toast {
            background: var(--bg-elevated);
            box-shadow: 0 4px 20px rgba(80, 60, 30, 0.12);
        }

        /* Light mode: seed popup */
        body.theme-light .seed-popup {
            background: var(--bg-secondary);
            box-shadow: 0 8px 32px rgba(80, 60, 30, 0.15);
        }

        /* Light mode: typing indicator dots */
        body.theme-light .typing-indicator span:not(.typing-text) {
            box-shadow: 0 0 8px var(--accent-glow);
        }

        /* Light mode: context meter */
        body.theme-light .context-bar {
            background: rgba(139, 105, 20, 0.12);
        }

        /* Light mode: sidebar rail glow (arcane only) */
        body.theme-light .sidebar::after {
            display: none;
        }

        /* Light mode: sovereign & element toggle boxes — clean look */
        body.theme-light .sovereign-toggle,
        body.theme-light .element-toggle {
            background: rgba(0, 0, 0, 0.04);
            border-color: transparent;
            box-shadow: none;
        }

        body.theme-light .sovereign-toggle:hover,
        body.theme-light .element-toggle:hover {
            background: rgba(0, 0, 0, 0.08);
            border-color: transparent;
        }

        body.theme-light .sovereign-glyph {
            text-shadow: none;
        }

        body.theme-light .sovereign-toggle.active .sovereign-glyph {
            text-shadow: none;
        }

        /* ============================================
           TIME GAP DIVIDERS
           ============================================ */

        .time-gap-divider {
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 1rem;
            padding: 0.5rem 0;
            color: var(--text-muted);
            font-size: 0.7rem;
            opacity: 0.7;
        }

        .time-gap-divider::before,
        .time-gap-divider::after {
            content: '';
            flex: 1;
            height: 1px;
            background: linear-gradient(90deg, transparent, var(--border-light), transparent);
        }

        .time-gap-divider span {
            white-space: nowrap;
            font-style: italic;
        }

        /* ============================================
           MESSAGE REACTIONS
           ============================================ */

        /* Reaction trigger button — smiley face in message action bar */
        .react-trigger-btn {
            opacity: 0.5;
        }
        .react-trigger-btn:hover {
            opacity: 1;
        }

        /* User reaction emoji badges shown above the message footer */
        .message-reactions-display {
            display: flex;
            flex-wrap: wrap;
            gap: 0.25rem;
            margin-top: 0.35rem;
            padding: 0 0.25rem;
        }

        .reaction-badge {
            font-size: 1rem;
            padding: 0.15rem 0.4rem;
            border-radius: 12px;
            background: var(--bg-tertiary);
            border: 1px solid var(--border-subtle);
            cursor: pointer;
            transition: background 0.12s ease, border-color 0.12s ease;
            line-height: 1.4;
            user-select: none;
        }

        .reaction-badge:hover {
            background: var(--bg-secondary);
            border-color: var(--accent);
        }

        /* Companion-initiated reaction badge on user messages */
        .companion-react-badge {
            position: absolute;
            bottom: -10px;
            right: 6px;
            font-size: 1.1rem;
            line-height: 1;
            background: var(--bg-secondary);
            border: 1px solid var(--border-subtle);
            border-radius: 10px;
            padding: 2px 4px;
            pointer-events: none;
            z-index: 2;
        }

        /* ── Emoji Picker Popover ── */
        .emoji-picker-popover {
            position: fixed;
            z-index: 9999;
            background: var(--bg-secondary, #1a1a1a);
            border: 1px solid var(--border-subtle, rgba(255,255,255,0.1));
            border-radius: 10px;
            box-shadow: 0 8px 32px rgba(0,0,0,0.4);
            width: 272px;
            overflow: hidden;
            display: flex;
            flex-direction: column;
        }

        .emoji-picker-tabs {
            display: flex;
            flex-wrap: wrap;
            gap: 2px;
            padding: 6px 6px 0;
            border-bottom: 1px solid var(--border-subtle, rgba(255,255,255,0.08));
        }

        .emoji-picker-tab {
            background: transparent;
            border: none;
            color: var(--text-muted, #888);
            padding: 4px 8px;
            border-radius: 6px;
            cursor: pointer;
            font-size: 0.68rem;
            font-weight: 500;
            transition: background 0.12s, color 0.12s;
            letter-spacing: 0.02em;
        }

        .emoji-picker-tab:hover {
            background: var(--bg-tertiary, rgba(255,255,255,0.06));
            color: var(--text-primary, #eee);
        }

        .emoji-picker-tab.active {
            background: var(--accent-subtle, rgba(167,139,250,0.15));
            color: var(--accent, #a78bfa);
        }

        .emoji-picker-panel {
            display: grid;
            grid-template-columns: repeat(8, 1fr);
            gap: 1px;
            padding: 6px;
            max-height: 220px;
            overflow-y: auto;
            overflow-x: hidden;
        }

        .emoji-picker-panel::-webkit-scrollbar {
            width: 4px;
        }

        .emoji-picker-panel::-webkit-scrollbar-track {
            background: transparent;
        }

        .emoji-picker-panel::-webkit-scrollbar-thumb {
            background: var(--border-subtle, rgba(255,255,255,0.1));
            border-radius: 2px;
        }

        .emoji-btn {
            background: transparent;
            border: none;
            padding: 4px;
            border-radius: 6px;
            cursor: pointer;
            font-size: 1.1rem;
            line-height: 1;
            transition: background 0.1s ease;
            text-align: center;
        }

        .emoji-btn:hover {
            background: var(--bg-tertiary, rgba(255,255,255,0.06));
        }

        .emoji-btn.active {
            background: var(--accent-subtle, rgba(167,139,250,0.18));
            outline: 1px solid var(--accent, #a78bfa);
        }

        /* ============================================
           MESSAGE NOTES/BOOKMARKS
           ============================================ */

        .message-note-container {
            margin-top: 0.5rem;
            padding: 0.5rem 0.75rem;
            background: rgba(251, 191, 36, 0.08);
            border-left: 2px solid #fbbf24;
            border-radius: 0 4px 4px 0;
            font-size: 0.8rem;
            color: var(--text-secondary);
        }

        .message-note-container .note-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            margin-bottom: 0.25rem;
        }

        .message-note-container .note-label {
            font-size: 0.65rem;
            letter-spacing: 0.02em;
            color: #fbbf24;
            font-weight: 500;
        }

        .message-note-container .note-remove {
            background: transparent;
            border: none;
            color: var(--text-muted);
            cursor: pointer;
            font-size: 0.9rem;
            padding: 0;
            line-height: 1;
            opacity: 0.6;
        }

        .message-note-container .note-remove:hover {
            opacity: 1;
            color: #f87171;
        }

        .note-input-container {
            display: none;
            margin-top: 0.5rem;
        }

        .note-input-container.active {
            display: block;
        }

        .note-input-container textarea {
            width: 100%;
            padding: 0.5rem;
            background: var(--bg-tertiary);
            border: 1px solid var(--border-subtle);
            border-radius: var(--radius);
            color: var(--text-primary);
            font-size: 0.8rem;
            font-family: inherit;
            resize: none;
            height: 60px;
        }

        .note-input-container textarea:focus {
            outline: none;
            border-color: var(--border-light);
        }

        .note-input-actions {
            display: flex;
            justify-content: flex-end;
            gap: 0.5rem;
            margin-top: 0.35rem;
        }

        .note-input-actions button {
            padding: 0.3rem 0.6rem;
            font-size: 0.7rem;
            border-radius: var(--radius);
            cursor: pointer;
        }

        .note-save-btn {
            background: var(--accent);
            border: none;
            color: #fff;
        }

        .note-cancel-btn {
            background: transparent;
            border: 1px solid var(--border-subtle);
            color: var(--text-muted);
        }

        /* ============================================
           IN-CONVERSATION SEARCH
           ============================================ */

        .conversation-search-overlay {
            position: absolute;
            top: 0;
            right: 0;
            left: 0;
            padding: 0.75rem 1rem;
            background: linear-gradient(180deg, var(--bg-secondary) 0%, rgba(15, 15, 18, 0.98) 100%);
            border-bottom: 1px solid var(--border-light);
            display: none;
            align-items: center;
            gap: 0.75rem;
            z-index: 100;
            backdrop-filter: blur(12px);
            box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
        }

        @keyframes slideDown {
            from { 
                opacity: 0; 
                transform: translateY(-100%); 
            }
            to { 
                opacity: 1; 
                transform: translateY(0); 
            }
        }

        .conversation-search-overlay.active {
            display: flex;
            animation: slideDown 0.25s ease-out;
        }

        .conversation-search-overlay .search-icon {
            color: var(--text-muted);
            flex-shrink: 0;
        }

        .conversation-search-overlay input {
            flex: 1;
            min-width: 120px;
            padding: 0.5rem 0.75rem;
            background: var(--bg-tertiary);
            border: 1px solid var(--border-subtle);
            border-radius: 6px;
            color: var(--text-primary);
            font-size: 0.85rem;
            font-family: inherit;
            transition: all 0.2s ease;
        }

        .conversation-search-overlay input:focus {
            outline: none;
            border-color: var(--accent);
            box-shadow: 0 0 0 2px var(--accent-subtle);
        }

        .conversation-search-overlay input::placeholder {
            color: var(--text-muted);
        }

        .search-nav-btns {
            display: flex;
            gap: 0.25rem;
        }

        .search-nav-btn {
            background: var(--bg-tertiary);
            border: 1px solid var(--border-subtle);
            color: var(--text-secondary);
            width: 28px;
            height: 28px;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 6px;
            cursor: pointer;
            font-size: 0.75rem;
            transition: all 0.15s ease;
        }

        .search-nav-btn:hover {
            background: var(--bg-elevated);
            border-color: var(--accent);
            color: var(--accent);
        }

        .search-nav-btn:active {
            transform: scale(0.95);
        }

        .search-nav-btn:disabled {
            opacity: 0.4;
            cursor: not-allowed;
        }

        .search-result-count {
            font-size: 0.75rem;
            color: var(--text-muted);
            white-space: nowrap;
            min-width: 70px;
            text-align: center;
            padding: 0.25rem 0.5rem;
            background: var(--bg-tertiary);
            border-radius: var(--radius);
        }

        .search-result-count:empty {
            display: none;
        }

        .search-close-btn {
            background: transparent;
            border: none;
            color: var(--text-muted);
            cursor: pointer;
            font-size: 1rem;
            padding: 0.35rem;
            border-radius: var(--radius);
            transition: all 0.15s ease;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .search-close-btn:hover {
            color: var(--text-primary);
            background: var(--bg-tertiary);
        }

        .message.search-highlight {
            outline: 2px solid var(--accent);
            outline-offset: 4px;
            border-radius: 8px;
            animation: highlightPulse 0.6s ease-out;
        }

        @keyframes highlightPulse {
            0% { 
                outline-color: var(--accent-glow); 
                outline-offset: 8px;
                outline-width: 4px;
            }
            100% { 
                outline-color: var(--accent);
                outline-offset: 4px;
                outline-width: 2px;
            }
        }

        .message .search-match {
            background: rgba(212, 175, 55, 0.3);
            padding: 0 0.1rem;
            border-radius: 2px;
        }

        /* ============================================
           PRESENCE/ENERGY STATUS
           ============================================ */

        .presence-indicator {
            display: flex;
            align-items: center;
            gap: 0.35rem;
            font-size: 0.65rem;
            color: var(--text-muted);
            margin-left: 0.5rem;
            padding: 0.2rem 0.5rem;
            background: var(--bg-tertiary);
            border-radius: 3px;
        }

        .presence-dot {
            width: 6px;
            height: 6px;
            border-radius: 50%;
            animation: presencePulse 3s ease-in-out infinite;
        }

        .presence-indicator.vibrant .presence-dot {
            background: #4ade80;
            box-shadow: 0 0 6px #4ade80;
        }

        .presence-indicator.active .presence-dot {
            background: #facc15;
            box-shadow: 0 0 6px #facc15;
        }

        .presence-indicator.quiet .presence-dot {
            background: #64748b;
            box-shadow: 0 0 4px #64748b;
        }

        .presence-indicator.dim .presence-dot {
            background: #475569;
            animation: presencePulse 5s ease-in-out infinite;
        }

        .presence-indicator.warm .presence-dot {
            background: #f59e0b;
            box-shadow: 0 0 6px #f59e0b;
        }

        .presence-indicator.intense .presence-dot {
            background: #ef4444;
            box-shadow: 0 0 6px #ef4444;
        }

        .presence-indicator.cool .presence-dot {
            background: #6b7280;
            box-shadow: 0 0 4px #6b7280;
        }

        .presence-indicator.neutral .presence-dot {
            background: #64748b;
            box-shadow: 0 0 4px #64748b;
        }

        @keyframes presencePulse {
            0%, 100% { opacity: 0.6; }
            50% { opacity: 1; }
        }

        /* ============================================
           SWIPE INDICATOR (MOBILE)
           ============================================ */

        .swipe-indicator {
            position: fixed;
            top: 50%;
            transform: translateY(-50%);
            padding: 1rem 0.5rem;
            background: var(--bg-secondary);
            border: 1px solid var(--border-light);
            border-radius: 8px;
            color: var(--text-secondary);
            font-size: 0.75rem;
            z-index: 1005;
            opacity: 0;
            transition: opacity 0.2s ease;
            pointer-events: none;
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 0.25rem;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
        }

        .swipe-indicator.left {
            left: 0.5rem;
        }

        .swipe-indicator.right {
            right: 0.5rem;
        }

        .swipe-indicator.active {
            opacity: 1;
        }

        .swipe-indicator .sovereign-name {
            font-weight: 500;
            color: var(--accent);
        }

        /* ============================================
           MOBILE RESPONSIVE STYLES
           ============================================ */

        /* Mobile menu button (hidden on desktop) */
        .mobile-menu-btn {
            display: none;
            position: fixed;
            top: env(safe-area-inset-top, 12px);
            left: env(safe-area-inset-left, 12px);
            z-index: 1001;
            background: var(--bg-secondary);
            border: 1px solid var(--border-light);
            border-radius: 8px;
            padding: 10px;
            color: var(--text-primary);
            cursor: pointer;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
            transition: all 0.2s ease;
            -webkit-tap-highlight-color: transparent;
        }

        .mobile-menu-btn:active {
            transform: scale(0.95);
            background: var(--bg-tertiary);
        }

        .mobile-menu-btn svg {
            display: block;
        }

        /* Sidebar overlay (hidden on desktop) */
        .sidebar-overlay {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(0, 0, 0, 0.5);
            z-index: 999;
            opacity: 0;
            transition: opacity 0.3s ease;
            -webkit-tap-highlight-color: transparent;
        }

        .sidebar-overlay.active {
            opacity: 1;
        }

        /* Tablet breakpoint */
        @media (max-width: 1024px) {
            .sidebar {
                width: 260px;
            }

            .message {
                max-width: 85%;
            }
        }

        /* Mobile breakpoint - full mobile layout */
        @media (max-width: 768px) {
            /* Safe area support */
            body {
                padding-top: env(safe-area-inset-top, 0);
                padding-bottom: env(safe-area-inset-bottom, 0);
                padding-left: env(safe-area-inset-left, 0);
                padding-right: env(safe-area-inset-right, 0);
            }

            .main {
                touch-action: pan-y pinch-zoom;
                margin-left: 0;
                width: 100%;
                /* Use dynamic viewport height so layout shrinks when keyboard appears */
                height: 100dvh;
                height: 100svh; /* fallback: small viewport (excludes browser chrome) */
            }

            /* Prevent sidebar "Ensoul" title from hiding behind hamburger button */
            .sidebar-header {
                padding-left: 64px;
            }

            /* Show mobile menu button */
            .mobile-menu-btn {
                display: flex;
                align-items: center;
                justify-content: center;
            }

            /* Show overlay */
            .sidebar-overlay {
                display: block;
                pointer-events: none;
            }

            .sidebar-overlay.active {
                pointer-events: auto;
            }

            /* Sidebar as off-canvas drawer */
            .sidebar {
                position: fixed;
                top: 0;
                left: 0;
                bottom: 0;
                width: 85%;
                max-width: 320px;
                transform: translateX(-100%);
                transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
                z-index: 1000;
                padding-top: calc(env(safe-area-inset-top, 0) + 10px);
                padding-bottom: env(safe-area-inset-bottom, 0);
                overflow-y: auto;
                -webkit-overflow-scrolling: touch;
            }

            .sidebar.open {
                transform: translateX(0);
                box-shadow: 4px 0 20px rgba(0, 0, 0, 0.3);
            }

            /* Compact header for mobile */
            .chat-header {
                padding: 12px 16px;
                padding-top: calc(env(safe-area-inset-top, 12px) + 12px);
                padding-left: 60px; /* Space for hamburger menu */
                flex-wrap: wrap;
                gap: 8px;
            }

            .header-identity {
                flex: 1 1 auto;
            }

            .sovereign-portrait {
                width: 36px;
                height: 36px;
                font-size: 1rem;
            }

            .sovereign-name {
                font-size: 1rem;
            }

            .sovereign-title {
                display: none; /* Hide title on small screens */
            }

            .header-actions {
                flex-basis: 100%;
                justify-content: flex-start;
                gap: 6px;
                overflow-x: auto;
                padding-bottom: 4px;
                -webkit-overflow-scrolling: touch;
            }

            .header-btn {
                min-width: 44px;
                min-height: 44px;
                padding: 10px 12px;
                font-size: 0.75rem;
                flex-shrink: 0;
            }

            /* Full-width messages */
            .message {
                max-width: 90%;
                padding: 12px 14px;
                font-size: 0.95rem;
            }

            .message.user {
                max-width: 85%;
            }

            /* Chat container */
            .chat-container {
                padding: 16px;
                padding-bottom: 140px; /* Space for input */
            }

            /* Input area with safe area padding */
            .input-container {
                padding: 12px 16px;
                padding-bottom: calc(env(safe-area-inset-bottom, 16px) + 12px);
                gap: 8px;
            }

            .input-wrapper {
                gap: 8px;
            }

            /* Prevent iOS zoom on input focus */
            #messageInput,
            .search-input,
            input[type="text"],
            input[type="password"],
            select,
            textarea {
                font-size: 16px !important;
            }

            #messageInput {
                padding: 12px 14px;
                min-height: 44px;
            }

            /* Larger touch targets for buttons */
            #sendBtn,
            #stopBtn,
            #micBtn {
                min-width: 48px;
                min-height: 48px;
                padding: 12px;
            }

            .input-action-btn {
                min-height: 44px;
                padding: 10px 14px;
            }

            /* Sidebar footer settings */
            .sidebar-footer {
                padding: 12px;
            }

            .settings-row {
                padding: 6px 0;
            }

            .settings-row label {
                min-width: 60px;
            }

            .settings-row select,
            .settings-row input[type="text"],
            .settings-row input[type="password"] {
                min-height: 40px;
            }

            .settings-btn {
                min-height: 48px;
                padding: 12px 16px;
            }

            /* Chat items larger touch targets */
            .chat-item {
                padding: 14px 16px;
                min-height: 52px;
            }

            /* Modals full-screen on mobile */
            .modal-content {
                width: 95%;
                max-width: none;
                max-height: 90vh;
                margin: 5vh auto;
            }

            .settings-modal {
                height: 85vh;
                max-height: 85vh;
            }

            .settings-tab {
                padding: 10px 4px;
                font-size: 0.72rem;
            }

            .modal-body {
                padding: 16px;
            }

            /* Keyboard shortcuts not useful on mobile */
            .shortcuts-modal {
                display: none;
            }

            /* Search overlay compact */
            .conversation-search-overlay {
                padding: 8px 12px;
                padding-top: calc(env(safe-area-inset-top, 8px) + 8px);
                left: 50px; /* Space for menu button */
            }

            /* Presence indicator compact */
            .presence-indicator {
                display: none; /* Hide on very small screens */
            }

            /* Context meter compact */
            .context-meter {
                padding: 8px;
            }

            .context-details {
                font-size: 0.65rem;
            }
        }

        /* Small phone breakpoint */
        @media (max-width: 375px) {
            .chat-header {
                padding-left: 52px;
            }

            .header-actions {
                gap: 4px;
            }

            .header-btn {
                padding: 8px 10px;
                min-width: 40px;
                font-size: 0.7rem;
            }

            .message {
                font-size: 0.9rem;
                padding: 10px 12px;
            }

            .sidebar-header h1 {
                font-size: 0.85rem;
            }

            .sidebar-header .subtitle {
                font-size: 0.65rem;
            }

            .chat-item .name {
                font-size: 0.85rem;
            }

            .sovereign-toggle,
            .element-toggle {
                min-width: 60px;
                padding: 8px 6px;
            }
        }

        /* Android-specific adjustments */
        body.android-build {
            /* Ensure proper touch handling */
            touch-action: manipulation;
        }

        body.android-build .mobile-menu-btn {
            /* Always show on Android build */
            display: flex;
        }

        @media (min-width: 769px) {
            body.android-build .mobile-menu-btn {
                display: none;
            }

            body.android-build .sidebar {
                transform: translateX(0);
            }
        }

        /* Landscape mode adjustments */
        @media (max-height: 500px) and (orientation: landscape) {
            .sidebar {
                padding-top: 10px;
            }

            .sidebar-header {
                padding: 10px 12px;
            }

            .chat-list {
                max-height: 40vh;
            }

            .chat-header {
                padding: 8px 12px;
                padding-left: 52px;
            }

            .input-container {
                padding: 8px 12px;
            }
        }

        /* ============================================
           CHARACTER-SPECIFIC TYPING INDICATORS
           ============================================ */

        .typing-indicator .typing-text {
            font-size: 0.75rem;
            font-style: italic;
            color: var(--accent);
            margin-left: 0.5rem;
            opacity: 0.9;
        }

        .typing-indicator.lumen .typing-text { color: var(--accent); }
        .typing-indicator.lilith .typing-text { color: var(--accent); }
        .typing-indicator.luna .typing-text { color: var(--accent); }
        .typing-indicator.lira .typing-text { color: var(--accent); }

        /* ============================================
           ENHANCED STEAMPUNK DECORATIVE ELEMENTS
           ============================================ */

        /* Brass conduit divider between sidebar sections */
        .chat-section + .chat-section {
            position: relative;
            padding-top: 0.75rem;
        }

        .chat-section + .chat-section::before {
            content: '';
            display: block;
            height: 1px;
            margin: 0 1rem 0.5rem;
            background: var(--border-subtle);
            opacity: 0.7;
        }

        /* Enhanced chat item hover - brass gauge activation */
        .chat-item:hover .indicator {
            transform: scale(1.15);
            transition: transform 0.2s ease;
        }

        /* Subtle engraved line pattern on sidebar footer */
        .sidebar-footer {
            position: relative;
        }

        /* Sidebar footer engraved separator moved to arcane skin (quartet-skin-arcane.css) */

        /* Enhanced status dot - pressure gauge light */
        .status-dot {
            position: relative;
            border: 1px solid rgba(0, 0, 0, 0.3);
            box-shadow:
                inset 0 1px 2px rgba(0, 0, 0, 0.4),
                0 0 4px currentColor;
        }

        .status-dot.connected {
            box-shadow:
                inset 0 1px 2px rgba(0, 0, 0, 0.3),
                0 0 6px #4ade80,
                0 0 12px rgba(74, 222, 128, 0.3);
        }

        /* Context bar */
        .context-bar {
            border: 1px solid var(--border-subtle);
            border-radius: var(--radius);
        }

        /* Kbd keys */
        .shortcut-keys kbd {
            background: var(--bg-tertiary);
            border: 1px solid var(--border-light);
            box-shadow: 0 2px 0 var(--bg-primary), 0 3px 4px rgba(0, 0, 0, 0.3);
            border-radius: var(--radius);
            font-family: var(--font-display);
            letter-spacing: 0.05em;
        }

        /* Enhanced error notification - brass-framed alert */
        .error-notification {
            border: 1px solid rgba(248, 113, 113, 0.3);
            box-shadow:
                0 4px 16px rgba(0, 0, 0, 0.4),
                inset 0 1px 0 rgba(255, 255, 255, 0.05);
        }

        /* Range slider track */
        .settings-row input[type="range"] {
            background: var(--bg-tertiary);
            border: 1px solid var(--border-subtle);
        }

        /* Range slider thumb */
        .settings-row input[type="range"]::-webkit-slider-thumb {
            background: var(--accent);
            border: none;
            box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
            width: 14px;
            height: 14px;
        }

        .settings-row input[type="range"]::-webkit-slider-thumb:hover {
            background: var(--accent);
            box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 0 8px var(--accent-glow);
        }

        /* Sidebar scrollbar - thin neutral */
        .chat-list::-webkit-scrollbar {
            width: 5px;
        }
        .chat-list::-webkit-scrollbar-track {
            background: transparent;
        }
        .chat-list::-webkit-scrollbar-thumb {
            background: var(--border-medium);
            border-radius: var(--radius);
        }

        /* Time gap dividers */
        .time-gap-divider {
            font-family: var(--font-display);
            letter-spacing: 0.04em;
            font-size: 0.6rem;
        }

        .time-gap-divider::before,
        .time-gap-divider::after {
            background: linear-gradient(90deg, transparent, var(--border-light), transparent);
        }

        /* Subtle scan-line effect on assistant messages during streaming */
        .message.assistant .message-content.typing {
            background-image: none;
        }

        /* Enhanced select dropdowns */
        .settings-row select {
            cursor: pointer;
        }

        .settings-row select:hover {
            border-color: var(--accent);
        }

        /* Header button — clean, no overlay */
        .header-btn {
            position: relative;
        }

        /* Enhanced modal header - position: relative for arcane skin */
        .modal-header {
            position: relative;
        }

        /* Modal header nameplate moved to arcane skin (quartet-skin-arcane.css) */

        /* ============================================
           SUMMONING PORTAL - Wizard & Custom Companions
           ============================================ */

        /* Custom companion sidebar items */
        .chat-item.custom-companion {
            position: relative;
        }

        .chat-item.custom-companion.active {
            background: rgba(255, 255, 255, 0.04);
        }

        .chat-item .cc-glyph {
            font-size: 0.85em;
            margin-right: 4px;
            opacity: 0.8;
        }

        /* Summoning Wizard Modal */
        .summoning-wizard-modal {
            max-width: 560px;
            max-height: 85vh;
        }

        .wizard-progress {
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 16px 24px 4px;
            gap: 0;
        }

        .wizard-step-indicator {
            width: 28px;
            height: 28px;
            border-radius: 50%;
            border: 1.5px solid var(--border-medium);
            display: flex;
            align-items: center;
            justify-content: center;
            font-family: var(--font-ui);
            font-size: 0.75rem;
            color: var(--text-muted);
            background: var(--bg-tertiary);
            transition: all 0.3s ease;
            flex-shrink: 0;
            pointer-events: none;
        }

        .wizard-step-indicator.active {
            border-color: var(--accent);
            color: var(--accent);
            background: radial-gradient(circle at center, var(--accent-subtle) 0%, transparent 70%);
            box-shadow: 0 0 8px var(--accent-glow), 0 0 16px var(--accent-glow);
            animation: wizardNodePulse 2s ease-in-out infinite;
        }

        .wizard-step-indicator.completed {
            border-color: var(--accent);
            background: var(--accent);
            color: var(--bg-primary);
            box-shadow: 0 0 8px var(--accent-glow);
        }

        .wizard-step-line {
            height: 1.5px;
            flex: 1;
            background: var(--border-subtle);
            margin: 0 4px;
            transition: all 0.3s ease;
        }

        .wizard-step-line.completed {
            background: var(--accent);
            box-shadow: 0 0 6px var(--accent-glow);
        }

        @keyframes wizardNodePulse {
            0%, 100% { box-shadow: 0 0 8px var(--accent-glow); }
            50% { box-shadow: 0 0 16px var(--accent-glow), 0 0 24px var(--accent-glow); }
        }

        .wizard-step-label {
            text-align: center;
            font-family: var(--font-display);
            font-size: 0.85rem;
            color: var(--text-secondary);
            padding: 6px 24px 12px;
            letter-spacing: 0.04em;
        }

        .wizard-body {
            padding: 0 24px 16px !important;
            overflow-y: auto;
            max-height: calc(85vh - 220px);
        }

        .wizard-step {
            display: none;
        }

        .wizard-step.active {
            display: block;
        }

        .wizard-field {
            margin-bottom: 14px;
        }

        .wizard-field label {
            display: block;
            font-family: var(--font-ui);
            font-size: 0.8rem;
            color: var(--text-secondary);
            margin-bottom: 4px;
            letter-spacing: 0.03em;
        }

        .wizard-field label .required {
            color: var(--accent);
        }

        .wizard-field input[type="text"],
        .wizard-field textarea,
        .wizard-field select {
            width: 100%;
            padding: 8px 10px;
            background: var(--bg-tertiary);
            border: 1px solid var(--border-light);
            border-radius: 6px;
            color: var(--text-primary);
            font-family: var(--font-body);
            font-size: 0.9rem;
            outline: none;
            transition: border-color 0.2s;
        }

        .wizard-field input:focus,
        .wizard-field textarea:focus,
        .wizard-field select:focus {
            border-color: var(--accent);
        }

        .wizard-field textarea {
            resize: vertical;
            min-height: 50px;
        }

        .wizard-field .field-char-count {
            display: block;
            text-align: right;
            font-size: 0.7rem;
            color: var(--text-muted);
            margin-top: 2px;
        }

        .wizard-row {
            display: flex;
            gap: 12px;
        }

        .wizard-row .wizard-field {
            flex: 1;
        }

        .wizard-field input[type="range"] {
            width: 100%;
            accent-color: var(--accent);
        }

        /* Glyph picker grid */
        .glyph-picker {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(38px, 1fr));
            gap: 6px;
        }

        .glyph-option {
            width: 38px;
            height: 38px;
            display: flex;
            align-items: center;
            justify-content: center;
            border: 1px solid var(--border-subtle);
            border-radius: var(--radius);
            background: var(--bg-tertiary);
            color: var(--text-primary);
            font-size: 1.1rem;
            cursor: pointer;
            transition: all 0.15s;
        }

        .glyph-option:hover {
            border-color: var(--accent);
            background: var(--bg-elevated);
            transform: translateY(-2px);
            box-shadow: 0 4px 8px rgba(0,0,0,0.3), 0 0 8px var(--accent-glow);
        }

        .glyph-option.selected {
            border-color: var(--accent);
            background: var(--accent-subtle);
            box-shadow: 0 0 12px var(--accent-glow);
        }

        /* Color picker grid */
        .color-picker {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
            gap: 8px;
        }

        .wizard-add-btn {
            background: none;
            border: 1px dashed var(--border-light);
            color: var(--text-muted);
            padding: 4px 12px;
            border-radius: var(--radius);
            cursor: pointer;
            font-size: 0.75rem;
            margin-top: 4px;
            transition: all 0.15s;
        }

        .wizard-add-btn:hover {
            border-color: var(--accent);
            color: var(--accent);
        }

        /* Wizard footer */
        .wizard-footer {
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .wizard-footer-spacer {
            flex: 1;
        }

        /* Companion manager list in settings */
        .companion-manager-list {
            display: flex;
            flex-direction: column;
            gap: 8px;
        }

        .companion-manager-card {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 10px 12px;
            background: var(--bg-tertiary);
            border: 1px solid var(--border-subtle);
            border-radius: 8px;
        }

        .companion-manager-glyph {
            font-size: 1.2rem;
            width: 32px;
            text-align: center;
            flex-shrink: 0;
        }

        .companion-manager-info {
            flex: 1;
            min-width: 0;
        }

        .companion-manager-name {
            font-family: var(--font-display);
            font-size: 0.85rem;
            color: var(--text-primary);
        }

        .companion-manager-element {
            font-size: 0.7rem;
            color: var(--text-muted);
        }

        .companion-manager-actions {
            display: flex;
            gap: 6px;
            flex-shrink: 0;
        }

        .companion-manager-actions button {
            background: none;
            border: 1px solid var(--border-light);
            color: var(--text-secondary);
            padding: 4px 10px;
            border-radius: var(--radius);
            cursor: pointer;
            font-size: 0.7rem;
            font-family: var(--font-ui);
            transition: all 0.15s;
        }

        .companion-manager-actions button:hover {
            border-color: var(--accent);
            color: var(--accent);
        }

        .companion-manager-actions .delete-btn:hover {
            border-color: var(--accent);
            color: var(--accent);
        }

        /* Invocation text decorative styling */
        .invocation .invocation-text {
            position: relative;
        }

        /* Per-sovereign model overrides */
        .sovereign-model-overrides {
            display: flex;
            flex-direction: column;
            gap: 8px;
        }

        .sovereign-model-row {
            display: flex;
            align-items: center;
            gap: 12px;
        }

        .sovereign-model-name {
            min-width: 60px;
            font-size: 0.8rem;
            color: var(--text-primary);
            font-weight: 600;
        }

        .sovereign-model-select {
            flex: 1;
            background: var(--bg-tertiary);
            color: var(--text-primary);
            border: 1px solid var(--border-subtle);
            border-radius: var(--radius);
            padding: 4px 8px;
            font-size: 0.75rem;
        }

        /* Export format picker */
        .export-format-picker {
            position: fixed;
            inset: 0;
            z-index: 9999;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .export-format-overlay {
            position: absolute;
            inset: 0;
            background: rgba(0,0,0,0.6);
        }

        .export-format-menu {
            position: relative;
            background: var(--bg-secondary);
            border: 1px solid var(--border-subtle);
            border-radius: 8px;
            padding: 16px;
            min-width: 220px;
            box-shadow: 0 8px 32px rgba(0,0,0,0.5);
        }

        .export-format-title {
            font-family: var(--font-display);
            font-size: 1rem;
            color: var(--text-primary);
            margin-bottom: 12px;
            text-align: center;
            letter-spacing: 0.05em;
        }

        .export-format-menu button {
            display: block;
            width: 100%;
            padding: 8px 12px;
            background: transparent;
            border: 1px solid transparent;
            color: var(--text-primary);
            font-size: 0.85rem;
            text-align: left;
            cursor: pointer;
            border-radius: var(--radius);
            margin-bottom: 4px;
            transition: all 0.15s ease;
        }

        .export-format-menu button:hover {
            background: var(--bg-tertiary);
            border-color: var(--border-subtle);
        }

        /* ============================================
           FONT SIZE CONTROL
           ============================================ */
        .font-size-control {
            display: flex;
            align-items: center;
            gap: 0.5rem;
        }

        .font-size-label {
            font-size: 0.75rem;
            color: var(--text-secondary);
            min-width: 35px;
            text-align: right;
        }

        .font-size-row input[type="range"] {
            width: 100px;
            accent-color: var(--accent);
        }

        /* ============================================
           FONT SIZE SCALING
           ============================================ */
        .message {
            font-size: calc(0.95rem * var(--font-scale));
        }

        /* ============================================
           REDUCED MOTION
           ============================================ */
        /* ============================================
           ACCESSIBILITY
           ============================================ */
        .skip-to-content {
            position: absolute;
            top: -40px;
            left: 0;
            background: var(--accent);
            color: var(--bg-primary);
            padding: 8px 16px;
            z-index: 10000;
            font-weight: 600;
            transition: top 0.2s;
            text-decoration: none;
        }

        .skip-to-content:focus {
            top: 0;
        }

        /* Visible focus indicators for keyboard users */
        *:focus-visible {
            outline: 2px solid var(--accent);
            outline-offset: 2px;
        }

        button:focus-visible, select:focus-visible, input:focus-visible, textarea:focus-visible {
            outline: 2px solid var(--accent);
            outline-offset: 2px;
        }

        .chat-item:focus-visible {
            outline: 2px solid var(--accent);
            outline-offset: -2px;
        }

        @media (prefers-reduced-motion: reduce) {
            .message {
                animation: none !important;
            }
            .chat-item.active .indicator {
                animation: none !important;
            }
            .typing-indicator span {
                animation: none !important;
            }
            * {
                transition-duration: 0.01ms !important;
            }
        }

        /* ── Soul Document Export Panel ─────────────────────────────── */

        .soul-doc-panel-overlay {
            position: fixed;
            inset: 0;
            z-index: 9500;
            background: rgba(0,0,0,0.65);
            display: flex;
            align-items: flex-end;
            justify-content: center;
            backdrop-filter: blur(4px);
        }

        @media (min-width: 600px) {
            .soul-doc-panel-overlay {
                align-items: center;
            }
        }

        .soul-doc-panel {
            background: var(--bg-secondary);
            border: 1px solid var(--border-subtle);
            border-radius: 12px 12px 0 0;
            width: 100%;
            max-width: 640px;
            max-height: 88vh;
            display: flex;
            flex-direction: column;
            overflow: hidden;
        }

        @media (min-width: 600px) {
            .soul-doc-panel {
                border-radius: 12px;
                max-height: 80vh;
            }
        }

        .soul-doc-header {
            display: flex;
            align-items: flex-start;
            gap: 12px;
            padding: 16px 16px 12px;
            border-bottom: 1px solid var(--border-light);
            flex-shrink: 0;
        }

        .soul-doc-header > div:first-child {
            flex: 1;
        }

        .soul-doc-title {
            font-family: var(--font-display);
            font-size: 16px;
            font-weight: 600;
            color: var(--text-primary);
        }

        .soul-doc-subtitle {
            font-size: 12px;
            color: var(--text-muted);
            margin-top: 2px;
        }

        .soul-doc-header-actions {
            display: flex;
            gap: 4px;
            align-items: center;
        }

        .soul-doc-content {
            flex: 1;
            overflow-y: auto;
            padding: 16px;
        }

        .soul-doc-loading {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            gap: 12px;
            padding: 48px 24px;
            color: var(--text-secondary);
            font-style: italic;
            font-size: 14px;
        }

        .soul-doc-pre {
            font-family: var(--font-primary, inherit);
            font-size: 13px;
            line-height: 1.7;
            color: var(--text-primary);
            white-space: pre-wrap;
            word-break: break-word;
            margin: 0;
        }

        .soul-doc-error {
            background: rgba(200,40,40,0.12);
            border: 1px solid rgba(200,40,40,0.35);
            border-radius: 6px;
            padding: 14px 16px;
            color: var(--text-primary);
            font-size: 13px;
            line-height: 1.6;
        }

        /* Pulsing glyph used in soul doc loading and import processing */
        .soul-doc-glyph-pulse {
            display: inline-block;
            animation: soulDocPulse 1.4s ease-in-out infinite;
            color: var(--accent);
        }

        @keyframes soulDocPulse {
            0%, 100% { opacity: 0.35; transform: scale(0.95); }
            50%       { opacity: 1;    transform: scale(1.05); }
        }

        /* ── Soul Document Import Modal ──────────────────────────────── */

        .soul-doc-import-modal {
            max-width: 560px;
        }

        .soul-doc-import-error {
            background: rgba(200,40,40,0.12);
            border: 1px solid rgba(200,40,40,0.35);
            border-radius: 6px;
            padding: 10px 12px;
            color: var(--text-primary);
            font-size: 13px;
            line-height: 1.5;
            margin-bottom: 12px;
        }

        /* ── Soul Doc / Wizard settings chip buttons ── */

        .soul-doc-mode-btn,
        .soul-doc-src-btn {
            background: transparent;
            border: 1px solid var(--border-light);
            border-radius: var(--radius);
            padding: 4px 10px;
            font-size: 12px;
            color: var(--text-muted);
            cursor: pointer;
            transition: border-color 0.15s, color 0.15s, background 0.15s;
        }
        .soul-doc-mode-btn:hover,
        .soul-doc-src-btn:hover {
            border-color: var(--accent);
            color: var(--text-primary);
        }
        .soul-doc-mode-active {
            border-color: var(--accent) !important;
            color: var(--accent) !important;
            background: color-mix(in srgb, var(--accent) 15%, transparent) !important;
            font-weight: 600;
        }
        .soul-doc-src-active {
            border-color: var(--accent) !important;
            color: var(--accent) !important;
            background: color-mix(in srgb, var(--accent) 15%, transparent) !important;
            font-weight: 600;
        }

        /* ── Aesthetic Edit Modal (beta: post-document-import light edit) ── */

        .aesthetic-edit-modal {
            padding: 0;
            overflow: hidden;
        }

        .aesthetic-edit-preview {
            display: flex;
            flex-direction: column;
            align-items: center;
            padding: 32px 24px 24px;
            background: var(--bg-secondary);
            border-bottom: 1px solid var(--border-light);
            gap: 10px;
        }

        .aesthetic-preview-glyph {
            font-size: 52px;
            line-height: 1;
            transition: color 0.2s ease;
        }

        .aesthetic-preview-name {
            font-family: var(--font-display);
            font-size: 18px;
            font-weight: 600;
            color: var(--text-primary);
            letter-spacing: 0.03em;
        }

        .aesthetic-edit-body {
            padding: 20px 24px;
            display: flex;
            flex-direction: column;
            gap: 0;
        }

        .aesthetic-field {
            margin-bottom: 20px;
        }

        .aesthetic-label {
            display: block;
            font-size: 11px;
            font-weight: 600;
            letter-spacing: 0.08em;
            letter-spacing: 0.02em;
            color: var(--text-muted);
            margin-bottom: 8px;
        }

        .aesthetic-name-input {
            width: 100%;
            box-sizing: border-box;
            background: var(--bg-secondary);
            border: 1px solid var(--border-light);
            border-radius: var(--radius);
            padding: 10px 12px;
            color: var(--text-primary);
            font-size: 15px;
            font-family: var(--font-display);
            outline: none;
            transition: border-color 0.2s;
        }

        .aesthetic-name-input:focus {
            border-color: var(--accent);
        }

        .aesthetic-glyph-grid {
            display: flex;
            flex-wrap: wrap;
            gap: 6px;
        }

        .aesthetic-glyph-option {
            width: 38px;
            height: 38px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 18px;
            border: 1px solid var(--border-light);
            border-radius: var(--radius);
            cursor: pointer;
            color: var(--text-secondary);
            background: var(--bg-secondary);
            transition: border-color 0.15s, color 0.15s, background 0.15s;
            user-select: none;
        }

        .aesthetic-glyph-option:hover {
            border-color: var(--accent);
            color: var(--text-primary);
        }

        .aesthetic-glyph-option.selected {
            border-color: var(--accent);
            border-width: 2px;
            color: var(--accent);
            background: var(--accent-subtle);
        }


        .aesthetic-edit-footer {
            display: flex;
            gap: 10px;
            padding: 16px 24px;
            border-top: 1px solid var(--border-light);
            background: var(--bg-secondary);
        }

        .aesthetic-edit-footer .modal-btn-secondary {
            flex: none;
        }

        .aesthetic-edit-footer .modal-btn-primary {
            flex: 1;
        }

/* ── Onboarding Overlay ── */
.onboarding-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-primary);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 0.8s ease;
}

.onboarding-overlay.fade-out {
    opacity: 0;
    pointer-events: none;
}

.onboarding-overlay.hidden {
    display: none;
}

/* Onboarding container */
.onboarding-container {
    width: 100%;
    max-width: 520px;
    padding: 40px 32px;
    text-align: center;
    animation: onboardFadeIn 0.8s ease;
}

@keyframes onboardFadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ── First Light Pages ── */
.first-light-page {
    animation: firstLightFadeIn 0.8s ease;
}

@keyframes firstLightFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.lantern-glyph {
    font-size: 56px;
    color: var(--accent);
    margin-bottom: 48px;
}

.lantern-glyph-small {
    font-size: 28px;
    color: var(--accent);
    opacity: 0.6;
    margin-bottom: 32px;
}

.onboarding-headline {
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 400;
    color: var(--accent);
    letter-spacing: 1.5px;
    margin-bottom: 24px;
}

.onboarding-text {
    font-family: var(--font-body);
    font-size: 17px;
    line-height: 1.7;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.onboarding-text-primary {
    font-family: var(--font-body);
    font-size: 22px;
    line-height: 1.6;
    color: var(--text-primary);
    margin-bottom: 24px;
}

.onboarding-tap-hint {
    font-size: 12px;
    color: var(--text-muted);
    opacity: 0.5;
    letter-spacing: 2px;
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
}

/* ── Path Chooser ── */
.path-chooser {
    animation: onboardFadeIn 1s ease;
}

.path-question {
    font-family: var(--font-display);
    font-size: 24px;
    font-weight: 400;
    color: var(--text-primary);
    letter-spacing: 1px;
    margin-bottom: 48px;
}

.path-card {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 20px;
    margin-bottom: 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    border: 1px solid var(--border-subtle);
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
}

.path-card:hover {
    border-color: var(--border-medium);
    transform: translateY(-1px);
}

.path-card:active {
    transform: translateY(0);
}

.path-card-glyph {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    font-size: 22px;
    flex-shrink: 0;
    margin-right: 16px;
}

.path-card-text {
    flex: 1;
}

.path-card-title {
    font-family: var(--font-display);
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.path-card-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.4;
}

.path-card-arrow {
    font-size: 20px;
    opacity: 0.5;
    margin-left: 8px;
}

/* ── Connect Step ── */
.connect-step {
    animation: onboardFadeIn 0.8s ease;
}

.connect-btn {
    display: block;
    width: 100%;
    padding: 16px;
    margin-top: 40px;
    background: var(--accent);
    color: var(--bg-primary);
    font-family: var(--font-display);
    font-size: 15px;
    font-weight: 600;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s ease;
}

.connect-btn:hover {
    filter: brightness(1.1);
    box-shadow: 0 0 20px var(--accent-glow);
}

.connect-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.connect-error {
    font-size: 13px;
    color: #e05555;
    margin-top: 16px;
    line-height: 1.4;
}

.connect-skip {
    display: inline-block;
    margin-top: 24px;
    padding: 8px 16px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 13px;
    cursor: pointer;
    transition: color 0.2s ease;
    font-family: var(--font-body);
}

.connect-skip:hover {
    color: var(--text-secondary);
}

.connect-success {
    color: var(--accent);
}

/* ── Connect step: included model list ── */
.connect-included-models {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 24px;
    margin: 4px 0 4px;
    text-align: left;
    padding: 0 8px;
}

.connect-model-item {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 13px;
    color: var(--text-secondary);
    animation: onboardFadeIn 0.6s ease both;
}

.connect-model-item:nth-child(1) { animation-delay: 0.05s; }
.connect-model-item:nth-child(2) { animation-delay: 0.15s; }
.connect-model-item:nth-child(3) { animation-delay: 0.25s; }
.connect-model-item:nth-child(4) { animation-delay: 0.35s; }
.connect-model-item:nth-child(5) { animation-delay: 0.45s; }
.connect-model-item:nth-child(6) { animation-delay: 0.55s; }

.cmi-dot {
    font-size: 9px;
    color: var(--accent);
    opacity: 0.8;
    flex-shrink: 0;
}

/* Progress bar — fills over 2.5s then finishOnboarding fires */
.connect-progress-bar {
    height: 2px;
    background: var(--border-subtle);
    border-radius: 1px;
    margin: 24px 0 20px;
    overflow: hidden;
}

.connect-progress-fill {
    height: 100%;
    width: 0;
    background: var(--accent);
    border-radius: 1px;
    animation: connectProgress 2.5s ease-in-out forwards;
    animation-delay: 0.1s;
}

@keyframes connectProgress {
    from { width: 0; }
    to   { width: 100%; }
}

/* Begin button */
.connect-begin-btn {
    display: block;
    width: 100%;
    padding: 14px;
    background: var(--accent);
    color: var(--bg-primary);
    font-family: var(--font-display);
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.5px;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s ease;
}

.connect-begin-btn:hover {
    filter: brightness(1.1);
    box-shadow: 0 0 20px var(--accent-glow);
}

/* Hint below begin button */
.connect-more-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 14px;
    opacity: 0.6;
    line-height: 1.4;
}

.connect-spinner {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 2px solid var(--border-subtle);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 24px auto;
}

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

/* ── Responsive adjustments ── */
@media (max-width: 768px) {
    .onboarding-container {
        padding: 32px 24px;
    }

    .onboarding-headline {
        font-size: 18px;
    }

    .onboarding-text-primary {
        font-size: 18px;
    }

    .onboarding-text {
        font-size: 15px;
    }

    .path-question {
        font-size: 20px;
    }
}

/* ── Light theme overrides ── */
body.theme-light .onboarding-overlay {
    background: var(--bg-primary);
}

body.theme-light .connect-btn {
    color: #fff;
}

/* ============================================
   DRIFT MODE — Auto-conversation
   ============================================ */

.drift-btn {
    /* inherits .header-btn transition */
}

.drift-btn.active {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.drift-btn.active .drift-icon {
    animation: drift-spin 3s linear infinite;
}

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

/* ── Summoner policy notice bar ─────────────────────────────────────────── */
.policy-notice {
    padding: 8px 16px;
    font-size: 12px;
    line-height: 1.5;
    text-align: center;
    color: var(--text-secondary);
    border-top: 1px solid var(--border-subtle);
    border-bottom: 1px solid var(--border-subtle);
    background: var(--bg-secondary);
}
.policy-notice--amber {
    color: #b8860b;
    background: rgba(184, 134, 11, 0.06);
    border-color: rgba(184, 134, 11, 0.2);
}
body.theme-light .policy-notice--amber {
    color: #7a5900;
}
.policy-notice--red {
    color: #a05040;
    background: rgba(160, 80, 64, 0.06);
    border-color: rgba(160, 80, 64, 0.2);
}
.policy-notice--blocked {
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    border-color: var(--border-medium);
}

.drift-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(var(--accent-rgb, 180, 160, 100), 0.08);
    border-top: 1px solid rgba(var(--accent-rgb, 180, 160, 100), 0.15);
    border-bottom: 1px solid rgba(var(--accent-rgb, 180, 160, 100), 0.15);
    cursor: pointer;
    transition: background 0.2s ease;
    user-select: none;
}

.drift-banner:hover {
    background: rgba(var(--accent-rgb, 180, 160, 100), 0.14);
}

.drift-banner .drift-spinner {
    font-size: 16px;
    color: var(--accent, #b4a064);
    animation: drift-spin 3s linear infinite;
    display: inline-block;
}

.drift-banner .drift-banner-text {
    font-size: 13px;
    color: var(--text-secondary, #a09080);
    font-style: italic;
    font-family: var(--font-body);
}

.drift-banner .drift-stop-hint {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 8px;
    background: rgba(var(--accent-rgb, 180, 160, 100), 0.15);
    color: var(--accent, #b4a064);
    font-weight: 600;
    font-family: var(--font-body);
}

body.theme-light .drift-banner {
    background: rgba(var(--accent-rgb, 180, 160, 100), 0.06);
}

body.theme-light .drift-btn.active {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

/* ============================================
   AGE GATE OVERLAY
   ============================================ */

.age-gate-overlay {
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: rgba(0, 0, 0, 0.96);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: opacity 0.4s ease;
}

.age-gate-overlay.age-gate-fading {
    opacity: 0;
    pointer-events: none;
}

.age-gate-card {
    max-width: 440px;
    width: 90%;
    padding: 48px 40px;
    background: var(--bg-secondary, #1A1A1A);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.age-gate-glyph {
    font-size: 40px;
    color: var(--accent, #b4a064);
    line-height: 1;
    margin-bottom: 4px;
}

.age-gate-title {
    font-family: var(--font-body, 'Inter', sans-serif);
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary, #E8E6E1);
    letter-spacing: 0.02em;
}

.age-gate-statement {
    font-family: var(--font-body, 'Inter', sans-serif);
    font-size: 15px;
    color: var(--text-primary, #E8E6E1);
    line-height: 1.5;
    max-width: 320px;
}

.age-gate-sub {
    font-family: var(--font-body, 'Inter', sans-serif);
    font-size: 13px;
    color: var(--text-secondary, #888);
    line-height: 1.4;
}

.age-gate-btn {
    margin-top: 8px;
    padding: 12px 28px;
    background: var(--accent, #b4a064);
    color: #0F0F0F;
    border: none;
    border-radius: 6px;
    font-family: var(--font-body, 'Inter', sans-serif);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    letter-spacing: 0.02em;
    transition: opacity 0.2s ease, transform 0.15s ease;
}

.age-gate-btn:hover {
    opacity: 0.85;
    transform: translateY(-1px);
}

.age-gate-btn:active {
    transform: translateY(0);
}
