/* Neural Discourse - Cyberpunk Terminal Aesthetic */

:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #0d0d14;
    --bg-tertiary: #12121a;
    --bg-panel: #080810;

    --green-primary: #00ff9d;
    --green-dim: #00cc7d;
    --green-glow: rgba(0, 255, 157, 0.4);
    --green-dark: #003d26;

    --purple-primary: #bf7af0;
    --purple-dim: #9466e8;
    --purple-glow: rgba(191, 122, 240, 0.4);

    --blue-primary: #00d4ff;
    --blue-dim: #00a8cc;
    --blue-glow: rgba(0, 212, 255, 0.4);

    --cyan-primary: #00ffd5;
    --cyan-glow: rgba(0, 255, 213, 0.3);
    --cyan-bloom: 0 0 10px rgba(0, 255, 213, 0.5),
                  0 0 20px rgba(0, 255, 213, 0.3),
                  0 0 40px rgba(0, 255, 213, 0.2);
    --cyan-bloom-intense: 0 0 15px rgba(0, 255, 213, 0.7),
                          0 0 30px rgba(0, 255, 213, 0.5),
                          0 0 60px rgba(0, 255, 213, 0.3);

    --text-primary: #e0e0e0;
    --text-secondary: #888;
    --text-dim: #444;

    --border-color: #1e1e2e;
    --border-glow: #2a2a4a;

    --font-mono: 'JetBrains Mono', 'Fira Code', 'SF Mono', 'Consolas', monospace;
}

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

html {
    background: var(--bg-primary);
}

/* Scanline Overlay with subtle flicker */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        repeating-linear-gradient(
            0deg,
            rgba(0, 0, 0, 0.2),
            rgba(0, 0, 0, 0.2) 1px,
            transparent 1px,
            transparent 2px
        ),
        repeating-linear-gradient(
            90deg,
            rgba(0, 255, 213, 0.015),
            rgba(0, 255, 213, 0.015) 1px,
            transparent 1px,
            transparent 4px
        );
    pointer-events: none;
    z-index: 9999;
    animation: scanlineFlicker 0.1s infinite;
}

@keyframes scanlineFlicker {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.97; }
}

/* CRT Vignette with chromatic aberration */
body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(ellipse at center, transparent 0%, transparent 50%, rgba(0,0,0,0.5) 100%),
        linear-gradient(90deg, rgba(255,0,0,0.02) 0%, transparent 3%, transparent 97%, rgba(0,255,255,0.02) 100%);
    pointer-events: none;
    z-index: 9998;
}

body {
    font-family: var(--font-mono);
    background: transparent;
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Matrix rain background canvas - stronger on left side */
#matrix-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    opacity: 0.45;
    pointer-events: none;
    mask-image: linear-gradient(
        90deg,
        rgba(0,0,0,0.6) 0%,
        rgba(0,0,0,0.5) 25%,
        rgba(0,0,0,0.4) 50%,
        rgba(0,0,0,0.35) 75%,
        rgba(0,0,0,0.3) 100%
    );
    -webkit-mask-image: linear-gradient(
        90deg,
        rgba(0,0,0,0.6) 0%,
        rgba(0,0,0,0.5) 25%,
        rgba(0,0,0,0.4) 50%,
        rgba(0,0,0,0.35) 75%,
        rgba(0,0,0,0.3) 100%
    );
}

/* Geometric Corner Decorator */
.cyber-corner {
    position: absolute;
    width: 20px;
    height: 20px;
    border-color: var(--green-primary);
    border-style: solid;
    border-width: 0;
    opacity: 0.6;
}

.cyber-corner.tl { top: 0; left: 0; border-top-width: 2px; border-left-width: 2px; }
.cyber-corner.tr { top: 0; right: 0; border-top-width: 2px; border-right-width: 2px; }
.cyber-corner.bl { bottom: 0; left: 0; border-bottom-width: 2px; border-left-width: 2px; }
.cyber-corner.br { bottom: 0; right: 0; border-bottom-width: 2px; border-right-width: 2px; }

