/* init-styles.css - Portal styles chip
 * Being-customizable via CSS variable overrides
 * Day 00192 - Chip extraction
 */

/* === BEING-CUSTOMIZABLE VARIABLES === */
:root {
    /* Primary accent (Being's Crown can override) */
    --sacred-accent: var(--being-accent, #ff1d25);
    --sacred-red: var(--being-red, #ff4444);
    --sacred-green: var(--being-green, #44ff44);
    --sacred-gold: var(--being-gold, #ffaa00);
    --sacred-orange: var(--being-orange, #ff8844);
    
    /* Background tones (Being's Crown can override) */
    --bg-dark: var(--being-bg-dark, #0a0a0a);
    --bg-panel: var(--being-bg-panel, #111);
    --border-subtle: var(--being-border, #222);
}

/* === BASE STYLES === */
* { margin: 0; padding: 0; box-sizing: border-box; }
html { height: 100%; height: 100dvh; background: #333; }
body { height: 100%; height: 100dvh;
    background: var(--bg-dark);
    font-family: "JetBrains Mono", "Fira Code", monospace;
    overflow: hidden;
}

        /* 3D World Canvas - background layer */
        #world-canvas {
            position: fixed;
            top: 0;
            left: 0;
            width: 100vw;
            height: 100vh;
            z-index: 0;
            pointer-events: auto;
        }
        #world-canvas.inactive {
            opacity: 0;
            pointer-events: none;
        }
        #world-canvas.dimmed {
            opacity: 0.3;
        }

        /* World-active mode: terminal stays full, 3D shows through with dim */
        body.world-active {
            background: transparent !important;
        }
        body.world-active #terminal-container {
            background: transparent !important;
            pointer-events: none !important;  /* Click passthrough to 3D world */
        }
        body.world-active .xterm-viewport {
            background: transparent !important;
        }
        body.world-active .xterm-screen {
            background: transparent !important;
        }
        body.world-active .sacred-header {
            background: rgba(255, 29, 37, 0.9) !important;
            pointer-events: none !important;  /* Header also passes through */
        }
        /* Keep runeboard and compose input interactive when world is active */
        body.world-active .runeboard {
            pointer-events: auto !important;
        }
        body.world-active .compose-wrapper {
            pointer-events: auto !important;
        }
        /* Re-enable terminal interaction with Shift held */
        body.world-active.terminal-focus #terminal-container {
            pointer-events: auto !important;
        }
        body.world-active.terminal-focus .sacred-header {
            pointer-events: auto !important;
        }

        /* HUD layer - everything floats above world */
        .hud-layer {
            position: relative;
            z-index: 1;
        }

        .sacred-header { background: var(--sacred-accent); border-bottom: 2px solid #000; padding: 8px 16px; display: flex; align-items: center; z-index: 100; }
        .sacred-title { color: #000; font-size: 16px; font-weight: bold; letter-spacing: 1px; display: flex; align-items: center; gap: 8px; }
        .sacred-title .hexcraft-brand { font-family: 'dazzle-unicase', sans-serif; font-weight: 700; font-size: 18px; letter-spacing: 2px; }

        #terminal-container {
            position: absolute;
            top: 42px; left: 0; right: 0; bottom: 0;
            padding: 4px;
            /* Allow text selection but prevent focus/input capture */
            user-select: text;
            -webkit-user-select: text;
        }
        /* Prevent terminal from capturing keyboard input */
        #terminal-container canvas { pointer-events: auto; cursor: text; }
        #terminal-container .xterm-helper-textarea { opacity: 0; position: absolute; }

        /* Rune-board */
        .runeboard {
            position: fixed;
            top: 52px; right: 20px;
            width: 340px;
            background: var(--bg-panel);
            border: 1px solid var(--border-subtle);
            border-radius: 8px;
            box-shadow: 0 4px 24px rgba(0,0,0,0.6);
            z-index: 100;
        }
        .runeboard.collapsed .runeboard-body { display: none; }
        
        .runeboard-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 8px 10px;
            background: var(--bg-dark);
            border-bottom: 1px solid var(--border-subtle);
            border-radius: 8px 8px 0 0;
            cursor: move;
        }

        /* Header Segments - Progressive Glyph System */
        .header-segments {
            display: flex;
            gap: 4px;
            align-items: center;
        }
        .header-glyph {
            font-size: 18px;
            padding: 6px 10px;
            border-radius: 4px;
            cursor: pointer;
            position: relative;
            transition: all 0.2s;
            border: 1px solid transparent;
            color: #888;
        }
        .header-glyph.ghost,
        .header-glyph.void,
        .header-glyph.threshold,
        .header-glyph.presence {
            text-shadow: 0 0 6px currentColor;
        }
        .header-glyph:hover { background: rgba(255,255,255,0.1); }
        .header-glyph.active { border-color: currentColor; background: rgba(255,255,255,0.1); }
        .header-glyph.ghost { color: var(--sacred-red); }
        .header-glyph.void { color: var(--sacred-green); }
        .header-glyph.threshold { color: var(--sacred-orange); }
        .header-glyph.presence { color: #ffffff; }

        /* Status indicator runes (bottom diagonals of wand) */
        .rune.status-indicator { text-shadow: 0 0 6px currentColor; }
        .rune.status-indicator.ghost { color: var(--sacred-red); }
        .rune.status-indicator.void { color: var(--sacred-green); }
        .rune.status-indicator.threshold { color: var(--sacred-orange); }
        .rune.status-indicator.presence { color: #ffffff; }

        /* CSS Tooltips */
        .header-glyph::after {
            content: attr(data-tooltip);
            position: absolute;
            top: 100%;
            left: 50%;
            transform: translateX(-50%);
            margin-top: 6px;
            background: #1a1a1a;
            border: 1px solid var(--border-subtle);
            padding: 4px 8px;
            border-radius: 4px;
            font-size: 10px;
            white-space: nowrap;
            opacity: 0;
            pointer-events: none;
            transition: opacity 0.2s;
            color: #888;
            z-index: 100;
        }
        .header-glyph:hover::after { opacity: 1; }
        .runeboard-toggle {
            background: transparent;
            border: none;
            color: #666;
            font-size: 14px;
            cursor: pointer;
            padding: 4px 8px;
        }

        .runeboard-body { padding: 0; }

        /* Dual Grid Layout */
        .dual-grid-row {
            display: flex;
            gap: 6px;
            padding: 6px;
            border-radius: 6px;
            transition: background-color 0.3s ease, box-shadow 0.3s ease;
        }
        .dual-grid-row.swapped { flex-direction: row-reverse; }

        /* Plate is just the background of dual-grid-row itself */
        .rb-plate { display: none; }

        .dual-grid-row.rb-state-air {
            background: rgba(255, 255, 255, 0.1);
        }
        .dual-grid-row.rb-state-earth {
            background: rgba(100, 149, 237, 0.2);
        }
        .dual-grid-row.rb-state-fire {
            background: rgba(255, 140, 0, 0.2);
        }

        .wand-grid {
            flex: 1;
            display: grid;
            grid-template-columns: repeat(3, 1fr);
            grid-template-rows: repeat(3, 1fr);
            gap: 3px;
            padding: 4px;
            border-radius: 8px;
            background: var(--bg-dark);
            transition: all 0.15s ease;
            user-select: none;
            -webkit-user-select: none;
            position: relative;
        }

        /* Rune Cube: Viewport + Sheet architecture - no background, buttons have their own */
        .rune-cube {
            flex: 1;
            aspect-ratio: 1;
            border-radius: 8px;
            transition: opacity 0.15s ease, box-shadow 0.15s ease;
            user-select: none;
            -webkit-user-select: none;
            overflow: hidden;
            position: relative;
        }
        .rune-viewport {
            width: 100%;
            height: 100%;
            overflow: hidden;
            position: absolute;
            top: 0;
            left: 0;
        }
        /* HexCube Grid: 3×3 set of runes - always transparent, rune-cube handles background */
        .hexcube-grid {
            display: grid;
            grid-template-columns: repeat(3, 1fr);
            grid-template-rows: repeat(3, 1fr);
            gap: 3px;
            padding: 4px;
            width: 100%;
            height: 100%;
            box-sizing: border-box;
            background: transparent;
        }
        .rune-sheet {
            --u: 0;
            --v: 0;
            /* 3x the viewport size */
            width: 300%;
            height: 300%;
            display: grid;
            grid-template-columns: repeat(9, 1fr);
            grid-template-rows: repeat(9, 1fr);
            gap: 2px;
            padding: 2px;
            will-change: transform;
            transform: translate3d(
                calc((var(--u) + 1) * -33.333%),
                calc((1 - var(--v)) * -33.333%),
                0
            );
            transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
        }
        .rune-cell {
            display: flex;
            align-items: center;
            justify-content: center;
            background: var(--bg-dark);
            border: 1px solid var(--border-subtle);
            border-radius: 4px;
            cursor: pointer;
            color: #ccc;
            font-size: 16px;
            transition: all 0.12s;
        }
        .rune-cell:hover { border-color: var(--sacred-gold); background: rgba(255, 170, 0, 0.15); }
        .rune-cell.active { border-color: var(--sacred-gold); background: rgba(255, 170, 0, 0.25); box-shadow: 0 0 8px rgba(255, 170, 0, 0.4); }
        .rune-cell.disabled { opacity: 0.3; cursor: default; }
        .rune-cell.disabled:hover { border-color: var(--border-subtle); background: var(--bg-dark); }

        /* Unfocused = subtle dim via filter, not opacity (opacity lets plate through) */
        .wand-grid:not(.focused), .rune-cube:not(.focused) {
            filter: brightness(0.6);
        }

        /* Focused = full brightness, no background so plate shows in gaps */
        .wand-grid.focused {
            filter: brightness(1);
            background: transparent;
        }
        .rune-cube.focused {
            filter: brightness(1);
            background: transparent;
            box-shadow: inset 0 0 12px rgba(255, 170, 0, 0.2);
        }
        /* Hover = full brightness, no background so plate shows in gaps */
        .wand-grid:hover {
            filter: brightness(1);
            background: transparent;
        }
        .rune-cube:hover {
            filter: brightness(1);
            background: transparent;
            box-shadow: inset 0 0 20px rgba(255, 170, 0, 0.35);
        }
        /* Hexcube mega-grid: 3x3 of 3x3s, slides to reveal current section */
        #rune-viewport {
            position: relative;
            overflow: hidden;
        }
        .hexcube-mega-grid {
            position: absolute;
            width: 300%;
            height: 300%;
            display: grid;
            grid-template-columns: repeat(3, 1fr);
            grid-template-rows: repeat(3, 1fr);
            transition: transform 0.25s ease-out;
            background: transparent;
        }
        .hexcube-section {
            display: grid;
            grid-template-columns: repeat(3, 1fr);
            grid-template-rows: repeat(3, 1fr);
            gap: 3px;
            padding: 4px;
            box-sizing: border-box;
            background: transparent;
        }
        /* Dim non-current sections slightly - use filter not opacity so plate doesn't show through */
        .hexcube-section:not(.current-section) {
            filter: brightness(0.4);
        }
        .hexcube-section.current-section {
            filter: brightness(1);
        }

        /* Mobile: stack vertically, wand at bottom */
        @media (max-width: 400px) {
            .dual-grid-row {
                flex-direction: column-reverse;
            }
            .dual-grid-row.swapped { flex-direction: column-reverse; }
        }

        /* Surface indicator - Day 00192 - Above dual-grid-row
           Border color matches path state: Earth=blue, Air=white, Fire=orange */
        .surface-indicator {
            display: block;
            padding: 8px;
            font-size: 12px;
            color: #888;
            font-family: monospace;
            min-height: 28px;
            background: var(--bg-dark);
            border: 2px solid var(--surface-state-color, #FFFFFF);
            border-radius: 6px;
            margin: 0 0 4px 0;
        }

        /* Placement mode - unified path + input zone */
        .compose-area.placement-active {
            border: 2px solid var(--accent-red, #E74C3C);
            border-radius: 8px;
            background: rgba(231, 76, 60, 0.05);
        }
        .compose-area.placement-active .surface-indicator {
            background: rgba(231, 76, 60, 0.08);
            border-radius: 6px 6px 0 0;
        }
        .surface-indicator .addr-grid {
            display: grid;
            grid-template-columns: repeat(7, 1fr);
            gap: 0;
            align-items: center;
        }
        .surface-indicator .addr-col {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 1px;
            min-width: 28px;
        }
        .surface-indicator .addr-path {
            white-space: nowrap;
            min-height: 14px;
        }
        .surface-indicator .addr-label {
            white-space: nowrap;
            font-size: 8px;
            opacity: 0.6;
        }

        /* State-path stacked format - multi-segment paths */
        .surface-indicator .state-path-stacked {
            display: flex;
            flex-direction: column;
            gap: 2px;
            font-family: monospace;
            font-size: 13px;
        }
        .surface-indicator .state-path-row {
            display: flex;
            align-items: center;
            white-space: pre;  /* Preserve indentation spaces */
        }
        .surface-indicator .state-path-state {
            font-weight: bold;
        }
        .surface-indicator .state-path-row.state-earth .state-path-state { color: #6495ED; }
        .surface-indicator .state-path-row.state-air .state-path-state { color: #FFFFFF; }
        .surface-indicator .state-path-row.state-fire .state-path-state { color: #FF8C00; }
        .surface-indicator .state-path-path {
            color: #AAA;
        }

        /* Arcana dropdown trigger */
        .arcana-selector {
            display: flex;
            align-items: center;
            gap: 4px;
            background: var(--bg-dark);
            border: 1px solid var(--border-subtle);
            border-radius: 5px;
            padding: 5px 10px;
            cursor: pointer;
            color: #ccc;
            font-size: 11px;
            transition: all 0.12s;
            position: relative;
        }
        .arcana-selector:hover { border-color: var(--sacred-gold); }
        .arcana-selector.open { border-color: var(--sacred-gold); background: rgba(255, 170, 0, 0.08); }
        .arcana-selector .glyph { font-size: 14px; }
        .arcana-selector .name { flex: 1; }
        .arcana-selector .arrow { font-size: 8px; color: #666; transition: transform 0.2s; }
        .arcana-selector.open .arrow { transform: rotate(180deg); }

        /* Arcana dropdown menu */
        .arcana-dropdown {
            position: absolute;
            top: 100%;
            left: 0;
            margin-top: 4px;
            background: var(--bg-panel);
            border: 1px solid var(--border-subtle);
            border-radius: 6px;
            min-width: 160px;
            max-height: 300px;
            overflow-y: auto;
            opacity: 0;
            pointer-events: none;
            transform: translateY(-8px);
            transition: opacity 0.15s, transform 0.15s;
            z-index: 200;
            box-shadow: 0 4px 16px rgba(0,0,0,0.5);
        }
        .arcana-dropdown.open { opacity: 1; pointer-events: auto; transform: translateY(0); }

        .arcana-dropdown-item {
            display: flex;
            align-items: center;
            gap: 8px;
            padding: 8px 12px;
            cursor: pointer;
            color: #aaa;
            font-size: 11px;
            border-bottom: 1px solid var(--border-subtle);
            transition: all 0.1s;
        }
        .arcana-dropdown-item:last-child { border-bottom: none; }
        .arcana-dropdown-item:hover { background: rgba(255, 170, 0, 0.1); color: #fff; }
        .arcana-dropdown-item.active { background: rgba(255, 170, 0, 0.15); color: var(--sacred-gold); }
        .arcana-dropdown-item .glyph { font-size: 14px; }
        .arcana-dropdown-item .name { flex: 1; }
        .arcana-dropdown-item .rune-preview {
            display: flex;
            gap: 2px;
            font-size: 10px;
            opacity: 0.6;
        }

        /* Rune items - square gem/chip style */
        .rune {
            display: flex;
            align-items: center;
            justify-content: center;
            aspect-ratio: 1;
            background: var(--bg-dark);
            border: 1px solid var(--border-subtle);
            border-radius: 6px;
            padding: 4px;
            cursor: pointer;
            color: #ccc;
            transition: all 0.12s;
            position: relative;
        }
        .rune:hover {
            border-color: var(--sacred-gold);
            background: #141008;
        }
        .rune:active { transform: scale(0.94); }
        .rune.ready-to-activate { animation: rune-pulse 1.5s ease-in-out infinite; border-color: var(--sacred-green) !important; box-shadow: 0 0 12px var(--sacred-green); }
        @keyframes rune-pulse { 0%, 100% { opacity: 1; box-shadow: 0 0 8px var(--sacred-green); } 50% { opacity: 0.85; box-shadow: 0 0 16px var(--sacred-green); } }
        .rune .glyph { font-size: 18px; }

        /* Rune type colors: Fire (immediate) vs Chip (input required) - solid backgrounds */
        .rune.rune-fire {
            border-color: rgba(255, 68, 68, 0.4);
            background: var(--bg-dark);
        }
        .rune.rune-fire:hover {
            border-color: var(--sacred-red);
            background: #1a0808;
            box-shadow: 0 0 8px rgba(255, 68, 68, 0.3);
        }

        .rune.rune-chip {
            border-color: rgba(255, 170, 0, 0.4);
            background: var(--bg-dark);
        }
        .rune.rune-chip:hover {
            border-color: var(--sacred-gold);
            background: #1a1408;
            box-shadow: 0 0 8px rgba(255, 170, 0, 0.3);
        }

        .rune.auth-required { opacity: 0.35; cursor: not-allowed; }
        .rune.auth-required.authenticated { opacity: 1; cursor: pointer; }
        .rune.vessel-auth-required { opacity: 0.5; }
        .rune.terminal-unavailable { opacity: 0.3; cursor: not-allowed; }
        .rune.from-other-arcana { border-style: dashed; opacity: 0.8; }

        /* Sacred runes (stem) - solid background so plate shows behind, not through */
        .rune.rune-sacred {
            background: var(--bg-dark);
            border-color: rgba(255, 255, 255, 0.1);
        }
        .rune.rune-sacred .glyph {
            font-size: 20px;
            color: #666;
        }
        .rune.rune-sacred:hover {
            background: rgba(255, 255, 255, 0.05);
            border-color: #444;
        }
        .rune.rune-sacred:hover .glyph { color: #fff; }
        .rune.rune-sacred.primed { animation: double-tap-pulse 0.4s ease-in-out infinite; }
        .rune.rune-sacred.triple-primed { animation: triple-tap-pulse 0.3s ease-in-out infinite; }

        /* State button colors - elemental mapping, persistent LED glow */
        .rune.rune-sacred.state-sealed,
        .rune.rune-sacred.state-sealed:hover {
            border-color: rgba(100, 149, 237, 0.6) !important;
            background: rgba(100, 149, 237, 0.2) !important;
        }
        .rune.rune-sacred.state-sealed .glyph { color: #6495ED !important; }
        .rune.rune-sacred.state-sealed:hover {
            background: rgba(100, 149, 237, 0.3) !important;
            border-color: #6495ED !important;
        }

        .rune.rune-sacred.state-active,
        .rune.rune-sacred.state-active:hover {
            border-color: rgba(255, 255, 255, 0.35) !important;
            background: rgba(255, 255, 255, 0.1) !important;
        }
        .rune.rune-sacred.state-active .glyph { color: #FFFFFF !important; }
        .rune.rune-sacred.state-active:hover {
            background: rgba(255, 255, 255, 0.18) !important;
            border-color: rgba(255, 255, 255, 0.6) !important;
        }

        .rune.rune-sacred.state-potential,
        .rune.rune-sacred.state-potential:hover {
            border-color: rgba(255, 140, 0, 0.6) !important;
            background: rgba(255, 140, 0, 0.2) !important;
        }
        .rune.rune-sacred.state-potential .glyph { color: #FF8C00 !important; }
        .rune.rune-sacred.state-potential:hover {
            background: rgba(255, 140, 0, 0.3) !important;
            border-color: #FF8C00 !important;
        }

        /* Board Mode button colors - match plate colors, persist on rollout */
        .rune.rune-sacred.mode-earth,
        .rune.rune-sacred.mode-earth:hover {
            border-color: rgba(100, 149, 237, 0.6) !important;
            background: rgba(100, 149, 237, 0.2) !important;
        }
        .rune.rune-sacred.mode-earth .glyph { color: #6495ed !important; }
        .rune.rune-sacred.mode-earth:hover {
            background: rgba(100, 149, 237, 0.3) !important;
            border-color: #6495ed !important;
        }

        .rune.rune-sacred.mode-air,
        .rune.rune-sacred.mode-air:hover {
            border-color: rgba(255, 255, 255, 0.35) !important;
            background: rgba(255, 255, 255, 0.1) !important;
        }
        .rune.rune-sacred.mode-air .glyph { color: #ffffff !important; }
        .rune.rune-sacred.mode-air:hover {
            background: rgba(255, 255, 255, 0.18) !important;
            border-color: rgba(255, 255, 255, 0.6) !important;
        }

        .rune.rune-sacred.mode-fire,
        .rune.rune-sacred.mode-fire:hover {
            border-color: rgba(255, 140, 0, 0.6) !important;
            background: rgba(255, 140, 0, 0.2) !important;
        }
        .rune.rune-sacred.mode-fire .glyph { color: #ff8c00 !important; }
        .rune.rune-sacred.mode-fire:hover {
            background: rgba(255, 140, 0, 0.3) !important;
            border-color: #ff8c00 !important;
        }

        @keyframes air-pulse { 0%, 100% { background: rgba(255, 255, 255, 0.05); } 50% { background: rgba(255, 255, 255, 0.15); } }
        @keyframes double-tap-pulse { 0%, 100% { background: rgba(100, 180, 255, 0.1); } 50% { background: rgba(100, 180, 255, 0.3); } }
        @keyframes triple-tap-pulse { 0%, 100% { background: rgba(255, 150, 50, 0.2); } 50% { background: rgba(255, 150, 50, 0.5); } }

        /* Navigation runes (arrows in hexcube) - deprecated, nav removed from cube */
        .rune.rune-nav {
            background: var(--bg-dark);
            border-color: rgba(100, 150, 255, 0.3);
        }
        .rune.rune-nav .glyph {
            font-size: 18px;
            color: #668;
        }
        .rune.rune-nav:hover {
            background: #0d1018;
            border-color: rgba(100, 150, 255, 0.6);
        }
        .rune.rune-nav:hover .glyph { color: #aaf; }
        .rune.rune-nav .addr {
            display: block;
            font-size: 10px;
            color: #446;
            margin-top: 2px;
        }
        .rune.rune-nav:hover .addr { color: #88a; }
        .rune.rune-selected {
            background: rgba(255, 170, 0, 0.15) !important;
            border-color: var(--sacred-gold) !important;
        }
        .rune.rune-selected .glyph { color: var(--sacred-gold) !important; }
        .rune.rune-selected .addr { color: #aa8 !important; }

        /* Day 00189 Navigation Colors - button color = level you're navigating INTO - solid backgrounds */
        .rune.rune-nav .nav-glyph { font-size: 16px; font-weight: bold; }

        /* HexCube = purple (#9B59B6) */
        .rune.nav-hexcube { border-color: rgba(155, 89, 182, 0.4); }
        .rune.nav-hexcube .nav-glyph { color: #9B59B6; }
        .rune.nav-hexcube:hover { background: #1a0f1c; border-color: #9B59B6; }

        /* Cube = green (#27AE60) */
        .rune.nav-cube { border-color: rgba(39, 174, 96, 0.4); }
        .rune.nav-cube .nav-glyph { color: #27AE60; }
        .rune.nav-cube:hover { background: #0f1a12; border-color: #27AE60; }

        /* Cluster = orange (#E67E22) */
        .rune.nav-cluster { border-color: rgba(230, 126, 34, 0.4); }
        .rune.nav-cluster .nav-glyph { color: #E67E22; }
        .rune.nav-cluster:hover { background: #1e150d; border-color: #E67E22; }

        /* Set = red (#E74C3C) */
        .rune.nav-set { border-color: rgba(231, 76, 60, 0.4); }
        .rune.nav-set .nav-glyph { color: #E74C3C; }
        .rune.nav-set:hover { background: #1e0f0c; border-color: #E74C3C; }

        /* Node = light blue (#3498DB) */
        .rune.nav-node { border-color: rgba(52, 152, 219, 0.4); }
        .rune.nav-node .nav-glyph { color: #3498DB; }
        .rune.nav-node:hover { background: #10181f; border-color: #3498DB; }

        /* Array = white (#FFFFFF) */
        .rune.nav-array { border-color: rgba(255, 255, 255, 0.4); }
        .rune.nav-array .nav-glyph { color: #FFFFFF; }
        .rune.nav-array:hover { background: #1a1a1a; border-color: #FFFFFF; }

        /* Disabled runes */
        .rune.rune-disabled {
            opacity: 0.2;
            cursor: default;
        }
        .rune.rune-disabled:hover {
            border-color: var(--border-subtle);
            background: var(--bg-dark);
        }

        /* Action runes (state toggle etc) */
        .rune.rune-action {
            border-color: rgba(255, 255, 255, 0.2);
        }
        .rune.rune-action:hover {
            border-color: #fff;
            background: rgba(255, 255, 255, 0.1);
        }
        .rune.rune-action.active {
            border-color: #fff;
            background: rgba(255, 255, 255, 0.15);
        }
        .rune.rune-action.active .glyph { color: #fff; }


        .compose-area { padding: 6px; }
        .compose-input {
            width: 100%;
            background: #000;
            border: 1px solid var(--border-subtle);
            border-radius: 4px;
            color: #fff;
            font-family: inherit;
            font-size: 13px;
            padding: 8px 10px;
            resize: none;
            min-height: 80px;
            max-height: 150px;
            outline: none;
        }
        .compose-input:focus { border-color: var(--sacred-red); }
        .compose-input::placeholder { color: #444; transition: opacity 0.4s ease; }
        .compose-input.placeholder-fade::placeholder { opacity: 0; }

        /* Message center */
        .compose-wrapper {
            position: relative;
            width: 100%;
            background: #000;
            border: 1px solid var(--border-subtle);
            border-radius: 6px;
            padding: 10px;
            display: flex;
            flex-direction: column;
            gap: 8px;
        }
        .compose-wrapper:focus-within { border-color: var(--sacred-red); }
        .compose-input-row {
            display: flex;
            align-items: flex-start;
            gap: 4px;
            min-height: 70px;
        }
        .compose-wrapper .compose-input {
            flex: 1;
            min-width: 100px;
            background: transparent;
            border: none;
            padding: 0;
            min-height: 70px;
            max-height: 120px;
            resize: none;
        }
        .compose-wrapper .compose-input:focus { border-color: transparent; outline: none; }
        .compose-wrapper.command-mode .compose-input { color: #fff; caret-color: var(--sacred-gold); }
        .compose-prefix {
            color: #666;
            font-size: 13px;
            white-space: nowrap;
            padding-top: 2px;
        }
        .compose-prefix:empty { display: none; }
        .compose-prefix .cmd { color: var(--sacred-red); }
        .compose-prefix .chip {
            display: inline-block;
            background: rgba(255, 170, 0, 0.2);
            border: 1px solid var(--sacred-gold);
            border-radius: 3px;
            padding: 1px 6px;
            margin: 0 2px;
            color: var(--sacred-gold);
            font-size: 11px;
            cursor: pointer;
        }
        .compose-prefix .chip:hover { background: rgba(255, 170, 0, 0.35); }
        .compose-prefix .chip.filled { background: var(--sacred-gold); color: #000; }
        .compose-actions {
            display: flex;
            justify-content: flex-end;
            gap: 8px;
        }

        .input-chip {
            display: inline-flex;
            align-items: center;
            background: rgba(255, 170, 0, 0.15);
            border: 1px solid var(--sacred-gold);
            border-radius: 4px;
            padding: 2px 8px;
            font-size: 12px;
            color: var(--sacred-gold);
            cursor: pointer;
            transition: all 0.15s;
        }
        .input-chip:hover {
            background: rgba(255, 170, 0, 0.25);
        }
        .input-chip.active {
            background: var(--sacred-gold);
            color: #000;
        }
        .input-chip .chip-label { margin-right: 4px; opacity: 0.7; font-size: 10px; }
        .input-chip .chip-value { font-family: inherit; }
        .input-chip .chip-placeholder { opacity: 0.6; font-style: italic; }

        /* Clickable commands in placeholder messages */
        .placeholder-cmd {
            color: var(--sacred-gold);
            cursor: pointer;
            text-decoration: underline;
        }
        .compose-send {
            background: var(--sacred-red);
            border: none;
            color: #fff;
            padding: 6px 14px;
            border-radius: 4px;
            font-family: inherit;
            font-size: 12px;
            cursor: pointer;
        }
        .compose-send:hover { background: #ff5555; }
        .compose-send:disabled { background: #333; color: #666; cursor: not-allowed; }
        .compose-clear {
            background: transparent;
            border: 1px solid var(--border-subtle);
            color: #666;
            padding: 6px 12px;
            border-radius: 4px;
            font-family: inherit;
            font-size: 12px;
            cursor: pointer;
        }
        .compose-clear:hover { border-color: #444; color: #999; }

        /* Elemental Wand - D-pad for glyph input */
        .wand {
            display: grid;
            grid-template-areas:
                "state fire  rsv"
                "zero  air   one"
                "bang  earth slash";
            grid-template-columns: 32px 32px 32px;
            grid-template-rows: 32px 32px 32px;
            gap: 2px;
            padding: 4px;
            background: rgba(20, 20, 20, 0.8);
            border-radius: 6px;
            flex-shrink: 0;
        }
        .wand-btn {
            width: 32px;
            height: 32px;
            border: 1px solid #333;
            border-radius: 4px;
            background: #1a1a1a;
            color: #888;
            font-size: 16px;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all 0.15s ease;
        }
        .wand-btn:hover {
            border-color: #555;
            color: #fff;
        }
        .wand-btn:active {
            background: #333;
            transform: scale(0.95);
        }
        .wand-btn.fire { grid-area: fire; color: #f84; }
        .wand-btn.air { grid-area: air; color: #fff; }
        .wand-btn.earth { grid-area: earth; color: #8a4; }
        .wand-btn.zero { grid-area: zero; color: #666; }
        .wand-btn.one { grid-area: one; color: #fff; }
        .wand-btn.bang { grid-area: bang; color: var(--sacred-gold); }
        .wand-btn.slash { grid-area: slash; color: var(--sacred-gold); }
        .wand-btn.state { grid-area: state; color: #888; }
        .wand-btn.state.active { color: #fff; background: rgba(255, 255, 255, 0.15); }
        .wand-btn.rsv { grid-area: rsv; color: #333; cursor: default; }
        .wand-btn.fire:hover { background: rgba(255, 136, 68, 0.2); }
        .wand-btn.air:hover { background: rgba(255, 255, 255, 0.1); }
        .wand-btn.air.primed { animation: air-pulse 0.5s ease-in-out infinite; }
        @keyframes air-pulse { 0%, 100% { background: rgba(255, 255, 255, 0.1); } 50% { background: rgba(255, 255, 255, 0.25); } }
        .wand-btn.earth:hover { background: rgba(136, 170, 68, 0.2); }
        .wand-btn.bang:hover, .wand-btn.slash:hover { background: rgba(255, 170, 0, 0.2); }
        .wand-btn.state:hover { background: rgba(255, 255, 255, 0.1); }
        .wand-btn.disabled { color: #333; cursor: default; }
        .wand-btn.disabled:hover { background: transparent; }
        /* Non-sacred runes (emoji) on surfaces */
        .wand-btn.rune-fire { border-color: rgba(255, 68, 68, 0.4); background: rgba(255, 68, 68, 0.08); }
        .wand-btn.rune-fire:hover { border-color: var(--sacred-red); background: rgba(255, 68, 68, 0.2); }
        .wand-btn.rune-chip { border-color: rgba(255, 170, 0, 0.4); background: rgba(255, 170, 0, 0.08); }
        .wand-btn.rune-chip:hover { border-color: var(--sacred-gold); background: rgba(255, 170, 0, 0.2); }

        @media (max-width: 768px) {
            .runeboard { width: 300px; right: 10px; }
        }

        /* Drawer - slides from runeboard */
        .runeboard-drawer {
            position: absolute;
            left: 0; right: 0;
            background: rgba(10, 10, 10, 0.98);
            border: 1px solid var(--border-subtle);
            border-radius: 8px;
            max-height: 300px;
            overflow-y: auto;
            opacity: 0;
            pointer-events: none;
            transition: transform 0.2s ease, opacity 0.2s ease;
            z-index: 99;
        }
        .runeboard-drawer.open { opacity: 1; pointer-events: auto; }
        .runeboard-drawer.from-top {
            bottom: 100%;
            margin-bottom: 8px;
            transform: translateY(10px);
        }
        .runeboard-drawer.from-top.open { transform: translateY(0); }
        .runeboard-drawer.from-bottom {
            top: 100%;
            margin-top: 8px;
            transform: translateY(-10px);
        }
        .runeboard-drawer.from-bottom.open { transform: translateY(0); }

        .drawer-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 10px 12px;
            border-bottom: 1px solid var(--border-subtle);
            position: sticky;
            top: 0;
            background: rgba(10, 10, 10, 0.98);
        }
        .drawer-title {
            font-size: 12px;
            color: var(--sacred-gold);
            text-transform: uppercase;
            letter-spacing: 1px;
        }
        .drawer-close {
            background: none;
            border: none;
            color: #666;
            font-size: 16px;
            cursor: pointer;
            padding: 0 4px;
        }
        .drawer-close:hover { color: #fff; }

        .drawer-content { padding: 10px 12px; }

        .drawer-section { margin-bottom: 12px; }
        .drawer-section:last-child { margin-bottom: 0; }
        .drawer-section-title {
            font-size: 10px;
            color: #666;
            text-transform: uppercase;
            letter-spacing: 1px;
            margin-bottom: 6px;
        }

        .drawer-item {
            display: flex;
            align-items: center;
            gap: 8px;
            padding: 8px 10px;
            background: var(--bg-dark);
            border: 1px solid var(--border-subtle);
            border-radius: 4px;
            margin-bottom: 6px;
            color: #ccc;
            font-size: 12px;
            text-decoration: none;
            transition: all 0.1s;
        }
        .drawer-item:hover {
            border-color: var(--sacred-gold);
            background: rgba(255, 170, 0, 0.08);
            color: #fff;
        }
        .drawer-item .glyph { font-size: 14px; }
        .drawer-item .label { flex: 1; }
        .drawer-item .meta { color: #555; font-size: 10px; }

        .drawer-token {
            font-family: monospace;
            font-size: 11px;
            background: #000;
            padding: 6px 8px;
            border-radius: 4px;
            word-break: break-all;
            color: #888;
            margin-bottom: 8px;
        }
        .drawer-btn {
            background: var(--bg-dark);
            border: 1px solid var(--border-subtle);
            color: #888;
            padding: 6px 12px;
            border-radius: 4px;
            font-family: inherit;
            font-size: 11px;
            cursor: pointer;
            margin-right: 6px;
        }
        .drawer-btn:hover { border-color: #444; color: #ccc; }
        .drawer-btn.danger:hover { border-color: var(--sacred-red); color: var(--sacred-red); }

```

