:root {
    --bg: #0a0a0a;
    --panel: #141414;
    --panel-2: #1a1a1a;
    --border: #262626;
    --text: #ededed;
    --muted: #8f8f8f;
    --red: #e02020;
    --red-strong: #ff4a3d;

    --font-display: "Archivo", -apple-system, BlinkMacSystemFont, sans-serif;
    --font-body: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
}

* { box-sizing: border-box; }

/* ---- Scrollbars: match the palette instead of the OS default ---- */
html {
    scrollbar-width: thin;
    scrollbar-color: #3a3a3a var(--panel-2);
}
*::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
*::-webkit-scrollbar-track {
    background: var(--panel-2);
}
*::-webkit-scrollbar-thumb {
    background: #3a3a3a;
    border-radius: 4px;
}
*::-webkit-scrollbar-thumb:hover {
    background: var(--red);
}

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    height: 100%;
}

body { min-height: 100vh; }

.muted { color: var(--muted); }

.screen {
    display: none;
    min-height: 100vh;
}
.screen.active { display: flex; }

.rule {
    width: 56px;
    height: 4px;
    background: var(--red);
    margin: 0 0 28px;
}
.rule-error { background: var(--red-strong); }

/* ============ Query screen ============ */
#query-screen {
    align-items: center;
    justify-content: center;
    padding: 32px 24px;
}
.query-layout {
    width: 100%;
    max-width: 1080px;
    display: flex;
    gap: 56px;
    align-items: flex-start;
}
.query-main {
    flex: 1 1 480px;
    min-width: 0;
}
.brand {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 40px;
    letter-spacing: -0.5px;
    margin: 0 0 12px;
}
.lede {
    color: var(--muted);
    font-size: 17px;
    line-height: 1.5;
    margin: 0 0 32px;
    max-width: 46ch;
}

.query-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.query-form textarea {
    background: var(--panel);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 16px;
    font-size: 15px;
    line-height: 1.6;
    font-family: var(--font-body);
    resize: vertical;
    min-height: 160px;
}
.query-form textarea::placeholder { color: #5c5c5c; }
.query-form textarea:focus {
    outline: none;
    border-color: var(--red);
}
.query-form button {
    align-self: flex-start;
    background: var(--red);
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 14px 28px;
    font-size: 15px;
    font-weight: 600;
    font-family: var(--font-body);
    cursor: pointer;
    transition: background 150ms ease;
}
.query-form button:hover { background: var(--red-strong); }
.query-form button:disabled {
    background: var(--panel-2);
    color: var(--muted);
    cursor: not-allowed;
}

/* ---- Examples side panel ---- */
.examples-panel {
    flex: 0 0 300px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 20px;
    max-height: 560px;
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.examples-panel h2 {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 15px;
    margin: 0 0 4px;
}
.examples-hint {
    font-size: 13px;
    margin: 0 0 14px;
}
.examples-list {
    list-style: none;
    margin: 0;
    padding: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-height: 0;
}
.example-item {
    width: 100%;
    text-align: left;
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
    border-left: 2px solid transparent;
    border-radius: 3px;
    padding: 10px 12px;
    font-size: 13.5px;
    line-height: 1.4;
    font-family: var(--font-body);
    cursor: pointer;
    transition: border-color 120ms ease, background 120ms ease;
}
.example-item:hover {
    border-color: var(--red);
    border-left-color: var(--red);
    background: var(--panel-2);
}
.example-item:focus-visible {
    outline: 2px solid var(--red);
    outline-offset: 1px;
}

/* ============ Progress screen ============ */
#progress-screen {
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.progress-wrap {
    width: 100%;
    max-width: 480px;
}
#progress-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 28px;
    margin: 0 0 8px;
}
#progress-caption {
    margin: 0 0 28px;
    font-size: 15px;
    min-height: 1.3em;
}

.progress-bar-track {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 3px;
    height: 6px;
    overflow: hidden;
}
.progress-bar-fill {
    height: 100%;
    width: 0%;
    background: var(--red);
    box-shadow: 0 0 12px 0 rgba(224, 32, 32, 0.6);
    /* Duration is also set inline from app.js (PROGRESS_DURATION_MS)
       so the two stay in sync; this is the fallback value. */
    transition: width 20000ms linear;
}

/* ============ Dashboard (single screen, no scroll on desktop) ============ */
#dashboard-screen {
    align-items: stretch;
    justify-content: flex-start;
    padding: 32px 40px;
}
.dashboard {
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 64px);
}