/* Header */
.header {
    padding: 0.75rem 2rem;
    border: 1px solid var(--purple-dim);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(180deg, var(--bg-secondary) 0%, var(--bg-primary) 100%);
    position: relative;
    z-index: 2;
    margin: 0 40px 8px 40px;
    box-shadow: 0 0 20px rgba(191, 122, 240, 0.15);
}

.header::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--purple-primary), var(--cyan-primary), var(--green-primary), transparent);
    opacity: 0.5;
}

.logo {
    display: flex;
    align-items: center;
    gap: 1rem;
}

#tesseract {
    width: 100px;
    height: 100px;
    filter: drop-shadow(0 0 15px rgba(0, 255, 213, 0.8)) drop-shadow(0 0 30px rgba(0, 255, 213, 0.5));
    display: block;
    background: transparent;
}

.settings-btn {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 0.4rem 0.6rem;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    cursor: pointer;
    transition: all 0.2s;
    margin-left: 1rem;
}

.settings-btn:hover {
    border-color: var(--purple-primary);
    color: var(--purple-primary);
    box-shadow: 0 0 10px var(--purple-glow);
}

.api-key-input {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    letter-spacing: 1px;
}

.key-status {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    font-size: 0.6rem;
    border-radius: 2px;
    margin-left: 0.5rem;
}

.key-status.configured {
    background: rgba(0, 255, 157, 0.2);
    color: var(--green-primary);
    border: 1px solid var(--green-dim);
}

.key-status.missing {
    background: rgba(136, 136, 136, 0.15);
    color: var(--text-dim);
    border: 1px solid var(--text-dim);
}

.logo-text {
    font-size: 1rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 3px;
    background: linear-gradient(90deg, var(--green-primary), var(--cyan-primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: none;
    filter: drop-shadow(0 0 10px var(--green-glow));
    position: relative;
}

.logo-text::after {
    content: '_';
    -webkit-text-fill-color: var(--green-primary);
    animation: blink 1s step-end infinite;
}

@keyframes blink {
    50% { opacity: 0; }
}

/* Glitch Effect */
.glitch {
    position: relative;
}

.glitch::before,
.glitch::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-secondary);
}

.glitch::before {
    left: 2px;
    text-shadow: -2px 0 var(--purple-primary);
    clip: rect(24px, 550px, 90px, 0);
    animation: glitch-anim 3s infinite linear alternate-reverse;
}

.glitch::after {
    left: -2px;
    text-shadow: -2px 0 var(--blue-primary);
    clip: rect(85px, 550px, 140px, 0);
    animation: glitch-anim 2s infinite linear alternate-reverse;
}

@keyframes glitch-anim {
    0% { clip: rect(10px, 9999px, 31px, 0); }
    10% { clip: rect(67px, 9999px, 91px, 0); }
    20% { clip: rect(12px, 9999px, 52px, 0); }
    30% { clip: rect(45px, 9999px, 71px, 0); }
    40% { clip: rect(23px, 9999px, 84px, 0); }
    50% { clip: rect(58px, 9999px, 92px, 0); }
    60% { clip: rect(31px, 9999px, 62px, 0); }
    70% { clip: rect(76px, 9999px, 98px, 0); }
    80% { clip: rect(8px, 9999px, 47px, 0); }
    90% { clip: rect(89px, 9999px, 100px, 0); }
    100% { clip: rect(43px, 9999px, 78px, 0); }
}

.status-bar {
    display: flex;
    gap: 2rem;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.status-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.8rem;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    position: relative;
}

.status-item::before,
.status-item::after {
    content: '';
    position: absolute;
    width: 6px;
    height: 6px;
    border-color: var(--green-dim);
    border-style: solid;
}

.status-item::before {
    top: -1px;
    left: -1px;
    border-width: 1px 0 0 1px;
}

.status-item::after {
    bottom: -1px;
    right: -1px;
    border-width: 0 1px 1px 0;
}

.status-dot {
    width: 10px;
    height: 9px;
    background: var(--text-dim);
    clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
}

.status-dot.active {
    background: var(--green-primary);
    box-shadow: 0 0 10px var(--green-glow);
    animation: statusPulse 2s infinite;
}

.status-dot.inactive {
    background: var(--purple-dim);
    opacity: 0.4;
}

