/* Leitstand - Stellwerk. Eine Optik (Grafit), bewusst ohne Hellmodus:
   Konsole fuer den Betreiber, nicht fuer Kunden. Alle Farben als Tokens. */
@font-face { font-family: "Plex Condensed"; src: url("/schriften/ibm-plex-sans-condensed-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Plex Condensed"; src: url("/schriften/ibm-plex-sans-condensed-latin-500-normal.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Plex Condensed"; src: url("/schriften/ibm-plex-sans-condensed-latin-600-normal.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Plex Mono"; src: url("/schriften/ibm-plex-mono-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Plex Mono"; src: url("/schriften/ibm-plex-mono-latin-500-normal.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Plex Mono"; src: url("/schriften/ibm-plex-mono-latin-600-normal.woff2") format("woff2"); font-weight: 600; font-display: swap; }

:root {
  --grund: #15171a; --seite: #1a1c20; --flaeche: #1e2125; --zeile-aktiv: #22252a;
  --linie: #2c3036; --linie-stark: #3a3f46;
  --text: #ecebe7; --leise: #a2a8ae;
  --akzent: #ff8a3d; --frei: #43c486; --achtung: #f2c84b; --halt: #ff6b6b; --ram: #7aa7ff;
  --balken: #7a8088; --schalter-an: #2f8f62; --schalter-aus: #6b717a;
  --schatten: rgb(0 0 0 / .6);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { scroll-padding-top: 16px; }
body { margin: 0; background: var(--grund); color: var(--text); font: 15px/1.5 "Plex Condensed", "Arial Narrow", sans-serif; }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; text-wrap: balance; }
p { margin: 0; }
button, input, textarea { font: inherit; color: inherit; }
input, textarea { font-size: 16px; color: var(--text); background: var(--flaeche); border: 1px solid var(--linie-stark); border-radius: 4px; padding: 10px; min-height: 44px; width: 100%; }
:focus-visible { outline: 2px solid var(--akzent); outline-offset: 2px; }
code { font-family: "Plex Mono", ui-monospace, monospace; }

.zahl { font-family: "Plex Mono", ui-monospace, monospace; font-variant-numeric: tabular-nums; }
.leise { color: var(--leise); }
.klein { font-size: 13px; }
.etikett { font-size: 13px; font-weight: 500; letter-spacing: .14em; color: var(--leise); }
.fehler { color: var(--halt); font-size: 14px; }
.fehler:empty { display: none; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.stapel { display: flex; flex-direction: column; gap: 12px; }
.reihe { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.feld { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--leise); }

/* Knoepfe */
.knopf { min-height: 44px; padding: 0 16px; border-radius: 4px; border: 1px solid var(--linie-stark); background: transparent; cursor: pointer; font-weight: 500; }
.knopf:hover { border-color: var(--leise); }
.knopf.haupt { background: var(--text); color: var(--grund); border-color: var(--text); font-weight: 600; }
.knopf.gefahr { border-color: var(--halt); color: var(--halt); }
.knopf.gefahr-voll { background: var(--halt); border-color: var(--halt); color: var(--grund); font-weight: 600; }
.knopf.gut { border-color: var(--frei); color: var(--frei); }
.knopf.klein { min-height: 36px; padding: 0 12px; font-size: 14px; }
.knopf:disabled { opacity: .6; cursor: progress; }

/* Signalbegriffe: Form UND Farbe UND Wort - nie nur Farbe */
.signal { display: inline-block; flex: none; width: 12px; height: 12px; }
.signal.gross { width: 18px; height: 18px; }
.sig-frei { background: var(--frei); border-radius: 50%; }
.sig-achtung { background: var(--achtung); transform: rotate(45deg) scale(.85); }
.sig-halt { background: var(--halt); }
.sig-frei-text, .txt-frei { color: var(--frei); }
.sig-achtung-text, .txt-gelb { color: var(--achtung); }
.sig-halt-text, .txt-rot { color: var(--halt); }
.txt-gruen { color: var(--leise); }

/* Anmeldung */
.laden { padding: 24px; }
.anmeldung { max-width: 440px; margin: 10vh auto; padding: 0 16px; display: flex; flex-direction: column; gap: 16px; }
.anmeldung h1 { font-size: 34px; font-weight: 600; letter-spacing: .14em; }
.codefeld { font-size: 28px; letter-spacing: .4em; max-width: 14ch; }

/* Kopf */
.kopf { display: flex; align-items: center; gap: 12px 20px; padding: 12px 24px; border-bottom: 1px solid var(--linie); flex-wrap: wrap; }
.marke { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.marke h1 { font-size: 22px; font-weight: 600; letter-spacing: .14em; }
.kopf-rechts { margin-left: auto; display: flex; gap: 8px 16px; align-items: center; flex-wrap: wrap; }
.zaehler { display: flex; gap: 14px; }
.zaehl { display: inline-flex; gap: 6px; align-items: center; }

/* Gleisbild */
.gleisbild { padding: 16px 24px 8px; }
.gleis { position: relative; padding: 0 24px; margin-top: 10px; }
.schiene { position: absolute; left: 0; right: 0; top: 20px; height: 4px; background: var(--linie-stark); border-radius: 2px; }
.signale { position: relative; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.gleis-signal { background: transparent; border: 0; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 0 6px 6px; min-width: 110px; max-width: 200px; }
.mast { width: 44px; height: 44px; border-radius: 50%; background: var(--grund); border: 3px solid var(--linie-stark); display: flex; align-items: center; justify-content: center; }
.gleis-signal:hover .mast { border-color: var(--leise); }
.gleis-signal[aria-pressed="true"] .mast { border-color: var(--akzent); }
.gleis-name { font-weight: 600; letter-spacing: .06em; text-align: center; overflow-wrap: anywhere; }
.gleis-wort { font-size: 13px; }

/* Arbeitsflaeche */
.arbeitsflaeche { display: flex; flex-wrap: wrap; align-items: stretch; }
.hauptspalte { flex: 999 1 620px; min-width: 0; padding: 12px 24px 24px; display: flex; flex-direction: column; gap: 16px; }
.detail { flex: 1 1 340px; min-width: 0; max-width: 460px; background: var(--seite); border-left: 1px solid var(--linie); padding: 16px 20px 24px; display: flex; flex-direction: column; gap: 18px; }

/* Liste - scrollt in ihrem eigenen Rahmen, nie die Seite */
.tabelle-rahmen { overflow-x: auto; }
.spalten, .zeile { display: grid; grid-template-columns: 20px minmax(8rem, 1.4fr) minmax(11rem, 1.6fr) 5.5rem 120px minmax(6.5rem, 1fr) 5rem; gap: 12px; align-items: center; min-width: 760px; }
.kopfzeile { padding: 8px 12px; font-size: 12px; letter-spacing: .1em; color: var(--leise); border-bottom: 1px solid var(--linie); }
.liste { list-style: none; margin: 0; padding: 0; }
.zeile { width: 100%; text-align: left; padding: 12px; min-height: 56px; background: transparent; border: 0; border-left: 3px solid transparent; border-bottom: 1px solid var(--linie); cursor: pointer; }
.zeile:hover { background: var(--flaeche); }
.zeile[aria-pressed="true"] { background: var(--zeile-aktiv); border-left-color: var(--akzent); }
.name-zelle { display: flex; flex-direction: column; min-width: 0; }
.name-zelle strong { font-weight: 600; overflow-wrap: anywhere; }
.zustand-zelle { font-size: 14px; line-height: 1.35; }
.funke { fill: none; stroke: var(--akzent); stroke-width: 1.5; }
.balken { display: flex; align-items: center; gap: 8px; }
.balken-bahn { flex: 1; height: 6px; background: var(--linie); border-radius: 3px; overflow: hidden; }
.balken-fuellung { display: block; height: 100%; background: var(--balken); }
.balken-fuellung.voll { background: var(--halt); }
.leer { padding: 16px 12px; color: var(--leise); }

/* Kurve */
.karte { background: var(--flaeche); border: 1px solid var(--linie); border-radius: 6px; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.karte h2 { font-size: 16px; font-weight: 600; letter-spacing: .06em; overflow-wrap: anywhere; min-width: 0; }
.umschalter { margin-left: auto; display: flex; border: 1px solid var(--linie-stark); border-radius: 4px; overflow: hidden; }
.umschalter button { border: 0; background: transparent; min-height: 40px; padding: 0 14px; cursor: pointer; }
.umschalter button[aria-pressed="true"] { background: var(--text); color: var(--grund); }
.kurve-flaeche { position: relative; }
.kurve { width: 100%; height: auto; display: block; }
.gitter { stroke: var(--linie); }
.gitter.halb { stroke-dasharray: 3 4; }
.linie-cpu { fill: none; stroke: var(--akzent); stroke-width: 2; }
.linie-ram { fill: none; stroke: var(--ram); stroke-width: 1.75; }
.kurve-leer { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.legende { display: flex; gap: 18px; font-size: 13px; color: var(--leise); flex-wrap: wrap; }
.kurve-hinweis { margin-left: auto; }
.strich { display: inline-block; width: 16px; height: 3px; vertical-align: middle; margin-right: 6px; }
.strich.cpu { background: var(--akzent); }
.strich.ram { background: var(--ram); }

/* Detail */
.detail-kopf { display: flex; align-items: center; gap: 10px; }
.detail-kopf h2 { font-size: 24px; font-weight: 600; letter-spacing: .04em; overflow-wrap: anywhere; min-width: 0; }
.detail-wort { margin-left: auto; font-size: 14px; flex: none; }
.zustand { font-size: 14px; }
.eckdaten { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 12px; margin: 0; font-size: 14px; }
.eckdaten dt { color: var(--leise); }
.eckdaten dd { margin: 0; overflow-wrap: anywhere; }
.abschnitt { display: flex; flex-direction: column; gap: 6px; }
.werkzeug { display: flex; align-items: center; gap: 10px; min-height: 48px; border-bottom: 1px solid var(--linie); }
.werkzeug-name { flex: 1; min-width: 0; }
.schalter { width: 48px; height: 28px; border-radius: 14px; border: 0; background: var(--schalter-aus); position: relative; cursor: pointer; padding: 0; flex: none; }
.schalter[aria-checked="true"] { background: var(--schalter-an); }
.schalter-knauf { position: absolute; top: 4px; left: 4px; width: 20px; height: 20px; border-radius: 50%; background: var(--text); transition: transform .15s ease; }
.schalter[aria-checked="true"] .schalter-knauf { transform: translateX(20px); }
.sperrbox { border: 1px solid var(--halt); border-radius: 6px; padding: 12px; }
.karte-innen { border: 1px solid var(--linie-stark); border-radius: 6px; padding: 14px; background: var(--grund); }
.klapp { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.klapp form { align-self: stretch; }
.einstellungen summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; gap: 8px; font-weight: 500; }
/* display:flex nimmt dem summary sein Dreieck - ohne Zeichen sieht es aus wie Text */
.einstellungen summary::before { content: "▸"; color: var(--leise); }
.einstellungen[open] summary::before { content: "▾"; }
.einstellungen[open] { gap: 14px; }
/* "Schluessel erneuern" (gefaehrlich) deutlich weg von "Speichern" - nicht versehentlich treffen */
.einstellungen .klapp { margin-top: 6px; padding-top: 14px; border-top: 1px solid var(--linie); }
.protokoll { list-style: none; margin: 0; padding: 0; font-size: 14px; }
.protokoll li { display: grid; grid-template-columns: 6.5rem minmax(0, 1fr); gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--linie); }
.protokoll li > span:last-child { overflow-wrap: anywhere; }
.protokoll li.hinweis { display: block; }

/* Dialoge */
dialog { background: var(--seite); color: var(--text); border: 1px solid var(--linie-stark); border-radius: 8px; padding: 20px; width: min(480px, calc(100vw - 32px)); }
dialog::backdrop { background: var(--schatten); }
dialog h2 { font-size: 20px; font-weight: 600; overflow-wrap: anywhere; }

@media (max-width: 1000px) {
  .detail { max-width: none; border-left: 0; border-top: 1px solid var(--linie); }
}
@media (max-width: 600px) {
  .kopf, .gleisbild, .hauptspalte { padding-left: 16px; padding-right: 16px; }
  .detail { padding-left: 16px; padding-right: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  .schalter-knauf { transition: none; }
}
