/* JE Validation console — ad-studio visual identity (user decision,
 * 2026-08-06 fixlist round 2): palette, gradient topbar, Inter, white panels
 * on #f1f0f6, light-only. Component classes (.crow/.box/.lab/.rstep/.stat/
 * .results-table…) keep their names from the spec-mockup era so app.js is
 * unaffected by the reskin. Layout: symmetric three-panel configure grid
 * (equal-width side panels flanking the middle), every screen inside the
 * same .panel chrome.
 */

:root {
  color-scheme: light;
  --brand-magenta: #d6007e;
  --brand-purple: #3a2b8f;
  --gradient: linear-gradient(135deg, #d6007e 0%, #7b2ea8 55%, #3a2b8f 100%);

  --bg: #f1f0f6;             /* page */
  --panel: #ffffff;
  --panel-2: #f6f5fb;
  --panel-3: #eeecf5;
  --ink: #16131f;
  --ink-2: #57526b;
  --ink-3: #8b86a0;
  --line: rgb(20 18 28 / 10%);
  --line-2: rgb(20 18 28 / 16%);
  --accent: var(--brand-magenta);
  --accent-2: var(--brand-purple);
  --accent-soft: #fbe9f3;

  --l1: #0b8f41; --l1bg: #e7f5ec;   /* success */
  --l2: #2a78d6; --l2bg: #e8f1fb;   /* blue */
  --l3: #b57200; --l3bg: #faf0dd;   /* warning */
  --l4: #c13746; --l4bg: #fae9eb;   /* danger */

  --shadow: 0 1px 2px rgb(20 18 28 / 6%), 0 10px 34px rgb(20 18 28 / 8%);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
          "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; color: inherit; }

::selection { background: var(--accent-soft); color: var(--ink); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* an author display rule that ties with the UA's [hidden]{display:none} wins
   by source order; this global rule closes that hole app-wide. */
[hidden] { display: none !important; }

.wrap { max-width: 1280px; margin: 0 auto; padding: 0 20px; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ---- topbar (ad-studio gradient brand bar) -------------------------------- */

.topbar {
  display: flex;
  align-items: center;
  gap: .9rem;
  padding: .9rem 1.25rem;
  color: #fff;
  background: var(--gradient);
  box-shadow: 0 4px 20px rgb(58 43 143 / 16%);
}

.brand-mark {
  display: grid;
  width: 2.5rem;
  height: 2.5rem;
  place-items: center;
  color: var(--brand-magenta);
  background: #fff;
  border-radius: 11px;
  font-size: 1.05rem;
  font-weight: 900;
  letter-spacing: -0.02em;
  flex: none;
}

.brand-text { flex: 1; min-width: 0; }

h1 {
  font-size: 15px;
  font-weight: 750;
  letter-spacing: -0.01em;
  margin: 0;
  color: #fff;
}

.brand-sub {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgb(255 255 255 / 72%);
}

#health-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: rgb(255 255 255 / 45%); flex: none;
}
#health-dot.ok { background: #6ef0a4; box-shadow: 0 0 8px 0 rgb(110 240 164 / 80%); }
#health-dot.down { background: #ffb3bb; box-shadow: 0 0 8px 0 rgb(255 179 187 / 80%); }

main.wrap { padding-top: 22px; padding-bottom: 64px; }

/* ---- panel chrome (shared by all three screens) ---------------------------- */

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-title {
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--accent-2);
  background: var(--panel-2);
  border-bottom: 1px solid var(--line);
  padding: 9px 16px;
}

.panel-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-body { padding: 14px 16px; }

/* ---- shared component language -------------------------------------------- */

.lab {
  font-size: 10px; letter-spacing: 0.09em; text-transform: uppercase;
  color: var(--ink-3); font-weight: 680; margin: 18px 0 6px;
}
.lab:first-child { margin-top: 0; }
.lab-sub { text-transform: none; letter-spacing: normal; font-weight: 400; }
.boxlab { margin: 0 0 8px; }

.box {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 13px; margin: 0 0 14px;
}
.box:last-child { margin-bottom: 0; }
.box.invalid { border-color: var(--l4); }

fieldset.box { min-width: 0; }
/* visually-hidden accessible name for the fieldset; .boxlab is the visible one */
fieldset.box > legend {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.pill {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px;
  padding: 4px 10px; border: 1px solid var(--line-2); border-radius: 999px;
  color: var(--ink-2); background: var(--panel);
}

.chip {
  cursor: pointer; user-select: none; font-size: 11.5px; padding: 5px 11px;
  border-radius: 999px; border: 1px solid var(--line-2); background: var(--panel);
  color: var(--ink-2);
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

.tier {
  flex: 0 0 auto; font-size: 9.5px; font-weight: 700; padding: 1px 6px;
  border-radius: 4px;
}
.tier.L1 { color: var(--l1); background: var(--l1bg); }
.tier.L2 { color: var(--l2); background: var(--l2bg); }
.tier.L3 { color: var(--l3); background: var(--l3bg); }
.tier.L4 { color: var(--l4); background: var(--l4bg); }

.stat {
  font-family: var(--mono); font-size: 10.5px; text-transform: uppercase;
  letter-spacing: 0.04em; padding: 2px 8px; border-radius: 999px;
  border: 1px solid var(--line-2); color: var(--ink-2); background: var(--panel);
}
.stat.status-queued { color: var(--ink-3); }
.stat.status-running { color: var(--accent-2); border-color: var(--accent-2); }
.stat.status-finished, .stat.ok { color: var(--l1); border-color: var(--l1); }
.stat.status-failed, .stat.status-interrupted, .stat.bad { color: var(--l4); border-color: var(--l4); }
.stat.status-aborted { color: var(--l3); border-color: var(--l3); }

.dials { display: flex; flex-wrap: wrap; gap: 5px; }
.dial {
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
  border: 1px dashed var(--line-2); color: var(--ink-2);
}

.rnote {
  font-size: 12.5px; margin: 10px 0 0; padding: 7px 10px; border-radius: 8px;
  background: var(--panel);
}
.rnote.good { color: var(--l1); background: var(--l1bg); border: 1px solid var(--l1); }
.rnote.bad { color: var(--l4); background: var(--l4bg); border: 1px solid var(--l4); }
.rnote.warn { color: var(--l3); background: var(--l3bg); border: 1px solid var(--l3); }

.kvline { font-size: 12.5px; margin: 4px 0; color: var(--ink-2); }
.kvline b { color: var(--ink); }
.fieldnote { font-size: 11px; color: var(--ink-3); margin-top: 4px; }

.wbar {
  display: flex; height: 6px; border-radius: 4px; overflow: hidden;
  margin: 4px 0 10px; border: 1px solid var(--line);
}

pre {
  font-family: var(--mono); font-size: 11px; line-height: 1.55;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px; overflow: auto; color: var(--ink-2); margin: 0;
  white-space: pre-wrap; word-break: break-word;
}

/* ---- inputs ---------------------------------------------------------------- */

input[type="number"], input[type="search"], select {
  background: var(--panel); border: 1px solid var(--line-2); border-radius: 7px;
  color: var(--ink); padding: 5px 8px; font-size: 12.5px;
}
.field-row select { flex: 1; min-width: 0; font-size: 12px; }

input[type="range"] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 3px;
  background: var(--line-2); border-radius: 2px; outline-offset: 4px;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 10px; height: 16px; border-radius: 3px;
  background: var(--accent); cursor: pointer; border: none;
}
input[type="range"]::-moz-range-thumb {
  width: 10px; height: 16px; border-radius: 3px; background: var(--accent);
  cursor: pointer; border: none;
}
input[type="range"]:disabled { opacity: 0.5; }
input[type="range"]:disabled::-webkit-slider-thumb { background: var(--ink-3); }
input[type="range"]:disabled::-moz-range-thumb { background: var(--ink-3); }

input[type="checkbox"] { accent-color: var(--accent); }

.launch-row { display: flex; justify-content: flex-end; margin-top: 12px; }
#launch {
  background: var(--gradient); color: #fff; font-weight: 650; font-size: 12.5px;
  border: none; border-radius: 8px;
  padding: 9px 24px; cursor: pointer; transition: filter 100ms ease;
  box-shadow: 0 2px 10px rgb(214 0 126 / 25%);
}
#launch:hover:not(:disabled) { filter: brightness(1.08); }
#launch:active:not(:disabled) { filter: brightness(0.94); }
#launch:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; }

@media (prefers-reduced-motion: reduce) {
  #launch, .ep-tile, .crow { transition: none; }
}

/* ---- configure: symmetric 3-panel grid ------------------------------------- */

.configure-grid {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 280px;
  gap: 16px;
  align-items: start;
}

@media (max-width: 980px) {
  .configure-grid { grid-template-columns: 1fr; }
  .col-tasks .crowlist { max-height: 220px; }
}

.crowlist {
  max-height: 520px; overflow-y: auto; border: 1px solid var(--line);
  border-radius: 10px; background: var(--panel);
}

.crow {
  display: flex; gap: 8px; align-items: center; width: 100%;
  padding: 8px 10px; cursor: pointer; border: none; border-bottom: 1px solid var(--line);
  background: transparent; color: inherit; text-align: left;
}
.crow:last-child { border-bottom: none; }
.crow:hover { background: var(--panel-2); }
.crow.on { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.tid { font-size: 11px; color: var(--ink-3); flex: 0 0 auto; }
.ctitle { flex: 1; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.field-row {
  display: flex; gap: 8px; align-items: center; padding: 7px 0;
  border-top: 1px solid var(--line);
}
.field-row:first-of-type { border-top: none; }
.fieldlabel { font-size: 11.5px; color: var(--ink-3); flex: 0 0 108px; }
.field-row input[type="range"] { flex: 1; }
.field-row input[type="number"] { width: 84px; text-align: right; }
.field-row input#token-ceiling { width: 132px; }
.fieldval { font-size: 11.5px; width: 40px; text-align: right; color: var(--ink-2); }

#knobs > .field-row:first-child { border-top: none; }

.toolgrid { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.ctool {
  display: inline-flex; gap: 5px; align-items: center; cursor: pointer; font-size: 11.5px;
}
.ctool.off { opacity: 0.4; cursor: not-allowed; }
.ctool input:disabled { cursor: not-allowed; }

/* ---- model dropdown --------------------------------------------------------- */

.model-field { position: relative; flex: 1; min-width: 0; }

.dd-btn {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  width: 100%; padding: 6px 10px; font-size: 12.5px; cursor: pointer;
  background: var(--panel); border: 1px solid var(--line-2); border-radius: 7px;
  color: var(--ink); text-align: left;
}
.dd-btn:hover { border-color: var(--accent); }
.dd-btn[aria-expanded="true"] { border-color: var(--accent); }
.dd-caret { color: var(--ink-3); font-size: 10px; flex: none; }

.dd-panel {
  position: absolute; z-index: 30; top: calc(100% + 4px); left: 0; right: 0;
  min-width: 300px;
  background: var(--panel); border: 1px solid var(--line-2); border-radius: 10px;
  box-shadow: var(--shadow); padding: 8px;
}
.dd-panel input[type="search"] { width: 100%; margin-bottom: 6px; }

.dd-list { max-height: 260px; overflow-y: auto; }

.dd-note { font-size: 11px; color: var(--ink-3); margin: 4px 2px; }

.mrow {
  display: grid; grid-template-columns: 18px minmax(0, 1fr) auto; align-items: center;
  gap: 8px; padding: 6px 8px; border-radius: 7px; cursor: pointer;
  font-size: 12px;
}
.mrow:hover { background: var(--panel-2); }
.mrow-disabled { opacity: 0.45; cursor: not-allowed; }
.mrow-main { min-width: 0; }
.model-name { color: var(--ink); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.model-id { color: var(--ink-3); font-size: 10.5px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.model-price { color: var(--ink-3); white-space: nowrap; font-size: 10.5px; }

.model-tags { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 0 2px 116px; }
.model-tags:empty { display: none; }
.mtag {
  display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px;
  padding: 3px 6px 3px 10px; border-radius: 999px;
  background: var(--accent-soft); color: var(--ink-2); border: 1px solid var(--line);
}
.mtag .mtag-x {
  border: none; background: none; cursor: pointer; padding: 0 4px;
  color: var(--ink-3); font-size: 12px; line-height: 1; border-radius: 50%;
}
.mtag .mtag-x:hover { color: var(--l4); }

.baseline-row { flex-wrap: wrap; }
.baseline-check {
  display: inline-flex; gap: 5px; align-items: center; cursor: pointer;
  font-size: 11.5px; color: var(--ink-2);
}

/* ---- prompt preview --------------------------------------------------------- */

.prompt-preview { margin-top: 10px; }
.prompt-preview pre { max-height: 260px; }
.prompt-preview .lab { margin-top: 10px; }
.prompt-preview .lab:first-child { margin-top: 0; }

#config-preview { max-height: 420px; }

/* ---- live view -------------------------------------------------------------- */

.run-meta-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; text-transform: none; letter-spacing: normal; font-weight: 400; }

.conn-badge {
  font-family: var(--mono); font-size: 10px; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--ink-3);
}
.conn-badge.conn-live::before { content: "● "; color: var(--l1); }
.conn-badge.conn-reconnecting::before { content: "● "; color: var(--l3); }
.conn-badge.conn-closed::before, .conn-badge.conn-connecting::before { content: "● "; color: var(--ink-3); }

.episode-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 8px; margin-bottom: 16px;
}

.ep-tile {
  display: flex; flex-direction: column; align-items: flex-start; gap: 5px; text-align: left;
  background: var(--panel); border: 1px solid var(--line-2); border-radius: 10px;
  padding: 9px 10px; cursor: pointer; transition: border-color 100ms ease;
}
.ep-tile:hover { border-color: var(--accent); }
.ep-tile.ep-tile-focused { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }

.ep-tile-chip {
  display: inline-flex; align-items: center; gap: 4px; font-family: var(--mono);
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em;
}
.ep-tile-glyph { font-size: 11px; line-height: 1; }
.ep-tile-chip.status-queued { color: var(--ink-3); }
.ep-tile-chip.status-running { color: var(--accent-2); }
.ep-tile-chip.status-finished { color: var(--l1); }
.ep-tile-chip.status-failed, .ep-tile-chip.status-interrupted { color: var(--l4); }
.ep-tile-chip.status-aborted { color: var(--l3); }

.ep-tile-name { font-size: 12px; color: var(--ink); word-break: break-all; }
.ep-tile-seed { font-size: 11px; color: var(--ink-3); }
.ep-tile-counters { display: flex; gap: 10px; font-size: 11px; color: var(--ink-3); }
.ep-tile-reason { font-size: 10px; color: var(--l4); word-break: break-word; }

.player-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 14px; }
@media (max-width: 980px) { .player-grid { grid-template-columns: 1fr; } }

.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.panel-head h2, .panel-head h3 {
  margin: 0; font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--ink-3);
}
#step-feed-title { font-family: var(--mono); font-size: 11px; color: var(--ink-2); }

.step-feed { max-height: 520px; overflow-y: auto; padding-right: 2px; }

.rstep {
  background: var(--panel); border: 1px solid var(--line); border-left-width: 3px;
  border-radius: 8px; padding: 7px 10px; margin-bottom: 6px; font-size: 12px;
}
.rhead { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.rn { color: var(--ink-3); font-size: 10.5px; min-width: 16px; }
.rtool { color: var(--accent-2); font-weight: 600; font-size: 11.5px; }
.rargs { color: var(--ink-3); font-size: 11px; flex: 1; }
.rtok { color: var(--ink-3); font-size: 10.5px; }
.robs { font-size: 12px; color: var(--ink-2); margin-top: 3px; padding-left: 24px; }

.scoreboard { position: sticky; top: 12px; }
.kv { width: 100%; font-size: 12.5px; border-collapse: collapse; }
.kv td { padding: 4px 0; border: none; }
.kv td:last-child { text-align: right; color: var(--ink); }
.statusline { font-size: 11px; color: var(--ink-2); }

/* ---- run history ------------------------------------------------------------- */

#history { margin-top: 20px; }
#history .crowlist { max-height: 260px; }

.history-row {
  display: grid;
  grid-template-columns: 110px 76px minmax(0, 1fr) 64px 72px 84px;
  gap: 10px;
}
.history-id { font-size: 11.5px; color: var(--ink-3); }
.history-task { font-size: 12px; }
.history-models {
  font-size: 12px; color: var(--ink-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.history-seeds { font-size: 11.5px; color: var(--ink-3); text-align: right; }
.history-cost { font-size: 11.5px; text-align: right; }
.history-row .stat { justify-self: end; }

@media (max-width: 980px) {
  .history-row { grid-template-columns: 96px minmax(0, 1fr) 72px 84px; }
  .history-models, .history-seeds { display: none; }
}

/* ---- results ----------------------------------------------------------------- */

#live, #results { margin-top: 20px; }

.raw-toggle {
  background: var(--panel); border: 1px solid var(--line-2); color: var(--ink-3);
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; border-radius: 999px;
  padding: 4px 10px; cursor: pointer;
}
.raw-toggle:hover { color: var(--accent); border-color: var(--accent); }

.results-level { margin-bottom: 22px; }
.results-level:last-child { margin-bottom: 0; }

.results-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.results-table th {
  text-align: left; font-size: 10.5px; font-weight: 640; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--ink-3); border-bottom: 1px solid var(--line-2);
  padding: 6px 8px;
}
.results-table td { padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; color: var(--ink-2); }
.results-table .num { text-align: right; font-variant-numeric: tabular-nums; }

.results-model-row, .step-timeline-row,
.results-seed-row:not(.results-seed-row-noreport) { cursor: pointer; }
.results-model-row:hover, .step-timeline-row:hover,
.results-seed-row:not(.results-seed-row-noreport):hover { background: var(--accent-soft); }
.results-seed-row-noreport { color: var(--ink-3); }

.rationale-cell { font-style: italic; color: var(--ink-3); }
.step-timeline-row-error { color: var(--l4); }

.badge {
  font-family: var(--mono); font-size: 10px; text-transform: uppercase;
  padding: 1px 6px; border-radius: 4px; border: 1px solid var(--line-2);
}
.badge-ok { color: var(--l1); border-color: var(--l1); }
.badge-error { color: var(--l4); border-color: var(--l4); }

.step-detail-row pre { white-space: pre-wrap; word-break: break-word; }

.breakdown { margin-bottom: 14px; }
