:root {
    --bg:         #1a1b1a;
    --rail-bg:    #161716;
    --surface:    #252625;
    --card:       #2a2b2a;
    --border:     #333433;
    --text:       #e8e6e1;
    --muted:      #7a7a7a;
    --accent:     #888888;
}

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

html, body {
    width: 100%; height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    overflow: hidden;
}

/* ─── LOGIN ─────────────────────────────────────── */
.login-container {
    display: flex; align-items: center; justify-content: center;
    width: 100%; height: 100%;
}
.login-card {
    width: 320px; padding: 44px 36px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 12px; text-align: center;
}
.login-card h1 { font-size: 22px; font-weight: 500; margin-bottom: 28px; color: var(--text); }
#login-form { display: flex; flex-direction: column; gap: 12px; }
#password {
    padding: 11px 14px;
    background: var(--card); border: 1px solid var(--border);
    border-radius: 8px; color: var(--text); font-size: 14px;
    outline: none; transition: border-color 0.15s;
}
#password:focus { border-color: #555; }
#login-form button[type="submit"] {
    padding: 11px; background: var(--text); color: var(--bg);
    border: none; border-radius: 8px; font-size: 14px;
    font-weight: 600; cursor: pointer; transition: opacity 0.15s;
}
#login-form button[type="submit"]:hover { opacity: 0.85; }
.error-msg { color: #e06c6c; font-size: 12px; min-height: 16px; }

/* ─── APP SHELL ──────────────────────────────────── */
.app-container {
    display: flex; width: 100%; height: 100%;
    position: relative; overflow: hidden;
}

/* ─── RAIL ───────────────────────────────────────── */
.rail {
    width: 50px; flex-shrink: 0;
    background: var(--rail-bg);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0 14px;
    z-index: 20;
}
.rail-top, .rail-bottom {
    display: flex; flex-direction: column;
    align-items: center; gap: 4px;
}
.rail-btn {
    width: 36px; height: 36px; border-radius: 8px;
    background: transparent; border: none;
    color: var(--muted); cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.12s, color 0.12s;
}
.rail-btn svg { width: 18px; height: 18px; }
.rail-btn:hover { background: rgba(255,255,255,0.07); color: var(--text); }
.rail-btn.active { color: var(--text); }

/* (project dots moved to top-right — see .project-dot) */

/* ─── HISTORY PANEL ──────────────────────────────── */
.history-panel {
    position: absolute;
    left: 50px; top: 0;
    width: 230px; height: 100%;
    background: #1d1e1d;
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    transform: translateX(-230px);
    transition: transform 0.22s cubic-bezier(0.4,0,0.2,1);
    z-index: 15;
}
.history-panel.open { transform: translateX(0); }
.history-header {
    padding: 14px 14px 10px;
    display: flex; flex-direction: column; gap: 2px;
    border-bottom: 1px solid var(--border);
}
.history-header span:first-child { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.history-project-name { font-size: 13px; color: var(--text); font-weight: 500; }
.chat-list { flex: 1; overflow-y: auto; padding: 6px; }
.chat-item {
    display: block; width: 100%;
    padding: 8px 10px;
    background: transparent; border: 1px solid transparent;
    border-radius: 6px; color: var(--text); text-align: left;
    cursor: pointer; font-size: 13px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    transition: background 0.12s;
}
.chat-item:hover { background: rgba(255,255,255,0.05); }
.chat-item.active { background: rgba(255,255,255,0.07); border-color: rgba(255,255,255,0.1); }

/* ─── MAIN AREA ──────────────────────────────────── */
.main-area { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; position: relative; }

/* Top-right bar — project dots live here */
.main-topbar {
    position: absolute; top: 0; right: 0;
    height: 44px; padding: 0 14px;
    display: flex; align-items: center; gap: 6px;
    z-index: 10; pointer-events: none;
}
.project-dots {
    display: flex; align-items: center; gap: 5px;
    pointer-events: all;
}
.project-dot {
    width: 24px; height: 24px; border-radius: 50%;
    background: var(--surface); border: 1.5px solid transparent;
    font-size: 12px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: border-color 0.12s, transform 0.1s;
    flex-shrink: 0;
}
.project-dot:hover { transform: scale(1.1); }
.project-dot.active { border-color: var(--accent); }

/* ─── WELCOME SCREEN ─────────────────────────────── */
.welcome-screen {
    flex: 1;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 24px; padding: 40px 24px 60px;
}
.welcome-heading {
    display: flex; align-items: center; gap: 16px;
}
.asterisk-logo {
    width: 42px; height: 42px;
    color: #d4845e; flex-shrink: 0;
}
.welcome-heading h1 {
    font-size: 36px; font-weight: 300;
    font-family: Georgia, "Times New Roman", serif;
    color: var(--text); letter-spacing: -0.3px;
}

/* ─── INPUT CARD ─────────────────────────────────── */
.input-card-wrap { width: 100%; max-width: 660px; }
.input-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 16px 16px 10px;
    display: flex; flex-direction: column;
    transition: border-color 0.15s;
}
.input-card:focus-within { border-color: #484848; }
.input-card textarea {
    width: 100%; background: transparent; border: none; outline: none;
    color: var(--text); font-size: 15px; font-family: inherit;
    resize: none; min-height: 24px; max-height: 200px; line-height: 1.5;
}
.input-card textarea::placeholder { color: var(--muted); }
.input-card-footer {
    display: flex; align-items: center;
    justify-content: space-between;
    margin-top: 10px; gap: 8px;
}
.attach-btn {
    width: 30px; height: 30px; border-radius: 7px;
    background: transparent; border: 1px solid var(--border);
    color: var(--muted); cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; transition: background 0.12s, color 0.12s;
}
.attach-btn svg { width: 15px; height: 15px; }
.attach-btn:hover { background: rgba(255,255,255,0.06); color: var(--text); }

/* Model pill */
.model-pill-group { position: relative; }
.model-pill {
    display: flex; align-items: center; gap: 4px;
    background: transparent; border: none;
    color: var(--muted); cursor: pointer; font-size: 13px;
    padding: 5px 8px; border-radius: 7px;
    transition: background 0.12s, color 0.12s; white-space: nowrap;
}
.model-pill:hover { background: rgba(255,255,255,0.06); color: var(--text); }
.model-pill-type { color: var(--muted); }
.chevron { width: 13px; height: 13px; flex-shrink: 0; }
.model-dropdown {
    display: none; position: absolute; bottom: calc(100% + 6px); left: 0;
    background: #2d2e2d; border: 1px solid var(--border);
    border-radius: 8px; overflow: hidden; min-width: 130px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4); z-index: 100;
}
.model-dropdown.open { display: block; }
.model-option {
    padding: 9px 14px; cursor: pointer; font-size: 13px; color: var(--text);
    transition: background 0.1s;
}
.model-option:hover { background: rgba(255,255,255,0.07); }
.model-option.selected { color: var(--accent); }

/* Send button */
.send-btn {
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--text); color: var(--bg);
    border: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; transition: opacity 0.12s;
}
.send-btn svg { width: 16px; height: 16px; }
.send-btn:hover { opacity: 0.82; }

