:root {
    --bg: #fbfbfa;
    --surface: #ffffff;
    --border: #e3e1dd;
    --text: #1f1e1c;
    --muted: #6b6862;
    --accent: #2f5d87;
    --accent-soft: #eef3f8;
    --radius: 8px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #17181a;
        --surface: #1e2022;
        --border: #32353a;
        --text: #e8e6e3;
        --muted: #9a968f;
        --accent: #7fb0dd;
        --accent-soft: #212a33;
    }
}

* { box-sizing: border-box; }

/*
 * The `hidden` attribute is only `display: none` in the UA stylesheet, so any author
 * rule setting `display` (the flex containers below) silently overrides it.
 */
[hidden] { display: none !important; }

body {
    margin: 0;
    padding: 0 16px 64px;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

.masthead, main, footer { max-width: 820px; margin: 0 auto; }

.masthead {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
    padding: 40px 0 24px;
}

.account { display: flex; align-items: center; gap: 10px; min-height: 40px; }

#account-details { display: flex; align-items: center; gap: 8px; font-size: 0.88rem; }

#account-email { color: var(--muted); }

#signout {
    padding: 5px 12px;
    font: inherit;
    font-size: 0.82rem;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
}
.masthead h1 { margin: 0; font-size: 1.6rem; letter-spacing: -0.01em; }
.subtitle { margin: 6px 0 0; color: var(--muted); font-size: 0.95rem; }

.ask { display: flex; gap: 8px; flex-wrap: wrap; }

.ask input[type="text"] {
    flex: 1 1 320px;
    min-width: 0;
    padding: 11px 14px;
    font-size: 1rem;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.ask input[type="text"]:focus-visible,
.ask select:focus-visible,
button:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

.ask select {
    padding: 11px 12px;
    font-size: 0.95rem;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.ask button[type="submit"] {
    padding: 11px 22px;
    font-size: 0.95rem;
    font-weight: 600;
    color: #fff;
    background: var(--accent);
    border: 1px solid transparent;
    border-radius: var(--radius);
    cursor: pointer;
}

.ask button[type="submit"]:disabled { opacity: 0.55; cursor: progress; }

.examples { margin: 14px 0 0; color: var(--muted); font-size: 0.85rem; }

.example {
    margin: 3px 4px 3px 0;
    padding: 4px 10px;
    font: inherit;
    font-size: 0.82rem;
    color: var(--accent);
    background: var(--accent-soft);
    border: 1px solid var(--border);
    border-radius: 999px;
    cursor: pointer;
}

.status {
    margin-top: 28px;
    padding: 14px 16px;
    color: var(--muted);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.92rem;
}

.status.error {
    color: #8c2f2f;
    background: #fdf1f1;
    border-color: #f0d4d4;
}

@media (prefers-color-scheme: dark) {
    .status.error { color: #f0b4b4; background: #2c1e1e; border-color: #4a3030; }
}

.status code {
    padding: 1px 5px;
    background: var(--accent-soft);
    border-radius: 4px;
    font-size: 0.88em;
}

.answer {
    margin-top: 28px;
    padding: 4px 24px 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.summary h2 {
    margin: 26px 0 8px;
    padding-bottom: 5px;
    font-size: 0.82rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--muted);
    border-bottom: 1px solid var(--border);
}

.summary p:first-child strong { font-size: 1.06rem; }
.summary ul { padding-left: 20px; }
.summary li { margin: 5px 0; }

.sources { margin-top: 28px; }
.sources h2 { font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); }
.sources ol { padding-left: 20px; margin: 0; }
.sources li { margin-bottom: 14px; }

.source-title { font-weight: 600; }

.tag {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 8px;
    font-size: 0.72rem;
    color: var(--muted);
    background: var(--accent-soft);
    border-radius: 999px;
    vertical-align: middle;
}

.source-snippet { margin: 4px 0 0; color: var(--muted); font-size: 0.88rem; }
.source-uri { margin: 3px 0 0; color: var(--muted); font-size: 0.76rem; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; word-break: break-all; }

footer { margin-top: 48px; color: var(--muted); font-size: 0.8rem; }

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