/* Cyclotron Builder GUI — tokens follow cyclotroninfo.com's global.css so the
   page slots into the site family (light and dark, system font, physics blue). */

:root {
  --bg: #fdfdfb;
  --bg-raised: #f4f4ef;
  --bg-sunken: #ebebe4;
  --text: #1d2129;
  --text-muted: #5b6472;
  --accent: #0f62a8;
  --accent-hover: #0b4d85;
  --rule: #d9dbd4;
  --code-bg: #eef0ea;
  --badge-bg: #e3ecf5;
  --warn: #b35a00;
  --warn-bg: #fff3e0;
  --bad: #b3261e;
  --bad-bg: #fde8e6;
  --good: #2e7d32;
  --good-bg: #e6f3e7;
  --fig-warm: #c05617;
  --fig-cool: #0f62a8;
  --max-width: 80rem;
}
:root:not([data-theme="light"]) { color-scheme: light dark; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14171c; --bg-raised: #1d222a; --bg-sunken: #11141a; --text: #e6e8ec; --text-muted: #9aa3b0;
    --accent: #6db3e8; --accent-hover: #92c8f0; --rule: #313842; --code-bg: #21262e; --badge-bg: #23364a;
    --warn: #e0a050; --warn-bg: #2d2416; --bad: #ef7f78; --bad-bg: #3a1f1d; --good: #7cc47f; --good-bg: #1c2f1e;
    --fig-warm: #c87c33; --fig-cool: #4f9ad8;
  }
}
:root[data-theme="dark"] {
  --bg: #14171c; --bg-raised: #1d222a; --bg-sunken: #11141a; --text: #e6e8ec; --text-muted: #9aa3b0;
  --accent: #6db3e8; --accent-hover: #92c8f0; --rule: #313842; --code-bg: #21262e; --badge-bg: #23364a;
  --warn: #e0a050; --warn-bg: #2d2416; --bad: #ef7f78; --bad-bg: #3a1f1d; --good: #7cc47f; --good-bg: #1c2f1e;
  --fig-warm: #c87c33; --fig-cool: #4f9ad8;
}

* { box-sizing: border-box; }
html { font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; line-height: 1.5; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 1rem; }
h1 { font-size: 1.6rem; margin: 0 0 0.5rem; line-height: 1.25; letter-spacing: -0.01em; }
h2 { font-size: 1.25rem; margin: 1.5rem 0 0.5rem; }
h3 { font-size: 1.05rem; margin: 0 0 0.6rem; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }
code, pre { font-family: ui-monospace, "Cascadia Code", Menlo, Consolas, monospace; font-size: 0.9em; background: var(--code-bg); border-radius: 4px; }
code { padding: 0.1em 0.35em; }
pre { padding: 0.75rem; overflow-x: auto; white-space: pre-wrap; }
table { border-collapse: collapse; width: 100%; font-size: 0.92rem; }
th, td { text-align: left; padding: 0.35rem 0.6rem; border-bottom: 1px solid var(--rule); vertical-align: top; }
th { color: var(--text-muted); font-weight: 600; }
.muted { color: var(--text-muted); }
.small { font-size: 0.86rem; }
.plain { list-style: none; padding: 0; margin: 0; }
.plain li { padding: 0.25rem 0; border-bottom: 1px solid var(--rule); }
.plain li:last-child { border-bottom: 0; }

.container { max-width: var(--max-width); margin: 0 auto; padding: 0 1rem; }
.skip-link { position: absolute; left: -9999px; top: 0; background: var(--accent); color: var(--bg); padding: 0.5rem 1rem; z-index: 100; }
.skip-link:focus { left: 0; }

header { border-bottom: 1px solid var(--rule); background: var(--bg-raised); }
.header-inner { display: flex; align-items: center; flex-wrap: wrap; gap: 0.3rem 1.2rem; padding: 0.6rem 1rem; }
.wordmark { display: inline-flex; align-items: center; gap: 0.5rem; font-weight: 700; font-size: 1.1rem; }
.badge { display: inline-block; background: var(--badge-bg); color: var(--accent); border-radius: 999px; padding: 0.1rem 0.65rem; font-size: 0.78rem; font-weight: 600; white-space: nowrap; }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.good { background: var(--good-bg); color: var(--good); }
header nav { display: flex; flex-wrap: wrap; gap: 0.2rem 1rem; font-size: 0.95rem; }   /* five links wrap at 320 px instead of widening the page */
header nav a { color: var(--text-muted); }
header nav a[aria-current="page"] { color: var(--accent); font-weight: 600; }
/* the mode switch (project decision 2026-11-07: "Simple" and "Brief" did not read as a pair): Simple | Full as one segmented control,
   separate from the full page's screen tabs */
