/* style.css - "classic ROOT GUI, modern comfort".
   The look of a TBrowser / TCanvas window (flat gray frames, beveled buttons,
   sunken white text entries, etched group frames, a menu bar and a status bar,
   navy highlight) with today's readability: 14px Helvetica, generous spacing,
   clear hierarchy, visible focus rings, hover states, zebra tables.
   Plain CSS, no framework. */

:root {
  --frame: #e4e4e4;          /* TGFrame background */
  --frame-2: #ececec;        /* slightly lighter surface (toolbar, table header) */
  --hilite: #ffffff;         /* light bevel edge */
  --shadow: #9a9a9a;         /* dark bevel edge */
  --dark: #4a4a4a;           /* outer dark line */
  --ink: #111111;
  --muted: #555555;
  --entry: #ffffff;          /* TGTextEntry background */
  --entry-line: #e6e6e6;     /* table row separators */
  --accent: #000080;         /* ROOT's navy: menu highlight, primary button, focus */
  --accent-ink: #ffffff;
  --link: #1246a8;
  --err: #b3261e;
  --warn: #8a5a00;
  --ok: #1b6e2f;
  --font: Helvetica, "Helvetica Neue", Arial, sans-serif;
  --mono: Menlo, "Courier New", monospace;
  --control-h: 30px;         /* height of buttons and single-line inputs */
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; height: 100%; }
body {
  font: 14px/1.45 var(--font);
  color: var(--ink);
  background: var(--frame);
  display: flex; flex-direction: column; min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--link); text-underline-offset: 2px; }
a:hover { color: var(--accent); }
code { font-family: var(--mono); font-size: 12.5px; background: rgba(0, 0, 0, 0.05); padding: 0 3px; }
.mono { font-family: var(--mono); }
p { margin: 6px 0; }
.hint { color: var(--muted); font-size: 12.5px; line-height: 1.45; margin: 6px 0 8px; }
.hint-inline { color: var(--muted); font-weight: normal; font-size: 12.5px; }

/* ---- the two bevels that define the look ------------------------------ */
.raised, button, .toolbar {
  border-style: solid; border-width: 1px;
  border-color: var(--hilite) var(--shadow) var(--shadow) var(--hilite);
}
.sunken, input[type=text], input[type=url], textarea, select, .canvas-frame, .status-part, .report-table, .message {
  border-style: solid; border-width: 1px;
  border-color: var(--shadow) var(--hilite) var(--hilite) var(--shadow);
  box-shadow: inset 1px 1px 0 var(--dark);
}

