:root {
    --bg-gradient-start: #050816;
    --bg-gradient-end: #0b1220;
    --accent: #38bdf8;
    --accent-soft: rgba(56, 189, 248, 0.15);
    --card-bg: rgba(15, 23, 42, 0.92);
    --card-border: rgba(148, 163, 184, 0.28);
    --text-main: #e5e7eb;
    --text-muted: #9ca3af;
    --danger: #f97373;
    --surface: #0f172a;
}

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

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

body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(circle at top left, #1d2347 0, transparent 55%),
        radial-gradient(circle at bottom right, #0f766e 0, transparent 55%),
        linear-gradient(135deg, var(--bg-gradient-start), var(--bg-gradient-end));
    color: var(--text-main);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

.shell {
    width: 100%;
    max-width: 960px;
    padding: 20px;
}

.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand--compact {
    margin-bottom: 8px;
}

.ai-logo {
    width: 36px;
    height: 36px;
    border-radius: 4px;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-logo::after {
    content: "AI";
    font-weight: 700;
    font-size: 11px;
    letter-spacing: 0.06em;
    color: #0f172a;
}

.brand-text-title {
    font-size: 18px;
    font-weight: 600;
}

.header-actions {
    display: flex;
    align-items: center;
}

.logout-link {
    font-size: 13px;
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.logout-link:hover {
    color: #7dd3fc;
}

.card {
    border-radius: 4px;
    padding: 16px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 120px);
}

.card-header {
    margin-bottom: 12px;
}

.card-title-group {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.card-title {
    font-size: 15px;
    font-weight: 600;
}

.card-subtitle {
    font-size: 13px;
    color: var(--text-muted);
}

.chat-window {
    flex: 1;
    min-height: 0;
    border-radius: 4px;
    padding: 10px;
    background: var(--surface);
    border: 1px solid var(--card-border);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chat-log {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chat-empty {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 13px;
    text-align: center;
    padding: 8px;
}

.message {
    display: flex;
    gap: 8px;
    align-items: flex-start;
}

.message-avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 7px;
    font-weight: 700;
    line-height: 1.1;
    text-align: center;
    color: #0f172a;
    flex-shrink: 0;
}

.message-avatar.user {
    background: #fb923c;
    color: #431407;
}

.message-bubble {
    max-width: 100%;
    border-radius: 4px;
    padding: 8px 10px;
    font-size: 13px;
    background: #1e293b;
    border: 1px solid rgba(71, 85, 105, 0.6);
}

.message-bubble.assistant {
    background: var(--surface);
    border-color: rgba(56, 189, 248, 0.35);
}

.message-meta {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

.typing-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: typing-bounce 1.2s infinite ease-in-out both;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.15s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes typing-bounce {
    0%,
    80%,
    100% {
        opacity: 0.35;
    }
    40% {
        opacity: 1;
    }
}

.input-row {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--card-border);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.input-top-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.textarea-wrapper {
    flex: 1;
    min-width: 0;
}

textarea {
    width: 100%;
    min-height: 72px;
    max-height: 160px;
    resize: vertical;
    padding: 10px;
    border-radius: 4px;
    border: 1px solid rgba(71, 85, 105, 0.8);
    outline: none;
    background: #0c1222;
    color: var(--text-main);
    font-size: 14px;
    font-family: inherit;
    line-height: 1.4;
}

textarea::placeholder {
    color: var(--text-muted);
}

textarea:focus {
    border-color: var(--accent);
    outline: 2px solid var(--accent-soft);
    outline-offset: 0;
}

button[type="submit"] {
    border: none;
    cursor: pointer;
    padding: 10px 16px;
    border-radius: 4px;
    background: var(--accent);
    color: #0f172a;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    flex-shrink: 0;
}

button[type="submit"]:hover {
    background: #7dd3fc;
}

button[type="submit"]:disabled {
    cursor: default;
    opacity: 0.45;
}

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

.input-status--error {
    color: var(--danger);
}

.error-text {
    color: var(--danger);
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Login */

.login-card {
    max-width: 380px;
    margin: 0 auto;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.login-error {
    padding: 10px;
    border-radius: 4px;
    background: rgba(249, 115, 115, 0.1);
    border: 1px solid rgba(249, 115, 115, 0.35);
    color: var(--danger);
    font-size: 13px;
}

.login-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.login-field label {
    font-size: 13px;
    color: var(--text-muted);
}

.login-field input {
    padding: 10px;
    border-radius: 4px;
    border: 1px solid rgba(71, 85, 105, 0.8);
    background: #0c1222;
    color: var(--text-main);
    font-size: 14px;
    font-family: inherit;
    outline: none;
}

.login-field input:focus {
    border-color: var(--accent);
    outline: 2px solid var(--accent-soft);
    outline-offset: 0;
}

.login-submit {
    margin-top: 4px;
    padding: 10px 16px;
    border: none;
    border-radius: 4px;
    background: var(--accent);
    color: #0f172a;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
}

.login-submit:hover {
    background: #7dd3fc;
}

@media (max-width: 768px) {
    body {
        align-items: flex-start;
        padding: 12px 0 20px;
    }

    .shell {
        padding: 0 12px;
    }

    .header {
        flex-direction: column;
        align-items: flex-start;
        margin-bottom: 12px;
    }

    .login-card {
        max-width: 100%;
    }

    .card {
        max-height: none;
        padding: 14px 12px;
    }

    .chat-window {
        max-height: 58vh;
    }

    .input-top-row {
        flex-direction: column;
        align-items: stretch;
    }

    button[type="submit"] {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .brand-text-title {
        font-size: 16px;
    }

    .chat-window {
        max-height: 52vh;
    }
}
