:root {
  --bg: #f5f6f4;
  --card: #ffffff;
  --text: #1f2421;
  --muted: #646b66;
  --border: #d9ddd9;
  --accent: #1f6fb2;
  --ok: #2e7d32;
  --error: #b3261e;
  --log-bg: #f0f1ef;
  --grid: #e1e0d9;
  --axis: #898781;
  /* categorical series colours (validated reference palette, light) */
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  --s5: #e87ba4; --s6: #008300; --s7: #6250d6; --s8: #e34948;
  /* sequential blue ramp for lines of a varied number, low to high (steps 250-700 of the reference palette) */
  --ramp: #86b6ef,#6da7ec,#5598e7,#3987e5,#2a78d6,#256abf,#1c5cab,#184f95,#104281,#0d366b;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161a18;
    --card: #1f2421;
    --text: #e6e9e7;
    --muted: #9aa29d;
    --border: #353b37;
    --accent: #6aaee8;
    --ok: #7bc47f;
    --error: #f28b82;
    --log-bg: #121513;
    --grid: #2c2c2a;
    --axis: #898781;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
    --s5: #d55181; --s6: #0ca30c; --s7: #9085e9; --s8: #e66767;
    /* on dark: low = dim, high = bright (steps 600-100) */
    --ramp: #184f95,#1c5cab,#256abf,#2a78d6,#3987e5,#5598e7,#6da7ec,#86b6ef,#9ec5f4,#b7d3f6,#cde2fb;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}
header, main { max-width: 900px; margin: 0 auto; padding: 0 16px; }
header { padding-top: 20px; }
/* logo bar: white in both themes (corporate design), University of Bonn always at the right */
.logos {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 14px; padding: 10px 14px; background: #fff; border: 1px solid var(--border); border-radius: 8px;
}
.logos img { display: block; width: auto; min-width: 0; object-fit: contain; }
.logo-simplace { height: 46px; max-width: 40%; }
.logo-crop { height: 42px; max-width: 22%; }
.logo-uni { height: 34px; max-width: 34%; }
@media (max-width: 480px) {
  .logos { padding: 8px 10px; gap: 8px; }
  .logo-simplace { height: 32px; }
  .logo-crop { height: 30px; }
  .logo-uni { height: 24px; }
}
h1 { margin: 0; font-size: 1.5rem; }
h1 span { font-weight: 400; color: var(--muted); }
h2 { margin: 0 0 12px; font-size: 1.1rem; display: flex; align-items: center; gap: 8px; }
h3 { margin: 16px 0 6px; font-size: 1rem; }
.step {
  display: inline-grid; place-items: center;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: 0.8rem;
}
.muted { color: var(--muted); }
.small { font-size: 0.85rem; margin: 4px 0; }
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  margin: 16px 0;
}
label { display: block; margin: 12px 0 4px; font-weight: 600; }
label.inline { display: inline-flex; align-items: center; gap: 6px; margin: 4px 16px 4px 0; font-weight: 400; }
input, textarea, select {
  width: 100%;
  min-height: 40px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
input[type=radio], input[type=checkbox] { width: auto; min-height: 0; }
input:disabled, select:disabled { opacity: 0.55; }
input:invalid { border-color: var(--error); }
textarea { font-family: ui-monospace, Consolas, monospace; }
fieldset.modes { border: 0; padding: 0; margin: 12px 0 0; }
fieldset.modes legend { font-weight: 600; padding: 0; margin-bottom: 4px; }
button {
  margin-top: 16px;
  min-height: 40px;
  padding: 9px 18px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
button.secondary { background: transparent; color: var(--accent); border: 1px solid var(--border); }
button.head-button { margin: 0 0 0 auto; padding: 6px 14px; font-size: 0.9rem; }
button:disabled { opacity: 0.5; cursor: default; }
.error { color: var(--error); white-space: pre-wrap; }
/* public web client: another browser runs a simulation */
.busy { border-left: 3px solid var(--accent); padding: 0.4rem 0.6rem; background: var(--log-bg); }
details { margin-top: 16px; }
summary { cursor: pointer; font-weight: 600; }

/* parameter form */
#params { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 0 16px; }
.param label { margin-bottom: 2px; }
.param .hint, .sens-row .hint { font-size: 0.8rem; color: var(--muted); margin: 2px 0 0; word-break: break-word; }
.param.changed input, .param.changed select { border-color: var(--accent); }

.param.locked .hint { color: var(--accent); }

/* project table and sensitivity */
#table-box, #sens-box { margin-bottom: 20px; border-bottom: 1px solid var(--border); padding-bottom: 16px; }
#table-box h3, #sens-box h3 { margin-top: 0; }
.table-wrap { overflow-x: auto; margin-top: 12px; }
#project-table { border-collapse: collapse; min-width: 100%; }
#project-table th { text-align: left; font-size: 0.85rem; padding: 4px; white-space: nowrap; }
#project-table td { padding: 3px 4px; vertical-align: middle; }
#project-table td input, #project-table td select { min-width: 88px; }
#project-table td.name input { min-width: 64px; }
#project-table button.remove { margin: 0; min-height: 36px; padding: 4px 8px; }
.buttons { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.buttons button { margin-top: 12px; }
.file-button {
  display: inline-flex; align-items: center; margin: 12px 0 0; min-height: 40px; padding: 9px 18px;
  border: 1px solid var(--border); border-radius: 6px; color: var(--accent); font-weight: 600; cursor: pointer;
}
.file-button input { display: none; }
.sens-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 12px; align-items: end; max-width: 560px; }
.sens-row + .sens-row { margin-top: 8px; }
.sens-row .wide { grid-column: span 3; }

/* solution overview */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
#graph-box .modes { margin-top: 8px; }
.graph-legend { margin: 4px 0 8px; }
.legend-toggle { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-weight: 400; cursor: pointer; min-height: 32px; }
.legend-toggle input { margin: 0; }
.legend-toggle i { width: 12px; height: 12px; border-radius: 2px; display: inline-block; }
#graph-wrap { overflow-x: auto; }
#graph { display: block; font: 12px system-ui, -apple-system, "Segoe UI", sans-serif; }
#graph .col-head { fill: var(--muted); font-weight: 600; }
#graph .node rect { fill: var(--card); stroke-width: 1.5; }
#graph .node .tint { stroke: none; }
#graph .node text { fill: var(--text); }
#graph .node { cursor: pointer; }
#graph .edge path.line { fill: none; stroke: var(--axis); stroke-width: 1.2; opacity: 0.55; }
#graph .edge path.hit { fill: none; stroke: transparent; stroke-width: 12; cursor: pointer; }
#graph .edge.active path.line { stroke: var(--text); opacity: 0.9; stroke-width: 1.8; }
#graph .faded { opacity: 0.18; }
#graph .node.selected rect, #graph .node.selected circle { stroke-width: 3; }
.graph-info { margin-top: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); font-size: 0.9rem; }
.graph-info h4 { margin: 0 0 4px; }
.graph-info ul { margin: 4px 0; padding-left: 18px; }
.graph-info li { word-break: break-word; }
.graph-info .vars { color: var(--muted); font-size: 0.8rem; }

/* run */
.job-head { margin: 16px 0 6px; }
.progress {
  height: 10px;
  border-radius: 5px;
  background: var(--log-bg);
  border: 1px solid var(--border);
  overflow: hidden;
}
#bar { height: 100%; width: 0; background: var(--accent); transition: width 0.4s; }
.DONE #bar { background: var(--ok); }
.FAILED #bar { background: var(--error); }
pre#log {
  margin: 8px 0 0;
  max-height: 360px;
  overflow: auto;
  padding: 8px;
  background: var(--log-bg);
  border-radius: 6px;
  font: 12px/1.4 ui-monospace, Consolas, monospace;
  white-space: pre-wrap;
  word-break: break-word;
}
pre#log .WARN { color: #b26a00; }
pre#log .ERROR, pre#log .FATAL { color: var(--error); }

