/* Layout: one 1200px column; the search console is the only raised surface, data views sit flat below it in tabs. */
:root {
  --bg: #f4f5f8;
  --surface: #ffffff;
  --surface-2: #eceef3;
  --ink: #131824;
  --ink-2: #485266;
  --muted: #6e788b;
  --line: #dce0e8;
  --grid: #e8ebf0;
  --accent: #b3262e;
  --accent-ink: #ffffff;
  --accent-soft: #f8e4e5;
  --dot-core: #ffe9d6;
  --focus: #2a78d6;
  --warn-ink: #8a5600;
  --warn-soft: #fbefd6;
  /* redshift-type series (validated categorical slots 2, 3, 1) */
  --s-spec: #eb6834;
  --s-grism: #1baf7a;
  --s-phot: #2a78d6;
  --shadow: 0 1px 2px rgba(19, 24, 36, 0.06), 0 8px 24px rgba(19, 24, 36, 0.06);
  --f-display: "Bricolage Grotesque", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --f-body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --step--1: 0.8125rem;
  --step-0: 0.9375rem;
  --step-1: 1.125rem;
  --step-2: 1.5rem;
  --step-3: 2.25rem;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c0f15;
    --surface: #151a23;
    --surface-2: #1d232e;
    --ink: #e8ebf1;
    --ink-2: #b6bdcb;
    --muted: #8a94a7;
    --line: #2a313e;
    --grid: #222936;
    --accent: #f0646b;
    --accent-ink: #1b0a0c;
    --accent-soft: #3b1d22;
    --dot-core: #fff1e6;
    --focus: #6aa5ec;
    --warn-ink: #f2c46b;
    --warn-soft: #3a2e14;
    --s-spec: #d95926;
    --s-grism: #199e70;
    --s-phot: #3987e5;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0c0f15;
  --surface: #151a23;
  --surface-2: #1d232e;
  --ink: #e8ebf1;
  --ink-2: #b6bdcb;
  --muted: #8a94a7;
  --line: #2a313e;
  --grid: #222936;
  --accent: #f0646b;
  --accent-ink: #1b0a0c;
  --accent-soft: #3b1d22;
  --dot-core: #fff1e6;
  --focus: #6aa5ec;
  --warn-ink: #f2c46b;
  --warn-soft: #3a2e14;
  --s-spec: #d95926;
  --s-grism: #199e70;
  --s-phot: #3987e5;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.3);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 var(--step-0)/1.55 var(--f-body);
}
img { max-width: 100%; }
[hidden] { display: none !important; }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
code, .mono { font-family: var(--f-mono); font-size: 0.92em; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: var(--step--1); }
h1, h2, h3 { font-family: var(--f-display); text-wrap: balance; margin: 0; letter-spacing: -0.01em; }
h3 { font-size: var(--step-1); font-weight: 700; }

.wrap {
  width: 100%;
  max-width: 1200px;
  margin-inline: auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}

