:root {
  --bg: #070b16; --panel: #0d1426; --line: #1c2742;
  --text: #e2e8f0; --muted: #64748b; --accent: #38bdf8;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font-family: system-ui, -apple-system, sans-serif; }
body { display: flex; flex-direction: column; height: 100vh; }

header { display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 16px 24px; border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #0c1326, #080d1a); }
header h1 { font-size: 19px; font-weight: 700; margin: 0; letter-spacing: .3px; line-height: 1.25; }
.headright { display: flex; align-items: center; gap: 14px; }
.status { font-size: 14px; color: var(--muted); white-space: nowrap; }
.status.live { color: #34d399; }
.status.disconnected, .status.error { color: #f87171; }
.iconbtn { background: #1e293b; color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 12px; font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.iconbtn:hover { background: #273549; }

main { flex: 1; display: flex; min-height: 0; }
#plot { flex: 1; position: relative; background: #0a1020; overflow: hidden; cursor: grab; }
#plot:active { cursor: grabbing; }
#view { position: absolute; inset: 0; transform-origin: 0 0; }
#view canvas, #view svg { position: absolute; inset: 0; width: 100%; height: 100%; }

#legend { position: absolute; top: 16px; right: 16px; display: flex; flex-direction: column;
  align-items: center; gap: 6px; font-size: 13px; color: var(--muted);
  background: rgba(8,13,26,.78); padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line); }
#legend .ltitle { font-weight: 700; color: var(--text); letter-spacing: .5px; font-size: 14px; }
#legend .bar { width: 18px; height: 180px; border-radius: 4px;
  background: linear-gradient(to top, rgb(10,12,40), rgb(170,30,120), rgb(250,200,60)); }
#hint { position: absolute; left: 14px; bottom: 12px; font-size: 11px; color: var(--muted);
  background: rgba(8,13,26,.6); padding: 4px 8px; border-radius: 6px; pointer-events: none; }

#panel { width: 280px; border-left: 1px solid var(--line); padding: 16px;
  background: var(--panel); display: flex; flex-direction: column; gap: 18px; }
#readout { font-variant-numeric: tabular-nums; font-size: 14px; color: var(--text);
  background: #0a1020; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
#calib { display: flex; flex-direction: column; gap: 10px; }
#calib h2 { font-size: 13px; color: var(--muted); margin: 0; text-transform: uppercase; letter-spacing: .5px; }
#thresh { display: flex; flex-direction: column; gap: 8px; }
#thresh h2 { font-size: 13px; color: var(--muted); margin: 0; text-transform: uppercase; letter-spacing: .5px; }
#thresh-slider { width: 100%; accent-color: var(--accent); cursor: pointer; }
#thresh-val { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
button { background: var(--accent); color: #001018; border: 0; border-radius: 8px;
  padding: 10px 14px; font-size: 14px; font-weight: 600; cursor: pointer; }
button:disabled { opacity: .5; cursor: default; }
#calib-cancel, #pipe-restart { background: #334155; color: var(--text); }
#calib-msg { font-size: 13px; color: var(--muted); min-height: 18px; }

/* Info-Overlay (Erklaerung fuer Laien + technisch Interessierte) */
#info { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(4,7,14,.72); z-index: 10; padding: 24px; }
#info[hidden] { display: none; }
#info .card { width: min(840px, 100%); max-height: 92vh; overflow: auto; background: var(--panel);
  border: 1px solid var(--line); border-radius: 14px; padding: 28px 34px; line-height: 1.6; }
#info .card a { color: var(--accent); }
#info .card code { background: #0a1020; border: 1px solid var(--line); border-radius: 4px;
  padding: 1px 5px; font-size: 13px; }
#info .card h2 { margin: 0 0 6px; font-size: 20px; }
#info .card h3 { margin: 18px 0 4px; font-size: 13px; color: var(--accent);
  text-transform: uppercase; letter-spacing: .5px; }
#info .card p { margin: 6px 0; color: #cbd5e1; font-size: 14px; }
#info-close { margin-top: 18px; }

/* Fresnel-Zonen-Schema im Info-Overlay */
.fresnel-fig { margin: 12px 0 4px; padding: 0; }
.fresnel-fig svg { width: 100%; height: auto; max-height: 240px;
  background: #f1f5f9; border: 1px solid var(--line); border-radius: 10px; }
.fresnel-fig figcaption { margin-top: 8px; font-size: 12.5px; color: var(--muted); line-height: 1.5; }
.fl-zone   { fill: rgba(14,116,144,.14); stroke: #0e7490; stroke-width: 1.5; stroke-dasharray: 5 4; }
.fl-path   { stroke: #334155; stroke-width: 2; }
.fl-virt   { stroke: #64748b; stroke-width: 1.5; stroke-dasharray: 3 4; }
.fl-wall   { stroke: #1e293b; stroke-width: 4; }
.fl-anchor { fill: #d97706; stroke: #1e293b; stroke-width: 1; }
.fl-anchor-virt { fill: #fef3c7; stroke: #d97706; stroke-width: 1.5; stroke-dasharray: 2 2; }
.fl-refl   { fill: #0e7490; }
.fl-person { fill: #dc2626; stroke: #1e293b; stroke-width: 1.5; }
.fl-cap    { fill: #0f172a; font-size: 13px; font-weight: 600; }
.fl-lbl    { fill: #475569; font-size: 11px; }
