/* modern.css - the Modern workspace.
 *
 * The visual language follows the official ROOT website (root.cern): a flat
 * ROOT-blue masthead (#346295), warm sand hairlines (#e9dcbe) instead of
 * shadows, a pale blue-gray footer (#e5ebf2), dark Material-Ocean code
 * surfaces (#263238), a uniform 4px radius, no gradients, and the system
 * font stack. The sizing is looser than root.cern's because this is a form a
 * student works in, not a page they read.
 *
 * Layout: three pages for measurements, fit settings, and results. Previously a results
 * rail on the right that stays in view while you scroll, so changing a
 * setting and re-fitting never hides the plot.
 *
 * This file is loaded after style.css and overrides it for `body.modern`.
 */

:root {
  --blue: #346295;          /* ROOT's brand blue: masthead, links, accents */
  --blue-dark: #27496f;
  --blue-soft: #eaf0f7;     /* tinted surface for selected / highlighted things */
  --ink: #343434;           /* ROOT body text */
  --ink-soft: #5d6873;
  --muted: #7c8792;
  --sand: #e9dcbe;          /* ROOT's signature hairline */
  --line: #dfe5ec;          /* cooler hairline for dense controls */
  --paper: #ffffff;
  --footer-bg: #e5ebf2;
  --code-bg: #263238;       /* ROOT's code blocks */
  --code-ink: #eeffff;
  --code-accent: #82aaff;
  --ok: #3fa63f;
  --warn: #d67f05;
  --danger: #ee5f5b;
  --radius: 4px;
  --masthead-h: 60px;
  --page: 1320px;

  /* names the shared style.css uses, remapped to the ROOT palette */
  --frame: #ffffff; --frame-2: #f7f9fb; --entry: #ffffff; --shadow: var(--line);
  --dark: var(--line); --hilite: #ffffff; --entry-line: var(--line);
  --accent: var(--blue); --accent-ink: #ffffff; --link: var(--blue);
  --err: #b3261e; --control-h: 42px;
  --font: -apple-system, BlinkMacSystemFont, "Roboto", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --mono: Menlo, Consolas, "Lucida Console", monospace;
}

/* ============================================================ base */

body.modern {
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.6 var(--font);
  min-height: 100svh;
  display: flex;
  flex-direction: column;
}
body.modern h1, body.modern h2, body.modern h3 { font-weight: 600; line-height: 1.25; margin: 0; letter-spacing: -0.01em; }
body.modern a { color: var(--blue); text-decoration: none; }
body.modern a:hover { text-decoration: underline; }
body.modern p { margin: 0 0 1em; }
body.modern code { font-family: var(--mono); font-size: .85em; background: #f4f6f8; border-radius: 3px; padding: 1px 5px; color: #2f4a68; }

.skip-link { position: fixed; top: -80px; left: 16px; z-index: 200; background: #fff; color: var(--blue); padding: 12px 16px; border: 1px solid var(--sand); border-radius: var(--radius); }
.skip-link:focus { top: 12px; }

a:focus-visible, button:focus-visible, summary:focus-visible,
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid #7ba7d4; outline-offset: 2px;
}

/* ============================================================ masthead */



/* ============================================================ worksheet bar */

.worksheet-bar {
  display: flex; align-items: end; gap: 24px; flex-wrap: wrap;
  margin-bottom: 24px; padding: 0 0 24px; border-bottom: 1px solid var(--line);
}
.worksheet-bar .title-field { flex: 1 1 280px; min-width: 0; max-width: 580px; }
.worksheet-bar label { display: block; margin-bottom: 6px; font-weight: 600; font-size: 14px; }
body.modern #doc-title {
  width: 100%; min-height: 42px; padding: 9px 12px;
  border: 1px solid #9dabb9; border-radius: var(--radius); background: #fff; color: var(--ink);
  font-size: 16px; font-weight: 400;
}
body.modern #doc-title::placeholder { color: #647382; opacity: 1; }
.doc-actions { display: flex; align-items: center; gap: 8px; }
.example-actions { max-width: 440px; margin-bottom: 24px; }
.example-actions > span { font-size: 14px; font-weight: 600; margin-right: 4px; }

/* ============================================================ buttons */

