:root {
    --bg: #0d0d0d;
    --panel: #111111;
    --panel-2: #181818;
    --panel-3: #202020;
    --border: rgba(255,255,255,0.08);
    --text: #f3f3f3;
    --muted: #9a9a9a;
    --accent: #ffffff;
    --bubble-user: #1f1f1f;
    --bubble-bot: #141414;
    --hover: #1d1d1d;
    --green: #39d353;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    height: 100%;
}

body {
    min-height: 100vh;
}

button, input, textarea {
    font: inherit;
}

.app-shell {
    display: flex;
    min-height: 100vh;
    background: var(--bg);
}

.sidebar {
    width: 280px;
    background: #0a0a0a;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-top {
    padding: 18px 16px 14px;
    border-bottom: 1px solid var(--border);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.brand-logo {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: linear-gradient(135deg, #ffffff, #7b7b7b);
    color: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 18px;
}

.brand-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.brand-text strong {
    font-size: 15px;
}

.brand-text span {
    color: var(--muted);
    font-size: 12px;
}

.new-chat-btn {
    width: 100%;
    border: 1px solid var(--border);
    background: #151515;
    color: var(--text);
    border-radius: 14px;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: 0.2s ease;
}

.new-chat-btn:hover {
    background: #1d1d1d;
}

.sidebar-section {
    padding: 16px;
}

.sidebar-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    margin-bottom: 12px;
}

.model-switcher {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.model-btn {
    width: 100%;
    border: 1px solid var(--border);
    background: #131313;
    color: var(--text);
    border-radius: 14px;
    padding: 12px 14px;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: 0.2s ease;
}

.model-btn:hover {
    background: #1b1b1b;
}

.model-btn.active {
    background: #202020;
    border-color: rgba(255,255,255,0.18);
}

.model-dot {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: #7a7a7a;
    flex-shrink: 0;
}

.model-dot.mid {
    background: #bfbfbf;
}

.model-dot.pro {
    background: var(--green);
}

.history-wrap {
    flex: 1;
    min-height: 0;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: calc(100vh - 320px);
    overflow-y: auto;
    padding-right: 4px;
}

.history-item {
    width: 100%;
    background: #131313;
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 12px;
    padding: 10px 12px;
    cursor: pointer;
    text-align: left;
    transition: 0.2s ease;
}

.history-item:hover {
    background: #1b1b1b;
}

.history-item.active {
    background: #222;
    border-color: rgba(255,255,255,0.18);
}

.history-title {
    font-size: 13px;
    line-height: 1.35;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-meta {
    font-size: 11px;
    color: var(--muted);
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border);
}

.mini-card {
    border: 1px solid var(--border);
    background: #131313;
    border-radius: 14px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.mini-card strong {
    font-size: 12px;
    color: var(--muted);
}

.mini-card span {
    font-size: 14px;
    color: var(--text);
}

.chat-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: #0f0f0f;
}

.topbar {
    height: 74px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 22px;
    background: rgba(15,15,15,0.95);
    backdrop-filter: blur(14px);
    position: sticky;
    top: 0;
    z-index: 20;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.topbar-left h1 {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
}

.topbar-left p {
    margin: 3px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.topbar-model-pill {
    border: 1px solid var(--border);
    background: #161616;
    border-radius: 999px;
    padding: 10px 14px;
    font-size: 13px;
    color: var(--text);
}

.mobile-sidebar-btn {
    display: none;
    border: 1px solid var(--border);
    background: #181818;
    color: white;
    border-radius: 10px;
    width: 42px;
    height: 42px;
    cursor: pointer;
}

.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 28px 20px 24px;
}

.welcome-screen {
    max-width: 860px;
    margin: 30px auto 0;
    text-align: center;
}

.welcome-badge {
    display: inline-block;
    padding: 8px 14px;
    border-radius: 999px;
    background: #191919;
    border: 1px solid var(--border);
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 18px;
}

.welcome-screen h2 {
    margin: 0 0 12px;
    font-size: 40px;
    line-height: 1.1;
}

.welcome-screen p {
    color: #bbbbbb;
    font-size: 16px;
    line-height: 1.7;
    margin: 0 auto 28px;
    max-width: 720px;
}

.welcome-cards {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin-top: 18px;
}

.welcome-card {
    background: #141414;
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 18px;
    color: var(--text);
    text-align: left;
    display: flex;
    gap: 12px;
    cursor: pointer;
    transition: 0.2s ease;
}

.welcome-card:hover {
    background: #1b1b1b;
    transform: translateY(-1px);
}

.welcome-card span {
    font-size: 22px;
    flex-shrink: 0;
}

.welcome-card strong {
    display: block;
    margin-bottom: 4px;
    font-size: 15px;
}

.welcome-card small {
    color: var(--muted);
    line-height: 1.45;
    font-size: 13px;
}

.messages {
    max-width: 900px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.message-row {
    display: flex;
    width: 100%;
}

.message-row.user {
    justify-content: flex-end;
}

.message-row.assistant {
    justify-content: flex-start;
}

.message-bubble {
    max-width: min(85%, 820px);
    border-radius: 22px;
    padding: 16px 18px;
    line-height: 1.65;
    font-size: 15px;
    white-space: pre-wrap;
    word-wrap: break-word;
    border: 1px solid var(--border);
}

.message-row.user .message-bubble {
    background: #1a1a1a;
}

.message-row.assistant .message-bubble {
    background: #121212;
}

.message-bubble.streaming::after {
    content: "▋";
    display: inline-block;
    margin-left: 2px;
    animation: blink 1s infinite;
}

@keyframes blink {
    50% { opacity: 0.2; }
}

.composer-wrap {
    padding: 18px 20px 22px;
    border-top: 1px solid var(--border);
    background: #0f0f0f;
}

.composer {
    max-width: 900px;
    margin: 0 auto;
}

.composer-inner {
    background: #141414;
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 14px 14px 14px 18px;
    display: flex;
    align-items: flex-end;
    gap: 12px;
}

#messageInput {
    flex: 1;
    background: transparent;
    color: white;
    border: none;
    resize: none;
    outline: none;
    min-height: 26px;
    max-height: 220px;
    line-height: 1.5;
    font-size: 15px;
}

#messageInput::placeholder {
    color: #7e7e7e;
}

.send-btn {
    width: 44px;
    height: 44px;
    border-radius: 999px;
    border: none;
    background: #ffffff;
    color: #000;
    cursor: pointer;
    font-size: 20px;
    font-weight: 700;
    flex-shrink: 0;
}

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

.composer-meta {
    margin-top: 10px;
    display: flex;
    justify-content: space-between;
    gap: 12px;
    color: var(--muted);
    font-size: 12px;
    padding: 0 6px;
}

@media (max-width: 980px) {
    .sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        height: 100vh;
        z-index: 50;
        transition: left 0.25s ease;
    }

    .sidebar.open {
        left: 0;
    }

    .mobile-sidebar-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .welcome-cards {
        grid-template-columns: 1fr;
    }

    .composer-meta {
        flex-direction: column;
    }
}

@media (max-width: 640px) {
    .topbar {
        padding: 0 14px;
    }

    .chat-container {
        padding: 18px 12px;
    }

    .composer-wrap {
        padding: 14px 12px 16px;
    }

    .message-bubble {
        max-width: 100%;
    }

    .topbar-model-pill {
        display: none;
    }

    .welcome-screen h2 {
        font-size: 32px;
    }
}
