/* c0vert-chxt theme: Cyberpunk / CRT / Neon Indigo & Holo-Cyan */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --bg-void: #0a0714;
    --bg-panel: #130c24;
    --bg-panel-alt: #1c1136;
    --bg-input: #0d0820;
    --purple-800: #291447;
    --purple-700: #4c2a7a;
    --purple-500: #7b2cbf;
    --purple-400: #9d4edd;
    --purple-300: #c77dff;
    --purple-200: #e0aaff;
    --holo-cyan: #00e5ff;
    --cyan-dim: #0099aa;
    --text-dim: #9d7ab8;
    --text-bright: #f0e6ff;
    --danger: #ff3366;
    --danger-glow: rgba(255, 51, 102, 0.6);
    --warning: #ffaa00;
    --success: #00ffaa;
    --success-glow: rgba(0, 255, 170, 0.6);
}

html, body {
    width: 100%;
    height: 100%;
    height: 100dvh;
    font-family: 'Courier New', Courier, monospace;
    background: var(--bg-void);
    color: var(--purple-200);
    overflow: hidden;
    position: relative;
    -webkit-font-smoothing: antialiased;
}

/* CRT & Atmosphere layers */
.grid-overlay {
    position: fixed; inset: 0; z-index: 0; pointer-events: none;
    background:
        linear-gradient(rgba(157, 78, 221, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(157, 78, 221, 0.05) 1px, transparent 1px);
    background-size: 40px 40px;
    animation: gridScroll 25s linear infinite;
}
@keyframes gridScroll { to { transform: translate(40px, 40px); } }

.scanlines {
    position: fixed; inset: 0; z-index: 10; pointer-events: none;
    background: repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(0,0,0,.28) 2px, rgba(0,0,0,.28) 4px);
}

.crt-glow {
    position: fixed; inset: 0; z-index: 10; pointer-events: none;
    background: radial-gradient(ellipse at center, rgba(157,78,221,.07) 0%, rgba(0,229,255,.03) 50%, rgba(0,0,0,.6) 100%);
    box-shadow: inset 0 0 100px rgba(0,0,0,0.8);
}

.particles { position: fixed; inset: 0; pointer-events: none; z-index: 1; }
.particle {
    position: absolute; width: 2px; height: 2px; border-radius: 50%;
    background: var(--purple-300); box-shadow: 0 0 6px var(--purple-400);
    opacity: 0; animation: floatParticle linear infinite;
}
.particle.cyan { background: var(--holo-cyan); box-shadow: 0 0 8px var(--holo-cyan); }
@keyframes floatParticle {
    0% { opacity: 0; transform: translateY(100vh) scale(0); }
    10%, 90% { opacity: 0.8; }
    100% { opacity: 0; transform: translateY(-10vh) scale(1); }
}

/* App Shell Layout */
.app-container {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    height: 100dvh;
    max-width: 1200px;
    margin: 0 auto;
    background: rgba(19, 12, 36, 0.85);
    border-left: 1px solid var(--purple-700);
    border-right: 1px solid var(--purple-700);
    backdrop-filter: blur(8px);
}

/* Header */
.app-header {
    flex-shrink: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--purple-700);
    box-shadow: 0 2px 15px rgba(0,0,0,0.4);
    gap: 10px;
}

.brand-section {
    display: flex;
    align-items: center;
    gap: 12px;
}

.app-logo {
    width: 32px;
    height: 32px;
    image-rendering: pixelated;
    border: 1px solid var(--holo-cyan);
    border-radius: 4px;
    box-shadow: 0 0 8px rgba(0, 229, 255, 0.4);
}

.brand-text h1 {
    font-size: 1.15rem;
    font-weight: bold;
    color: var(--holo-cyan);
    letter-spacing: 0.08em;
    text-shadow: 0 0 10px rgba(0, 229, 255, 0.5);
    margin: 0;
}

.brand-text .version-tag {
    font-size: 0.72rem;
    color: var(--purple-300);
    letter-spacing: 0.05em;
}

.header-status-area {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.node-counter {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: var(--bg-input);
    border: 1px solid var(--purple-700);
    border-radius: 4px;
    font-size: 0.78rem;
    color: var(--text-bright);
}

.pulse-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 8px var(--success-glow);
    animation: blink 2s infinite;
}
.pulse-dot.warning { background: var(--warning); box-shadow: 0 0 8px var(--warning); }
.pulse-dot.danger { background: var(--danger); box-shadow: 0 0 8px var(--danger); }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

/* Kill Switch Bar */
.killswitch-bar {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    background: #1a0a18;
    border-bottom: 1px solid var(--purple-700);
    transition: background 0.3s;
    flex-wrap: wrap;
    gap: 10px;
}

.killswitch-bar.armed {
    background: linear-gradient(90deg, rgba(255, 51, 102, 0.15), rgba(255, 170, 0, 0.1));
    border-bottom: 1px solid var(--danger);
    box-shadow: inset 0 0 20px rgba(255, 51, 102, 0.2);
}