/* ─── QUICK PILLS ─────────────────────────────────── */
.quick-pills {
    display: flex; flex-wrap: wrap; gap: 8px; justify-content: center;
    max-width: 660px;
}
.quick-pill {
    padding: 7px 15px; border-radius: 20px;
    background: transparent; border: 1px solid var(--border);
    color: var(--muted); cursor: pointer; font-size: 13px;
    transition: border-color 0.12s, color 0.12s, background 0.12s;
}
.quick-pill:hover { border-color: #555; color: var(--text); background: rgba(255,255,255,0.03); }

/* ─── CHAT VIEW ───────────────────────────────────── */
.chat-view {
    display: flex; flex-direction: column;
    height: 100%;
}
.chat-top-bar {
    padding: 0 20px;
    height: 48px;
    display: flex; align-items: center; justify-content: space-between;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.chat-title-text { font-size: 13px; color: var(--muted); font-weight: 500; }
.model-indicator { font-size: 12px; color: var(--muted); }
.chat-thread {
    flex: 1; overflow-y: auto;
    padding: 28px 24px 8px;
    display: flex; flex-direction: column; gap: 16px;
    align-items: center;
}
/* Inner wrapper keeps messages at max-width */
.chat-thread > * { width: 100%; max-width: 660px; }
.message { display: flex; flex-direction: column; gap: 4px; }
.message.user { align-items: flex-end; }
.message.assistant { align-items: flex-start; }
.message-content {
    max-width: 72%; padding: 12px 16px;
    border-radius: 12px; word-wrap: break-word; font-size: 14px; line-height: 1.6;
}
.message.user .message-content {
    background: var(--surface); border: 1px solid var(--border);
    border-bottom-right-radius: 4px;
}
.message.assistant .message-content {
    background: transparent; color: var(--text);
}
.message-content code {
    background: var(--card); padding: 2px 5px; border-radius: 4px;
    font-family: "Fira Code", "Courier New", monospace; font-size: 12px;
}
.chat-input-wrap {
    padding: 8px 24px 24px;
    flex-shrink: 0;
    display: flex;
    justify-content: center;
}
.chat-input-wrap .input-card {
    width: 100%;
    max-width: 660px;
}

/* ─── PANELS (right side slide-in) ───────────────── */
.slide-panel {
    position: fixed; right: 0; top: 0;
    width: 380px; height: 100%;
    background: var(--rail-bg); border-left: 1px solid var(--border);
    display: flex; flex-direction: column;
    z-index: 500;
    animation: panelIn 0.22s cubic-bezier(0.4,0,0.2,1);
}
@keyframes panelIn { from { transform: translateX(100%); } to { transform: translateX(0); } }
.panel-header {
    padding: 18px 18px 14px;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
}
.panel-header h3 { font-size: 15px; font-weight: 500; }
.close-btn {
    width: 28px; height: 28px; border-radius: 6px;
    background: transparent; border: none; color: var(--muted);
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: background 0.12s, color 0.12s;
}
.close-btn svg { width: 15px; height: 15px; }
.close-btn:hover { background: rgba(255,255,255,0.07); color: var(--text); }
.panel-content { flex: 1; overflow-y: auto; padding: 18px; }
.notes-quick-add { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }
.notes-input {
    padding: 10px 12px; background: var(--card); border: 1px solid var(--border);
    border-radius: 8px; color: var(--text); font-size: 13px; outline: none;
}
.notes-input:focus { border-color: #555; }
.notes-organise-btn {
    padding: 8px 12px; background: transparent; border: 1px solid var(--border);
    border-radius: 8px; color: var(--muted); cursor: pointer; font-size: 12px;
    transition: background 0.12s, color 0.12s;
}
.notes-organise-btn:hover { background: rgba(255,255,255,0.05); color: var(--text); }
.todo-section, .notes-section { margin-bottom: 20px; }
.todo-section h4, .notes-section h4 {
    font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
    color: var(--muted); font-weight: 600; margin-bottom: 8px;
}
.todo-item, .note-item {
    padding: 8px 10px; background: var(--card); border-radius: 7px;
    margin-bottom: 6px; display: flex; align-items: center;
    justify-content: space-between; font-size: 13px; gap: 8px;
}
.todo-item label { display: flex; align-items: center; gap: 8px; cursor: pointer; flex: 1; }
.todo-item.done label { opacity: 0.5; text-decoration: line-through; }
.item-del {
    background: none; border: none; color: var(--muted); cursor: pointer;
    font-size: 16px; line-height: 1; flex-shrink: 0; padding: 0 2px;
    transition: color 0.12s;
}
.item-del:hover { color: #e06c6c; }

/* ─── SETTINGS MODAL ──────────────────────────────── */
.modal {
    position: fixed; inset: 0; z-index: 600;
    background: rgba(0,0,0,0.6);
    display: flex; align-items: center; justify-content: center;
}
.modal-content {
    background: var(--rail-bg); border: 1px solid var(--border);
    border-radius: 12px; width: 90%; max-width: 560px; max-height: 82vh;
    display: flex; flex-direction: column; overflow: hidden;
}
.modal-header {
    padding: 18px 18px 14px; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
}
.modal-header h3 { font-size: 15px; font-weight: 500; }
.modal-body { flex: 1; overflow-y: auto; padding: 18px; }
.settings-section { margin-bottom: 28px; }
.settings-section h4 { font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.settings-hint { font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.output-settings {
    width: 100%; padding: 10px 12px; background: var(--card);
    border: 1px solid var(--border); border-radius: 8px;
    color: var(--text); font-family: inherit; font-size: 13px;
    resize: vertical; outline: none; line-height: 1.5;
}
.output-settings:focus { border-color: #555; }
.btn-save {
    margin-top: 10px; padding: 8px 18px;
    background: var(--text); color: var(--bg);
    border: none; border-radius: 7px; font-size: 13px;
    font-weight: 600; cursor: pointer; transition: opacity 0.12s;
}
.btn-save:hover { opacity: 0.85; }
.integrations-list { display: flex; flex-direction: column; gap: 10px; }

/* ─── SCROLLBAR ───────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #555; }

/* ─── RESPONSIVE ──────────────────────────────────── */
@media (max-width: 640px) {
    .welcome-heading h1 { font-size: 26px; }
    .input-card-wrap { max-width: 100%; }
    .quick-pills { max-width: 100%; }
    .slide-panel { width: 100%; }
    .modal-content { max-width: 100%; border-radius: 0; }
}
