/* INK REALM v3.0 - Extracted & Externalized Styles */

/* ========== STYLE BLOCK 1 ========== */

:root {
            --red: #ff0033;
            --black: #0a0a0a;
            --white: #fff;
            --gray-1: #111;
            --gray-2: #222;
            --gray-3: #333;
            --gray-6: #666;
            --gray-9: #999;
            --gray-c: #ccc;
        }

        ::selection {
            background: var(--red);
            color: var(--black);
            text-shadow: none;
        }

        /* ---------- reset & base ---------- */
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        body {
            font-family: 'IBM Plex Mono', 'Courier New', monospace;
            background: #000;
            color: #fff;
            height: 100vh;
            overflow: hidden;
            position: relative;
        }

        /* ---------- CRT overlay ---------- */
        #crt-overlay {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            pointer-events: none;
            z-index: 9999;
            box-shadow: inset 0 0 100px rgba(0,0,0,0.9);
        }

        .scanline {
            width: 100%;
            height: 100%;
            background: linear-gradient(to bottom, rgba(255,255,255,0) 50%, rgba(0,0,0,0.5) 50%);
            background-size: 100% 4px;
            animation: scanline 10s linear infinite, flicker 0.15s infinite;
        }

        @keyframes scanline {
            0% { background-position: 0 0; }
            100% { background-position: 0 100%; }
        }

        @keyframes flicker {
            0% { opacity: 0.3; }
            50% { opacity: 0.4; }
            100% { opacity: 0.3; }
        }

        /* ---------- splash ---------- */
        .glitch-splash {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: #000;
            z-index: 10000;
            display: flex;
            justify-content: center;
            align-items: center;
            flex-direction: column;
            pointer-events: none;
        }
        .glitch-text {
            font-size: 1.5rem;
            letter-spacing: .5rem;
            display: flex;
            align-items: center;
            gap: 15px;
            color: #fff;
            text-shadow: 0 0 10px rgba(255,255,255,.5);
        }
        .splash-icon {
            height: 40px;
            filter: grayscale(100%) contrast(1.5);
        }
        .glitch-subtext {
            font-size: .8rem;
            color: #666;
            margin-top: 15px;
            letter-spacing: 2px;
        }

        /* ---------- header ---------- */
        .header {
            position: fixed;
            top: 0;
            width: 100%;
            height: 60px; 
            box-sizing: border-box; 
            z-index: 100;
            background: rgba(0, 0, 0, 0.8) !important;
            backdrop-filter: blur(5px);
            border-bottom: 1px solid #333;
            display: flex; 
            align-items: center; 
        }
        .header-center {
            position: absolute;
            left: 50%;
            transform: translateX(-50%);
            display: flex;
            align-items: center;
            gap: 20px;
            height: 100%;
        }    
        .logo {
            display: flex;
            align-items: center;
            gap: 10px;
        }
        .logo-icon {
            height: 20px;
            filter: grayscale(100%);
        }
        .logo-text {
            font-size: 1.2rem;
            font-weight: 400;
            letter-spacing: 3px;
            text-transform: uppercase;
        }
        .model-select {
            background: var(--gray-1);
            color: var(--white);
            border: 1px solid var(--gray-3);
            padding: .5rem 1rem;
            font-family: 'IBM Plex Mono', monospace;
            font-size: .85rem;
            outline: none;
            cursor: pointer;
            min-width: 250px;
        }
        .model-select option {
            background: var(--black);
            color: var(--white);
        }
        .model-select:hover {
            border-color: var(--gray-6);
        }
        .status-indicator {
            display: flex;
            align-items: center;
            gap: .5rem;
            font-size: .9rem;
        }
        .status-dot {
            width: 8px;
            height: 8px;
            border-radius: 50%;
            background: #e00d1f;
            animation: pulse 2s infinite;
        }
        .status-dot.error {
            background: #f7f705;
        }
        @keyframes pulse {
            0%, 100% { opacity: .3; }
            50% { opacity: 1; }
        }

        /* ---------- 3-column desktop layout ---------- */
        .container {
            display: flex;
            height: 100vh;
            padding-top: 60px; 
            padding-bottom: 30px;
            width: 100%;
        }

        /* Column 1: Live Document Editor */
        .article-panel {
            width: 400px;
            min-width: 400px;
            display: flex;
            flex-direction: column;
            background: #080203;
            border-right: 1px solid var(--gray-3);
            flex-shrink: 0; 
        }

        .article-header {
            padding: 0.75rem 1rem;
            background: var(--gray-1);
            border-bottom: 1px solid var(--gray-3);
            font-size: .8rem;
            color: var(--gray-6);
            text-transform: uppercase;
            letter-spacing: 1px;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .article-level-hud {
            display: flex;
            gap: 4px;
            align-items: center;
        }

        .doc-lvl-btn {
            background: #000;
            border: 1px solid #333;
            color: #888;
            font-family: 'IBM Plex Mono', monospace;
            font-size: 0.65rem;
            padding: 3px 6px;
            cursor: pointer;
            transition: all 0.2s ease;
        }

        .doc-lvl-btn.active, .doc-lvl-btn:hover {
            color: #000;
            background: var(--red);
            border-color: var(--red);
            font-weight: bold;
            box-shadow: 0 0 8px rgba(255, 0, 51, 0.5);
        }

        article {
            flex: 1;
            background: #0d0d0d;
            color: #dcdcdc;
            border: none;
            padding: 1.5rem;
            font-family: 'IBM Plex Mono', monospace;
            font-size: .9rem;
            resize: none;
            outline: none;
            line-height: 1.6;
            overflow-y: auto;
        }

        article:empty::before {
            content: 'Article auto-saves to URL hash. Use # for title.\A\AExample:\A# My Story\A\AOnce upon a time...';
            color: #fff; 
            font-style: italic;
            pointer-events: none;
            white-space: pre-wrap;
            display: block;
            opacity: 0.4; 
        }

        article:focus::before {
            content: '';
        }

        /* Document Theme Levels */
        article.level-0 {
            background: #0d0d0d !important;
            color: #dcdcdc !important;
            font-family: 'IBM Plex Mono', monospace !important;
            letter-spacing: 0;
            text-shadow: none;
        }

        article.level-1 {
            background: #080203 !important;
            color: #ff3355 !important;
            font-family: 'Courier New', monospace !important;
            text-shadow: 0 0 8px rgba(255, 0, 51, 0.6);
            letter-spacing: 0.05em;
        }

        article.level-2 {
            background: #110507 !important;
            color: #ffffff !important;
            font-family: 'Georgia', serif !important;
            font-style: italic;
            font-size: 1.05rem !important;
            text-shadow: 0 2px 10px rgba(0, 0, 0, 0.9);
            letter-spacing: 0.03em;
        }

        article.level-3 {
            background: #050002 !important;
            color: #fff0f3 !important;
            font-family: 'IBM Plex Mono', monospace !important;
            text-shadow: 0 0 10px #ff0033, 0 0 20px rgba(255, 0, 51, 0.8);
            letter-spacing: 0.12em;
            box-shadow: inset 0 0 30px rgba(255, 0, 51, 0.15);
        }

        /* Column 2: Center Writing/Chat */
        .writing-container {
            flex: 1;
            display: flex;
            flex-direction: column;
            background: var(--black);
            border-right: 1px solid var(--gray-3);
            min-width: 320px;
        }

        /* Column 3: Scratchpad */
        .notepad-panel {
            width: 350px;
            display: flex;
            flex-direction: column;
            background: var(--black);
            overflow-y: auto;
            flex-shrink: 0;
        }
        .notepad-header {
            padding: 0.75rem 1rem;
            background: var(--gray-1);
            border-bottom: 1px solid var(--gray-3);
            font-size: .8rem;
            color: var(--gray-6);
            display: flex;
            justify-content: space-between;
            align-items: center;
            text-transform: uppercase;
            letter-spacing: 1px;
        }
        .notepad-actions {
            display: flex;
            gap: 15px;
        }
        .notepad-btn {
            cursor: pointer;
            color: var(--gray-9);
            transition: color .2s;
        }
        .notepad-btn:hover {
            color: var(--white);
        }
        .notepad-area {
            flex: 1;
            background: #8b0000 !important;
            color: #000000 !important;
            font-weight: 500;
            border: none;
            border-bottom: 1px solid var(--gray-3);
            padding: 1.5rem;
            font-family: 'IBM Plex Mono', monospace;
            font-size: .9rem;
            resize: none;
            outline: none;
            line-height: 1.6;
        }
        .notepad-area::placeholder {
            color: rgba(0, 0, 0, 0.6);
            font-style: italic;
        }
        .notepad-area:focus::placeholder {
            color: transparent;
        }

        /* ---------- chat ---------- */
        .chat-messages {
            flex: 1;
            overflow-y: auto;
            padding: 2rem;
            display: flex;
            flex-direction: column;
            gap: 1.5rem;
        }
        .message {
            max-width: 80%;
            line-height: 1.6;
            font-family: 'Courier New', monospace;
        }
        .message.user {
            align-self: flex-end;
            text-align: right;
            color: var(--gray-9);
            font-style: italic;
        }
        .message.ai {
            align-self: flex-start;
            color: var(--gray-c);
        }
        .message.system {
            align-self: center;
            font-size: .9rem;
            text-align: center;
            max-width: 90%;
            color: var(--gray-6);
        }
        .message-header {
            font-size: .7rem;
            color: var(--gray-6);
            margin-bottom: .5rem;
            text-transform: uppercase;
            letter-spacing: 1px;
        }

        /* ---------- input ---------- */
        .input-container {
            border-top: 1px solid var(--gray-3);
            padding: 1.5rem 2rem;
            background: var(--gray-1);
        }
        .input-row {
            display: flex;
            gap: 1rem;
            align-items: stretch;
        }
        .text-input {
            flex: 1;
            padding: 1rem;
            background: var(--black);
            border: 1px solid var(--gray-3);
            color: var(--white);
            font-family: 'IBM Plex Mono', monospace;
            font-size: .95rem;
            resize: none;
            min-height: 60px;
            line-height: 1.6;
        }
        .text-input:focus {
            outline: none;
            border-color: var(--white);
        }
        .send-button {
            padding: .75rem 1.5rem;
            background: var(--black);
            border: 1px solid var(--white);
            color: var(--white);
            font-family: 'IBM Plex Mono', monospace;
            font-weight: bold;
            cursor: pointer;
            text-transform: uppercase;
            letter-spacing: 1px;
            transition: all .2s;
            min-height: 60px;
        }
        .send-button:hover {
            background: var(--white);
            color: var(--black);
        }
        .send-button:disabled {
            opacity: .5;
            cursor: not-allowed;
        }

        /* ---------- footer ---------- */
        .footer {
            position: fixed;
            bottom: 0;
            width: 100%;
            height: 30px;
            background: var(--black);
            border-top: 1px solid var(--gray-3);
            display: block;
            align-items: center;
            padding: 0 2rem;
            justify-content: space-between;
            font-size: .7rem;
            color: var(--gray-6);
            z-index: 90;
        }
        .footer a {
            color: var(--gray-9);
            text-decoration: none;
        }
        .footer a:hover {
            color: var(--white);
        }
        .header-icon {
            cursor: pointer;
        }

        /* ---------- scrollbars & effects ---------- */
        ::-webkit-scrollbar {
            width: 8px;
        }
        ::-webkit-scrollbar-track {
            background: var(--gray-1);
        }
        ::-webkit-scrollbar-thumb {
            background: var(--gray-3);
        }
        ::-webkit-scrollbar-thumb:hover {
            background: var(--gray-6);
        }

        .loading-dots::after {
            content: '';
            animation: loading-dots 1.5s steps(4,end) infinite;
        }
        @keyframes loading-dots {
            0%, 20% { content: '.'; }
            40% { content: '..'; }
            60% { content: '...'; }
            80%, 100% { content: ''; }
        }

        .orb-container {
            display: inline-block;
            vertical-align: middle;
            margin-right: 15px; 
            width: 50px;
            height: 50px;
            position: relative;
        }
        .glitch-orb {
            width: 100%;
            height: 100%;
            fill: none;
            stroke-width: 3;
            overflow: visible;
        }
        .orb-circle { stroke: #ff0033; } 
        .orb-triangle { stroke: #ffffff; } 
        .orb-container svg {
            animation: slow-spin 10s linear infinite;
            filter: drop-shadow(0 0 5px rgba(255, 0, 51, 0.4));
            transition: all 0.2s ease;
        }
        .orb-container:hover svg {
            animation: glitch-shake 0.3s cubic-bezier(.25, .46, .45, .94) both infinite;
            filter: drop-shadow(2px 2px 0px rgba(255, 255, 255, 0.5)) 
                    drop-shadow(-2px -2px 0px rgba(255, 0, 51, 0.8));
        }
        .orb-container:hover .orb-triangle {
            fill: rgba(255, 255, 255, 0.1);
        }

        @keyframes slow-spin {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }
        @keyframes glitch-shake {
            0% { transform: translate(0) rotate(0deg); }
            20% { transform: translate(-2px, 2px) rotate(-5deg); }
            40% { transform: translate(-2px, -2px) rotate(5deg); }
            60% { transform: translate(2px, 2px) rotate(-5deg); }
            80% { transform: translate(2px, -2px) rotate(5deg); }
            100% { transform: translate(0) rotate(0deg); }
        }

        .live-feed {
            padding: 1rem 1.5rem;
            font-size: .75rem;
            color: var(--gray-c);
            display: flex;
            flex-direction: column;
            gap: 1.2rem;
        }
        .feed-section { line-height: 1.5; }
        .feed-title {
            color: var(--gray-6);
            letter-spacing: 1px;
            text-transform: uppercase;
            margin-bottom: .25rem;
        }
        .feed-item {
            color: var(--white);
            font-family: 'IBM Plex Mono', monospace;
        }

        #console-log {
            max-height: 120px;
            overflow-y: auto;
            font-size: 0.65rem;
            border: 1px solid #222;
            padding: 6px;
            background: #050505;
            display: flex;
            flex-direction: column;
            gap: 3px;
        }
        .log-info { color: #888; }
        .log-warn { color: #f7f705; }
        .log-error { color: #ff0033; }
 
        #ton-qr {
            width: 60px; 
            border: 1px solid #ff0033;
            padding: 2px;
            background: #000;
            cursor: zoom-in; 
            transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275); 
            box-shadow: 0 0 10px rgba(255, 0, 51, 0.2);
            position: relative; 
            z-index: 10001; 
        }
        #ton-qr:hover {
            box-shadow: 0 0 20px rgba(255, 0, 51, 0.6);
            border-color: #fff;
        }
   #ton-qr.expanded {
    position: fixed;
    top: 50vh;
    left: 50vw;
    transform: translate(-50%, -50%);
    margin: 0;
    width: min(75vmin, 280px);
    height: min(75vmin, 280px);
    z-index: 9999;
    background: #fff;
    padding: 8px;
    border: 2px solid var(--red);
    /* 100vmax creates an instant dark backdrop over the rest of the screen */
    box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.82), 0 0 30px var(--red);
    cursor: pointer;
}

        .message.ai .message-content.typing::after {
            content: "█";
            animation: blink 1s step-end infinite;
            margin-left: 2px;
            vertical-align: middle;
        }
        @keyframes blink {
            0%, 100% { opacity: 1; }
            50% { opacity: 0; }
        } 

        .controls { display: flex; align-items: center; }
        .control-group {
            display: flex;
            align-items: center;
            gap: 15px;
            background: #000;
            padding: 5px;
            border: 1px solid #222; 
        }
        .terminal-label {
            color: #666;
            font-size: 0.7rem;
            letter-spacing: 1px;
            font-family: 'IBM Plex Mono', monospace;
        }
        .custom-select-container select { display: none; }
        .custom-select-container {
            position: relative;
            width: 280px; 
            font-family: 'IBM Plex Mono', monospace;
            font-size: 0.8rem;
            user-select: none;
        }
        .select-selected {
            background-color: #000;
            color: #fff; 
            padding: 10px 15px;
            border: 1px solid #333;
            cursor: pointer;
            display: flex;
            justify-content: space-between;
            align-items: center;
            transition: all 0.2s ease;
        }
        .select-selected:hover { border-color: #999; }
        .select-selected:after {
            content: "";
            width: 0;
            height: 0;
            border: 5px solid transparent;
            border-top-color: #fff;
            margin-left: 10px;
        }
        .select-selected.select-arrow-active {
            border-color: #ff0033; 
            box-shadow: 0 0 10px rgba(255, 0, 51, 0.2);
        }
        .select-selected.select-arrow-active:after {
            border-top-color: transparent;
            border-bottom-color: #ff0033; 
            transform: translateY(-5px);
        }
        .select-items {
            position: absolute;
            background-color: #000;
            top: 100%;
            left: 0;
            right: 0;
            z-index: 9999;
            border: 1px solid #ff0033; 
            border-top: none;
            max-height: 400px;
            overflow-y: auto;
            box-shadow: 0 10px 20px rgba(0,0,0,0.9);
        }
        .select-items div {
            color: #ccc;
            padding: 10px 15px;
            cursor: pointer;
            border-bottom: 1px solid #111;
        }
        .select-items div:hover {
            background-color: #ff0033; 
            color: #000; 
            font-weight: bold;
        }
        .select-hide { display: none; }
        .terminal-btn {
            background: #111;
            color: #fff;
            border: 1px solid #333;
            padding: 10px 20px;
            font-family: 'IBM Plex Mono', monospace;
            cursor: pointer;
            text-transform: uppercase;
            font-size: 0.75rem;
            transition: all 0.2s;
        }
        .terminal-btn:hover {
            background: #fff;
            color: #000;
        }

        .mobile-tab-bar {
            display: none;
        }

        .mobile-warning {
            display: none;
            margin-top: 20px;
            font-size: 0.65rem;
            color: var(--red);
            letter-spacing: 1.5px;
            border: 1px dashed var(--red);
            padding: 6px 12px;
            background: rgba(255, 0, 51, 0.05);
        }

        /* =========================================
           TOP-LEVEL PRINT / PDF EXPORT ENGINE
           ========================================= */
        @media print {
            /* Hide all chrome & panels */
            #crt-overlay, .glitch-splash, .header, .mobile-tab-bar, 
            .writing-container, .notepad-panel, .footer, .article-header {
                display: none !important;
            }

            body, html {
                background: #fff !important;
                color: #000 !important;
                height: auto !important;
                overflow: visible !important;
            }

            .container {
                padding: 0 !important;
                display: block !important;
                height: auto !important;
            }

            .article-panel {
                width: 100% !important;
                min-width: 100% !important;
                background: #fff !important;
                border: none !important;
                position: static !important;
                display: block !important;
            }

            article {
                background: #fff !important;
                color: #111 !important;
                font-family: 'IBM Plex Mono', 'Courier New', monospace !important;
                font-size: 11pt !important;
                line-height: 1.7 !important;
                padding: 0.5in !important;
                white-space: pre-wrap !important;
                text-shadow: none !important;
                box-shadow: none !important;
                border: none !important;
            }
        }
/* --- HOLLYWOOD WIRE DISPATCH STYLING --- */
/* --- HORIZONTAL WIRE TICKER --- */
.wire-ticker {
    width: 100%;
    overflow: hidden;
    white-space: nowrap;
    position: relative;
    background: #050505;
    border-left: 2px solid var(--red);
    height: 24px;
    display: flex;
    align-items: center;
}

/* Edge shadows for smooth fade-in/out */
.wire-ticker::before, .wire-ticker::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    width: 15px;
    z-index: 2;
    pointer-events: none;
}
.wire-ticker::before {
    left: 0;
    background: linear-gradient(to right, #050505, transparent);
}
.wire-ticker::after {
    right: 0;
    background: linear-gradient(to left, #050505, transparent);
}

.wire-ticker-track {
    display: inline-flex;
    white-space: nowrap;
    will-change: transform;
    animation: wire-scroll 45s linear infinite;
}

/* Hover to pause so links are easy to click */
.wire-ticker:hover .wire-ticker-track {
    animation-play-state: paused;
}

.wire-ticker a {
    color: #ccc;
    text-decoration: none;
    font-size: 0.72rem;
    padding: 0 16px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: color 0.2s ease;
}

.wire-ticker a:hover {
    color: var(--red);
    text-shadow: 0 0 8px rgba(255, 0, 51, 0.6);
}

.wire-bullet {
    color: var(--red);
    font-weight: bold;
}

.wire-placeholder {
    color: #666;
    font-size: 0.72rem;
    padding-left: 10px;
}

/* Infinite seamless scroll keyframe */
@keyframes wire-scroll {
    0% {
        transform: translateX(0);
    }
    100% {
        transform: translateX(-50%);
    }
}
             /* Search Overlay Styles */
    /* Search Overlay (Backdrop) */
.searchform-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(5px);
    z-index: 1000;
    display: none;
    justify-content: center;
    align-items: center;
}

.searchform-overlay.active {
    display: flex;
}

/* The Search Pop-Up Box with the GIF Background */
.searchform {
    position: relative;
    background-color: #0a0a0a;
    /* Layer a dark gradient over the GIF so text remains crisp and readable */
    background-image: 
        linear-gradient(rgba(0, 0, 0, 0.75), rgba(0, 0, 0, 0.85)),
        url('https://raw.githubusercontent.com/ghostm68/pantheon/main/mw.inkrealm.info.webp');
    background-position: center;
    background-size: cover;
    background-repeat: no-repeat;
    border: 1px solid var(--red);
    box-shadow: 0 0 30px rgba(255, 0, 51, 0.35);
    padding: 40px;
    max-width: 500px;
    width: 90%;
    text-align: center;
}

/* Terminal-styling for the form elements inside */
.searchform p {
    color: #ccc;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.85rem;
    letter-spacing: 1px;
}

.search-field {
    flex: 1;
    padding: 12px;
    background: rgba(0, 0, 0, 0.85);
    border: 1px solid #333;
    color: #fff;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.9rem;
    outline: none;
}

.search-field:focus {
    border-color: var(--red);
    box-shadow: 0 0 8px rgba(255, 0, 51, 0.4);
}

.search-button {
    padding: 12px 20px;
    background: #111;
    color: #fff;
    border: 1px solid var(--red);
    border-left: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.search-button:hover {
    background: var(--red);
    color: #000;
}
   /* Terminal Close Button for Search */
.btn-close-search {
    position: absolute;
    top: 25px;
    right: 30px;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    color: #fff;
    border: 1px solid #333;
    font-size: 1.25rem;
    text-decoration: none;
    cursor: pointer;
    z-index: 1005;
    transition: all 0.2s ease;
}

.btn-close-search:hover {
    background: var(--red);
    color: #000;
    border-color: var(--red);
    box-shadow: 0 0 15px rgba(255, 0, 51, 0.6);
} 
        /* =========================================
           SINGLE CONSOLIDATED MOBILE ENGINE (< 768px)
           ========================================= */
        /* =========================================
   MOBILE ENGINE (< 768px) — Touch-first layout
   ========================================= */
@media screen and (max-width: 768px) {
    body {
        height: auto;
        min-height: 100dvh;
        min-height: 100svh;
        overflow-x: hidden;
        overflow-y: auto;
        padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    }

    .header {
        height: auto !important;
        min-height: 56px;
        flex-wrap: wrap;
        padding: 8px 12px;
        padding-top: max(8px, env(safe-area-inset-top));
        gap: 8px;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 100;
    }

    .header-center {
        position: static !important;
        transform: none !important;
        width: 100%;
        order: 3;
        justify-content: space-between;
        margin-top: 4px;
        gap: 8px;
    }

    .logo {
        flex: 1;
        min-width: 0;
    }

    .logo-text {
        font-size: 0.95rem;
        letter-spacing: 2px;
    }

    .orb-container {
        width: 36px;
        height: 36px;
        margin-right: 8px;
    }

    .custom-select-container {
        width: min(160px, 42vw) !important;
        font-size: 0.7rem;
    }

    .select-selected {
        padding: 8px 10px;
        font-size: 0.7rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        min-height: 40px;
    }

    .terminal-label { display: none; }

    .terminal-btn {
        padding: 8px 14px;
        font-size: 0.7rem;
        min-height: 40px;
        touch-action: manipulation;
    }

    #ton-qr { display: block; }

    .glitch-text {
        font-size: 1rem;
        letter-spacing: 0.2rem;
    }

    /* Mobile Tab Bar */
    .mobile-tab-bar {
        display: flex;
        position: fixed;
        top: calc(92px + env(safe-area-inset-top, 0px));
        left: 0;
        right: 0;
        width: 100%;
        height: 44px;
        background: #000;
        border-bottom: 1px solid var(--gray-3);
        z-index: 95;
    }

    .mobile-tab {
        flex: 1;
        background: #0d0d0d;
        border: none;
        border-right: 1px solid #222;
        color: #777;
        font-family: 'IBM Plex Mono', monospace;
        font-size: 0.72rem;
        letter-spacing: 1px;
        padding: 0;
        cursor: pointer;
        min-height: 44px;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }

    .mobile-tab:last-child {
        border-right: none;
    }

    .mobile-tab.active {
        background: #1a0005;
        color: var(--red);
        border-bottom: 3px solid var(--red);
        font-weight: bold;
    }

    /* Container & Panel Switching */
    .container {
        padding-top: calc(136px + env(safe-area-inset-top, 0px)) !important;
        padding-bottom: 0 !important;
        height: calc(100dvh - 136px - env(safe-area-inset-top, 0px) - 50px);
        height: calc(100svh - 136px - env(safe-area-inset-top, 0px) - 50px);
        min-height: 400px;
        display: block !important;
        position: relative;
        overflow: hidden;
    }

    .article-panel,
    .writing-container,
    .notepad-panel {
        width: 100% !important;
        min-width: 100% !important;
        height: 100% !important;
        position: absolute;
        top: 0;
        left: 0;
        display: none !important;
        border-right: none !important;
    }

    .container.view-doc .article-panel { display: flex !important; }
    .container.view-chat .writing-container { display: flex !important; }
    .container.view-pad .notepad-panel { display: flex !important; }

    /* ===== FORCE chat input visible ONLY on AI Chat tab ===== */
    .container.view-chat .writing-container {
        display: flex !important;
        flex-direction: column !important;
        overflow: hidden !important;
        height: 100% !important;
    }

    .container.view-chat .chat-messages {
        flex: 1 1 auto !important;
        min-height: 0 !important;
        max-height: 55% !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
        padding: 0.75rem 1rem !important;
    }

    .container.view-chat .input-container {
        flex: 0 0 auto !important;
        flex-shrink: 0 !important;
        min-height: 90px !important;
        padding: 0.6rem 0.75rem !important;
        padding-bottom: max(0.6rem, env(safe-area-inset-bottom)) !important;
        background: var(--gray-1) !important;
        border-top: 1px solid var(--gray-3) !important;
        z-index: 20;
    }

    .container.view-chat .input-row {
        display: flex !important;
        gap: 0.6rem !important;
        align-items: stretch !important;
    }

    .container.view-chat .text-input {
        flex: 1 !important;
        min-height: 48px !important;
        height: 48px !important;
        font-size: 16px !important;
        padding: 0.6rem !important;
        resize: none !important;
    }

    .container.view-chat .send-button {
        min-height: 48px !important;
        height: 48px !important;
        padding: 0 1rem !important;
        font-size: 0.8rem !important;
        flex-shrink: 0 !important;
    }

    /* Explicitly hide input when not on chat tab */
    .container:not(.view-chat) .input-container,
    .container.view-doc .input-container,
    .container.view-pad .input-container {
        display: none !important;
        visibility: hidden !important;
        height: 0 !important;
        min-height: 0 !important;
        padding: 0 !important;
        overflow: hidden !important;
    }

    .article-header {
        flex-wrap: wrap;
        gap: 8px;
        padding: 0.6rem 0.75rem;
    }

    .article-level-hud {
        flex-wrap: wrap;
        gap: 4px;
    }

    .doc-lvl-btn {
        min-height: 36px;
        padding: 6px 10px;
        font-size: 0.7rem;
        touch-action: manipulation;
    }

    article {
        padding: 1rem;
        font-size: 0.95rem;
        -webkit-overflow-scrolling: touch;
    }

    .text-input {
        min-height: 52px;
        font-size: 16px; /* prevent iOS zoom */
        padding: 0.75rem;
    }

    .send-button {
        min-height: 52px;
        padding: 0.5rem 1.1rem;
        font-size: 0.85rem;
        touch-action: manipulation;
    }

    .chat-messages {
        padding: 1rem;
        -webkit-overflow-scrolling: touch;
    }

    .input-container {
        padding: 0.75rem 1rem;
        padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
    }

    .notepad-area {
        font-size: 16px;
        -webkit-overflow-scrolling: touch;
    }

    .live-feed {
        padding: 0.75rem 1rem;
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }

    .mobile-warning {
        display: block;
    }

    #nova-fm-interface {
        top: auto !important;
        bottom: calc(70px + env(safe-area-inset-bottom, 0px));
        right: 10px;
        left: auto;
        align-items: flex-end;
    }

    #nova-fm-panel {
        width: min(280px, 90vw);
    }

    /* Footer - visible under the active panel */
    .footer {
        display: flex !important;
        position: relative !important;
        bottom: auto !important;
        width: 100%;
        height: auto;
        min-height: 40px;
        padding: 12px;
        font-size: 0.7rem;
        color: var(--gray-6);
        background: var(--black);
        border-top: 1px solid var(--gray-3);
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 4px;
        text-align: center;
        z-index: 10;
    }

    .footer a {
        color: var(--gray-9);
    }

    .searchform {
        max-width: 95%;
        padding: 28px 20px;
    }


    /* Compact Intel / Live Feed so hardware alerts are not cropped */
    .container.view-pad .notepad-panel {
        display: flex !important;
        flex-direction: column !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    .container.view-pad .notepad-area {
        flex: 0 0 auto !important;
        min-height: 120px !important;
        max-height: 160px !important;
    }

    .container.view-pad .live-feed {
        flex: 1 1 auto !important;
        padding: 0.5rem 0.75rem !important;
        font-size: 0.7rem !important;
        overflow-y: auto !important;
    }

    .container.view-pad .feed-section {
        margin-bottom: 0.6rem !important;
        line-height: 1.35 !important;
    }

    .container.view-pad .feed-title {
        font-size: 0.65rem !important;
        margin-bottom: 0.15rem !important;
    }

    .container.view-pad #console-log,
    .container.view-pad #hardware-tag,
    .container.view-pad #feed-news,
    .container.view-pad #feed-market {
        font-size: 0.68rem !important;
        line-height: 1.3 !important;
    }

    .btn-close-search {
        top: 16px;
        right: 16px;
        width: 48px;
        height: 48px;
    }
}


