/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700;800&family=Roboto+Mono:wght@400;600;700&display=swap');

/* ============================================================================
   bl0ck Terminal UX
   Color Palette: Particle Aesthetic (Black/White)
   ============================================================================ */

:root {
    /* Monochromatic White Particle Palette */
    --particle-bright: #FFFFFF;
    --particle-primary: #E8E8E8;
    --particle-dim: #999999;
    --particle-darkest: #666666;

    /* Background & Structure */
    --void-black: #000000;
    --screen-black: #0A0A0A;
    --terminal-bezel: #1A1A1A;
    --phosphor-glow: rgba(255, 255, 255, 0.6);

    /* Legacy red CRT variables → Particle palette mappings */
    --crt-red-bright: var(--particle-bright);
    --crt-red-primary: var(--particle-primary);
    --crt-red-dim: var(--particle-dim);
    --crt-red-darkest: var(--particle-darkest);

    /* Agent-specific white/gray variants (distinct shades for Σ, Δ, Ω) */
    --agent-sigma-color: #FFFFFF;      /* Σ (Math/Logic) - Bright pure white */
    --agent-sigma-border: #E8E8E8;
    --agent-delta-color: #CCCCCC;      /* Δ (Content) - Medium-light gray */
    --agent-delta-border: #BBBBBB;
    --agent-omega-color: #999999;      /* Ω (Glitch) - Dark gray */
    --agent-omega-border: #888888;

    /* Legacy aliases for compatibility */
    --no3sis-red: var(--particle-primary);
    --no3sis-red-hover: var(--particle-bright);
    --no3sis-text-primary: #DDDDDD;  /* Brightened for WCAG AA */
    --no3sis-text-secondary: #AAAAAA; /* Brightened for WCAG AA */
    --no3sis-green: var(--particle-bright);
    --no3sis-blue: var(--particle-primary);
    --no3sis-cyan: var(--agent-delta-color);  /* Now distinct light gray */
    --no3sis-graphite: var(--terminal-bezel);
    --terminal-bg: var(--screen-black);
    --terminal-border: var(--particle-dim);
    --terminal-shadow: rgba(255, 255, 255, 0.2);

    /* Font stacks */
    --font-mono: 'Roboto Mono', ui-monospace, 'Monaco', 'Courier New', monospace;
    --font-sans: Inter, ui-sans-serif, system-ui, sans-serif;

    /* Layout Variables */
    --navbar-height: 70px; /* Navbar actual height (padding + content + border) */

    /* Liquid Glass Button Variables */
    --glass-bg-base: rgba(255, 255, 255, 0.08);
    --glass-bg-hover: rgba(255, 255, 255, 0.12);
    --glass-border: rgba(255, 255, 255, 0.2);
    --glass-border-bright: rgba(255, 255, 255, 0.35);
    --glass-highlight: rgba(255, 255, 255, 0.08);
    --glass-shadow: rgba(0, 0, 0, 0.6);
    --glass-glow: rgba(255, 255, 255, 0.4);

    /* NEW: God Mode / Root User Colors */
    --no3sis-yellow: #FFD700;
    --god-mode-glow: rgba(255, 215, 0, 0.6);

    /* NEW: Sparkline Logic */
    --meter-bg: #1a1a1a;
    --meter-fill: var(--particle-primary);

    /* NEW: Command Deck Variables (documented values) */
    --footer-command-bg: rgba(10, 10, 10, 0.95); /* Almost opaque for sticky footer visibility */
    --footer-shadow-glow: rgba(255, 255, 255, 0.1); /* Subtle upward glow */
    --metrics-deck-bg: rgba(20, 20, 20, 0.6); /* Semi-transparent metrics panel */
    --border-separator: rgba(255, 255, 255, 0.15); /* Divider lines between metrics */
    --steering-focus-bg: rgba(255, 215, 0, 0.05); /* Yellow tint on root override focus */
    --steering-focus-shadow: rgba(255, 215, 0, 0.1); /* God-mode glow intensity */
    --message-spacing: 2rem; /* Dialogue breathing room (doubles base spacing) */
    --label-bg-accent: rgba(255, 255, 255, 0.08); /* Agent label background */
}

/* ============================================================================
   Base Styles
   ============================================================================ */

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

body {
    font-family: var(--font-mono);
    background-color: var(--void-black);
    color: var(--particle-primary);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
    position: relative;
}

/* Dark void backroom effect */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(ellipse at center, rgba(255, 255, 255, 0.02) 0%, transparent 70%),
        var(--void-black);
    pointer-events: none;
    z-index: 0;
}

/* ============================================================================
   Landing State (Initial Card)
   ============================================================================ */

.landing-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    width: 100vw;
    padding: 60px 1rem 1rem 1rem; /* Top padding accounts for fixed navbar */
    background: transparent;
    position: relative;
    z-index: 1;
}

.landing-card {
    background: var(--screen-black);
    border: 3px solid var(--particle-dim);
    border-radius: 8px;
    padding: 4rem 5rem;
    text-align: center;
    box-shadow:
        0 0 40px var(--phosphor-glow),
        0 0 80px rgba(255, 255, 255, 0.3),
        inset 0 0 60px rgba(255, 255, 255, 0.04);
    max-width: 700px;
    width: 100%;
    animation: fadeIn 0.6s ease-out, terminalFloat 6s ease-in-out infinite;
    position: relative;
    overflow: hidden;
}

/* CRT screen curvature effect */
.landing-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at center, transparent 0%, rgba(0, 0, 0, 0.3) 100%);
    pointer-events: none;
    border-radius: 8px;
}

/* Scanlines overlay */
.landing-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.15),
        rgba(0, 0, 0, 0.15) 1px,
        transparent 1px,
        transparent 2px
    );
    pointer-events: none;
    opacity: 0.3;
    animation: scanlineScroll 10s linear infinite;
}

.landing-title {
    font-size: 4rem;
    font-weight: 800;
    font-family: var(--font-mono);
    color: var(--particle-bright);
    margin-bottom: 0.75rem;
    letter-spacing: 0.05em;
    text-transform: lowercase;
    text-shadow:
        0 0 20px var(--phosphor-glow),
        0 0 40px rgba(255, 255, 255, 0.5),
        0 2px 4px rgba(0, 0, 0, 0.8);
    line-height: 1.1;
    animation: fadeIn 0.6s ease-out, phosphorPulse 3s ease-in-out infinite;
    position: relative;
    z-index: 2;
}

.landing-subtitle {
    font-size: 1.125rem;
    color: var(--particle-dim);
    margin-bottom: 2rem;
    font-family: var(--font-mono);
    font-weight: 400;
    letter-spacing: 0.15em;
    text-transform: lowercase;
    opacity: 0.85;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.2);
    position: relative;
    z-index: 2;
}