.modes { display: inline-flex; align-items: center; border: 1px solid var(--rule); border-radius: 999px; overflow: hidden; font-size: 0.84rem; background: var(--bg-raised); }
.modes-label { padding: 0.15rem 0.6rem; color: var(--text-muted); font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.04em; }
.modes a { padding: 0.2rem 0.75rem; color: var(--text-muted); text-decoration: none; }
.modes a[aria-current="page"] { background: var(--accent); color: var(--bg); font-weight: 600; }
header nav.screens { align-items: center; }
header nav.screens .modes-label { padding-left: 0; }
header nav a.empty { opacity: 0.55; }   /* Result before any run: reachable, but visibly empty */
td.has-note { text-decoration: underline dotted; cursor: help; }
.status { margin-left: auto; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.8rem; color: var(--text-muted); }
.status.pending { color: var(--warn); }
.status.bad { color: var(--bad); }

main { padding: 1.5rem 1rem 3rem; min-height: 70vh; }
footer { border-top: 1px solid var(--rule); padding: 1.2rem 0 2rem; }

/* brief */
.brief-grid { display: grid; grid-template-columns: minmax(0, 1fr) 20rem; gap: 1.5rem; align-items: start; }
.brief .intro { margin-top: 0; }
fieldset { border: 1px solid var(--rule); border-radius: 10px; margin: 0 0 1rem; padding: 0.7rem 1rem 0.9rem; background: var(--bg-raised); min-width: 0; }   /* a fieldset's default min-inline-size is min-content: at phone width it widened the whole document (review 2026-11-07) */
legend { font-weight: 600; padding: 0 0.4rem; }
details.fs { margin: 0 0 1rem; }
details.fs > summary { cursor: pointer; font-weight: 600; padding: 0.4rem 0; }
details.fs fieldset { margin-top: 0.4rem; }
.field { margin: 0.45rem 0; min-width: 0; }
.field > label { display: block; font-weight: 500; margin-bottom: 0.2rem; }
.field.inline > label { display: inline; margin-right: 0.4rem; }
.field.inline { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem 0.5rem; }
.row2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 1.5rem; }
.row3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 1.2rem; }
.hint { color: var(--text-muted); font-size: 0.84rem; }
input[type=number], input[type=text], select { font: inherit; font-size: 0.95rem; color: var(--text); background: var(--bg); border: 1px solid var(--rule); border-radius: 6px; padding: 0.25rem 0.45rem; }
input[type=number] { width: 7.5em; }
select { max-width: 100%; min-width: 0; }
.field.inline > select { flex: 1 1 8rem; }   /* a select with a long option shrinks to its row instead of widening the page (phone-width review 2026-11-07) */
.checks label { display: block; padding: 0.15rem 0; }
.inline-checks label { display: inline-block; margin-right: 1rem; }
label.check { font-weight: 400; }
.checks .floor { color: var(--text-muted); font-size: 0.84rem; }
.owned { display: flex; gap: 0.5rem; align-items: center;; flex-wrap: wrap; }
.owned > select { flex: 1 1 10rem; min-width: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.4rem; }
.chip { background: var(--badge-bg); color: var(--accent); border-radius: 999px; padding: 0.1rem 0.3rem 0.1rem 0.7rem; font-size: 0.84rem; display: inline-flex; gap: 0.3rem; align-items: center; }
.chip button { border: 0; background: none; color: inherit; cursor: pointer; font-size: 1rem; line-height: 1; padding: 0 0.3rem; }

button { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--rule); border-radius: 6px; padding: 0.35rem 0.9rem; cursor: pointer; }
button:hover { border-color: var(--accent); }
button:disabled { opacity: 0.5; cursor: default; }
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; padding: 0.5rem 1.3rem; }
button.primary:hover { background: var(--accent-hover); }
button.small, .btn-like { font-size: 0.84rem; padding: 0.22rem 0.6rem; }
.btn-like { border: 1px solid var(--rule); border-radius: 6px; cursor: pointer; background: var(--bg); }
.btn-like:hover { border-color: var(--accent); }
button:focus-visible, select:focus-visible, input:focus-visible, a:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; margin: 1rem 0; }
.actions .spacer { flex: 1; }
.progress { display: inline-flex; align-items: center; gap: 0.6rem; font-size: 0.86rem; color: var(--text-muted); min-width: 16rem; }
.progress .bar { position: relative; width: 9rem; height: 0.5rem; background: var(--bg-sunken); border: 1px solid var(--rule); border-radius: 4px; overflow: hidden; }
.progress .fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: var(--accent); transition: width 0.5s linear; }