/* ========== STYLE BLOCK 2 ========== */

/* ── NOISE OVERLAY ── */
        .noise {
            position: fixed;
            top: -10rem;
            left: -10rem;
            width: calc(max(100vw, 100dvh) + 20rem);
            height: calc(max(100vw, 100dvh) + 20rem);
            z-index: 1000;
            pointer-events: none;
            background-position: 50%;
            transform: translateZ(0);
            animation: noise 2s steps(1) infinite;
            background-image: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI4MCIgaGVpZ2h0PSI4MCIgdmlld0JveD0iMCAwIDgwIDgwIj48cmVjdCB3aWR0aD0iODAiIGhlaWdodD0iODAiIGZpbGw9IiMwZjBmMGYiLz48cmVjdCB3aWR0aD0iMSIgaGVpZ2h0PSIxIiBmaWxsPSIjZmZmIiBvcGFjaXR5PSIwLjA0IiB4PSIwIiB5PSIwIi8+PHJlY3Qgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0iI2ZmZiIgb3BhY2l0eT0iMC4wNiIgeD0iMiIgeT0iMyIvPjxyZWN0IHdpZHRoPSIxIiBoZWlnaHQ9IjEiIGZpbGw9IiNmZmYiIG9wYWNpdHk9IjAuMDMiIHg9IjUiIHk9IjciLz48cmVjdCB3aWR0aD0iMSIgaGVpZ2h0PSIxIiBmaWxsPSIjZmZmIiBvcGFjaXR5PSIwLjA1IiB4PSI5IiB5PSIyIi8+PHJlY3Qgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0iI2ZmZiIgb3BhY2l0eT0iMC4wNyIgeD0iMTIiIHk9IjUiLz48cmVjdCB3aWR0aD0iMSIgaGVpZ2h0PSIxIiBmaWxsPSIjZmZmIiBvcGFjaXR5PSIwLjA0IiB4PSIxNSIgeT0iOSIvPjxyZWN0IHdpZHRoPSIxIiBoZWlnaHQ9IjEiIGZpbGw9IiNmZmYiIG9wYWNpdHk9IjAuMDYiIHg9IjE4IiB5PSIxIi8+PHJlY3Qgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0iI2ZmZiIgb3BhY2l0eT0iMC4wMyIgeD0iMjAiIHk9IjYiLz48cmVjdCB3aWR0aD0iMSIgaGVpZ2h0PSIxIiBmaWxsPSIjZmZmIiBvcGFjaXR5PSIwLjA1IiB4PSIyMyIgeT0iNCIvPjxyZWN0IHdpZHRoPSIxIiBoZWlnaHQ9IjEiIGZpbGw9IiNmZmYiIG9wYWNpdHk9IjAuMDciIHg9IjI2IiB5PSI4Ii8+PC9zdmc+);
            opacity: .25;
            mix-blend-mode: screen;
        }
        @keyframes noise {
            0% { transform: translate3d(0, 9rem, 0); }
            50% { transform: translate3d(-9rem, -4rem, 0); }
            100% { transform: translate3d(0, 9rem, 0); }
        }

        .reveal {
            opacity: 0;
            transform: translateY(30px);
            will-change: transform, opacity;
        }

        /* ── POINTER TRAIL CANVAS ── */
        #trailCanvas {
            position: fixed;
            inset: 0;
            width: 100vw;
            height: 100vh;
            pointer-events: none;
            z-index: 9999;
            mix-blend-mode: screen;
        }