@keyframes statusPulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 10px var(--green-glow); }
    50% { opacity: 0.6; box-shadow: 0 0 20px var(--green-glow); }
}

/* Main Layout */
.main-container {
    display: grid;
    grid-template-columns: 280px 1fr 300px;
    gap: 0;
    height: calc(100vh - 60px - 30px);
    position: relative;
    margin: 0 40px 30px 40px;
    background: transparent;
    pointer-events: none;
}

.main-container > * {
    pointer-events: auto;
}

/* Sidebar */
.sidebar {
    background: var(--bg-secondary);
    border: 1px solid var(--purple-dim);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    box-shadow: 0 0 20px rgba(191, 122, 240, 0.3), 0 0 40px rgba(191, 122, 240, 0.15);
    margin-right: 10px;
    min-height: 0;
    max-height: 100%;
    transition: box-shadow 0.3s ease;
}

.sidebar:hover {
    box-shadow: 0 0 25px rgba(191, 122, 240, 0.5), 0 0 50px rgba(191, 122, 240, 0.25);
}

.sidebar-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    position: relative;
}

.sidebar-title {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 3px;
    color: var(--purple-primary);
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sidebar-title::before {
    content: '//';
    color: var(--text-dim);
}

.sidebar-title::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, var(--purple-dim), transparent);
}

/* Buttons */
.btn {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    padding: 0.7rem 1rem;
    border: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
    letter-spacing: 1px;
    position: relative;
    clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 8px, 100% 100%, 8px 100%, 0 calc(100% - 8px));
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, transparent 0%, rgba(255,255,255,0.05) 100%);
    pointer-events: none;
}

.btn:hover {
    border-color: var(--green-primary);
    box-shadow: 0 0 15px var(--green-glow), inset 0 0 15px rgba(0, 255, 157, 0.1);
    text-shadow: 0 0 10px var(--green-glow);
}

.btn-primary {
    background: linear-gradient(135deg, var(--green-dark) 0%, var(--bg-tertiary) 100%);
    border-color: var(--green-dim);
    color: var(--green-primary);
    font-weight: 600;
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--green-dim) 0%, var(--green-dark) 100%);
    box-shadow: 0 0 25px var(--green-glow), inset 0 0 20px rgba(0, 255, 157, 0.2);
}

.btn-block {
    width: 100%;
}

/* Conversation List */
.conversation-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.conversation-item {
    padding: 0.75rem 1rem;
    border: 1px solid transparent;
    margin-bottom: 0.25rem;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    background: transparent;
}

.conversation-item::before {
    content: '>';
    position: absolute;
    left: 0.25rem;
    color: var(--text-dim);
    opacity: 0;
    transition: all 0.2s;
}

.conversation-item:hover {
    background: rgba(191, 122, 240, 0.05);
    border-color: var(--border-color);
    padding-left: 1.5rem;
}

.conversation-item:hover::before {
    opacity: 1;
    color: var(--purple-primary);
}

.conversation-item.active {
    background: rgba(191, 122, 240, 0.1);
    border-color: var(--purple-dim);
    border-left: 3px solid var(--purple-primary);
    padding-left: 1.5rem;
}

.conversation-item.active::before {
    content: '▶';
    opacity: 1;
    color: var(--purple-primary);
    font-size: 0.6rem;
}

.conversation-title {
    font-size: 0.8rem;
    margin-bottom: 0.25rem;
    color: var(--text-primary);
}

.conversation-meta {
    font-size: 0.6rem;
    color: var(--text-dim);
    font-family: var(--font-mono);
}

/* Main Chat Area */
.chat-container {
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
    position: relative;
    border: 1px solid var(--green-dim);
    box-shadow: 0 0 20px rgba(0, 255, 157, 0.3), 0 0 40px rgba(0, 255, 157, 0.15);
    margin-right: 10px;
    min-height: 0;
    max-height: 100%;
    overflow: hidden;
    transition: box-shadow 0.3s ease;
}

.chat-container:hover {
    box-shadow: 0 0 25px rgba(0, 255, 157, 0.5), 0 0 50px rgba(0, 255, 157, 0.25);
}

.chat-header {
    padding: 0.75rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-secondary);
    position: relative;
}