/* ---- toolbar (TGToolBar) ---------------------------------------------- */
.toolbar {
  display: flex; align-items: center; gap: 6px; padding: 6px 8px; background: var(--frame-2);
  border-left-color: transparent; border-right-color: transparent;
}
.toolbar .separator { width: 0; height: 22px; border-left: 1px solid var(--shadow); border-right: 1px solid var(--hilite); margin: 0 6px; }
.toolbar .spacer { flex: 1; }
.toolbar .app-name { color: var(--accent); padding-right: 6px; font-weight: bold; letter-spacing: 0.03em; }
.toolbar button { display: inline-flex; align-items: center; gap: 7px; }
.ic { display: inline-block; width: 12px; height: 12px; border: 1px solid var(--dark); box-sizing: border-box; }
.ic-load { background: linear-gradient(180deg, #f5d76e 0 40%, #e0b93a 40%); border-color: #8a6d1a; }
.ic-save { background: #1f5fbf; border-color: #123a75; box-shadow: inset 0 -4px 0 #fff, inset 0 -5px 0 #123a75; }
.ic-png { background: linear-gradient(135deg, #2a8f3c 0 50%, #7cc47f 50%); border-color: #1e6a2c; }
.ic-table { background: repeating-linear-gradient(0deg, #fff 0 3px, #8e44ad 3px 4px), #fff; border-color: #5e2b73; }

/* ---- buttons (TGTextButton) ------------------------------------------- */
button {
  font: inherit; color: var(--ink); background: var(--frame); padding: 0 14px; min-height: var(--control-h);
  box-shadow: 1px 1px 0 var(--dark); cursor: pointer; border-radius: 0; line-height: 1.2;
  transition: background 0.08s;
}
button:hover:not(:disabled) { background: #f2f2f2; }
button:active:not(:disabled) {
  border-color: var(--shadow) var(--hilite) var(--hilite) var(--shadow);
  box-shadow: inset 1px 1px 0 var(--dark); background: #d8d8d8;
}
button:disabled { color: var(--shadow); text-shadow: 1px 1px 0 var(--hilite); box-shadow: 1px 1px 0 var(--shadow); cursor: default; }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button.primary {
  background: var(--accent); color: var(--accent-ink); font-weight: bold; padding: 0 32px; min-height: 36px;
  border-color: #6a6ab8 #000050 #000050 #6a6ab8;
}
button.primary:hover:not(:disabled) { background: #1a1a9a; }
button.primary:active:not(:disabled) { background: #000060; border-color: #000050 #6a6ab8 #6a6ab8 #000050; }
button.primary:disabled { background: #9a9ab8; color: #e8e8f4; text-shadow: none; }

/* ---- form controls (TGTextEntry, TGComboBox) -------------------------- */
input[type=text], input[type=url], textarea, select {
  font: inherit; color: var(--ink); background: var(--entry); padding: 5px 8px; width: 100%;
  border-radius: 0; margin: 0; min-height: var(--control-h);
}
textarea { resize: vertical; line-height: 1.4; min-height: 0; }
select { width: auto; padding-right: 8px; cursor: pointer; }
input::placeholder, textarea::placeholder { color: #9a9a9a; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.field { margin: 8px 0; }
.field > label { display: block; margin-bottom: 4px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.actions { margin-top: 12px; }
.grow { flex: 1 1 150px; }

/* ---- group frames (TGGroupFrame): etched border, title in the border --- */
fieldset.group {
  border: 1px solid var(--shadow); box-shadow: 1px 1px 0 var(--hilite), inset 1px 1px 0 var(--hilite);
  margin: 8px 0 14px; padding: 10px 14px 14px;
}
fieldset.group > legend { padding: 0 6px; margin-left: 6px; font-weight: bold; letter-spacing: 0.01em; color: var(--accent); }

/* ---- "?" help buttons and the pop-over --------------------------------- */
.help-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; min-height: 0;
  padding: 0; margin-left: 4px; border-radius: 50%; border: 1px solid var(--accent); background: var(--entry);
  color: var(--accent); font-size: 12px; font-weight: bold; box-shadow: none; vertical-align: middle; line-height: 1;
}
.help-btn:hover:not(:disabled) { background: var(--accent); color: var(--accent-ink); }
.help-btn:active:not(:disabled) { border-color: var(--accent); box-shadow: none; }
.help-pop {
  position: fixed; z-index: 60; background: var(--entry); color: var(--ink);
  border: 1px solid; border-color: var(--hilite) var(--shadow) var(--shadow) var(--hilite);
  box-shadow: 2px 2px 0 var(--dark), 6px 10px 24px rgba(0, 0, 0, 0.22); font-size: 13.5px;
}
.help-title { display: flex; justify-content: space-between; align-items: center; background: var(--accent); color: var(--accent-ink); padding: 6px 12px; font-weight: bold; }
.help-close { min-height: 0; padding: 0 6px; border: 0; box-shadow: none; background: none; color: var(--accent-ink); font-size: 18px; line-height: 1; }
.help-close:hover:not(:disabled) { background: rgba(255, 255, 255, 0.15); }
.help-body { padding: 8px 12px 10px; max-height: 60vh; overflow: auto; }
.help-body p { margin: 6px 0; }

/* ---- expanders (details) inside groups -------------------------------- */
.expander { margin-top: 8px; border-top: 1px solid var(--shadow); box-shadow: 0 1px 0 var(--hilite) inset; padding-top: 6px; }
.expander > summary { cursor: pointer; color: var(--accent); font-weight: bold; padding: 4px 0; list-style: none; }
.expander > summary::-webkit-details-marker { display: none; }
.expander > summary::before { content: "▸ "; font-size: 12px; }
.expander[open] > summary::before { content: "▾ "; }
.param-table { width: 100%; border-collapse: collapse; background: var(--entry); margin: 6px 0 4px;
  border: 1px solid; border-color: var(--shadow) var(--hilite) var(--hilite) var(--shadow); box-shadow: inset 1px 1px 0 var(--dark); }
.param-table th { background: var(--frame-2); font-size: 12.5px; color: var(--muted); text-align: left; padding: 5px 8px; border-bottom: 1px solid var(--shadow); }
.param-table td { padding: 3px 6px; border-bottom: 1px solid var(--entry-line); }
.param-table td.idx { font-family: var(--mono); color: var(--muted); width: 44px; }
.param-table input { min-height: 26px; padding: 3px 6px; border: 1px solid transparent; box-shadow: none; background: transparent; }
.param-table input:focus { background: #fffbe6; border-color: var(--accent); outline: none; }
.checks { gap: 16px; }
label.check { display: inline-flex; align-items: center; gap: 6px; margin: 0; cursor: pointer; }
label.check input { width: 15px; height: 15px; margin: 0; accent-color: var(--accent); }

/* ---- plot height handle --------------------------------------------- */
.hsplitter { height: 10px; cursor: row-resize; position: relative; margin: 2px 0 4px; }
.hsplitter::after {
  content: ""; position: absolute; left: 40%; right: 40%; top: 4px; height: 2px;
  border-top: 1px solid var(--shadow); border-bottom: 1px solid var(--hilite);
}
.hsplitter:hover::after, body.resizing-y .hsplitter::after { border-color: var(--accent); }
body.resizing-y, body.resizing-y * { cursor: row-resize !important; user-select: none; }

/* the Fit button stays in view while scrolling a long form */
.inputs .actions {
  position: sticky; bottom: 0; background: var(--frame); padding: 10px 0 4px; margin-top: 6px;
  box-shadow: 0 -10px 10px -8px rgba(0, 0, 0, 0.12);
}

.columns { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
@media (max-width: 520px) { .columns { grid-template-columns: repeat(2, 1fr); } }
.col-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 4px; }
.col-head > span:first-child { font-weight: bold; }
.cx { color: var(--accent); }
.cy { color: #b2231c; }
.cerr { color: var(--muted); }
.dataset-row { margin: 2px 0 10px; }
.dataset-row select { min-width: 0; }
.swatch { display: inline-block; width: 12px; height: 12px; border: 1px solid var(--dark); flex: none; }
button.small { min-height: 26px; padding: 0 10px; font-size: 13px; }
button.expand { margin-left: auto; }

/* ---- dataset-row: colour-coded, grouped actions -----------------------
   New plot (create) = green · data tools (Paste data / Data table / Point
   exclusions) = blue · Delete (destructive) = red, set apart on the right.
   Only backgrounds/text are tinted, so the ROOT bevel is preserved; disabled
   buttons fall back to the neutral look. */
.dataset-row [data-action="dataset-add"] { background: #dcf0e3; color: #1b6b39; }
.dataset-row [data-action="dataset-add"]:hover:not(:disabled) { background: #d5ecdd; }
.dataset-row [data-paste-spreadsheet],
.dataset-row #btn-table,
.dataset-row #point-exclusions { background: #e2ecfb; color: #1f5390; }
.dataset-row [data-paste-spreadsheet]:hover:not(:disabled),
.dataset-row #btn-table:hover:not(:disabled),
.dataset-row #point-exclusions:hover:not(:disabled) { background: #d2e0f6; }
.dataset-row [data-action="dataset-remove"] { background: #fdeceb; color: #a3231b; margin-left: 12px; }
.dataset-row [data-action="dataset-remove"]:hover:not(:disabled) { background: #f8dad7; }
.dataset-row .expand { margin-left: 0; }               /* keep Data table inline with its group */
.dataset-row button:disabled { background: var(--frame); color: var(--shadow); }
.columns textarea { font-family: var(--mono); font-size: 12.5px; padding: 6px; }
.count { color: var(--muted); font-size: 12px; font-family: var(--mono); }
.count::before { content: "n="; }
.count.mismatch { color: var(--err); font-weight: bold; }

/* ---- results ---------------------------------------------------------- */
.message {
  padding: 10px 12px 10px 14px; margin: 0 0 10px; white-space: pre-wrap; background: var(--entry);
  border-left-width: 5px; line-height: 1.45;
}
.message.error { border-left-color: var(--err); color: var(--err); }
.message.error::before { content: "Let’s take a look  "; font-weight: bold; }
.message.warn { border-left-color: #d29a00; color: var(--warn); }
.message.warn::before { content: "Fit note  "; font-weight: bold; }
.message.info { border-left-color: var(--ok); color: var(--ok); }

.canvas-frame { background: var(--entry); padding: 3px; position: relative; }
.plot { width: 100%; height: 600px; background: #fff; position: relative; overflow: hidden; }

/* Overlay toggle that grows the plot downward when it feels boxed in. */
.plot-expand-btn {
  position: absolute; top: 8px; right: 8px; z-index: 6;
  font: inherit; font-size: 12px; font-weight: 600; line-height: 1;
  padding: 5px 10px; border-radius: 5px; cursor: pointer;
  border: 1px solid var(--edge, #9aa2ab);
  background: rgba(255, 255, 255, 0.92); color: #1a1a1a;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18); text-shadow: none;
}
.plot-expand-btn:hover:not(:disabled) { background: #fff; border-color: var(--accent); }
.plot-expand-btn[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink, #fff); border-color: var(--accent); }

/* Advanced plot options: an overlay button (top-left) and its popover panel. */
.plot-options-btn {
  position: absolute; top: 8px; left: 8px; z-index: 6;
  font: inherit; font-size: 12px; font-weight: 600; line-height: 1;
  padding: 5px 10px; border-radius: 5px; cursor: pointer;
  border: 1px solid var(--edge, #9aa2ab);
  background: rgba(255, 255, 255, 0.92); color: #1a1a1a;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18); text-shadow: none;
}
.plot-options-btn:hover:not(:disabled) { background: #fff; border-color: var(--accent); }
.plot-options-btn[aria-expanded="true"] { background: var(--accent); color: var(--accent-ink, #fff); border-color: var(--accent); }
.plot-options-pop {
  position: absolute; top: 44px; left: 8px; z-index: 7;
  width: 264px; max-width: calc(100% - 16px); max-height: calc(100% - 56px); overflow: auto;
  background: #fff; color: #1a1a1a; border: 1px solid var(--edge, #9aa2ab);
  border-radius: 8px; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.22); padding: 10px 12px 12px; font-size: 13px;
}
.plot-options-pop .po-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.plot-options-pop .po-reset {
  font: inherit; font-size: 12px; padding: 3px 9px; border-radius: 4px;
  border: 1px solid var(--edge, #9aa2ab); background: #f2f2f2; color: #1a1a1a; cursor: pointer; text-shadow: none;
}
.plot-options-pop .po-reset:hover { background: #fff; border-color: var(--accent); }
.plot-options-pop .po-group { border: 1px solid var(--edge, #d8d8d8); border-radius: 6px; padding: 5px 8px 8px; margin: 8px 0 0; }
.plot-options-pop .po-group legend { font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted, #666); padding: 0 4px; }
.plot-options-pop .po-check { display: inline-flex; align-items: center; gap: 5px; margin: 3px 12px 3px 0; white-space: nowrap; cursor: pointer; }
.plot-options-pop .po-field { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 6px 0 0; }
.plot-options-pop .po-field span { color: var(--muted, #555); }
.plot-options-pop .po-field select { flex: 0 0 auto; min-width: 132px; font: inherit; font-size: 12px; padding: 2px 4px; }

/* Full-screen: the Expand button makes the plot frame fill the whole window. */
.canvas-frame.plot-fullscreen {
  position: fixed; inset: 0; z-index: 1000;
  margin: 0; padding: 12px; border: none; border-radius: 0;
  background: #fff; box-shadow: none;
}
.canvas-frame.plot-fullscreen .plot { height: 100%; }
.canvas-frame.plot-fullscreen .plot-expand-btn { top: 12px; right: 12px; z-index: 1001; }
.canvas-frame.plot-fullscreen .plot-options-btn { top: 12px; left: 12px; z-index: 1001; }
.canvas-frame.plot-fullscreen .plot-options-pop { z-index: 1002; }
.plot .placeholder { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); margin: 0; text-align: center; padding: 20px; }
@media (max-width: 960px) { .plot { height: 460px; } }

.report-group { margin-top: 12px; }
.report .placeholder-text { color: var(--muted); margin: 2px 0; }
.report .fine { color: var(--muted); font-size: 12.5px; margin: 8px 0 0; }
.report-table { width: 100%; border-collapse: collapse; background: var(--entry); margin: 8px 0 12px; }
.report-table th, .report-table td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--entry-line); }
.report-table th { background: var(--frame-2); font-weight: bold; font-size: 12.5px; color: var(--muted); border-bottom: 1px solid var(--shadow); }
.report-table tbody tr:nth-child(even) { background: #f6f6f6; }
.report-table td.num { font-family: var(--mono); font-size: 13px; }
.report-table td:nth-child(2) { font-size: 14px; }
.report .summary {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; margin: 8px 0 4px;
}
.report .stat {
  background: var(--entry); padding: 7px 10px 6px;
  border: 1px solid; border-color: var(--shadow) var(--hilite) var(--hilite) var(--shadow); box-shadow: inset 1px 1px 0 var(--dark);
}
.report .stat .k { display: block; font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.report .stat .v { display: block; font-family: var(--mono); font-size: 15px; }
.report .stat.good .v { color: var(--ok); }
.report .stat.meh .v { color: var(--warn); }
.report .stat.bad .v { color: var(--err); }
.report .stat.good { border-left: 4px solid var(--ok); }
.report .stat.meh { border-left: 4px solid #d29a00; }
.report .stat.bad { border-left: 4px solid var(--err); }
.report .ds-name { font-weight: bold; color: var(--accent); }
.report-tools { margin: 4px 0 8px; }
.report .converged { color: var(--ok); font-weight: bold; }
.report .not-converged { color: var(--err); font-weight: bold; }

/* ---- status bar (TGStatusBar) ----------------------------------------- */
.statusbar { display: flex; gap: 4px; padding: 5px 8px; background: var(--frame); border-top: 1px solid var(--hilite); font-size: 12.5px; }
.status-part { padding: 3px 10px; min-width: 170px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: var(--frame); }
.status-part.grow { flex: 1; min-width: 0; }
.status-part.ok { color: var(--ok); }
.status-part.err { color: var(--err); }
.status-part.busy { color: var(--muted); }
.status-part.busy::before { content: "… "; }
.status-part.credit { min-width: 0; color: var(--muted); font-size: 11.5px; text-align: right; }

/* ---- dialogs (TGTransientFrame) and drag overlay ---------------------- */
dialog.tframe {
  padding: 0; background: var(--frame); color: var(--ink); width: min(600px, 92vw);
  border: 1px solid; border-color: var(--hilite) var(--shadow) var(--shadow) var(--hilite);
  box-shadow: 2px 2px 0 var(--dark), 8px 12px 30px rgba(0, 0, 0, 0.25);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.3); }
dialog .titlebar { background: var(--accent); color: var(--accent-ink); padding: 7px 14px; font-weight: bold; }
dialog .dialog-body { padding: 12px 16px 16px; }
dialog textarea { width: 100%; margin: 10px 0 0; font-size: 12.5px; }

.drop-overlay {
  position: fixed; inset: 0; background: rgba(228, 228, 228, 0.88); border: 3px dashed var(--accent);
  display: grid; place-items: center; font-size: 20px; color: var(--accent); z-index: 50; pointer-events: none;
}

/* ---- data table dialog ------------------------------------------------ */
dialog.resizable { resize: both; overflow: hidden; width: min(900px, 94vw); height: min(680px, 90vh); min-width: 520px; min-height: 360px;
  display: flex; flex-direction: column; }
dialog.resizable:not([open]) { display: none; }
dialog.resizable .titlebar { flex: none; }
.titlebar-note { font-weight: normal; opacity: 0.85; margin-left: 12px; font-size: 12.5px; }
.table-body { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.table-tools { margin: 6px 0; }
.table-tools .spacer { flex: 1; }
.tabs { display: flex; gap: 2px; flex-wrap: wrap; border-bottom: 1px solid var(--shadow); box-shadow: 0 1px 0 var(--hilite); padding-bottom: 0; }
.tab {
  display: inline-flex; align-items: center; gap: 7px; min-height: 28px; padding: 0 12px; margin-bottom: -1px;
  border-bottom-color: var(--shadow); box-shadow: none; background: var(--frame);
}
.tab.active { background: var(--entry); border-bottom-color: var(--entry); font-weight: bold; }
.tab.add { color: var(--accent); }
.tab .tab-x { color: var(--muted); padding-left: 4px; font-size: 15px; line-height: 1; }
.tab .tab-x:hover { color: var(--err); }
.grid-wrap { flex: 1; min-height: 160px; overflow: auto; background: var(--entry);
  border: 1px solid; border-color: var(--shadow) var(--hilite) var(--hilite) var(--shadow); box-shadow: inset 1px 1px 0 var(--dark); }
.grid { border-collapse: collapse; width: 100%; font-size: 13px; }
.grid th { position: sticky; top: 0; background: var(--frame-2); text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--shadow); z-index: 1; }
.grid td { padding: 0; border-bottom: 1px solid var(--entry-line); border-right: 1px solid var(--entry-line); }
.grid td.rownum, .grid th.rownum { width: 48px; text-align: right; color: var(--muted); padding: 0 8px; font-family: var(--mono); font-size: 12px; background: #f6f6f6; }
.grid td.rowdel, .grid th.rowdel { width: 30px; text-align: center; border-right: 0; }
.grid input { min-height: 28px; padding: 3px 8px; border: 0; box-shadow: none; background: transparent; font-family: var(--mono); font-size: 13px; }
.grid input:focus { outline: 2px solid var(--accent); outline-offset: -2px; background: #fffbe6; }
.grid tbody tr:hover td { background: #f9f9ff; }
.rowdel-btn { min-height: 0; padding: 0 6px; border: 0; box-shadow: none; background: none; color: var(--muted); font-size: 15px; }
.rowdel-btn:hover:not(:disabled) { color: var(--err); background: none; }
.import-panel { margin: 8px 0 0; padding: 8px 10px; background: var(--frame-2);
  border: 1px solid; border-color: var(--shadow) var(--hilite) var(--hilite) var(--shadow); }
.import-panel textarea { width: 100%; }
#import-mapping .field { margin: 4px 0; min-width: 150px; }
#import-mapping select { width: 100%; }


/* Optional diagnostic plots. */
.optional-plots { border: 0; padding: 0; margin: 14px 0 0; min-width: 0; }
.optional-plots > legend { padding: 0; font-weight: bold; }
.optional-choices { display: grid; gap: 8px; margin: 12px 0; }
.optional-choice { display: flex; gap: 8px; align-items: flex-start; cursor: pointer; }
.optional-choice input { margin-top: 4px; accent-color: var(--accent); }
.optional-choice small { display: block; color: var(--muted); font-size: 11px; }
.diagnostic-config { border-top: 1px solid var(--shadow); padding: 10px 0; }
.diagnostic-config > summary { cursor: pointer; color: var(--accent); }
.diagnostic-fields { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 0 12px; }
.diagnostic-fields .field { min-width: 0; }
.diagnostic-fields select { width: 100%; }
.diagnostic-fields input[type=number] { width: 100%; min-height: 30px; font: inherit; padding: 5px 8px; border: 1px solid var(--shadow); background: var(--entry); color: var(--ink); }
.diagnostic-config > .check { margin: 5px 12px 5px 0; }

/* Histogram controls inherit each workspace's form style. */
[hidden] { display: none !important; }
#histogram-data textarea { width: 100%; box-sizing: border-box; font-family: monospace; }
.analysis-choice { margin-bottom: 14px; }
.histogram-binning > .field { min-width: 85px; }
#hist-fit-options { margin-bottom: 16px; }

.table-fit-settings { margin: 12px 0; padding: 12px; }
.table-fit-settings .row { flex-wrap: wrap; }
.table-fit-settings input { width: 100%; box-sizing: border-box; }


/* Application prompts use each workspace's existing dialog frame. */
dialog.app-dialog { width: min(480px, 92vw); max-height: 90vh; }
.app-dialog .dialog-message { white-space: pre-wrap; overflow-wrap: anywhere; margin: 0 0 14px; }
.app-dialog .actions { justify-content: flex-end; }
.app-dialog .dialog-error { color: var(--err); margin: 8px 0; }
.app-dialog input[aria-invalid="true"] { outline: 2px solid var(--err); }
body.modern button.danger { background: #a72d25; border-color: #a72d25; color: white; }
body.modern button.danger:hover:not(:disabled) { background: #86221c; border-color: #86221c; }

.app-dialog.save-notice .dialog-message { color: #a1241c; font-weight: 700; line-height: 1.6; }

/* Results navigation uses a link so normal browser navigation remains available. */
.analyze-results-button{display:inline-flex;align-items:center;justify-content:center;padding:8px 16px;background:var(--accent);color:#fff;text-decoration:none;font-weight:600;border:2px outset #b8b8dc;white-space:nowrap}
.analyze-results-button:hover{background:#1a1a9a;color:#fff;text-decoration:none}
.analyze-results-button:focus-visible{outline:2px solid var(--accent);outline-offset:3px}
.result-navigation{display:flex;justify-content:flex-end;padding:8px 0}


/* ---- guided model library dialog -------------------------------------- */
#model-library-btn { background: #eef3fb; color: #1f5390; }
#model-library-btn:hover:not(:disabled) { background: #dde8f8; }
.model-library-dialog { width: min(720px, 94vw); max-height: 88vh; padding: 0; }
.model-library-dialog .ml-body { padding: 16px 18px; overflow: auto; max-height: 72vh; }
.ml-intro { margin: 0 0 12px; color: #3a4553; font-size: 14px; }
.model-library-dialog .ml-search { width: 100%; margin-bottom: 12px; }
.ml-cats { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.ml-cat { min-height: 28px; padding: 0 12px; font-size: 13px; }
.ml-cat.active { background: var(--accent); color: var(--accent-ink); border-color: #6a6ab8 #000050 #000050 #6a6ab8; }
.ml-cat-head { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--accent); margin: 18px 0 8px; }
.ml-card { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid #dfe5ec; border-radius: 4px; margin-bottom: 8px; background: #fff; }
.ml-card:hover { border-color: var(--accent); background: #fbfcfe; }
.ml-card-main { flex: 1; min-width: 0; }
.ml-name { font-weight: 600; margin-bottom: 3px; }
.ml-desc { margin: 0 0 6px; font-size: 13px; line-height: 1.5; color: #3a4553; }
.ml-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; }
.ml-formula { font-size: 12px; background: #f3f6fa; padding: 2px 6px; border-radius: 3px; overflow-wrap: anywhere; }
.ml-axes { font-size: 12px; color: #6a7686; }
.ml-use { min-height: 30px; padding: 0 18px; background: #e2ecfb; color: #1f5390; align-self: center; flex: none; font-weight: 600; }
.ml-use:hover:not(:disabled) { background: #cfe0f6; }
.ml-empty { color: #6a7686; }
.model-library-dialog .actions { padding: 10px 18px; border-top: 1px solid #dfe5ec; margin: 0; }
@media (max-width: 560px) { .ml-card { flex-direction: column; align-items: stretch; } .ml-use { align-self: stretch; } }
.ml-guide { margin-top: 8px; }
.ml-guide > summary { cursor: pointer; color: #1f5390; font-size: 12.5px; font-weight: 600; list-style: none; }
.ml-guide > summary::-webkit-details-marker { display: none; }
.ml-guide > summary::before { content: "\25B8  "; }
.ml-guide[open] > summary::before { content: "\25BE  "; }
.ml-guide ul { margin: 8px 0 2px; padding-left: 20px; }
.ml-guide li { font-size: 13px; line-height: 1.55; color: #3a4553; margin-bottom: 4px; }
.param-help-btn { margin-top: 8px; font-weight: 600; }
.help-model-guide { background: #eef3fb; border: 1px solid #cfe0f6; border-radius: 4px; padding: 9px 12px; margin: 0 0 12px; }
.help-model-name { margin: 0 0 6px; }
.help-model-guide ul { margin: 0; padding-left: 18px; }
.help-model-guide li { margin-bottom: 4px; line-height: 1.5; }
