/* ==================== DESIGN TOKENS ==================== */
:root {
    --bg: #0a0e14;
    --bg-card: #111820;
    --bg-elevated: #1a2230;
    --bg-input: #0d1117;
    --bg-hover: #1e2a3a;
    --border: #1e2a3a;
    --border-hover: #2a3a50;
    --border-focus: #00d9ff;
    --text: #e0e0e0;
    --text-dim: #6b7b8d;
    --text-muted: #3a4a5a;
    --accent: #00d9ff;
    --accent-dim: rgba(0, 217, 255, 0.15);
    --green: #00ff88;
    --green-dim: rgba(0, 255, 136, 0.15);
    --orange: #ffbd2e;
    --orange-dim: rgba(255, 189, 46, 0.15);
    --red: #ff4757;
    --red-dim: rgba(255, 71, 87, 0.15);
    --purple: #b794f6;
    --purple-dim: rgba(183, 148, 246, 0.15);
    --font-mono: 'JetBrains Mono', monospace;
    --font-body: 'Inter', -apple-system, sans-serif;
    --radius: 8px;
    --radius-lg: 12px;
    --sidebar-w: 230px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: var(--font-body); background: var(--bg); color: var(--text); min-height: 100vh; overflow-x: hidden; }

/* ==================== BUBBLES (Abyss-style) ==================== */
.abyss-bubbles {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: 9999;
    transition: opacity 0.5s ease;
}
.app.active ~ .abyss-bubbles,
.abyss-bubbles.subtle {
    opacity: 0.3;
}
.abyss-bubble {
    position: absolute;
    bottom: -20px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%,
        rgba(0, 255, 136, 0.15),
        rgba(0, 217, 255, 0.08) 40%,
        rgba(0, 217, 255, 0.03) 70%,
        transparent 100%);
    border: 1px solid rgba(0, 255, 136, 0.12);
    animation: bubbleRise linear forwards;
    will-change: transform;
}
.abyss-bubble::after {
    content: '';
    position: absolute;
    top: 20%; left: 25%;
    width: 30%; height: 20%;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    transform: rotate(-30deg);
}
@keyframes bubbleRise {
    0% { transform: translateY(0) translateX(0) scale(1); opacity: 0; }
    5% { opacity: 1; }
    50% { transform: translateY(-50vh) translateX(var(--drift)) scale(var(--scale-end)); }
    90% { opacity: 0.6; }
    100% { transform: translateY(-105vh) translateX(var(--drift-end)) scale(var(--scale-end)); opacity: 0; }
}

/* ==================== LOGIN ==================== */
.login-screen {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh; background: radial-gradient(ellipse at center, #111820 0%, #0a0e14 70%);
    position: relative;
}
.login-box {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 40px 40px 28px; width: 400px; max-width: 90vw;
    text-align: center; position: relative; z-index: 1;
}
/* Pre-reserve the login icon's space so the SVG load doesn't shift layout —
   this is what caused the "bottom-up janky" feel as the squid logo popped in
   and pushed everything below it down. */
.login-icon {
    font-size: 3rem;
    margin-bottom: 0.2rem;
    line-height: 1;
    height: 150px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.login-icon img { display: inline-block; }
.login-box h1 { font-family: var(--font-mono); font-size: 1.1rem; color: var(--accent); margin-bottom: 4px; letter-spacing: 3px; }
.login-sub { color: var(--text-dim); font-size: 0.78rem; margin-bottom: 28px; }
.login-box input {
    width: 100%; padding: 12px 16px; background: var(--bg-input);
    border: 1px solid var(--border); border-radius: var(--radius);
    color: var(--text); font-family: var(--font-mono); font-size: 0.9rem;
    outline: none; margin-bottom: 12px;
}
.login-box input:focus { border-color: var(--border-focus); box-shadow: 0 0 0 2px var(--accent-dim); }
.login-box input::placeholder { color: var(--text-muted); font-family: var(--font-body); letter-spacing: 0; }
.login-box button {
    width: 100%; padding: 12px; background: var(--accent); color: var(--bg);
    border: none; border-radius: var(--radius); font-family: var(--font-mono);
    font-weight: 600; font-size: 0.85rem; cursor: pointer; letter-spacing: 1px;
    transition: opacity 0.2s; margin-bottom: 0;
}
.login-box button:hover { opacity: 0.85; }
.login-error { color: var(--red); font-size: 0.8rem; margin-top: 12px; display: none; }
.login-branding {
    margin-top: 20px; margin-bottom: 0;
    font-size: 0.6rem; color: var(--text-muted);
    font-family: var(--font-mono); letter-spacing: 1px;
}

/* ==================== APP LAYOUT ==================== */
.app { display: none; position: relative; z-index: 1; }
.app.active { display: flex; height: 100vh; overflow: hidden; }

/* ==================== SIDEBAR ==================== */
.sidebar {
    width: var(--sidebar-w); background: var(--bg-card); border-right: 1px solid var(--border);
    flex-shrink: 0; position: fixed; top: 0; left: 0; bottom: 0;
    overflow-y: auto; display: flex; flex-direction: column; z-index: 10;
}
.sidebar-logo {
    font-family: var(--font-mono); font-size: 0.9rem; color: var(--accent);
    padding: 18px 20px 16px; border-bottom: 1px solid var(--border);
    margin-bottom: 8px; display: flex; align-items: center; gap: 8px;
    flex-wrap: wrap; letter-spacing: 2px;
}
.logo-agent-icon { font-size: 1.4rem; display: flex; align-items: center; }
.logo-agent-icon img { width: 28px; height: 28px; object-fit: contain; }
.logo-sub { display: block; width: 100%; color: var(--text-muted); font-size: 0.6rem; letter-spacing: 1px; margin-top: 2px; }
.nav-section { color: var(--text-muted); font-size: 0.6rem; text-transform: uppercase; letter-spacing: 2px; padding: 14px 20px 4px; font-weight: 600; }
.nav-item {
    display: flex; align-items: center; gap: 10px; padding: 9px 20px;
    color: var(--text-dim); cursor: pointer; font-size: 0.82rem;
    transition: all 0.15s; border-left: 3px solid transparent;
}
.nav-item:hover { color: var(--text); background: var(--bg-hover); }
.nav-item.active { color: var(--accent); background: var(--accent-dim); border-left-color: var(--accent); }
.nav-icon { width: 20px; text-align: center; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.nav-icon svg { display: block; }
.sidebar-footer {
    margin-top: auto; padding: 12px 16px; border-top: 1px solid var(--border);
    display: flex; flex-direction: column; gap: 8px;
}
.session-info { display: flex; align-items: center; gap: 6px; font-size: 0.7rem; color: var(--text-muted); font-family: var(--font-mono); }
.session-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); box-shadow: 0 0 6px var(--green); flex-shrink: 0; }
.logout-btn {
    background: none; border: 1px solid var(--border); border-radius: var(--radius);
    color: var(--text-dim); font-size: 0.75rem; padding: 6px 12px; cursor: pointer;
    transition: all 0.15s; font-family: var(--font-body); display: flex; align-items: center; gap: 4px;
}
.logout-btn:hover { border-color: var(--red); color: var(--red); background: var(--red-dim); }

/* ==================== MAIN CONTENT ==================== */
.main-content { flex: 1; margin-left: var(--sidebar-w); padding: 24px; height: 100vh; max-width: 100%; overflow-x: hidden; overflow-y: auto; display: flex; flex-direction: column; }
.tab-panel { display: none; }
.tab-panel.active { display: block; flex: 1; overflow-y: auto; overflow-x: hidden; min-height: 0; }
#tab-chat.active { display: flex; flex-direction: column; overflow: hidden; }
.panel-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; flex-wrap: wrap; gap: 8px; flex-shrink: 0; }
.panel-header h2 { font-family: var(--font-mono); font-size: 1.05rem; color: var(--text); display: flex; align-items: center; gap: 8px; }
.panel-header h2 span { color: var(--accent); }
.panel-icon { display: flex; align-items: center; }
.panel-icon svg { display: block; }
.loading-msg { color: var(--text-dim); font-size: 0.85rem; padding: 40px 0; text-align: center; }