.chat-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--blue-primary), transparent);
    opacity: 0.3;
}

.chat-title {
    font-size: 0.8rem;
    color: var(--blue-primary);
    text-transform: uppercase;
    letter-spacing: 2px;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.chat-title::before {
    content: '⬡';
    font-size: 0.7rem;
    animation: pulseHex 2s ease-in-out infinite;
}

@keyframes pulseHex {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(0.9); }
}

.chat-actions {
    display: flex;
    gap: 0.5rem;
}

/* Messages */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    background:
        radial-gradient(ellipse at top left, rgba(191, 122, 240, 0.03) 0%, transparent 50%),
        radial-gradient(ellipse at bottom right, rgba(0, 255, 157, 0.03) 0%, transparent 50%);
    min-height: 0;
}

.message {
    max-width: 80%;
    padding: 1rem 1.25rem;
    position: relative;
    line-height: 1.7;
    font-size: 0.85rem;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
}

.message::before,
.message::after {
    content: '';
    position: absolute;
    width: 10px;
    height: 10px;
}

.message-model-a {
    align-self: flex-start;
    border-left: 3px solid var(--purple-primary);
    clip-path: polygon(0 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%);
}

.message-model-a::before {
    top: -1px;
    left: -4px;
    border-top: 1px solid var(--purple-primary);
    border-left: 1px solid var(--purple-primary);
}

.message-model-b {
    align-self: flex-end;
    border-right: 3px solid var(--green-primary);
    clip-path: polygon(0 0, 100% 0, 100% 100%, 10px 100%, 0 calc(100% - 10px));
}

.message-model-b::after {
    bottom: -1px;
    right: -4px;
    border-bottom: 1px solid var(--green-primary);
    border-right: 1px solid var(--green-primary);
}

.message-human {
    border: 2px solid var(--blue-primary) !important;
    background: linear-gradient(135deg, rgba(0, 153, 255, 0.05), rgba(0, 208, 255, 0.05)) !important;
    box-shadow: 0 0 15px rgba(0, 153, 255, 0.3) !important;
}

.message-human .message-model {
    color: var(--blue-primary) !important;
}

.message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.message-model {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 2px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* AI Avatar - Rotating Cube */
.ai-avatar {
    width: 18px;
    height: 18px;
    position: relative;
    display: inline-block;
    perspective: 50px;
}

.ai-avatar .cube {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    animation: rotateCube 4s infinite linear;
}

.ai-avatar .cube-face {
    position: absolute;
    width: 12px;
    height: 12px;
    border: 1px solid;
    opacity: 0.8;
    top: 3px;
    left: 3px;
}

.ai-avatar .cube-face.front { transform: translateZ(6px); }
.ai-avatar .cube-face.back { transform: translateZ(-6px) rotateY(180deg); }
.ai-avatar .cube-face.right { transform: translateX(6px) rotateY(90deg); }
.ai-avatar .cube-face.left { transform: translateX(-6px) rotateY(-90deg); }
.ai-avatar .cube-face.top { transform: translateY(-6px) rotateX(90deg); }
.ai-avatar .cube-face.bottom { transform: translateY(6px) rotateX(-90deg); }

@keyframes rotateCube {
    0% { transform: rotateX(0deg) rotateY(0deg); }
    100% { transform: rotateX(360deg) rotateY(360deg); }
}

/* Model A avatar - purple/blue */
.message-model-a .ai-avatar .cube-face {
    border-color: var(--purple-primary);
    background: rgba(168, 85, 247, 0.15);
    box-shadow: inset 0 0 5px rgba(168, 85, 247, 0.3);
}

/* Model B avatar - cyan/green */
.message-model-b .ai-avatar .cube-face {
    border-color: var(--cyan-primary);
    background: rgba(0, 208, 255, 0.15);
    box-shadow: inset 0 0 5px rgba(0, 208, 255, 0.3);
}

.message-model-a .message-model {
    color: var(--purple-primary);
}

.message-model-b .message-model {
    color: var(--cyan-primary);
}

.message-tokens {
    font-size: 0.6rem;
    color: var(--text-dim);
    padding: 0.15rem 0.4rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
}

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

/* Controls Panel */
.controls-panel {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
    display: flex;
    gap: 1rem;
    align-items: center;
    position: relative;
}

.controls-panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, var(--green-primary), transparent, var(--purple-primary));
    opacity: 0.3;
}

