@font-face {
    font-family: Vazirmatn;
    src: url("../fonts/Vazirmatn.woff2") format("woff2");
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}

:root {
    --bg: #070b18;
    --navy: #101735;
    --panel: rgba(12, 18, 42, 0.88);
    --text: #f3f5ff;
    --muted: #b7c0de;
    --line: rgba(166, 150, 255, 0.22);
    --purple: #8b5cf6;
    --blue: #3d6bff;
    --danger: #ffc1ce;
    --shadow: 0 24px 80px rgba(18, 10, 48, 0.45);
    color-scheme: dark;
}

* { box-sizing: border-box; }

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

body {
    font-family: Vazirmatn, Tahoma, sans-serif;
    color: var(--text);
    background:
        radial-gradient(900px 480px at 100% -10%, rgba(109, 76, 255, 0.38), transparent 55%),
        radial-gradient(720px 420px at -10% 110%, rgba(37, 78, 220, 0.32), transparent 50%),
        var(--bg);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.mark {
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    flex: 0 0 auto;
    border-radius: 16px;
    background: linear-gradient(145deg, #9b6dff, #3557e8);
    box-shadow: 0 8px 24px rgba(80, 70, 220, 0.35);
    font-weight: 700;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.brand h1, .hello {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 700;
}

.muted, .hint, .quota {
    margin: 0;
    color: var(--muted);
    font-size: 0.86rem;
}

.auth-body {
    min-height: 100dvh;
    display: grid;
    place-items: center;
    padding: 24px 16px;
}

.card, .shell {
    background:
        linear-gradient(var(--panel), var(--panel)) padding-box,
        linear-gradient(145deg, rgba(176, 148, 255, 0.7), rgba(61, 107, 255, 0.18) 45%, rgba(120, 90, 255, 0.55)) border-box;
    border: 1px solid transparent;
}

.card {
    width: min(440px, 100%);
    padding: 28px 24px 22px;
    border-radius: 28px;
    box-shadow: var(--shadow);
}

.card form, .composer {
    display: grid;
    gap: 8px;
}

label {
    margin-top: 8px;
    font-size: 0.92rem;
}

input, textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #0c132c;
    color: var(--text);
    font: inherit;
    padding: 12px 14px;
}

textarea {
    resize: none;
    min-height: 52px;
    max-height: 160px;
    line-height: 1.7;
}

input:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible {
    outline: 2px solid #c4b5fd;
    outline-offset: 2px;
}

button {
    font: inherit;
    cursor: pointer;
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

.primary {
    border: 0;
    border-radius: 14px;
    padding: 12px 18px;
    color: white;
    background: linear-gradient(135deg, var(--purple), var(--blue));
    box-shadow: 0 10px 24px rgba(70, 70, 210, 0.28);
}

.ghost {
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 8px 14px;
    color: var(--text);
    background: transparent;
}

.alert {
    margin: 12px 0 0;
    padding: 10px 12px;
    border-radius: 12px;
    color: var(--danger);
    background: rgba(255, 80, 110, 0.12);
    border: 1px solid rgba(255, 140, 164, 0.35);
}

.switch {
    margin: 16px 0 0;
    color: var(--muted);
}

a {
    color: #d6ccff;
}

.shell {
    width: min(920px, 100%);
    height: 100dvh;
    margin-inline: auto;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    box-shadow: var(--shadow);
}

.top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
    background: rgba(8, 12, 30, 0.55);
}

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

.messages {
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 18px 16px 8px;
}

.messages::-webkit-scrollbar { width: 8px; }
.messages::-webkit-scrollbar-thumb {
    background: rgba(150, 140, 255, 0.35);
    border-radius: 99px;
}

.empty {
    margin: auto;
    text-align: center;
    display: grid;
    justify-items: center;
    gap: 8px;
}

.bubble {
    width: fit-content;
    max-width: min(78%, 640px);
    display: grid;
    gap: 4px;
    padding: 10px 12px 8px;
}

.bubble .who, .bubble time {
    color: rgba(255, 255, 255, 0.72);
    font-size: 0.75rem;
}

.bubble .body {
    margin: 0;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    line-height: 1.75;
}

.bubble.assistant {
    align-self: flex-start;
    background: rgba(16, 24, 58, 0.92);
    border: 1px solid var(--line);
    border-radius: 18px 18px 6px 18px;
}

.bubble.user {
    align-self: flex-end;
    background: linear-gradient(145deg, #6d4aff, #3557e0);
    border-radius: 18px 18px 18px 6px;
}

.bubble.pending .body { opacity: 0.75; }

.composer {
    padding: 12px 16px 14px;
    border-top: 1px solid var(--line);
    background: rgba(7, 11, 26, 0.72);
}

.composer-row {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.composer-row textarea { flex: 1; }
.composer-row .primary { min-width: 84px; min-height: 52px; }
.hint { padding-bottom: 2px; }

@media (max-width: 720px) {
    .shell { width: 100%; border-right: 0; border-left: 0; }
    .top { align-items: flex-start; }
    .top-actions { flex-direction: column; align-items: flex-end; }
    .bubble { width: min(92%, 640px); }
    .card { padding: 22px 16px 16px; }
}

@media (prefers-reduced-motion: reduce) {
    * { scroll-behavior: auto !important; }
}