/* masthead */
.masthead { padding-block: 28px 20px; }
.masthead-inner { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px 32px; }
.brand { display: flex; align-items: center; gap: 14px; }
.psf { width: 56px; height: 56px; flex: none; }
.psf .spikes line { stroke-width: 1.4; opacity: 0.55; }
.psf .spikes line.minor { stroke-width: 1; opacity: 0.35; }
h1 { font-size: var(--step-3); font-weight: 700; line-height: 1; }
.tagline { margin: 6px 0 0; color: var(--ink-2); }
.masthead-side { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.stats { margin: 0; font-variant-numeric: tabular-nums; color: var(--ink-2); text-align: right; }
.stats b { color: var(--ink); font-weight: 600; }
.masthead-actions { display: flex; gap: 8px; }

/* buttons */
button, select, input, textarea { font: inherit; color: inherit; }
.primary-btn, .ghost-btn, .link-btn {
  display: inline-flex; align-items: center; gap: 6px;
  border-radius: 8px; padding: 7px 14px; cursor: pointer;
  font-size: var(--step--1); font-weight: 500; text-decoration: none; line-height: 1.3;
}
.primary-btn { background: var(--accent); color: var(--accent-ink); border: 1px solid var(--accent); font-weight: 600; }
.primary-btn:hover { filter: brightness(1.08); }
.ghost-btn { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.ghost-btn:hover { background: var(--surface-2); }
.link-btn { background: none; border: 0; color: var(--accent); padding: 4px 2px; }
.link-btn:hover { text-decoration: underline; }

/* search console */
.console {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 20px;
  display: grid;
  gap: 14px;
}
.console-head h2 { font-size: var(--step-2); font-weight: 700; }
.hint { margin: 4px 0 0; color: var(--ink-2); font-size: var(--step--1); max-width: 72ch; }
.console-body { display: grid; grid-template-columns: minmax(0, 4fr) minmax(0, 7fr); gap: 20px; align-items: start; }
.q-input { display: grid; gap: 10px; min-width: 0; }
textarea {
  width: 100%; resize: vertical; min-height: 120px;
  font-family: var(--f-mono); font-size: 0.875rem; line-height: 1.6;
  padding: 10px 12px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--bg); color: var(--ink);
}
.q-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: var(--step--1); color: var(--ink-2); }
select, input[type="number"], input[type="search"] {
  border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 6px 8px; font-size: var(--step--1);
}
.example-note { margin: 0; font-size: var(--step--1); color: var(--muted); }
.file-btn { cursor: pointer; }
.q-results { min-width: 0; }
.q-summary { margin: 0 0 8px; font-weight: 500; }
.q-summary .yes { color: var(--accent); }
.q-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.q-empty { color: var(--muted); font-size: var(--step--1); border: 1px dashed var(--line); border-radius: var(--radius); padding: 18px; }

