/* jupyddl playground — light and dark are both selected, not flipped. */

:root {
  color-scheme: light;
  --surface-1: #fcfcfb;
  --page: #f9f9f7;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);

  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;

  --seq-low: #cde2fb;
  --seq-high: #0d366b;
  --good: #0ca30c;
  --critical: #d03b3b;

  --radius: 10px;
  --shadow: 0 1px 2px rgba(11, 11, 11, .05), 0 6px 20px rgba(11, 11, 11, .045);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --surface-1: #1a1a19;
    --page: #0d0d0d;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --series-6: #008300;
    --seq-low: #cde2fb;
    --seq-high: #184f95;
    --shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 6px 20px rgba(0, 0, 0, .35);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-1: #1a1a19;
  --page: #0d0d0d;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-6: #008300;
  --seq-low: #cde2fb;
  --seq-high: #184f95;
  --shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 6px 20px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

/* `display` rules on .boot/.pane would otherwise beat the hidden attribute. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--page);
  color: var(--text-primary);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--series-1); }

/* ---------------------------------------------------------------- header */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 14px 20px;
  border-bottom: 1px solid var(--border); background: var(--surface-1);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo { font-size: 26px; line-height: 1; }
.topbar h1 { font-size: 17px; margin: 0; font-weight: 700; letter-spacing: -0.01em; }
.tag {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .06em; color: var(--text-muted);
  border: 1px solid var(--border); border-radius: 999px; padding: 2px 8px;
  vertical-align: 2px; margin-left: 4px;
}
.sub { margin: 1px 0 0; font-size: 12.5px; color: var(--text-secondary); }
.topbar-actions { display: flex; gap: 8px; align-items: center; }

button, select {
  font-family: inherit; font-size: 13px; border-radius: 8px;
  border: 1px solid var(--border); padding: 7px 12px;
  background: var(--surface-1); color: var(--text-primary); cursor: pointer;
}
button:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--series-1); outline-offset: 2px;
}
.ghost { background: transparent; color: var(--text-secondary); text-decoration: none;
  display: inline-flex; align-items: center; gap: 6px; }
.ghost:hover { color: var(--text-primary); }
.ghost.small { font-size: 12px; padding: 4px 9px; }
.primary { background: var(--series-1); border-color: var(--series-1); color: #fff; font-weight: 600; }
.primary:hover { filter: brightness(1.06); }
.primary:disabled, .secondary:disabled { opacity: .5; cursor: progress; }
.secondary { font-weight: 600; }

/* ------------------------------------------------------------------ boot */
.bootbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 9px 20px; border-bottom: 1px solid var(--border);
  background: var(--surface-1); font-size: 13px;
}
.bootbar p { margin: 0; }
.boot-note { color: var(--text-muted); }
.spinner {
  width: 15px; height: 15px; flex: none;
  border: 2px solid var(--grid); border-top-color: var(--series-1);
  border-radius: 50%; animation: spin 900ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }

/* -------------------------------------------------------------- controls */
main { padding: 18px 20px 40px; max-width: 1500px; margin: 0 auto; }
.controls {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end;
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px; margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.field { display: flex; flex-direction: column; gap: 5px; }
.field.grow { flex: 1 1 220px; justify-content: center; }
.field label {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .05em; color: var(--text-muted);
}
.blurb { font-size: 13px; color: var(--text-secondary); }

/* ----------------------------------------------------------------- panes */
.grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  align-items: start;
}
.pane {
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow);
  min-width: 0;
}
.pane.wide { grid-column: 1 / -1; }
.pane-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; margin-bottom: 10px;
}
.pane h2 { font-size: 13px; margin: 0; text-transform: uppercase;
  letter-spacing: .05em; color: var(--text-secondary); }
.pane h3 { font-size: 13px; margin: 0; font-weight: 600; }
.hint { font-size: 11.5px; color: var(--text-muted); }

/* --------------------------------------------------------------- editors */
.tabs { display: flex; gap: 4px; }
.tab {
  font-size: 12px; padding: 4px 10px; border-radius: 999px;
  border: 1px solid transparent; background: transparent; color: var(--text-muted);
}
.tab.active { background: var(--page); border-color: var(--border); color: var(--text-primary); }
.editor {
  width: 100%; height: 460px; resize: vertical;
  font-family: var(--mono); font-size: 12.5px; line-height: 1.55;
  background: var(--page); color: var(--text-primary);
  border: 1px solid var(--border); border-radius: 8px; padding: 12px;
  tab-size: 2;
}

/* ----------------------------------------------------------------- stats */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 14px; }
.stat {
  display: flex; flex-direction: column; gap: 2px;
  background: var(--page); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px;
}
.stat-value { font-size: 18px; font-weight: 700; letter-spacing: -0.02em; }
.stat-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-muted); }

