:root {
    --sc-bg: oklch(1 0 0);
    --sc-surface: oklch(0.97 0.006 60);
    --sc-ink: oklch(0.20 0.020 55);
    --sc-muted: oklch(0.44 0.025 55);
    --sc-border: oklch(0.88 0.012 60);
    --sc-honey: oklch(0.62 0.15 58);
    --sc-honey-dark: oklch(0.42 0.12 55);
    --sc-berry: oklch(0.36 0.13 18);
    --sc-focus: oklch(0.62 0.15 58 / 0.28);
}

.sc-page {
    width: min(100% - 32px, 1440px);
    max-width: 1440px;
    color: var(--sc-ink);
    padding-top: 24px;
    font-family: Inter, "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 1rem;
}

.sc-heading,
.sc-atlas-head,
.sc-evidence-head,
.sc-selection,
.sc-legend-head,
.sc-total > div {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sc-heading {
    gap: 24px;
    margin-bottom: 18px;
}

.sc-heading h1 {
    margin: 0;
    font-size: 1.75rem;
    line-height: 1.2;
    letter-spacing: -0.025em;
}

.sc-heading p,
.sc-atlas-head p,
.sc-evidence-head p {
    margin: 5px 0 0;
    color: var(--sc-muted);
}

.sc-heading-links,
.sc-atlas-actions {
    display: flex;
    gap: 8px;
    flex: 0 0 auto;
}

.sc-status {
    min-height: 22px;
    margin: 0 0 10px;
    color: var(--sc-muted);
    font-size: 0.9rem;
}

.sc-status[data-state="error"] {
    color: var(--sc-berry);
}

.sc-page .button.primary {
    border-color: var(--sc-honey);
    background: var(--sc-honey);
    color: var(--sc-ink);
    font-weight: 700;
}

.sc-page .button.primary:hover,
.sc-page .button.primary:active {
    border-color: var(--sc-honey-dark);
    background: var(--sc-honey-dark);
    color: #fff;
}

.sc-toolbar {
    display: grid;
    grid-template-columns: minmax(230px, 1.45fr) repeat(3, minmax(130px, 0.8fr)) minmax(230px, 1.25fr) auto auto;
    gap: 10px;
    align-items: end;
    padding: 14px;
    border: 1px solid var(--sc-border);
    border-radius: 12px 12px 0 0;
    background: var(--sc-surface);
}

.sc-field,
.sc-gene-search,
.sc-view-field {
    display: grid;
    gap: 6px;
    min-width: 0;
}

.sc-field > span,
.sc-gene-search > label,
.sc-view-field > span {
    color: var(--sc-muted);
    font-size: 0.75rem;
    font-weight: 700;
}

.sc-toolbar select,
.sc-toolbar input {
    width: 100%;
    height: 42px;
    border: 1px solid var(--sc-border);
    border-radius: 8px;
    background: var(--sc-bg);
    color: var(--sc-ink);
    padding: 0 11px;
    font: inherit;
}

.sc-toolbar select:focus-visible,
.sc-toolbar input:focus-visible,
.sc-view-toggle button:focus-visible,
.sc-tabs button:focus-visible,
.sc-legend-button:focus-visible {
    outline: 3px solid var(--sc-focus);
    outline-offset: 1px;
    border-color: var(--sc-honey-dark);
}

.sc-gene-search > div {
    display: flex;
}

.sc-gene-search input {
    border-radius: 8px 0 0 8px;
}

.sc-gene-search .button {
    min-width: 60px;
    border-radius: 0 8px 8px 0;
}

.sc-view-toggle {
    display: flex;
    height: 42px;
    border: 1px solid var(--sc-border);
    border-radius: 8px;
    overflow: hidden;
    background: var(--sc-bg);
}

.sc-view-toggle button {
    min-width: 48px;
    border: 0;
    border-right: 1px solid var(--sc-border);
    background: transparent;
    color: var(--sc-muted);
    cursor: pointer;
    font: inherit;
    font-weight: 700;
}

.sc-view-toggle button:last-child {
    border-right: 0;
}

.sc-view-toggle button[aria-pressed="true"] {
    background: var(--sc-honey);
    color: var(--sc-ink);
}

.sc-reset {
    height: 42px;
}

.sc-sample-context {
    display: flex;
    align-items: center;
    gap: 8px 12px;
    min-height: 42px;
    padding: 8px 16px;
    border-right: 1px solid var(--sc-border);
    border-left: 1px solid var(--sc-border);
    background: var(--sc-bg);
    color: var(--sc-muted);
    font-size: 0.82rem;
}

.sc-sample-context > span:first-child {
    color: var(--sc-ink);
    font-weight: 700;
}

.sc-sample-context strong {
    color: var(--sc-berry);
    white-space: nowrap;
}

.sc-sample-context > span:nth-of-type(2) {
    min-width: 0;
}

.sc-sample-context button {
    margin-left: auto;
    border: 0;
    background: transparent;
    color: var(--sc-honey-dark);
    padding: 5px 0;
    cursor: pointer;
    font: inherit;
    font-weight: 700;
    white-space: nowrap;
}

.sc-sample-context button:hover {
    color: var(--sc-berry);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.sc-sample-context button:focus-visible {
    border-radius: 4px;
    outline: 3px solid var(--sc-focus);
    outline-offset: 2px;
}

.sc-atlas {
    border: 1px solid var(--sc-border);
    border-top: 0;
    background: var(--sc-bg);
}

.sc-atlas-head {
    min-height: 66px;
    gap: 16px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--sc-border);
}

.sc-atlas-head h2,
.sc-evidence-head h2 {
    margin: 0;
    font-size: 1.05rem;
    letter-spacing: -0.01em;
}

.sc-atlas-head p,
.sc-evidence-head p {
    font-size: 0.84rem;
}

.sc-atlas-body {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 230px;
    min-height: 620px;
}

.sc-plot-wrap {
    position: relative;
    min-width: 0;
    min-height: 620px;
}

.sc-plot {
    width: 100%;
    height: 620px;
}

.sc-plot-loading {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: grid;
    place-content: center;
    justify-items: center;
    gap: 10px;
    padding: 32px;
    background: var(--sc-bg);
    text-align: center;
}

.sc-plot-loading[hidden] {
    display: none;
}

.sc-loading-dots {
    display: flex;
    gap: 7px;
    min-height: 16px;
}

.sc-loading-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--sc-honey);
    animation: sc-pulse 900ms ease-in-out infinite alternate;
}