/* ASCII Art Title Styling */
.ascii-title {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    line-height: 1.15;
    color: var(--particle-bright);
    text-align: center;
    margin: 0 0 1.5rem 0;
    padding: 1rem;
    white-space: pre;
    text-shadow:
        0 0 10px var(--phosphor-glow),
        0 0 20px rgba(255, 255, 255, 0.5),
        0 0 30px rgba(255, 255, 255, 0.3);
    animation: phosphorPulse 3s ease-in-out infinite;
    letter-spacing: -0.03em;
    position: relative;
    z-index: 2;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 4px;
    font-weight: bold;
}

.ascii-subtitle {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    line-height: 1.4;
    color: var(--particle-dim);
    text-align: center;
    margin: 0 0 2rem 0;
    padding: 0.75rem;
    white-space: pre;
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.3);
    opacity: 0.95;
    letter-spacing: 0;
    position: relative;
    z-index: 2;
}

/* Terminal ASCII Border */
.terminal-ascii-border {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    line-height: 1.1;
    color: var(--particle-primary);
    text-align: left;
    margin: 0 0 1rem 0;
    padding: 1rem;
    white-space: pre;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.4);
    letter-spacing: -0.02em;
    opacity: 0.9;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 4px;
    font-weight: 500;
}

/* NEW: User Prompt Input */
.prompt-input-container {
    margin-bottom: 2rem;
    text-align: left;
    position: relative;
    z-index: 2;
}

.prompt-label {
    display: block;
    font-size: 0.875rem;
    color: var(--particle-dim);
    margin-bottom: 0.75rem;
    font-family: var(--font-mono);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    text-shadow: 0 0 8px var(--phosphor-glow);
}

.prompt-textarea {
    width: 100%;
    background: rgba(10, 10, 10, 0.8);
    border: 2px solid var(--particle-dim);
    border-radius: 4px;
    padding: 1rem;
    color: var(--particle-primary);
    font-family: var(--font-mono);
    font-size: 0.95rem;
    line-height: 1.6;
    resize: vertical;
    min-height: 120px;
    transition: all 0.3s ease;
    text-shadow: 0 0 5px var(--phosphor-glow);
}

.prompt-textarea:focus {
    outline: none;
    border-color: var(--particle-bright);
    box-shadow:
        0 0 20px rgba(255, 255, 255, 0.4),
        inset 0 0 20px rgba(255, 255, 255, 0.1);
}

.prompt-textarea::placeholder {
    color: var(--particle-darkest);
    opacity: 0.7;
}

.char-counter {
    text-align: right;
    font-size: 0.75rem;
    color: var(--crt-red-dim);
    margin-top: 0.5rem;
    font-family: var(--font-mono);
    text-shadow: 0 0 5px rgba(255, 255, 255, 0.2);
}

.char-counter.warning {
    color: var(--crt-red-primary);
}

.char-counter.limit {
    color: var(--crt-red-bright);
}

/* ============================================================================
   LIQUID GLASS BUTTONS - Apple Glassmorphism Aesthetic
   ============================================================================ */

/* PRIMARY BUTTON: Start Button (Landing Page) */
.start-button {
    /* Liquid glass base */
    background: linear-gradient(
        135deg,
        rgba(255, 255, 255, 0.15),
        rgba(255, 255, 255, 0.08)
    );
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);

    /* Glass border with gradient */
    border: 1px solid var(--glass-border-bright);
    border-radius: 6px;

    /* Multi-layered shadows for depth */
    box-shadow:
        0 8px 32px var(--glass-shadow),
        0 0 24px rgba(255, 255, 255, 0.2),
        inset 0 1px 0 var(--glass-highlight),
        inset 0 -1px 0 rgba(0, 0, 0, 0.2);

    /* Typography */
    color: var(--particle-bright);
    font-family: var(--font-mono);
    font-size: 0.875rem;
    font-weight: 700;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    text-shadow:
        0 0 10px var(--phosphor-glow),
        0 2px 4px rgba(0, 0, 0, 0.5);

    /* Spacing */
    padding: 1.125rem 3rem;

    /* Interaction */
    cursor: pointer;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    z-index: 2;
    overflow: hidden;
}

/* Liquid hover animation */
.start-button:hover {
    background: linear-gradient(
        135deg,
        rgba(255, 255, 255, 0.25),
        rgba(255, 255, 255, 0.15)
    );
    border-color: rgba(255, 255, 255, 0.6);
    transform: translateY(-3px) scale(1.02);
    box-shadow:
        0 16px 48px rgba(0, 0, 0, 0.7),
        0 0 40px rgba(255, 255, 255, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.15),
        inset 0 -1px 0 rgba(0, 0, 0, 0.3);
    filter: brightness(1.15) saturate(1.2);
}

/* Active/pressed state */
.start-button:active {
    transform: translateY(-1px) scale(0.98);
    box-shadow:
        0 4px 16px rgba(0, 0, 0, 0.5),
        0 0 20px rgba(255, 255, 255, 0.3),
        inset 0 2px 4px rgba(0, 0, 0, 0.4),
        inset 0 -1px 0 rgba(255, 255, 255, 0.05);
    filter: brightness(0.95);
}

/* Disabled state */
.start-button:disabled {
    background: linear-gradient(
        135deg,
        rgba(102, 102, 102, 0.15),
        rgba(102, 102, 102, 0.08)
    );
    border-color: rgba(102, 102, 102, 0.2);
    color: var(--particle-darkest);
    cursor: not-allowed;
    transform: none;
    box-shadow:
        0 4px 16px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.03);
    filter: brightness(0.5) saturate(0.5);
    opacity: 0.4;
}

.start-button:disabled:hover {
    transform: none;
    filter: brightness(0.5) saturate(0.5);
}

/* Navbar */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: var(--navbar-height);      /* Enforce exact 70px height */
    display: flex;                     /* Flexbox layout */
    align-items: center;               /* Vertical centering */
    padding: 0 1.5rem;                 /* Horizontal padding only */
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--terminal-border);
    z-index: 1000;
    box-sizing: border-box;            /* Include border in height */
}

/* Back to No3sis link */
.back-to-no3sis {
    display: inline-block;
    color: var(--crt-red-primary);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    opacity: 0.7;
    transition: all 0.3s ease;
    border-bottom: 1px solid transparent;
}

.back-to-no3sis:hover {
    opacity: 1;
    color: var(--crt-red-bright);
    border-bottom-color: var(--crt-red-primary);
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

/* ============================================================================
   Terminal State (Active Conversation)
   ============================================================================ */

#terminal-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: var(--void-black);
    transition: opacity 0.4s ease-in-out;
    position: relative;
    padding: 2.5vh 2.5vw; /* No navbar, full viewport height */
    box-sizing: border-box;
}