body.modern button {
  font: inherit; font-size: 14px; color: var(--ink); background: #fff;
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 9px 16px; min-height: 40px; cursor: pointer; box-shadow: none;
  transition: background .15s, border-color .15s;
}
body.modern button:hover:not(:disabled) { background: var(--blue-soft); border-color: #b9cde2; }
body.modern button:active:not(:disabled) { background: #dde8f4; }
body.modern button:disabled { color: #a6aeb6; background: #f6f7f9; border-color: var(--line); cursor: default; text-shadow: none; }
body.modern button.primary {
  background: var(--blue); border-color: var(--blue); color: #fff; font-weight: 600;
  padding: 12px 28px; min-height: 46px; font-size: 15px;
}
body.modern button.primary:hover:not(:disabled) { background: var(--blue-dark); border-color: var(--blue-dark); }
body.modern button.primary:disabled { background: #9fb4cb; border-color: #9fb4cb; color: #edf2f8; }
body.modern button.small { font-size: 13px; padding: 6px 12px; min-height: 34px; }
body.modern button.ghost { border-color: transparent; background: transparent; color: var(--blue); }
body.modern button.ghost:hover:not(:disabled) { background: var(--blue-soft); border-color: transparent; }

/* the round "?" next to a heading */
body.modern .help-btn {
  width: 22px; height: 22px; min-height: 22px; padding: 0; border-radius: 50%;
  border: 1px solid #b9cde2; color: var(--blue); background: #fff;
  font-size: 12px; font-weight: 700; line-height: 1; display: inline-flex;
  align-items: center; justify-content: center; flex: none;
}
body.modern .help-btn:hover:not(:disabled) { background: var(--blue); color: #fff; border-color: var(--blue); }

/* ============================================================ workspace grid */

.workspace {
  flex: 1; width: min(var(--page), calc(100% - 48px)); margin: 0 auto;
  padding: 28px 0 40px;
  display: block;
  max-width: 1060px;
}
.worksheet { width: 100%; }
[hidden] { display: none !important; }

/* ---- step navigation ---- */
.steps { scroll-margin-top: calc(var(--masthead-h) + 18px); display: flex; gap: 8px; margin-bottom: 22px; flex-wrap: wrap; }
.step-chip {
  flex: 1 1 0; min-width: 150px; display: flex; align-items: flex-start; gap: 10px;
  text-align: left; padding: 10px 12px; background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius); position: relative; overflow: hidden; min-height: 0;
}
.step-chip::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--blue);
  transform: scaleX(0); transform-origin: left; transition: transform .18s ease-in-out;
}
.step-chip[aria-current="step"]::after { transform: scaleX(1); }
.step-chip[aria-current="step"] { border-color: #b9cde2; background: var(--blue-soft); }

.step-chip .label { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.step-chip .label b { font-size: 13.5px; font-weight: 600; }
.step-chip .label span { font-size: 12px; color: var(--muted); line-height: 1.35; overflow-wrap: anywhere; }

/* ---- step cards ---- */
.card {
  border: 1px solid var(--sand); border-radius: var(--radius); background: #fff;
  padding: 24px 26px 26px; margin-bottom: 20px; scroll-margin-top: 78px;
}
.card:last-of-type { margin-bottom: 0; }
.card > header { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }

.card > header h2 { font-size: 19px; flex: 1; }
.card .lede { color: var(--ink-soft); font-size: 14px; margin: 0 0 20px; max-width: 62ch; }

/* ============================================================ form controls */

body.modern input[type=text], body.modern input[type=url], body.modern input[type=number],
body.modern textarea, body.modern select {
  font: inherit; font-size: 15px; color: var(--ink); background: #fff;
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 12px; min-height: 44px; width: 100%; box-shadow: none;
}
body.modern textarea { min-height: 0; line-height: 1.6; resize: vertical; }
body.modern select { cursor: pointer; }
body.modern input:hover:not(:focus), body.modern textarea:hover:not(:focus), body.modern select:hover:not(:focus) { border-color: #c3ccd6; }
body.modern input:focus, body.modern textarea:focus, body.modern select:focus {
  border-color: var(--blue); outline: none; box-shadow: 0 0 0 3px #d7e4f2;
}
body.modern input::placeholder, body.modern textarea::placeholder { color: #aab3bc; }
body.modern .field { margin: 0 0 16px; }
body.modern .field > label { display: block; font-size: 14px; font-weight: 600; color: var(--ink); margin-bottom: 6px; }
body.modern .hint, body.modern .hint-inline { font-size: 13px; color: var(--muted); line-height: 1.6; }
body.modern .hint { margin: 10px 0 0; }
body.modern .hint-inline { font-weight: 400; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 620px) { .field-row { grid-template-columns: 1fr; gap: 0; } }

body.modern label.check { display: inline-flex; align-items: center; gap: 9px; font-size: 14px; cursor: pointer; margin: 0; }
body.modern label.check input { width: 17px; height: 17px; min-height: 0; accent-color: var(--blue); flex: none; }

/* collapsible "optional" blocks */
body.modern details.fold { border-top: 1px solid var(--line); margin-top: 20px; padding-top: 4px; }
body.modern details.fold > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px;
  padding: 12px 0; font-size: 14px; font-weight: 600; color: var(--blue);
}
body.modern details.fold > summary::-webkit-details-marker { display: none; }
body.modern details.fold > summary::before { content: "▸"; font-size: 11px; transition: transform .15s; }
body.modern details.fold[open] > summary::before { transform: rotate(90deg); }

body.modern details.fold > .fold-body { padding: 4px 0 18px; }

/* ============================================================ step 1: data */

.dataset-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 18px; }
.dataset-row .swatch { width: 10px; height: 10px; border-radius: 2px; border: 1px solid rgba(0,0,0,.25); flex: none; }
.dataset-row select { flex: 0 1 240px; width: auto; min-height: 34px; padding: 5px 10px; font-size: 14px; }
/* One uniform, compact size for every action (incl. the injected Point exclusions button). */
body.modern .dataset-row button { min-height: 34px; padding: 6px 12px; font-size: 13px; }
.dataset-row .expand { margin-left: 0; }
/* Restrained colour: green = create, blue = the primary data action, red = destroy;
   everything else stays neutral. Delete is set apart on the right. */
body.modern .dataset-row [data-action="dataset-add"] { background: #eaf4ee; color: #2a6b45; border-color: #cfe4d6; }
body.modern .dataset-row [data-action="dataset-add"]:hover:not(:disabled) { background: #e0eee6; border-color: #bcdac8; }
body.modern .dataset-row #btn-table { background: #e7effb; color: #245a97; border-color: #cdddf3; }
body.modern .dataset-row #btn-table:hover:not(:disabled) { background: #d9e5f8; border-color: #bacdef; }
body.modern .dataset-row #point-exclusions { background: var(--paper); color: var(--ink-soft); border-color: var(--line); }
body.modern .dataset-row #point-exclusions:hover:not(:disabled) { background: var(--blue-soft); color: var(--blue-dark); border-color: #c8d5e6; }
body.modern .dataset-row [data-action="dataset-remove"] { margin-left: auto; background: #fbeceb; color: #a3231b; border-color: #f1d2ce; }
body.modern .dataset-row [data-action="dataset-remove"]:hover:not(:disabled) { background: #f6dcd9; border-color: #e8bdb8; }

.columns { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 560px) { .columns { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.col-head { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; margin-bottom: 6px; }
.col-head > span:first-child { font-size: 13px; font-weight: 600; }
.col-head .cx { color: var(--blue); }
.col-head .cy { color: #b2231c; }
.col-head .cerr { color: var(--muted); font-weight: 500; }
.count { font-size: 11.5px; color: var(--muted); font-family: var(--mono); }
.count::before { content: ""; }
.count.mismatch { color: var(--danger); font-weight: 700; }
.columns textarea {
  font-family: var(--mono); font-size: 13.5px; line-height: 1.7; padding: 10px;
  height: 190px; background: #fcfdfe;
}

/* ============================================================ step 2: function */

.formula-field { position: relative; }
.formula-field label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; }
body.modern #formula {
  font-family: var(--mono);
}

.preset-label { font-size: 13px; color: var(--muted); margin: 18px 0 8px; }
.presets { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 8px; }
.preset {
  display: flex; flex-direction: column; gap: 2px; align-items: flex-start; text-align: left;
  padding: 9px 11px; min-height: 0; border: 1px solid var(--line); border-radius: var(--radius); background: #fff;
}
.preset b { font-size: 13px; font-weight: 600; }
.preset code { font-family: var(--mono); font-size: 11.5px; color: #55708c; background: none; padding: 0; }
.preset:hover { background: var(--blue-soft); border-color: #b9cde2; }
.preset[aria-pressed="true"] { border-color: var(--blue); background: var(--blue-soft); box-shadow: inset 0 0 0 1px var(--blue); }

.param-table { width: 100%; border-collapse: collapse; margin: 6px 0 0; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.param-table th {
  background: #f7f9fb; font-size: 12px; font-weight: 600; color: var(--ink-soft);
  text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); text-transform: none; letter-spacing: 0;
}
.param-table td { padding: 5px 8px; border-bottom: 1px solid var(--line); }
.param-table tr:last-child td { border-bottom: 0; }
.param-table td.idx { width: 46px; font-family: var(--mono); font-size: 12.5px; color: var(--muted); padding-left: 12px; }
.param-table input { border-color: transparent; background: transparent; min-height: 36px; padding: 6px 8px; font-size: 14px; }
.param-table input:hover { border-color: var(--line); background: #fff; }
.param-table input:focus { background: #fff; }
.param-table input[data-pguess] { font-family: var(--mono); }
#param-table-note { margin: 8px 0 0; }

/* ============================================================ step 3: options */

.optional-plots { border: 0; padding: 0; margin: 0; min-width: 0; }
.optional-plots > legend { padding: 0; font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.optional-choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); gap: 10px; margin: 14px 0 0; }
.optional-choice {
  display: flex; gap: 10px; align-items: flex-start; cursor: pointer;
  border: 1px solid var(--line); border-radius: var(--radius); padding: 11px 13px; margin: 0;
}
.optional-choice:hover { background: #fafcfe; border-color: #c3ccd6; }
.optional-choice:has(input:checked) { border-color: var(--blue); background: var(--blue-soft); }
.optional-choice input { width: 17px; height: 17px; margin: 2px 0 0; accent-color: var(--blue); flex: none; }
.optional-choice span { font-size: 14px; font-weight: 600; line-height: 1.35; }
.optional-choice small { display: block; font-weight: 400; font-size: 12px; color: var(--muted); margin-top: 3px; }

.diagnostic-advanced { margin-top: 18px; }
.diagnostic-config { border-top: 1px solid var(--line); padding: 6px 0; }
.diagnostic-config > summary { cursor: pointer; font-size: 13.5px; font-weight: 600; color: var(--blue); padding: 9px 0; list-style: none; }
.diagnostic-config > summary::-webkit-details-marker { display: none; }
.diagnostic-config > summary::before { content: "▸ "; font-size: 11px; }
.diagnostic-config[open] > summary::before { content: "▾ "; }
.diagnostic-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 0 16px; }
.diagnostic-fields .field { margin-bottom: 12px; }
.diagnostic-fields .field > label { font-size: 12.5px; font-weight: 500; color: var(--ink-soft); }
.diagnostic-fields input, .diagnostic-fields select { min-height: 38px; padding: 7px 10px; font-size: 14px; }
.diagnostic-config .check { margin: 4px 16px 10px 0; font-size: 13px; }
.checks { display: flex; gap: 20px; flex-wrap: wrap; align-items: center; }

/* ============================================================ fit bar */

.fit-bar {
  position: sticky; bottom: 0; z-index: 20; display: flex; align-items: center; gap: 16px;
  background: #fff; border-top: 1px solid var(--sand);
  padding: 14px 0 16px; margin-top: 8px;
}
/* widen the white band past the column so nothing shows through at the edges */
.fit-bar::before {
  content: ""; position: absolute; left: -14px; right: -14px; top: 0; bottom: 0;
  background: #fff; border-top: 1px solid var(--sand); z-index: -1;
}
.fit-bar .primary { flex: none; }
#fit-status, #fit-status.status-part {
  font-size: 13.5px; color: var(--ink-soft); border: 0; box-shadow: none; background: none;
  padding: 0; min-width: 0; white-space: normal; flex: 1;
}
#fit-status.ok { color: var(--ok); }
#fit-status.err { color: var(--danger); }
#fit-status.warn { color: var(--warn); }
#fit-status.busy::before { content: ""; }

/* ============================================================ results rail */

.rail { min-width: 0; }
.rail-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.rail-head h2 { font-size: 17px; }
.rail-head .export-actions { margin-left: auto; display: flex; gap: 6px; }
.rail-head .export-actions button { font-size: 13px; padding: 6px 12px; min-height: 34px; }

body.modern .message {
  border: 1px solid var(--sand); border-left: 4px solid var(--muted); border-radius: var(--radius);
  padding: 12px 16px; margin: 0 0 16px; font-size: 14px; line-height: 1.6; box-shadow: none;
  white-space: pre-wrap; background: #f8f9f9; color: #3d4144;
}
body.modern .message::before { font-weight: 700; display: block; margin-bottom: 2px; }
body.modern .message.error { background: #fdefef; border-color: #f4cfce; border-left-color: var(--danger); color: #8f2320; }
body.modern .message.error::before { content: "Error"; }
body.modern .message.warn { background: #fbf2e6; border-color: #eedcc0; border-left-color: var(--warn); color: #7a4a05; }
body.modern .message.warn::before { content: "Warning"; }
body.modern .message.info { background: #ebf5f8; border-color: #cfe4ec; border-left-color: #3b9cba; color: #1f5062; }
body.modern .message.info::before { content: ""; display: none; }

.canvas-frame { border: 1px solid var(--sand); border-radius: var(--radius); background: #fff; padding: 10px; box-shadow: none; position: relative; scroll-margin-top: calc(var(--masthead-h) + 14px); }
body.modern .plot-expand-btn {
  position: absolute; top: 14px; right: 14px; z-index: 6;
  font-size: 12px; font-weight: 600; line-height: 1; min-height: 0;
  padding: 6px 11px; border-radius: 5px; color: var(--blue);
  background: rgba(255, 255, 255, 0.94); border: 1px solid var(--sand);
  box-shadow: 0 1px 3px rgba(52, 98, 149, 0.18);
}
body.modern .plot-expand-btn:hover:not(:disabled) { background: var(--blue-soft); border-color: #b9cde2; }
body.modern .plot-expand-btn[aria-pressed="true"] { background: var(--blue); color: #fff; border-color: var(--blue); }

body.modern .plot-options-btn {
  position: absolute; top: 14px; left: 14px; z-index: 6;
  font-size: 12px; font-weight: 600; line-height: 1; min-height: 0;
  padding: 6px 11px; border-radius: 5px; color: var(--blue);
  background: rgba(255, 255, 255, 0.94); border: 1px solid var(--sand);
  box-shadow: 0 1px 3px rgba(52, 98, 149, 0.18);
}
body.modern .plot-options-btn:hover:not(:disabled) { background: var(--blue-soft); border-color: #b9cde2; }
body.modern .plot-options-btn[aria-expanded="true"] { background: var(--blue); color: #fff; border-color: var(--blue); }
body.modern .plot-options-pop { color: var(--ink); border-color: var(--sand); }
body.modern .plot-options-pop .po-reset { color: var(--blue); }
body.modern .canvas-frame.plot-fullscreen .plot-options-btn { top: 12px; left: 12px; }

/* Grab bar under the plot: drag it down to make the plot taller. */
body.modern .hsplitter { height: 18px; margin: 8px 0 2px; cursor: row-resize; position: relative; touch-action: none; }
body.modern .hsplitter::after {
  content: ""; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 52px; height: 6px; border: 0; border-radius: 3px; background: var(--sand); transition: background .15s;
}
body.modern .hsplitter:hover::after, body.modern.resizing-y .hsplitter::after { background: var(--blue); }
.plot { width: 100%; height: clamp(340px, 46vh, 560px); background: #fff; position: relative; overflow: hidden; }
.plot .placeholder {
  position: absolute; inset: 0; display: grid; place-items: center;
  padding: 28px; margin: 0; color: var(--muted); font-size: 14.5px; line-height: 1.75;
}
.plot .placeholder > span { display: block; max-width: 52ch; text-align: center; }
.plot .placeholder strong { white-space: nowrap; color: var(--ink); }
.plot .placeholder b { display: block; color: var(--ink); font-size: 16px; font-weight: 600; margin-bottom: 8px; }
.plot .placeholder em { font-style: normal; color: var(--blue); }

/* fit report */
.report-block { margin-top: 20px; }
.report-block > header { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.report-block > header h3 { font-size: 15px; }
.report-tools { display: flex; gap: 6px; margin-left: auto; }
.report-tools button { font-size: 12.5px; padding: 5px 10px; min-height: 30px; }
.report { overflow-x: auto; font-size: 14px; }
.report .placeholder-text { color: var(--muted); font-size: 14px; margin: 0; }
.report > p { margin: 0 0 12px; color: var(--ink-soft); font-size: 13.5px; }
.report .converged { color: var(--ok); font-weight: 600; }
.report .not-converged { color: var(--danger); font-weight: 600; }
.report .ds-name { color: var(--blue); font-weight: 600; }
.report .fine { font-size: 12.5px; color: var(--muted); }
.report-table { width: 100%; border-collapse: collapse; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin: 0 0 16px; box-shadow: none; }
.report-table th { background: #f7f9fb; font-size: 12px; font-weight: 600; color: var(--ink-soft); text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); letter-spacing: 0; text-transform: none; }
.report-table td { padding: 9px 12px; border-bottom: 1px solid var(--line); }
.report-table tbody tr:last-child td { border-bottom: 0; }
.report-table tbody tr:nth-child(even) { background: #fbfcfd; }
.report-table td.num { font-family: var(--mono); font-size: 13.5px; }
.report-table td:nth-child(2) { font-weight: 600; }
.report .summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 0 0 12px; }
@media (max-width: 620px) { .report .summary { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.report .stat { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; background: #fff; box-shadow: none; }
.report .stat .k { display: block; font-size: 11.5px; color: var(--muted); margin-bottom: 2px; }
.report .stat .v { display: block; font-family: var(--mono); font-size: 16px; }
.report .stat.good { border-left: 3px solid var(--ok); }
.report .stat.good .v { color: #2f7d2f; }
.report .stat.meh { border-left: 3px solid var(--warn); }
.report .stat.meh .v { color: #9a5c04; }
.report .stat.bad { border-left: 3px solid var(--danger); }
.report .stat.bad .v { color: #b3261e; }

/* ============================================================ footer */

.site-footer {
  background: var(--footer-bg); color: #6f7a85; margin-top: auto;
  border-top: 1px solid var(--sand); padding: 18px clamp(16px, 3vw, 40px);
}
.site-footer .inner { width: min(var(--page), 100%); margin: 0 auto; display: flex; gap: 16px; align-items: center; flex-wrap: wrap; font-size: 12.5px; }
.site-footer a { color: #4d6c92; }
.site-footer .spacer { flex: 1; }
#health-status, #health-status.status-part {
  border: 0; box-shadow: none; background: none; padding: 0; min-width: 0; font-size: 12.5px; color: inherit;
}
#health-status.ok { color: #2f7d2f; }
#health-status.err { color: #a33; }
#health-status.busy::before { content: ""; }

/* ============================================================ dialogs, help, table editor */

body.modern dialog.tframe {
  border: 1px solid var(--sand); border-radius: var(--radius); background: #fff; padding: 0;
  box-shadow: 0 2px 4px rgba(0,0,0,.16), 0 8px 34px rgba(0,0,0,.18);
}
body.modern dialog::backdrop { background: rgba(23, 43, 66, .42); }
body.modern .titlebar { background: var(--blue); color: #fff; padding: 13px 20px; font-size: 15px; font-weight: 600; }
body.modern .titlebar-note { font-weight: 400; font-size: 12.5px; color: #cfe0f1; margin-left: 10px; }
body.modern .dialog-body { padding: 20px 22px 22px; }
body.modern dialog .row.actions { margin-top: 18px; gap: 10px; }

body.modern .help-pop { border: 1px solid var(--sand); border-radius: var(--radius); background: #fff; box-shadow: 0 2px 4px rgba(0,0,0,.16), 0 8px 30px rgba(0,0,0,.18); }
body.modern .help-title { background: var(--blue); color: #fff; padding: 11px 16px; font-size: 14.5px; font-weight: 600; display: flex; justify-content: space-between; align-items: center; }
body.modern .help-close { min-height: 24px; padding: 0 6px; border: 0; background: none; color: #fff; font-size: 20px; line-height: 1; }
body.modern .help-close:hover { background: rgba(255,255,255,.18); }
body.modern .help-body { padding: 14px 16px 16px; font-size: 14px; line-height: 1.7; max-height: 62vh; overflow: auto; }
body.modern .help-body p { margin: 0 0 10px; }
body.modern .help-body code { font-size: 12.5px; }

body.modern .drop-overlay { background: rgba(234, 240, 247, .9); border: 3px dashed var(--blue); color: var(--blue); font-size: 19px; }

/* spreadsheet-style table editor keeps its dense grid, in ROOT colors */
body.modern .tabs { border-bottom: 1px solid var(--line); gap: 4px; }
body.modern .tab { border: 1px solid var(--line); border-bottom-color: var(--line); border-radius: var(--radius) var(--radius) 0 0; background: #f7f9fb; min-height: 34px; font-size: 13.5px; }
body.modern .tab.active { background: #fff; border-bottom-color: #fff; color: var(--blue); }
body.modern .grid-wrap { border: 1px solid var(--line); border-radius: var(--radius); box-shadow: none; }
body.modern .grid th { background: #f7f9fb; font-size: 12.5px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
body.modern .grid td { border-color: var(--line); }
body.modern .grid input { border: 0; border-radius: 0; min-height: 34px; font-size: 13.5px; background: transparent; }
body.modern .grid input:focus { box-shadow: inset 0 0 0 2px var(--blue); background: #fffdf2; }
body.modern .grid td.rownum, body.modern .grid th.rownum { background: #f7f9fb; color: var(--muted); }
body.modern .import-panel { background: #f7f9fb; border: 1px solid var(--line); border-radius: var(--radius); }

/* ============================================================ narrow screens */

@media (max-width: 1099px) {
  .rail { border-top: 1px solid var(--sand); padding-top: 24px; }
}
@media (max-width: 760px) {
  :root { --masthead-h: 52px; }
  .masthead { gap: 10px; }

  .brand-name { font-size: 13px; letter-spacing: .02em; }
  .masthead nav { gap: 0; }
  .masthead nav a { padding: 0 8px; font-size: 13px; }
  /* you are already on this page, so the link only costs space */
  .masthead nav a[aria-current] { display: none; }
  .step-chip .label b { font-size: 12.5px; line-height: 1.25; }

  .workspace { width: calc(100% - 32px); padding: 20px 0 32px; }
  .card { padding: 18px 16px 20px; }
  .card > header h2 { font-size: 17px; }
  .steps { gap: 6px; }
  .step-chip { min-width: 0; flex: 1 1 100px; padding: 8px 10px; }
  .step-chip .label span { display: none; }
  .worksheet-bar { padding: 10px 16px; gap: 10px; }
  #doc-title { font-size: 17px; }
  .columns textarea { height: 150px; font-size: 13px; }
  .plot { height: 320px; }
  .fit-bar .primary { padding: 12px 20px; }
}

@media (max-width: 430px) {
  .brand-name { font-size: 12.5px; letter-spacing: 0; }
  .masthead nav { flex: none; }
  .masthead nav a { padding: 0 7px; font-size: 12.5px; }
  .worksheet-bar { padding: 10px 14px; }
  .card { padding: 16px 14px 18px; }
  .workspace { width: calc(100% - 24px); }
}

@media (max-width: 600px) {
  body.standard-workspace { --masthead-h: 86px; }
  .masthead.workspace-masthead {
    display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: 42px 44px;
    height: var(--masthead-h); flex-shrink: 0; gap: 0;
  }
  .workspace-masthead .brand { min-width: 0; }
  .workspace-masthead nav {
    display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
    width: 100%; height: 44px; margin-left: 0; gap: 0;
  }
  .workspace-masthead nav a {
    justify-content: center; padding: 0 4px; white-space: normal;
    text-align: center; font-size: 12.5px; line-height: 1.25;
  }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}

/* ============================================================ shared workspace chrome
 * cli.html (the console) loads this file for its page frame. These are the
 * generic pieces it uses - a header bar, a centered column, section headings
 * and a footer - in the same ROOT palette as the worksheet above.
 */

.workspace-header {
  position: sticky; top: 0; z-index: 40; background: var(--blue); color: #fff;
  min-height: var(--masthead-h); display: flex; align-items: center; gap: 24px;
  padding: 0 clamp(14px, 3vw, 40px);
}
.workspace-header .site-name { color: #fff; font-size: 15px; font-weight: 700; letter-spacing: .04em; text-decoration: none; white-space: nowrap; }
.workspace-header .site-name:hover { text-decoration: none; }
.workspace-header nav { margin-left: auto; display: flex; gap: 4px; align-items: stretch; height: var(--masthead-h); }
.workspace-header nav a { position: relative; display: flex; align-items: center; padding: 0 12px; color: #e6eef7; font-size: 14px; text-decoration: none; white-space: nowrap; }
.workspace-header nav a:hover { color: #fff; text-decoration: none; }
.workspace-header nav a::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: #fff;
  transform: scaleX(0); transform-origin: left; transition: transform .18s ease-in-out;
}
.workspace-header nav a:hover::after { transform: scaleX(1); }

.modern-main { width: min(1060px, calc(100% - 48px)); margin: 32px auto 0; flex: 1; outline: none; }
.document-bar { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 26px; flex-wrap: wrap; }
.document-bar h1 { font-size: 24px; }
.document-actions { display: flex; gap: 8px; align-items: center; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 10px; }
.section-heading h2 { font-size: 18px; }
.section-description { color: var(--ink-soft); font-size: 14px; max-width: 78ch; margin: 0 0 20px; }

.workspace-footer {
  background: var(--footer-bg); color: #6f7a85; border-top: 1px solid var(--sand); margin-top: 40px;
  padding: 18px clamp(14px, 3vw, 40px); display: flex; justify-content: space-between; gap: 16px;
  flex-wrap: wrap; font-size: 12.5px;
}
.workspace-footer a { color: #4d6c92; }

@media (max-width: 760px) {
  .modern-main { width: calc(100% - 32px); margin-top: 22px; }
  .workspace-header { gap: 10px; }
  .workspace-header .site-name { font-size: 13px; }
  .workspace-header nav a { padding: 0 8px; font-size: 13px; }
  .document-bar h1 { font-size: 21px; }
}

/* ============================================================ analysis type, histograms, per-dataset fit */

.analysis-choice { margin-bottom: 18px; }
.analysis-choice select { font-size: 15px; }
.dataset-note { margin: 0 0 16px; color: var(--muted); }
.histogram-binning { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 14px; align-items: end; }
@media (max-width: 620px) { .histogram-binning { grid-template-columns: 1fr; } }
#histogram-data textarea { font-family: var(--mono); font-size: 13.5px; line-height: 1.7; }
.hist-summary {
  border-left: 3px solid var(--blue); background: var(--blue-soft); color: #2c4f76;
  padding: 8px 12px; border-radius: 0 var(--radius) var(--radius) 0; margin: 14px 0;
}
.hist-summary:empty { display: none; }
#btn-histogram { margin-top: 6px; }
#hist-fit-options { border-left: 3px solid var(--sand); padding-left: 14px; margin: 0 0 18px; }
#fit-dataset-label { margin: 6px 0 18px; }

.table-fit-settings {
  border: 1px solid var(--line); border-radius: var(--radius); background: #fbfcfd;
  padding: 12px 16px 4px; margin: 14px 0 0; min-width: 0;
}
.table-fit-settings > legend { padding: 0 6px; font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.table-fit-settings .field { margin-bottom: 12px; }
.table-fit-settings input { min-height: 38px; font-size: 14px; }

#dataset-type-dialog { width: min(440px, 92vw); }
#dataset-type-dialog .row { gap: 10px; margin-top: 16px; }

/* Keep the table usable when fit settings exceed the available dialog height. */
body.modern #table-dialog {
  width: min(1000px, 94vw);
  min-width: min(520px, 94vw);
  max-width: 96vw;
  max-height: 94dvh;
}
body.modern #table-dialog .table-body {
  display: block;
  overflow: auto;
  min-height: 0;
  padding-bottom: 0;
}
body.modern #table-dialog .grid-wrap {
  height: clamp(200px, 32vh, 360px);
  min-height: 200px;
  overflow: auto;
}
body.modern #table-dialog .table-body > .actions {
  position: sticky;
  bottom: 0;
  z-index: 3;
  background: #fff;
  border-top: 1px solid var(--line);
  padding: 12px 0;
  margin-top: 16px;
  flex-wrap: wrap;
}

/* Equation input shares the worksheet's typography, borders and blue controls. */
.equation-editor { margin: 18px 0 24px; }
body.modern .equation-mode-field { border: 0; padding: 0; margin: 0 0 20px; min-width: 0; }
body.modern .equation-mode-field legend { padding: 0; margin-bottom: 8px; font-size: 14px; font-weight: 600; }
.equation-mode-options { position: relative; display: inline-flex; flex-wrap: wrap; gap: 8px; }
.equation-mode-options input { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
body.modern .equation-mode-options label { display: flex; align-items: center; justify-content: center; min-height: 44px; padding: 10px 18px; border: 1px solid #8ca5be; border-radius: 4px; background: #fff; color: #27496f; cursor: pointer; font-size: 14px; font-weight: 400; }
body.modern .equation-mode-options label:hover { background: #eaf0f7; }
body.modern .equation-mode-options input:checked + label { background: #346295; border-color: #346295; color: #fff; font-weight: 600; }
body.modern .equation-mode-options input:focus-visible + label { outline: 3px solid #205f96; outline-offset: 3px; }
@media (forced-colors: active) { .equation-mode-options input:checked + label { outline: 2px solid Highlight; } }
#equation-label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 8px; }
#fit-equation { display: block; width: 100%; min-height: 82px; padding: 14px; font-size: 26px; background: #fff; color: #24384a; border: 1px solid #bacbdc; border-radius: 4px; --caret-color: #346295; --selection-background-color: #dbe8f5; --contains-highlight-background-color: #edf3f9; }
#fit-equation:focus-within { outline: 2px solid #346295; outline-offset: 2px; }
#fit-equation::part(virtual-keyboard-toggle), #fit-equation::part(menu-toggle) { display: none; }
.equation-help, #equation-translation { margin-top: 14px; font-size: 14px; line-height: 1.65; }
.equation-help summary, #equation-translation summary { cursor: pointer; color: #346295; }
#equation-root-preview { display: block; margin-top: 8px; padding: 12px; overflow-wrap: anywhere; white-space: pre-wrap; }
.equation-error { border-left: 3px solid #a12e26; padding: 8px 12px; color: #92251e; background: #fff5f3; line-height: 1.5; }
body.modern .param-table td.idx { width: auto; min-width: 100px; overflow-wrap: anywhere; }

body.modern .analyze-results-button{background:var(--blue);border:1px solid var(--blue);border-radius:4px;color:white;padding:8px 16px;font-size:14px;min-height:38px}
body.modern .analyze-results-button:hover{background:var(--blue-dark);border-color:var(--blue-dark)}
.rail-head .export-actions{flex-wrap:wrap;align-items:center}

.parameter-heading{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap;margin-bottom:12px}.parameter-heading .preset-label{margin:0}body.modern .parameter-guide-button{display:inline-block;padding:8px 16px;border:1px solid var(--blue);border-radius:4px;background:var(--blue);color:#fff;font-size:14px;font-weight:600;text-decoration:none;min-height:38px;cursor:pointer}body.modern .parameter-guide-button:hover:not(:disabled){background:var(--blue-dark);border-color:var(--blue-dark)}

/* Insert data: data-type selector + per-type entry areas */
.insert-type-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.insert-type-tabs .type-tab { min-height: 34px; padding: 6px 14px; border-radius: 6px; font-size: 13px; background: var(--paper); border: 1px solid var(--line); color: var(--ink-soft); }
.insert-type-tabs .type-tab:hover:not(.active) { background: var(--blue-soft); border-color: #b8cbe4; }
.insert-type-tabs .type-tab.active { background: var(--blue); border-color: var(--blue); color: #fff; font-weight: 600; }
.insert-histogram { display: flex; flex-direction: column; gap: 12px; }
.insert-histogram .ins-hist-field { display: flex; flex-direction: column; gap: 4px; }
.insert-histogram .ins-hist-field > label { font-size: 13px; font-weight: 600; }
.insert-histogram .ins-hist-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.insert-histogram .hint-inline { font-weight: 400; color: var(--muted); font-size: 12px; }
.insert-histogram textarea { min-height: 0; }
@media (max-width: 640px) { .insert-histogram .ins-hist-row { grid-template-columns: 1fr; } }

/* Missing measurements belong to the fit page, without blocking navigation. */
.fit-data-notice {
  margin: 16px 0 22px; padding: 14px 16px;
  border: 1px solid #e7c77c; border-left: 4px solid #b77913;
  border-radius: var(--radius); background: #fff7e3; color: #704b13;
  font-size: 15px; line-height: 1.5;
}