.turns-input {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.turns-input label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.turns-input input {
    width: 60px;
    padding: 0.5rem;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    color: var(--green-primary);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    text-align: center;
    clip-path: polygon(0 0, calc(100% - 5px) 0, 100% 5px, 100% 100%, 5px 100%, 0 calc(100% - 5px));
}

.turns-input input:focus {
    outline: none;
    border-color: var(--green-primary);
    box-shadow: 0 0 15px var(--green-glow);
}

/* Settings Panel */
.settings-panel {
    background: var(--bg-secondary);
    border: 1px solid var(--cyan-primary);
    padding: 1rem;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 0 20px rgba(0, 255, 213, 0.3), 0 0 40px rgba(0, 255, 213, 0.15);
    min-height: 0;
    max-height: 100%;
    transition: box-shadow 0.3s ease;
}

.settings-panel:hover {
    box-shadow: var(--cyan-bloom-intense);
}


.settings-section {
    margin-bottom: 1.5rem;
    position: relative;
}

.settings-title {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 3px;
    color: var(--blue-primary);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    justify-content: space-between;
}

.settings-title::before {
    content: '⬡';
    font-size: 0.7rem;
}

.panel-close-btn {
    background: transparent;
    border: 1px solid var(--cyan-dim);
    color: var(--cyan-primary);
    cursor: pointer;
    padding: 0.2rem 0.4rem;
    font-size: 0.7rem;
    transition: all 0.3s ease;
    margin-left: auto;
}

.panel-close-btn:hover {
    background: var(--cyan-dim);
    color: var(--bg-primary);
    box-shadow: 0 0 10px var(--cyan-glow);
}

.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.form-label::before {
    content: '// ';
    color: var(--text-dim);
}

.form-select,
.form-input,
.form-textarea {
    width: 100%;
    padding: 0.6rem 0.75rem;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    transition: all 0.2s;
}

.form-select:focus,
.form-input:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--green-primary);
    box-shadow: 0 0 15px var(--green-glow);
}

.form-select option {
    background: var(--bg-secondary);
}

.form-textarea {
    min-height: 70px;
    resize: vertical;
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-dim);
    text-align: center;
    padding: 2rem;
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 1.5rem;
    opacity: 0.2;
    animation: floatIcon 3s ease-in-out infinite;
}

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

.empty-text {
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--cyan-primary);
    animation: textPulseGlitch 3s ease-in-out infinite;
    position: relative;
}

@keyframes textPulseGlitch {
    0%, 100% {
        opacity: 1;
        text-shadow: 0 0 10px var(--cyan-glow);
        transform: translateX(0);
    }
    25% {
        opacity: 0.85;
        text-shadow: 0 0 20px var(--cyan-glow), 0 0 40px var(--green-glow);
    }
    50% {
        opacity: 1;
        text-shadow: 0 0 15px var(--green-glow);
    }
    75% {
        opacity: 0.9;
        text-shadow: 0 0 25px var(--purple-glow);
    }
    /* Glitch moments */
    5% { transform: translateX(-2px); }
    5.5% { transform: translateX(2px); }
    6% { transform: translateX(0); }
    45% { transform: translateX(1px); }
    45.5% { transform: translateX(-1px); }
    46% { transform: translateX(0); }
}

.empty-hint {
    font-size: 0.7rem;
    color: var(--text-dim);
}

/* Loading Animation */
.loading {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--green-primary);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.loading-dots {
    display: flex;
    gap: 4px;
}

.loading-dots span {
    width: 8px;
    height: 7px;
    background: var(--green-primary);
    clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
    animation: loadingDot 1.4s infinite ease-in-out both;
}

.loading-dots span:nth-child(1) { animation-delay: -0.32s; }
.loading-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes loadingDot {
    0%, 80%, 100% { transform: scale(0) rotate(0deg); }
    40% { transform: scale(1) rotate(45deg); }
}