.sc-loading-dots span:nth-child(2) { animation-delay: 150ms; }
.sc-loading-dots span:nth-child(3) { animation-delay: 300ms; }

.sc-plot-loading strong {
    color: var(--sc-ink);
    font-size: 0.95rem;
}

.sc-plot-loading p {
    max-width: 58ch;
    margin: 0;
    color: var(--sc-muted);
    font-size: 0.84rem;
    line-height: 1.55;
    text-wrap: pretty;
}

@keyframes sc-pulse {
    to { transform: translateY(-8px); opacity: 0.48; }
}

.sc-plot-empty {
    position: absolute;
    inset: 0;
    display: grid;
    place-content: center;
    justify-items: center;
    gap: 10px;
    padding: 32px;
    text-align: center;
    background: var(--sc-bg);
}

.sc-plot-empty h3,
.sc-plot-empty p { margin: 0; }
.sc-plot-empty p { max-width: 54ch; color: var(--sc-muted); }

.sc-legend {
    display: flex;
    flex-direction: column;
    border-left: 1px solid var(--sc-border);
    padding: 16px;
}

.sc-legend-head {
    padding-bottom: 12px;
    border-bottom: 1px solid var(--sc-border);
}

.sc-legend-head h3 {
    margin: 0;
    font-size: 0.9rem;
}

.sc-legend-head span {
    color: var(--sc-muted);
    font-size: 0.8rem;
}

.sc-legend-items {
    flex: 1;
    padding: 10px 0;
}

.sc-legend-button {
    display: grid;
    grid-template-columns: 12px minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-height: 36px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--sc-ink);
    padding: 5px 7px;
    cursor: pointer;
    text-align: left;
    font: inherit;
    font-size: 0.82rem;
}

.sc-legend-button:hover,
.sc-legend-button[aria-pressed="true"] {
    background: var(--sc-surface);
}

