:root {
    color-scheme: light;
    --blue: #1d4f91;
    --blue-dark: #112b4f;
    --gold: #f4be3b;
    --ink: #171d27;
    --muted: #626d7d;
    --line: #d9e0ea;
    --surface: #ffffff;
    --paper: #f5f2ea;
    --green: #2f7d5b;
    --red: #c94c3a;
    --shadow: 0 18px 42px rgba(23, 29, 39, 0.1);
}

* {
    box-sizing: border-box;
}

html {
    min-width: 320px;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
    font: inherit;
}

button {
    -webkit-tap-highlight-color: transparent;
}

a {
    color: var(--blue);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

.shell {
    width: min(1200px, calc(100% - 32px));
    margin: 0 auto;
}

.hero {
    position: relative;
    min-height: 360px;
    display: grid;
    align-items: end;
    overflow: hidden;
    background:
        linear-gradient(90deg, rgba(17, 43, 79, 0.96), rgba(17, 43, 79, 0.72) 48%, rgba(17, 43, 79, 0.2)),
        url("https://commons.wikimedia.org/wiki/Special:FilePath/Chase_Center_-_Warriors.jpg?width=1600") center / cover;
}

.hero::after {
    content: "";
    position: absolute;
    inset: auto 0 0;
    height: 9px;
    background: linear-gradient(90deg, var(--gold), var(--green), var(--red), var(--blue));
}

.hero-inner {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 20px;
    align-items: end;
    width: min(1200px, calc(100% - 32px));
    margin: 0 auto;
    padding: 56px 0 48px;
}

.hero-credit {
    position: absolute;
    right: 0;
    bottom: 16px;
    margin: 0;
    color: rgba(255, 255, 255, 0.68);
    font-size: 0.72rem;
    font-weight: 650;
}

.hero-copy {
    max-width: 780px;
    color: #fff;
}

.eyebrow {
    margin: 0 0 6px;
    color: var(--blue);
    font-size: 0.76rem;
    font-weight: 850;
    letter-spacing: 0;
    text-transform: uppercase;
}

.hero .eyebrow {
    color: var(--gold);
}

h1 {
    margin-bottom: 12px;
    font-size: clamp(2.7rem, 2.15rem + 3vw, 5.7rem);
    line-height: 0.92;
    letter-spacing: 0;
}

h2 {
    margin-bottom: 0;
    font-size: 1.18rem;
    line-height: 1.25;
    letter-spacing: 0;
}

h3 {
    margin-bottom: 8px;
    font-size: 1rem;
    line-height: 1.3;
    letter-spacing: 0;
}

.lede {
    max-width: 700px;
    margin-bottom: 0;
    color: rgba(255, 255, 255, 0.86);
    font-size: 1.05rem;
    line-height: 1.6;
}

.status-pill {
    display: inline-flex;
    min-height: 38px;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, 0.34);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    font-size: 0.82rem;
    font-weight: 850;
    padding: 0 14px;
    white-space: nowrap;
    backdrop-filter: blur(14px);
}

.status-pill.error {
    border-color: rgba(255, 255, 255, 0.5);
    background: rgba(201, 76, 58, 0.34);
}

.mode-switch {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin-top: -38px;
    position: relative;
    z-index: 2;
}