/* ---------------------------------------------------------------- charts */
.chart-block { margin-bottom: 14px; }
.chart-block:last-child { margin-bottom: 0; }
.chart-head { display: flex; align-items: baseline; justify-content: space-between;
  gap: 10px; margin-bottom: 6px; }
.chart-host { position: relative; height: 190px; }
.chart-host.short { height: 130px; }
.chart { display: block; width: 100%; overflow: visible; }

.legend { display: flex; gap: 12px; flex-wrap: wrap; }
.legend.spread { justify-content: center; margin-top: 8px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px; color: var(--text-secondary); }
.legend-item i, .legend i {
  width: 10px; height: 10px; border-radius: 3px; display: inline-block;
}
.dot { border-radius: 50%; }
.dot.low { background: var(--seq-low); }
.dot.high { background: var(--seq-high); }

.chart-tooltip {
  position: absolute; top: 0; left: 0; pointer-events: none; opacity: 0;
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; box-shadow: var(--shadow);
  font-size: 12px; min-width: 132px; transition: opacity .12s ease; z-index: 5;
}
.tt-head { font-weight: 600; margin-bottom: 4px; color: var(--text-primary); }
.tt-row { display: flex; align-items: center; gap: 6px; }
.tt-swatch { width: 9px; height: 9px; border-radius: 2px; flex: none; }
.tt-name { color: var(--text-secondary); }
.tt-value { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 600; }

.wavefront-host { display: grid; place-items: center; aspect-ratio: 1 / 1; max-height: 460px; }
#wavefront { width: 100%; height: 100%; }

/* ------------------------------------------------------------------ plan */
.plan {
  margin: 0; padding-left: 26px; max-height: 460px; overflow-y: auto;
  font-family: var(--mono); font-size: 12.5px; color: var(--text-primary);
}
.plan li { padding: 2px 0; }
.plan li::marker { color: var(--text-muted); font-family: var(--sans); font-size: 11px; }
.empty { color: var(--text-muted); font-size: 13px; padding: 18px 0; }

/* ------------------------------------------------------------------ race */
.race-grid { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.data-table { width: 100%; border-collapse: collapse; margin-top: 16px; font-size: 12.5px; }
.data-table caption { text-align: left; color: var(--text-muted); font-size: 11.5px;
  margin-bottom: 6px; }
.data-table th, .data-table td {
  text-align: right; padding: 6px 10px; border-bottom: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}
.data-table th:first-child, .data-table td:first-child { text-align: left; font-family: var(--mono); }
.data-table thead th { color: var(--text-muted); font-weight: 600; text-transform: uppercase;
  font-size: 10.5px; letter-spacing: .05em; }

/* ----------------------------------------------------------------- misc */
.error {
  margin-top: 16px; padding: 12px 14px; border-radius: var(--radius);
  border: 1px solid var(--critical); color: var(--critical);
  background: color-mix(in srgb, var(--critical) 8%, transparent);
  font-family: var(--mono); font-size: 12.5px; white-space: pre-wrap;
}
.footer {
  margin-top: 26px; display: flex; flex-wrap: wrap; gap: 10px;
  justify-content: space-between; color: var(--text-muted); font-size: 12px;
}
.ok { color: var(--good); font-weight: 600; }
.bad { color: var(--critical); font-weight: 600; }

@media (max-width: 640px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .controls { gap: 10px; }
  .editor { height: 300px; }
}

/* ------------------------------------------------------- workbench views */
.viewnav { display: flex; gap: 2px; flex: 1 1 auto; justify-content: center; }
.navlink {
  border: none; background: transparent; color: var(--text-secondary);
  font-size: 13.5px; font-weight: 600; padding: 7px 14px; border-radius: 8px;
}
.navlink:hover { background: var(--page); color: var(--text-primary); }
.navlink.active { background: var(--page); color: var(--series-1); }

.view { display: none; }
.view.active { display: block; }

.controls.inner { box-shadow: none; }
.field.narrow { max-width: 120px; }
.field input[type="number"] {
  font-family: inherit; font-size: 13px; border-radius: 8px;
  border: 1px solid var(--border); padding: 7px 10px;
  background: var(--surface-1); color: var(--text-primary); width: 100%;
}
.tagrow { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 4px; }
.chip {
  font-size: 10.5px; font-weight: 600; letter-spacing: .03em;
  color: var(--text-secondary); background: var(--page);
  border: 1px solid var(--border); border-radius: 999px; padding: 1px 8px;
}
.wide.pane + .wide.pane { margin-top: 16px; }
#view-experiment .pane, #view-requirements .pane, #view-generate .pane {
  margin-bottom: 16px;
}
.prose {
  font-size: 13.5px; color: var(--text-secondary); max-width: 78ch;
  margin: 0 0 14px;
}
.ghost.wide { width: 100%; margin-top: 8px; justify-content: center; }

