:root {
  /* Flexoki dark — https://stephango.com/flexoki */
  --bg: #1C1B1A;        /* base-950 */
  --panel: #282726;     /* base-900 */
  --panel-2: #343331;   /* base-850 */
  --border: #403E3C;    /* base-800 */
  --grid: #343331;       /* base-850 */
  --axis: #6F6E69;      /* base-600 */
  --text: #FFFCF0;      /* paper    */
  --text-dim: #878580;  /* base-500 */
  --accent: #4385BE;    /* blue-400 */
  --series-a: #4385BE;  /* blue-400 */
  --series-b: #DA702C;  /* orange-400 */
  --series-c: #3AA99F;  /* cyan-400 */
  --series-d: #8B7EC8;  /* purple-400 */
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
}

/* --- top bar: title, tabs, global options on one line --- */

.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  row-gap: 0.25rem;
  padding: 0.25rem 0.85rem;
  min-height: 2.4rem;
  flex: 0 0 auto;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}

.topbar h1 {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.tabs { display: flex; gap: 0.2rem; }

.tabs button {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-dim);
  font: 500 0.78rem inherit;
  padding: 0.2rem 0.65rem;
  border-radius: 4px;
  cursor: pointer;
}

.tabs button:hover { color: var(--text); background: var(--panel-2); }

.tabs button[aria-selected="true"] {
  color: var(--text);
  background: var(--panel-2);
  border-color: var(--border);
}

.topbar .spacer { flex: 1; }

.topbar .opts[hidden] { display: none; }

.topbar .opts { display: flex; gap: 0.85rem; align-items: center; font-size: 0.75rem; color: var(--text-dim); }

/* --- panels fill the remaining viewport --- */

.view { flex: 1 1 auto; min-height: 0; display: none; flex-direction: column; }
.view.active { display: flex; }

.controls {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}

/* One full-width row per config so sliders get real travel, and so the
   two rows' columns line up for at-a-glance A/B comparison. */
.config {
  flex: 1 1 100%;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: center;
  gap: 0.25rem 1.6rem;
  padding: 0.3rem 0.55rem;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--slot-color);
  border-radius: 5px;
}

.config.off { opacity: 0.4; }

.config .slot {
  font: 600 0.75rem var(--mono);
  color: var(--slot-color);
}

.config-head {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.param {
  display: grid;
  grid-template-columns: minmax(0, 7.8rem) minmax(40px, 1fr) 4.2rem;
  align-items: center;
  gap: 0.4rem;
}

.param label {
  font-size: 0.72rem;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: right;
}

.param input[type="range"] { min-width: 0; }

select, input[type="number"] {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.15rem 0.3rem;
  font: 0.75rem var(--mono);
}

input[type="number"] { width: 100%; text-align: right; }
select:focus, input:focus { outline: 1px solid var(--accent); outline-offset: -1px; }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  height: 1rem;
  margin: 0;
}

input[type="range"]::-webkit-slider-runnable-track { height: 3px; background: var(--border); border-radius: 2px; }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  margin-top: -4.5px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--slot-color, var(--accent));
  cursor: pointer;
}
input[type="range"]::-moz-range-track { height: 3px; background: var(--border); border-radius: 2px; }
input[type="range"]::-moz-range-thumb {
  width: 12px; height: 12px; border: 0; border-radius: 50%;
  background: var(--slot-color, var(--accent));
  cursor: pointer;
}

.chart-wrap { flex: 1 1 auto; min-height: 0; position: relative; }

.chart-wrap canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
}

/* --- readout strip pinned to the bottom --- */

.readout {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 0 1.1rem;
  height: 3rem;
  overflow: hidden;
  padding: 0.25rem 0.7rem;
  border-top: 1px solid var(--border);
  background: var(--panel);
  font: 0.78rem var(--mono);
}

.readout .hint { color: var(--text-dim); }
.readout .k { color: var(--text-dim); }
.readout .v { font-weight: 600; }
.readout .sw { display: inline-block; width: 0.55rem; height: 0.55rem; border-radius: 2px; margin-right: 0.3rem; }

label.check { display: inline-flex; align-items: center; gap: 0.3rem; cursor: pointer; white-space: nowrap; }
input[type="checkbox"] { accent-color: var(--accent); margin: 0; }

.topbar .opts input[type="number"] { width: 3.9rem; }

.topbar button#opt-reset {
  background: var(--panel-2);
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.15rem 0.5rem;
  font: 0.75rem inherit;
  cursor: pointer;
}

.topbar button#opt-reset:hover { color: var(--text); border-color: var(--axis); }

.pad {
  flex: 1 1 100%;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.15rem 0.5rem;
  font-size: 0.75rem;
  color: var(--text-dim);
}

.pad .pad-name { font: 0.75rem var(--mono); color: var(--text); }
.pad .hint {
  color: var(--text-dim);
  cursor: help;
  text-decoration: underline dotted var(--border);
  text-underline-offset: 3px;
}

/* Anything carrying help text advertises it. */
.topbar .opts label.check[title] { cursor: help; }

.topbar .opts label.check[title] > span,
.topbar .opts label.check[title] > input[type="checkbox"] + * {
  text-decoration: underline dotted var(--text-dim);
  text-underline-offset: 3px;
}

.topbar .opts label.check[title] {
  text-decoration: underline dotted var(--text-dim);
  text-underline-offset: 3px;
}

.topbar .opts label.check[title] input { text-decoration: none; }

.readout-cursor {
  flex: 0 0 8.5rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.readout-rows {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  overflow: hidden;
}

.readout-rows > div, .readout-cursor > div {
  display: flex;
  gap: 0 1.1rem;
  white-space: nowrap;
  line-height: 1.35;
}

.param label.has-help {
  cursor: help;
  text-decoration: underline dotted var(--border);
  text-underline-offset: 3px;
}

.topbar .opts label.check[title] {
  cursor: help;
  text-decoration: underline dotted var(--text-dim);
  text-underline-offset: 3px;
}

.topbar .opts label.check[title] input { text-decoration: none; }

.config button.fit {
  background: var(--bg);
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.15rem 0.45rem;
  font: 0.72rem var(--mono);
  cursor: pointer;
}

.config button.fit:hover:enabled { color: var(--text); border-color: var(--slot-color); }
.config button.fit:disabled { opacity: 0.4; cursor: default; }

/* A parameter wants well over the ~14.5rem its label, slider and value strictly
   need, since the slider is the control being read. Three per row is the widest
   layout used; below 820px even that squeezes them, so they stack. */
@media (max-width: 820px) {
  .config { grid-template-columns: minmax(0, 1fr); }
}
