:root {
    --bg: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-message: #0f3460;
    --bg-user: #533483;
    --text: #e0e0e0;
    --text-muted: #888;
    --accent: #e94560;
    --border: #2a2a4a;
    --input-bg: #222244;
}

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

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

.hidden { display: none !important; }

.screen {
    height: 100vh;
    width: 100vw;
}

/* Auth */
.auth-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 1rem;
}

.auth-container h1 {
    font-size: 2.5rem;
    color: var(--accent);
}

.subtitle {
    color: var(--text-muted);
    margin-bottom: 2rem;
}

.auth-form {
    width: min(28rem, 90vw);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.auth-form input {
    width: 100%;
    padding: 0.8rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--input-bg);
    color: var(--text);
    font-size: 1rem;
}

.auth-form input:focus {
    outline: none;
    border-color: var(--accent);
}

/* Layout */
.layout {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
}

.sidebar-header h2 {
    font-size: 1.2rem;
    margin-bottom: 0.75rem;
    color: var(--accent);
}

.sidebar-meta {
    margin-top: 0.75rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.btn-primary {
    width: 100%;
    padding: 0.5rem;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
}

.btn-primary:hover { opacity: 0.9; }

.conversation-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.conversation-item {
    padding: 0.45rem 0.5rem;
    border-radius: 6px;
    margin-bottom: 2px;
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.conversation-item:hover { background: var(--bg); }
.conversation-item.active { background: var(--bg-message); }
.conversation-item.private {
    box-shadow: inset 0 0 0 1px rgba(255, 140, 160, 0.18);
}

.conversation-title {
    flex: 1;
    min-width: 0;
    padding: 0.15rem 0.25rem;
    background: none;
    border: none;
    color: var(--text);
    cursor: pointer;
    font-size: 0.85rem;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conversation-title.private {
    color: #ffb3c1;
}

.conversation-menu-trigger {
    width: 1.8rem;
    height: 1.8rem;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
}

.conversation-menu-trigger:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
}

.conversation-menu {
    position: absolute;
    top: calc(100% + 0.15rem);
    right: 0.25rem;
    z-index: 20;
    min-width: 10rem;
    padding: 0.35rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-secondary);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
}

.conversation-menu-action {
    width: 100%;
    padding: 0.55rem 0.65rem;
    border: none;
    border-radius: 6px;
    background: none;
    color: var(--text);
    text-align: left;
    cursor: pointer;
    font-size: 0.84rem;
}

.conversation-menu-action:hover {
    background: rgba(255, 255, 255, 0.06);
}

.conversation-menu-action.danger {
    color: #ff8ca0;
}

.sidebar-footer {
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
}

.user-info { color: var(--text-muted); }

.btn-text {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.8rem;
}

.btn-text:hover { color: var(--accent); }

/* Chat main */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.conversation-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 2rem 0.5rem;
}

.conversation-header h2 {
    font-size: 1.15rem;
}

.conversation-subtitle {
    margin-top: 0.2rem;
    color: var(--text-muted);
    font-size: 0.88rem;
}

.messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 2rem;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
}

.empty-state h2 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.message {
    margin-bottom: 1rem;
    display: flex;
    gap: 0.75rem;
}

.message-role {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    min-width: 70px;
    padding-top: 0.25rem;
}

.message-role.user { color: var(--accent); }
.message-role.assistant { color: #4fc3f7; }

.message-content {
    flex: 1;
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* Chat input */
.chat-input {
    padding: 1rem 2rem;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
}

#message-input {
    flex: 1;
    padding: 0.75rem 1rem;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 0.95rem;
    font-family: inherit;
    resize: none;
    max-height: 150px;
    outline: none;
}

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

.btn-send {
    padding: 0.75rem 1.5rem;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.95rem;
}

.btn-send:hover { opacity: 0.9; }
.btn-send:disabled { opacity: 0.5; cursor: not-allowed; }

.modal {
    position: fixed;
    inset: 0;
    background: rgba(10, 10, 18, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.modal-card {
    width: min(38rem, 100%);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 1.25rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.modal-copy {
    color: var(--text-muted);
    margin: 0.75rem 0 1rem;
}

.model-picker-options {
    display: grid;
    gap: 0.75rem;
}

.model-option {
    width: 100%;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg);
    color: var(--text);
    text-align: left;
    cursor: pointer;
}

.model-option:hover {
    border-color: var(--accent);
}

.model-option:disabled {
    cursor: not-allowed;
    opacity: 0.7;
}

.model-option-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    font-size: 1rem;
    font-weight: 600;
}

.model-option-description {
    margin-top: 0.35rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.model-option-error {
    margin-top: 0.5rem;
    color: #f4a3a3;
    font-size: 0.8rem;
}

.status-pill {
    padding: 0.2rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.status-pill.healthy {
    background: rgba(79, 195, 247, 0.15);
    color: #4fc3f7;
}

.status-pill.unhealthy {
    background: rgba(233, 69, 96, 0.18);
    color: #ff8ca0;
}

.private-badge {
    padding: 0.3rem 0.7rem;
    border: 1px solid rgba(255, 140, 160, 0.45);
    border-radius: 999px;
    background: linear-gradient(135deg, rgba(233, 69, 96, 0.22), rgba(255, 140, 160, 0.18));
    color: #ffd3db;
    font-size: 0.78rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

#chat-screen.private-chat .chat-main {
    background:
        radial-gradient(circle at top right, rgba(255, 140, 160, 0.15), transparent 32%),
        radial-gradient(circle at bottom left, rgba(233, 69, 96, 0.14), transparent 28%);
}

#chat-screen.private-chat .conversation-header {
    border-bottom: 1px solid rgba(255, 140, 160, 0.18);
}

#chat-screen.private-chat #message-input {
    border-color: rgba(255, 140, 160, 0.35);
    box-shadow: inset 0 0 0 1px rgba(255, 140, 160, 0.08);
}
