/* Same look as the "X, visually" demos (cross validation, knn, ...). */
:root {
  --ink: #1c2230;
  --muted: #5d6677;
  --bg: #f4f5f8;
  --card: #fff;
  --line: #e3e6ec;
  --radius: 14px;
  --accent: #1d4ed8;
  /* status, always with a word beside it */
  --ok: #15803d;
  --warn: #b45309;
  --bad: #b91c1c;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }

body {
  margin: 0;
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", sans-serif;
  color: var(--ink);
  background: var(--bg);
}
code, pre, textarea { font-family: var(--mono); font-size: .88em; }
code { background: #f1f3f7; border-radius: 4px; padding: 0 3px; }

header, main, footer {
  max-width: 1360px;
  margin: 0 auto;
  padding-left: 24px;
  padding-right: 24px;
}
header { padding-top: 28px; padding-bottom: 6px; }
h1 { font-size: 2rem; margin: 0 0 2px; letter-spacing: -0.015em; }
.sub { color: var(--muted); margin: 0; font-size: 1.05rem; }

.tabs { display: flex; gap: 8px; margin-top: 18px; }
.tab {
  font: inherit;
  font-weight: 600;
  color: var(--muted);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 18px;
  cursor: pointer;
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(16, 24, 40, .04),
    0 6px 20px rgba(16, 24, 40, .05);
  padding: 14px 16px;
}
.card h2 { font-size: 1.12rem; margin: 0 0 8px; }
.card h3 {
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
  margin: 2px 0 6px;
}
.card p { margin: 0 0 10px; }
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 6px;
}
.card-head h2 { margin: 0; }
.card-head .buttons { margin: 0; }

.intro {
  max-width: 1312px;
  margin: 12px auto 0;
  padding: 16px 20px 8px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px 32px;
}
/* lets the code example scroll instead of widening the page */
.intro > * { min-width: 0; }
.intro:has(> .howto[hidden]) { grid-template-columns: 1fr; }
.goal {
  background: #f3f6ff;
  border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0;
  padding: 7px 11px;
}
.howto summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 600;
  width: max-content;
  margin-top: 6px;
}
.howto ul { margin: 6px 0 10px; padding-left: 1.1em; }
.howto li { margin: 4px 0; }
.howto pre {
  background: #f6f7fa;
  border-radius: 8px;
  padding: 8px 10px;
  margin: 6px 0;
  overflow-x: auto;
}