.dashboard-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 24px;
    flex-shrink: 0;
}
.eyebrow-mark {
    display: block;
    width: 32px;
    height: 3px;
    background: var(--red);
    margin-bottom: 10px;
}
.dashboard-header h2 {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 26px;
    margin: 0;
    max-width: 60ch;
}

#restart-btn,
#error-restart-btn {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 9px 18px;
    font-size: 14px;
    font-family: var(--font-body);
    cursor: pointer;
    white-space: nowrap;
    transition: border-color 150ms ease, color 150ms ease;
    flex-shrink: 0;
}
#restart-btn:hover,
#error-restart-btn:hover {
    border-color: var(--red);
    color: var(--red-strong);
}

.dashboard-grid {
    flex: 1 1 auto;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    min-height: 0;
}
.dashboard-col {
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-height: 0;
}
.report-card {
    background: var(--panel);
    border: 1px solid var(--border);
    padding: 22px;
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex: 1 1 0;
}
.report-card h3 {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 13px;
    color: var(--red-strong);
    margin: 0 0 14px;
    flex-shrink: 0;
}

/* Only this inner region scrolls — the header above and any CTA
   below (e.g. the story button) stay put. */
.card-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding-right: 6px;
}
.report-card p {
    margin: 0 0 12px;
    line-height: 1.55;
    font-size: 14.5px;
    color: var(--text);
}
.bullets {
    margin: 0 0 4px;
    padding-left: 18px;
}
.bullets li {
    margin: 6px 0;
    line-height: 1.5;
    font-size: 14px;
    color: var(--muted);
}

/* ---- Success story card: the outbound link is the emphasis here ---- */
.success-card {
    flex: 1 1 0;
}
.story-link-btn {
    flex-shrink: 0;
    margin-top: 14px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    background: var(--red);
    color: #fff;
    text-decoration: none;
    border-radius: 4px;
    padding: 14px 16px;
    transition: background 150ms ease;
}
.story-link-btn:hover { background: var(--red-strong); }
.story-link-btn.is-disabled {
    background: var(--panel-2);
    color: var(--muted);
    cursor: default;
    pointer-events: none;
}
.story-link-btn.is-disabled .story-link-title { color: var(--muted); }
.story-link-label {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 14px;
}
.story-link-title {
    font-size: 12.5px;
    color: rgba(255, 255, 255, 0.85);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---- Why Nitor: takes the leftover space in its column so the
   next-step card below doesn't have to stretch to fill it ---- */
.why-nitor-card {
    flex: 1 1 auto;
}

/* ---- Next step card: sized to its content, not the column — it
   should read as a callout, not another equal-height panel ---- */
.next-step-card {
    flex: 0 0 auto;
    background: var(--panel-2);
    border: 1px solid var(--red);
    box-shadow: 0 0 0 1px rgba(224, 32, 32, 0.15), 0 8px 24px -12px rgba(224, 32, 32, 0.45);
    padding: 18px 22px;
}
.contact-btn {
    align-self: flex-start;
    margin-top: 4px;
    background: transparent;
    color: var(--red-strong);
    border: 1px solid var(--red-strong);
    text-decoration: none;
    border-radius: 4px;
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 600;
    transition: background 150ms ease, color 150ms ease;
}
.contact-btn:hover {
    background: var(--red-strong);
    color: #0a0a0a;
}

/* ============ Error screen ============ */
#error-screen {
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.error-wrap {
    width: 100%;
    max-width: 480px;
}
.error-wrap h2 {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 26px;
    margin: 0 0 10px;
}
#error-message { margin: 0 0 24px; font-size: 15px; }

/* ============ Responsive ============ */
@media (max-width: 900px) {
    .query-layout { flex-direction: column; }
    .examples-panel { max-height: 320px; width: 100%; }

    #dashboard-screen { padding: 20px; }
    .dashboard { height: auto; }
    .dashboard-grid { grid-template-columns: 1fr; }
    .dashboard-header { flex-wrap: wrap; }

    /* The desktop layout relies on flex-basis:0 + min-height:0 so
       cards can shrink to fit one viewport. On mobile there's no
       fixed viewport to fit into, so those same rules just collapse
       the cards to near-nothing and the text overlaps. Switch every
       card back to sizing off its own content. */
    .report-card {
        flex: none;
        min-height: auto;
    }
    .card-scroll {
        flex: none;
        overflow: visible;
        max-height: none;
    }
    .next-step-card {
        box-shadow: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .progress-bar-fill { transition: none; }
}