.sc-legend-button > span:nth-child(2) {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sc-legend-button small {
    color: var(--sc-muted);
    font-variant-numeric: tabular-nums;
}

.sc-swatch {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.sc-total {
    margin: 0;
    padding-top: 10px;
    border-top: 1px solid var(--sc-border);
}

.sc-total > div { min-height: 30px; }
.sc-total dt { color: var(--sc-muted); font-size: 0.78rem; }
.sc-total dd { margin: 0; font-size: 0.84rem; font-weight: 700; font-variant-numeric: tabular-nums; }

.sc-selection {
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 10px 24px;
    min-height: 54px;
    padding: 9px 16px;
    border: 1px solid var(--sc-border);
    border-top: 0;
    background: var(--sc-surface);
    font-size: 0.84rem;
}

.sc-selection > span {
    color: var(--sc-muted);
}

.sc-selection .button {
    margin-left: auto;
}

.sc-evidence {
    margin-top: 18px;
    border: 1px solid var(--sc-border);
    background: var(--sc-bg);
}

.sc-evidence-head {
    min-height: 64px;
    padding: 12px 16px;
}

.sc-tabs {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    padding: 0 12px;
    border-top: 1px solid var(--sc-border);
    border-bottom: 1px solid var(--sc-border);
}

.sc-tabs button {
    position: relative;
    min-height: 46px;
    border: 0;
    background: transparent;
    color: var(--sc-muted);
    padding: 0 13px;
    cursor: pointer;
    font: inherit;
    font-size: 0.84rem;
    font-weight: 700;
    white-space: nowrap;
}

.sc-tabs button[aria-selected="true"] {
    color: var(--sc-honey-dark);
}

.sc-tabs button[aria-selected="true"]::after {
    content: "";
    position: absolute;
    right: 10px;
    bottom: -1px;
    left: 10px;
    height: 2px;
    background: var(--sc-honey);
}

.sc-evidence-status {
    min-height: 20px;
    margin: 10px 16px;
    color: var(--sc-muted);
    font-size: 0.82rem;
}

.sc-table-scroll {
    overflow: auto;
    max-height: 520px;
    border-top: 1px solid var(--sc-border);
}

.sc-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
    font-variant-numeric: tabular-nums;
}

.sc-table th,
.sc-table td {
    padding: 9px 12px;
    border-bottom: 1px solid var(--sc-border);
    text-align: left;
    vertical-align: top;
}

.sc-table th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--sc-surface);
    color: var(--sc-muted);
    font-size: 0.74rem;
    font-weight: 700;
    white-space: nowrap;
}

.sc-table tbody tr:hover { background: oklch(0.98 0.007 58); }
.sc-table td:first-child { font-family: "Cascadia Mono", Consolas, monospace; color: var(--sc-berry); }
.sc-gene-link {
    color: var(--sc-berry);
    font-weight: 700;
    text-decoration: underline;
    text-decoration-color: oklch(0.36 0.13 18 / 0.35);
    text-underline-offset: 3px;
}
.sc-gene-link:hover { text-decoration-color: currentColor; }
.sc-gene-link:focus-visible {
    border-radius: 3px;
    outline: 3px solid var(--sc-focus);
    outline-offset: 2px;
}
.sc-table .sc-empty-row { padding: 34px 16px; color: var(--sc-muted); text-align: center; font-family: inherit; }

@media (max-width: 1320px) {
    .sc-toolbar {
        grid-template-columns: repeat(5, minmax(130px, 1fr));
    }
    .sc-field-dataset,
    .sc-gene-search { grid-column: span 2; }
    .sc-reset { align-self: end; }
}

@media (max-width: 960px) {
    .sc-toolbar { grid-template-columns: 1fr 1fr; }
    .sc-field-dataset,
    .sc-gene-search { grid-column: 1 / -1; }
}

@media (max-width: 900px) {
    .sc-atlas-body { grid-template-columns: 1fr; }
    .sc-legend {
        border-top: 1px solid var(--sc-border);
        border-left: 0;
    }
    .sc-legend-items {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    }
    .sc-plot-wrap,
    .sc-plot { min-height: 540px; height: 540px; }
}

@media (max-width: 680px) {
    .sc-page { width: min(100% - 20px, 1440px); padding-top: 16px; }
    .sc-heading { align-items: flex-start; flex-direction: column; }
    .sc-toolbar { grid-template-columns: 1fr 1fr; }
    .sc-atlas-head { align-items: flex-start; flex-direction: column; }
    .sc-atlas-actions { width: 100%; }
    .sc-atlas-actions .button { flex: 1; }
    .sc-sample-context { align-items: flex-start; flex-wrap: wrap; }
    .sc-sample-context > span:nth-of-type(2) { width: 100%; order: 3; }
    .sc-sample-context button { margin-left: 0; }
    .sc-plot-wrap,
    .sc-plot { min-height: 480px; height: 480px; }
    .sc-selection .button { width: 100%; margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
    .sc-loading-dots span { animation: none; }
}