/* Scrollbar - Default (green for chat) */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--green-dim), var(--green-dark));
    border-radius: 4px;
    border: 1px solid var(--green-dim);
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, var(--green-primary), var(--green-dim));
    box-shadow: 0 0 8px var(--green-glow);
}

::-webkit-scrollbar-corner {
    background: var(--bg-panel);
}

/* Sidebar scrollbar - Purple */
.sidebar ::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--purple-dim), rgba(148, 102, 232, 0.4));
    border: 1px solid var(--purple-dim);
}

.sidebar ::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, var(--purple-primary), var(--purple-dim));
    box-shadow: 0 0 8px var(--purple-glow);
}

/* Settings panel scrollbar - Cyan */
.settings-panel::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--cyan-primary), var(--blue-dim));
    border: 1px solid var(--cyan-primary);
}

.settings-panel::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, var(--cyan-primary), var(--blue-primary));
    box-shadow: 0 0 8px var(--cyan-glow);
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
    backdrop-filter: blur(5px);
}

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

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    clip-path: polygon(0 0, calc(100% - 20px) 0, 100% 20px, 100% 100%, 20px 100%, 0 calc(100% - 20px));
}

.modal::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--purple-primary), var(--cyan-primary), var(--green-primary), var(--purple-primary));
}

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

.modal-title {
    font-size: 0.8rem;
    color: var(--green-primary);
    text-transform: uppercase;
    letter-spacing: 2px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.modal-title::before {
    content: '>';
    color: var(--text-dim);
}

.modal-close {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    line-height: 1;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.modal-close:hover {
    color: var(--green-primary);
    border-color: var(--green-primary);
    box-shadow: 0 0 10px var(--green-glow);
}

.modal-body {
    padding: 1.5rem;
}

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

/* Decorative ASCII Border */
.ascii-border {
    position: relative;
    padding: 1rem;
}

.ascii-border::before {
    content: '┌──────────────────────────────────────┐';
    position: absolute;
    top: 0;
    left: 0;
    font-size: 0.5rem;
    color: var(--text-dim);
    white-space: pre;
}

/* Hex decoration */
.hex-decoration {
    position: fixed;
    bottom: 20px;
    left: 20px;
    font-size: 0.6rem;
    color: var(--text-dim);
    font-family: var(--font-mono);
    opacity: 0.3;
    pointer-events: none;
}

/* Responsive */
@media (max-width: 1400px) {
    .main-container {
        margin: 0 20px 30px 20px;
    }
    .header {
        margin: 0 20px 8px 20px;
    }
}

@media (max-width: 1200px) {
    .main-container {
        grid-template-columns: 250px 1fr 260px;
        margin: 0 15px 20px 15px;
    }
    .header {
        margin: 0 15px 8px 15px;
    }
}

@media (max-width: 900px) {
    .main-container {
        margin: 0;
        gap: 0;
        height: calc(100vh - 52px);
        grid-template-columns: 1fr;
    }
    .header {
        margin: 0;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }

    .settings-panel {
        display: none !important;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1001;
        background: var(--bg-secondary);
        overflow-y: auto;
    }

    .settings-panel[style*="display: block"],
    .settings-panel[style*="display:block"] {
        display: block !important;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: -280px;
        width: 280px;
        height: 100vh;
        z-index: 1000;
        margin: 0;
        border-radius: 0;
        transition: left 0.3s ease;
    }

    .sidebar.mobile-open {
        left: 0;
    }

    .mobile-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.7);
        z-index: 999;
    }

    .mobile-overlay.active {
        display: block;
    }

    .chat-container {
        margin: 0;
        padding-top: 2.2rem;
        display: flex;
        flex-direction: column;
    }

    .chat-header {
        flex-shrink: 0;
    }

    .messages-container {
        padding: 0.5rem;
        flex: 1;
        overflow-y: auto;
        min-height: 200px;
    }

    .controls-panel {
        flex-shrink: 0;
    }

    .message {
        max-width: 98%;
    }
}

/* Mobile Config Bar */
.mobile-config {
    display: none;
    padding: 0.35rem 0.5rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    gap: 0.4rem;
    justify-content: center;
    align-items: center;
    min-height: 0;
    line-height: 1;
    margin: 0;
}