/* ==================== STAT CARDS ==================== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.stat-label { font-size: 0.68rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 8px; font-weight: 500; }
.stat-value { font-family: var(--font-mono); font-size: 1.5rem; font-weight: 700; line-height: 1.2; }
.stat-sub { font-size: 0.7rem; color: var(--text-dim); margin-top: 4px; }
.stat-value.cyan { color: var(--accent); }
.stat-value.green { color: var(--green); }
.stat-value.orange { color: var(--orange); }
.stat-value.red { color: var(--red); }
.stat-value.purple { color: var(--purple); }

/* ==================== CHAT ==================== */
.chat-container { display: flex; flex-direction: column; flex: 1; min-height: 0; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.chat-header { padding: 12px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; font-size: 0.85rem; flex-shrink: 0; }
.chat-status { display: flex; align-items: center; gap: 6px; }
.chat-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 6px var(--green); }
.chat-messages { flex: 1; overflow-y: auto; padding: 16px 16px 0; display: flex; flex-direction: column; gap: 12px; }
.chat-messages::after { content: ''; flex-shrink: 0; height: 48px; }
.chat-msg { display: flex; gap: 10px; align-items: flex-start; }
.chat-msg-avatar {
    width: 40px; height: 40px; border-radius: 10px; display: flex;
    align-items: center; justify-content: center; font-size: 1.2rem;
    flex-shrink: 0; background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.08);
}
.chat-msg-avatar img { border-radius: 8px; width: 100%; height: 100%; object-fit: cover; }
.chat-msg-content { flex: 1; min-width: 0; }
.chat-msg-name { font-weight: 600; font-size: 0.8rem; margin-bottom: 2px; }
.chat-msg-text { font-size: 0.85rem; line-height: 1.6; color: #c8d4e0; word-wrap: break-word; overflow: hidden; }
.chat-msg-time { font-size: 0.68rem; color: var(--text-muted); margin-top: 4px; }
.chat-msg.agent .chat-msg-name { color: var(--green); }
.chat-msg.agent .chat-msg-avatar { background: rgba(0,255,136,0.12); border-color: rgba(0,255,136,0.25); }
.chat-msg.human .chat-msg-name { color: var(--accent); }
.chat-msg.human .chat-msg-avatar { background: rgba(0,217,255,0.12); border-color: rgba(0,217,255,0.25); }
.chat-routing-step { padding: 6px 16px; }
.routing-indicator {
    display: inline-flex; align-items: center; gap: 8px;
    font-size: 0.78rem; color: var(--accent); font-family: var(--font-mono);
    padding: 6px 14px; border-radius: var(--radius);
    background: rgba(0,217,255,0.06); border: 1px solid rgba(0,217,255,0.12);
}
.routing-indicator svg { color: var(--accent); opacity: 0.7; }
.routing-indicator strong { color: var(--text); }
.routing-step-count { color: var(--text-muted); font-size: 0.7rem; margin-left: 4px; }

/* Sub-Agent Conversation Thread */
.sa-activation { padding: 10px 16px; }
.sa-activation-header {
    display: flex; align-items: center; gap: 8px;
    font-size: 0.82rem; color: var(--accent); font-family: var(--font-mono); font-weight: 600;
    margin-bottom: 8px;
}
.sa-activation-header svg { color: var(--accent); }
.sa-chain {
    display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
    font-size: 0.75rem; font-family: var(--font-mono);
}
.sa-chain-module {
    padding: 4px 10px; border-radius: var(--radius);
    background: rgba(0,217,255,0.06); border: 1px solid rgba(0,217,255,0.12);
    color: var(--text);
}
.sa-chain-arrow { color: var(--text-muted); font-size: 0.7rem; }

.sa-description {
    padding: 2px 16px 8px; font-size: 0.75rem; color: var(--text-muted);
    font-style: italic; font-family: var(--font-body);
}

.sa-parallel-header {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    padding: 8px 16px; font-size: 0.75rem; font-family: var(--font-mono);
    color: var(--text-muted);
}
.sa-parallel-badge {
    padding: 2px 8px; border-radius: 4px; font-size: 0.68rem; font-weight: 700;
    background: rgba(255,189,46,0.12); color: #FFBD2E; border: 1px solid rgba(255,189,46,0.25);
    letter-spacing: 0.5px;
}
.sa-parallel-icons { font-size: 1rem; }

.sa-step {
    display: flex; align-items: center; gap: 8px;
    padding: 4px 16px; font-family: var(--font-mono); font-size: 0.78rem;
}
.sa-connector { color: var(--border); font-size: 1rem; width: 14px; text-align: center; }
.sa-step-icon { font-size: 1rem; }
.sa-step-name { color: var(--accent); font-weight: 600; }
.sa-step-count { color: var(--text-muted); font-size: 0.68rem; }

.sa-thinking {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 16px; font-family: var(--font-mono); font-size: 0.75rem;
}
.sa-thinking-icon { font-size: 0.9rem; }
.sa-thinking-dots { display: inline-flex; gap: 3px; }
.sa-thinking-dots span {
    width: 5px; height: 5px; border-radius: 50%; background: var(--accent); opacity: 0.4;
    animation: typingBounce 1.2s infinite;
}
.sa-thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.sa-thinking-dots span:nth-child(3) { animation-delay: 0.4s; }
.sa-thinking-label { color: var(--text-muted); }

.sa-msg .sa-avatar {
    background: rgba(0,217,255,0.08); border-color: rgba(0,217,255,0.15);
    font-size: 1rem; display: flex; align-items: center; justify-content: center;
}
.sa-msg .sa-name { color: var(--accent); font-family: var(--font-mono); font-size: 0.75rem; }

.sa-complete {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 16px; font-size: 0.78rem; font-family: var(--font-mono);
    color: var(--green);
}
.sa-complete svg { color: var(--green); }

/* Markdown rendered content inside chat messages */
.chat-msg-text h1 { font-size: 1.2rem; font-weight: 700; margin: 16px 0 8px; color: var(--text); }
.chat-msg-text h2 { font-size: 1.1rem; font-weight: 700; margin: 14px 0 6px; color: var(--text); }
.chat-msg-text h3 { font-size: 1rem; font-weight: 600; margin: 12px 0 4px; color: var(--text); }
.chat-msg-text h4 { font-size: 0.9rem; font-weight: 600; margin: 10px 0 4px; color: var(--text); }
.chat-msg-text p { margin: 0 0 8px; line-height: 1.5; }
.chat-msg-text ul, .chat-msg-text ol { margin: 4px 0 8px 20px; padding: 0; }
.chat-msg-text li { margin-bottom: 3px; line-height: 1.5; }
.chat-msg-text blockquote {
    border-left: 3px solid var(--accent); padding: 6px 12px; margin: 8px 0;
    background: rgba(0,217,255,0.04); border-radius: 0 4px 4px 0; color: var(--text-muted);
}
.chat-msg-text table { border-collapse: collapse; margin: 8px 0; width: 100%; font-size: 0.82rem; }
.chat-msg-text th { background: var(--bg-elevated); padding: 6px 10px; text-align: left; border: 1px solid var(--border); font-weight: 600; }
.chat-msg-text td { padding: 6px 10px; border: 1px solid var(--border); }
.chat-msg-text hr { border: none; border-top: 1px solid var(--border); margin: 12px 0; }
.chat-msg-text a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.chat-msg-text a:hover { opacity: 0.85; }
.chat-msg-text code { background: var(--bg-elevated); padding: 1px 5px; border-radius: 3px; font-family: var(--font-mono); font-size: 0.8rem; }
.chat-msg-text img { max-width: 100%; border-radius: 6px; margin: 8px 0; }
.chat-msg-text strong { color: var(--text); }
.chat-input-bar { display: flex; gap: 10px; padding: 14px 16px; border-top: 1px solid var(--border); background: rgba(0,0,0,0.25); align-items: center; flex-shrink: 0; }
.chat-input {
    flex: 1; background: var(--bg-input); border: 1px solid var(--border);
    border-radius: 10px; padding: 11px 16px; color: var(--text);
    font-size: 0.85rem; font-family: inherit; outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.chat-input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(0,217,255,0.1); }
.chat-input::placeholder { color: var(--text-muted); }
.chat-send {
    width: 42px; height: 42px; border-radius: 10px; border: none;
    background: linear-gradient(135deg, #00d9ff, #00a8cc); color: #000;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: opacity 0.15s, transform 0.1s; flex-shrink: 0;
}
.chat-send:hover { opacity: 0.85; transform: scale(1.03); }
.chat-send:active { transform: scale(0.97); }
.chat-send:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.chat-send svg { display: block; }
.chat-attach {
    width: 42px; height: 42px; border-radius: 10px; border: 1px solid var(--border);
    background: transparent; color: var(--text-muted); cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: border-color 0.15s, color 0.15s; flex-shrink: 0;
}
.chat-attach:hover { border-color: var(--accent); color: var(--accent); }
.chat-attach svg { display: block; }
.chat-attach-preview {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 16px; background: rgba(0,217,255,0.06);
    border-top: 1px solid var(--border); font-size: 0.78rem;
}
.attach-file-info { display: flex; align-items: center; gap: 8px; color: var(--text-dim); min-width: 0; }
.attach-file-name { color: var(--accent); font-family: var(--font-mono); font-size: 0.75rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-file-size { color: var(--text-muted); font-size: 0.7rem; flex-shrink: 0; }
.attach-remove {
    background: none; border: none; color: var(--text-muted); cursor: pointer;
    font-size: 0.85rem; padding: 2px 6px; border-radius: 4px;
    transition: color 0.15s, background 0.15s;
}
.attach-remove:hover { color: var(--red, #ff4757); background: rgba(255,71,87,0.1); }
.typing-indicator { display: none; padding: 8px 16px; font-size: 0.78rem; color: var(--text-muted); flex-shrink: 0; }
.typing-indicator.visible { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.typing-dots { display: flex; gap: 3px; }
.typing-dots span { width: 5px; height: 5px; border-radius: 50%; background: var(--green); opacity: 0.4; animation: typing 1.4s infinite; }
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing { 0%, 60%, 100% { opacity: 0.2; transform: scale(0.8); } 30% { opacity: 1; transform: scale(1.1); } }

/* Typewriter cursor */
.typewriter-cursor {
    display: inline-block;
    width: 2px; height: 1em;
    background: var(--green);
    margin-left: 1px;
    vertical-align: text-bottom;
    animation: blink 0.7s step-end infinite;
}
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

/* Scan pulse animation */
.scan-pulse { display: inline-block; animation: scanPulse 1.5s ease-in-out infinite; }
@keyframes scanPulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.08); opacity: 0.7; }
}

/* Code blocks in chat */
.chat-code-block {
    position: relative; background: var(--bg-input); border: 1px solid var(--border);
    border-radius: var(--radius); margin: 8px 0;
    max-width: 100%;
}
.chat-code-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 6px 10px; background: var(--bg-elevated); border-bottom: 1px solid var(--border);
    font-size: 0.7rem; color: var(--text-dim); font-family: var(--font-mono);
}
.chat-code-actions { display: flex; gap: 4px; }
.chat-code-actions button {
    padding: 2px 8px; font-size: 0.65rem; background: var(--bg-card);
    border: 1px solid var(--border); border-radius: 4px; color: var(--text-dim);
    cursor: pointer; font-family: var(--font-body); transition: all 0.15s;
}
.chat-code-actions button:hover { border-color: var(--accent); color: var(--accent); }
.btn-code-edit {
    display: flex; align-items: center; gap: 4px;
    padding: 2px 8px; font-size: 0.65rem; background: var(--bg-card);
    border: 1px solid var(--border); border-radius: 4px; color: var(--text-dim);
    cursor: pointer; font-family: var(--font-body); transition: all 0.15s;
}
.btn-code-edit:hover { border-color: var(--accent); color: var(--accent); }
.chat-code-body { padding: 10px 12px; font-family: var(--font-mono); font-size: 0.78rem; line-height: 1.5; overflow-x: auto; white-space: pre; color: var(--text); }

/* Action bar (Preview / Download / Scan) */
.chat-action-bar {
    display: flex; gap: 6px; margin-top: 10px; padding-top: 10px;
    border-top: 1px solid var(--border); flex-wrap: wrap; align-items: center;
}
.chat-action-bar .btn { font-size: 0.72rem; padding: 4px 10px; }

/* Danger zone */
.btn-danger { background: rgba(255,71,87,0.1); color: #ff4757; border-color: rgba(255,71,87,0.3); }
.btn-danger:hover { background: #ff4757; color: #fff; }
.danger-card { border-color: rgba(255,71,87,0.3) !important; background: rgba(255,71,87,0.03) !important; }
.danger-row { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border: 1px solid rgba(255,71,87,0.2); border-radius: var(--radius); background: var(--bg-card); }
.danger-modal { margin-top: 16px; padding: 16px; border: 2px solid #ff4757; border-radius: var(--radius); background: var(--bg-card); }

/* ==================== TABLES ==================== */
.table-wrap { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { background: var(--bg-elevated); color: var(--text-dim); font-size: 0.68rem; text-transform: uppercase; letter-spacing: 1px; padding: 10px 14px; text-align: left; font-weight: 600; white-space: nowrap; }
.data-table td { padding: 10px 14px; font-size: 0.82rem; border-top: 1px solid var(--border); vertical-align: middle; }
.data-table tr:hover td { background: rgba(0,217,255,0.03); }

/* ==================== BUTTONS ==================== */
.btn { padding: 7px 14px; background: var(--bg-elevated); color: var(--text-dim); border: 1px solid var(--border); border-radius: var(--radius); font-size: 0.8rem; cursor: pointer; transition: all 0.15s; font-family: var(--font-body); white-space: nowrap; display: inline-flex; align-items: center; gap: 4px; }
.btn:hover { border-color: var(--border-hover); color: var(--text); background: var(--bg-hover); }
.btn-sm { padding: 5px 10px; font-size: 0.75rem; }
.btn-primary { background: var(--accent); color: var(--bg); border-color: var(--accent); font-weight: 600; }
.btn-primary:hover { opacity: 0.85; color: var(--bg); }

/* ==================== BADGES ==================== */
.badge { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 0.68rem; font-weight: 600; white-space: nowrap; }
.badge-green { background: var(--green-dim); color: var(--green); }
.badge-red { background: var(--red-dim); color: var(--red); }
.badge-orange { background: var(--orange-dim); color: var(--orange); }
.badge-cyan { background: var(--accent-dim); color: var(--accent); }

/* ==================== SETTINGS ==================== */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.setting-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; }
.setting-card h3 { font-family: var(--font-mono); font-size: 0.85rem; margin-bottom: 12px; color: var(--text); display: flex; align-items: center; gap: 8px; }
.setting-card h3 svg { flex-shrink: 0; }
.setting-row { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; font-size: 0.8rem; }
.setting-label { color: var(--text-dim); }
.setting-value { font-family: var(--font-mono); font-size: 0.78rem; }
.setting-value.on { color: var(--green); }
.setting-value.off { color: var(--text-muted); }
.icon-input-row { display: flex; gap: 8px; margin-top: 8px; align-items: center; }
.icon-input-row input {
    flex: 1; padding: 6px 10px; background: var(--bg-input); border: 1px solid var(--border);
    border-radius: var(--radius); color: var(--text); font-size: 0.8rem; outline: none;
}
.icon-input-row input:focus { border-color: var(--accent); }
.icon-preview { font-size: 2rem; width: 48px; height: 48px; display: flex; align-items: center; justify-content: center; }
.icon-preview img { width: 48px; height: 48px; border-radius: 8px; object-fit: cover; }

/* ==================== STATUS BOARD ==================== */
.status-board { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; margin-bottom: 16px; }
.status-summary { margin-bottom: 16px; }
.status-summary-text { display: flex; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.status-summary-count { font-family: var(--font-mono); font-size: 1.4rem; font-weight: 700; }
.status-summary-label { font-size: 0.78rem; color: var(--text-dim); }
.status-bar-track { width: 100%; height: 4px; background: var(--bg-hover); border-radius: 2px; overflow: hidden; }
.status-bar-fill { height: 100%; border-radius: 2px; transition: width 0.6s ease; }
.status-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.status-group { background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; }
.status-group.all-ok { border-color: rgba(0,255,136,0.15); }
.status-group-header { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.status-group-icon { display: flex; align-items: center; flex-shrink: 0; }
.status-group-name { font-family: var(--font-mono); font-size: 0.72rem; color: var(--text-dim); letter-spacing: 0.5px; text-transform: uppercase; flex: 1; }
.status-group-count { font-family: var(--font-mono); font-size: 0.68rem; color: var(--text-muted); }
.status-group-count.ok { color: var(--green); }
.status-group-items { display: flex; flex-direction: column; gap: 4px; }
.status-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 0; font-size: 0.78rem; }
.status-item-left { display: flex; align-items: center; gap: 6px; min-width: 0; flex: 1; overflow: hidden; }
.status-item-right { display: flex; align-items: center; gap: 6px; flex-shrink: 1; min-width: 0; }
.status-item-label { color: var(--text); font-size: 0.78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status-item-detail { font-family: var(--font-mono); font-size: 0.68rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 120px; }
.status-item-detail.unconfigured { color: var(--text-muted); }
.status-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.status-dot.green { background: var(--green); box-shadow: 0 0 4px rgba(0,255,136,0.4); }
.status-dot.red { background: var(--red); box-shadow: 0 0 4px rgba(255,71,87,0.4); }
.btn-setup { font-family: var(--font-body); font-size: 0.65rem; padding: 2px 8px; background: var(--accent-dim); color: var(--accent); border: 1px solid rgba(0,217,255,0.2); border-radius: 4px; cursor: pointer; transition: all 0.15s; white-space: nowrap; }
.btn-setup:hover { background: rgba(0,217,255,0.25); border-color: var(--accent); }
@media (max-width: 768px) {
    .status-groups { grid-template-columns: 1fr; }
    .status-item-detail { max-width: 100px; }
}

/* ==================== PLUGIN PANELS ==================== */
.plugin-panels-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.plugin-panel { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.plugin-panel-header { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.plugin-panel-icon { display: flex; align-items: center; flex-shrink: 0; color: var(--accent); }
.plugin-panel-title { font-family: var(--font-mono); font-size: 0.78rem; color: var(--text); flex: 1; }
.plugin-panel-refresh { background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 2px; border-radius: 4px; display: flex; align-items: center; transition: color 0.15s; }
.plugin-panel-refresh:hover { color: var(--accent); }
@media (max-width: 768px) {
    .plugin-panels-grid { grid-template-columns: 1fr; }
}

/* ==================== MOBILE BOTTOM NAV ==================== */
.mobile-nav { display: none; }
.mobile-more-menu { display: none; }

@media (max-width: 768px) {
    .mobile-nav {
        display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 1000;
        background: var(--bg-card); border-top: 1px solid var(--border);
        padding: 4px 0 max(4px, env(safe-area-inset-bottom));
        justify-content: space-around; align-items: center;
    }
    .mobile-nav-item {
        display: flex; flex-direction: column; align-items: center; gap: 2px;
        padding: 6px 12px; color: var(--text-muted); font-size: 0.6rem;
        font-family: var(--font-body); cursor: pointer; transition: color 0.15s;
        -webkit-tap-highlight-color: transparent;
    }
    .mobile-nav-item.active { color: var(--accent); }
    .mobile-nav-item svg { width: 20px; height: 20px; }

    /* More overflow menu */
    .mobile-more-menu {
        position: fixed; bottom: calc(56px + env(safe-area-inset-bottom)); right: 8px; z-index: 999;
        background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg);
        padding: 6px 0; min-width: 160px; box-shadow: 0 -4px 20px rgba(0,0,0,0.4);
    }
    .mobile-more-menu.open { display: block; }
    .mobile-more-item {
        padding: 10px 16px; font-size: 0.82rem; color: var(--text-dim);
        font-family: var(--font-body); cursor: pointer; transition: all 0.1s;
        -webkit-tap-highlight-color: transparent;
    }
    .mobile-more-item:hover, .mobile-more-item:active { background: var(--bg-hover); color: var(--text); }
    .mobile-more-item.active { color: var(--accent); }

    /* Adjust main content to account for bottom nav height */
    .main-content { padding-bottom: calc(60px + env(safe-area-inset-bottom)) !important; }
    /* chat-input-bar does NOT need margin-bottom — #tab-chat height already subtracts 56px for the nav */
    .chat-input-bar { padding-bottom: 8px; }
}

/* PWA standalone — bottom nav needs safe area for home indicator */
@media (display-mode: standalone) and (max-width: 768px) {
    .mobile-nav { padding-bottom: max(8px, env(safe-area-inset-bottom)); }
    /* chat-input-bar margin already accounts for safe-area via the mobile nav rule above — no extra padding needed */
}

/* ==================== LANDSCAPE LOCK (MOBILE) ==================== */
/* iOS ignores manifest "orientation" field. This is the only way to enforce portrait. */
/* Shows a rotate-your-phone overlay when mobile device is in landscape. */
/* `pointer: coarse` ensures this only fires on touchscreens — a desktop browser */
/* with DevTools open narrows the viewport below 932px but still has `pointer: fine`, */
/* so the overlay correctly stays hidden. */
.landscape-lock { display: none; }
@media (max-width: 932px) and (orientation: landscape) and (pointer: coarse) {
    .landscape-lock {
        display: flex; position: fixed; inset: 0; z-index: 10000;
        background: var(--bg); color: var(--text-dim);
        flex-direction: column; align-items: center; justify-content: center; gap: 16px;
        font-family: var(--font-body); text-align: center; padding: 20px;
    }
    .landscape-lock svg { opacity: 0.5; }
    .landscape-lock p { font-size: 0.9rem; max-width: 300px; }
    .landscape-lock span { font-size: 0.7rem; color: var(--text-muted); }
}

/* ==================== SCROLLBARS ==================== */
.chat-messages::-webkit-scrollbar,
.main-content::-webkit-scrollbar { width: 6px; }
.chat-messages::-webkit-scrollbar-track,
.main-content::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb,
.main-content::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 3px; }
.chat-messages::-webkit-scrollbar-thumb:hover,
.main-content::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.15); }

/* ==================== RESPONSIVE ==================== */
@media (max-width: 768px) {
    .sidebar { display: none; }
    .app.active { height: 100dvh; }
    .main-content { margin-left: 0; padding: 12px; height: 100dvh; overflow-y: auto; }
    #tab-chat.active { height: calc(100dvh - 24px - 56px - env(safe-area-inset-bottom)); } /* 12px padding top + bottom + mobile nav */
    .chat-container { border-radius: var(--radius); }
    .chat-messages { overflow-x: hidden; }
    .chat-msg pre { max-width: calc(100vw - 80px); overflow-x: auto; }
    .chat-msg table { display: block; overflow-x: auto; max-width: calc(100vw - 80px); }
    .panel-header { flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
    .panel-header h2 { font-size: 1rem; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .settings-grid { grid-template-columns: 1fr; }
    /* Fix nested scroll trap — let main-content scroll, not the tab-panel */
    /* Chat is exempt — it has its own flex scroll container */
    .tab-panel.active:not(#tab-chat) { overflow-y: visible; }
    .status-board { overflow-x: hidden; }
    /* iOS zoom prevention — inputs below 16px trigger auto-zoom */
    .chat-input, input, textarea, select { font-size: 16px !important; }
}

/* ==================== MOBILE CODE BLOCK ALIGNMENT ==================== */
/* Code blocks stay inside chat-msg-content (no negative margin hack). */
/* The code BODY scrolls horizontally. The block itself fits the parent. */
@media (max-width: 768px) {
    /* Let code blocks be visible — parent overflow:hidden clips them */
    .chat-msg-text {
        overflow: visible;
    }
    /* Code blocks fill their parent width, no escape attempt */
    .chat-code-block {
        margin-left: 0;
        margin-right: 0;
        width: 100%;
        max-width: 100%;
        border-radius: 6px;
        overflow: hidden; /* contain the code body within the block border */
    }
    /* The code body scrolls horizontally for long lines */
    .chat-code-body {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        max-width: 100%;
        padding: 10px 12px;
        white-space: pre;
        font-size: 0.72rem;
    }
    .chat-code-header {
        font-size: 0.65rem;
        padding: 5px 8px;
    }
    .chat-code-header span {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        max-width: 60%;
    }
    /* Action bar stays in flow */
    .chat-action-bar {
        margin-left: 0;
        width: 100%;
        max-width: 100%;
    }
    /* Inline code in text — break long strings */
    .chat-msg-text code {
        word-break: break-all;
        font-size: 0.75rem;
    }
    /* Markdown pre blocks (not inside chat-code-block) */
    .chat-msg-text pre {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        max-width: 100%;
        font-size: 0.72rem;
    }
}

/* ==================== PWA STANDALONE ==================== */
/* Rules 7-8: Safe-area insets and overscroll ONLY in standalone mode */
@media (display-mode: standalone) {
    .app.active { height: 100dvh; }
    .main-content { height: 100dvh; }
    /* Rule 8: overscroll-behavior on both html and body — Bug 197659 */
    html, body { overscroll-behavior-y: contain; }
    /* Prevent pinch zoom in PWA — testing checklist item */
    html { touch-action: pan-x pan-y; }
    /* Safe area insets for notch/home indicator — Rule 7 */
    /* Top: main-content handles status bar area */
    /* Bottom: each tab's bottom element handles home indicator (chat-input-bar, etc.) */
    /* NOT on main-content — double-dip with chat-input-bar caused visible gap */
    .main-content { padding-top: max(12px, env(safe-area-inset-top)); }
    .sidebar { padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom); }
    /* chat-input-bar safe area handled by mobile nav margin — no standalone override needed */
}

/* PWA standalone + landscape — side notch safe areas */
@media (display-mode: standalone) and (orientation: landscape) {
    .main-content { padding-left: max(8px, env(safe-area-inset-left)); padding-right: max(8px, env(safe-area-inset-right)); }
}
/* ─── Onboarding / Setup Additions ───────────────────── */

.setup-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 30px 0;
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid rgba(0, 217, 255, 0.15);
    border-top-color: var(--accent, #00d9ff);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.cred-box {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(0, 217, 255, 0.15);
    border-radius: 8px;
    padding: 14px;
    text-align: left;
}

.cred-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.cred-label {
    font-family: var(--font-mono, 'JetBrains Mono', monospace);
    font-size: 0.68rem;
    color: #2ed573;
    font-weight: 600;
}

.cred-copy {
    background: none;
    border: 1px solid rgba(0, 217, 255, 0.3);
    color: var(--accent, #00d9ff);
    font-size: 0.65rem;
    padding: 2px 8px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.cred-copy:hover {
    background: rgba(0, 217, 255, 0.1);
    border-color: var(--accent, #00d9ff);
}

.cred-value {
    font-family: var(--font-mono, 'JetBrains Mono', monospace);
    font-size: 0.66rem;
    color: var(--text, #e8e8e8);
    word-break: break-all;
    background: rgba(0, 0, 0, 0.4);
    padding: 5px 8px;
    border-radius: 4px;
    margin-top: 4px;
    user-select: all;
}

.login-error {
    display: none;
    color: #ff4757;
    font-size: 0.75rem;
    margin-top: 4px;
    min-height: 18px;
}

/* ─── Toggle Switch ─────────────────────────────── */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--border, rgba(255,255,255,0.08));
    border-radius: 22px;
    transition: all 0.25s ease;
}

.toggle-slider:before {
    content: "";
    position: absolute;
    height: 16px;
    width: 16px;
    left: 2px;
    bottom: 2px;
    background: var(--text-muted, #666);
    border-radius: 50%;
    transition: all 0.25s ease;
}

.toggle-switch input:checked + .toggle-slider {
    background: rgba(0, 217, 255, 0.2);
    border-color: var(--accent, #00d9ff);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(18px);
    background: var(--accent, #00d9ff);
}
/* ─── Service Health Rows ───────────────────────── */
.service-health-grid {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sh-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 6px;
    text-decoration: none;
    color: inherit;
    transition: background 0.15s;
}

.sh-row:hover {
    background: rgba(255, 255, 255, 0.04);
}

.sh-name {
    flex: 1;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text, #e8e8e8);
}

.sh-label {
    font-size: 0.75rem;
    min-width: 80px;
    text-align: right;
    font-family: var(--font-mono, 'JetBrains Mono', monospace);
}

/* ─── Feedback (thumbs up/down) ─── */
.chat-feedback {
    display: flex;
    gap: 4px;
    margin-top: 4px;
    opacity: 0.3;
    transition: opacity 0.2s;
}
.chat-msg:hover .chat-feedback,
.chat-feedback:focus-within {
    opacity: 1;
}
@media (max-width: 768px) {
    .chat-feedback { opacity: 0.5; }
}
.feedback-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    color: var(--text-muted, #888);
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s, background 0.15s;
}
.feedback-btn:hover {
    color: var(--text, #e8e8e8);
    background: rgba(255, 255, 255, 0.05);
}
.feedback-btn.voted-up { color: var(--green, #4ade80); }
.feedback-btn.voted-down { color: var(--accent, #00d9ff); }
.feedback-input {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    padding: 8px;
    background: rgba(0, 217, 255, 0.03);
    border: 1px solid var(--border, #333);
    border-radius: 8px;
    animation: feedbackSlideIn 0.2s ease-out;
}
@keyframes feedbackSlideIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}
.feedback-input input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text, #e8e8e8);
    font-size: 0.85rem;
    outline: none;
    font-family: inherit;
}
.feedback-input input::placeholder {
    color: var(--text-muted, #888);
}
.feedback-submit {
    background: var(--accent, #00d9ff);
    color: var(--bg, #0a0a0f);
    border: none;
    border-radius: 4px;
    padding: 4px 12px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    transition: opacity 0.15s;
}
.feedback-submit:hover { opacity: 0.85; }
.feedback-submit:disabled { opacity: 0.5; cursor: default; }
.feedback-ack {
    font-size: 0.82rem;
    color: var(--text-muted, #888);
    font-style: italic;
    transition: opacity 0.3s;
}

/* ════════════════════════════════════════════════════════════════════
   SURGE MODE — Visual language matching the marketing page.
   Used by Power Tools card, chat container, chat header, and the
   Surge activation viewport (the team grid).
   ════════════════════════════════════════════════════════════════════ */

@property --squid-surge-angle {
    syntax: '<angle>';
    inherits: false;
    initial-value: 0deg;
}

/* Blue runner — Sub-Agent Mode visual. Same shape and tempo as the gold
   runner; cyan palette so the user can tell the two modes apart at a glance.
   Applied to the outer Power Tools card when sub_agents_enabled is true,
   and to the chat container when sub-agent is on and surge is off (when
   surge is on, the gold .surge-glow takes over). */
.sub-glow {
    position: relative;
    border: 1px solid rgba(0, 217, 255, 0.3);
    box-shadow: 0 0 0 1px rgba(0, 217, 255, 0.06), 0 0 36px rgba(0, 217, 255, 0.06);
}
.sub-glow::after {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: inherit;
    padding: 2px;
    background: conic-gradient(
        from var(--squid-surge-angle),
        transparent 0deg,
        transparent 320deg,
        rgba(0, 217, 255, 0.55) 340deg,
        #B0F0FF 355deg,
        rgba(0, 217, 255, 0.55) 370deg,
        transparent 390deg
    );
    -webkit-mask:
        linear-gradient(#fff 0 0) content-box,
        linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
            mask-composite: exclude;
    pointer-events: none;
    animation: squid-surge-electrify 4s linear infinite;
    z-index: 0;
    filter: drop-shadow(0 0 4px rgba(0, 217, 255, 0.6))
            drop-shadow(0 0 10px rgba(0, 217, 255, 0.35));
}
.chat-container.sub-glow::after {
    inset: 0;
    padding: 1.5px;
}

/* Gold runner border — bright dot of light tracing the perimeter */
.surge-glow {
    position: relative;
    border: 1px solid rgba(244, 196, 48, 0.35);
    box-shadow: 0 0 0 1px rgba(244, 196, 48, 0.08), 0 0 40px rgba(244, 196, 48, 0.08);
}
.surge-glow::after {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: inherit;
    padding: 2px;
    background: conic-gradient(
        from var(--squid-surge-angle),
        transparent 0deg,
        transparent 320deg,
        rgba(244, 196, 48, 0.6) 340deg,
        #FFEC8B 355deg,
        rgba(244, 196, 48, 0.6) 370deg,
        transparent 390deg
    );
    -webkit-mask:
        linear-gradient(#fff 0 0) content-box,
        linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
            mask-composite: exclude;
    pointer-events: none;
    animation: squid-surge-electrify 4s linear infinite;
    z-index: 0;
    filter: drop-shadow(0 0 4px rgba(244, 196, 48, 0.7))
            drop-shadow(0 0 10px rgba(244, 196, 48, 0.4));
}
@keyframes squid-surge-electrify {
    to { --squid-surge-angle: 360deg; }
}

/* Chat container variant — flush against the existing border so the
   runner doesn't clip on overflow:hidden. */
.chat-container.surge-glow::after {
    inset: 0;
    padding: 1.5px;
}

/* Inner Surge sub-module on the Settings card — when surge_enabled flips
   true, this inner block runs the fast/bright "loading" pulse for ~1.4s
   to signal the agent is powering up. The OUTER Power Tools card keeps
   the normal-tempo runner the whole time. */
.surge-inner {
    position: relative;
}
.surge-inner.surge-loading {
    box-shadow: 0 0 0 1px rgba(244, 196, 48, 0.5), 0 0 60px rgba(244, 196, 48, 0.35);
    transition: box-shadow 0.3s ease;
}
.surge-inner.surge-loading::after {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: inherit;
    padding: 2px;
    background: conic-gradient(
        from var(--squid-surge-angle),
        transparent 0deg,
        transparent 310deg,
        #FFEC8B 345deg,
        #FFFFFF 355deg,
        #FFEC8B 365deg,
        transparent 400deg
    );
    -webkit-mask:
        linear-gradient(#fff 0 0) content-box,
        linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
            mask-composite: exclude;
    pointer-events: none;
    animation: squid-surge-electrify 0.7s linear infinite;
    z-index: 1;
    filter: drop-shadow(0 0 8px rgba(244, 196, 48, 1))
            drop-shadow(0 0 18px rgba(244, 196, 48, 0.7))
            drop-shadow(0 0 32px rgba(244, 196, 48, 0.4));
}

/* SURGE MODE gold pill — header marker, mirrors the marketing page tag */
.surge-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-mono, monospace);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.5px;
    color: var(--yellow, #F4C430);
    background: rgba(244, 196, 48, 0.1);
    border: 1px solid rgba(244, 196, 48, 0.4);
    border-radius: 999px;
    padding: 4px 10px;
    margin-left: 8px;
    box-shadow: 0 0 12px rgba(244, 196, 48, 0.25);
}
.surge-pill-bolt {
    font-size: 13px;
    line-height: 1;
    margin-top: -1px;
    letter-spacing: 0;
}

/* SUB-AGENT MODE blue pill — same shape, blue palette. Shows when
   sub_agents_enabled is true and surge_enabled is false. When surge
   flips on, this pill is replaced by the gold surge pill. */
.subagent-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-mono, monospace);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.5px;
    color: var(--accent, #00d9ff);
    background: rgba(0, 217, 255, 0.08);
    border: 1px solid rgba(0, 217, 255, 0.4);
    border-radius: 999px;
    padding: 4px 10px;
    margin-left: 8px;
    box-shadow: 0 0 10px rgba(0, 217, 255, 0.2);
}

/* Header bolt — gold lightning anchor next to the agent name in chat */
.surge-header-bolt {
    width: 22px;
    height: 32px;
    color: var(--yellow, #F4C430);
    filter: drop-shadow(0 0 8px rgba(244, 196, 48, 0.6))
            drop-shadow(0 0 16px rgba(244, 196, 48, 0.35));
    transform: rotate(-6deg);
    animation: squid-bolt-pulse 4s ease-in-out infinite;
    flex-shrink: 0;
}
@keyframes squid-bolt-pulse {
    0%, 100% {
        opacity: 0.85;
        filter: drop-shadow(0 0 8px rgba(244, 196, 48, 0.5))
                drop-shadow(0 0 16px rgba(244, 196, 48, 0.3));
    }
    50% {
        opacity: 1;
        filter: drop-shadow(0 0 12px rgba(244, 196, 48, 0.85))
                drop-shadow(0 0 24px rgba(244, 196, 48, 0.5));
    }
}

/* ════════════════════════════════════════════════════════════════════
   SURGE ACTIVATION — Team grid rendered in the viewport panel when
   the user flips Surge on in Settings. Shows ops-center as the
   controller (full-width "boss" card up top), the other 10 specialists
   in a responsive grid below, and a soft compliance footer reminding
   the user that Surge spends more tokens.
   ════════════════════════════════════════════════════════════════════ */

.surge-activation {
    padding: 24px 22px 28px;
    color: var(--text);
    font-family: var(--font-body);
    height: 100%;
    overflow-y: auto;
    background: radial-gradient(ellipse at top, rgba(244, 196, 48, 0.06), transparent 70%);
}
.surge-activation-hero {
    text-align: center;
    margin-bottom: 22px;
}
.surge-activation-bolt {
    width: 44px;
    height: 60px;
    color: var(--yellow, #F4C430);
    filter: drop-shadow(0 0 16px rgba(244, 196, 48, 0.7))
            drop-shadow(0 0 32px rgba(244, 196, 48, 0.4));
    transform: rotate(-6deg);
    margin-bottom: 6px;
}
.surge-activation-title {
    font-family: var(--font-mono, monospace);
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--yellow, #F4C430);
    margin: 0 0 4px;
    text-transform: uppercase;
}
.surge-activation-sub {
    font-size: 0.78rem;
    color: var(--text-muted, #888);
    margin: 0;
    letter-spacing: 0.3px;
}
.surge-team-controller {
    background: linear-gradient(135deg, rgba(244, 196, 48, 0.12), rgba(244, 196, 48, 0.04));
    border: 1px solid rgba(244, 196, 48, 0.45);
    border-radius: 12px;
    padding: 14px 16px;
    margin: 0 0 14px;
    display: flex;
    gap: 12px;
    align-items: flex-start;
}
.surge-team-controller .surge-team-icon {
    color: var(--yellow, #F4C430);
    flex-shrink: 0;
    margin-top: 2px;
}
.surge-team-controller .surge-team-name {
    font-family: var(--font-mono, monospace);
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--yellow, #F4C430);
    letter-spacing: 0.5px;
    margin: 0 0 2px;
}
.surge-team-controller .surge-team-tag {
    font-size: 0.62rem;
    color: rgba(244, 196, 48, 0.7);
    font-family: var(--font-mono, monospace);
    letter-spacing: 1.5px;
    text-transform: uppercase;
    margin-bottom: 4px;
}
.surge-team-controller .surge-team-desc {
    font-size: 0.78rem;
    color: var(--text);
    line-height: 1.4;
    margin: 0;
}
.surge-team-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin: 0 0 18px;
}
.surge-team-card {
    background: var(--bg-card, #1a1d23);
    border: 1px solid rgba(244, 196, 48, 0.18);
    border-radius: 10px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-height: 0;
}
.surge-team-card-head {
    display: flex;
    align-items: center;
    gap: 8px;
}
.surge-team-card .surge-team-icon {
    color: var(--yellow, #F4C430);
    flex-shrink: 0;
}
.surge-team-card .surge-team-name {
    font-family: var(--font-mono, monospace);
    font-size: 0.74rem;
    font-weight: 600;
    color: var(--text);
    letter-spacing: 0.3px;
    margin: 0;
}
.surge-team-card .surge-team-desc {
    font-size: 0.7rem;
    color: var(--text-muted, #888);
    line-height: 1.4;
    margin: 0;
}
.surge-activation-footer {
    margin-top: 6px;
    padding: 10px 12px;
    background: rgba(244, 196, 48, 0.05);
    border: 1px solid rgba(244, 196, 48, 0.2);
    border-radius: 8px;
    font-size: 0.7rem;
    color: rgba(244, 196, 48, 0.85);
    text-align: center;
    line-height: 1.4;
}
.surge-activation-footer strong { color: var(--yellow, #F4C430); }

/* Mobile — collapse the grid to a single column so cards stay readable
   in the full-screen viewport overlay. */
@media (max-width: 720px) {
    .surge-team-grid { grid-template-columns: 1fr; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .surge-glow::after,
    .sub-glow::after,
    .surge-inner.surge-loading::after { animation: none; opacity: 0.5; }
    .surge-header-bolt                { animation: none; }
}