.killswitch-bar.disarmed {
    background: linear-gradient(90deg, rgba(0, 255, 170, 0.1), rgba(0, 229, 255, 0.05));
    border-bottom: 1px solid var(--success);
}

.ks-info {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.82rem;
}

.ks-title {
    font-weight: bold;
    letter-spacing: 0.05em;
}

.ks-timer {
    font-weight: bold;
    font-size: 1.05rem;
    padding: 2px 8px;
    border-radius: 3px;
    background: rgba(0,0,0,0.4);
    letter-spacing: 0.1em;
}

.killswitch-bar.armed .ks-timer {
    color: var(--danger);
    border: 1px solid var(--danger);
    text-shadow: 0 0 8px var(--danger-glow);
    animation: timerPulse 1s infinite alternate;
}
@keyframes timerPulse { from { transform: scale(1); } to { transform: scale(1.05); } }

.killswitch-bar.disarmed .ks-timer {
    color: var(--success);
    border: 1px solid var(--success);
    text-shadow: 0 0 8px var(--success-glow);
}

.ks-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Custom Tactical Switch Button */
.switch-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: bold;
    text-transform: uppercase;
    cursor: pointer;
    border-radius: 3px;
    transition: all 0.2s;
    user-select: none;
}

.switch-btn.arm-trigger {
    background: rgba(255, 51, 102, 0.2);
    color: var(--danger);
    border: 1px solid var(--danger);
    box-shadow: 0 0 10px rgba(255, 51, 102, 0.3);
}

.switch-btn.arm-trigger:hover {
    background: var(--danger);
    color: var(--bg-void);
    box-shadow: 0 0 18px var(--danger-glow);
}

.switch-btn.disarmed-state {
    background: rgba(0, 255, 170, 0.15);
    color: var(--success);
    border: 1px solid var(--success);
    cursor: default;
    box-shadow: 0 0 8px var(--success-glow);
}

.purge-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    font-family: inherit;
    font-size: 0.75rem;
    color: #ff7799;
    background: transparent;
    border: 1px solid #772244;
    border-radius: 3px;
    cursor: pointer;
    transition: 0.2s;
}
.purge-btn:hover {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
    box-shadow: 0 0 12px var(--danger-glow);
}

/* Encryption Bar */
.crypto-bar {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 5px 16px;
    background: var(--bg-input);
    border-bottom: 1px solid var(--purple-700);
    font-size: 0.75rem;
    color: var(--text-dim);
}
.crypto-bar .e2ee-badge {
    color: var(--holo-cyan);
    font-weight: bold;
}
.crypto-bar .key-btn {
    background: none;
    border: 1px solid var(--purple-700);
    color: var(--purple-300);
    padding: 2px 8px;
    border-radius: 3px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.72rem;
}
.crypto-bar .key-btn:hover {
    border-color: var(--holo-cyan);
    color: var(--holo-cyan);
}