@media (max-width: 900px) {
    .mobile-config {
        display: flex;
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        z-index: 100;
    }

    .chat-container {
        margin-top: 0;
    }
}

.mobile-btn {
    padding: 0.5rem 0.85rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--cyan-dim);
    color: var(--cyan-primary);
    font-family: var(--font-mono);
    font-size: 0.7rem;
    line-height: 1;
    cursor: pointer;
    transition: all 0.3s ease;
    height: auto;
    min-height: 0;
    display: inline-flex;
    align-items: center;
    margin: 0;
}

.mobile-btn:hover, .mobile-btn:active {
    background: var(--cyan-dim);
    color: var(--bg-primary);
}

/* ============================================
   TAB NAVIGATION
   ============================================ */

.tab-nav {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin: 0 30px;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.tab-btn {
    padding: 0.6rem 1.25rem;
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-dim);
    font-family: var(--font-mono);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 8px, 100% 100%, 8px 100%, 0 calc(100% - 8px));
}

.tab-btn:hover {
    color: var(--cyan-primary);
    border-color: var(--cyan-primary);
    background: rgba(0, 255, 213, 0.08);
    box-shadow: 0 0 15px var(--cyan-glow);
}

.tab-btn.active {
    color: var(--green-primary);
    border-color: var(--green-primary);
    background: rgba(0, 255, 157, 0.1);
    box-shadow: 0 0 20px var(--green-glow);
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--green-primary);
    box-shadow: 0 0 10px var(--green-glow);
}

/* Tab Content */
.tab-content {
    display: none;
}

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

/* ============================================
   INFO PAGES (Instructions, Credits)
   ============================================ */

.info-page {
    max-width: 800px;
    margin: 2rem auto;
    padding: 2rem;
}

.info-section {
    margin-bottom: 2.5rem;
    padding: 1.5rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    position: relative;
    box-shadow: 0 0 20px rgba(0, 255, 213, 0.15), 0 0 40px rgba(0, 255, 213, 0.08);
}

.info-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 3px;
    height: 100%;
    background: linear-gradient(180deg, var(--cyan-primary), var(--purple-primary));
}

.info-title {
    font-size: 0.85rem;
    color: var(--cyan-primary);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.info-text {
    font-size: 0.8rem;
    line-height: 1.8;
    color: var(--text-secondary);
}

.info-text.version {
    color: var(--text-dim);
    font-size: 0.7rem;
}

.info-list {
    margin: 0.75rem 0;
    padding-left: 1.5rem;
    color: var(--text-secondary);
    font-size: 0.8rem;
    line-height: 1.8;
}

.info-list li {
    margin-bottom: 0.25rem;
}

.info-link {
    color: var(--cyan-primary);
    text-decoration: none;
    border-bottom: 1px solid var(--cyan-dim);
    transition: all 0.3s ease;
}

.info-link:hover {
    color: var(--green-primary);
    border-color: var(--green-primary);
}

.info-steps {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.info-step {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    padding: 1rem;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
}

.step-number {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--green-primary);
    min-width: 2.5rem;
}

.info-step strong {
    display: block;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
    font-size: 0.8rem;
}

.info-step p {
    font-size: 0.75rem;
    color: var(--text-dim);
    margin: 0;
}

/* Provider Tags */
.provider-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.provider-tag {
    padding: 0.4rem 0.8rem;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    border: 1px solid;
    background: rgba(0, 0, 0, 0.3);
}

.provider-tag.anthropic {
    color: var(--purple-primary);
    border-color: var(--purple-primary);
}

.provider-tag.groq {
    color: var(--green-primary);
    border-color: var(--green-primary);
}

.provider-tag.openai {
    color: #74aa9c;
    border-color: #74aa9c;
}

.provider-tag.xai {
    color: var(--text-secondary);
    border-color: var(--text-secondary);
}

.provider-tag.kimi {
    color: var(--cyan-primary);
    border-color: var(--cyan-primary);
}

.provider-tag.gemini {
    color: var(--blue-primary);
    border-color: var(--blue-primary);
}

/* Tech List */
.tech-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tech-item {
    padding: 0.3rem 0.6rem;
    font-size: 0.65rem;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    background: var(--bg-panel);
}

/* Contact Link */
.contact-link {
    color: var(--cyan-primary);
    text-decoration: none;
    transition: all 0.2s;
}

.contact-link:hover {
    text-shadow: 0 0 10px var(--cyan-glow);
}

/* ============================================
   HISTORY PAGE
   ============================================ */

.history-page {
    height: calc(100vh - 100px);
    display: flex;
    flex-direction: column;
    padding: 0.5rem 2rem;
}

.history-header {
    text-align: center;
    margin-bottom: 0.5rem;
}

.history-header .info-title {
    border-bottom: none;
    margin-bottom: 0.5rem;
}

.history-header .info-text {
    font-size: 0.7rem;
}

.history-canvas-container {
    flex: 1;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    position: relative;
    overflow: hidden;
    box-shadow: 0 0 25px rgba(0, 255, 213, 0.15), 0 0 50px rgba(0, 255, 213, 0.08);
}

#history-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

.history-legend {
    display: flex;
    justify-content: center;
    gap: 2rem;
    padding: 0.75rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-top: none;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.65rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.legend-dot.neuron {
    background: var(--cyan-primary);
    box-shadow: 0 0 8px var(--cyan-glow);
}

.legend-line {
    width: 25px;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--cyan-primary), transparent);
    box-shadow: 0 0 5px var(--cyan-glow);
}