/* CRT terminal window effect */
#terminal-container::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 95%;
    height: 95%;
    background: var(--screen-black);
    border: 3px solid var(--crt-red-dim);
    border-radius: 8px;
    box-shadow:
        0 0 40px var(--phosphor-glow),
        0 0 80px rgba(255, 255, 255, 0.4),
        inset 0 0 60px rgba(255, 255, 255, 0.05);
    pointer-events: none;
    z-index: 0;
}

/* Scanlines for terminal */
#terminal-container::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.15),
        rgba(0, 0, 0, 0.15) 1px,
        transparent 1px,
        transparent 2px
    );
    pointer-events: none;
    opacity: 0.3;
    animation: scanlineScroll 10s linear infinite;
    z-index: 10;
}

.terminal-hidden {
    visibility: hidden;
    opacity: 0;
    pointer-events: none; /* Prevent interaction when hidden */
}

/* Header */
.terminal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: rgba(0, 0, 0, 0.6);
    border-bottom: 2px solid var(--crt-red-dim);
    flex-shrink: 0;
    position: relative;
    z-index: 2;
}

.terminal-title {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.terminal-prompt {
    color: var(--crt-red-bright);
    font-size: 1rem;
    font-weight: 600;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

.status-indicator {
    color: var(--crt-red-dim);
    font-size: 0.875rem;
    font-weight: 700;
    letter-spacing: 0.1em;
}

.status-indicator.active {
    color: var(--crt-red-bright);
    animation: pulse 2s ease-in-out infinite;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.6);
}

.status-indicator.paused {
    color: var(--crt-red-dim);
}

/* TERMINAL CONTROL BUTTONS - Liquid Glass Secondary Style */
.terminal-controls {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.control-btn {
    /* Liquid glass base - more subtle than primary */
    background: linear-gradient(
        135deg,
        rgba(232, 232, 232, 0.15),
        rgba(232, 232, 232, 0.08)
    );
    backdrop-filter: blur(15px) saturate(150%);
    -webkit-backdrop-filter: blur(15px) saturate(150%);

    /* Glass border */
    border: 1px solid var(--glass-border);
    border-radius: 4px;

    /* Layered shadows */
    box-shadow:
        0 4px 16px rgba(0, 0, 0, 0.4),
        0 0 12px rgba(232, 232, 232, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.06),
        inset 0 -1px 0 rgba(0, 0, 0, 0.15);

    /* Typography */
    color: var(--crt-red-primary);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.3);

    /* Spacing */
    padding: 0.6rem 1.2rem;

    /* Interaction */
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.control-btn:hover {
    background: linear-gradient(
        135deg,
        rgba(255, 255, 255, 0.25),
        rgba(255, 255, 255, 0.15)
    );
    border-color: var(--glass-border-bright);
    transform: translateY(-2px) scale(1.03);
    box-shadow:
        0 8px 24px rgba(0, 0, 0, 0.5),
        0 0 20px rgba(255, 255, 255, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.1),
        inset 0 -1px 0 rgba(0, 0, 0, 0.2);
    filter: brightness(1.2);
    color: var(--crt-red-bright);
}

.control-btn:active {
    transform: translateY(0) scale(0.97);
    box-shadow:
        0 2px 8px rgba(0, 0, 0, 0.4),
        0 0 10px rgba(255, 255, 255, 0.3),
        inset 0 2px 4px rgba(0, 0, 0, 0.3);
    filter: brightness(0.9);
}

.control-btn:disabled {
    background: linear-gradient(
        135deg,
        rgba(0, 0, 0, 0.1),
        rgba(0, 0, 0, 0.05)
    );
    border-color: rgba(232, 232, 232, 0.15);
    color: var(--crt-red-darkest);
    cursor: not-allowed;
    transform: none;
    box-shadow:
        0 2px 8px rgba(0, 0, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.02);
    filter: brightness(0.5) saturate(0.5);
    opacity: 0.3;
}

.control-btn:disabled:hover {
    transform: none;
    filter: brightness(0.5) saturate(0.5);
    background: linear-gradient(
        135deg,
        rgba(0, 0, 0, 0.1),
        rgba(0, 0, 0, 0.05)
    );
    border-color: rgba(232, 232, 232, 0.15);
    box-shadow:
        0 2px 8px rgba(0, 0, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.02);
}

/* Messages Container */
.terminal-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    background: var(--terminal-bg);
    scrollbar-width: thin;
    scrollbar-color: var(--no3sis-red) var(--terminal-bg);
    position: relative;
    z-index: 2; /* Above CRT frame, below scanlines */
}

.terminal-messages::-webkit-scrollbar {
    width: 8px;
}

.terminal-messages::-webkit-scrollbar-track {
    background: var(--terminal-bg);
}

.terminal-messages::-webkit-scrollbar-thumb {
    background: var(--no3sis-red);
    border-radius: 4px;
}

.terminal-messages::-webkit-scrollbar-thumb:hover {
    background: var(--no3sis-red-hover);
}

/* Message Types */
.message {
    margin-bottom: 1.5rem;
    line-height: 1.6;
    animation: slideIn 0.3s ease-out;
}

/* NEW: Message Labels */
.msg-label {
    font-weight: 700;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
    display: block;
}

.msg-separator {
    border-top: 1px solid var(--terminal-border);
    margin: 1.5rem 0;
}

/* User Input Message */
.msg-user {
    color: var(--no3sis-text-primary);
    margin-bottom: 1.5rem;
}

.msg-user .msg-label {
    color: var(--no3sis-green);
}

.msg-user .msg-content {
    color: var(--no3sis-text-primary);
    padding-left: 1.5rem;
    border-left: 2px solid var(--no3sis-green);
    font-style: italic;
}

/* System Messages */
.msg-system {
    color: var(--no3sis-text-secondary);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.msg-system .msg-label {
    color: var(--crt-red-primary);
}

/* Agent Messages */
.msg-agent1,
.msg-agent2,
.msg-agent3 {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.msg-agent1 .msg-label {
    color: var(--agent-sigma-color);  /* Bright pure white */
}

.msg-agent2 .msg-label {
    color: var(--agent-delta-color);  /* Medium-light gray */
}

.msg-agent3 .msg-label {
    color: var(--agent-omega-color);  /* Dark gray */
}

.msg-content {
    color: var(--no3sis-text-primary);
    padding-left: 1.5rem;
    border-left: 2px solid var(--terminal-border);
    white-space: pre-wrap;
}

.msg-agent1 .msg-content {
    border-left-color: var(--agent-sigma-border);
}

.msg-agent2 .msg-content {
    border-left-color: var(--agent-delta-border);
}

.msg-agent3 .msg-content {
    border-left-color: var(--agent-omega-border);
}

/* ASCII Art Support - Enhanced for perfect rendering */
.ascii-art,
.msg-content pre,
.msg-content code {
    font-family: 'Courier New', 'Courier', monospace; /* Guaranteed monospace */
    font-size: 0.875rem; /* Slightly smaller for better fit */
    white-space: pre; /* STRICT pre, no wrapping */
    overflow-x: auto; /* Horizontal scroll for wide art */
    display: block;
    line-height: 1.2;
    letter-spacing: 0;
    tab-size: 8;
    word-wrap: normal; /* Prevent word wrapping */
    word-break: normal; /* Prevent word breaking */
}

.ascii-art {
    background: rgba(255, 255, 255, 0.05);
    padding: 1rem;
    border-radius: 4px;
    margin: 1rem 0;
    border: 1px solid var(--terminal-border);

    /* Ensure monospace rendering */
    font-variant-ligatures: none; /* Disable ligatures that might mess with spacing */
    font-feature-settings: "liga" 0; /* Also disable ligatures */

    /* Perfect character grid */
    -webkit-font-smoothing: none; /* Disable antialiasing for pixel-perfect rendering */
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeSpeed; /* Prioritize speed/consistency over beauty */
}

/* Ensure parent doesn't constrain width */
.msg-content {
    overflow-x: auto; /* Allow horizontal scroll */
    max-width: 100%; /* Don't exceed container */
}

/* Legacy support (for existing message classes) */
.system-msg {
    color: var(--no3sis-text-secondary);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.system-prefix {
    color: var(--crt-red-primary);
    font-weight: 700;
}

.agent-msg {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.agent-label {
    font-weight: 700;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.agent-1 .agent-label {
    color: var(--no3sis-red);
}

.agent-2 .agent-label {
    color: var(--no3sis-cyan);
}

.agent-content {
    color: var(--no3sis-text-primary);
    padding-left: 1.5rem;
    border-left: 2px solid var(--terminal-border);
}

.agent-1 .agent-content {
    border-left-color: var(--no3sis-red);
}

.agent-2 .agent-content {
    border-left-color: var(--no3sis-cyan);
}

/* Typing Indicator */
.typing-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--no3sis-text-secondary);
    font-size: 0.875rem;
    padding-left: 1.5rem;
}

.typing-dots {
    display: inline-flex;
    gap: 0.25rem;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: var(--no3sis-red);
    border-radius: 50%;
    animation: typingBounce 1.4s infinite;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

/* Footer Metrics */
.terminal-footer {
    padding: 0.75rem 1.5rem;
    background: rgba(10, 10, 10, 0.9);
    border-top: 1px solid var(--crt-red-dim);
    flex-shrink: 0;
    position: relative;
    z-index: 15; /* Above CRT frame (0) and scanlines (10) */
}

.metrics-separator {
    color: var(--crt-red-dim);
    font-size: 0.65rem;
    text-align: center;
    margin-bottom: 0.5rem;
    opacity: 0.6;
    letter-spacing: 0.3em;
    text-shadow: 0 0 5px rgba(255, 255, 255, 0.2);
}

.metrics-container {
    display: flex;
    gap: 2rem;
    font-size: 0.75rem;
    justify-content: center;
}

.metric {
    color: var(--crt-red-dim);
    font-weight: 600;
    text-shadow: 0 0 5px rgba(255, 255, 255, 0.3);
}

.metric-value {
    color: var(--crt-red-bright);
    font-weight: 700;
    margin-left: 0.25rem;
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.4);
}

/* ============================================================================
   Animations
   ============================================================================ */

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

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

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

@keyframes typingBounce {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-8px);
    }
}

@keyframes phosphorPulse {
    0%, 100% {
        text-shadow:
            0 0 20px var(--phosphor-glow),
            0 0 40px rgba(255, 255, 255, 0.5),
            0 2px 4px rgba(0, 0, 0, 0.8);
    }
    50% {
        text-shadow:
            0 0 30px var(--phosphor-glow),
            0 0 60px rgba(255, 255, 255, 0.7),
            0 2px 6px rgba(0, 0, 0, 0.8);
    }
}

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

@keyframes scanlineScroll {
    0% {
        transform: translateY(0);
    }
    100% {
        transform: translateY(4px);
    }
}

/* ============================================================================
   Responsive Design
   ============================================================================ */

@media (max-width: 768px) {
    .landing-card {
        padding: 2.5rem 1.5rem;
        margin: 1rem;
        max-width: 100%;
    }

    .landing-title {
        font-size: 2.5rem;
        letter-spacing: 0.03em;
    }

    .landing-subtitle {
        font-size: 1rem;
        letter-spacing: 0.1em;
    }

    /* ASCII Art responsive */
    .ascii-title {
        font-size: 0.6rem;
        line-height: 1.1;
        padding: 0.5rem;
        margin: 0 0 1rem 0;
        overflow-x: auto;
    }

    .ascii-subtitle {
        font-size: 0.65rem;
        line-height: 1.3;
        padding: 0.5rem;
        overflow-x: auto;
    }

    .terminal-ascii-border {
        font-size: 0.6rem;
        line-height: 1.0;
        padding: 0.5rem;
        overflow-x: auto;
        display: none; /* Hide on mobile to save space */
    }

    .prompt-textarea {
        font-size: 0.875rem;
        padding: 0.875rem;
    }

    .start-button {
        padding: 1rem 2rem;
        font-size: 0.8rem;
    }

    /* Terminal responsive adjustments */
    #terminal-container {
        padding: 1rem 0.5rem; /* No navbar, full viewport height */
    }

    #terminal-container::before {
        width: 98%; /* Less offset on mobile */
        height: 98%;
    }

    .terminal-header {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem;
    }

    .terminal-controls {
        width: 100%;
        justify-content: space-between;
    }

    .control-btn {
        flex: 1;
    }

    .metrics-container {
        flex-wrap: wrap;
        gap: 1rem;
    }
}