/* results */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0 16px; }
.checks { display: flex; flex-wrap: wrap; gap: 0 4px; }
.chart { margin-top: 16px; }
.chart h4 { margin: 0 0 4px; font-size: 0.95rem; }
.chart canvas { display: block; touch-action: pan-y; }
.bar-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 6px 0 0 60px; font-size: 0.8rem; }
.bar-legend span { display: inline-flex; align-items: center; gap: 6px; }
.bar-legend i { width: 12px; height: 12px; border-radius: 2px; display: inline-block; }
.scale { display: flex; align-items: center; gap: 8px; margin: 4px 0 0 52px; font-size: 0.8rem; color: var(--muted); }
.scale-bar { flex: 0 1 220px; height: 10px; border-radius: 2px; }
/* layer diagram below a line diagram (shared time axis, as the lapclient) */
.layer { margin-top: 2px; }
.layer-head { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 12px; font-size: 0.8rem; }
.layer-head .scale { margin: 0; flex: 1 1 160px; max-width: 320px; }
.layer .hint { margin: 2px 0 0; }
.layer-frame { position: relative; }
.layer-cursor, .layer-select { position: absolute; display: none; pointer-events: none; }
/* light line with dark edges: visible on every colour of the ramp, in both themes */
.layer-cursor { width: 1px; background: #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.55); }
.layer-select { background: var(--axis); opacity: 0.18; }
.uplot { font-family: inherit; color: var(--text); }
.u-legend { font-size: 0.8rem; color: var(--text); }
.u-legend .u-marker { border-radius: 2px; }
#output-list { margin: 0; padding-left: 20px; max-height: 320px; overflow: auto; }
#output-list li { margin: 2px 0; word-break: break-all; }
a { color: var(--accent); }
