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

:root {
    --bg: #1a1a2e;
    --surface: #16213e;
    --surface2: #0f3460;
    --accent: #e94560;
    --text: #eee;
    --text2: #aaa;
    --green: #4ade80;
    --red: #f87171;
    --radius: 10px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ── Top Bar ─────────────────────────────────── */
#topbar {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    background: var(--surface);
    border-bottom: 1px solid #333;
    gap: 10px;
    z-index: 10;
}

#current-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#current-project {
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#current-session {
    font-size: 11px;
    color: var(--text2);
}

.icon-btn {
    background: none;
    border: none;
    color: var(--text);
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
}

.icon-btn:active { background: rgba(255,255,255,0.1); }

.status-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.status-dot.connected { background: var(--green); }
.status-dot.disconnected { background: var(--red); }

/* ── Sidebar ─────────────────────────────────── */
#sidebar-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 20;
}

#sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 280px;
    background: var(--surface);
    z-index: 30;
    padding: 16px;
    overflow-y: auto;
    transform: translateX(-100%);
    transition: transform 0.2s;
}

#sidebar.open { transform: translateX(0); }

.sidebar-section { margin-bottom: 20px; }
.sidebar-section h3 {
    font-size: 13px;
    color: var(--text2);
    text-transform: uppercase;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.small-btn {
    background: var(--surface2);
    color: var(--text);
    border: none;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
}

#project-list, #session-list {
    list-style: none;
}

#project-list li, #session-list li {
    padding: 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
}

#project-list li:hover, #session-list li:hover,
#project-list li.active, #session-list li.active {
    background: var(--surface2);
}

.hidden { display: none !important; }

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

.msg {
    margin-bottom: 12px;
    padding: 10px 14px;
    border-radius: var(--radius);
    max-width: 95%;
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
    white-space: pre-wrap;
}

.msg.user {
    background: var(--surface2);
    margin-left: auto;
    border-bottom-right-radius: 2px;
}

.msg.assistant {
    background: var(--surface);
    border-bottom-left-radius: 2px;
}

.msg.tool {
    background: #1a2a1a;
    border-left: 3px solid var(--green);
    font-size: 13px;
    font-family: monospace;
}

.msg.error {
    background: #2a1a1a;
    border-left: 3px solid var(--red);
    color: var(--red);
}

.msg code {
    background: rgba(255,255,255,0.1);
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 13px;
}

.msg pre {
    background: rgba(0,0,0,0.3);
    padding: 8px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 6px 0;
    font-size: 12px;
}

/* ── Status Bar ──────────────────────────────── */
#status-bar {
    padding: 6px 14px;
    font-size: 12px;
    color: var(--text2);
    display: flex;
    align-items: center;
    gap: 8px;
}

#status-bar::before {
    content: "";
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--accent);
    animation: pulse 1s infinite;
}

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

/* ── Confirm Banner ──────────────────────────── */
#confirm-banner {
    background: var(--surface);
    border-top: 2px solid var(--accent);
    padding: 12px;
}

#confirm-message {
    font-size: 13px;
    margin-bottom: 10px;
    max-height: 120px;
    overflow-y: auto;
    white-space: pre-wrap;
    font-family: monospace;
}

.confirm-actions {
    display: flex;
    gap: 10px;
}

.btn {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
}

.btn-accept { background: var(--green); color: #000; }
.btn-reject { background: var(--red); color: #fff; }
.btn:active { opacity: 0.8; }

/* ── Input Area ──────────────────────────────── */
#input-area {
    display: flex;
    align-items: flex-end;
    padding: 8px 10px;
    background: var(--surface);
    border-top: 1px solid #333;
    gap: 8px;
}

#input-text {
    flex: 1;
    background: var(--bg);
    border: 1px solid #444;
    border-radius: 8px;
    color: var(--text);
    padding: 10px 12px;
    font-size: 15px;
    resize: none;
    max-height: 120px;
    outline: none;
    font-family: inherit;
}

#input-text:focus { border-color: var(--accent); }

.send-btn {
    background: var(--accent);
    width: 42px; height: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

/* ── Login Screen ────────────────────────────── */
#login-screen {
    position: fixed; inset: 0;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.login-box {
    text-align: center;
    padding: 30px;
}

.login-box h2 {
    margin-bottom: 20px;
    font-size: 22px;
}

.login-box input {
    width: 100%;
    max-width: 280px;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid #444;
    background: var(--surface);
    color: var(--text);
    font-size: 15px;
    margin-bottom: 14px;
    outline: none;
    text-align: center;
}

.login-box .btn {
    max-width: 280px;
}