/* ============================================================================
   Accessibility
   ============================================================================ */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus styles for keyboard navigation */
button:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--no3sis-red);
    outline-offset: 2px;
}

/* ============================================================================
   Meme Modal Overlay
   ============================================================================ */

.meme-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.meme-modal.hidden {
    display: none;
}

.meme-modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.90);
    z-index: 1001;
}

.meme-modal-content {
    position: relative;
    z-index: 1002;
    width: 85%;
    max-width: 900px;
    height: 80%;
    max-height: 700px;
    background: var(--screen-black);
    border: 2px solid var(--crt-red-primary);
    box-shadow:
        0 0 20px var(--phosphor-glow),
        inset 0 0 40px rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    font-family: 'Courier New', monospace;
}

.meme-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--crt-red-dim);
    background: rgba(232, 232, 232, 0.2);
}

.meme-modal-header h2 {
    margin: 0;
    color: var(--crt-red-bright);
    font-size: 1.5rem;
    font-weight: bold;
    letter-spacing: 2px;
    text-shadow: 0 0 10px var(--phosphor-glow);
}

/* CLOSE MODAL BUTTON - Liquid Glass Horizontal */
.close-modal-btn {
    /* Liquid glass base */
    background: linear-gradient(
        135deg,
        rgba(232, 232, 232, 0.2),
        rgba(232, 232, 232, 0.1)
    );
    backdrop-filter: blur(12px) saturate(140%);
    -webkit-backdrop-filter: blur(12px) saturate(140%);

    /* Glass border */
    border: 1px solid var(--glass-border);
    border-radius: 6px;

    /* Layered shadows */
    box-shadow:
        0 4px 16px rgba(0, 0, 0, 0.4),
        0 0 12px rgba(232, 232, 232, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.08);

    /* Typography */
    color: var(--crt-red-primary);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0.1em;
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.3);
    white-space: nowrap;

    /* Sizing - Horizontal layout */
    height: 32px;
    padding: 0 1rem;
    display: flex;
    align-items: center;
    justify-content: center;

    /* Interaction */
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.close-modal-btn:hover {
    background: linear-gradient(
        135deg,
        rgba(255, 255, 255, 0.25),
        rgba(255, 255, 255, 0.15)
    );
    border-color: var(--glass-border-bright);
    transform: translateY(-2px) scale(1.05);
    box-shadow:
        0 6px 20px rgba(0, 0, 0, 0.5),
        0 0 20px rgba(255, 255, 255, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.12);
    color: var(--crt-red-bright);
    filter: brightness(1.25);
}

