:root {
    color-scheme: dark;
    --background: #0b0d10;
    --surface: #15191f;
    --surface-raised: #1d232b;
    --border: #2a333e;
    --text: #f5f7fa;
    --muted: #919ba7;
    --accent: #a8ff78;
    --accent-dark: #172619;
    --danger: #ff8f8f;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(circle at 20% 0%, rgba(94, 73, 255, .12), transparent 34rem),
        radial-gradient(circle at 85% 90%, rgba(168, 255, 120, .08), transparent 30rem),
        var(--background);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.topbar {
    min-height: 82px;
    padding: 16px clamp(20px, 5vw, 72px);
    border-bottom: 1px solid var(--border);
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 28px;
    background: rgba(11, 13, 16, .82);
    backdrop-filter: blur(16px);
}

.brand { color: var(--text); text-decoration: none; font-weight: 750; font-size: 20px; }
.brand-mark { color: var(--accent); margin-right: 8px; font-family: ui-monospace, monospace; }
.category-picker { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 14px; }
select { min-width: 220px; padding: 11px 36px 11px 14px; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; font: inherit; }
.progress { color: var(--muted); font-size: 13px; text-align: right; }
.topbar-account { display: flex; justify-content: flex-end; align-items: center; gap: 12px; }
.topbar-account form { margin: 0; }
.user-email { max-width: 180px; overflow: hidden; color: var(--muted); font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.account-link, .link-button { color: var(--text); font-size: 13px; font-weight: 650; text-decoration: none; }
.account-link-primary { padding: 9px 12px; border: 1px solid rgba(168, 255, 120, .32); border-radius: 9px; color: var(--accent); background: var(--accent-dark); }
.link-button { padding: 0; border: 0; background: transparent; }
.link-button:hover, .account-link:hover { color: var(--accent); }

.stage {
    width: min(1100px, calc(100% - 32px));
    margin: 0 auto;
    min-height: calc(100vh - 150px);
    display: grid;
    grid-template-columns: 56px minmax(0, 820px) 56px;
    justify-content: center;
    align-items: start;
    gap: clamp(12px, 3vw, 34px);
    padding: clamp(60px, 10vh, 120px) 0 60px;
}

.content-column { min-width: 0; }
.card { min-height: 410px; padding: clamp(28px, 5vw, 60px); border: 1px solid var(--border); border-radius: 24px; background: rgba(21, 25, 31, .9); box-shadow: 0 28px 80px rgba(0, 0, 0, .3); }
.eyebrow { color: var(--accent); font-size: 12px; font-weight: 750; letter-spacing: .14em; text-transform: uppercase; }
h1 { margin: 18px 0 12px; font: 700 clamp(36px, 7vw, 72px)/1 ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: -.06em; overflow-wrap: anywhere; }
.prompt { margin: 0; color: var(--muted); font-size: 17px; }
.actions { display: flex; gap: 10px; margin-top: 34px; }
button { font: inherit; cursor: pointer; }
.primary, .secondary, .known { padding: 12px 18px; border-radius: 10px; font-weight: 700; }
.primary { color: #0b0d10; background: var(--accent); border: 1px solid var(--accent); }
.secondary { color: var(--text); background: var(--surface-raised); border: 1px solid var(--border); }
.known { color: var(--accent); background: var(--accent-dark); border: 1px solid rgba(168, 255, 120, .32); }
.full-button { display: block; margin-top: 24px; }
.primary:hover { filter: brightness(.92); }
.secondary:hover, .known:hover { border-color: var(--muted); }

.nav-button { width: 56px; height: 56px; margin-top: 146px; border: 1px solid var(--border); border-radius: 50%; color: var(--text); background: var(--surface); font-size: 24px; transition: .15s ease; }
.nav-button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); transform: translateY(-2px); }
.nav-button:disabled { opacity: .25; cursor: default; }

.answer, .manual { margin-top: 28px; padding-top: 26px; border-top: 1px solid var(--border); color: #dce2e8; line-height: 1.7; }
.answer p:first-child { margin-top: 0; font-size: 19px; }
.manual h2, .manual h3 { margin-top: 32px; color: var(--text); line-height: 1.25; }
pre { overflow-x: auto; padding: 18px; border: 1px solid var(--border); border-radius: 12px; background: #0d1014; color: #d8ffca; line-height: 1.55; }
code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px; border: 1px solid var(--border); text-align: left; }
a { color: var(--accent); }
.source { display: inline-block; margin-top: 22px; font-size: 14px; }
.loading { margin-top: 24px; color: var(--muted); }
.error { margin-top: 24px; color: var(--danger); }
.statistics { margin-top: 18px; padding: 20px 24px; border: 1px solid var(--border); border-radius: 16px; background: rgba(21, 25, 31, .72); display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.statistics-title { font-weight: 750; }
.statistics-hint { margin-top: 4px; color: var(--muted); font-size: 12px; }
.statistics dl { display: flex; gap: 30px; margin: 0; }
.statistics dl > div { min-width: 70px; }
.statistics dt { color: var(--muted); font-size: 12px; }
.statistics dd { margin: 3px 0 0; color: var(--accent); font: 700 24px/1 ui-monospace, monospace; }
.category-statistics { margin-top: 18px; padding: 20px 24px; border: 1px solid var(--border); border-radius: 16px; background: rgba(21, 25, 31, .72); }
.category-statistics dl { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 18px 28px; margin: 22px 0 0; }
.category-statistics dl > div { min-width: 0; }
.category-statistics dt { overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.category-statistics dd { margin: 5px 0 0; color: var(--accent); font: 700 20px/1 ui-monospace, monospace; }
.hidden { display: none !important; }
footer { padding: 0 20px 28px; color: #65707c; font-size: 12px; text-align: center; }
.auth-stage { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: min(100%, 460px); padding: clamp(28px, 6vw, 48px); border: 1px solid var(--border); border-radius: 24px; background: rgba(21, 25, 31, .94); box-shadow: 0 28px 80px rgba(0, 0, 0, .3); }
.auth-brand { display: inline-block; margin-bottom: 36px; }
.auth-title { margin: 0 0 10px; font: 700 36px/1.1 Inter, ui-sans-serif, system-ui, sans-serif; letter-spacing: -.035em; }
.auth-subtitle { margin: 0 0 28px; color: var(--muted); line-height: 1.5; }
.auth-form { display: grid; gap: 18px; }
.auth-form label { display: grid; gap: 8px; color: #dce2e8; font-size: 14px; font-weight: 650; }
.auth-form input { width: 100%; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; outline: none; color: var(--text); background: #0d1014; font: inherit; }
.auth-form input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(168, 255, 120, .1); }
.auth-form .primary { margin-top: 4px; }
.form-errors { margin-bottom: 22px; padding: 12px 14px; border: 1px solid rgba(255, 143, 143, .3); border-radius: 10px; color: var(--danger); background: rgba(255, 143, 143, .07); font-size: 14px; }
.form-errors p { margin: 0; }
.form-errors p + p { margin-top: 6px; }
.auth-switch { margin: 24px 0 0; color: var(--muted); font-size: 14px; text-align: center; }

@media (max-width: 760px) {
    .topbar { grid-template-columns: 1fr; gap: 12px; }
    .category-picker { align-items: stretch; flex-direction: column; }
    select { width: 100%; }
    .progress { display: none; }
    .topbar-account { justify-content: flex-start; flex-wrap: wrap; }
    .stage { grid-template-columns: 46px minmax(0, 1fr) 46px; gap: 8px; padding-top: 40px; width: calc(100% - 16px); }
    .content-column { grid-column: 1 / -1; grid-row: 1; }
    .card { padding: 28px 22px; }
    .nav-button { position: relative; z-index: 2; grid-row: 2; margin: 8px 0 0; width: 46px; height: 46px; }
    .nav-prev { grid-column: 1; }
    .nav-next { grid-column: 3; }
    h1 { font-size: clamp(34px, 12vw, 58px); }
    .actions { flex-wrap: wrap; }
    .statistics { align-items: flex-start; flex-direction: column; }
}