/* Chat Messages Viewport */
.chat-viewport {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

.chat-viewport::-webkit-scrollbar {
    width: 6px;
}
.chat-viewport::-webkit-scrollbar-track {
    background: var(--bg-void);
}
.chat-viewport::-webkit-scrollbar-thumb {
    background: var(--purple-700);
    border-radius: 3px;
}
.chat-viewport::-webkit-scrollbar-thumb:hover {
    background: var(--purple-400);
}

/* Messages */
.msg-row {
    display: flex;
    flex-direction: column;
    max-width: 82%;
    word-break: break-word;
    animation: msgIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes msgIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.msg-row.incoming {
    align-self: flex-start;
}
.msg-row.outgoing {
    align-self: flex-end;
}

.msg-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 3px;
    font-size: 0.72rem;
    color: var(--text-dim);
}
.msg-row.outgoing .msg-header {
    justify-content: flex-end;
}

.msg-sender {
    font-weight: bold;
}
.msg-row.outgoing .msg-sender { color: var(--holo-cyan); }
.msg-row.incoming .msg-sender { color: var(--purple-300); }

.msg-bubble {
    padding: 10px 14px;
    border-radius: 6px;
    line-height: 1.45;
    font-size: 0.92rem;
    position: relative;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

.msg-row.outgoing .msg-bubble {
    background: linear-gradient(135deg, #1b2044, #121936);
    color: var(--text-bright);
    border: 1px solid rgba(0, 229, 255, 0.4);
    box-shadow: 0 0 15px rgba(0, 229, 255, 0.15);
}

.msg-row.incoming .msg-bubble {
    background: linear-gradient(135deg, #24143a, #1a0e2e);
    color: var(--purple-200);
    border: 1px solid var(--purple-700);
    box-shadow: 0 0 15px rgba(157, 78, 221, 0.15);
}

.msg-lock-icon {
    font-size: 0.7rem;
    opacity: 0.6;
    margin-left: 6px;
}

.system-notice {
    align-self: center;
    max-width: 90%;
    text-align: center;
    padding: 8px 16px;
    border-radius: 4px;
    background: rgba(13, 8, 32, 0.75);
    border: 1px dashed var(--purple-700);
    font-size: 0.78rem;
    color: var(--text-dim);
}
.system-notice.wipe-alert {
    border-color: var(--danger);
    color: var(--danger);
    background: rgba(255, 51, 102, 0.12);
    box-shadow: 0 0 15px rgba(255, 51, 102, 0.2);
}

/* Chat Input Bar */
.chat-input-bar {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: var(--bg-panel);
    border-top: 1px solid var(--purple-700);
    gap: 10px;
}

.chat-input {
    flex: 1;
    background: var(--bg-input);
    border: 1px solid var(--purple-700);
    color: var(--purple-200);
    padding: 12px 14px;
    font-family: inherit;
    font-size: 0.95rem;
    border-radius: 4px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.chat-input:focus {
    border-color: var(--holo-cyan);
    box-shadow: 0 0 10px rgba(0, 229, 255, 0.4);
}

.send-btn {
    padding: 12px 20px;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: bold;
    color: var(--holo-cyan);
    background: rgba(0, 229, 255, 0.08);
    border: 1px solid var(--holo-cyan);
    border-radius: 4px;
    cursor: pointer;
    transition: 0.2s;
    white-space: nowrap;
}
.send-btn:hover {
    background: var(--holo-cyan);
    color: var(--bg-void);
    box-shadow: 0 0 16px var(--holo-cyan);
}

/* Buttons and Links */
a.btn, button.btn {
    display: inline-block; cursor: pointer; text-decoration: none; font: inherit;
    color: var(--holo-cyan); background: transparent; border: 1px solid var(--holo-cyan);
    padding: 6px 14px; border-radius: 3px; transition: .2s;
}
a.btn:hover, button.btn:hover { background: var(--holo-cyan); color: var(--bg-void); box-shadow: 0 0 12px var(--holo-cyan); }
a.btn.danger, button.btn.danger { color: var(--danger); border-color: var(--danger); }
a.btn.danger:hover, button.btn.danger:hover { background: var(--danger); color: var(--bg-void); box-shadow: 0 0 12px var(--danger); }

/* HAL 9000 / Sorry Dave Screen */
.dave-container {
    position: relative;
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    height: 100dvh;
    padding: 24px;
    text-align: center;
    background: radial-gradient(circle at center, #1b0610 0%, #060206 80%);
}

.hal-eye-wrapper {
    position: relative;
    width: 140px;
    height: 140px;
    margin-bottom: 28px;
    border-radius: 50%;
    background: #111;
    border: 5px solid #2a2a2a;
    box-shadow: 0 0 30px rgba(255, 0, 40, 0.4), inset 0 0 20px #000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hal-eye {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: radial-gradient(circle at 45% 45%, #ffffff 0%, #ff1133 35%, #880011 70%, #220000 100%);
    box-shadow: 0 0 35px #ff0033, 0 0 60px rgba(255, 0, 50, 0.6);
    animation: halPulse 3s infinite ease-in-out;
}
@keyframes halPulse {
    0%, 100% { transform: scale(0.97); opacity: 0.9; }
    50% { transform: scale(1.03); opacity: 1; box-shadow: 0 0 45px #ff0044, 0 0 80px rgba(255, 0, 60, 0.8); }
}

.dave-title {
    font-size: clamp(1.4rem, 4vw, 2.2rem);
    color: #ff3355;
    letter-spacing: 0.08em;
    text-shadow: 0 0 15px rgba(255, 51, 85, 0.6);
    margin-bottom: 16px;
}

.dave-desc {
    max-width: 520px;
    color: #e0b0cc;
    line-height: 1.6;
    font-size: 1rem;
    margin-bottom: 24px;
}

.dave-queue-box {
    padding: 12px 24px;
    background: rgba(20, 5, 12, 0.8);
    border: 1px dashed #ff3355;
    border-radius: 4px;
    font-size: 0.85rem;
    color: #ff88aa;
    margin-bottom: 20px;
}

/* Modal */
.modal-overlay {
    position: fixed; inset: 0; z-index: 999;
    background: rgba(0,0,0,0.8);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal-overlay.active { display: flex; }

.modal-box {
    background: var(--bg-panel);
    border: 1px solid var(--purple-400);
    border-radius: 6px;
    padding: 24px;
    max-width: 480px;
    width: 100%;
    box-shadow: 0 0 30px rgba(157, 78, 221, 0.4);
}
.modal-box h3 {
    color: var(--holo-cyan);
    margin-bottom: 12px;
}
.modal-box p {
    color: var(--purple-200);
    font-size: 0.85rem;
    line-height: 1.5;
    margin-bottom: 16px;
}

/* Mobile Media Queries */
@media (max-width: 640px) {
    .app-header { padding: 8px 12px; }
    .brand-text h1 { font-size: 1rem; }
    .killswitch-bar { padding: 6px 12px; }
    .ks-timer { font-size: 0.95rem; }
    .chat-viewport { padding: 12px 10px; }
    .msg-row { max-width: 92%; }
    .chat-input-bar { padding: 8px 10px; }
    .send-btn { padding: 10px 14px; font-size: 0.85rem; }
    .purge-btn span { display: none; }
}