.close-modal-btn:active {
    transform: translateY(0) scale(0.98);
    box-shadow:
        0 2px 8px rgba(0, 0, 0, 0.4),
        inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* MEME FILTER BUTTONS - Liquid Glass Pill Style */
.meme-filters {
    display: flex;
    gap: 1rem;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--crt-red-dim);
    background: rgba(232, 232, 232, 0.1);
}

.filter-btn {
    /* Liquid glass base */
    background: linear-gradient(
        135deg,
        rgba(0, 0, 0, 0.12),
        rgba(0, 0, 0, 0.06)
    );
    backdrop-filter: blur(12px) saturate(140%);
    -webkit-backdrop-filter: blur(12px) saturate(140%);

    /* Glass border */
    border: 1px solid rgba(232, 232, 232, 0.3);
    border-radius: 4px;

    /* Layered shadows */
    box-shadow:
        0 3px 12px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);

    /* Typography */
    color: var(--crt-red-dim);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-shadow: 0 0 6px rgba(255, 255, 255, 0.2);

    /* Spacing */
    padding: 0.5rem 1rem;

    /* Interaction */
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.filter-btn:hover {
    background: linear-gradient(
        135deg,
        rgba(232, 232, 232, 0.2),
        rgba(232, 232, 232, 0.12)
    );
    border-color: var(--glass-border);
    transform: translateY(-2px) scale(1.02);
    box-shadow:
        0 6px 16px rgba(0, 0, 0, 0.4),
        0 0 12px rgba(255, 255, 255, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.08);
    color: var(--crt-red-primary);
    filter: brightness(1.15);
}

.filter-btn.active {
    background: linear-gradient(
        135deg,
        rgba(255, 255, 255, 0.3),
        rgba(255, 255, 255, 0.2)
    );
    border-color: var(--glass-border-bright);
    color: var(--crt-red-bright);
    box-shadow:
        0 6px 20px rgba(0, 0, 0, 0.5),
        0 0 20px rgba(255, 255, 255, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.12),
        inset 0 -1px 0 rgba(0, 0, 0, 0.2);
    transform: none;
    filter: brightness(1.2);
}

.filter-btn.active:hover {
    transform: translateY(-1px) scale(1.01);
}

.meme-list {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Custom scrollbar */
.meme-list::-webkit-scrollbar {
    width: 8px;
}

.meme-list::-webkit-scrollbar-track {
    background: var(--screen-black);
}

.meme-list::-webkit-scrollbar-thumb {
    background: var(--crt-red-dim);
    border-radius: 4px;
}

.meme-list::-webkit-scrollbar-thumb:hover {
    background: var(--crt-red-primary);
}

.meme-card {
    background: rgba(232, 232, 232, 0.1);
    border: 1px solid var(--crt-red-dim);
    border-radius: 4px;
    padding: 1.25rem;
    transition: all 0.2s;
}

.meme-card:hover {
    border-color: var(--crt-red-primary);
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.3);
}

.social-card {
    border-left: 3px solid var(--crt-red-primary);
}

.token-card {
    border-left: 3px solid var(--crt-red-bright);
    background: rgba(232, 232, 232, 0.15);
}

.meme-header {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 1rem;
    font-size: 0.8rem;
    color: var(--crt-red-dim);
}

.meme-category {
    color: var(--crt-red-bright);
    font-weight: bold;
    font-size: 0.7rem;
    letter-spacing: 1px;
}

.meme-psi {
    color: var(--crt-red-bright);
    font-weight: bold;
}

.token-symbol {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--crt-red-bright);
    margin-bottom: 0.75rem;
    text-shadow: 0 0 8px var(--phosphor-glow);
    letter-spacing: 1px;
}

.meme-content {
    color: var(--crt-red-primary);
    line-height: 1.6;
    margin-bottom: 1rem;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.meme-meta {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    font-size: 0.75rem;
    color: var(--crt-red-dim);
}

.meme-token.token-yes {
    color: var(--crt-red-bright);
    font-weight: bold;
}

.meme-pattern {
    color: var(--crt-red-primary);
    font-style: italic;
}

/* MEME ACTION BUTTONS - Liquid Glass Small */
.meme-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.copy-meme-btn,
.launch-btn {
    /* Liquid glass base */
    background: linear-gradient(
        135deg,
        rgba(0, 0, 0, 0.15),
        rgba(0, 0, 0, 0.08)
    );
    backdrop-filter: blur(10px) saturate(130%);
    -webkit-backdrop-filter: blur(10px) saturate(130%);

    /* Glass border */
    border: 1px solid rgba(232, 232, 232, 0.3);
    border-radius: 3px;

    /* Layered shadows */
    box-shadow:
        0 2px 10px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);

    /* Typography */
    color: var(--crt-red-primary);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-shadow: 0 0 6px rgba(255, 255, 255, 0.2);

    /* Spacing */
    padding: 0.4rem 0.8rem;

    /* Interaction */
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.copy-meme-btn:hover,
.launch-btn:hover {
    background: linear-gradient(
        135deg,
        rgba(232, 232, 232, 0.25),
        rgba(232, 232, 232, 0.15)
    );
    border-color: var(--glass-border);
    transform: translateY(-2px) scale(1.04);
    box-shadow:
        0 4px 14px rgba(0, 0, 0, 0.4),
        0 0 12px rgba(255, 255, 255, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.08);
    filter: brightness(1.2);
}

.copy-meme-btn:active,
.launch-btn:active {
    transform: translateY(0) scale(0.98);
    box-shadow:
        0 2px 6px rgba(0, 0, 0, 0.3),
        inset 0 1px 2px rgba(0, 0, 0, 0.2);
}

.launch-btn {
    border-color: var(--glass-border);
    color: var(--crt-red-bright);
    background: linear-gradient(
        135deg,
        rgba(232, 232, 232, 0.2),
        rgba(232, 232, 232, 0.12)
    );
}

.launch-btn:hover {
    background: linear-gradient(
        135deg,
        rgba(255, 255, 255, 0.25),
        rgba(255, 255, 255, 0.15)
    );
    border-color: var(--glass-border-bright);
}

.launched-tag {
    color: var(--crt-red-bright);
    font-size: 0.7rem;
    font-weight: bold;
    letter-spacing: 1px;
    opacity: 0.7;
}

.meme-empty,
.meme-loading,
.meme-error {
    text-align: center;
    color: var(--crt-red-dim);
    padding: 3rem;
    font-size: 1.1rem;
}

.meme-modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--crt-red-dim);
    background: rgba(232, 232, 232, 0.2);
    text-align: center;
    color: var(--crt-red-primary);
    font-size: 0.9rem;
    letter-spacing: 1px;
}