.rail { position: sticky; top: 1rem; display: grid; gap: 1rem; }
.card { background: var(--bg-raised); border: 1px solid var(--rule); border-radius: 10px; padding: 0.9rem 1.1rem; min-width: 0; overflow-x: auto; }   /* a wide table scrolls inside its card, never the page */
.card.warn { border-color: var(--warn); background: var(--warn-bg); }
.sentence { margin: 0.2rem 0 0.4rem; }
#brief-json { max-height: 14rem; overflow: auto; margin: 0.3rem 0 0; }
.recent li { cursor: pointer; }
.recent li:hover { color: var(--accent); }

/* result */
.result-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.6rem; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.warnings { display: grid; gap: 0.4rem; margin: 0.8rem 0; }
.warnings:empty { display: none; }
.warning { border-left: 4px solid var(--warn); background: var(--warn-bg); padding: 0.4rem 0.8rem; border-radius: 0 6px 6px 0; font-size: 0.92rem; }
.warning.bad { border-color: var(--bad); background: var(--bad-bg); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr)); gap: 0.7rem; margin: 0.8rem 0; }
.tile { background: var(--bg-raised); border: 1px solid var(--rule); border-radius: 10px; padding: 0.6rem 0.9rem; }
.tile .k { font-size: 0.8rem; color: var(--text-muted); }
.tile .v { font-size: 1.5rem; font-weight: 600; line-height: 1.2; margin: 0.15rem 0; }
.tile .s { font-size: 0.8rem; color: var(--text-muted); }
.tile.good { border-color: var(--good); }
.tile.bad { border-color: var(--bad); }
/* design facts (project decision 2026-11-07): readouts in the lab's style, grouped by section */
/* the frontier table in a half-width card: rows must not wrap into tall cells; it scrolls inside its own box instead */
.table-scroll { max-height: 24rem; overflow: auto; margin-top: 0.4rem; }
.table-scroll table { white-space: nowrap; }
.facts-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: 0.6rem 1.2rem; margin: 0.5rem 0; }
.facts-grid section { min-width: 0; }
.facts-grid h4 { margin: 0.3rem 0 0.2rem; font-size: 0.86rem; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
.facts-grid table { width: 100%; font-size: 0.9rem; }
.facts-grid td { padding: 0.12rem 0.3rem 0.12rem 0; vertical-align: top; }
.facts-grid td.k { color: var(--text-muted); }
.facts-grid td.v { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.facts-grid td.v .u { color: var(--text-muted); font-size: 0.82rem; margin-left: 0.25rem; }
.facts-grid .note { font-size: 0.82rem; color: var(--text-muted); margin: 0.2rem 0 0; }
.facts-grid .note.flag { color: var(--text); border-left: 3px solid var(--warn); padding-left: 0.5rem; }
.verify { margin: 0.8rem 0; }
.verdict { margin-top: 0.6rem; padding: 0.6rem 0.8rem; border-radius: 8px; border: 1px solid var(--rule); background: var(--bg); }
.verdict.good { border-color: var(--good); }
.verdict.bad { border-color: var(--bad); }
.two-col { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1rem; margin: 0.8rem 0; align-items: start; }
.two-col.solo { grid-template-columns: minmax(0, 1fr); }
.stack { display: grid; gap: 1rem; min-width: 0; align-content: start; }
/* result bands (project decision 2026-11-07): Design space beside Design facts, Experiments beside Drawings, the bill of materials full width —
   cards of like height share a band, so no card sits beside a much taller one */
.chart svg { width: 100%; height: auto; display: block; }
.chart text { fill: var(--text-muted); font-size: 11px; }
.chart .axis { stroke: var(--rule); }
.chart .pt { fill: var(--fig-cool); cursor: pointer; }
.chart .pt.best { fill: var(--fig-warm); }
.chart .pt:hover { stroke: var(--text); stroke-width: 1.5; }
table.compact td, table.compact th { padding: 0.25rem 0.5rem; font-size: 0.86rem; }
tr.best td { font-weight: 600; }
.report { margin-top: 0.8rem; }
.tabs { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-bottom: 0.6rem; }
.tabs button { font-size: 0.82rem; padding: 0.2rem 0.6rem; border-radius: 999px; }
.tabs button[aria-selected="true"] { background: var(--accent); color: #fff; border-color: var(--accent); }
.prose { max-width: 52rem; }
.prose h2 { font-size: 1.15rem; margin-top: 1rem; }
.prose table { margin: 0.6rem 0; }
.prose li { margin: 0.15rem 0; }
.diag button { margin-left: 0.5rem; }

.drawings { display: grid; grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr)); gap: 0.6rem; margin: 0.6rem 0; }
.drawings figure { margin: 0; background: #fff; border: 1px solid var(--rule); border-radius: 8px; padding: 0.4rem; }
.drawings img { width: 100%; height: auto; display: block; }
tr.sel { cursor: pointer; }
tr.sel:hover td { background: var(--badge-bg); }

/* compare */
.compare-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr)); gap: 1rem; }
.compare-grid table td:first-child { color: var(--text-muted); width: 45%; }