.mode-card {
    min-height: 116px;
    border: 1px solid rgba(17, 43, 79, 0.14);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: var(--shadow);
    color: var(--ink);
    cursor: pointer;
    padding: 18px;
    text-align: left;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.mode-card:hover {
    border-color: rgba(29, 79, 145, 0.45);
    transform: translateY(-2px);
}

.mode-card.is-active {
    border-color: var(--blue);
    background: var(--blue);
    color: #fff;
    box-shadow: 0 18px 42px rgba(29, 79, 145, 0.16);
}

.mode-card span {
    display: block;
    margin-bottom: 14px;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 850;
    text-transform: uppercase;
}

.mode-card.is-active span {
    color: rgba(255, 255, 255, 0.74);
}

.mode-card strong {
    display: block;
    font-size: clamp(1.35rem, 1.1rem + 1vw, 2.1rem);
    line-height: 1.05;
    letter-spacing: 0;
}

.view {
    padding-top: 24px;
}

.view[hidden] {
    display: none;
}

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

.control-button {
    display: inline-flex;
    min-height: 38px;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    color: #344054;
    cursor: pointer;
    font-size: 0.86rem;
    font-weight: 850;
    padding: 0 12px;
    transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.control-button:hover {
    border-color: rgba(29, 79, 145, 0.42);
    color: var(--blue);
}

.control-button.is-active {
    border-color: var(--blue);
    background: var(--blue);
    color: #fff;
}

.control-group.compact {
    justify-content: flex-end;
}

.control-group.compact .control-button {
    min-height: 34px;
    font-size: 0.8rem;
    padding: 0 10px;
}

.story-heading {
    max-width: 760px;
    margin: 0 auto 22px;
    text-align: center;
}

.story-heading h2 {
    font-size: clamp(1.7rem, 1.35rem + 1.2vw, 2.6rem);
}

.story-heading p:last-child {
    margin: 12px auto 0;
    color: #475467;
    font-size: 0.98rem;
    line-height: 1.6;
}

.story-track {
    position: relative;
    display: grid;
    gap: 34px;
    padding: 8px 0 36px;
}

.story-track::before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: calc(50% - 2px);
    width: 4px;
    border-radius: 999px;
    background: linear-gradient(180deg, var(--blue), var(--gold), var(--green), var(--red));
}

.story-event {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 96px minmax(0, 1fr);
    gap: 18px;
    min-height: 288px;
    opacity: 0.66;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.story-event:hover,
.story-event:focus-within,
.story-event.is-visible {
    opacity: 1;
}

.story-event:hover {
    transform: translateY(-2px);
}

.story-side {
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 14px 34px rgba(23, 29, 39, 0.08);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.story-event:hover .story-side,
.story-event:focus-within .story-side {
    border-color: #111827;
    box-shadow: 0 0 0 3px #111827, 0 18px 42px rgba(17, 24, 39, 0.16);
}

.story-event:nth-child(even) .story-visual {
    grid-column: 3;
}

.story-event:nth-child(even) .story-copy-card {
    grid-column: 1;
    grid-row: 1;
}

.story-year-node {
    position: relative;
    z-index: 1;
    display: grid;
    grid-column: 2;
    grid-row: 1;
    align-items: center;
    justify-items: center;
}

.story-year-node span {
    display: inline-flex;
    min-width: 76px;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    border: 3px solid var(--paper);
    border-radius: 999px;
    background: var(--blue);
    color: #fff;
    font-size: 0.88rem;
    font-weight: 900;
    box-shadow: 0 0 0 2px var(--blue);
    transition: background 0.2s ease, box-shadow 0.2s ease;
}

.story-event:hover .story-year-node span,
.story-event:focus-within .story-year-node span {
    background: #111827;
    box-shadow: 0 0 0 2px #111827;
}

.story-visual {
    position: relative;
    min-height: 288px;
    margin: 0;
    overflow: hidden;
    background: #07111f;
}

.story-visual::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
    background:
        radial-gradient(circle at 70% 18%, rgba(244, 190, 59, 0.16), transparent 36%),
        linear-gradient(180deg, rgba(7, 17, 31, 0.08), rgba(7, 17, 31, 0.58));
    pointer-events: none;
}

.story-visual img {
    width: 100%;
    height: 100%;
    min-height: 288px;
    object-fit: cover;
    display: block;
    filter: brightness(0.58) contrast(1.12) saturate(0.92);
    transform: scale(1.015);
    transition: filter 0.2s ease, transform 0.2s ease;
}

.story-event:hover .story-visual img,
.story-event:focus-within .story-visual img {
    filter: brightness(0.74) contrast(1.08) saturate(1);
    transform: scale(1.045);
}

.story-visual figcaption {
    position: absolute;
    right: 8px;
    bottom: 8px;
    z-index: 2;
    border-radius: 999px;
    background: rgba(7, 17, 31, 0.82);
    color: #fff;
    font-size: 0.68rem;
    font-weight: 750;
    padding: 4px 8px;
}

.story-copy-card {
    align-self: stretch;
    display: grid;
    align-content: center;
    padding: 28px;
}

.story-copy-card h3 {
    margin-bottom: 12px;
    font-size: clamp(1.32rem, 1.08rem + 0.9vw, 2.05rem);
    line-height: 1.08;
}

.story-copy-card p {
    color: #475467;
    line-height: 1.68;
}

.story-copy-card > p:last-of-type {
    margin-bottom: 0;
}

.timeline-date {
    margin: 0 0 8px;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 900;
}

.tag-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 14px;
}

.tag {
    border-radius: 999px;
    background: #eef2f8;
    color: #354052;
    font-size: 0.72rem;
    font-weight: 850;
    padding: 4px 8px;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.metric-card {
    min-height: 112px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    padding: 16px;
}

.metric-label {
    margin: 0 0 8px;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 850;
    text-transform: uppercase;
}

.metric-value {
    margin: 0;
    font-size: 1.72rem;
    font-weight: 900;
    letter-spacing: 0;
}

.metric-note {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 0.84rem;
    line-height: 1.35;
}

.chart-panel,
.sources-section {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.94);
    box-shadow: var(--shadow);
}

.chart-panel {
    min-width: 0;
    margin-top: 16px;
    padding: 16px;
}

.panel-heading,
.section-heading {
    display: flex;
    gap: 16px;
    align-items: start;
    justify-content: space-between;
    margin-bottom: 14px;
}

.panel-actions {
    display: grid;
    gap: 8px;
    justify-items: end;
}

.panel-actions.wide {
    max-width: 610px;
}

.panel-meta {
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 850;
    white-space: nowrap;
}

.panel-note {
    max-width: 620px;
    margin: 8px 0 0;
    color: #667085;
    font-size: 0.88rem;
    line-height: 1.45;
}

.chart {
    width: 100%;
    min-height: 390px;
}

.chart.small {
    min-height: 310px;
}

.analysis-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(340px, 0.75fr);
    gap: 16px;
    align-items: stretch;
}