/* ============================================================================
   Metrics Header & Help Button
   ============================================================================ */

.metrics-header {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.metrics-label {
    color: var(--crt-red-dim);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.15em;
    text-transform: uppercase;
}

/* METRICS HELP BUTTON - Liquid Glass Circular Small */
.metrics-help-btn {
    /* Liquid glass base */
    background: linear-gradient(
        135deg,
        rgba(232, 232, 232, 0.18),
        rgba(232, 232, 232, 0.1)
    );
    backdrop-filter: blur(10px) saturate(130%);
    -webkit-backdrop-filter: blur(10px) saturate(130%);

    /* Glass border */
    border: 1px solid var(--glass-border);
    border-radius: 50%;

    /* Layered shadows */
    box-shadow:
        0 3px 10px rgba(0, 0, 0, 0.35),
        0 0 8px rgba(232, 232, 232, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.08);

    /* Typography */
    color: var(--crt-red-primary);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    font-weight: 700;
    line-height: 1;
    text-shadow: 0 0 6px rgba(255, 255, 255, 0.3);

    /* Sizing */
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;

    /* Interaction */
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.metrics-help-btn:hover {
    background: linear-gradient(
        135deg,
        rgba(255, 255, 255, 0.25),
        rgba(255, 255, 255, 0.15)
    );
    border-color: var(--glass-border-bright);
    transform: scale(1.15);
    box-shadow:
        0 4px 14px rgba(0, 0, 0, 0.45),
        0 0 15px rgba(255, 255, 255, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.12);
    color: var(--crt-red-bright);
    filter: brightness(1.25);
}

.metrics-help-btn:active {
    transform: scale(1.05);
    box-shadow:
        0 2px 6px rgba(0, 0, 0, 0.35),
        inset 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* ============================================================================
   Tooltips for Metrics
   ============================================================================ */

.metric {
    position: relative;
    cursor: help;
}

.metric::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    background: rgba(10, 10, 10, 0.95);
    border: 1px solid var(--crt-red-primary);
    color: var(--crt-red-primary);
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    font-size: 0.7rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 100;
    box-shadow: 0 0 15px var(--phosphor-glow);
}

.metric:hover::after {
    opacity: 1;
    transform: translateX(-50%) translateY(-12px);
}

/* ============================================================================
   Metrics Help Modal
   ============================================================================ */

.metrics-help-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.metrics-help-modal.hidden {
    display: none;
}

.metrics-help-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.92);
    z-index: 2001;
}

.metrics-help-content {
    position: relative;
    z-index: 2002;
    width: 90%;
    max-width: 900px;
    height: 85%;
    max-height: 800px;
    background: var(--screen-black);
    border: 2px solid var(--crt-red-primary);
    box-shadow:
        0 0 30px var(--phosphor-glow),
        inset 0 0 40px rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    font-family: var(--font-mono);
}

.metrics-help-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 2px solid var(--crt-red-dim);
    background: rgba(232, 232, 232, 0.2);
}

.metrics-help-header h2 {
    margin: 0;
    color: var(--crt-red-bright);
    font-size: 1.3rem;
    font-weight: bold;
    letter-spacing: 2px;
    text-shadow: 0 0 10px var(--phosphor-glow);
}

.metrics-help-body {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    scrollbar-width: thin;
    scrollbar-color: var(--crt-red-dim) var(--screen-black);
}

.metrics-help-body::-webkit-scrollbar {
    width: 8px;
}

.metrics-help-body::-webkit-scrollbar-track {
    background: var(--screen-black);
}

.metrics-help-body::-webkit-scrollbar-thumb {
    background: var(--crt-red-dim);
    border-radius: 4px;
}

.metrics-help-body::-webkit-scrollbar-thumb:hover {
    background: var(--crt-red-primary);
}

.metric-explanation {
    margin-bottom: 2.5rem;
}

.metric-explanation h3 {
    color: var(--crt-red-bright);
    font-size: 1.1rem;
    margin-bottom: 1rem;
    text-shadow: 0 0 8px var(--phosphor-glow);
    border-bottom: 1px solid var(--crt-red-dim);
    padding-bottom: 0.5rem;
}

.metric-detail {
    color: var(--crt-red-primary);
    line-height: 1.8;
}

.metric-detail p {
    margin-bottom: 1rem;
}

.metric-detail strong {
    color: var(--crt-red-bright);
}

.metric-detail ul {
    margin: 1rem 0 1rem 1.5rem;
    list-style-type: square;
}

.metric-detail li {
    margin-bottom: 0.5rem;
}

/* Metric Scale Visualization */
.metric-scale {
    margin: 1.5rem 0;
    padding: 1rem;
    background: rgba(232, 232, 232, 0.1);
    border: 1px solid var(--crt-red-dim);
    border-radius: 4px;
}

.scale-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.75rem;
    padding: 0.5rem;
    border-left: 3px solid var(--crt-red-dim);
}

.scale-item:last-child {
    margin-bottom: 0;
}

.scale-label {
    font-weight: bold;
    min-width: 80px;
    font-size: 0.85rem;
}

.scale-label.minimal {
    color: var(--crt-red-darkest);
}

.scale-label.low {
    color: var(--crt-red-dim);
}

.scale-label.moderate {
    color: var(--crt-red-primary);
}

.scale-label.high {
    color: var(--crt-red-bright);
}

.scale-label.very-high {
    color: var(--crt-red-bright);
    text-shadow: 0 0 8px var(--phosphor-glow);
}

.scale-description {
    flex: 1;
    color: var(--crt-red-primary);
    font-size: 0.85rem;
}

