/* Motor & Prop Bench. Colours are the other tools' tokens, so the platform
   reads as one; the charts' motors take the validated categorical palette in
   its fixed order. */

:root {
  color-scheme: light;
  --page: #f9f9f7; --surface: #fcfcfb; --surface-2: #f3f2ee;
  --ink: #0b0b0b; --ink-2: #52514e; --muted: #898781;
  --border: rgba(11, 11, 11, 0.10);
  --good-ink: #006300; --warning-ink: #8a5a00; --critical-ink: #b3261e; --critical: #d03b3b;
  --accent: #2a78d6; --focus: #2a78d6;
  --grid: #e1e0d9; --axis: #c3c2b7; --series-1: #2a78d6;
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.04), 0 2px 8px rgba(11, 11, 11, 0.04);
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0d0d0d; --surface: #1a1a19; --surface-2: #232321;
    --ink: #ffffff; --ink-2: #c3c2b7; --muted: #898781;
    --border: rgba(255, 255, 255, 0.10);
    --good-ink: #0ca30c; --warning-ink: #fab219; --critical-ink: #e66767;
    --accent: #3987e5; --focus: #6da7ec;
    --grid: #2c2c2a; --axis: #383835; --series-1: #3987e5; --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d; --surface: #1a1a19; --surface-2: #232321;
  --ink: #ffffff; --ink-2: #c3c2b7; --muted: #898781;
  --border: rgba(255, 255, 255, 0.10);
  --good-ink: #0ca30c; --warning-ink: #fab219; --critical-ink: #e66767;
  --accent: #3987e5; --focus: #6da7ec;
  --grid: #2c2c2a; --axis: #383835; --series-1: #3987e5; --shadow: none;
}

/* The motors' colours: the categorical palette's eight slots, in order
   (light, and stepped for the dark surface). */
:root {
  --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100;
  --series-5: #e87ba4; --series-6: #008300; --series-7: #4a3aa7; --series-8: #e34948;
  --stop: #d03b3b;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
    --series-5: #d55181; --series-6: #008300; --series-7: #9085e9; --series-8: #e66767;
  }
}
:root[data-theme="dark"] {
  --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
  --series-5: #d55181; --series-6: #008300; --series-7: #9085e9; --series-8: #e66767;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--page); color: var(--ink); font-family: var(--font);
             font-size: 14px; line-height: 1.45; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
body.loading .page { visibility: hidden; }
a { color: var(--accent); }

.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 14px;
          flex-wrap: wrap; padding: 10px 20px; background: var(--surface);
          border-bottom: 1px solid var(--border); }
.back { color: var(--accent); text-decoration: none; white-space: nowrap; }
.back:hover { text-decoration: underline; }
.brand { min-width: 0; }
.brand h1 { font-size: 16px; font-weight: 650; margin: 0; }
.subtitle { margin: 0; color: var(--ink-2); font-size: 13px; }
.actions { display: flex; gap: 6px; margin-left: auto; align-items: center; flex-wrap: wrap; }
.btn { display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--border);
       background: var(--surface); border-radius: 8px; padding: 5px 11px; cursor: pointer;
       white-space: nowrap; text-decoration: none; color: inherit; }
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.big { padding: 8px 18px; font-weight: 600; }
.file-btn { position: relative; }
.actions select { width: auto; margin-top: 0; padding: 5px 8px; }

.page { padding: 16px 20px; display: grid; gap: 16px; }
@media (max-width: 900px) { .page { padding: 12px; gap: 12px; } }
.layout { display: grid; grid-template-columns: minmax(300px, 420px) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 980px) { .layout { grid-template-columns: 1fr; } }
.side, .main { display: grid; gap: 16px; min-width: 0; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
        box-shadow: var(--shadow); padding: 14px 16px; min-width: 0; }
.card h2 { font-size: 15px; margin: 0 0 6px; }
.card h3 { font-size: 13.5px; margin: 12px 0 4px; color: var(--ink-2); }
.intro ul.uses { margin: 4px 0 8px; padding-left: 20px; }
.intro ul.uses li { margin: 2px 0; }
.profile-bar { margin-top: 10px; }

