/* MOSAICS Studio in the browser. The palette is the one Bright's Oxford page
   uses: parchment, brick, Oxford navy and antique gold, with an editorial
   serif for headings and a monospace face for every number that matters. */

:root {
  /* The palette of www.cs.ox.ac.uk/mosaics: cream page, deep maroon bar, maroon accent, Lato. */
  --parchment: #fffbf1;
  --paper: #ffffff;
  --ink: #333333;
  --ink-soft: #555555;
  --muted: #7d7d7d;
  --line: #e5e0d3;
  --brick: #910000;
  --brick-deep: #6b0000;
  --navy: #450000;
  --navy-soft: #7a1a1a;
  --gold: #d9a441;
  --ok: #2e7d4f;
  --warn: #f89406;
  --err: #b94a48;
  --info: #2f5d9e;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(69, 0, 0, 0.06), 0 6px 18px rgba(69, 0, 0, 0.06);
  --serif: Lato, "Helvetica Neue", Helvetica, Arial, sans-serif;
  --sans: Lato, "Helvetica Neue", Helvetica, Arial, sans-serif;
  --mono: "JetBrains Mono", Monaco, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--parchment); color: var(--ink); font-family: var(--sans); font-size: 15px; line-height: 1.5; }
h1, h2, h3 { font-family: var(--serif); font-weight: 700; margin: 0; color: var(--brick); letter-spacing: 0; }
h1 { font-size: 2.1rem; line-height: 1.15; font-weight: 400; }
h2 { font-size: 1.15rem; margin-bottom: 0.6rem; }
p { margin: 0 0 0.6rem; }
a { color: var(--brick); }
small, .fine { color: var(--muted); font-size: 0.85rem; }
.fine { margin: 0.5rem 0 0; }
.fine.blocked { color: var(--err); border-left: 3px solid #e7b6b2; padding-left: 10px; }
.mono { font-family: var(--mono); font-size: 0.85em; }
u { text-decoration-color: var(--gold); }
[hidden] { display: none !important; }

.app { display: grid; grid-template-columns: 290px minmax(0, 1fr); min-height: 100vh; }

/* Rail */
.rail { background: var(--navy); color: #f1e6e6; padding: 28px 22px; display: flex; flex-direction: column; gap: 26px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 44px; height: 44px; border-radius: 10px; display: block; box-shadow: 0 0 0 2px rgba(255,255,255,0.35); }
.brand-name { font-family: var(--serif); font-size: 1.25rem; font-weight: 700; color: #fff; letter-spacing: 0.01em; }
.brand-sub { font-size: 0.8rem; color: #b8c0d6; }
.steps { display: flex; flex-direction: column; gap: 6px; }
.step { display: flex; gap: 12px; align-items: flex-start; text-align: left; width: 100%; background: transparent; border: 1px solid transparent; color: #f1e6e6; padding: 10px 12px; border-radius: 12px; cursor: pointer; font: inherit; }
.step small { display: block; color: #c9a3a3; font-size: 0.78rem; line-height: 1.3; }
.step b { color: #fff; font-weight: 600; }
.step:disabled { opacity: 0.45; cursor: default; }
.step:not(:disabled):hover { background: rgba(255, 255, 255, 0.06); }
.step.is-current { background: rgba(255, 255, 255, 0.1); border-color: rgba(255, 255, 255, 0.14); }
.step.is-done .step-n { background: var(--ok); color: #fff; }
.step-n { flex: 0 0 26px; height: 26px; border-radius: 50%; background: rgba(255, 255, 255, 0.12); display: grid; place-items: center; font-family: var(--mono); font-size: 0.8rem; margin-top: 2px; }
.step.is-current .step-n { background: var(--gold); color: var(--navy); }
.engine-card { margin-top: auto; background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 12px; padding: 14px; }
.engine-title { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.12em; color: #d4b3b3; margin-bottom: 4px; }
.engine-status { font-size: 0.9rem; color: #fff; min-height: 1.4em; }
.engine-note { font-size: 0.75rem; color: #c9a3a3; margin-top: 8px; line-height: 1.35; }
.engine-card.is-ready .engine-status { color: #b9e6c9; }
.engine-card.is-failed .engine-status { color: #f2b3ad; }
.rail-foot { font-size: 0.72rem; color: #c9a3a3; font-family: var(--mono); line-height: 1.5; }

.bar { height: 6px; background: rgba(255, 255, 255, 0.12); border-radius: 999px; overflow: hidden; margin-top: 8px; }
.bar.tall { height: 10px; background: var(--line); }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--gold), var(--brick)); transition: width 0.25s ease; }
.bar-fill.indeterminate { width: 40% !important; animation: slide 1.2s ease-in-out infinite alternate; }
@keyframes slide { from { margin-left: 0; } to { margin-left: 60%; } }

/* Main */
.main { padding: 40px 48px 80px; max-width: 1380px; }
.page-head { margin-bottom: 26px; max-width: 860px; }
.eyebrow { font-family: var(--mono); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.14em; color: var(--brick); margin-bottom: 8px; }
.lede { font-size: 1.05rem; color: var(--ink-soft); }

.cards { display: grid; gap: 18px; }
.cards.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; box-shadow: var(--shadow); min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.split { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr); gap: 22px; align-items: start; }
.viewer-col, .log-col { position: sticky; top: 24px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.viewer { height: 460px; border-radius: var(--radius); border: 1px solid var(--line); background: #fffdf7; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.viewer-caption { font-size: 0.82rem; color: var(--muted); }
.viewer-tabs { display: flex; gap: 6px; }
.tab { font: inherit; font-size: 0.85rem; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--paper); cursor: pointer; color: var(--ink-soft); }
.tab.is-current { background: var(--navy); color: #fff; border-color: var(--navy); }

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; flex: 1; }
.field > span { font-size: 0.8rem; font-weight: 600; color: var(--ink-soft); }
textarea, input[type="number"], input[type="text"], select { font: inherit; padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); min-width: 0; width: 100%; }
textarea { font-family: var(--mono); letter-spacing: 0.08em; resize: vertical; }
select { appearance: auto; }
textarea:focus, input:focus, select:focus { outline: 2px solid rgba(195, 154, 63, 0.5); border-color: var(--gold); }
.row { display: flex; gap: 10px; margin: 10px 0; }
.row.checks { gap: 18px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; }
.hint { font-family: var(--mono); font-size: 0.75rem; }
.hint.bad { color: var(--err); }

.btn { font: inherit; font-weight: 600; font-size: 0.92rem; padding: 10px 16px; border-radius: 10px; border: 1px solid var(--line); background: #fff; color: var(--navy); cursor: pointer; transition: transform 0.05s ease, box-shadow 0.15s ease; margin-top: 8px; }
.btn:hover:not(:disabled) { box-shadow: var(--shadow); transform: translateY(-1px); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.primary { background: var(--brick); border-color: var(--brick); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--brick-deep); }
.btn.danger { background: #fff; color: var(--err); border-color: #e7b6b2; }
.actions { display: flex; justify-content: flex-end; gap: 10px; }
.actions.left { justify-content: flex-start; }
.actions.wrap { flex-wrap: wrap; }

.drop { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 26px 16px; border: 2px dashed var(--line); border-radius: 12px; background: #fff; cursor: pointer; text-align: center; color: var(--ink-soft); margin: 8px 0; }
.drop:hover, .drop.is-over { border-color: var(--gold); background: #fffdf7; }
.drop-icon { font-size: 1.6rem; color: var(--gold); }
.drop.small { padding: 12px 14px; }
.status-pill[data-status="incomplete"] { background: #fff1d6; color: #8a5a00; }
#und-native-note.is-warning { color: #8a5a00; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin-bottom: 12px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.stat b { display: block; font-family: var(--mono); font-size: 1.15rem; color: var(--navy); font-weight: 500; }
.stat span { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }

.table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.table th, .table td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 600; }
.table td.num, .table th.num { text-align: right; font-family: var(--mono); }
.table .seq { font-family: var(--mono); letter-spacing: 0.06em; word-break: break-all; }
.table.kv td:first-child { color: var(--muted); width: 34%; }
.table.kv td:last-child { font-family: var(--mono); font-size: 0.82rem; word-break: break-all; }

.reason { background: #fff6e6; border-left: 3px solid var(--brick); padding: 10px 12px; border-radius: 0 10px 10px 0; color: var(--ink-soft); font-size: 0.92rem; }
.advanced { margin: 12px 0; }
.advanced summary { cursor: pointer; color: var(--brick); font-weight: 600; font-size: 0.9rem; }

.gates { display: flex; flex-direction: column; gap: 8px; }
.gate { display: grid; grid-template-columns: 10px 1fr auto; gap: 10px; align-items: center; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: #fff; font-size: 0.88rem; }
.gate i { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.gate[data-state="met"] i { background: var(--ok); }
.gate[data-state="unmet"] i { background: var(--warn); }
.gate[data-state="not_applicable"] i { background: #c9c9c9; }
.gate small { color: var(--muted); display: block; }
.gate .state { font-family: var(--mono); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-soft); }

.diagnostics { display: flex; flex-direction: column; gap: 8px; }
.diag { display: grid; grid-template-columns: 8px 1fr; gap: 10px; padding: 9px 11px; border-radius: 10px; border: 1px solid var(--line); background: #fff; font-size: 0.88rem; }
.diag i { width: 8px; border-radius: 4px; background: var(--muted); }
.diag[data-severity="ok"] i { background: var(--ok); }
.diag[data-severity="info"] i { background: var(--info); }
.diag[data-severity="warning"] i { background: var(--warn); }
.diag[data-severity="error"] i { background: var(--err); }
.diag b { font-weight: 600; }
.diag .code { font-family: var(--mono); font-size: 0.72rem; color: var(--muted); }
.diag p { margin: 2px 0 0; color: var(--ink-soft); }
.diag .remedy { color: var(--navy-soft); }
.diag-summary { font-size: 0.85rem; color: var(--muted); margin-bottom: 8px; }
.diagnostics.collapsed .diag[data-severity="ok"] { display: none; }
.show-all { font: inherit; font-size: 0.82rem; background: none; border: none; color: var(--brick); cursor: pointer; padding: 0; text-decoration: underline; text-decoration-color: var(--gold); }

.log { font-family: var(--mono); font-size: 0.74rem; line-height: 1.45; background: #2b0000; color: #f3e6e6; padding: 14px 16px; border-radius: var(--radius); height: 560px; overflow: auto; white-space: pre; margin: 0; box-shadow: var(--shadow); }
.log.short { height: 220px; }
.log-wrap { display: flex; flex-direction: column; min-height: 0; }
.row.wrap { flex-wrap: wrap; gap: 6px; }
.engine-file { margin: 10px 0; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.file-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.file-tools { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; text-transform: none; letter-spacing: 0; }
.file-state { font-family: var(--mono); font-size: 0.72rem; color: var(--muted); }
.file-state.is-edited { color: var(--brick); font-weight: 600; }
textarea.engine-text { font-family: var(--mono); font-size: 0.74rem; line-height: 1.45; letter-spacing: 0; background: #2b0000; color: #f3e6e6; border: 1px solid transparent; border-radius: var(--radius); padding: 12px 14px; white-space: pre; overflow: auto; resize: vertical; box-shadow: var(--shadow); }
textarea.engine-text.is-edited { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(217, 164, 65, 0.35); }
.is-expanded { position: fixed; inset: 16px; z-index: 60; margin: 0; padding: 16px; background: var(--parchment); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 24px 64px rgba(0, 0, 0, 0.35); display: flex; flex-direction: column; gap: 8px; }
.is-expanded .log, .is-expanded textarea.engine-text { flex: 1 1 auto; height: auto !important; min-height: 0; resize: none; }
.log-wrap.is-expanded::before { content: "Engine output"; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); }
.expand-close { position: absolute; top: 12px; right: 16px; }
.viewer-col.is-expanded { overflow: auto; }
.viewer-col.is-expanded .viewer { flex: 1 1 auto; height: auto; min-height: 320px; }
.viewer-readout { position: absolute; left: 10px; bottom: 10px; z-index: 5; max-width: 70%; font-family: var(--mono); font-size: 0.78rem; line-height: 1.4; color: var(--ink); background: rgba(255, 250, 241, 0.92); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; pointer-events: none; white-space: pre-line; }
.viewer-readout:empty { display: none; }
.viewer-tools .tool-btn.is-recording { background: var(--err); color: #fff; border-color: var(--err); }
.viewer-tools select.narrow { width: auto; }
.log-head { display: flex; justify-content: space-between; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); }
.progress-text { font-family: var(--mono); font-size: 0.85rem; color: var(--ink-soft); margin-top: 8px; }

.headline { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 22px; }
.headline .stat { background: var(--paper); box-shadow: var(--shadow); }
.headline .stat b { font-size: 1.45rem; }
.headline .stat.bad b { color: var(--err); }

.chart { width: 100%; height: 240px; }
.chart svg { width: 100%; height: 100%; display: block; }
.chart .axis { stroke: var(--line); stroke-width: 1; }
.chart .grid { stroke: #efe7d8; stroke-width: 1; }
.chart .series { fill: none; stroke: var(--brick); stroke-width: 1.8; stroke-linejoin: round; }
.chart .series.secondary { stroke: var(--navy-soft); stroke-dasharray: 4 3; stroke-width: 1.2; }
.chart text { font-family: var(--mono); font-size: 10px; fill: var(--muted); }
.chart .empty { font-family: var(--sans); font-size: 12px; }

.graph-result { margin-top: 10px; }
.toast { position: fixed; right: 22px; bottom: 22px; background: var(--navy); color: #fff; padding: 12px 16px; border-radius: 12px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25); max-width: 520px; font-size: 0.9rem; z-index: 50; }
.toast.error { background: var(--err); }
.toast pre { white-space: pre-wrap; font-size: 0.72rem; margin: 6px 0 0; max-height: 180px; overflow: auto; opacity: 0.9; }

@media (max-width: 1100px) {
  .cards.three { grid-template-columns: 1fr; }
  .split { grid-template-columns: 1fr; }
  .viewer-col, .log-col { position: static; }
}
@media (max-width: 800px) {
  .app { grid-template-columns: 1fr; }
  .rail { position: static; height: auto; }
  .main { padding: 24px 18px 60px; }
  .row { flex-direction: column; }
}

/* ---- round two: two-card start, viewer tools, parameter form, frames ---- */
.cards.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field.short { flex: 0 0 110px; }
.btn.small { padding: 7px 12px; font-size: 0.82rem; margin-top: 0; }
.hetero { margin: 10px 0 4px; font-size: 0.88rem; color: var(--ink-soft); }
.hetero b { color: var(--navy); }
.table .chk { width: 26px; }
.edit-current { display: flex; flex-wrap: wrap; gap: 2px 4px; margin: 6px 0 10px; min-height: 1.2rem; }
.edit-res { display: inline-flex; flex-direction: column; align-items: center; font-family: var(--mono); line-height: 1.1; }
.edit-res b { font-size: 0.95rem; }
.edit-res small { font-size: 0.62rem; color: var(--muted); }
.details { padding: 0; }
.details > summary { list-style: none; cursor: pointer; padding: 18px 22px; display: flex; align-items: baseline; justify-content: space-between; gap: 14px; }
.details > summary::-webkit-details-marker { display: none; }
.details > summary h2 { margin: 0; }
.details > summary::after { content: "+"; font-family: var(--mono); color: var(--brick); font-size: 1.1rem; }
.details[open] > summary::after { content: "−"; }
.details > *:not(summary) { padding: 0 22px 20px; }
.details .diagnostics, .details .gates { margin-top: 6px; }

.viewer-tools { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; font-size: 0.8rem; }
.viewer-tools select, .viewer-tools input[type="text"] { padding: 5px 8px; font-size: 0.8rem; border-radius: 8px; width: auto; }
.viewer-tools input[type="text"] { width: 96px; font-family: var(--mono); }
.viewer-tools label { display: flex; align-items: center; gap: 4px; color: var(--muted); }
.viewer-tools .tool-btn { font: inherit; font-size: 0.78rem; padding: 5px 9px; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--navy); cursor: pointer; }
.viewer-tools .tool-btn.is-on { background: var(--navy); color: #fff; border-color: var(--navy); }
.viewer-tools .sep { width: 1px; height: 18px; background: var(--line); margin: 0 2px; }
.frames { display: flex; align-items: center; gap: 10px; background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; }
.frames input[type="range"] { flex: 1; }

.simtype { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin: 10px 0; font-size: 0.88rem; }
.simtype b { font-family: var(--mono); color: var(--brick); }
.parameters fieldset { border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px 12px; margin: 10px 0; background: #fff; }
.parameters legend { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); padding: 0 6px; font-weight: 600; }
.parameters .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.parameters .param { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.parameters .param > span { font-size: 0.78rem; font-weight: 600; color: var(--ink-soft); display: flex; justify-content: space-between; gap: 6px; }
.parameters .param > span code { font-family: var(--mono); font-weight: 400; color: var(--muted); font-size: 0.7rem; }
.parameters .param input, .parameters .param select { padding: 6px 8px; font-size: 0.85rem; border-radius: 8px; }
.parameters .param.is-changed input, .parameters .param.is-changed select { border-color: var(--gold); background: #fffbf0; }
.parameters .param small { font-size: 0.72rem; color: var(--muted); line-height: 1.3; }
.parameters .param[data-advanced="true"] { display: none; }
.parameters.show-advanced .param[data-advanced="true"] { display: flex; }
.parameters fieldset[data-empty="true"] { display: none; }
.cite a { color: var(--brick); }

/* ---- batch ---- */
.card.batch { margin-top: 18px; border-color: #e6c9c9; }
.batch-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.table tr.is-selected td { background: #fff3e0; }
.table tr.is-clickable { cursor: pointer; }
.table tr.is-clickable:hover td { background: #fff8ea; }
.status-pill { display: inline-block; font-family: var(--mono); font-size: 0.7rem; padding: 2px 8px; border-radius: 999px; background: #eee; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.06em; }
.status-pill[data-status="done"] { background: #dff2e6; color: var(--ok); }
.status-pill[data-status="failed"] { background: #f9dcdc; color: var(--err); }
.status-pill[data-status="stopped"] { background: #eee4d6; color: #6b4a1f; }
.status-pill[data-status="running"], .status-pill[data-status="preparing"] { background: #fff1d6; color: #8a5a00; }
.status-pill[data-status="prepared"] { background: #e6eef9; color: var(--info); }

/* ---- credits, chart actions, tall charts ---- */
.credits { font-size: 0.72rem; color: #d4b3b3; line-height: 1.45; display: flex; flex-direction: column; gap: 8px; border-top: 1px solid rgba(255,255,255,0.12); padding-top: 12px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.chart-actions { display: inline-flex; gap: 6px; }
tr.left-out td { color: var(--muted); }
tr.left-out td.seq, tr.left-out td.mono { text-decoration: line-through; text-decoration-color: #e7b6b2; }
.series-picker { display: flex; flex-direction: column; gap: 6px; margin: 8px 0 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chips .fine { margin: 0 4px 0 0; font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.08em; }
.chip { font: inherit; font-size: 0.78rem; line-height: 1.2; padding: 4px 10px 4px 8px; border-radius: 999px; border: 1px solid var(--line); background: #fff; color: var(--ink-soft); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.chip::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--swatch, transparent); border: 1px solid var(--swatch, var(--line)); opacity: 0.3; }
.chip:hover { border-color: var(--swatch, var(--navy-soft)); }
.chip[aria-pressed="true"] { border-color: var(--swatch, var(--navy)); color: var(--navy); background: #fff8ec; }
.chip[aria-pressed="true"]::before { opacity: 1; }
.chip.plain::before { display: none; }
.chip.mode[aria-pressed="true"] { background: var(--navy); color: #fff; border-color: var(--navy); }
.chart-actions .tool-btn { font: inherit; font-size: 0.74rem; padding: 4px 8px; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--navy); cursor: pointer; }
.chart.tall { height: 320px; }
.chart .pt { stroke: none; }

/* ---- the region builder on the Run page ---- */
.regions { border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px 12px; margin: 10px 0; background: #fff; min-width: 0; }
.regions legend { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); padding: 0 6px; font-weight: 600; }
.regions { container-type: inline-size; }
.region-grid { display: grid; grid-template-columns: minmax(320px, 1.2fr) minmax(0, 0.8fr); gap: 14px; align-items: start; margin-top: 8px; }
/* The card sits in the Run page's form column, about 550 px wide beside the engine output; below 820 px the residue table and the widths go under the view, where a row fits on one line. */
@container (max-width: 820px) { .region-grid { grid-template-columns: 1fr; } }
.region-view, .region-side { min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.regions .viewer-col, .edit-dialog .viewer-col { position: static; }
.viewer.region { height: 380px; }
.region-actions { margin: 0; }
.region-count { margin: 0; }
.region-table td, .region-table th { padding: 5px 6px; font-size: 0.85rem; }
.region-table td.acts { text-align: right; }
.region-table td.acts .tool-btn { font: inherit; font-size: 0.74rem; padding: 3px 7px; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--navy); cursor: pointer; margin-left: 4px; }
.region-table td.acts .tool-btn.is-on { background: var(--navy); color: #fff; border-color: var(--navy); }
.region-table .swatch { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--swatch, var(--line)); margin-right: 6px; vertical-align: middle; }
.region-widths { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.region-widths .param { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.region-widths .param > span { font-size: 0.74rem; font-weight: 600; color: var(--ink-soft); display: flex; justify-content: space-between; gap: 6px; }
.region-widths .param > span code { font-family: var(--mono); font-weight: 400; color: var(--muted); font-size: 0.68rem; }
.region-widths .param input { padding: 5px 8px; font-size: 0.82rem; border-radius: 8px; }
@media (max-width: 1100px) { .region-grid { grid-template-columns: 1fr; } }
@container (max-width: 400px) { .region-widths { grid-template-columns: 1fr; } }

/* ---- the window a part of the structure is changed in ---- */
.edit-dialog { width: min(1180px, 94vw); max-width: none; border: 1px solid var(--line); border-radius: var(--radius); padding: 0; background: var(--parchment); color: var(--ink); box-shadow: 0 24px 64px rgba(0, 0, 0, 0.35); }
.edit-dialog::backdrop { background: rgba(69, 0, 0, 0.35); }
.edit-dialog-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px 22px 10px; }
.edit-dialog-head h2 { margin: 0; }
.edit-dialog-body { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(300px, 0.85fr); gap: 18px; padding: 0 22px 22px; align-items: start; }
.edit-dialog-view { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.edit-dialog-view .viewer { height: 480px; }
.edit-dialog-form { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; min-width: 0; }
@media (max-width: 1100px) { .edit-dialog-body { grid-template-columns: 1fr; } .edit-dialog-view .viewer { height: 360px; } }

/* ---- sessions, the queue, and two runs side by side ---- */
.session-rail { padding: 6px 18px 4px; }
.session-rail .rail-actions { display: flex; gap: 8px; }
.session-rail .btn { flex: 1 1 0; min-width: 0; white-space: nowrap; }
.session-rail .btn:disabled { background: transparent; color: rgba(255, 255, 255, 0.45); border-color: rgba(255, 255, 255, 0.25); }
.session-rail .btn.quiet { background: transparent; color: rgba(255, 255, 255, 0.85); border-color: rgba(255, 255, 255, 0.35); }
.session-rail .btn.quiet:hover { background: rgba(255, 255, 255, 0.12); }
.session-note { font-size: 0.72rem; color: rgba(255, 255, 255, 0.65); margin-top: 6px; min-height: 1em; }
.name-dialog { width: min(520px, 92vw); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 22px; background: var(--parchment); color: var(--ink); }
.name-dialog::backdrop { background: rgba(69, 0, 0, 0.35); }
.name-dialog h2 { margin-top: 0; }
.queue-bar { height: 6px; border-radius: 3px; background: #ececec; overflow: hidden; min-width: 90px; margin-top: 4px; }
.queue-bar > div { height: 100%; background: var(--navy); width: 0; transition: width 0.3s; }
.queue-bar.indeterminate > div { width: 30%; animation: queue-slide 1.2s linear infinite; }
@keyframes queue-slide { from { margin-left: -30%; } to { margin-left: 100%; } }
.table td.queue-status { min-width: 150px; }
.table .queue-message { font-size: 0.74rem; color: var(--muted); display: block; }
.table .queue-took { font-size: 0.74rem; color: var(--muted); display: block; margin-top: 2px; }
.table .queue-took .btn { margin-left: 6px; }
.log-tab.is-history { font-style: italic; }
#und-cmp { container-type: inline-size; }
.cmp-viewers { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 10px; }
.cmp-viewers .viewer-col { position: static; }
.viewer.cmp { height: 320px; }
@container (max-width: 700px) { .cmp-viewers { grid-template-columns: 1fr; } }
.table td.cmp-a { color: #1f4e79; } .table td.cmp-b { color: #b5451b; }
#example-status { display: inline-block; max-width: 100%; }
.table td.queue-start { min-width: 190px; }
.log-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 6px; }
.log-tab { font: inherit; font-size: 0.78rem; padding: 3px 10px; border: 1px solid #d8d3cc; border-radius: 999px; background: #fff; color: #333; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.log-tab.is-selected { border-color: var(--navy); background: var(--navy); color: #fff; }
.log-tab i { width: 8px; height: 8px; border-radius: 50%; background: #bbb; display: inline-block; }
.log-tab i.s-loading { background: #d9a400; } .log-tab i.s-ready { background: #8a8a8a; } .log-tab i.s-running { background: #2f6f9f; animation: pulse 1.2s infinite; } .log-tab i.s-done { background: #3b8f5a; } .log-tab i.s-failed { background: #a8434f; }
.note { color: #4a4a4a; } .note.is-warning { color: #8a3b00; }
.cmp-legend { display: flex; flex-wrap: wrap; gap: 4px 18px; margin: 4px 0 6px; font-size: 0.78rem; color: #4a4a4a; }
.cmp-key { display: inline-flex; align-items: center; gap: 6px; }
.cmp-key i { display: inline-block; width: 14px; height: 10px; border-radius: 2px; flex: none; }
.queue-swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: 0; background: var(--navy); }
.queue-swatch.s1 { background: #2f6f9f; } .queue-swatch.s2 { background: #3b8f5a; } .queue-swatch.s3 { background: #b8792a; } .queue-swatch.s4 { background: #7b5ea7; } .queue-swatch.s5 { background: #a8434f; }
.queue-from { font: inherit; font-size: 0.8rem; padding: 4px 6px; border: 1px solid #d8d3cc; border-radius: 6px; background: #fff; color: inherit; max-width: 100%; }
.table td.actions-cell { white-space: nowrap; }
.table td.actions-cell .btn { margin-right: 4px; }

/* ---- the tours: the coach panel beside the page, the target it points at, the closing summary ---- */
.demo-summary { border-left: 4px solid var(--navy); }
.demo-summary p { margin: 6px 0; }
.demo-summary .num { font-family: var(--mono); }

/* ---- the comparison's charts: read at a glance ---- */
.cmp-charts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin: 10px 0; }
.cmp-chart-card { border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px 8px; background: #fff; min-width: 0; }
.cmp-chart-card.wide { grid-column: 1 / -1; }
.cmp-chart-card .card-head { margin-bottom: 4px; }
.cmp-chart-card h3 { margin: 0; font-size: 0.95rem; }
.chart.cmp { height: 260px; }
.chart.cmp.tall { height: 360px; }
.chart.cmp text { font-family: var(--sans); font-size: 12px; fill: var(--ink-soft); }
@container (max-width: 720px) { .cmp-charts { grid-template-columns: 1fr; } }
#cmp-structures { margin-top: 12px; }
#cmp-structures h3 { margin: 0 0 4px; font-size: 1rem; }
.table td.sub { background: #fff3e0; }

.tours { display: flex; flex-direction: column; gap: 8px; margin: 8px 0; }
.tour-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.tour-row b { display: block; }
.tour-row span { display: block; font-size: 0.88rem; color: var(--ink-soft); }
.tour-row small { display: block; font-size: 0.74rem; color: var(--muted); margin-top: 2px; }
.coach { position: fixed; right: 24px; bottom: 24px; width: min(440px, calc(100vw - 48px)); z-index: 60; background: #fff; color: var(--ink); border: 1px solid var(--line); border-left: 6px solid var(--navy); border-radius: 14px; box-shadow: 0 18px 48px rgba(69, 0, 0, 0.22); padding: 14px 18px 12px; animation: coach-in 0.35s ease-out; }
.coach-head { display: flex; justify-content: space-between; gap: 10px; font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.coach-title { margin: 6px 0 4px; font-size: 1.05rem; color: var(--navy); }
.coach-text { font-size: 0.95rem; line-height: 1.45; max-height: 40vh; overflow: auto; }
.coach-text p { margin: 6px 0; }
.coach-text .num { font-family: var(--mono); }
.coach-cite { margin: 6px 0 0; font-size: 0.8rem; color: var(--ink-soft); font-style: italic; }
.coach-progress { height: 4px; border-radius: 2px; background: #efe7d8; margin: 10px 0 8px; overflow: hidden; }
.coach-progress > div { height: 100%; width: 0; background: var(--navy); transition: width 0.25s linear; }
.coach-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.coach.is-working .coach-progress > div { width: 30%; animation: queue-slide 1.2s linear infinite; }
@keyframes coach-in { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
.coach-target { outline: 3px solid var(--navy); outline-offset: 4px; border-radius: 12px; box-shadow: 0 0 0 8px rgba(69, 0, 0, 0.12); transition: box-shadow 0.4s ease, outline-color 0.4s ease; animation: coach-pulse 1.6s ease-in-out 2; }
@keyframes coach-pulse { 0%, 100% { box-shadow: 0 0 0 8px rgba(69, 0, 0, 0.12); } 50% { box-shadow: 0 0 0 14px rgba(69, 0, 0, 0.04); } }
@media (prefers-reduced-motion: reduce) { .coach { animation: none; } .coach-target { animation: none; } }
@media (max-width: 900px) { .coach { right: 8px; left: 8px; bottom: 8px; width: auto; } }
.compat { margin: 0 0 16px; padding: 12px 16px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--paper); font-size: 0.92rem; line-height: 1.45; }
.compat.is-blocking { background: var(--err); color: #fff; border-color: var(--err); }

/* Full size: an icon in the top-right corner of every 3D view and chart. */
.fig-expand { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; padding: 0; border-radius: 8px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.95); color: var(--navy); cursor: pointer; flex: 0 0 auto; }
.fig-expand:hover, .fig-expand:focus-visible { background: var(--navy); color: #fff; border-color: var(--navy); }
.viewer > .fig-expand { position: absolute; top: 8px; right: 8px; z-index: 7; box-shadow: 0 1px 4px rgba(69, 0, 0, 0.15); }
.card-head { gap: 8px; }
.chart-actions { flex-wrap: wrap; justify-content: flex-end; }
.is-expanded { padding-top: 56px; }
.is-expanded .chart { flex: 1 1 auto; height: auto !important; min-height: 240px; }
.cmp-chart-card.is-expanded, .card.is-expanded { overflow: auto; }
.viewer:focus { outline: none; }
.viewer:focus-visible { outline: 2px solid var(--navy); outline-offset: 2px; }
.viewer-tools .tool-hint { color: var(--muted); font-size: 0.74rem; flex: 1 1 220px; min-width: 0; }
.viewer.is-box-selecting canvas { cursor: crosshair; }
.box-select { position: absolute; z-index: 6; border: 2px dashed var(--navy); background: rgba(217, 164, 65, 0.18); pointer-events: none; }
.box-select.is-removing { border-color: var(--err); background: rgba(185, 74, 72, 0.15); }

/* Work in progress on a page: a bar and a line saying what is being done. */
.task-progress { display: flex; align-items: center; gap: 10px; margin: 8px 0; font-size: 0.85rem; color: var(--ink-soft); }
.task-progress[hidden] { display: none; }
.task-progress .bar { flex: 0 0 160px; height: 6px; border-radius: 3px; background: #efe7d8; overflow: hidden; }
.task-progress .bar > i { display: block; height: 100%; width: 0; background: var(--navy); transition: width 0.2s linear; }
.task-progress.is-indeterminate .bar > i { width: 30%; animation: queue-slide 1.2s linear infinite; }
.viewer > .task-progress { position: absolute; left: 12px; right: 12px; top: 46%; z-index: 6; justify-content: center; margin: 0; padding: 10px 14px; background: rgba(255, 250, 241, 0.94); border: 1px solid var(--line); border-radius: 10px; }

/* The trajectory controls: a Play button that reads as one. */
.frames .play-btn { min-width: 92px; font-weight: 700; display: inline-flex; align-items: center; gap: 6px; justify-content: center; }
.frames .play-btn svg { flex: 0 0 auto; }
.frames .frame-count { font-family: var(--mono); font-size: 0.82rem; white-space: nowrap; }
.frames select { width: auto; padding: 4px 6px; font-size: 0.8rem; }

/* The region builder's ways to pick many residues at once. */
.region-pick { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 8px 0 0; }
.region-pick input[type="text"] { flex: 1 1 180px; min-width: 120px; font-family: var(--mono); padding: 5px 8px; font-size: 0.85rem; }
.region-pick select { width: auto; padding: 5px 8px; font-size: 0.85rem; }
.region-pick .tool-btn.is-on { background: var(--navy); color: #fff; border-color: var(--navy); }
.region-pick .fine { flex: 1 1 100%; margin: 0; }
.region-widths .param[hidden] { display: none; }
.region-pick .sep { width: 1px; height: 18px; background: var(--line); margin: 0 2px; }
.region-pick .btn.is-on { background: var(--navy); color: #fff; border-color: var(--navy); }
.viewer-col.is-expanded, .regions .viewer-col.is-expanded, .edit-dialog .viewer-col.is-expanded, .cmp-viewers .viewer-col.is-expanded { position: fixed; inset: 16px; }
.viewer-col.is-expanded > .log-head, .viewer-col.is-expanded > .log-wrap { display: none; }
#und-frames { flex-wrap: wrap; }
#und-frames .frames-thin { flex: 1 1 100%; margin: 0; order: 10; }
#und-frames #frames-all { order: 11; }
.viewer-col.is-expanded .viewer { flex: 1 0 auto; min-height: max(320px, calc(100vh - 220px)); }

/* ---- the structure editor: contents on the left, the view in the middle,
   the selection, its actions, the history and the checks on the right ---- */
.ed-dialog { width: min(1560px, 97vw); height: min(940px, 94vh); max-width: none; max-height: none; border: 1px solid var(--line); border-radius: 12px; padding: 0; background: #faf7f0; color: var(--ink); box-shadow: 0 28px 80px rgba(0, 0, 0, 0.38); overflow: hidden; font-size: 13.5px; }
.ed-dialog[open] { display: flex; flex-direction: column; }
.ed-dialog::backdrop { background: rgba(43, 0, 0, 0.42); }
.ed-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 14px 10px 18px; background: #fff; border-bottom: 1px solid var(--line); flex: 0 0 auto; }
.ed-title { display: flex; align-items: baseline; gap: 12px; min-width: 0; }
.ed-title h2 { margin: 0; font-size: 1.05rem; color: var(--navy); }
.ed-file { font-family: var(--mono); font-size: 0.78rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ed-head-tools { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.ed-head-tools .btn { margin: 0 0 0 6px; }
.ed-sep { width: 1px; height: 22px; background: var(--line); margin: 0 6px; }
.ed-status { font-size: 0.8rem; color: var(--muted); max-width: 360px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ed-status.is-working::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--gold); margin-right: 6px; animation: ed-pulse 1.1s ease-in-out infinite; }
.ed-status.is-bad { color: var(--err); }
@keyframes ed-pulse { 0%, 100% { opacity: 0.35; } 50% { opacity: 1; } }

.ed-btn { font: inherit; font-size: 0.82rem; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 11px; border-radius: 7px; border: 1px solid #d9d2c2; background: #fff; color: var(--navy); cursor: pointer; white-space: nowrap; }
.ed-btn:hover:not(:disabled) { background: #fbf6ec; border-color: #c9bfa9; }
.ed-btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }
.ed-btn:disabled { opacity: 0.42; cursor: default; }
.ed-btn.primary { background: var(--brick); border-color: var(--brick); color: #fff; }
.ed-btn.primary:hover:not(:disabled) { background: var(--brick-deep); }
.ed-btn.danger { color: var(--err); border-color: #e7c2bf; }
.ed-btn.danger:hover:not(:disabled) { background: #fdf1f0; border-color: var(--err); }
.ed-btn.small { height: 26px; padding: 0 9px; font-size: 0.76rem; }

.ed-body { flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: 250px minmax(0, 1fr) 360px; }
.ed-tree, .ed-inspector { background: #fff; overflow-y: auto; min-height: 0; }
.ed-tree { border-right: 1px solid var(--line); padding: 4px 0 12px; }
.ed-inspector { border-left: 1px solid var(--line); padding: 0 0 16px; }
.ed-pane-head { font-size: 0.68rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); padding: 12px 14px 6px; display: flex; align-items: center; gap: 8px; }
.ed-count { font-family: var(--mono); font-size: 0.7rem; color: var(--ink-soft); background: #f1ece1; border-radius: 999px; padding: 0 7px; letter-spacing: 0; font-weight: 600; }
.ed-empty { color: var(--muted); font-size: 0.8rem; padding: 2px 14px; margin: 0; list-style: none; }

.ed-chain { border-left: 3px solid transparent; }
.ed-chain.is-selected { border-left-color: var(--brick); background: #fcf6ef; }
.ed-chain-head { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto 26px; align-items: center; gap: 2px; padding: 2px 8px 2px 6px; min-height: 32px; }
.ed-chain-head:hover { background: #faf5ec; }
.ed-twisty { font: inherit; width: 22px; height: 22px; border: 0; background: none; color: var(--muted); cursor: pointer; border-radius: 4px; font-size: 0.75rem; }
.ed-twisty:hover { background: #efe8da; color: var(--navy); }
.ed-chain-name { font: inherit; display: flex; align-items: baseline; gap: 8px; border: 0; background: none; text-align: left; cursor: pointer; padding: 4px 2px; min-width: 0; color: var(--ink); }
.ed-chain-name b { font-family: var(--mono); font-size: 0.9rem; color: var(--navy); min-width: 14px; }
.ed-chain-name span { font-size: 0.7rem; letter-spacing: 0.06em; color: var(--ink-soft); }
.ed-chain-count { font-family: var(--mono); font-size: 0.75rem; color: var(--muted); display: inline-flex; align-items: center; gap: 5px; }
.ed-flag { font-style: normal; font-family: var(--mono); font-size: 0.66rem; font-weight: 700; color: #6b4300; background: #fbe3b4; border-radius: 999px; padding: 0 6px; }
.ed-icon { width: 24px; height: 24px; display: inline-grid; place-items: center; border: 1px solid transparent; border-radius: 6px; background: none; color: var(--muted); cursor: pointer; opacity: 0; }
.ed-chain-head:hover .ed-icon, .ed-icon:focus-visible { opacity: 1; }
.ed-icon.danger:hover:not(:disabled) { color: var(--err); border-color: #e7c2bf; background: #fdf1f0; }
.ed-icon:disabled { display: none; }
.ed-strip { display: flex; flex-wrap: wrap; gap: 2px; padding: 4px 10px 10px 30px; max-height: 260px; overflow-y: auto; }
.ed-res { font-family: var(--mono); font-size: 0.68rem; line-height: 1; min-width: 17px; height: 19px; padding: 0 3px; border: 1px solid #e8e1d2; border-radius: 3px; background: #fff; color: var(--ink-soft); cursor: pointer; }
.ed-res:hover { border-color: var(--navy-soft); color: var(--navy); }
.ed-res.is-het { color: var(--muted); background: #f6f3ec; font-size: 0.6rem; }
.ed-res.is-mod { background: #fbe3b4; border-color: #e3b65c; color: #5a3a00; font-weight: 700; font-size: 0.6rem; }
.ed-res.is-on { background: var(--brick); border-color: var(--brick); color: #fff; }

.ed-components { padding: 0 8px; display: flex; flex-direction: column; gap: 2px; }
.ed-comp { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 6px; border-radius: 6px; font-size: 0.8rem; }
.ed-comp:hover { background: #faf5ec; }
.ed-comp b { font-family: var(--mono); color: var(--navy); }
.ed-comp span { color: var(--ink-soft); min-width: 0; }

.ed-stage { display: flex; flex-direction: column; gap: 8px; padding: 10px 12px; min-width: 0; min-height: 0; background: #f4efe4; }
.ed-dialog .viewer-col { position: static; }
.ed-dialog .viewer-col.is-expanded { position: fixed; inset: 16px; }
.ed-stage .viewer { flex: 1 1 auto; height: auto; min-height: 280px; border-radius: 8px; box-shadow: none; }
.ed-stage .viewer-tools { border-radius: 8px; padding: 6px 8px; gap: 5px; }
.ed-stage .viewer-tools .tool-hint,
.ed-stage .viewer-tools label:has([data-tool="quality"]), .ed-stage .viewer-tools [data-tool="record"],
.ed-stage .viewer-tools label:has([data-tool="dpi"]), .ed-stage .viewer-tools [data-tool="png"],
.ed-stage .viewer-tools label:has([data-tool="labelsize"]), .ed-stage .viewer-tools [data-tool="expand"],
.ed-stage .viewer-tools label:has([data-tool="scroll"]), .ed-stage .viewer-tools [data-tool="spin"] { display: none; }
.ed-stage-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.ed-seg { display: inline-flex; align-items: center; gap: 0; font-size: 0.78rem; }
.ed-seg > span { color: var(--muted); margin-right: 8px; }
.ed-seg-btn { font: inherit; font-size: 0.78rem; height: 26px; padding: 0 11px; border: 1px solid #d9d2c2; background: #fff; color: var(--ink-soft); cursor: pointer; margin-left: -1px; }
.ed-seg-btn:first-of-type { border-radius: 6px 0 0 6px; margin-left: 0; }
.ed-seg-btn:last-of-type { border-radius: 0 6px 6px 0; }
.ed-seg-btn[aria-pressed="true"] { background: var(--navy); border-color: var(--navy); color: #fff; position: relative; }
.ed-stage .viewer-caption { font-size: 0.76rem; }

.ed-section { border-bottom: 1px solid #efe9dc; padding: 0 0 12px; }
.ed-section > *:not(.ed-pane-head) { margin-left: 14px; margin-right: 14px; }
.ed-more > summary { cursor: pointer; list-style: none; }
.ed-more > summary::-webkit-details-marker { display: none; }
.ed-more > summary::after { content: "+"; margin-left: auto; font-family: var(--mono); font-size: 0.9rem; color: var(--brick); }
.ed-more[open] > summary::after { content: "−"; }
.ed-more:not([open]) { padding-bottom: 0; }
.ed-selrow { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 8px; }
.ed-field { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.ed-field.wide { margin-top: 6px; }
.ed-field > span { font-size: 0.7rem; font-weight: 600; color: var(--ink-soft); }
.ed-field input, .ed-field select { padding: 5px 8px; font-size: 0.82rem; border-radius: 7px; height: 30px; }
.ed-selection { margin: 10px 14px 8px; font-size: 0.85rem; color: var(--ink); min-height: 1.3em; }
.ed-selection b { font-family: var(--mono); font-weight: 600; color: var(--navy); }
.ed-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.ed-consequence { margin: 8px 14px 0; font-size: 0.78rem; color: var(--ink-soft); min-height: 1em; }
.ed-consequence:empty { display: none; }
.ed-note { font-size: 0.8rem; color: var(--ink-soft); margin: 0 0 8px; }
.ed-inspector .edit-current { margin: 4px 14px 6px; }
.ed-inspector .hint { margin: 6px 14px; }
.ed-inspector .fine { font-size: 0.74rem; margin-top: 8px; }

.ed-history { list-style: none; margin: 0; padding: 0 8px 0 10px; display: flex; flex-direction: column; gap: 2px; counter-reset: none; }
.ed-hist { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 6px; padding: 6px 4px; border-radius: 6px; font-size: 0.8rem; }
.ed-hist:last-of-type:not(.is-undone) { background: #fcf6ef; }
.ed-hist-n { font-family: var(--mono); font-size: 0.72rem; color: #fff; background: var(--navy-soft); border-radius: 50%; width: 20px; height: 20px; display: grid; place-items: center; }
.ed-hist b { font-weight: 600; display: block; color: var(--ink); }
.ed-hist small { display: block; color: var(--ink-soft); font-size: 0.74rem; line-height: 1.35; margin-top: 2px; }
.ed-hist.is-undone { opacity: 0.55; }
.ed-hist.is-undone .ed-hist-n { background: #b9b2a3; }

.ed-checks { list-style: none; margin: 0; padding: 0 14px; display: flex; flex-direction: column; gap: 4px; }
.ed-checks li { display: grid; grid-template-columns: 8px minmax(0, 1fr); gap: 8px; align-items: baseline; font-size: 0.8rem; color: var(--ink-soft); }
.ed-checks i { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); transform: translateY(1px); }
.ed-checks li[data-severity="ok"] i { background: var(--ok); }
.ed-checks li[data-severity="info"] i { background: var(--info); }
.ed-checks li[data-severity="warning"] i { background: var(--warn); }
.ed-checks li[data-severity="error"] i { background: var(--err); }

/* the modified residues a force field has no template for: each with its two choices */
.mod-panel { margin: 10px 0 6px; display: flex; flex-direction: column; gap: 10px; }
.mod-row { border: 1px solid #ead9b5; background: #fffaf0; border-radius: 10px; padding: 10px 12px; }
.ed-inspector .mod-row { padding: 8px 10px; }
.mod-head { font-size: 0.92rem; color: var(--ink); display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px; }
.mod-head b { font-family: var(--mono); color: #6b4300; }
.mod-tag { font-size: 0.7rem; font-weight: 600; letter-spacing: 0.04em; color: #8a3b00; background: #fbe3b4; border-radius: 999px; padding: 1px 8px; }
.mod-why { margin: 4px 0 6px; font-size: 0.84rem; color: var(--ink-soft); }
.mod-choice { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 10px; align-items: start; padding: 6px 0; border-top: 1px dashed #ecdcbc; }
.mod-choice:first-of-type { border-top: 0; }
.mod-choice .btn { margin: 0; white-space: nowrap; }
.mod-choice p { margin: 0; font-size: 0.8rem; color: var(--ink-soft); line-height: 1.4; }
.mod-choice.is-off .mod-no { font-size: 0.78rem; color: var(--muted); padding: 6px 0; }
.ed-inspector .mod-choice { grid-template-columns: 1fr; gap: 4px; }
.ed-inspector .mod-choice .btn { justify-self: start; }
.mod-all { display: flex; justify-content: flex-end; }
.ed-summary { margin: 8px 0 0; padding-left: 20px; font-size: 0.84rem; color: var(--ink-soft); }
.ed-summary li { margin: 2px 0; }

@media (max-width: 1180px) {
  .ed-body { grid-template-columns: 220px minmax(0, 1fr); }
  .ed-inspector { grid-column: 1 / -1; border-left: 0; border-top: 1px solid var(--line); max-height: 42vh; }
}
@media (max-width: 760px) {
  .ed-body { grid-template-columns: 1fr; overflow-y: auto; }
  .ed-tree { max-height: 30vh; border-right: 0; border-bottom: 1px solid var(--line); }
  .ed-stage .viewer { min-height: 320px; }
}
@media (prefers-reduced-motion: reduce) { .ed-status.is-working::before { animation: none; } }