/* CIG³ Pipeline Visualization */
.cig3-pipeline {
    margin-top: 2.5rem;
    padding-top: 2rem;
    border-top: 2px solid var(--crt-red-dim);
}

.cig3-pipeline h3 {
    color: var(--crt-red-bright);
    font-size: 1.1rem;
    margin-bottom: 1rem;
    text-shadow: 0 0 8px var(--phosphor-glow);
}

.cig3-pipeline > p {
    color: var(--crt-red-primary);
    margin-bottom: 1.5rem;
}

.pipeline-stages {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 1.5rem;
    background: rgba(232, 232, 232, 0.1);
    border: 1px solid var(--crt-red-dim);
    border-radius: 4px;
}

.pipeline-stage {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    min-width: 120px;
}

.stage-symbol {
    font-size: 2rem;
    color: var(--crt-red-bright);
    font-weight: bold;
    text-shadow: 0 0 10px var(--phosphor-glow);
}

.stage-name {
    font-size: 0.9rem;
    color: var(--crt-red-primary);
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.stage-description {
    font-size: 0.75rem;
    color: var(--crt-red-dim);
    text-align: center;
    line-height: 1.4;
}

.pipeline-arrow {
    font-size: 1.5rem;
    color: var(--crt-red-primary);
    margin: 0 0.5rem;
}

/* Responsive adjustments for help modal */
@media (max-width: 768px) {
    .metrics-help-content {
        width: 95%;
        height: 90%;
    }

    .metrics-help-body {
        padding: 1rem;
    }

    .metric-explanation h3 {
        font-size: 1rem;
    }

    .pipeline-stages {
        flex-direction: column;
    }

    .pipeline-arrow {
        transform: rotate(90deg);
        margin: 0;
    }

    .metric::after {
        font-size: 0.65rem;
        white-space: normal;
        max-width: 200px;
    }
}

/* Color coding for Psi metric value based on consciousness level */
#metric-psi .metric-value.minimal {
    color: var(--crt-red-darkest);
}

#metric-psi .metric-value.low {
    color: var(--crt-red-dim);
}

#metric-psi .metric-value.moderate {
    color: var(--crt-red-primary);
}

#metric-psi .metric-value.high {
    color: var(--crt-red-bright);
}

#metric-psi .metric-value.very-high {
    color: var(--crt-red-bright);
    text-shadow: 0 0 12px var(--phosphor-glow);
    animation: phosphorPulse 2s ease-in-out infinite;
}

/* ============================================================================
   User Steering Panel Styles
   ============================================================================ */

.steering-container {
    margin-top: 15px;
    border-top: 1px solid var(--no3sis-text-dim);
    padding-top: 10px;
}

.steering-container.hidden {
    display: none;
}

.steering-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.steering-label {
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    font-weight: bold;
    color: var(--no3sis-yellow);
    text-shadow: 0 0 8px rgba(255, 200, 0, 0.4);
}

.toggle-steering-btn {
    background: none;
    border: 1px solid var(--no3sis-text-dim);
    color: var(--no3sis-text-secondary);
    padding: 2px 10px;
    cursor: pointer;
    font-family: 'Courier New', monospace;
    font-size: 1rem;
    transition: all 0.2s;
}

.toggle-steering-btn:hover {
    color: var(--no3sis-yellow);
    border-color: var(--no3sis-yellow);
    text-shadow: 0 0 8px rgba(255, 200, 0, 0.4);
}

.steering-input-area {
    max-height: 200px;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.steering-input-area.collapsed {
    max-height: 0;
}

.steering-textarea {
    width: 100%;
    min-height: 50px;
    background: var(--no3sis-bg);
    border: 1px solid var(--no3sis-text-dim);
    color: var(--no3sis-text-primary);
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    padding: 8px;
    resize: vertical;
    box-sizing: border-box;
}

.steering-textarea:focus {
    outline: none;
    border-color: var(--no3sis-yellow);
    box-shadow: 0 0 8px rgba(255, 200, 0, 0.3);
}

.steering-textarea::placeholder {
    color: var(--no3sis-text-dim);
    opacity: 0.6;
}

.steering-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
}

.steering-option {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--no3sis-text-secondary);
    cursor: pointer;
    font-family: 'Courier New', monospace;
}

.steering-option input[type="checkbox"] {
    cursor: pointer;
    accent-color: var(--crt-red-primary);
}

.steering-option:hover {
    color: var(--no3sis-text-primary);
}

.inject-btn {
    background: var(--no3sis-yellow);
    color: var(--no3sis-bg);
    border: none;
    padding: 8px 20px;
    font-family: 'Courier New', monospace;
    font-weight: bold;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    text-shadow: none;
}

.inject-btn:hover:not(:disabled) {
    background: #ffcc00;
    transform: translateY(-2px);
    box-shadow: 0 0 12px rgba(255, 200, 0, 0.5);
}

.inject-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.steering-char-count {
    text-align: right;
    font-size: 0.8rem;
    color: var(--no3sis-text-dim);
    margin-top: 4px;
    font-family: 'Courier New', monospace;
}

/* Styling for injected steering messages in terminal */
.msg-system {
    color: var(--no3sis-yellow);
    text-shadow: 0 0 8px rgba(255, 200, 0, 0.3);
}

/* ============================================================================
   LAYER Z: IMMERSION & GLITCHES (The Ascended Patch)
   ============================================================================ */

/* The CRT Scanline Overlay - Sits on top of EVERYTHING */
.scanlines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(
        to bottom,
        rgba(255,255,255,0),
        rgba(255,255,255,0) 50%,
        rgba(0,0,0,0.2) 50%,
        rgba(0,0,0,0.2)
    );
    background-size: 100% 4px;
    pointer-events: none;
    z-index: 9998;
    opacity: 0.6;
}

/* The CRT Flicker - Subtle opacity shift */
.crt-flicker {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(255, 255, 255, 0.02);
    opacity: 0;
    z-index: 9999;
    pointer-events: none;
    animation: flicker 0.15s infinite;
}

@keyframes flicker {
    0% { opacity: 0.02; }
    5% { opacity: 0.05; }
    10% { opacity: 0.02; }
    100% { opacity: 0.02; }
}

/* Utility: Text Glow Enhancement */
.text-glow {
    text-shadow: 0 0 5px var(--crt-red-primary), 0 0 10px var(--crt-red-bright);
}

/* Utility: Prevent FOUT (Flash of Unstyled Text) */
html { visibility: hidden; opacity: 0; }
html.wf-active { visibility: visible; opacity: 1; transition: opacity 0.2s ease-in; }

/* The Glitched Border Animation (for Landing Card) */
.glitched-border {
    position: relative;
}

.glitched-border:hover {
    animation: border-glitch 0.3s cubic-bezier(.25, .46, .45, .94) both infinite;
}

