/* ============================================================
   Nari SpeakerKit – Dark Theme
   ============================================================ */

:root {
  /* Farbschema übernommen von nari-dsp-studio/studio (src/index.css) */
  --bg:          #0F1113;   /* theme-bg */
  --bg-2:        #14171A;
  --panel:       #1A1D21;   /* theme-card */
  --panel-2:     #21252B;
  --panel-3:     #2A2F36;
  --line:        #2D3139;   /* theme-border */
  --line-soft:   #23272D;
  --text:        #E5E7EB;
  --text-2:      #9CA3AF;
  --muted:       #6B7280;   /* theme-muted */
  --accent:      #F472B6;   /* theme-accent */
  --accent-dim:  #DB2777;
  --good:        #10B981;   /* theme-success */
  --warn:        #F59E0B;   /* theme-warning */
  --danger:      #EF4444;
  --sum:         #E5E7EB;
  --meas:        #64748B;
  --meassum:     #10B981;

  --radius:   10px;
  --radius-s: 7px;
  --shadow:   0 10px 30px rgba(0,0,0,.5);
  --font:     "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono:     "JetBrains Mono", ui-monospace, "SF Mono", "DejaVu Sans Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
h1,h2,h3 { margin: 0; font-weight: 600; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }

/* ---------- App-Grundraster ---------- */
.app {
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 16px;
  background: linear-gradient(180deg, #1A1D21, #14171A);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 11px; }
/* Das Zeichen sitzt wie in den anderen Nari-Werkzeugen in einer getoenten
   Fassung: Rahmen und Zeichnung in der Signalfarbe, Fuellung dahinter. */
.brand-mark { width: 32px; height: 32px; flex: none; }
.brand-mark .frame { fill: rgba(244,114,182,.14); stroke: rgba(244,114,182,.25); }
.brand-mark g { stroke: var(--accent); }
.brand-text h1 { font-size: 14.5px; letter-spacing: .2px; }
.brand-text p { margin: 1px 0 0; font-size: 11px; color: var(--muted); }

.topbar-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.tool-group {
  display: flex; align-items: center; gap: 6px;
  padding-left: 10px;
  border-left: 1px solid var(--line-soft);
}
.tool-group:first-child { border-left: 0; padding-left: 0; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 30px; padding: 0 11px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  color: var(--text-2);
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s, color .12s, border-color .12s, opacity .12s;
}
.btn:hover:not(:disabled) { background: var(--panel-3); color: var(--text); border-color: #3A404A; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .38; cursor: default; }
.btn.primary { background: var(--accent-dim); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #E24A93; }
.btn.ghost { background: transparent; }
.btn.small { height: 26px; padding: 0 9px; font-size: 12px; }
.btn.icon { width: 30px; padding: 0; }
.btn.icon svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.btn.icon svg .fill { fill: currentColor; stroke: none; }
.btn.danger:hover { color: var(--danger); border-color: #5A2A2A; }

/* ---------- Felder ---------- */
.inline-field { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 11.5px; }
.inline-field .unit { color: var(--muted); font-size: 11px; }
select, input[type="number"], input[type="text"] {
  height: 30px;
  padding: 0 8px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  color: var(--text);
  outline: none;
  min-width: 0;
}
select {
  cursor: pointer;
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  padding-right: 26px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--text-2) 50%),
    linear-gradient(135deg, var(--text-2) 50%, transparent 50%);
  background-position: calc(100% - 14px) calc(50% - 1px), calc(100% - 9px) calc(50% - 1px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
select option { background-color: var(--panel); color: var(--text); }
input[type="number"] { font-family: var(--mono); font-variant-numeric: tabular-nums; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(244,114,182,.18); }
input.num { width: 96px; text-align: right; }
input.num.tiny { width: 72px; height: 26px; }
input.invalid { border-color: var(--danger) !important; box-shadow: 0 0 0 2px rgba(239,68,68,.2) !important; }
/* ============================================================
   Eigene Pfeile an den Zahlenfeldern
   ------------------------------------------------------------
   Die nativen sehen in jedem Browser anders aus, sitzen mal innen
   und mal außen, und umfärben lassen sie sich nicht: sobald man
   ::-webkit-inner-spin-button das Aussehen nimmt, verliert der
   Knopf auch seine Funktion – nachgemessen, er zählt dann nicht
   mehr. Also werden sie ganz abgeschaltet und durch zwei Dreiecke
   ersetzt, gezeichnet wie der Pfeil am Auswahlfeld. Das Zählen
   übernimmt ui.js, damit beide Hälften anklickbar bleiben.
   ============================================================ */
input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; appearance: none; margin: 0; }
input[type=number] {
  -moz-appearance: textfield; appearance: textfield;
  /* Luft zwischen Zahl und Pfeilen: die Pfeile enden 3 px vor dem Rand
     und sind 10 px breit, der Rest ist Abstand zur Zahl. */
  padding-right: 24px;
  --spin-up: var(--muted);
  --spin-dn: var(--muted);
  background-image:
    linear-gradient(135deg, transparent 50%, var(--spin-up) 50%),
    linear-gradient(225deg, transparent 50%, var(--spin-up) 50%),
    linear-gradient(45deg,  transparent 50%, var(--spin-dn) 50%),
    linear-gradient(135deg, var(--spin-dn) 50%, transparent 50%);
  background-position:
    calc(100% - 13px) calc(50% - 5px), calc(100% - 8px) calc(50% - 5px),
    calc(100% - 13px) calc(50% + 2px), calc(100% - 8px) calc(50% + 2px);
  background-size: 5px 4px;
  background-repeat: no-repeat;
}
input[type=number]:hover, input[type=number]:focus { --spin-up: var(--text-2); --spin-dn: var(--text-2); }
/* Gedrückt: nur die Hälfte, die gerade zählt. */
input[type=number][data-spin="up"] { --spin-up: var(--accent); }
input[type=number][data-spin="down"] { --spin-dn: var(--accent); }
input[type=number]:disabled, input[type=number][readonly] { --spin-up: transparent; --spin-dn: transparent; }

.check { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); cursor: pointer; font-size: 12px; user-select: none; }
.check input { accent-color: var(--accent); width: 14px; height: 14px; cursor: pointer; }

/* Switch */
/* position: relative ist hier kein Schoenheitsdetail: ohne positionierten
   Vorfahren bezieht sich das ausgeblendete Kaestchen auf den Seitenanfang.
   Beim Anklicken bekommt es den Fokus, der Browser scrollt es sichtbar – und
   verschiebt dabei das ganze Dokument, obwohl body auf overflow:hidden steht. */
.switch { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; user-select: none; position: relative; }
.switch input { position: absolute; left: 0; top: 0; width: 100%; height: 100%; opacity: 0; margin: 0; pointer-events: none; }
.switch .track {
  position: relative; width: 34px; height: 19px; border-radius: 999px;
  background: #2A2F36; border: 1px solid var(--line); transition: background .15s, border-color .15s;
  flex: none;
}
.switch .knob {
  position: absolute; top: 2px; left: 2px; width: 13px; height: 13px; border-radius: 50%;
  background: #6B7280; transition: transform .15s, background .15s;
}
.switch input:checked + .track { background: rgba(244,114,182,.26); border-color: var(--accent-dim); }
.switch input:checked + .track .knob { transform: translateX(15px); background: var(--accent); }
.switch-label { font-size: 12px; color: var(--text-2); }
.switch.bypass input:checked + .track { background: rgba(245,158,11,.28); border-color: #8A5D0B; }
.switch.bypass input:checked + .track .knob { background: var(--warn); }
.switch.bypass input:checked ~ .switch-label { color: var(--warn); font-weight: 600; }

/* ---------- Workspace ---------- */
.workspace {
  display: grid;
  grid-template-columns: minmax(0,1fr) 372px;
  min-height: 0;
  overflow: hidden;
}

/* ---------- Graph ---------- */
.graph-panel {
  display: flex; flex-direction: column; min-width: 0; min-height: 0;
  background: var(--bg);
  border-right: 1px solid var(--line);
}
.graph-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line-soft);
  flex-wrap: wrap;
}
.tabs { display: inline-flex; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 2px; gap: 2px; }
.tab {
  height: 26px; padding: 0 12px; border: 0; background: transparent; color: var(--muted);
  border-radius: 5px; cursor: pointer; font-size: 12px; transition: background .12s, color .12s;
}
.tab:hover { color: var(--text-2); }
.tab.active { background: var(--panel-3); color: var(--text); }
.graph-opts { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.graph-opts.no-meas .meas-only { display: none; }
.graph-opts .target-only { display: none; }
body.has-target .graph-opts .target-only { display: inline-flex; }

.plots { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 2px; padding: 6px 8px 2px; }
.plot { position: relative; flex: 1; min-height: 0; }
.plot canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.plot-caption {
  position: absolute; top: 6px; left: 60px;
  font-size: 10.5px; letter-spacing: .6px; text-transform: uppercase; color: var(--muted);
  pointer-events: none;
}
.plots.multi .plot-caption { top: 3px; }

.tooltip {
  position: absolute; z-index: 20; pointer-events: none;
  background: rgba(26,29,33,.97);
  border: 1px solid var(--line);
  border-left: 3px solid var(--tip-color, var(--accent));
  border-radius: 6px;
  padding: 7px 9px;
  box-shadow: var(--shadow);
  font-size: 11.5px;
  white-space: nowrap;
}
.tooltip .tt-title { font-weight: 600; margin-bottom: 3px; color: var(--tip-color, var(--accent)); }
.tooltip .tt-row { display: flex; justify-content: space-between; gap: 14px; color: var(--text-2); font-family: var(--mono); }
.tooltip .tt-row b { color: var(--text); font-weight: 500; }

.graph-empty {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(180deg, rgba(15,17,19,.55), rgba(15,17,19,.92));
  z-index: 8;
}
.ge-inner { text-align: center; max-width: 340px; padding: 24px; }
.ge-inner svg { width: 76px; height: 48px; stroke: var(--line); margin-bottom: 10px; }
.ge-inner h3 { font-size: 15px; margin-bottom: 6px; }
.ge-inner p { color: var(--muted); margin: 0 0 14px; line-height: 1.5; }
.ge-actions { display: flex; gap: 8px; justify-content: center; }

.legend {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 7px 14px; min-height: 32px;
  border-top: 1px solid var(--line-soft);
  color: var(--muted); font-size: 11.5px;
}
.legend .lg { display: inline-flex; align-items: center; gap: 6px; cursor: default; }
.legend .lg .swatch { width: 16px; height: 3px; border-radius: 2px; background: currentColor; }
.legend .lg.dashed .swatch { background: repeating-linear-gradient(90deg, currentColor 0 4px, transparent 4px 8px); }
.legend .lg-slot { cursor: pointer; }
.legend .lg-slot:hover { color: var(--text) !important; }
.legend .lg.off { opacity: .38; }

/* ---------- Side panel ---------- */
.side-panel { display: flex; flex-direction: column; min-height: 0; background: var(--bg-2); }
.side-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 12px; border-bottom: 1px solid var(--line-soft);
}
.side-head h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .7px; color: var(--text-2); }
.side-head .count {
  display: inline-block; min-width: 20px; text-align: center;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px;
  padding: 1px 6px; font-size: 11px; color: var(--muted); margin-left: 4px;
}
.side-head-actions { display: flex; gap: 6px; }

.slot-list { flex: 1; overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.slot-list::-webkit-scrollbar, .modal-body::-webkit-scrollbar, .table-wrap::-webkit-scrollbar { width: 6px; height: 6px; }
.slot-list::-webkit-scrollbar-thumb, .modal-body::-webkit-scrollbar-thumb, .table-wrap::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }
.slot-list::-webkit-scrollbar-thumb:hover { background: var(--muted); }

.slot {
  flex: none;                 /* nicht zusammenstauchen lassen (Liste scrollt) */
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 3px solid var(--slot-color, var(--accent));
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color .12s, box-shadow .12s, opacity .12s;
}
.slot.selected { box-shadow: 0 0 0 1.5px var(--slot-color), 0 6px 18px rgba(0,0,0,.35); border-color: var(--slot-color); }
.slot.disabled { opacity: .5; }
.slot-head {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 8px 7px 10px;
  background: color-mix(in srgb, var(--slot-color) 13%, var(--panel));
  border-bottom: 1px solid var(--line-soft);
  cursor: pointer;
}
.slot-idx {
  font-family: var(--mono); font-size: 11px; font-weight: 700;
  background: var(--slot-color); color: #0F1113;
  border-radius: 4px; padding: 1px 5px; min-width: 22px; text-align: center;
}
.slot-name { font-size: 12.5px; font-weight: 500; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot-head .btn.icon { width: 24px; height: 24px; background: transparent; border-color: transparent; }
.slot-head .btn.icon:hover { background: var(--panel-3); border-color: var(--line); }
.slot-head .switch .track { width: 30px; height: 17px; }
.slot-head .switch .knob { width: 11px; height: 11px; }
.slot-head .switch input:checked + .track .knob { transform: translateX(13px); }

.badge {
  font-size: 9.5px; text-transform: uppercase; letter-spacing: .5px; font-weight: 700;
  padding: 2px 5px; border-radius: 4px; white-space: nowrap;
}
.badge.invert { background: rgba(245,158,11,.15); color: var(--warn); border: 1px solid rgba(245,158,11,.35); }
.badge.info { background: rgba(244,114,182,.14); color: var(--accent); border: 1px solid rgba(244,114,182,.3); }

.slot-body { padding: 9px 10px 11px; display: flex; flex-direction: column; gap: 9px; }
.params { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > span { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; display: flex; justify-content: space-between; }
.field > span em { font-style: normal; color: #55627a; }
.field input, .field select { width: 100%; height: 28px; }
.field.wide { grid-column: 1 / -1; }
.field input[type="number"] { text-align: right; }

.seg { display: flex; background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 2px; gap: 2px; height: 28px; }
.seg button {
  flex: 1; border: 0; background: transparent; color: var(--muted); border-radius: 4px; cursor: pointer; font-size: 11.5px;
}
.seg button.active { background: var(--slot-color); color: #0F1113; font-weight: 600; }

.slot-note {
  grid-column: 1 / -1;
  font-size: 11px; line-height: 1.45; color: var(--muted);
  background: var(--bg-2); border: 1px solid var(--line-soft); border-radius: 6px; padding: 6px 8px;
}
.slot-note strong { color: var(--text-2); font-weight: 600; }
.slot-note.warn { border-color: rgba(245,158,11,.28); background: rgba(245,158,11,.07); color: #D6B27A; }

.slot-empty { padding: 26px 20px; text-align: center; color: var(--muted); }
.slot-empty h3 { font-size: 13.5px; color: var(--text-2); margin-bottom: 6px; }
.slot-empty p { margin: 0 0 14px; line-height: 1.5; }

/* ---------- Statusbar ---------- */
.statusbar {
  display: flex; align-items: center; gap: 14px;
  padding: 6px 14px;
  background: var(--bg-2);
  border-top: 1px solid var(--line);
  font-size: 11.5px; color: var(--muted);
}
.statusbar .spacer { flex: 1; }
.statusbar .hint { color: #4B5563; }
#statCursor { min-width: 150px; text-align: right; color: var(--text-2); }

/* ---------- Modals ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(8,9,11,.7);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.modal {
  width: min(660px, 100%); max-height: min(84vh, 900px);
  display: flex; flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.modal.wide { width: min(880px, 100%); }
.modal.narrow { width: min(460px, 100%); }
.modal-body .lead { color: var(--muted); font-size: 12.5px; line-height: 1.55; margin-bottom: 12px; }
.modal-body .results + .check { margin-top: 10px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 13px 16px; border-bottom: 1px solid var(--line-soft); }
.modal-head h2 { font-size: 14px; }
.tabs.sub { margin: 12px 16px 0; align-self: flex-start; }
.modal-body { padding: 14px 16px; overflow: auto; flex: 1; min-height: 0; }
.modal-foot { display: flex; align-items: center; gap: 8px; padding: 11px 16px; border-top: 1px solid var(--line-soft); }
.modal-foot .foot-hint { flex: 1; color: var(--muted); font-size: 11.5px; }
.export-opts { display: flex; align-items: center; gap: 16px; margin-bottom: 10px; flex-wrap: wrap; }
.export-note { color: var(--text-2); font-size: 11.5px; line-height: 1.5; margin-bottom: 10px; }
.export-note code { background: var(--bg-2); padding: 1px 4px; border-radius: 3px; color: var(--accent); }
#taExport {
  width: 100%; min-height: 320px; resize: vertical;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px; font-size: 12px; line-height: 1.55; white-space: pre; overflow: auto;
}
.table-wrap { max-height: 52vh; overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
table.coef { width: 100%; border-collapse: collapse; font-family: var(--mono); font-size: 11.5px; }
table.coef th, table.coef td { padding: 5px 9px; text-align: right; border-bottom: 1px solid var(--line-soft); white-space: nowrap; }
table.coef th { position: sticky; top: 0; background: var(--panel-2); color: var(--text-2); font-weight: 600; text-align: right; z-index: 1; }
table.coef th:first-child, table.coef td:first-child { text-align: left; }
table.coef tr.slot-row td { background: var(--panel-2); color: var(--text); font-family: var(--font); font-weight: 600; }
table.coef tr.slot-row td .dot { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 7px; vertical-align: middle; }
table.coef td.name { color: var(--text-2); font-family: var(--font); }
table.coef tr.note-row td { color: var(--warn); font-family: var(--font); text-align: left; background: rgba(245,158,11,.07); }

.help section { margin-bottom: 18px; }
.help h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .7px; color: var(--accent); margin-bottom: 8px; }
.help p { margin: 0 0 8px; line-height: 1.55; color: var(--text-2); }
.help dl { display: grid; grid-template-columns: minmax(120px, 210px) 1fr; gap: 5px 14px; margin: 0; }
.help dt { color: var(--text); }
.help dd { margin: 0; color: var(--text-2); line-height: 1.45; }
kbd {
  font-family: var(--mono); font-size: 10.5px;
  background: var(--panel-3); border: 1px solid var(--line); border-bottom-width: 2px;
  border-radius: 4px; padding: 1px 5px; color: var(--text);
}
.help code { background: var(--bg-2); padding: 1px 4px; border-radius: 3px; color: var(--accent); font-family: var(--mono); }

/* ---------- Toasts ---------- */
.toasts { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  pointer-events: auto;
  display: flex; align-items: flex-start; gap: 9px;
  background: var(--panel-2); border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: 8px; padding: 9px 13px; box-shadow: var(--shadow);
  max-width: 560px; font-size: 12.5px; line-height: 1.45;
  animation: toastIn .18s ease-out;
}
.toast.error { border-left-color: var(--danger); }
.toast.warn  { border-left-color: var(--warn); }
.toast.ok    { border-left-color: var(--good); }
.toast .t-title { font-weight: 600; display: block; margin-bottom: 2px; }
.toast .t-body { color: var(--text-2); white-space: pre-line; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .workspace { grid-template-columns: minmax(0,1fr) 320px; }
  .statusbar .hint { display: none; }
}
@media (max-width: 900px) {
  body { overflow: auto; }
  .app { height: auto; min-height: 100vh; }
  .workspace { grid-template-columns: 1fr; }
  .graph-panel { height: 62vh; border-right: 0; border-bottom: 1px solid var(--line); }
  .side-panel { max-height: none; }
}

/* ============================================================
   Simulation & Spleiß
   ============================================================ */
.tabs.wrap { flex-wrap: wrap; }
.tab.sim-only, .tab.port-only, .tab.line-only { display: none; }
body.sim-on .tab.sim-only { display: inline-block; }
body.sim-on.has-port .tab.port-only { display: inline-block; }
body.sim-on.has-line .tab.line-only { display: inline-block; }
body.sim-on.has-line .tab.port-only { display: inline-block; }

/* ---- Seitenreiter ---- */
.side-tabs {
  display: flex; gap: 2px; padding: 6px 8px 0;
  border-bottom: 1px solid var(--line-soft); background: var(--bg-2);
}
.side-tab {
  flex: 1; height: 30px; border: 1px solid transparent; border-bottom: 0;
  background: transparent; color: var(--muted); cursor: pointer;
  border-radius: 7px 7px 0 0; font-size: 12px; transition: background .12s, color .12s;
}
.side-tab:hover { color: var(--text-2); }
.side-tab.active { background: var(--panel); border-color: var(--line); color: var(--text); font-weight: 600; }
.side-tab .dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--good); margin-left: 5px; vertical-align: middle; }

.side-body { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.form-scroll { flex: 1; overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.form-scroll::-webkit-scrollbar { width: 6px; }
.form-scroll::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }

/* ---- Formulargruppen ---- */
.fgroup { flex: none; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.fgroup > summary {
  display: flex; align-items: center; gap: 8px; cursor: pointer; list-style: none;
  padding: 8px 10px; background: var(--panel-2); border-bottom: 1px solid transparent;
  font-size: 12px; font-weight: 600; color: var(--text-2);
}
.fgroup > summary::-webkit-details-marker { display: none; }
.fgroup > summary::before {
  content: ''; width: 0; height: 0; flex: none;
  border-left: 4px solid var(--muted); border-top: 3.5px solid transparent; border-bottom: 3.5px solid transparent;
  transition: transform .15s;
}
.fgroup[open] > summary { border-bottom-color: var(--line-soft); }
.fgroup[open] > summary::before { transform: rotate(90deg); }
.fgroup > summary .tag { margin-left: auto; font-size: 11px; font-weight: 400; color: var(--muted); font-family: var(--mono); }
.fgroup .fbody { padding: 9px 10px 11px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.fgroup .fbody.one { grid-template-columns: 1fr; }
.fgroup .fbody .wide { grid-column: 1 / -1; }

.ffield { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.ffield > span { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; display: flex; justify-content: space-between; gap: 6px; }
.ffield > span em { font-style: normal; color: #55627a; }
.ffield input, .ffield select { width: 100%; height: 28px; }
.ffield input[type="number"] { text-align: right; }
.ffield.derived input { color: var(--muted); font-style: italic; }

.seg.neutral button.active { background: var(--panel-3); color: var(--text); font-weight: 600; }
.fgroup .seg { height: 28px; }

/* ---- Ergebnisblock ---- */
.results { grid-column: 1 / -1; display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; font-size: 11.5px; }
.results dt { color: var(--muted); white-space: nowrap; }
.results dd { margin: 0; text-align: right; font-family: var(--mono); color: var(--text-2); }
.results dd.warn { color: var(--warn); }
.results dd.bad { color: var(--danger); }
.results dd.muted { color: var(--muted); }
.results dd.good { color: var(--good); }
.results .sep { grid-column: 1/-1; height: 1px; background: var(--line-soft); margin: 4px 0; }

.hintbox {
  grid-column: 1 / -1; font-size: 11px; line-height: 1.45; color: var(--muted);
  background: var(--bg-2); border: 1px solid var(--line-soft); border-radius: 6px; padding: 6px 8px;
}
.hintbox strong { color: var(--text-2); }
.hintbox.warn { border-color: rgba(245,158,11,.3); background: rgba(245,158,11,.07); color: #D6B27A; }
.hintbox.bad  { border-color: rgba(239,68,68,.32); background: rgba(239,68,68,.08); color: #E7A0A0; }
.hintbox.good { border-color: rgba(16,185,129,.28); background: rgba(16,185,129,.07); color: #86C7AF; }

/* ---- Diagnose (Gates) ---- */
.diag { grid-column: 1/-1; display: flex; flex-direction: column; gap: 5px; }
.diag-row {
  display: flex; align-items: flex-start; gap: 8px; font-size: 11.5px; line-height: 1.4;
  padding: 6px 8px; border-radius: 6px; background: var(--bg-2); border: 1px solid var(--line-soft);
}
.diag-row .mark { flex: none; width: 15px; height: 15px; border-radius: 4px; display: grid; place-items: center; font-size: 10px; font-weight: 700; margin-top: 1px; }
.diag-row.ok   .mark { background: rgba(16,185,129,.18); color: var(--good); }
.diag-row.warn .mark { background: rgba(245,158,11,.18); color: var(--warn); }
.diag-row.bad  .mark { background: rgba(239,68,68,.18); color: var(--danger); }
.diag-row .txt { flex: 1; color: var(--text-2); }
.diag-row .txt b { color: var(--text); font-weight: 600; display: block; margin-bottom: 1px; }
.diag-row .num { font-family: var(--mono); color: var(--muted); white-space: nowrap; }

table.mini { width: 100%; border-collapse: collapse; font-size: 11px; font-family: var(--mono); }
table.mini th, table.mini td { padding: 3px 6px; text-align: right; border-bottom: 1px solid var(--line-soft); }
table.mini th { color: var(--muted); font-weight: 500; }
table.mini td:first-child, table.mini th:first-child { text-align: left; }
table.mini tr.best td { color: var(--good); }
table.mini tr.best td:first-child::after { content: ' ◄'; }

.paste-preview { margin-top: 10px; font-size: 11.5px; color: var(--text-2); }
.paste-preview .pill {
  display: inline-block; margin: 2px 4px 2px 0; padding: 2px 7px; border-radius: 999px;
  background: var(--panel-2); border: 1px solid var(--line); font-family: var(--mono); font-size: 11px;
}
.paste-preview .pill b { color: var(--good); font-weight: 600; }
#taDriverPaste { width: 100%; min-height: 180px; resize: vertical; background: var(--bg-2);
  border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font-size: 12px; line-height: 1.5; }

.form-empty { padding: 26px 18px; text-align: center; color: var(--muted); font-size: 12px; line-height: 1.55; }
.form-empty h3 { font-size: 13.5px; color: var(--text-2); margin-bottom: 6px; }
.form-empty .btn { margin-top: 12px; }

.grp-actions { display: flex; gap: 6px; grid-column: 1/-1; }
.grp-actions .btn { flex: 1; }

/* ============================================================
   Messungen
   ============================================================ */
.tab[data-view="time"] { }
.inline-field.time-only { display: none; }
body.time-view .inline-field.time-only { display: inline-flex; }

.meas-list {
  flex: none; max-height: 42%; overflow-y: auto;
  border-bottom: 1px solid var(--line-soft);
  padding: 8px; display: flex; flex-direction: column; gap: 5px;
}
.meas-list::-webkit-scrollbar { width: 6px; }
.meas-list::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }

.meas-item {
  flex: none; display: flex; align-items: center; gap: 7px;
  padding: 6px 8px; border-radius: 7px; cursor: pointer;
  background: var(--panel); border: 1px solid var(--line);
  border-left: 3px solid var(--m-color, var(--muted));
  transition: background .12s, border-color .12s;
}
.meas-item:hover { background: var(--panel-2); }
.meas-item.selected { border-color: var(--m-color); box-shadow: 0 0 0 1px var(--m-color); }
.meas-item.hidden-trace { opacity: .45; }
.meas-item .m-name { flex: 1; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meas-item .m-sub { font-size: 10px; color: var(--muted); font-family: var(--mono); }
.meas-item .m-eye { width: 22px; height: 22px; display: grid; place-items: center; border-radius: 5px; color: var(--muted); flex: none; }
.meas-item .m-eye:hover { background: var(--panel-3); color: var(--text); }
.meas-item .m-eye svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.7; }
.meas-item .role-badge {
  font-size: 9px; font-weight: 700; letter-spacing: .4px; padding: 1px 5px; border-radius: 4px;
  background: rgba(56,189,248,.15); color: var(--simc, #38BDF8); border: 1px solid rgba(56,189,248,.32);
}
.meas-item .role-badge.near { background: rgba(245,158,11,.15); color: var(--warn); border-color: rgba(245,158,11,.32); }
.meas-item .role-badge.target { background: rgba(52,211,153,.15); color: #34D399; border-color: rgba(52,211,153,.32); }
.meas-item .m-col { width: 12px; height: 12px; border-radius: 3px; flex: none; background: var(--m-color); }

.meas-empty { padding: 20px 14px; text-align: center; color: var(--muted); font-size: 12px; line-height: 1.5; }

.rec-meter { height: 10px; border-radius: 5px; background: var(--bg-2); border: 1px solid var(--line); overflow: hidden; position: relative; }
.rec-meter > i { display: block; height: 100%; background: linear-gradient(90deg, var(--good), var(--warn) 78%, var(--danger) 94%); width: 0; transition: width .08s linear; }
.rec-progress { height: 6px; border-radius: 3px; background: var(--bg-2); border: 1px solid var(--line); overflow: hidden; margin: 10px 0; }
.rec-progress > i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .15s linear; }
.rec-row { display: flex; align-items: center; gap: 10px; margin-top: 8px; font-size: 11.5px; color: var(--text-2); }
.rec-row .num { font-family: var(--mono); margin-left: auto; }

/* ============================================================
   Messdialog
   ============================================================ */
.rec-body { padding: 0; }
.rec-sec { border-bottom: 1px solid var(--line-soft); padding: 14px 16px; }
.rec-sec:last-of-type { border-bottom: 0; }
.rec-sec > h3 {
  font-size: 11px; text-transform: uppercase; letter-spacing: .8px;
  color: var(--muted); margin: 0 0 10px; display: flex; align-items: center; gap: 8px;
}
.rec-sec > h3::after { content: ''; flex: 1; height: 1px; background: var(--line-soft); }

.rec-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
.rec-grid .wide { grid-column: 1 / -1; }
.rec-field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.rec-field > label {
  font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px;
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
}
.rec-field > label .val { color: var(--text); font-family: var(--mono); font-size: 11.5px; letter-spacing: 0; text-transform: none; }
/* Ein erklärender Zusatz gehört neben die Beschriftung, nicht ans andere
   Ende der Zeile – dort liest er sich wie eine eigene Angabe. */
.rec-field > label em { font-style: normal; color: var(--muted); opacity: .8; margin-right: auto; }
.rec-field select, .rec-field input[type="text"], .rec-field input[type="number"] { width: 100%; height: 30px; }
.rec-field input[type="number"] { text-align: right; }

.rec-pair { display: grid; grid-template-columns: 1fr auto 1fr; align-items: end; gap: 6px; }
.rec-pair .sep { padding-bottom: 8px; color: var(--muted); font-size: 11px; }

input[type="range"] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 22px; background: transparent; cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: var(--panel-3); }
input[type="range"]::-moz-range-track { height: 4px; border-radius: 2px; background: var(--panel-3); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--panel); margin-top: -5px;
}
input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%; background: var(--accent); border: 2px solid var(--panel);
}
input[type="range"]:focus { outline: none; }
input[type="range"]:focus::-webkit-slider-thumb { box-shadow: 0 0 0 3px rgba(59,130,246,.25); }

.rec-seg { display: flex; background: var(--bg-2); border: 1px solid var(--line); border-radius: 7px; padding: 2px; gap: 2px; height: 30px; }
.rec-seg button { flex: 1; border: 0; background: transparent; color: var(--muted); border-radius: 5px; cursor: pointer; font-size: 11.5px; }
.rec-seg button:hover { color: var(--text-2); }
.rec-seg button.active { background: var(--panel-3); color: var(--text); font-weight: 600; }

.rec-level { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; margin-top: 12px; }
.rec-level .lbl { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.rec-level .num { font-family: var(--mono); font-size: 11.5px; color: var(--text-2); min-width: 70px; text-align: right; }
.rec-meter { height: 12px; border-radius: 6px; background: var(--bg-2); border: 1px solid var(--line); overflow: hidden; position: relative; }
.rec-meter > i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--good) 0%, var(--good) 60%, var(--warn) 82%, var(--danger) 96%); transition: width .06s linear; }
.rec-meter > b { position: absolute; top: 0; bottom: 0; width: 2px; background: rgba(229,231,235,.5); }

.rec-summary {
  flex: none;
  padding: 9px 16px; background: var(--bg-2); border-top: 1px solid var(--line-soft);
  font-size: 11.5px; color: var(--text-2); display: flex; flex-wrap: wrap; gap: 6px 18px;
}
.rec-summary span { display: inline-flex; gap: 6px; }
.rec-summary b { color: var(--text); font-weight: 600; font-family: var(--mono); }

.rec-progress { height: 6px; border-radius: 3px; background: var(--bg-2); border: 1px solid var(--line); overflow: hidden; margin: 10px 0; }
.rec-progress > i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .15s linear; }
.rec-row { display: flex; align-items: center; gap: 10px; margin-top: 8px; font-size: 11.5px; color: var(--text-2); }
.rec-row .num { font-family: var(--mono); margin-left: auto; }
#recStatus { padding: 0 16px 14px; }
#recStatus:empty { padding: 0; }

/* ============================================================
   Infozeile unter dem Diagramm
   ============================================================ */
.graph-info {
  display: flex; align-items: center; gap: 14px;
  padding: 6px 14px; min-height: 30px;
  border-top: 1px solid var(--line-soft);
  background: var(--bg-2);
  font-size: 11.5px; overflow: hidden;
}
.graph-info .gi-left {
  display: flex; align-items: center; gap: 10px; flex-wrap: nowrap;
  min-width: 0; flex: 1; overflow-x: auto; scrollbar-width: none;
}
.graph-info .gi-left::-webkit-scrollbar { height: 0; }
.graph-info .gi-right { display: flex; align-items: center; margin-left: auto; flex: none; }
.graph-info .gi-f {
  font-family: var(--mono); font-weight: 600; color: var(--text);
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 5px; padding: 2px 7px;
}
.graph-info .gi-item { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); white-space: nowrap; }
.graph-info .gi-item i { width: 8px; height: 3px; border-radius: 2px; flex: none; }
.graph-info .gi-item b { color: var(--text-2); font-weight: 500; font-family: var(--mono); }
.graph-info .gi-slot {
  display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
  color: var(--text-2); padding: 2px 8px; border-radius: 6px;
  border: 1px solid transparent;
}
.graph-info .gi-slot.hot { background: var(--panel-2); border-color: var(--line); color: var(--text); }
.graph-info .gi-slot em { color: var(--warn); font-style: normal; }
.graph-info .gi-sep { color: #2A3547; margin: 0 1px; }
.graph-info .gi-num {
  font-family: var(--mono); font-size: 10px; font-weight: 700; color: #0B0E13;
  border-radius: 4px; padding: 1px 5px; min-width: 18px; text-align: center;
}

/* ---- Kurven-Auswahl ---- */
.popwrap { position: relative; }
.popover {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 40;
  background: var(--panel); border: 1px solid var(--line); border-radius: 9px;
  box-shadow: var(--shadow); padding: 8px; min-width: 232px;
}
.popover h4 {
  margin: 0 0 6px; font-size: 10px; text-transform: uppercase; letter-spacing: .7px;
  color: var(--muted); font-weight: 600;
}
.popover .check { display: flex; padding: 4px 5px; border-radius: 5px; width: 100%; }
.popover .check:hover { background: var(--panel-2); }
.gi-item .gi-sub { font-style: normal; color: var(--muted); font-size: 10px; margin-left: 4px; }
/* Filter ohne eigene Kurve im Bild: der Punkt ist da, die Linie nicht. */
.legend .lg-slot.nocurve .swatch { background: transparent; box-shadow: inset 0 0 0 2px currentColor; }
.pop-ctx {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 0 5px 7px; margin-bottom: 5px; border-bottom: 1px solid var(--line-soft);
  font-size: 11px; color: var(--muted);
}
.pop-ctx b { color: var(--text-2); font-weight: 600; }
.btn.tiny { height: 21px; padding: 0 7px; font-size: 10.5px; }
/* Von Hand geschaltet: bleibt beim Wechsel der Basis stehen. */
.popover .check.pinned { box-shadow: inset 2px 0 0 var(--accent); }
.popover .check.pinned span { color: var(--text); }
.popover .pop-note {
  margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line-soft);
  font-size: 10.5px; color: var(--muted); line-height: 1.45;
}
.inline-field.dist-only { display: none; }
body.dist-view .inline-field.dist-only { display: inline-flex; }
body.dist-view .inline-field.time-only { display: none; }

/* ---- Testton ---- */
.rec-tone { display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 10px; margin-top: 10px; }
.rec-tone .lbl { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }

/* ============================================================
   Transmissionline / TQWT
   ============================================================ */
.line-profile { width: 100%; height: 92px; display: block; border-radius: 6px;
  background: var(--bg-2); border: 1px solid var(--line-soft); }
.seg-table { display: flex; flex-direction: column; gap: 8px; }
.seg-row { background: var(--bg-2); border: 1px solid var(--line-soft); border-radius: 8px; padding: 8px; }
.seg-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 7px; }
.seg-head span { font-size: 10.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); font-weight: 600; }
.seg-head .btn.icon { width: 20px; height: 20px; background: transparent; border-color: transparent; }
.seg-head .btn.icon svg { width: 12px; height: 12px; }
.seg-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.seg-grid .ffield.wide { grid-column: 1 / -1; }
.seg-grid select { font-size: 11px; }

/* ============================================================
   Farbauswahl und Mehrfachauswahl
   ============================================================ */
.swatches { display: flex; flex-wrap: wrap; gap: 5px; }
.swatches .sw {
  width: 22px; height: 22px; border-radius: 6px; cursor: pointer; padding: 0;
  background: var(--sw); border: 1px solid rgba(0,0,0,.35);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.08);
}
.swatches .sw:hover { transform: scale(1.08); }
.swatches .sw.on { box-shadow: 0 0 0 2px var(--bg-2), 0 0 0 3.5px var(--sw); }
.ffield > span em#colName, .ffield > span em.val { color: var(--text-2); font-style: normal; text-transform: none; letter-spacing: 0; }

.pick-list {
  max-height: 200px; overflow-y: auto; display: flex; flex-direction: column; gap: 1px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 8px; padding: 4px;
}
.pick-list::-webkit-scrollbar { width: 6px; }
.pick-list::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }
.pick {
  display: flex; align-items: center; gap: 8px; padding: 5px 7px; border-radius: 6px;
  cursor: pointer; font-size: 12px; color: var(--text-2); user-select: none;
}
.pick:hover { background: var(--panel-2); }
.pick input { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; flex: none; }
.pick i { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.pick span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick-list:empty::after { content: 'Keine Messung vorhanden'; color: var(--muted); font-size: 11.5px; padding: 8px; }
.ffield > span em a { color: var(--accent); text-decoration: none; }
.ffield > span em a:hover { text-decoration: underline; }

/* ---- Filterkette je Zweig ---- */
.graph-opts .ways-only { display: none; }
body.has-ways .graph-opts .ways-only { display: inline-flex; }
.chain-bar {
  flex: none; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 7px 10px; background: var(--panel); border-bottom: 1px solid var(--line-soft);
}
.chain-bar select { height: 26px; max-width: 190px; }
.chain-bar .chain-note { font-size: 10.5px; color: var(--muted); line-height: 1.35; flex: 1; min-width: 120px; }
.chain-bar .chain-note strong { color: var(--text-2); }
.chain-bar .chain-counts { display: inline-flex; align-items: center; gap: 8px; font-family: var(--mono); font-size: 10.5px; color: var(--muted); }
.chain-bar .chain-counts i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; margin-right: 3px; }
.meas-item .role-badge.way { background: rgba(167,139,250,.15); color: #A78BFA; border-color: rgba(167,139,250,.32); }
.graph-info .gi-f { white-space: nowrap; flex: none; }

/* ---- Kennwerteleiste über einem Formular ---- */
.metric-bar {
  flex: none; display: flex; flex-wrap: wrap; gap: 5px 6px;
  padding: 8px 10px; background: var(--panel); border-bottom: 1px solid var(--line-soft);
}
.metric-bar .mx {
  display: inline-flex; align-items: baseline; gap: 5px; white-space: nowrap;
  background: var(--bg-2); border: 1px solid var(--line-soft); border-radius: 6px; padding: 3px 7px;
}
.metric-bar .mx i { font-style: normal; font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .3px; }
.metric-bar .mx b { font-family: var(--mono); font-size: 11.5px; color: var(--text); font-weight: 500; }
.metric-bar .mx.good b { color: var(--good); }
.metric-bar .mx.warn { border-color: rgba(245,158,11,.35); background: rgba(245,158,11,.08); }
.metric-bar .mx.warn b { color: var(--warn); }
.metric-bar .mx.bad { border-color: rgba(239,68,68,.38); background: rgba(239,68,68,.09); }
.metric-bar .mx.bad b { color: var(--danger); }
.metric-bar .mx-jump { cursor: pointer; }
.metric-bar .mx-jump:hover { border-color: var(--warn); }
.seg.roles button { font-size: 11px; padding: 0 2px; }
.metric-bar + .form-scroll { padding-top: 8px; }

/* Einheitliche Dialoge: Abschnitte wie im Messdialog */
.rec-body > .rec-sec:first-child { border-top: 0; }
.rec-field > label .val a { color: var(--accent); text-decoration: none; }
.rec-field > label .val a:hover { text-decoration: underline; }
.rec-summary:empty { display: none; }
.rec-grid .hintbox { margin: 0; }
.rec-grid .check.wide { margin: 2px 0; }
.paste-preview .paste-none { color: var(--muted); font-size: 11.5px; }
#taDriverPaste { min-height: 150px; }
.export-body .export-opts { padding-bottom: 10px; border-bottom: 1px solid var(--line-soft); margin-bottom: 12px; }
.chain-bar .chain-sim { flex: none; font-size: 11px; }

/* ---- Zeitabgleich ---- */
.align-table { margin-top: 2px; }
.align-table th { font-size: 10px; text-transform: uppercase; letter-spacing: .4px; }
.align-table td { vertical-align: top; padding: 6px; }
.align-table tr.al-ref td { color: var(--muted); }
.align-table .al-dot { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 6px; vertical-align: baseline; }
.align-table td:first-child { font-family: var(--sans, inherit); }
.align-table .al-sub { color: var(--muted); font-size: 10px; }
.align-table .al-note { color: var(--warn); text-align: left; font-family: inherit; }
.align-table .al-flip { color: var(--warn); }
.align-table .al-gain { color: var(--good); }
.align-table .al-prog { white-space: nowrap; font-size: 11px; color: var(--muted); }
.align-table .al-prog b { color: var(--text); font-weight: 600; }
.align-table .al-arrow { opacity: .55; padding: 0 1px; }
/* Die Spalte, auf die optimiert wurde – damit sichtbar ist, welche der drei
   Zahlen den Ausschlag gab und welche nur Beifang ist. */
.align-table .al-prog.al-crit {
  background: rgba(244,114,182,.10);
  box-shadow: inset 2px 0 0 var(--accent);
}
.rec-seg.disabled { opacity: .5; pointer-events: none; }
.rec-field.dimmed { opacity: .5; }
/* Ein einzelner Knopf in einer Aktionszeile soll ein Knopf bleiben und sich
   nicht über die ganze Breite ziehen – gestreckt liest er sich wie ein
   Banner und nicht wie etwas zum Anklicken. */
.grp-actions.left { justify-content: flex-start; }
.grp-actions.left .btn { flex: 0 0 auto; }
/* Die Reiter des Messfensters wechseln unterschiedlich hohe Inhalte. Ohne
   Mindesthöhe springt das Fenster bei jedem Klick, und der Knopf, den man
   gerade treffen wollte, ist woanders. */
#modalRecord .modal-body { min-height: 430px; }
/* Kalibrierdateien: zwei Spalten, beide linksbündig – eine rechtsbündige
   Wertespalte reißt bei langen Dateinamen quer durchs Fenster. */
.cal-list { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 11.5px; margin-top: 10px; }
.cal-list dt { color: var(--text-2); font-family: var(--mono); white-space: nowrap; }
.cal-list dd { color: var(--muted); margin: 0; text-align: left; }
.cal-list dd b { color: var(--text-2); font-weight: 600; }
/* Das Fenster der laufenden Messung. Oben, groß und ruhig, steht der
   Zustand – das Einzige, worauf man währenddessen schaut. Darunter die
   Pegelkontrolle, ganz unten die Kennwerte des Vorgangs als Zeile statt
   als Tabelle mit einer Lücke in der Mitte. */
.run-stage { min-height: 138px; display: flex; flex-direction: column; justify-content: center; }
.run-cue { text-align: center; padding: 6px 0; }
.run-cue-title {
  font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 6px;
}
.run-cue p { font-size: 12px; color: var(--text-2); line-height: 1.55; margin: 0 auto; max-width: 46ch; }
/* Je Eingangskanal ein Balken mit Beschriftung: mit zwei Kapseln sagt ein
   gemeinsamer Balken nicht, welche gerade ausschlägt. */
.lvl-box { display: flex; flex-direction: column; gap: 7px; }
.lvl-row { display: flex; align-items: center; gap: 10px; }
.lvl-row .lbl { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; white-space: nowrap; min-width: 132px; display: flex; flex-direction: column; gap: 1px; }
.lvl-row .lbl em { font-style: normal; font-size: 9.5px; letter-spacing: .2px; color: var(--good); text-transform: none; }
/* Ein Kanal, der nicht in die Messung geht, bleibt sichtbar – man will ja
   erkennen, dass dort nichts (oder das Falsche) anliegt –, tritt aber
   zurück. */
.lvl-row.unused { opacity: .55; }
.lvl-row.unused .lbl em { color: var(--muted); }
.lvl-row .num { font-family: var(--mono); font-size: 11.5px; color: var(--text-2); min-width: 118px; text-align: right; line-height: 1.25; }
/* In dB SPL steht der Effektivwert gross und der Spitzenwert klein
   darunter: die eine Zahl ist die Vorgabe, die andere die Aussteuerung. */
.lvl-row .num em { display: block; font-style: normal; font-size: 9.5px; color: var(--muted); }
.lvl-row .num strong { font-size: 13px; color: var(--text); font-weight: 600; }
/* Leiste unter den Balken: Umschalter dBFS/dB SPL und die Empfindlichkeit. */
.lvl-scale { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 4px;
             padding-top: 8px; border-top: 1px solid var(--line); }
.lvl-scale .lbl { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.lvl-scale .rec-seg { flex: 0 0 auto; }
.lvl-scale .rec-seg button { white-space: nowrap; }
.lvl-scale .lvl-ref { display: flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--text-2); }
.lvl-scale .lvl-ref em { font-style: normal; color: var(--muted); }
.lvl-scale .lvl-ref input { width: 68px; height: 26px; }
.lvl-scale .note { flex: 1 1 100%; font-size: 10.5px; color: var(--muted); line-height: 1.5; }
.lvl-row .rec-meter { flex: 1; }
/* Der Verlauf im Balken sagt schon, wo es eng wird; ein zusätzlicher
   Farbwechsel überdeckte ihn nur. Übersteuerung zeigt die Zahl. */
.lvl-row .num.hot { color: var(--danger); font-weight: 600; }
.lvl-idle { font-size: 11.5px; color: var(--muted); }
.lvl-box:empty::after {
  content: 'Noch keine Anzeige – „Eingang abhören" startet sie.';
  font-size: 11.5px; color: var(--muted);
}
.run-facts { display: flex; flex-wrap: wrap; gap: 6px; }
.run-facts .rf {
  display: inline-flex; align-items: baseline; gap: 6px;
  background: var(--bg-2); border: 1px solid var(--line-soft); border-radius: 6px; padding: 4px 8px;
}
.run-facts .rf i { font-style: normal; font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .3px; }
.run-facts .rf b { font-family: var(--mono); font-size: 11.5px; color: var(--text); font-weight: 500; }
/* Fortschritt und Aufforderungen sitzen in derselben Bühne. */
.run-stage .rec-row { justify-content: center; gap: 14px; font-size: 13px; }
.run-stage .rec-progress { margin: 12px auto 0; max-width: 380px; }
.run-stage .hintbox { text-align: left; }
#modalRun .modal-body { min-height: 0; }

/* Pegelachse von Hand: der Knopf, der sie zurückholt, hebt sich ab, und die
   Bildunterschrift sagt, warum die Achse nicht mehr mitgeht. */
body.view-manual #btnResetView { border-color: var(--accent-dim); color: var(--accent); }
body.view-manual #plotMag .plot-caption::after {
  content: ' · Pegelachse von Hand';
  color: var(--accent);
}
.align-table tr.al-extra td { border-bottom: 1px solid var(--line-soft); color: var(--muted);
  font-family: inherit; font-size: 10.5px; line-height: 1.45; text-align: left; padding-top: 0; }
.chain-bar .chain-align { flex: none; margin-left: auto; }
.align-table .al-warn { color: var(--warn); }
