:root {
    --bg-color: #050505;
    --text-primary: #00ff41; /* Classic matrix green */
    --text-dim: #008f11;
    --accent-color: #ff003c; /* Cyberpunk pink/red */
    --accent-blue: #00f0ff;
    --font-main: 'Share Tech Mono', monospace;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body, html {
    margin: 0;
    padding: 0;
    height: 100%;
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-main);
    overflow: hidden;
}

/* CRT Effects */
.scanlines {
    position: fixed;
    inset: 0;
    pointer-events: none;
    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;
    z-index: 100;
    opacity: 0.6;
}

.vignette {
    position: fixed;
    inset: 0;
    pointer-events: none;
    background: radial-gradient(circle, rgba(0,0,0,0) 60%, rgba(0,0,0,0.8) 100%);
    z-index: 99;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    position: relative;
    z-index: 1;
}

/* Header */
header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--text-dim);
    background: rgba(5, 5, 5, 0.9);
}

.brand {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 4px;
}

.glitch {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--accent-blue);
    text-shadow: 0 0 5px rgba(0, 240, 255, 0.5);
    letter-spacing: 2px;
    position: relative;
}

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

.system-status {
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-dim);
}

.blinking-dot {
    width: 8px;
    height: 8px;
    background-color: var(--text-primary);
    border-radius: 50%;
    animation: blink 1s infinite step-end;
    box-shadow: 0 0 8px var(--text-primary);
}

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

/* Navigation */
#episode-nav {
    display: flex;
    overflow-x: auto;
    padding: 8px;
    gap: 8px;
    border-bottom: 1px dashed var(--text-dim);
    scrollbar-width: none; /* Firefox */
}

#episode-nav::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
}

.ep-btn {
    background: transparent;
    border: 1px solid var(--text-dim);
    color: var(--text-dim);
    font-family: var(--font-main);
    padding: 6px 12px;
    font-size: 0.85rem;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
}

.ep-btn.active {
    background: var(--text-primary);
    color: var(--bg-color);
    border-color: var(--text-primary);
    box-shadow: 0 0 10px rgba(0, 255, 65, 0.4);
}

.ep-btn .status {
    margin-left: 6px;
    font-size: 0.7rem;
}

.ep-btn.active .status.live {
    color: var(--accent-color);
    font-weight: bold;
    animation: pulse 1.5s infinite;
}

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

/* Chat Area */
#chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    scroll-behavior: smooth;
}

/* Custom Scrollbar for Chat */
#chat-container::-webkit-scrollbar {
    width: 6px;
}
#chat-container::-webkit-scrollbar-track {
    background: #111;
}
#chat-container::-webkit-scrollbar-thumb {
    background: var(--text-dim);
}

#chat-messages {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-bottom: 20px;
}

.message {
    font-size: 0.95rem;
    line-height: 1.4;
    word-break: break-word;
    animation: fadeIn 0.2s ease-out forwards;
}

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

.msg-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
    font-size: 0.8rem;
    opacity: 0.8;
}

.msg-avatar {
    width: 16px;
    height: 16px;
    border-radius: 2px;
    filter: sepia(1) hue-rotate(80deg) saturate(400%); /* Make avatar match terminal theme */
}

.msg-user {
    color: var(--accent-blue);
    font-weight: bold;
}

.msg-user.self {
    color: var(--text-primary);
}

.msg-time {
    color: var(--text-dim);
}

.msg-content {
    padding-left: 12px;
    border-left: 2px solid var(--text-dim);
}

.message.system .msg-content {
    border-left: none;
    color: var(--accent-color);
    font-style: italic;
    padding-left: 0;
}

/* Input Area */
#input-container {
    padding: 12px 16px;
    background: rgba(5, 5, 5, 0.95);
    border-top: 1px solid var(--text-primary);
    box-shadow: 0 -5px 15px rgba(0, 255, 65, 0.05);
}

#chat-form {
    display: flex;
    gap: 8px;
    align-items: center;
}

.input-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.prompt {
    font-size: 0.75rem;
    color: var(--text-dim);
}

#chat-input {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 16px; /* Prevents iOS zoom */
    outline: none;
    width: 100%;
}

#chat-input::placeholder {
    color: rgba(0, 143, 17, 0.5);
}

#send-btn {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 8px;
    transition: color 0.2s, text-shadow 0.2s;
}

#send-btn:active {
    color: var(--accent-blue);
    text-shadow: 0 0 10px var(--accent-blue);
}