@media (max-width: 64rem) {
  .brief-grid { grid-template-columns: minmax(0, 1fr); }
  .rail { position: static; }
  .row3 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .two-col { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 40rem) {
  .row2, .row3 { grid-template-columns: minmax(0, 1fr); }
  .status { margin-left: 0; width: 100%; }
  h1 { font-size: 1.35rem; }
}

/* numeric fields are typed, not stepped: no spinner arrows */
input[type=number] { -moz-appearance: textfield; appearance: textfield; }
input[type=number]::-webkit-inner-spin-button, input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

/* design-space scatter */
.scatter { width: 100%; height: auto; display: block; background: var(--bg); border: 1px solid var(--rule); border-radius: 8px; cursor: crosshair; }
.chart-controls { gap: 0.4rem 0.9rem; margin-bottom: 0.4rem; }
.chart-controls select { font-size: 0.84rem; padding: 0.1rem 0.3rem; }
.legend { margin-left: auto; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin: 0 3px 0 6px; vertical-align: -1px; }
.sw-em { background: var(--fig-cool); } .sw-pm { background: var(--fig-warm); }
.sw-fr { background: var(--text); } .sw-cur { background: none; border: 2px solid var(--good); }

/* the "planning grade" note */
.badge-btn { cursor: pointer; border: 1px solid transparent; font: inherit; font-size: 0.78rem; font-weight: 600; line-height: 1.4; }
.badge-btn:hover { border-color: var(--accent); }
dialog.note { max-width: 36rem; background: var(--bg); color: var(--text); border: 1px solid var(--rule); border-radius: 10px; padding: 1rem 1.3rem; }
dialog.note::backdrop { background: rgba(0, 0, 0, 0.35); }
dialog.note h2 { margin-top: 0; }
dialog.note li { margin: 0.3rem 0; }

#owned-pick { max-width: 100%; width: 28rem; }
.chip { max-width: 100%; }

/* help */
.help-btn { display: inline-flex; align-items: center; justify-content: center; width: 1.15rem; height: 1.15rem; padding: 0; margin-left: 0.3rem; border-radius: 50%; border: 1px solid var(--accent); color: var(--accent); background: var(--bg); font-size: 0.72rem; font-weight: 700; line-height: 1; vertical-align: middle; cursor: help; }
.help-btn:hover, .help-btn[aria-expanded="true"] { background: var(--accent); color: #fff; }
.help-panel { position: fixed; top: 0; right: 0; bottom: 0; width: min(30rem, 100vw); background: var(--bg-raised); border-left: 1px solid var(--rule); box-shadow: -6px 0 24px rgba(0, 0, 0, 0.12); z-index: 40; display: flex; flex-direction: column; padding: 0.8rem 1.1rem 1rem; overflow: auto; }
.help-panel[hidden] { display: none; }
.help-head { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.5rem; }
.help-head b { flex: 1; font-size: 1.05rem; }
.help-body p { margin: 0.5rem 0; }
.help-body h3 { margin: 0.9rem 0 0.3rem; font-size: 0.98rem; }
.help-body .live { background: var(--badge-bg); border-radius: 6px; padding: 0.35rem 0.6rem; margin: 0.4rem 0; }
.help-links { margin-top: 0.6rem; }
.help-links a { display: block; padding: 0.1rem 0; }
.help-sources { margin-top: 0.5rem; border-top: 1px solid var(--rule); padding-top: 0.4rem; }
.help-index h2 { font-size: 1.1rem; margin-top: 1.4rem; }
.help-index .entry { margin: 0.4rem 0 0.8rem; }
.help-index .entry b { cursor: pointer; color: var(--accent); }
body.help-open main { padding-right: min(30rem, 100vw); }
@media (max-width: 64rem) { body.help-open main { padding-right: 1rem; } }