fieldset { border: 0; margin: 12px 0 0; padding: 0; min-width: 0; }
legend, label { font-weight: 600; font-size: 13px; padding: 0; }
.small-label { display: block; margin-top: 8px; }
fieldset.three { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px 10px; }
fieldset.three label { display: block; font-size: 12.5px; }
input:not([type=checkbox]):not([type=radio]):not([type=file]), select, textarea {
  width: 100%; margin-top: 4px; padding: 6px 8px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--surface); }
textarea { font-family: var(--mono); font-size: 12.5px; resize: vertical; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.row select { width: auto; margin-top: 0; }
.invalid { border-color: var(--critical) !important; }
.hint { color: var(--muted); font-size: 12.5px; margin: 4px 0 0; }
.hint.block { display: block; font-weight: 400; margin: 1px 0 0; }
.indent { margin-left: 24px; }
.caution { color: var(--warning-ink); font-size: 12.5px; margin: 6px 0 0; }
.muted { color: var(--ink-2); margin: 0; }
.check { display: flex; gap: 8px; align-items: baseline; margin-top: 8px; cursor: pointer; }
.check input, .choice input { transform: translateY(2px); flex: none; }
.choice { display: flex; gap: 8px; align-items: flex-start; margin-top: 6px; cursor: pointer; font-weight: 400; }
.choice strong { font-weight: 600; }
.tare-row { max-width: 220px; margin-top: 6px; }
.tare-row label { font-size: 12.5px; }
.motor-picks { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.motor-picks .check { margin-top: 4px; font-weight: 500; }
.danger { margin-top: 12px; border: 1px solid var(--critical); border-radius: 8px; padding: 8px 12px; }
.danger h3 { color: var(--critical-ink); margin-top: 4px; }
.danger ul { margin: 2px 0 6px; padding-left: 18px; font-size: 13px; }
.danger .check { font-weight: 500; font-size: 13px; }
.error-box { margin-top: 10px; padding: 8px 10px; border-radius: 8px; color: var(--critical-ink);
             border: 1px solid var(--critical); font-size: 13px; }
.error-box ul { margin: 0; padding-left: 18px; }
.plan-summary { margin: 12px 0 0; font-size: 13px; }
.csv-box { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 10px; }
.csv-box summary { cursor: pointer; font-weight: 600; }
.csv-columns { padding-left: 18px; }

/* the connection */
.fc-line { margin: 6px 0 0; }
.fc-safe { color: var(--good-ink); font-weight: 600; }
.fc-armed { color: var(--critical-ink); font-weight: 600; }
.fc-texts { margin: 6px 0 0; padding-left: 18px; color: var(--ink-2); font-size: 12.5px; font-family: var(--mono);
            overflow-wrap: anywhere; }
.kv { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 2px 12px; margin: 8px 0 0; font-size: 13px; }
.kv dt { color: var(--ink-2); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.mono { font-family: var(--mono); }
.warn-text { color: var(--warning-ink); }
.bad-text { color: var(--critical-ink); }
.good-text { color: var(--good-ink); }

/* the run */
.run-status { font-size: 15px; font-weight: 600; margin: 4px 0; }
.progress { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin: 6px 0 10px; }
.progress > div { height: 100%; background: var(--accent); }
.prompt { border: 2px solid var(--accent); border-radius: 10px; padding: 10px 12px; margin: 10px 0; }
.prompt label { display: block; font-size: 14px; }
.prompt input { max-width: 180px; font-size: 18px; }
.table-wrap { overflow-x: auto; }
.table { border-collapse: collapse; width: 100%; font-size: 13px; font-variant-numeric: tabular-nums; }
.table th, .table td { text-align: right; padding: 5px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table th:first-child, .table td:first-child { text-align: left; }
.table th { color: var(--ink-2); font-weight: 600; }
.table tr.testing td { background: var(--surface-2); font-weight: 600; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: 0; }

.stopbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; display: flex; gap: 14px; align-items: center;
           flex-wrap: wrap; padding: 10px 20px; background: var(--surface); border-top: 2px solid var(--stop);
           box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.15); }
.stop-btn { background: var(--stop); color: #fff; border: 0; border-radius: 12px; padding: 14px 36px; font-size: 20px;
            font-weight: 750; letter-spacing: .04em; cursor: pointer; min-width: 220px; }
.stop-btn:hover { filter: brightness(1.1); }
.stop-status { font-size: 14px; font-weight: 600; }
body.running { padding-bottom: 90px; }

/* the results */
.results-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: flex-start; }
.results-head .row { margin-top: 0; }
.numbers { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 10px; }
.numbers > div { width: 190px; }
.numbers label { font-size: 12.5px; }
.findings { list-style: none; margin: 8px 0 0; padding: 0; }
.findings li { display: flex; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.findings .mark { flex: none; font-weight: 700; width: 1.3em; text-align: center; }
.findings .good .mark { color: var(--good-ink); }
.findings .warn .mark { color: var(--warning-ink); }
.findings .bad .mark { color: var(--critical-ink); }
.findings .info .mark { color: var(--accent); }
.params-table th, .params-table td { text-align: left; }
.params-table td.name { font-family: var(--mono); font-weight: 600; text-align: left; }
.params-table td.why { white-space: normal; text-align: left; color: var(--ink-2); min-width: 220px; }
.params-table .gloss { display: block; font-family: var(--font); font-weight: 400; color: var(--muted); font-size: 12px; }
.facts { margin: 6px 0 0; padding-left: 18px; }
.facts li { margin: 3px 0; }
.sizing pre { background: var(--surface-2); border-radius: 8px; padding: 8px 10px; overflow-x: auto; font-size: 12.5px; margin: 6px 0 0; }
.sub { margin-top: 18px; padding-top: 12px; border-top: 1px solid var(--border); }
.sub > h3 { margin-top: 0; font-size: 14px; color: var(--ink); }
details.data summary { cursor: pointer; font-weight: 600; }

.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px; margin-top: 8px; }
.chart { margin: 0; min-width: 0; }
.chart figcaption { font-size: 13px; margin-bottom: 4px; }
.legend { display: flex; flex-wrap: wrap; gap: 2px 12px; font-size: 12.5px; color: var(--ink-2); margin: 2px 0 4px; }
.legend .line { display: inline-block; width: 16px; height: 0; border-top: 2px dashed var(--ink-2); margin-right: 6px;
                vertical-align: 3px; }
svg.plot { width: 100%; height: auto; display: block; overflow: visible; }
svg.plot .grid { stroke: var(--grid); stroke-width: 1; }
svg.plot .axis { stroke: var(--axis); stroke-width: 1; }
svg.plot .tick, svg.plot .axis-label { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
svg.plot .series { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
svg.plot .dot { stroke: var(--surface); stroke-width: 2; }
svg.plot .fit { fill: none; stroke: var(--ink-2); stroke-width: 2; }
svg.plot .fit.beyond { stroke-dasharray: 5 4; }
svg.plot .ref { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
svg.plot .ref-label { fill: var(--muted); font-size: 10.5px; }
svg.plot .flag { fill: none; stroke: var(--critical); stroke-width: 2; }
svg.plot .crosshair { stroke: var(--axis); stroke-width: 1; }
svg.plot .hit { fill: transparent; cursor: crosshair; }
.chart-empty { color: var(--muted); font-size: 13px; border: 1px dashed var(--border); border-radius: 8px; padding: 18px;
               text-align: center; }
.tooltip { position: fixed; z-index: 50; pointer-events: none; background: var(--surface);
           border: 1px solid var(--border); border-radius: 6px; padding: 4px 8px; font-size: 12.5px;
           box-shadow: var(--shadow); font-variant-numeric: tabular-nums; max-width: 260px; }
.tooltip div { white-space: nowrap; }

.about { padding: 4px 20px 24px; color: var(--muted); font-size: 12.5px; }
.about a { color: var(--ink-2); }
@media (max-width: 900px) { .about { padding: 4px 12px 20px; } }
@media (max-width: 600px) {
  .stopbar { padding: 8px 12px; }
  .stop-btn { width: 100%; }
  .numbers > div { width: calc(50% - 8px); }
}