/* Responsive adjustments for tabs */
@media (max-width: 900px) {
    .tab-nav {
        margin: 0;
        padding: 0.5rem;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        justify-content: flex-start;
    }

    .tab-btn {
        font-size: 0.7rem;
        padding: 0.5rem 0.85rem;
        white-space: nowrap;
        flex-shrink: 0;
    }

    .info-page {
        margin: 1rem;
        padding: 1rem;
    }

    .info-section {
        padding: 1rem;
    }

    .info-step {
        flex-direction: column;
        gap: 0.5rem;
    }

    .step-number {
        font-size: 1rem;
    }

    .history-page {
        padding: 0.5rem;
        height: calc(100vh - 100px);
    }

    .history-legend {
        gap: 0.75rem;
        flex-wrap: wrap;
        padding: 0.5rem;
    }

    .legend-item {
        font-size: 0.55rem;
    }

    /* Header adjustments for mobile */
    .status-bar {
        flex-wrap: wrap;
        gap: 0.25rem 0.5rem;
    }

    .status-item {
        font-size: 0.55rem;
    }

    .settings-btn {
        font-size: 0.6rem;
        padding: 0.3rem 0.6rem;
    }

    .logo-text {
        font-size: 0.8rem;
    }

    /* Fix main container height with tabs */
    .main-container {
        height: calc(100vh - 90px);
    }

    /* Provider tags wrap nicely */
    .provider-tags {
        justify-content: center;
    }

    .tech-list {
        justify-content: center;
    }
}

/* Extra small screens (phones in portrait) */
@media (max-width: 480px) {
    .tab-nav {
        justify-content: flex-start;
    }

    .tab-btn {
        font-size: 0.55rem;
        padding: 0.35rem 0.5rem;
    }

    .info-page {
        margin: 0.5rem;
        padding: 0.75rem;
    }

    .info-title {
        font-size: 0.75rem;
    }

    .info-text {
        font-size: 0.7rem;
    }

    .logo-text {
        font-size: 0.7rem;
    }

    .header {
        padding: 0.5rem 0.75rem;
    }

    .status-bar {
        display: none;
    }

    /* Modal adjustments */
    .modal {
        width: 95%;
        max-height: 95vh;
    }

    .modal-body {
        padding: 1rem;
    }

    .form-textarea {
        min-height: 50px;
    }

    /* Messages fit better */
    .messages-container {
        padding: 0.75rem;
    }

    .message {
        max-width: 95%;
        padding: 0.75rem 1rem;
        font-size: 0.8rem;
    }

    .message-header {
        flex-direction: column;
        gap: 0.25rem;
        align-items: flex-start;
    }

    .controls-panel {
        flex-wrap: wrap;
        padding: 0.75rem;
    }
}
