:root {
  --bg: #fbfbfa;
  --panel: #f1f1ee;
  --panel2: #e9e9e5;
  --ink: #1d1d1f;
  --muted: #6e6e73;
  --line: #d2d2cf;
  --rail: #e6e6e2;
  --divider: #d8d8d4;
  --obs: #c4372f;
  --calc: #1d1d1f;
  --diff: #2f6fbf;
  --accent: #0a7f6f;
  --accent-ink: #ffffff;
  --sel: #d9ece8;
  --phase-0: #0a7f6f;
  --phase-1: #b06a00;
  --phase-2: #7a3fb0;
  --phase-3: #2f6fbf;
  --phase-4: #a8325e;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1c1c1e; --panel: #242426; --panel2: #2c2c2e; --ink: #f2f2f2; --muted: #9a9aa0; --line: #3a3a3c; --rail: #19191b; --divider: #343436;
    --obs: #ff6b5e; --calc: #f2f2f2; --diff: #64a6ff; --accent: #3fd0b8; --accent-ink: #0f1f1c; --sel: #243b37;
    --phase-0: #3fd0b8; --phase-1: #f0a23a; --phase-2: #c08cf0; --phase-3: #64a6ff; --phase-4: #f07aa6;
  }
}
:root[data-theme="dark"] {
  --bg: #1c1c1e; --panel: #242426; --panel2: #2c2c2e; --ink: #f2f2f2; --muted: #9a9aa0; --line: #3a3a3c; --rail: #19191b; --divider: #343436;
  --obs: #ff6b5e; --calc: #f2f2f2; --diff: #64a6ff; --accent: #3fd0b8; --accent-ink: #0f1f1c; --sel: #243b37;
  --phase-0: #3fd0b8; --phase-1: #f0a23a; --phase-2: #c08cf0; --phase-3: #64a6ff; --phase-4: #f07aa6;
  color-scheme: dark;
}
:root[data-theme="light"] { color-scheme: light; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
/* §10: Increase contrast (System Settings ▸ Accessibility ▸ Display) honoured in both appearances: the lines, the dividers
   and the quiet text darker in light and lighter in dark, the selection stronger, and the plots' colours deeper in
   light and brighter in dark, each keeping its meaning (Yobs, Ycal, the difference, each phase). The dark rules repeat
   the dark theme's selectors, which outrank :root alone. */
@media (prefers-contrast: more) {
  :root {
    --muted: #3a3a3f; --line: #6e6e73; --divider: #8a8a8f; --rail: #dcdcd8; --sel: #b6dcd4;
    --obs: #a3150f; --calc: #000000; --diff: #0b4fa8; --accent: #006356;
    --phase-0: #006356; --phase-1: #8a4f00; --phase-2: #5c1f95; --phase-3: #0b4fa8; --phase-4: #8a1440;
  }
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
      --muted: #c8c8ce; --line: #8a8a90; --divider: #7a7a80; --rail: #101012; --sel: #2f5a52;
      --obs: #ff8a80; --calc: #ffffff; --diff: #8cc0ff; --accent: #5fe8d0;
      --phase-0: #5fe8d0; --phase-1: #ffbf5c; --phase-2: #d8adff; --phase-3: #8cc0ff; --phase-4: #ff9cc4;
    }
  }
  :root[data-theme="dark"] {
    --muted: #c8c8ce; --line: #8a8a90; --divider: #7a7a80; --rail: #101012; --sel: #2f5a52;
    --obs: #ff8a80; --calc: #ffffff; --diff: #8cc0ff; --accent: #5fe8d0;
    --phase-0: #5fe8d0; --phase-1: #ffbf5c; --phase-2: #d8adff; --phase-3: #8cc0ff; --phase-4: #ff9cc4;
  }
  .sl-row.selected, .prow.current { outline: 1px solid var(--ink); outline-offset: -1px; }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  display: flex; flex-direction: column;
  background: var(--bg); color: var(--ink);
  font: 13px/1.35 -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  -webkit-user-select: none; user-select: none; overflow: hidden;
}
button, input, select { font: inherit; color: inherit; }
button { padding: 4px 11px; border-radius: 6px; border: 1px solid var(--line); background: var(--bg); cursor: pointer; }
button:hover { border-color: var(--accent); }
button:disabled { opacity: 0.45; cursor: default; border-color: var(--line); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.quiet { border-color: transparent; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
kbd { font: 11px ui-monospace, Menlo, monospace; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; }
.mono { font-family: ui-monospace, Menlo, monospace; }
.sub { color: var(--muted); }
.empty { color: var(--muted); padding: 10px 12px; line-height: 1.5; }
code { font-family: ui-monospace, Menlo, monospace; font-size: 12px; }

/* ---------------------------------------------------------------- toolbar in the title bar */
.toolbar {
  display: flex; align-items: center; gap: 10px; height: 38px; flex: none;
  padding: 0 12px 0 84px; background: var(--panel); border-bottom: 4px solid var(--divider);
}
.tb-left { flex: 1; height: 100%; }
.search {
  display: flex; align-items: center; gap: 8px; width: 340px; padding: 4px 10px; border-radius: 7px;
  border: 1px solid var(--line); background: var(--bg); color: var(--muted); cursor: text;
}
.search span:first-child { flex: 1; }
.tb-verbs { display: flex; gap: 6px; }

/* ---------------------------------------------------------------- body: activity bar + dock */
.body { flex: 1; min-height: 0; display: flex; }
/* the rail: a wider grey strip with the tools' buttons, the active one marked by a bar at the edge (as an IDE's) */
.activity { width: 60px; flex: none; display: flex; flex-direction: column; justify-content: space-between; background: var(--rail); border-right: 4px solid var(--divider); padding: 8px 0; }
.act-top, .act-bottom { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.act { position: relative; width: 40px; height: 40px; padding: 0; border: none; border-radius: 8px; background: none; color: var(--muted); display: flex; align-items: center; justify-content: center; font-size: 17px; }
.act:hover { background: var(--panel2); color: var(--ink); }
.act.active { color: var(--accent); }
.act.active::before { content: ""; position: absolute; left: -6px; top: 8px; bottom: 8px; width: 3px; background: var(--accent); border-radius: 0 2px 2px 0; }
.act svg { width: 23px; height: 23px; }
.act .badge { position: absolute; top: 2px; right: 2px; min-width: 14px; height: 14px; border-radius: 7px; background: var(--accent); color: var(--accent-ink); font-size: 10px; line-height: 14px; text-align: center; padding: 0 3px; }
.dock { flex: 1; min-width: 0; min-height: 0; }

/* dockview mapped to the tokens */
.dv-theme-drs {
  --dv-group-view-background-color: var(--bg);
  --dv-tabs-and-actions-container-background-color: var(--panel);
  --dv-tabs-and-actions-container-height: 30px;
  --dv-tabs-and-actions-container-font-size: 12px;
  --dv-tab-font-size: 12px;
  --dv-activegroup-visiblepanel-tab-background-color: var(--bg);
  --dv-activegroup-visiblepanel-tab-color: var(--ink);
  --dv-activegroup-hiddenpanel-tab-background-color: var(--panel);
  --dv-activegroup-hiddenpanel-tab-color: var(--muted);
  --dv-inactivegroup-visiblepanel-tab-background-color: var(--bg);
  --dv-inactivegroup-visiblepanel-tab-color: var(--ink);
  --dv-inactivegroup-hiddenpanel-tab-background-color: var(--panel);
  --dv-inactivegroup-hiddenpanel-tab-color: var(--muted);
  --dv-tab-divider-color: var(--line);
  --dv-separator-border: var(--line);
  --dv-sash-color: var(--divider); --dv-active-sash-color: var(--accent);
  --dv-floating-box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35); --dv-group-view-background-color: var(--bg);
  background: var(--divider);
  --dv-drag-over-background-color: rgba(10, 127, 111, 0.18); --dv-drag-over-border-color: var(--accent);
  --dv-icon-hover-background-color: var(--panel2);
  --dv-paneview-header-border-color: var(--line);
  --dv-scrollbar-background-color: rgba(127, 127, 127, 0.35);
  --dv-border-radius: 0;
  --dv-overlay-z-index: 50;
  height: 100%;
}
.dv-theme-drs .dv-tab { padding: 0 10px; border-right: 1px solid var(--line); }
.dv-theme-drs .dv-active-group .dv-tab.dv-active-tab { box-shadow: inset 0 -2px 0 var(--accent); }
.dv-theme-drs .dv-groupview { border: none; border-radius: 6px; overflow: hidden; }
.dv-theme-drs .dv-grid-view.dv-dockview, .dv-theme-drs .dv-dockview { background: var(--divider); }   /* the grey shows at the rounded corners */
.dv-theme-drs .dv-tabs-and-actions-container { border-bottom: 1px solid var(--line); }
.dv-theme-drs .dv-sash:hover, .dv-theme-drs .dv-sash.dv-active { background: var(--accent); opacity: 0.6; }
.dv-theme-drs .dv-floating-group-container { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.dv-actions-drs { display: flex; align-items: center; padding: 0 4px; }
.dv-act { border: none; background: none; color: var(--muted); font-size: 13px; padding: 2px 6px; border-radius: 5px; }
.dv-act:hover { background: var(--panel2); color: var(--ink); }
/* the parameter's symbol marked in its formula (cards, the manual) */
.katex .hl { color: var(--accent); font-weight: 600; background: var(--sel); border-radius: 3px; padding: 0 2px; }
.pane { height: 100%; overflow: auto; display: flex; flex-direction: column; }
.pane-sidebar, .pane-inspector, .pane-bottom, .pane-log { background: var(--panel); }
.pane-file { background: var(--bg); overflow: hidden; }
.pane-start { background: var(--bg); align-items: center; justify-content: center; }

/* sidebar */
.sec-head { display: flex; justify-content: space-between; align-items: baseline; padding: 8px 12px 4px; font-size: 11px; font-weight: 600; letter-spacing: 0.06em; color: var(--muted); text-transform: uppercase; }
.sec-head .sub { text-transform: none; letter-spacing: 0; font-weight: 400; }
.sec-body { flex: 1; min-height: 120px; overflow: auto; }
.tree { padding-bottom: 8px; max-height: 45%; overflow: auto; flex: none; border-bottom: 1px solid var(--line); }
.sl-row { display: flex; align-items: center; gap: 6px; padding: 3px 8px 3px 10px; cursor: default; }
.sl-row.top { margin-top: 6px; }
.sl-row.top .nm { font-weight: 600; text-transform: uppercase; font-size: 11px; letter-spacing: 0.05em; color: var(--muted); }
.sl-row:hover { background: var(--panel2); }
.sl-row.selected { background: var(--sel); }
.sl-row .glyph { width: 20px; color: var(--muted); display: inline-flex; align-items: center; justify-content: center; flex: none; }
.sl-row .glyph svg { width: 16px; height: 16px; }
.sl-row .disc { width: 12px; color: var(--muted); font-size: 11px; text-align: center; }
.sl-row .kdot { width: 8px; height: 8px; border-radius: 50%; background: var(--line); flex: none; }
.sl-row .kdot[data-kind="pattern"], .sl-row .kdot[data-kind="phases"], .sl-row .kdot[data-kind="refinement"] { display: none; }
.sl-row .kdot[data-kind="data"] { background: var(--obs); }
.sl-row .kdot[data-kind="instrument"] { background: var(--diff); }
.sl-row .kdot[data-kind="background"] { background: var(--phase-1); }
.sl-row .kdot[data-kind="atom"] { background: var(--phase-2); }
.sl-row .kdot[data-kind="parameters"], .sl-row .kdot[data-kind="history"] { background: var(--accent); }
.sl-row .txt { display: flex; flex-direction: column; min-width: 0; }
.sl-row .nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sl-row .sub { font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sourcelist { padding-bottom: 12px; }

/* main area: a file's view */
.ctabs { display: flex; align-items: center; gap: 2px; padding: 4px 10px 0; border-bottom: 1px solid var(--line); background: var(--panel); flex: none; }
.ctab { padding: 4px 10px; border-radius: 6px 6px 0 0; color: var(--muted); cursor: default; }
.ctab.active { background: var(--bg); color: var(--ink); border: 1px solid var(--line); border-bottom-color: var(--bg); margin-bottom: -1px; }
.agreement { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; padding-right: 6px; }
.plotarea { position: relative; flex: 1; min-height: 0; }
.plotarea .plot { position: absolute; inset: 0; width: 100%; height: 100%; cursor: crosshair; }
.readout { position: absolute; top: 8px; right: 16px; color: var(--muted); font-variant-numeric: tabular-nums; pointer-events: none; }
.legend { position: absolute; top: 8px; left: 64px; display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--muted); pointer-events: none; }
.legend .key { display: inline-flex; align-items: center; gap: 6px; }
.legend .sw { width: 14px; height: 2px; display: inline-block; }
.paramsview { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 6px 8px; }
.ptable { border-collapse: collapse; font-variant-numeric: tabular-nums; width: 100%; }
.ptable th { text-align: left; color: var(--muted); font-weight: 500; border-bottom: 1px solid var(--line); padding: 3px 8px; }
.ptable td { padding: 2px 8px; border-bottom: 1px solid color-mix(in srgb, var(--line) 50%, transparent); vertical-align: top; }
.ptable td.num { text-align: right; }
.ptable td.mono { font-size: 11px; }

/* the start page */
.start-box { max-width: 560px; padding: 24px; }
.start-box h1 { font-size: 22px; margin: 0 0 6px; color: var(--accent); }
.start-box h2 { font-size: 11px; margin: 18px 0 6px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.start-box .lede { font-size: 14px; margin: 0 0 16px; }
.start-box p { margin: 6px 0; }
.start-recent { list-style: none; padding: 0; margin: 0; }
.start-recent li { padding: 3px 0; }
.start-recent a { color: var(--ink); text-decoration: none; }
.start-recent a:hover b { color: var(--accent); }

/* bottom panel: the refinement zone and the log */
.refzone { flex: 1; min-height: 0; display: flex; flex-direction: column; -webkit-user-select: text; user-select: text; }
.rz-head { display: flex; align-items: center; gap: 12px; padding: 6px 12px 2px; }
.rz-head h2 { font-size: 13px; margin: 0; }
.rz-verdict { margin-left: auto; display: flex; gap: 6px; }
.refstate { font-weight: 400; color: var(--muted); margin-left: 6px; }
.rz-cols { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 1.7fr 1.1fr; gap: 12px; padding: 0 12px 8px; }
.rz-col { overflow: auto; min-height: 0; }
.rz-col h3 { font-size: 11px; margin: 6px 0 4px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.refzone table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.refzone th { text-align: right; font-weight: 500; color: var(--muted); padding: 2px 4px; border-bottom: 1px solid var(--line); }
.refzone td { text-align: right; padding: 1px 4px; }
.refzone th:first-child, .refzone td:first-child { text-align: left; }
.cycles td:last-child, .cycles th:last-child { white-space: nowrap; text-align: left; }
.cycles td .sub { font-size: 11px; font-family: ui-monospace, Menlo, monospace; }
.params { width: 100%; }
/* a parameter by its name (L136): the name takes the room the value(esd) leaves, cut short with … if it must be (whole on hover) */
.params td:first-child { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 0; width: 100%; padding-right: 10px; }
.params td:nth-child(2) { white-space: nowrap; }
.params td.flag { color: var(--phase-1); font-size: 11px; text-align: left; }
.summary { margin-top: 6px; color: var(--muted); line-height: 1.5; }
.corr, .history { margin: 0; padding-left: 16px; color: var(--muted); font-size: 11px; }
.history li.acc b { color: var(--accent); }
.history li.dis { opacity: 0.7; }
.history button.small { margin: 0 0 0 4px; padding: 0 6px; }
.loglist { padding: 6px 12px; font-size: 12px; -webkit-user-select: text; user-select: text; }
.loglist div { padding: 1px 0; }
.loglist .err { color: var(--obs); }

/* inspector */
.inspector { flex: 1; overflow: auto; padding: 0 12px 16px; -webkit-user-select: text; user-select: text; }
.insp-head { padding: 8px 12px 8px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.inspector .insp-head { padding-left: 0; padding-right: 0; }
.insp-head .kind { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.insp-head .title { font-weight: 600; font-size: 14px; }
.insp-head .sub { font-size: 12px; }
.insp-children .child { display: flex; justify-content: space-between; gap: 8px; padding: 4px 2px; border-bottom: 1px solid color-mix(in srgb, var(--line) 50%, transparent); cursor: default; }
.insp-children .child:hover { background: var(--panel2); }
.insp-sec { padding: 0 12px; }
.inspector .insp-sec { padding: 0; }
.insp-sec h3 { font-size: 11px; margin: 12px 0 4px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.prow { display: grid; grid-template-columns: minmax(120px, 1fr) auto minmax(60px, 132px); align-items: center; gap: 8px; padding: 2px 0; min-height: 26px; }
.prow .pname { display: block; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: help; }
.prow .pname .sym { margin-left: 6px; }
.prow .pname .n { font-weight: 500; }
.prow .pname .qual, .prow .pname .sym { color: var(--muted); font-size: 12px; }
.prow .pval { display: flex; align-items: center; gap: 6px; justify-content: flex-end; }
.prow .pval input { width: 104px; text-align: right; padding: 2px 6px; border: 1px solid var(--line); border-radius: 5px; background: var(--bg); font-variant-numeric: tabular-nums; }
.prow .pval input:read-only { color: var(--ink); }
.prow .pval.text { justify-content: flex-start; grid-column: 2 / 4; text-align: right; color: var(--ink); line-height: 1.3; word-break: break-word; }
.prow .pval select { max-width: 230px; padding: 2px 4px; border: 1px solid var(--line); border-radius: 5px; background: var(--bg); }
.prow .pval input.name { width: 200px; text-align: left; }
.prow .pval .x { padding: 0 6px; border: none; background: none; color: var(--muted); font-size: 14px; }
.prow .pval .x:hover { color: var(--obs); }
button.small { font-size: 11px; padding: 2px 8px; margin: 4px 0 0; }
.prow .pval .unit { color: var(--muted); font-size: 11px; white-space: nowrap; max-width: 72px; overflow: hidden; text-overflow: ellipsis; }
.prow .ptail { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; font-size: 11px; color: var(--muted); min-width: 56px; line-height: 1.2; }
.prow .chk { display: inline-flex; align-items: center; gap: 4px; }
.prow .tie { color: var(--diff); }
.prow .flag { color: var(--phase-1); }
.prow.free .pname .n { color: var(--accent); }

/* status bar */
.statusbar { display: flex; align-items: center; gap: 14px; padding: 4px 12px; color: var(--muted); border-top: 4px solid var(--divider); background: var(--panel); font-size: 11px; flex: none; }
.statusbar .path { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 45%; }
.statusbar .msg { margin-left: auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: default; }
.statusbar .msg.error { color: var(--obs); }

/* ⌘K, context menus, cards */
.palette { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.25); display: flex; align-items: flex-start; justify-content: center; padding-top: 12vh; z-index: 60; }
.palette .box { width: 640px; max-height: 70vh; display: flex; flex-direction: column; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 16px 48px rgba(0, 0, 0, 0.3); overflow: hidden; }
.palette input { padding: 12px 14px; border: none; border-bottom: 1px solid var(--line); background: transparent; outline: none; font-size: 15px; }
.palette .list { overflow: auto; padding: 6px 0; }
.pgroup { padding: 6px 14px 2px; font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.pitem { display: flex; align-items: center; gap: 10px; padding: 5px 14px; cursor: default; }
.pitem.active { background: var(--sel); }
.pitem .glyph { width: 14px; color: var(--muted); text-align: center; }
.pitem .t { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.pitem .sub { font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ctx { position: fixed; z-index: 70; min-width: 180px; padding: 4px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25); display: flex; flex-direction: column; }
.ctx button { text-align: left; border: none; background: none; padding: 5px 10px; border-radius: 5px; }
.ctx button:hover { background: var(--sel); }
.tip { position: fixed; z-index: 80; max-width: 420px; padding: 10px 12px; background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25); pointer-events: none; font-size: 12px; line-height: 1.4; }
.vc-h { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 3px; }
.vc-what { color: var(--ink); }
.vc-aff { color: var(--muted); margin-top: 3px; }
.vc-f { color: var(--muted); font-size: 11px; margin-top: 5px; }
.dcard .dc-h { display: flex; align-items: baseline; gap: 10px; margin-bottom: 4px; }
.dcard .dc-sym { color: var(--muted); }
.dcard .dc-unit { margin-left: auto; color: var(--muted); font-size: 11px; }
.dcard .dc-note { color: var(--muted); font-size: 11px; margin-bottom: 4px; }
.dcard .dc-meaning { margin-bottom: 4px; }
.dcard .dc-eq { margin: 4px 0; overflow-x: auto; }
.dcard .dc-src, .dcard .dc-names, .dcard .dc-facts { color: var(--muted); font-size: 11px; margin-top: 4px; }
.dcard .dc-facts b, .dcard .dc-names b { color: var(--ink); font-weight: 600; }
.dcard .dc-link { margin-top: 6px; color: var(--accent); font-size: 11px; }

/* dialogs and viewers */
dialog { border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--ink); padding: 18px 20px; min-width: 380px; box-shadow: 0 16px 48px rgba(0, 0, 0, 0.3); -webkit-user-select: text; user-select: text; }
dialog.wide { width: min(860px, 90vw); max-height: 85vh; }
dialog.wide[open] { display: flex; flex-direction: column; }
dialog::backdrop { background: rgba(0, 0, 0, 0.3); }
dialog h2 { margin: 0 0 10px; font-size: 15px; }
dialog h3 { margin: 12px 0 4px; font-size: 12px; color: var(--muted); }
dialog .row { display: flex; align-items: center; gap: 10px; margin: 6px 0; }
dialog .row span { width: 100px; color: var(--muted); }
dialog .chk { display: flex; align-items: center; gap: 6px; margin: 6px 0; }
dialog input[type="text"], dialog select { padding: 3px 6px; border: 1px solid var(--line); border-radius: 5px; background: var(--bg); }
dialog .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
dialog p { margin: 6px 0; }
dialog a { color: var(--accent); }
/* flex: 1 1 auto, not flex: 1 (basis 0 %): in a dialog whose height is only a maximum, WebKit gave the body no height (L174) */
.viewer-body { flex: 1 1 auto; min-height: 0; overflow: auto; line-height: 1.5; }
.viewer-body h3 { font-size: 14px; color: var(--ink); margin: 14px 0 4px; }
.viewer-body h4 { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin: 10px 0 4px; }
.viewer-body ul { margin: 4px 0; padding-left: 18px; }
.rel { border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.man-p { padding: 6px 0; border-bottom: 1px solid color-mix(in srgb, var(--line) 50%, transparent); }
.man-eq { margin: 4px 0; overflow-x: auto; }

/* the Data module */
.ctabs .axis { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); margin-right: 8px; }
.ctabs select { padding: 1px 4px; border: 1px solid var(--line); border-radius: 5px; background: var(--bg); font-size: 12px; }
.legend .key { cursor: pointer; pointer-events: auto; }
.legend .key.off { opacity: 0.4; text-decoration: line-through; }
.data-side { padding: 0 12px 12px; }
.data-side h3 { font-size: 11px; margin: 10px 0 4px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.data-side .chk { display: flex; align-items: center; gap: 6px; padding: 2px 0; }
.data-side .ops { margin: 0; padding-left: 18px; }
.data-side .ops li { padding: 2px 0; }
.data-side .ops .x { padding: 0 5px; border: none; background: none; color: var(--muted); }
.data-side .ops .x:hover { color: var(--obs); }
.table-holder { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.dtable { display: flex; flex-direction: column; height: 100%; min-height: 0; outline: none; }
.dt-head { display: flex; align-items: center; gap: 8px; padding: 4px 10px; border-bottom: 1px solid var(--line); flex: none; }
.dt-find { padding: 2px 6px; border: 1px solid var(--line); border-radius: 5px; background: var(--bg); width: 160px; }
.dt-count { color: var(--muted); font-size: 11px; flex: 1; }
.dt-scroll { flex: 1; min-height: 0; overflow: auto; position: relative; }
.dt-spacer { position: absolute; top: 0; left: 0; width: 1px; }
.dt { position: absolute; top: 0; left: 0; min-width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 12px; }
.dt th { position: sticky; top: 0; z-index: 2; background: var(--panel); text-align: right; font-weight: 500; color: var(--muted); padding: 3px 8px; border-bottom: 1px solid var(--line); cursor: default; }
/* §8 (L119): the first column stays in view when a table scrolls sideways */
.dt th:first-child { left: 0; z-index: 3; }
.dt td:first-child { position: sticky; left: 0; z-index: 1; background: var(--bg); }
.dt tr.selected td:first-child { background: var(--sel); }
.dt tr:hover td:first-child { background: var(--panel2); }
.dt th .dt-resize { position: absolute; right: 0; top: 0; width: 5px; height: 100%; cursor: col-resize; }
.dt td { padding: 2px 8px; height: 22px; border-bottom: 1px solid color-mix(in srgb, var(--line) 40%, transparent); white-space: nowrap; }
.dt td.num { text-align: right; }
.dt tr.selected td { background: var(--sel); }

/* the Editor module */
.cm-holder { flex: 1; min-height: 0; overflow: hidden; }
.cm-holder .cm-editor { height: 100%; }
.cm-holder .cm-gutters { background: var(--panel); color: var(--muted); border-right: 1px solid var(--line); }
.cm-holder .cm-activeLineGutter { background: var(--panel2); }
.cm-holder .cm-activeLine { background: color-mix(in srgb, var(--sel) 45%, transparent); }
.cm-holder .cm-lintRange-error { background-image: none; text-decoration: underline wavy var(--obs); text-underline-offset: 3px; }
.cm-holder .cm-lintRange-warning { background-image: none; text-decoration: underline wavy var(--phase-1); text-underline-offset: 3px; }
.cm-tooltip { background: var(--panel) !important; color: var(--ink); border: 1px solid var(--line) !important; border-radius: 6px; box-shadow: 0 8px 24px rgba(0,0,0,.25); font-size: 12px; }
.cm-tooltip-lint .cm-diagnostic { padding: 6px 8px; border-left-width: 4px; }
.cm-diagnostic-error { border-left-color: var(--obs) !important; }
.cm-diagnostic-warning { border-left-color: var(--phase-1) !important; }
.cm-diagnosticAction { background: var(--accent) !important; color: var(--accent-ink) !important; border-radius: 4px; padding: 1px 6px; }
.cm-panels { background: var(--panel) !important; color: var(--ink) !important; border-color: var(--line) !important; }
.cm-panel input, .cm-panel button { font: inherit; }
.cm-holder .cm-foldGutter .cm-gutterElement { color: var(--muted); }
.problems { flex: 1; min-height: 0; overflow: auto; }
.prob-head { padding: 6px 12px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 8px; }
.prob-head .err { color: var(--obs); } .prob-head .warn { color: var(--phase-1); } .prob-head .ok { color: var(--accent); }
.prob { display: flex; gap: 10px; align-items: baseline; padding: 3px 12px; cursor: default; }
.prob:hover { background: var(--panel2); }
.prob .where { font-family: ui-monospace, Menlo, monospace; font-size: 11px; color: var(--muted); min-width: 52px; }
.prob.err .where { color: var(--obs); } .prob.warn .where { color: var(--phase-1); }
.prob .what { flex: 1; }
.prob .fix { margin: 0; }
.refine-problems { flex: none; max-height: 40%; border-bottom: 1px solid var(--line); }
.act .badge.err { background: var(--obs); color: #fff; }
.merge { height: 60vh; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.merge .cm-mergeView { height: 100%; }
.merge .cm-editor { height: 100%; font-size: 12px; }
.sl-row.ol .nm, .sl-row.ver .nm { font-weight: 500; }

/* the project pop-up in the title bar, the sidebar by role, the welcome page (W1, W2, W5) */
.tb-left { display: flex; align-items: center; gap: 2px; }
.proj { border: none; background: none; font-weight: 600; color: var(--ink); padding: 3px 6px; border-radius: 6px; }
.proj:hover { background: var(--panel2); }
.proj-caret { color: var(--muted); font-size: 10px; }
.sec-head .switch { display: inline-flex; gap: 2px; text-transform: none; letter-spacing: 0; }
.sec-head .switch button { font-size: 10px; padding: 1px 6px; border-radius: 4px; }
.sec-head .switch button.on { background: var(--sel); border-color: var(--accent); }
.sl-row.group { margin-top: 4px; background: var(--panel2); }
.sl-row.group .nm { font-weight: 600; text-transform: uppercase; font-size: 11px; letter-spacing: 0.05em; color: var(--muted); }
.sl-row.group .count { margin-left: auto; color: var(--muted); font-size: 11px; padding-right: 4px; }
.sl-row.missing .nm { color: var(--obs); }
.sl-row.missing .sub { color: var(--obs); }
.sl-row.stale { opacity: 0.55; }
.sl-row:focus { outline: 2px solid var(--accent); outline-offset: -2px; }
.empty.small { padding: 4px 24px; font-size: 11px; }
.start-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.dropzone { margin: 14px 0; padding: 22px; border: 2px dashed var(--line); border-radius: 10px; color: var(--muted); text-align: center; }
.ctx .sep { height: 1px; background: var(--line); margin: 4px 0; }
.ctx button.head { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; opacity: 1; }
.tip.multi { white-space: pre-line; }

/* the suggestion strip over a pattern (nothing analysed unasked) and the explained dialogs */
.suggest { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-bottom: 1px solid var(--line); background: var(--panel2); font-size: 12px; flex: none; }
.suggest span { flex: 1; color: var(--muted); }
dialog.explained { max-width: 560px; }
dialog.explained .row span.unit { width: auto; }
dialog.explained .help { margin: 0 0 10px 110px; font-size: 12px; color: var(--muted); line-height: 1.4; }
dialog .actions .spacer { flex: 1; }

/* collapsible inspector sections (Josu, 0.8.0) */
.insp-sec > h3 { cursor: pointer; user-select: none; display: flex; align-items: center; gap: 6px; }
.insp-sec > h3::before { content: "▾"; font-size: 9px; width: 10px; color: var(--muted); }
.insp-sec.collapsed > h3::before { content: "▸"; }
.insp-sec.collapsed > :not(h3) { display: none; }
.insp-head { position: relative; }
.insp-ctl { position: absolute; right: 0; top: 8px; display: flex; gap: 2px; }
.insp-ctl button { padding: 0 6px; font-size: 12px; line-height: 18px; }

/* the rail's bottom icons say what they are (W7) */
/* every button of the bar says what it is under its icon (APP_CONVENTIONS §2, L149); thin line icons */
.act.labelled { width: 56px; height: 46px; flex-direction: column; gap: 3px; }
.act.labelled .ic { display: flex; align-items: center; justify-content: center; height: 22px; }
.act.labelled svg { width: 22px; height: 22px; }
.act.labelled .lbl { font-size: 9px; line-height: 1; color: var(--muted); letter-spacing: 0.01em; white-space: nowrap; }
.act.labelled.active .lbl { color: var(--accent); }
.act.labelled:hover .lbl { color: var(--ink); }
.ctabs .subtitle { color: var(--muted); margin-left: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 46%; }
.refine-summary .row { display: flex; justify-content: space-between; gap: 10px; padding: 3px 0; }
.refine-summary .row .nm { color: var(--muted); }
.refine-summary .phase { cursor: pointer; }
.refine-summary .phase:hover { color: var(--accent); }
.ctabs { flex-wrap: nowrap; }
.ctabs .ctab { flex: none; white-space: nowrap; }
.ctabs .agreement { flex: none; white-space: nowrap; margin-left: auto; }
/* Explore's controls (L137): a bar of their own under the view tabs, wrapping onto a second line in a narrow window
   instead of running past its edge; a long parameter name in a selector is cut short (whole in the list) */
.ex-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; padding: 4px 10px; border-bottom: 1px solid var(--line); background: var(--panel); flex: none; min-width: 0; font-size: 12px; }
.ex-controls:not(:has(> :not([hidden]))) { display: none; }
.ex-controls .axis { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; color: var(--muted); min-width: 0; }
.ex-controls label { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; min-width: 0; }
.ex-controls select { padding: 1px 4px; border: 1px solid var(--line); border-radius: 5px; background: var(--bg); font-size: 12px; max-width: 200px; text-overflow: ellipsis; }
.ex-controls input[type="range"] { width: 120px; }
.ex-controls .subtitle { color: var(--muted); flex: 1 1 140px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 0.9.0: toolbar fields (W11), the background list (W4), the reflections view (W8), the cycles' sparkline */
.tb-field { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); }
.tb-field input { width: 44px; padding: 2px 5px; border: 1px solid var(--line); border-radius: 5px; background: var(--bg); font-size: 12px; text-align: right; }
.bg-side .bgtable { width: 100%; border-collapse: collapse; font-size: 12px; margin: 4px 0; }
.bg-side .bgtable th { text-align: left; color: var(--muted); font-weight: 500; padding: 2px 4px; }
.bg-side .bgtable td { padding: 1px 4px; }
.bg-side .bgtable tr.selected td { background: var(--sel); }
.bg-side .bgtable input { width: 70px; padding: 1px 4px; border: 1px solid var(--line); border-radius: 4px; background: var(--bg); font-size: 12px; text-align: right; }
.bg-side .bgtable td.n { color: var(--muted); }
.reflview { display: flex; flex-direction: column; height: 100%; min-height: 0; }
/* Refine's Comparison view (§4, app/DESIGN.md §11.1, app 0.52.0: the frame) */
.compareview { height: 100%; min-height: 0; overflow: auto; padding: 8px 14px; font-size: 13px; }
.compareview[hidden] { display: none; }
.compareview .lede { margin: 2px 0 8px; color: var(--muted); }
.compareview .compare-program { padding: 4px 0; border-bottom: 1px solid var(--line); }
.compareview .compare-program p { margin: 2px 0 0; }
.compareview .compare-section { margin-top: 12px; }
.compareview .compare-section h3 { margin: 0 0 4px; font-size: 13px; }
.compareview .compare-section .empty { padding: 18px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: 6px; }
.reflview .refl-bar { display: flex; align-items: center; gap: 10px; padding: 4px 10px; border-bottom: 1px solid var(--line); font-size: 12px; color: var(--muted); flex: none; }
.reflview .refl-bar select, .reflview .refl-bar input[type="text"] { padding: 1px 4px; border: 1px solid var(--line); border-radius: 5px; background: var(--bg); font-size: 12px; }
.reflview .table-holder { flex: 1; min-height: 0; }
.reflview .refl-note { padding: 4px 10px; font-size: 11px; color: var(--muted); border-top: 1px solid var(--line); flex: none; }
.chi2spark { display: block; width: 220px; height: 36px; margin: 2px 0 6px; }
.refstate .reason { color: var(--ink); }
.refstate .reason.bad { color: var(--obs); }

/* the panel toggles at the right of the toolbar (app 0.9.2) */
.tb-panels { display: flex; gap: 2px; margin-left: 6px; }
.tb-panels .tgl { width: 26px; height: 24px; padding: 0; border: 1px solid var(--line); border-radius: 5px; background: var(--bg); color: var(--muted); font-size: 13px; line-height: 1; }
.tb-panels .tgl.on { color: var(--accent); background: var(--sel); border-color: var(--accent); }
.tb-panels .tgl:hover { color: var(--ink); }

/* 0.10.0: who is this peak, the correlation heat map, the parameters' paths */
.whocard { position: absolute; right: 16px; top: 36px; max-width: 420px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 28px rgba(0,0,0,0.25); padding: 8px 10px; font-size: 12px; z-index: 5; }
.whocard .who-h { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.whocard .who-shares { margin: 2px 0 4px; }
.whocard .who-refl { border-collapse: collapse; font-variant-numeric: tabular-nums; }
.whocard .who-refl td { padding: 1px 6px 1px 0; }
.whocard button.x { border: none; background: none; color: var(--muted); font-size: 14px; }
.corrmap { display: block; margin: 4px 0; image-rendering: pixelated; cursor: crosshair; }
.pathmap { display: block; margin: 4px 0; }
.paths select { max-width: 260px; }

.rebase-list { margin: 6px 0; padding-left: 18px; font-size: 12px; line-height: 1.4; max-height: 40vh; overflow: auto; }
.rebase-list li.error b { color: var(--obs); }
.rebase-list li.warning b { color: var(--phase-1); }
#start-recent.wide { max-width: 360px; }

/* app 0.11.0: W11's pause and W12's steering, plan and restraints in the inspector */
.reason.paused { color: var(--accent); }
.insp-note { margin: 8px 0; padding: 6px 8px; border-radius: 6px; background: var(--sel); font-size: 12px; line-height: 1.35; }
.steer-param { border-top: 1px solid var(--line); padding: 6px 0; }
.steer-head { font-size: 12px; line-height: 1.35; margin-bottom: 3px; }
.steer-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 2px 0; font-size: 12px; }
.steer-row.field { padding-left: 8px; }
.steer-row .addr { flex: 1 1 100%; color: var(--muted); }
.steer-row .lbl { color: var(--muted); }
.steer-row input { padding: 1px 5px; border: 1px solid var(--line); border-radius: 5px; background: var(--bg); text-align: right; font-variant-numeric: tabular-nums; }
.steer-row select { padding: 1px 4px; border: 1px solid var(--line); border-radius: 5px; background: var(--bg); }
.steer-row .x, .plan-btns .x { padding: 0 6px; border: none; background: none; color: var(--muted); font-size: 14px; }
.plan-step { border-top: 1px solid var(--line); padding: 6px 0; font-size: 12px; }
.plan-step.next { background: var(--sel); border-radius: 6px; padding: 6px; }
.plan-step.done { opacity: 0.7; }
.plan-step .badge { display: inline-block; padding: 0 6px; border-radius: 8px; background: var(--accent); color: var(--accent-ink); font-size: 10px; }
.plan-step .err { color: var(--obs); }
.plan-btns { display: flex; gap: 4px; margin-top: 4px; }
.cycles tr.cyc-notes td { font-size: 11px; padding-top: 0; }
table.restraints td, table.restraints th { font-size: 12px; }
#dlg-pick-select.wide { max-width: 420px; }

#dlg-form-fields textarea { padding: 3px 6px; border: 1px solid var(--line); border-radius: 5px; background: var(--bg); font: 12px ui-monospace, Menlo, monospace; }
#dlg-form-fields .help { margin: 0 0 8px 110px; }

/* 0.11.1: the toolbar holds Run, Step, Pause, Resume, Stop, the fields, Pick and Exclude without wrapping */
.toolbar { gap: 8px; }
.toolbar .search { flex: 0 1 340px; min-width: 150px; }
.toolbar .tb-verbs { flex: 0 1 auto; min-width: 0; overflow: hidden; white-space: nowrap; }
.toolbar .tb-verbs .tb, .toolbar .tb-field { white-space: nowrap; flex: none; }
.toolbar .tb-verbs .tb { padding: 3px 8px; }
.toolbar .tb-left { flex: 0 1 220px; min-width: 60px; }

/* the toolbar at a usual width: the title and the search give way first; the verbs scroll sideways rather than clip */
.toolbar .tb-left { flex: 0 1 160px; min-width: 40px; overflow: hidden; }
.toolbar .tb-left .proj { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toolbar .search { flex: 0 1 300px; min-width: 96px; }
.toolbar .tb-verbs { overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; gap: 4px; }
.toolbar .tb-verbs .tb { padding: 3px 7px; }
.toolbar .tb-field input { width: 38px; }
.toolbar .search { flex-basis: 230px; }
.toolbar .tb-left { flex-basis: 130px; }

/* W5 (L120): a colour per role — Okabe–Ito, told apart by colour-blind readers — in light and dark; the icon by kind */
:root {
  --role-data: #d55e00; --role-control: #0072b2; --role-copy: #6f7f90; --role-version: #cc79a7; --role-input: #009e73; --role-output: #c88a00; --role-other: #8e8e93; --role-folder: #8e8e93; --role-fullprof: #2b2b2b;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --role-data: #f08a4b; --role-control: #56b4e9; --role-copy: #9aaabb; --role-version: #e7a9cf; --role-input: #3fd6a9; --role-output: #f2be4d; --role-other: #a0a0a6; --role-folder: #a0a0a6; --role-fullprof: #e6e6e6; } }
:root[data-theme="dark"] { --role-data: #f08a4b; --role-control: #56b4e9; --role-copy: #9aaabb; --role-version: #e7a9cf; --role-input: #3fd6a9; --role-output: #f2be4d; --role-other: #a0a0a6; --role-folder: #a0a0a6; --role-fullprof: #e6e6e6; }
.sl-row.file .glyph { color: var(--muted); }
.sl-row.file[data-role="data"] .glyph { color: var(--role-data); }
.sl-row.file[data-role="control"] .glyph { color: var(--role-control); }
.sl-row.file[data-role="copy"] .glyph { color: var(--role-copy); }
.sl-row.file[data-role="version"] .glyph { color: var(--role-version); }
.sl-row.file[data-role="input"] .glyph { color: var(--role-input); }
.sl-row.file[data-role="output"] .glyph { color: var(--role-output); }
.sl-row.file[data-role="other"] .glyph, .sl-row.file[data-role="folder"] .glyph { color: var(--role-other); }
.sl-row.group .rolebar { width: 4px; height: 14px; border-radius: 2px; background: var(--line); flex: none; margin-right: 2px; }
.sl-row.group[data-role="data"] .rolebar { background: var(--role-data); }
.sl-row.group[data-role="control"] .rolebar { background: var(--role-control); }
.sl-row.group[data-role="copy"] .rolebar { background: var(--role-copy); }
.sl-row.group[data-role="version"] .rolebar { background: var(--role-version); }
.sl-row.group[data-role="input"] .rolebar { background: var(--role-input); }
.sl-row.group[data-role="output"] .rolebar { background: var(--role-output); }
.sl-row.group[data-role="other"] .rolebar { background: var(--role-other); }
/* the state on the name: a dot for unsaved changes, dimmed when stale, red when missing, a lock on a version, a mark on an open file */
.sl-row.file .mark { margin-left: 6px; font-size: 10px; vertical-align: middle; }
.sl-row.file .mark.dirty { color: var(--accent); font-size: 12px; }
.sl-row.file .mark.lock { font-size: 10px; opacity: 0.8; }
.sl-row.file .mark.missing { color: var(--obs); font-weight: 700; border: 1px solid var(--obs); border-radius: 50%; padding: 0 4px; font-size: 9px; }
.sl-row.file .mark.open { color: var(--accent); }
.sl-row.file.open .nm { font-weight: 600; }
.sl-row.file.stale .nm, .sl-row.file.stale .glyph { opacity: 0.5; }
.sl-row.file.missing .nm { color: var(--obs); }

/* W14: FullProf's originals, one closed group in the Okabe–Ito set's black; FullProf's files marked as FullProf's (L122) */
.sl-row.file[data-role="fullprof"] .glyph { color: var(--role-fullprof); }
.sl-row.group[data-role="fullprof"] .rolebar { background: var(--role-fullprof); }
.sl-row.file .glyph { position: relative; }
.sl-row.file .glyph .fpmark { position: absolute; right: -4px; bottom: -3px; font: 700 7px/1 -apple-system, system-ui, sans-serif; font-style: normal; color: var(--fg); background: var(--panel); border: 1px solid currentColor; border-radius: 2px; padding: 0 1px; }
.suggest.organise { flex-wrap: wrap; }
#dlg-organise .steps { list-style: none; margin: 8px 0; padding: 0; max-height: 40vh; overflow: auto; border: 1px solid var(--line); border-radius: 6px; font-size: 12px; }
#dlg-organise .steps li { padding: 4px 8px; border-bottom: 1px solid var(--line); }
#dlg-organise .steps li b { display: inline-block; min-width: 74px; text-transform: none; }
#dlg-organise .steps li code { font-size: 11px; }
#dlg-organise .steps li .sub { display: block; color: var(--muted); }
#dlg-organise .steps li.skip { color: var(--obs); }
/* a tab's module icon (L122: two tabs of one file told apart) */
.dv-default-tab .tab-mod { display: inline-flex; width: 14px; height: 14px; margin-right: 5px; color: var(--muted); flex: none; }
.dv-default-tab .tab-mod svg { width: 14px; height: 14px; }
.dv-tab.dv-active-tab .tab-mod { color: var(--accent); }

/* where two dividers cross, one drag moves both (§1, L149) */
.sash-corner, .sash-corner .dv-sash { cursor: move !important; }

/* Start a Refinement from the structure (W2, W3; TU4) */
#dlg-start .modes { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12px; margin: 6px 0; }
#dlg-start .modes label { display: inline-flex; align-items: center; gap: 4px; }
#dlg-start .modes input[type="text"] { width: 5.5em; }
#dlg-start ul.plain { list-style: none; margin: 4px 0; padding: 0; font-size: 12px; }
#dlg-start ul.plain li { display: flex; align-items: center; gap: 8px; padding: 2px 0; }
#dlg-start ul.plain li button { margin-left: auto; }

/* the manual's window (APP_CONVENTIONS §5, L174): a definite height, contents at the left, the page at the right */
dialog.manual { width: min(1120px, 94vw); height: 88vh; max-height: 88vh; padding: 0; overflow: hidden; }
dialog.manual[open] { display: flex; flex-direction: column; }
.man-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); flex: none; }
.man-head h2 { margin: 0; flex: 1 1 auto; font-size: 15px; }
.man-head input[type="search"] { width: 260px; padding: 4px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--ink); }
.man-main { flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: minmax(180px, 240px) 1fr; }
#man-nav { overflow: auto; min-height: 0; border-right: 1px solid var(--line); padding: 8px 6px; background: var(--panel2); }
#man-nav button { display: block; width: 100%; text-align: left; border: 0; background: none; color: var(--ink); padding: 4px 8px; border-radius: 5px; font: inherit; cursor: default; }
#man-nav .man-page { font-weight: 600; font-size: 12px; margin-top: 4px; }
#man-nav .man-page.active { color: var(--accent); }
#man-nav .man-seclink { font-size: 12px; padding-left: 18px; color: var(--muted); }
#man-nav .man-seclink.active, #man-nav button:hover { color: var(--ink); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.man-body { overflow: auto; min-height: 0; padding: 14px 22px 30px; line-height: 1.55; }
.man-article { max-width: 820px; }
.man-article h2 { font-size: 15px; margin: 22px 0 6px; padding-top: 6px; border-top: 1px solid var(--line); }
.man-article h3 { font-size: 13px; margin: 14px 0 4px; }
.man-article ul, .man-article ol { padding-left: 20px; margin: 4px 0 8px; }
.man-article li { margin: 2px 0; }
.man-article code { font-size: 11.5px; }
.man-article .tex-d { margin: 8px 0; overflow-x: auto; }
.man-article table { border-collapse: collapse; margin: 6px 0; font-size: 12px; width: 100%; }
.man-article th, .man-article td { border-bottom: 1px solid var(--line); padding: 4px 6px; text-align: left; vertical-align: top; }
.man-article .man-cmds tr.grp th { background: var(--panel2); font-weight: 600; }
.man-article .man-cmds td:nth-child(2) { white-space: nowrap; }
.man-article .inventory th { width: 150px; color: var(--muted); font-weight: 500; }
.man-article section.item { border-top: 1px dashed var(--line); margin-top: 10px; }
.man-article .param-meta, .man-article .cite, .man-article .m { color: var(--muted); font-size: 11.5px; }
.man-hit { display: block; width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--line); background: none; color: var(--ink); padding: 8px 4px; font: inherit; cursor: default; }
.man-hit:hover { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.rel.new h3::after { content: "new"; margin-left: 8px; font-size: 10px; padding: 1px 6px; border-radius: 8px; background: var(--accent); color: var(--bg); vertical-align: middle; }
.dv-actions-drs .dv-help { font-weight: 600; }

/* Settings ▸ Shortcuts (app 0.20.1, APP_CONVENTIONS §6) */
#dlg-shortcuts { width: min(860px, 92vw); }
#dlg-shortcuts .sc-table { max-height: 52vh; overflow: auto; border: 1px solid var(--line); border-radius: 6px; }
#dlg-shortcuts .sc-table td:last-child { white-space: nowrap; }
#sc-msg.err, #sc-clashes b { color: var(--obs); }

/* The system's accent colour (APP_CONVENTIONS §10, L224): set by app.js (applyAccent) from System Settings ▸ Appearance;
   multicolour keeps the app's teal above. Buttons, the focus ring, selections and highlights all read --accent. */
:root[data-accent="system"] { --accent: var(--accent-light); --accent-ink: #ffffff; --sel: color-mix(in srgb, var(--accent-light) 20%, transparent); }
@media (prefers-color-scheme: dark) {
  :root[data-accent="system"]:not([data-theme="light"]) { --accent: var(--accent-dark); --accent-ink: #0b0b0c; --sel: color-mix(in srgb, var(--accent-dark) 28%, transparent); }
}
:root[data-theme="dark"][data-accent="system"] { --accent: var(--accent-dark); --accent-ink: #0b0b0c; --sel: color-mix(in srgb, var(--accent-dark) 28%, transparent); }
:root[data-accent="system"][data-accent-ink="dark"] { --accent-ink: #1b1b1b; }

/* A hidden panel's stub edge (APP_CONVENTIONS §1, L224): a click brings the panel back. */
.zone-stub { position: absolute; z-index: 6; background: transparent; }
.zone-stub::after { content: ""; position: absolute; background: var(--divider); }
.zone-stub[data-zone="sidebar"] { left: 0; top: 0; bottom: 0; width: 7px; cursor: e-resize; }
.zone-stub[data-zone="inspector"] { right: 0; top: 0; bottom: 0; width: 7px; cursor: w-resize; }
.zone-stub[data-zone="bottom"] { left: 0; right: 0; bottom: 0; height: 7px; cursor: n-resize; }
.zone-stub[data-zone="sidebar"]::after { left: 0; top: 0; bottom: 0; width: 2px; }
.zone-stub[data-zone="inspector"]::after { right: 0; top: 0; bottom: 0; width: 2px; }
.zone-stub[data-zone="bottom"]::after { left: 0; right: 0; bottom: 0; height: 2px; }
.zone-stub:hover::after { background: var(--accent); }
.zone-stub[data-zone="sidebar"]:hover::after, .zone-stub[data-zone="inspector"]:hover::after { width: 4px; }
.zone-stub[data-zone="bottom"]:hover::after { height: 4px; }

/* P49: the parameter a line of an output named, shown for a moment in the inspector */
.flash { animation: drs-flash 1.6s ease-out; }
@keyframes drs-flash { 0% { background: color-mix(in srgb, var(--accent) 35%, transparent); } 100% { background: transparent; } }
@media (prefers-reduced-motion: reduce) { .flash { animation: none; outline: 2px solid var(--accent); } }

/* The Settings window (APP_CONVENTIONS §4, app 0.30.0): a toolbar of panes, rows each with a one-line explanation. */
body.settings-window > header.toolbar, body.settings-window > .body, body.settings-window > footer.statusbar { display: none !important; }
body.settings-window { background: var(--panel); }
.settings-root { display: flex; flex-direction: column; height: 100vh; }
.set-bar { padding: 30px 12px 6px; border-bottom: 1px solid var(--line); background: var(--panel2, var(--panel)); }
.set-panes { display: flex; gap: 2px; justify-content: center; flex-wrap: wrap; }
.set-pane-btn { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 74px; padding: 5px 8px; border: none; background: transparent; border-radius: 6px; color: var(--ink); }
.set-pane-btn .g { font-size: 18px; line-height: 20px; color: var(--muted); }
.set-pane-btn .t { font-size: 11px; }
.set-pane-btn.active { background: var(--sel); }
.set-pane-btn.active .g { color: var(--accent); }
.set-body { flex: 1; overflow: auto; padding: 14px 28px 24px; }
.set-body h2 { font-size: 15px; margin: 4px 0 12px; }
.set-row { display: grid; grid-template-columns: 220px 1fr; column-gap: 14px; row-gap: 2px; padding: 8px 0; border-bottom: 1px solid var(--line); align-items: center; }
.set-row.wide { grid-template-columns: 1fr; }
.set-label { text-align: right; font-weight: 500; }
.set-row.wide .set-label { text-align: left; }
.set-ctl { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.set-ctl input[type="number"] { width: 90px; }
/* Settings ▸ External Programs: what a Check found, under the row's controls (app 0.52.0) */
.set-ctl .ext-said { flex-basis: 100%; }
.set-ctl .ext-said p { margin: 2px 0; }
.set-ctl .ext-said .ok { color: var(--ink); }
.set-ctl .ext-said .bad { color: var(--obs); }
.set-ctl .ext-said pre { margin: 2px 0; max-height: 9em; overflow: auto; white-space: pre-wrap; font-size: 0.85em; }
.set-ctl input.bad { outline: 2px solid var(--obs); }
.set-ctl .path { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.set-ctl .info { color: var(--muted); }
.set-help { grid-column: 2; margin: 0; font-size: 11.5px; color: var(--muted); }
.set-row.wide .set-help { grid-column: 1; }
.set-row .formats { max-height: 52vh; overflow: auto; width: 100%; }
.foot-projset { margin-left: 8px; }
/* §2: a file of the module changed on disk (waiting for an answer, or read again a moment ago) */
.act .badge.disk { background: var(--phase-1); color: #fff; }

/* File ▸ Print… (APP_CONVENTIONS §3, app 0.33.0): the sheet the shell fills with the active tab's plot or text; only print
   shows it, on white, and nothing else of the window prints */
.print-sheet { display: none; }
@media print {
  html, body { height: auto !important; overflow: visible !important; background: #fff !important; color: #000 !important; zoom: 1 !important; }
  body > *:not(#print-sheet) { display: none !important; }
  #print-sheet { display: block !important; color: #000; background: #fff; font: 10pt -apple-system, "Helvetica Neue", sans-serif; }
  .print-head { display: flex; gap: 0.6em; align-items: baseline; border-bottom: 0.5pt solid #888; padding-bottom: 4pt; margin-bottom: 8pt; }
  .print-head span { margin-left: auto; color: #555; }
  /* within the page Page Setup chose (its height less the margins, the header and a little room), else 160 mm */
  .print-body.figure svg { display: block; width: 100%; height: auto; max-height: 160mm; max-height: calc(var(--page-h, 247mm) - var(--page-mt, 0mm) - var(--page-mb, 0mm) - 26mm);
    /* the width capped by the same height and the figure's own proportions, so that it never runs past the page
       even where a print layout ignores max-height on an SVG (L290) */
    max-width: calc((var(--page-h, 247mm) - var(--page-mt, 0mm) - var(--page-mb, 0mm) - 26mm) * var(--vbw, 4) / var(--vbh, 3));
    break-inside: avoid; page-break-inside: avoid; }
  .print-text { font: 8.5pt ui-monospace, "SF Mono", Menlo, monospace; white-space: pre-wrap; word-break: break-all; margin: 0; }
  .print-text .ln { display: inline-block; width: 3.2em; color: #888; user-select: none; }
}

/* P09: a rotoinversion's bar over its digit, as International Tables print −3 */
.overbar { text-decoration: overline; }
td.sym { white-space: nowrap; }

/* §7, §11: drag and drop between modules (dnd.js): the target that takes the item, what a drop does in words (never
   the outline's colour alone), and a plot's grip */
.drop-over { outline: 2px dashed var(--accent); outline-offset: -4px; }
.drop-hint { position: fixed; z-index: 60; padding: 4px 8px; border-radius: 6px; background: var(--accent); color: var(--accent-ink); font-size: 12px; pointer-events: none; box-shadow: 0 2px 8px rgba(0,0,0,.2); }
.plot-drag { position: absolute; right: 6px; bottom: 6px; z-index: 3; padding: 0 5px; line-height: 18px; font-size: 13px; border: 1px solid var(--line); border-radius: 4px; background: var(--bg); color: var(--muted); cursor: grab; opacity: .75; }
.plot-drag:hover, .plot-drag:focus-visible { opacity: 1; color: var(--ink); }

/* View ▸ Customize Toolbar… (0.35.0) */
#dlg-toolbar { min-width: 520px; max-width: 680px; }
#dlg-toolbar .tb-list { list-style: none; padding: 0; margin: 4px 0 12px; max-height: 220px; overflow: auto; border: 1px solid var(--line); border-radius: 6px; }
#dlg-toolbar .tb-list li { display: flex; align-items: baseline; gap: 8px; padding: 4px 8px; border-bottom: 1px solid var(--line); }
#dlg-toolbar .tb-list li:last-child { border-bottom: none; }
#dlg-toolbar .tb-name { font-weight: 600; white-space: nowrap; }
#dlg-toolbar .tb-list .sub { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#dlg-toolbar .tb-acts { display: flex; gap: 4px; }
#dlg-toolbar .buttons { display: flex; justify-content: space-between; }

/* P45 (0.36.0): Refine's Parameter Impact and Normal Probability Plot views */
.impactview { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 6px 8px; -webkit-user-select: text; user-select: text; }
.impactview .impact-holder { flex: 1; min-height: 0; }
.impact-table td.num { font-variant-numeric: tabular-nums; }
.probview { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.probview[hidden] { display: none; }
.probview .prob-note { flex: none; padding: 6px 16px 0; }
.probview .plotarea { flex: 1; min-height: 0; }

/* §1, §3 (0.37.0): a panel in a macOS window of its own: the shell kept (dialogs, cards), only the panel shown */
body.panel-window > *:not(dialog):not(.panel-root):not(#tip):not(.ctx):not(.drop-hint) { display: none !important; }
.panel-root { display: flex; flex-direction: column; height: 100vh; }
.panel-bar { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-bottom: 1px solid var(--line); flex: none; -webkit-user-select: none; user-select: none; }
.panel-bar #panel-dockback { margin-left: auto; }
.panel-body { flex: 1; min-height: 0; overflow: auto; }
.panel-root .panel-status { flex: none; padding: 3px 10px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); min-height: 18px; }

/* E8a (0.38.0): with `labels`, the table's fixed first column (above, §8) names its rows: set left in the monospaced
   face (Explore's rule, now the table's) */
.dt-labels .dt td:first-child, .dt-labels .dt th:first-child { text-align: left; font-family: ui-monospace, Menlo, monospace; font-size: 11px; background: var(--panel); }

/* the shared time slider (E8, W11; 0.38.0) */
.tslider { display: flex; align-items: center; gap: 6px; padding: 4px 0 6px; }
.tslider .ts-track { position: relative; flex: 1; min-width: 80px; }
.tslider .ts-range { width: 100%; margin: 0; }
.tslider .ts-marks { position: absolute; left: 7px; right: 7px; top: -9px; height: 10px; pointer-events: none; }
.tslider .ts-mark { position: absolute; transform: translateX(-50%); font-size: 9px; line-height: 10px; color: var(--muted); pointer-events: auto; cursor: default; }
.tslider .ts-mark.bad { color: var(--diff); }
.tslider .ts-count { font-size: 11px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; min-width: 92px; }
.refslider { margin-top: 6px; }

/* L281: a project window in a macOS tab group: the page under the tab bar, which shows below the title bar */
body.tabbar { padding-top: 28px; box-sizing: border-box; }

/* §9 (R24): the core's problems marked where the value is edited: the outline's item and the inspector's row */
.pmark { margin-left: 4px; font-size: 11px; cursor: help; flex: none; }
.pmark.err { color: var(--obs); }
.pmark.warn { color: var(--phase-1); }
.sl-row.has-err .nm { text-decoration: underline wavy var(--obs); text-underline-offset: 3px; }
.sl-row.has-warn .nm { text-decoration: underline wavy var(--phase-1); text-underline-offset: 3px; }
.prow.has-err input, .prow.has-warn input { box-shadow: inset 0 -2px 0 var(--obs); }
.prow.has-warn input { box-shadow: inset 0 -2px 0 var(--phase-1); }
.prow.current { background: var(--sel); }
.refine-problems .prob.at { cursor: pointer; }
.refine-problems .prob.at:hover, .refine-problems .prob.at:focus-visible { background: var(--sel); }
.diag { white-space: pre-wrap; font: 11.5px/1.45 ui-monospace, Menlo, monospace; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 10px; max-height: 50vh; overflow: auto; user-select: text; }
/* P55: the guided plan, each step's values named; the preview's list of steps */
.plan-step .plan-what { margin: 2px 0; line-height: 1.4; }
.plan-step .plan-h .sub { margin-left: 6px; }
.insp-sec > .plan-btns { margin: 4px 0 8px; display: flex; gap: 6px; }
ol.guided { margin: 6px 0; padding-left: 22px; max-height: 52vh; overflow: auto; font-size: 12px; line-height: 1.45; }
ol.guided li { margin-bottom: 6px; }
ol.guided li .sub { margin-left: 4px; }
/* P54, P59: Refine's series view: its bar, the table, the chosen value's plot and the parametric fit */
.seriesview { display: flex; flex-direction: column; gap: 8px; padding: 8px; overflow: auto; height: 100%; }
.seriesview .series-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.seriesview .series-body { display: flex; flex-direction: column; gap: 8px; }
.seriesview .series-table { max-height: 34vh; }
.seriesview .series-plot { height: 260px; position: relative; }
.seriesview .series-fit .row { display: flex; gap: 8px; align-items: center; margin: 4px 0; }
.seriesview .series-fit .row > span { width: 6em; color: var(--muted); }
.seriesview .err { color: var(--obs); }
/* P06: a joint refinement's view: its bar, the patterns' table, the chosen pattern's settings and plot */
.jointview { display: flex; flex-direction: column; gap: 6px; padding: 6px 8px; height: calc(100% - 34px); min-height: 0; }
.jointview .joint-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.jointview .joint-patterns { display: flex; flex-direction: column; gap: 6px; flex: 1; min-height: 0; }
.jointview .joint-table { height: 130px; flex: none; }
.jointview .joint-pattern { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.jointview .joint-patterns .plotarea { flex: 1; min-height: 220px; position: relative; }
.jointview .joint-params { flex: 1; min-height: 0; }
.jointview .joint-params .table-holder { height: 100%; }
/* §8 (app 0.44.0): the shared table in an inspector section, as tall as its rows */
.insp-sec .dtable { margin: 4px 0; border: 1px solid var(--line); border-radius: 4px; }