/* ------------------------------------------------------------- pickers */
.matrix {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  margin-bottom: 14px;
}
.picker {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 12px 8px; margin: 0; min-width: 0;
}
.picker legend {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; color: var(--text-muted); padding: 0 4px;
}
.checklist {
  display: flex; flex-direction: column; gap: 3px;
  max-height: 190px; overflow-y: auto;
}
.check {
  display: flex; align-items: center; gap: 7px;
  font-size: 12.5px; color: var(--text-primary); cursor: pointer;
  padding: 2px 3px; border-radius: 5px;
}
.check:hover { background: var(--page); }
.picker-actions { display: flex; gap: 6px; margin-top: 7px; }
.picker.limits { display: flex; flex-direction: column; gap: 8px; }
.inline {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 11.5px; color: var(--text-secondary);
}
.inline input { width: 100%; }

.run-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spacer { flex: 1 1 auto; }
.progressbar {
  height: 4px; background: var(--grid); border-radius: 999px;
  overflow: hidden; margin-top: 12px;
}
#exp-progress-fill {
  height: 100%; width: 0; background: var(--series-1);
  transition: width .18s ease;
}

/* -------------------------------------------------------------- tables */
.table-scroll { overflow-x: auto; max-height: 460px; overflow-y: auto; }
.data-table th.num, .data-table td.num { text-align: right; }
.sortable th[data-key] { cursor: pointer; user-select: none; white-space: nowrap; }
.sortable th[data-key]:hover { color: var(--text-primary); }
.sortable th.sorted-asc::after { content: " ▲"; font-size: 8px; }
.sortable th.sorted-desc::after { content: " ▼"; font-size: 8px; }
.data-table thead th {
  position: sticky; top: 0; background: var(--surface-1); z-index: 1;
}
.row-error td { opacity: .65; }
.warn { color: var(--series-4); font-weight: 600; }
.verdict { font-size: 13px; margin: 0 0 10px; color: var(--text-secondary); }

/* -------------------------------------------------------- requirements */
.filterbar { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.filter {
  font-size: 12px; padding: 4px 11px; border-radius: 999px;
  border: 1px solid var(--border); background: transparent;
  color: var(--text-secondary); text-transform: capitalize;
}
.filter.active {
  background: var(--series-1); border-color: var(--series-1); color: #fff;
}
.pill {
  display: inline-block; font-size: 10.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .04em;
  padding: 2px 9px; border-radius: 999px; color: #fff;
}
.pill.native { background: var(--series-6); }
.pill.compiled { background: var(--series-1); }
.pill.partial { background: var(--series-4); color: #21160a; }
.pill.rejected { background: var(--text-muted); }
#req-table td { vertical-align: top; text-align: left; }
#req-table td:nth-child(2), #req-table td:nth-child(3) { white-space: nowrap; }
.note { font-size: 12px; color: var(--text-secondary); line-height: 1.5; }
#req-table code { font-family: var(--mono); font-size: 12px; }

/* ------------------------------------------------------------ generate */
.gen-output {
  display: grid; gap: 14px; margin-top: 14px;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}
.gen-output h3 {
  font-size: 12px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-muted); margin: 0 0 6px;
}
.code {
  background: var(--page); border: 1px solid var(--border);
  border-radius: 8px; padding: 12px; margin: 0;
  font-family: var(--mono); font-size: 11.5px; line-height: 1.5;
  max-height: 420px; overflow: auto; white-space: pre; color: var(--text-primary);
}

@media (max-width: 900px) {
  .topbar { flex-wrap: wrap; }
  .viewnav { order: 3; width: 100%; justify-content: flex-start; }
}

/* The requirement table is prose, not figures: headers align with their text. */
#req-table th { text-align: left; }
/* Cut the scrolling checklists on a whole row rather than through one. */
.checklist { max-height: 176px; padding-right: 2px; }

/* ---- Research view ------------------------------------------------- */
.subhead {
  font-size: 15px; font-weight: 650; letter-spacing: -0.01em;
  margin: 22px 0 6px; color: var(--text-primary);
}
.subhead:first-of-type { margin-top: 14px; }
.bullets { padding-left: 18px; }
.bullets li { margin-bottom: 8px; }
.codeblock {
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 8px; padding: 12px 14px; overflow-x: auto;
  font-size: 12.5px; line-height: 1.6; margin: 0 0 10px;
}
.codeblock code { color: var(--text-secondary); white-space: pre; }
/* The links in this view reuse .filter, which is a <button> elsewhere. */
a.filter { text-decoration: none; display: inline-block; }