main { padding-top: 14px; padding-bottom: 24px; }
.panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
.panel > * { min-width: 0; }
.code-panel { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); }
.col { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.wide { margin-top: 16px; }
[hidden] { display: none !important; }

/* ----------------------------------------------------------- controls */
textarea#code {
  display: block;
  width: 100%;
  min-height: 300px;
  resize: vertical;
  border: 1px solid #cfd4dd;
  border-radius: 8px;
  padding: 10px 12px;
  line-height: 1.45;
  color: var(--ink);
  background: #fbfbfd;
  tab-size: 4;
  white-space: pre;
  overflow: auto;
}
textarea#code:focus, input:focus, select:focus {
  outline: 2px solid #bfd0fb;
  border-color: var(--accent);
}
.buttons { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
button:not(.tab) {
  font: inherit;
  font-size: .92rem;
  font-weight: 600;
  color: var(--ink);
  background: #fff;
  border: 1px solid #cfd4dd;
  border-radius: 8px;
  padding: 5px 12px;
  cursor: pointer;
}
button:not(.tab):hover { background: #f3f4f7; }
button:not(.tab):active { background: #e9ebf0; }
button.primary {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}
button.primary:hover { background: #333b4d; }
button.quiet { color: var(--muted); font-weight: 500; }
button:disabled { opacity: .45; cursor: default; }
button.x {
  border: 0;
  background: none;
  color: var(--muted);
  padding: 0 4px;
  font-size: 1.05rem;
  line-height: 1;
}
.run-row button { min-width: 90px; }

.field {
  display: grid;
  grid-template-columns: 90px minmax(0, 1fr);
  align-items: center;
  gap: 2px 10px;
  margin: 8px 0;
}
.field > span:first-child { font-size: .92rem; color: var(--muted); }
input, select {
  font: inherit;
  font-size: .95rem;
  color: var(--ink);
  border: 1px solid #cfd4dd;
  border-radius: 8px;
  padding: 4px 8px;
  background: #fff;
  min-width: 0;
}
.field input, .field select { width: 100%; }

.seg {
  display: inline-flex;
  border: 1px solid #cfd4dd;
  border-radius: 8px;
  overflow: hidden;
  margin-left: auto;
}
.seg button {
  border: 0 !important;
  border-radius: 0 !important;
  font-size: .86rem !important;
  padding: 4px 12px !important;
}
.seg button + button { border-left: 1px solid #cfd4dd !important; }
.seg button[aria-checked="true"] {
  background: var(--ink) !important;
  color: #fff;
}

.drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
  border: 2px dashed #c3cad6;
  border-radius: 10px;
  padding: 34px 16px;
  color: var(--muted);
  cursor: pointer;
  background: #fbfbfd;
}
.drop b { color: var(--ink); }
.drop span { font-size: .88rem; }
.drop:hover { border-color: var(--accent); }
.drop.small { padding: 10px 16px; }
.drop.small span { display: none; }
.code-card.dragging { outline: 3px dashed var(--accent); outline-offset: -6px; }
.files-head { display: flex; align-items: center; gap: 8px;
  justify-content: space-between; margin: 10px 0 0; }
.file-view {
  min-height: 160px;
  max-height: 300px;
  overflow: auto;
  background: #f6f7fa;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  margin: 6px 0 0;
  line-height: 1.45;
  tab-size: 4;
}

.pill {
  font-size: .8rem;
  font-weight: 600;
  border-radius: 999px;
  padding: 2px 10px;
  background: #f1f3f7;
  color: var(--muted);
}
.pill.ready { background: #ecfdf3; color: var(--ok); }
.pill.failed { background: #fef2f2; color: var(--bad); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font-family: var(--mono);
  font-size: .82rem;
  background: #f1f3f7;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 1px 4px 1px 10px;
}

.msg {
  white-space: pre-wrap;
  font-family: var(--mono);
  font-size: .82rem;
  border-radius: 8px;
  padding: 8px 10px;
  margin: 8px 0 0;
  background: #f6f7fa;
  max-height: 260px;
  overflow: auto;
}
.msg.error { background: #fef2f2; color: #7f1d1d; }
.msg.note { font-family: inherit; font-size: .9rem; color: var(--muted); }
.msg-line { margin: 6px 0 0 !important; min-height: 1.5em; font-size: .92rem;
  font-variant-numeric: tabular-nums; }
.msg-line.error { color: var(--bad); }
.msg-line.ok { color: var(--ok); font-weight: 600; }
.output { margin-top: 8px; }
.output summary { cursor: pointer; color: var(--muted); font-size: .9rem; }
.output pre {
  max-height: 220px;
  overflow: auto;
  background: #f6f7fa;
  border-radius: 8px;
  padding: 8px 10px;
  margin: 6px 0 0;
  font-size: .8rem;
}

.progress {
  height: 6px;
  background: #eef0f4;
  border-radius: 999px;
  overflow: hidden;
}
.progress div {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width .15s;
}

/* ---------------------------------------------------------- readouts */
.muted { color: var(--muted); font-size: .88em; }
.hint { margin: 6px 2px 0 !important; color: var(--muted); font-size: .86rem; }

/* ------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; }
table.runs {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
  font-variant-numeric: tabular-nums;
}
.runs th {
  text-align: left;
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  font-weight: 600;
  border-bottom: 1px solid var(--line);
  padding: 6px 8px;
  white-space: nowrap;
}
.runs td {
  padding: 5px 8px;
  border-bottom: 1px solid #f0f2f5;
  white-space: nowrap;
}
.runs .num { text-align: right; }
.runs tr.baseline td:first-child { color: var(--muted); }
.runs tr.pick { cursor: pointer; }
.runs tr.pick:hover td { background: #f8f9fb; }
/* the selected run: same accent as the replay's run banner */
.runs tr.selected td { background: #eef3ff; }
.runs tr.selected:hover td { background: #e6eeff; }
.runs tr.selected td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.runs th button.sort {
  all: unset;
  cursor: pointer;
  font: inherit;
  text-transform: inherit;
  letter-spacing: inherit;
  color: inherit;
}
.runs th button.sort:hover { color: var(--ink); }
.runs th button.sort:focus-visible { outline: 2px solid #bfd0fb; }
.runs th[aria-sort] { color: var(--ink); }
.runs th[aria-sort="ascending"] button.sort::after { content: " \25B2"; }
.runs th[aria-sort="descending"] button.sort::after { content: " \25BC"; }
.runs tr.mine td { font-weight: 700; background: #f3f6ff; }
.runs tr.gap td {
  color: var(--muted);
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding-top: 14px;
}
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-left: 6px;
  vertical-align: middle;
}
.status-dot.ok { background: var(--ok); }
.status-dot.warn { background: var(--warn); }
.status-dot.bad { background: var(--bad); }

/* ------------------------------------------------------------- replay */
.replay-head { font-weight: 600; }
.run-code { margin: 0 0 12px; }
.run-code summary { cursor: pointer; color: var(--accent); font-weight: 600;
  width: max-content; }
.run-code .chips { margin-top: 6px; }
.run-code pre {
  max-height: 340px;
  overflow: auto;
  background: #f6f7fa;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  margin: 6px 0 0;
  line-height: 1.45;
  tab-size: 4;
}
.run-code .buttons { margin: 8px 0 0; }
button.chip.file { font-family: var(--mono); font-size: .8rem;
  padding: 1px 10px; border-radius: 999px; }
button.chip.file.on { background: var(--ink); color: #fff;
  border-color: var(--ink); }
.badge {
  display: inline-block;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  border-radius: 999px;
  padding: 0 8px;
  margin-right: 4px;
  vertical-align: 1px;
}
.badge.ok { background: #dcfce7; color: var(--ok); }
.badge.bad { background: #fee2e2; color: var(--bad); }
.badge.warn { background: #fef3c7; color: var(--warn); }

/* -------------------------------------------------------- post-mortem */
.pm-bar { display: flex; align-items: center; justify-content: space-between;
  gap: 4px 16px; flex-wrap: wrap; }
.pm-bar .hint { margin: 0 !important; }
.pm-bar + .pm-table-wrap { margin-top: 6px; }
.ov { text-decoration: overline; }
.runs th button.sort i, .key i:not(.ln) { font-family: Georgia,
  "Times New Roman", serif; font-size: 1.08em; text-transform: none; }
.check { display: inline-flex; align-items: center; gap: 6px;
  font-size: .92rem; color: var(--muted); cursor: pointer; }
.pm-table-wrap {
  max-height: 300px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 6px 0 12px;
}
.pm-table-wrap thead th { position: sticky; top: 0; background: var(--card);
  z-index: 1; }
.pm-plot-wrap { overflow-x: auto; }
.pm-plot { display: block; width: 100%; min-width: 640px; height: auto; }
.pm-row { fill: #fff; }
.pm-row.alt { fill: #fafbfc; }
.pm-row.picked.ok { fill: #effcf3; }
.pm-row.picked.bad { fill: #fef4f4; }
.pm-curve { fill: #dbe4f3; fill-opacity: .55; stroke: #7d8fb3;
  stroke-width: 1.2; }
.pm-mean { stroke: var(--ink); stroke-width: 1.2; stroke-dasharray: 4 3;
  stroke-opacity: .65; }
.pm-base { stroke: #c9ced8; stroke-width: 1; }
.pm-avg { stroke: var(--accent); stroke-width: 2; }
.pm-slice { fill: #fbbf24; stroke: #b45309; stroke-width: .8;
  stroke-linejoin: round; }
.pm-slice:hover { fill: #f59e0b; }
.pm-pep { fill: #dc2626; pointer-events: none; }
.pm-shop { font-size: 13px; font-weight: 700; fill: var(--ink); }
.pm-note { font-size: 11.5px; fill: var(--muted); }
.pm-note.truth { font-style: italic; }
.pm-badge.ok { fill: #dcfce7; }
.pm-badge.bad { fill: #fee2e2; }
.pm-badge-text { font-size: 9.5px; font-weight: 700; letter-spacing: .04em; }
.pm-badge-text.ok { fill: var(--ok); }
.pm-badge-text.bad { fill: var(--bad); }
.pm-tick { stroke: #a3abb9; }
.pm-ticklabel { font-size: 11px; fill: #8a93a3; }
.key {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 16px;
  margin: 6px 2px 0;
  color: var(--muted);
  font-size: .84rem;
}
.key > span { display: inline-flex; align-items: center; gap: 6px; }
.key .ln { display: inline-block; width: 22px; height: 0; }
.key .ln.avg { border-top: 2px solid var(--accent); }
.key .ln.mean { border-top: 1.5px dashed var(--ink); opacity: .7; }
.key .ln.curve { height: 10px; border: 1.2px solid #7d8fb3;
  border-bottom: 0; border-radius: 10px 10px 0 0; background: #e6ecf7; }

/* ----------------------------------------------------- runs + dialog */
.name-edit {
  font: inherit;
  width: 15ch;
  border-color: transparent;
  background: transparent;
  padding: 1px 4px;
  margin-left: -5px;
}
.name-edit:hover { border-color: #cfd4dd; }
.runs .acts { display: flex; gap: 6px; align-items: center;
  justify-content: flex-end; }
.runs .acts button:not(.x) { font-size: .8rem; padding: 2px 8px; }

.dialog {
  width: min(480px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 20px 8px;
  color: var(--ink);
  background: var(--card);
  box-shadow: 0 12px 40px rgba(16, 24, 40, .25);
}
.dialog::backdrop { background: rgba(16, 24, 40, .35); }
.dialog h2 { font-size: 1.12rem; margin: 0 0 8px; }
.dialog p { margin: 0 0 10px; }
.callout {
  background: #fff7e6;
  border-left: 3px solid var(--warn);
  border-radius: 0 8px 8px 0;
  padding: 7px 11px;
}
.dialog-buttons { justify-content: flex-end; }

footer {
  padding-top: 4px;
  padding-bottom: 28px;
  color: var(--muted);
  font-size: .9rem;
}
footer a { color: inherit; }

@media (max-width: 1360px) {
  .intro { margin-left: 24px; margin-right: 24px; }
}
@media (max-width: 900px) {
  .panel, .intro { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  header, main, footer { padding-left: 16px; padding-right: 16px; }
  .intro { margin-left: 16px; margin-right: 16px; }
  .field { grid-template-columns: 1fr; }
}