/* tabs */
.tabs { display: flex; gap: 4px; margin-top: 28px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs button {
  background: none; border: 0; border-bottom: 2px solid transparent; padding: 10px 14px; cursor: pointer;
  font-weight: 500; color: var(--ink-2); white-space: nowrap; margin-bottom: -1px;
}
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.tabs button:hover { color: var(--ink); }
.count-badge { display: inline-block; min-width: 1.6em; padding: 0 6px; margin-left: 4px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-size: 0.75rem; font-weight: 600; text-align: center; font-variant-numeric: tabular-nums; }
.view { padding-block: 18px 40px; }
.view-note { margin: 0 0 12px; font-size: var(--step--1); }

/* filters */
.filters { display: grid; gap: 10px; margin-bottom: 14px; }
.filter-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; }
.filter-row label { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.f-label { font-size: 0.6875rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; }
.f-search { flex: 1 1 260px; }
.f-search input { width: 100%; padding: 8px 10px; font-size: var(--step-0); }
.f-z input { width: 5.5em; }
.filter-row select { max-width: 15rem; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chips .spacer { flex: 1; }
.chip { flex-direction: row !important; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span {
  display: inline-block; padding: 4px 11px; border-radius: 999px; border: 1px solid var(--line);
  font-size: var(--step--1); cursor: pointer; user-select: none; background: var(--surface);
}
.chip input:checked + span { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chip input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }
.chip-btn { padding: 4px 11px; border-radius: 999px; border: 1px solid var(--line); font-size: var(--step--1); cursor: pointer; background: var(--surface); }
.chip-btn[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }

/* tables */
.table-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.table-head p { margin: 0; font-size: var(--step--1); }
.table-scroll { overflow: auto; max-height: 78vh; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table.data { width: 100%; border-collapse: collapse; font-size: var(--step--1); }
table.data th, table.data td { padding: 7px 10px; text-align: left; border-bottom: 1px solid var(--grid); vertical-align: top; }
table.data thead th {
  position: sticky; top: 0; background: var(--surface-2); font-weight: 600; font-size: 0.75rem;
  text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-2); white-space: nowrap; z-index: 1;
}
table.data th[data-sort] { cursor: pointer; }
table.data th[data-sort]:hover { color: var(--ink); }
table.data th[aria-sort="ascending"]::after { content: " ▲"; font-size: 0.65em; }
table.data th[aria-sort="descending"]::after { content: " ▼"; font-size: 0.65em; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr.clickable { cursor: pointer; }
table.data tbody tr.clickable:hover { background: var(--surface-2); }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data .mono { white-space: nowrap; }
table.data td.title-cell { min-width: 18rem; max-width: 34rem; }
.q-results .table-scroll table.data td { white-space: nowrap; }
.q-results .table-scroll table.data td[colspan] { white-space: normal; }
.q-results .table-scroll table.data td.refs-cell { white-space: normal; min-width: 11rem; }
.q-results .pill { margin-top: 3px; }

/* pills */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border-radius: 999px; font-size: 0.75rem; font-weight: 500; line-height: 1.6; white-space: nowrap; border: 1px solid transparent; }
.pill-lrd { background: var(--accent-soft); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.pill-bl { background: var(--surface-2); color: var(--ink-2); border-color: var(--line); }
.pill-warn { background: var(--warn-soft); color: var(--warn-ink); }
.pill-plain { background: var(--surface-2); color: var(--ink-2); }
.pill-new { background: transparent; color: var(--ink-2); border-color: var(--line); border-style: dashed; }
.pill-table { background: var(--surface-2); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 30%, transparent); text-decoration: none; }
.pill-table:hover { text-decoration: underline; }
.ztype { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: 0.75rem; }
.swatch { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.sw-spec { background: var(--s-spec); }
.sw-grism { background: var(--s-grism); }
.sw-phot { background: var(--s-phot); }
.sw-none { background: transparent; border: 1px solid var(--muted); }
.flags { display: flex; flex-wrap: wrap; gap: 4px; }
.flag { font-size: 0.6875rem; font-weight: 600; letter-spacing: 0.03em; padding: 0 6px; border-radius: 4px; border: 1px solid var(--line); color: var(--ink-2); line-height: 1.7; }
.flag.neg { color: var(--muted); border-style: dashed; font-weight: 500; }
.refs { display: flex; flex-wrap: wrap; gap: 4px; }
.ref { font-size: 0.75rem; padding: 0 6px; border-radius: 4px; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; text-decoration: none; }
a.ref:hover { color: var(--accent); }

.pager { display: flex; justify-content: center; align-items: center; gap: 10px; margin-top: 12px; font-size: var(--step--1); font-variant-numeric: tabular-nums; }

/* charts */
.legend { display: flex; flex-wrap: wrap; gap: 16px; margin-bottom: 14px; font-size: var(--step--1); color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-block { margin-bottom: 26px; min-width: 0; }
.chart-block h3 { margin-bottom: 8px; }
.chart { width: 100%; min-width: 0; }
.chart svg, .multiples svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 24px; }
.multiples { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); gap: 18px; }
.panel h4 { margin: 0 0 4px; font-family: var(--f-body); font-size: var(--step--1); font-weight: 600; display: flex; justify-content: space-between; gap: 8px; }
.panel h4 span { color: var(--muted); font-weight: 400; font-variant-numeric: tabular-nums; }
svg text { fill: var(--muted); font-family: var(--f-body); font-size: 11px; }
svg .axis-line { stroke: var(--line); }
svg .grid-line { stroke: var(--grid); }
svg .frame { fill: var(--surface); stroke: var(--line); }
svg .pt { stroke: var(--surface); stroke-width: 0.8; }
svg .pt-spec { fill: var(--s-spec); }
svg .pt-grism { fill: var(--s-grism); }
svg .pt-phot { fill: var(--s-phot); }
svg .pt-none { fill: var(--muted); }
svg .hover-ring { fill: none; stroke: var(--ink); stroke-width: 1.5; }
svg .bar-spec { fill: var(--s-spec); }
svg .bar-grism { fill: var(--s-grism); }
svg .bar-phot { fill: var(--s-phot); }
svg .bar-gap { stroke: var(--bg); stroke-width: 1; }
svg .growth-line { fill: none; stroke: var(--accent); stroke-width: 2; }
svg .growth-area { fill: var(--accent); opacity: 0.1; }
svg .end-dot { fill: var(--accent); stroke: var(--bg); stroke-width: 2; }
svg .end-label { fill: var(--ink); font-weight: 600; font-size: 12px; }
svg .crosshair { stroke: var(--ink-2); stroke-width: 1; stroke-dasharray: 3 3; }
svg .field-label { fill: var(--ink-2); font-size: 11px; font-weight: 600; }
svg .sky-outline { fill: var(--surface); stroke: var(--line); }

.tooltip {
  position: fixed; z-index: 50; pointer-events: none; max-width: 280px;
  background: var(--ink); color: var(--bg); padding: 6px 9px; border-radius: 6px;
  font-size: 0.75rem; line-height: 1.45; box-shadow: var(--shadow);
}
.tooltip b { font-weight: 600; }

/* inbox */
.inbox { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 0; border-top: 1px solid var(--line); }
.inbox li { padding: 12px 0; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 6.5rem minmax(0, 1fr); gap: 4px 16px; }
.inbox .date { font-variant-numeric: tabular-nums; color: var(--muted); font-size: var(--step--1); padding-top: 2px; }
.inbox .title { font-weight: 500; }
.inbox .title a { color: var(--ink); text-decoration: none; }
.inbox .title a:hover { color: var(--accent); text-decoration: underline; }
.inbox .meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: var(--step--1); color: var(--ink-2); margin-top: 3px; }
.inbox details { grid-column: 2; font-size: var(--step--1); color: var(--ink-2); }
.inbox summary { cursor: pointer; color: var(--muted); }
.inbox details p { max-width: 80ch; margin: 6px 0 0; }

/* prose */
.prose { max-width: 72ch; }
.prose h3 { margin-top: 24px; margin-bottom: 6px; }
.prose h3:first-child { margin-top: 0; }
.prose p, .prose li { color: var(--ink-2); }
.prose b { color: var(--ink); }
.downloads { padding-left: 1.2em; }

/* drawer */
.drawer {
  position: fixed; inset: 0 0 0 auto; width: min(560px, 100%); z-index: 40;
  background: var(--surface); border-left: 1px solid var(--line); box-shadow: -12px 0 40px rgba(0, 0, 0, 0.18);
  overflow-y: auto;
  padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}
.drawer-inner { padding: 20px; display: grid; gap: 16px; }
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; position: sticky; top: 0; background: var(--surface); padding-block: 4px 8px; z-index: 2; }
.drawer-head h2 { font-family: var(--f-mono); font-size: 1.05rem; font-weight: 500; letter-spacing: 0; word-break: break-word; }
.d-grid { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; align-items: start; }
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 14px; margin: 0; font-size: var(--step--1); }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-variant-numeric: tabular-nums; min-width: 0; }
.cutout { width: 168px; aspect-ratio: 1; max-width: 100%; border-radius: 8px; background: var(--surface-2); overflow: hidden; display: grid; place-items: center; color: var(--muted); font-size: 0.75rem; text-align: center; }
.cutout img { width: 100%; height: 100%; object-fit: cover; display: block; image-rendering: auto; }
.cutout-cap { font-size: 0.6875rem; color: var(--muted); margin-top: 4px; text-align: center; }
.d-links { display: flex; flex-wrap: wrap; gap: 6px; }
.d-section h3 { font-size: var(--step-0); margin-bottom: 6px; }
.copy-row { display: flex; gap: 6px; flex-wrap: wrap; }

.footer { padding-block: 10px 32px; border-top: 1px solid var(--line); }
.footer p { margin: 12px 0 0; }

@media (max-width: 1100px) {
  .console-body { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .masthead-side { align-items: flex-start; }
  .stats { text-align: left; }
  .d-grid { grid-template-columns: minmax(0, 1fr); }
  .inbox li { grid-template-columns: minmax(0, 1fr); }
  .inbox details { grid-column: 1; }
  h1 { font-size: 1.9rem; }
}
@media (prefers-reduced-motion: no-preference) {
  .drawer:not([hidden]) { animation: slide-in 160ms ease-out; }
  @keyframes slide-in { from { transform: translateX(24px); opacity: 0.6; } to { transform: none; opacity: 1; } }
}