/* ========== STYLE BLOCK 3 ========== */

/* NOVA FM — Top-Right Placement */
        #nova-fm-interface {
            position: fixed;
            top: 20px;
            right: 20px; /* Anchored to the right */
            left: auto;
            font-family: 'Courier New', monospace;
            z-index: 150;
            display: flex;
            flex-direction: column;
            align-items: flex-end; /* Aligns toggle & panel flush right */
        }

        #nova-fm-toggle {
            background: #000;
            color: #ffffff;
            border: 1px solid #ff0033;
            padding: 8px 12px;
            cursor: pointer;
            text-transform: uppercase;
            font-size: 11px;
            letter-spacing: 1.5px;
            font-weight: bold;
            transition: all 0.3s ease;
            margin-bottom: 5px;
            text-shadow: 0 0 8px rgba(255, 255, 255, 0.6);
            box-shadow: 0 0 8px rgba(255, 0, 51, 0.2);
        }

        #nova-fm-toggle:hover {
            color: #ffffff;
            background: #200005;
            border-color: #ff0033;
            box-shadow: 0 0 15px rgba(255, 0, 51, 0.7);
        }

        #nova-fm-toggle.live {
            background: #3d020a;
            color: #ff0033;
            box-shadow: 0 0 12px rgba(255, 0, 51, 0.5);
        }

        #nova-fm-panel {
            display: none;
            width: 300px;
            background: rgba(5, 5, 5, 0.95);
            border: 1px solid #fa0505;
            padding: 15px;
            box-shadow: 0 0 20px rgba(0,0,0,1);
            backdrop-filter: blur(5px);
            z-index: 1000;
        }

        #nova-fm-panel .nous-header {
            margin-bottom: 10px;
        }

        #nova-fm-panel audio {
            width: 100%;
            height: 32px;
            margin: 8px 0 4px;
            outline: none;
        }

        #nova-fm-panel .nova-fm-credit {
            font-size: 0.65rem;
            color: #888;
            line-height: 1.5;
            letter-spacing: 0.5px;
        }

        #nova-fm-panel .nova-fm-credit a {
            color: #ff0033;
            text-decoration: none;
        }

        #nova-fm-panel .nova-fm-credit a:hover {
            text-shadow: 0 0 6px #ff0033;
        }

        @media (max-width: 768px) {
            #nova-fm-interface {
                top: auto;
                bottom: 80px;
                right: 10px; /* Anchored bottom-right on mobile */
                left: auto;
                align-items: flex-end;
            }
        }