.data-drawer {
    min-width: 0;
    border-left: 1px solid var(--line);
    padding-left: 16px;
}

.drawer-heading {
    margin-bottom: 10px;
}

.drawer-heading h3 {
    margin: 0;
}

.workspace {
    display: grid;
    grid-template-columns: minmax(0, 1.55fr) minmax(300px, 0.8fr);
    gap: 16px;
    margin-top: 0;
}

.workspace.split {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.table-wrap {
    max-height: 390px;
    overflow: auto;
}

table {
    width: 100%;
    min-width: 520px;
    border-collapse: collapse;
}

th,
td {
    border-bottom: 1px solid var(--line);
    padding: 11px 10px;
    text-align: left;
    vertical-align: top;
}

th {
    position: sticky;
    top: 0;
    background: var(--surface);
    color: #344054;
    font-size: 0.74rem;
    text-transform: uppercase;
}

td {
    color: #475467;
    font-size: 0.88rem;
}

.sources-section {
    margin: 18px 0 56px;
    padding: 16px;
}

.sources {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.source-item {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    padding: 14px;
}

.source-item strong {
    display: block;
    margin-bottom: 6px;
    color: var(--ink);
}

.source-item span {
    display: block;
    color: var(--muted);
    font-size: 0.82rem;
    line-height: 1.4;
}

.empty-state {
    display: grid;
    min-height: 180px;
    place-items: center;
    color: var(--muted);
    text-align: center;
}

@media (max-width: 1020px) {
    .analysis-layout,
    .workspace,
    .workspace.split {
        grid-template-columns: 1fr;
    }

    .data-drawer {
        border-left: 0;
        border-top: 1px solid var(--line);
        padding: 16px 0 0;
    }

    .metric-grid,
    .sources {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 720px) {
    .shell,
    .hero-inner {
        width: min(100% - 20px, 1200px);
    }

    .hero {
        min-height: 420px;
    }

    .hero-inner,
    .mode-switch,
    .story-event,
    .metric-grid,
    .sources {
        grid-template-columns: 1fr;
    }

    .status-pill {
        justify-self: start;
    }

    .hero-credit {
        left: 0;
        right: auto;
    }

    .mode-switch {
        margin-top: -28px;
    }

    .mode-card {
        min-height: 96px;
    }

    .story-track {
        gap: 24px;
        padding-left: 0;
    }

    .story-track::before {
        left: 28px;
    }

    .story-event,
    .story-event:nth-child(even) {
        grid-template-columns: 58px minmax(0, 1fr);
        gap: 12px;
        min-height: 0;
    }

    .story-event .story-visual,
    .story-event:nth-child(even) .story-visual {
        grid-column: 2;
        grid-row: 1;
    }

    .story-event .story-copy-card,
    .story-event:nth-child(even) .story-copy-card {
        grid-column: 2;
        grid-row: 2;
    }

    .story-year-node,
    .story-event:nth-child(even) .story-year-node {
        grid-column: 1;
        grid-row: 1 / span 2;
        align-items: start;
        padding-top: 14px;
    }

    .story-year-node span {
        min-width: 52px;
        min-height: 38px;
        font-size: 0.78rem;
    }

    .story-copy-card {
        padding: 18px;
    }

    .story-visual,
    .story-visual img {
        min-height: 210px;
    }

    .panel-heading {
        display: grid;
    }

    .panel-actions,
    .control-group.compact {
        justify-items: start;
        justify-content: flex-start;
    }

    .chart {
        min-height: 330px;
    }

    .chart.small {
        min-height: 300px;
    }
}
