﻿:root {
    color-scheme: light dark;
    --background: #f8fafc;
    --surface: #ffffff;
    --surface-muted: #eef4f8;
    --text: #17212b;
    --muted: #5d6b78;
    --line: #d9e2ea;
    --accent: #1f7a8c;
    --accent-strong: #155f70;
    --danger: #b42318;
    --shadow: 0 18px 55px rgba(23, 33, 43, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--background);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.5;
}

button,
textarea {
    font: inherit;
}

.home-shell {
    width: min(920px, calc(100% - 32px));
    margin: 0 auto;
    padding: 72px 0 56px;
}

.hero {
    padding: 0 0 38px;
    border-bottom: 1px solid var(--line);
    text-align: center;
}

.brand {
    margin: 0 0 18px;
    font-size: 0.84rem;
    font-weight: 800;
    letter-spacing: 0;
    color: var(--accent-strong);
}

.hero h1 {
    margin: 0;
    font-size: clamp(2.15rem, 7vw, 4.7rem);
    line-height: 1.03;
    font-weight: 750;
    letter-spacing: 0;
}

.hero-copy {
    max-width: 680px;
    margin: 22px auto 0;
    color: var(--muted);
    font-size: 1.08rem;
}

.ask-section {
    padding: 42px 0 34px;
    border-bottom: 1px solid var(--line);
}

.ask-form {
    display: grid;
    gap: 18px;
}

textarea {
    width: 100%;
    min-height: 140px;
    resize: vertical;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 20px;
    background: var(--surface);
    color: var(--text);
    outline: none;
    box-shadow: var(--shadow);
}

textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent), var(--shadow);
}

.examples {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.examples button {
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 9px 12px;
    background: var(--surface);
    color: var(--muted);
    cursor: pointer;
}

.examples button:hover,
.examples button:focus-visible {
    border-color: var(--accent);
    color: var(--accent-strong);
}

.ask-button {
    justify-self: center;
    min-width: 210px;
    border: 0;
    border-radius: 8px;
    padding: 14px 22px;
    background: var(--accent);
    color: #ffffff;
    font-weight: 700;
    cursor: pointer;
}

.ask-button:hover,
.ask-button:focus-visible {
    background: var(--accent-strong);
}

.ask-button:disabled {
    opacity: 0.65;
    cursor: wait;
}

.status-panel,
.error-panel,
.answer-section {
    margin-top: 34px;
    padding-top: 32px;
    border-top: 1px solid var(--line);
}

.status-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: var(--muted);
}

.spinner {
    width: 22px;
    height: 22px;
    border: 3px solid var(--line);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.answer-section h2,
.sources-block h3 {
    margin: 0 0 14px;
    font-size: 1rem;
    font-weight: 800;
}

.answer-section p {
    margin: 0;
    color: var(--text);
    white-space: pre-line;
    font-size: 1.06rem;
}

.sources-block {
    margin-top: 30px;
}

.sources-block ul {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.sources-block li {
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 8px 12px;
    background: var(--surface-muted);
    color: var(--muted);
}

.error-panel {
    color: var(--danger);
    text-align: center;
    font-weight: 700;
}

.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;
}

[hidden] {
    display: none !important;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@media (max-width: 640px) {
    .home-shell {
        width: min(100% - 24px, 920px);
        padding-top: 44px;
    }

    .hero {
        text-align: left;
    }

    .hero-copy {
        margin-left: 0;
    }

    .ask-button {
        width: 100%;
    }
}

@media (prefers-color-scheme: dark) {
    :root {
        --background: #11161b;
        --surface: #171e25;
        --surface-muted: #1d2831;
        --text: #edf2f7;
        --muted: #a5b3c0;
        --line: #2c3945;
        --accent: #48a9b9;
        --accent-strong: #76c5d1;
        --danger: #ffb4ab;
        --shadow: 0 18px 55px rgba(0, 0, 0, 0.28);
    }
}