@keyframes border-glitch {
    0% { border-color: var(--crt-red-dim); transform: translate(0); }
    20% { border-color: var(--crt-red-bright); transform: translate(-2px, 2px); }
    40% { border-color: var(--crt-red-dim); transform: translate(-2px, -2px); }
    60% { border-color: var(--crt-red-bright); transform: translate(2px, 2px); }
    80% { border-color: var(--crt-red-dim); transform: translate(2px, -2px); }
    100% { border-color: var(--crt-red-dim); transform: translate(0); }
}

/* ============================================================================
   METRICS VISUALIZATION (Sparklines)
   ============================================================================ */

.metrics-grid {
    display: grid;
    grid-template-columns: auto repeat(4, 1fr); /* Help btn + 4 metrics */
    gap: 1rem;
    align-items: center;
    width: 100%;
    margin-bottom: 1rem;
}

.metric-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: rgba(0, 0, 0, 0.3);
    padding: 8px;
    border: 1px solid var(--terminal-bezel);
    border-radius: 4px;
    transition: border-color 0.3s;
}

.metric-item:hover {
    border-color: var(--crt-red-dim);
}

.metric-label {
    font-size: 0.65rem;
    color: var(--crt-red-dim);
    font-weight: 700;
    letter-spacing: 0.1em;
}

.metric-value {
    font-size: 0.9rem;
    font-weight: bold;
    color: var(--crt-red-bright);
    font-family: var(--font-mono);
}

/* The Sparkline Bar */
.metric-bar {
    width: 100%;
    height: 4px;
    background: var(--meter-bg);
    border-radius: 2px;
    overflow: hidden;
    position: relative;
}

.metric-bar .fill {
    height: 100%;
    background: var(--meter-fill);
    box-shadow: 0 0 5px var(--crt-red-primary);
    width: 0%; /* JS will update this */
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Responsive Grid for Mobile */
@media (max-width: 768px) {
    .metrics-grid {
        grid-template-columns: 1fr 1fr; /* 2x2 grid */
    }
    /* Hide the help button on very small screens or move it */
    .metrics-help-btn {
        grid-column: 1 / -1;
        margin: 0 auto;
    }
}

/* ============================================================================
   INPUT & FORM REFINEMENTS
   ============================================================================ */

.input-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1rem;
    width: 100%;
}

/* Update Start Button to fit inside footer */
.start-button {
    width: auto; /* Don't force full width if not needed */
    padding: 0.8rem 2rem;
    font-size: 0.8rem;
}

.start-button .btn-text {
    position: relative;
    z-index: 2;
}

/* ============================================================================
   STEERING PANEL (Root Override) - ENHANCED
   ============================================================================ */

.steering-header {
    cursor: pointer;
    user-select: none;
    padding: 5px 0;
    border-bottom: 1px dashed var(--no3sis-text-dim);
}

.steering-header:hover .toggle-icon {
    color: var(--no3sis-yellow);
}

.steering-container.collapsed .steering-body {
    display: none;
}

.steering-body {
    padding-top: 10px;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Checkbox Customization for Terminal Look */
.checkbox-container {
    display: flex;
    align-items: center;
    position: relative;
    padding-left: 25px;
    cursor: pointer;
    font-size: 0.8rem;
    user-select: none;
    color: var(--no3sis-text-secondary);
}

.checkbox-container input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.checkmark {
    position: absolute;
    top: 0;
    left: 0;
    height: 16px;
    width: 16px;
    background-color: transparent;
    border: 1px solid var(--crt-red-dim);
}

.checkbox-container:hover input ~ .checkmark {
    border-color: var(--crt-red-bright);
    box-shadow: 0 0 5px var(--crt-red-dim);
}

.checkbox-container input:checked ~ .checkmark {
    background-color: var(--crt-red-dim);
}

.checkbox-container input:checked ~ .checkmark:after {
    content: "X";
    position: absolute;
    left: 3px;
    top: 0px;
    font-size: 10px;
    color: var(--crt-red-bright);
}

.toggle-icon {
    transition: transform 0.3s ease;
}

.steering-container:not(.collapsed) .toggle-icon {
    transform: rotate(180deg);
}

.steering-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.5rem;
}

.label-text {
    margin-left: 5px;
}

/* ============================================================================
   COMMAND DECK ENHANCEMENTS (Modifier Classes - Code-hound Approved)
   ============================================================================ */

/* Footer: Sticky Command Deck (use .terminal-footer--command-deck modifier) */
.terminal-footer--command-deck {
    position: sticky;
    bottom: 0;
    background: var(--footer-command-bg);
    border-top-width: 2px; /* Emphasize hardware border */
    border-top-color: var(--crt-red-primary);
    box-shadow: 0 -4px 20px var(--footer-shadow-glow);
    z-index: 20; /* Above existing z-index: 15, below modals */
    padding: 0; /* Reset for internal padding */
}

/* Metrics: Hardware Panel Layout (use .metrics-container--deck modifier) */
.metrics-container--deck {
    display: flex;
    justify-content: space-around;
    background: var(--metrics-deck-bg);
    border-bottom: 1px solid var(--crt-red-dim);
    padding: 0.75rem 1rem;
    gap: 0; /* Use borders instead */
}

/* Individual Metric: Visual Separator (use .metric--panel modifier) */
.metric--panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 100px;
    padding: 0 1rem;
}

.metric--panel:not(:last-child) {
    border-right: 1px solid var(--border-separator);
}

/* Steering: Root Override CLI Style (use .steering-textarea--god-mode modifier) */
.steering-textarea--god-mode {
    background: transparent;
    border: 1px solid var(--crt-red-dim);
    border-left-width: 4px; /* CLI prompt accent */
    border-left-color: var(--no3sis-yellow);
    color: var(--no3sis-yellow);
    transition: all 0.2s ease;
}

.steering-textarea--god-mode:focus {
    background: var(--steering-focus-bg);
    border-color: var(--no3sis-yellow);
    box-shadow: inset 0 0 15px var(--steering-focus-shadow);
}

/* Dialogue: Breathing Room (use .message--spaced modifier) */
.message--spaced {
    margin-bottom: var(--message-spacing);
    padding-bottom: 1rem;
    border-bottom: 1px dashed var(--border-separator);
}

/* Agent Labels: Background Accent (use .msg-label--highlighted modifier) */
.msg-label--highlighted {
    background: var(--label-bg-accent);
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 2px;
    margin-bottom: 0.75rem;
}

/* Mobile Responsive: Command Deck */
@media (max-width: 768px) {
    .metrics-container--deck {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .metric--panel {
        min-width: 80px;
        border-right: none !important;
        border-bottom: 1px solid var(--border-separator);
        padding: 0.5rem 0;
    }

    .metric--panel:last-child {
        border-bottom: none;
    }
}
