:root {
    --bg: #090a0d;
    --panel: #0f1116;
    --panel2: #151820;
    --line: #252a34;
    --text: #f5f7fa;
    --muted: #8b93a1;
    --accent: #e8ebf0;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    width: 100%;
    height: 100%;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family:
        Inter,
        ui-sans-serif,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
}

button,
input,
textarea,
select {
    font: inherit;
}

button {
    cursor: pointer;
}

.hidden {
    display: none !important;
}

.honeypot {
    position: absolute !important;
    left: -9999px !important;
    opacity: 0 !important;
}

.auth-view {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.auth-card {
    width: 100%;
    max-width: 400px;
}

.wordmark {
    letter-spacing: .18em;
    font-weight: 800;
    font-size: 22px;
    margin-bottom: 36px;
    text-align: center;
}

.auth-title {
    font-size: 28px;
    font-weight: 650;
    letter-spacing: -.03em;
    text-align: center;
    margin-bottom: 28px;
}

input,
select,
textarea {
    border: 1px solid var(--line);
    background: var(--panel);
    color: var(--text);
    outline: none;
}

input:focus,
select:focus,
textarea:focus {
    border-color: #555d6b;
}

input {
    width: 100%;
    height: 52px;
    border-radius: 14px;
    padding: 0 16px;
    margin-bottom: 12px;
}

button {
    border: 0;
}

.primary {
    height: 50px;
    background: var(--accent);
    color: #08090b;
    border-radius: 14px;
    font-weight: 700;
}

.full {
    width: 100%;
}

.text-button {
    display: block;
    margin: 18px auto 0;
    background: transparent;
    color: var(--muted);
}

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

.error {
    color: #ff7272;
    font-size: 14px;
    min-height: 22px;
    margin-bottom: 8px;
}

.muted {
    color: var(--muted);
}

.small {
    font-size: 12px;
}

.turnstile-box {
    margin: 4px 0 14px;
}

.app {
    display: flex;
    width: 100%;
    height: 100vh;
}

.sidebar {
    width: 245px;
    border-right: 1px solid var(--line);
    background: #0b0d11;
    padding: 20px 14px;
    display: flex;
    flex-direction: column;
}

.sidebar-logo {
    font-size: 17px;
    font-weight: 800;
    letter-spacing: .15em;
    padding: 8px 10px 24px;
}

.new-chat,
.sidebar-button {
    width: 100%;
    border-radius: 11px;
    padding: 11px 12px;
    text-align: left;
}

.new-chat {
    background: var(--panel2);
    color: var(--text);
    border: 1px solid var(--line);
}

.sidebar-button {
    background: transparent;
    color: var(--muted);
}

.sidebar-button:hover,
.new-chat:hover {
    background: var(--panel2);
    color: var(--text);
}

.sidebar-spacer {
    flex: 1;
}

.main {
    flex: 1;
    min-width: 0;
    position: relative;
}

.topbar {
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid rgba(37,42,52,.5);
}

.topbar select {
    width: auto;
    min-width: 150px;
    height: 38px;
    padding: 0 12px;
    border-radius: 10px;
}

.mobile-logo {
    display: none;
}

.chat {
    height: calc(100vh - 64px);
    overflow-y: auto;
    padding: 42px 24px 180px;
}

.welcome {
    max-width: 760px;
    margin: 12vh auto 0;
    text-align: center;
}

.welcome-logo {
    margin: auto;
    width: 52px;
    height: 52px;
    border: 1px solid var(--line);
    border-radius: 16px;
    display: grid;
    place-items: center;
    font-weight: 800;
    font-size: 22px;
    background: var(--panel);
}

.welcome h1 {
    margin: 20px 0 8px;
    font-size: 30px;
}

.welcome p {
    color: var(--muted);
    margin: 0;
}

.message {
    max-width: 780px;
    margin: 0 auto 28px;
    display: flex;
    gap: 14px;
}

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

.message-card {
    max-width: 88%;
    line-height: 1.65;
    font-size: 15px;
}

.user .message-card {
    background: var(--panel2);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 12px 16px;
}

.assistant .message-card {
    width: 100%;
}

.assistant-label {
    font-size: 12px;
    font-weight: 750;
    letter-spacing: .09em;
    margin-bottom: 8px;
    color: var(--muted);
}

.content {
    white-space: pre-wrap;
    word-wrap: break-word;
}

.content pre {
    margin: 14px 0;
    padding: 16px;
    border-radius: 13px;
    background: #050607;
    border: 1px solid var(--line);
    overflow-x: auto;
    white-space: pre;
}

.content code {
    font-family:
        "SFMono-Regular",
        Consolas,
        monospace;
    font-size: 13px;
}

.composer-shell {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 32px 24px 16px;
    background:
        linear-gradient(
            transparent,
            var(--bg) 30%
        );
}

.composer {
    max-width: 780px;
    margin: auto;
    border: 1px solid var(--line);
    border-radius: 20px;
    background: var(--panel);
    padding: 10px;
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.composer textarea {
    flex: 1;
    border: 0;
    background: transparent;
    min-height: 40px;
    max-height: 180px;
    resize: none;
    padding: 10px;
}

.send,
.stop {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    font-size: 20px;
}

.send {
    background: var(--accent);
    color: #090a0d;
}

.stop {
    background: #292d36;
    color: white;
}

.composer-note {
    text-align: center;
    color: #666d79;
    font-size: 11px;
    margin-top: 9px;
}

.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.72);
    display: grid;
    place-items: center;
    padding: 20px;
    z-index: 50;
}

.modal-card {
    width: 100%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 22px;
}

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

.modal-header h2 {
    margin: 0 0 18px;
}

.close {
    background: transparent;
    color: var(--muted);
    font-size: 26px;
}

.stat {
    border: 1px solid var(--line);
    background: var(--panel2);
    padding: 15px;
    border-radius: 13px;
    margin-bottom: 10px;
}

.api-key {
    word-break: break-all;
    background: #050607;
    padding: 14px;
    border-radius: 12px;
    border: 1px solid var(--line);
    margin: 10px 0;
}

.modal-card input {
    margin-top: 8px;
}

.modal-card .primary {
    padding: 0 18px;
}

.danger {
    color: #ff7c7c;
    background: transparent;
}

@media (max-width: 720px) {

    .sidebar {
        display: none;
    }

    .topbar {
        justify-content: space-between;
        padding: 0 14px;
    }

    .mobile-logo {
        display: block;
        font-weight: 800;
        letter-spacing: .12em;
    }

    .chat {
        padding-left: 14px;
        padding-right: 14px;
    }

    .composer-shell {
        padding-left: 12px;
        padding-right: 12px;
    }

    .message-card {
        max-width: 95%;
    }
}
