/* DecoTrack – Bahnhof-Orientierung (docs/bahnhof-orientierung.md). Kopf, Hinweisleiste und Werkzeugleiste sind feste Ränder;
   der Plan füllt den Rest, Fenster (Abfahrten, Gleise …) schieben den Plan zusammen statt über ihn zu schweben. */
:root {
  --bhf-grund: #f4f2ed; --bhf-flaeche: #fffdf8; --bhf-rand: #cfc9bb; --bhf-text: #1d1c19; --bhf-leise: #5e5a50;
  --bhf-akzent: #0b5cad; --bhf-akzent-text: #fff; --bhf-warn: #7a3b00; --bhf-warn-grund: #fff0d6; --bhf-warn-rand: #e0a84a;
  --bhf-gleis: #3a3a37; --bhf-neben: #8c887c; --bhf-bstg: #e8e1cc; --bhf-bstg-rand: #9a916f; --bhf-route: #e4572e; --bhf-route-rand: #fff;
  --bhf-nummer: #123a63; --bhf-nummer-text: #fff; --bhf-weiche: #7a4fb5; --bhf-signal: #b8860b; --bhf-km: #2a7a4b; --bhf-zugang: #0e7c86;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bhf-grund: #1b1a17; --bhf-flaeche: #26241f; --bhf-rand: #4a463c; --bhf-text: #f1eee6; --bhf-leise: #b3ad9f;
    --bhf-akzent: #6cb2ff; --bhf-akzent-text: #0b1a2b; --bhf-warn: #ffd89a; --bhf-warn-grund: #3a2c12; --bhf-warn-rand: #8a6420;
    --bhf-gleis: #d8d4c8; --bhf-neben: #8f8a7c; --bhf-bstg: #3d3a31; --bhf-bstg-rand: #6c6652; --bhf-route: #ff7a4d; --bhf-route-rand: #1b1a17;
    --bhf-nummer: #9cc8f5; --bhf-nummer-text: #0b1a2b; --bhf-weiche: #c4a2f2; --bhf-signal: #ebc25a; --bhf-km: #7fd1a0; --bhf-zugang: #6fd2db;
  }
}
.bhf { position: fixed; inset: 0; z-index: 90; display: flex; flex-direction: column; background: var(--bhf-grund); color: var(--bhf-text); font: 15px/1.35 system-ui, sans-serif; padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
.bhf[hidden] { display: none; }
.bhf * { box-sizing: border-box; }
.bhf button { font: inherit; color: inherit; background: var(--bhf-flaeche); border: 1px solid var(--bhf-rand); border-radius: 8px; min-width: 44px; min-height: 44px; padding: 0 12px; cursor: pointer; touch-action: manipulation; }
.bhf button:hover { border-color: var(--bhf-akzent); }
.bhf button:focus-visible, .bhf input:focus-visible, .bhf [tabindex]:focus-visible { outline: 3px solid var(--bhf-akzent); outline-offset: 1px; }
.bhf button[aria-pressed="true"], .bhf button[aria-selected="true"] { background: var(--bhf-akzent); color: var(--bhf-akzent-text); border-color: var(--bhf-akzent); }
.bhf-kopf { position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: 0 6px; padding: 2px 6px; border-bottom: 1px solid var(--bhf-rand); background: var(--bhf-flaeche); }
.bhf-kopf > button:first-child { order: 0; }
.bhf-kopf h2 { order: 1; flex: 1 1 0; margin: 0; font-size: 17px; line-height: 1.2; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bhf-kopf h2 small { font-weight: 400; font-size: 12.5px; color: var(--bhf-leise); }
.bhf-umschalt { order: 2; display: flex; gap: 4px; }
.bhf-hinweis { order: 3; flex: 1 1 100%; min-width: 0; margin: 0 -6px; padding: 3px 12px; font-size: 12.5px; line-height: 18px; background: var(--bhf-warn-grund); color: var(--bhf-warn); border-top: 1px solid var(--bhf-warn-rand); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.bhf-hinweis b { font-weight: 700; }
.bhf-hinweis .mehr { opacity: .7; }
.bhf-hinweis-voll { position: absolute; z-index: 30; top: 100%; left: 0; right: 0; padding: 10px 14px; font-size: 14px; background: var(--bhf-warn-grund); color: var(--bhf-warn); border-bottom: 2px solid var(--bhf-warn-rand); box-shadow: 0 6px 16px rgba(0, 0, 0, .25); }
.bhf-hinweis-voll[hidden] { display: none; }
.bhf-mitte { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.bhf-spalte { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.bhf-planwrap { position: relative; flex: 1; min-height: 0; min-width: 0; }
.bhf-plan { position: absolute; inset: 0; background: var(--bhf-grund); touch-action: none; user-select: none; -webkit-user-select: none; overflow: hidden; }
.bhf-plan svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
/* Schublade: liegt über dem Plan (verkleinert ihn nicht), Knopfleiste bleibt frei */
.bhf-schublade { position: absolute; z-index: 20; top: 0; right: 0; bottom: 0; width: min(380px, 48%); display: flex; flex-direction: column; border-left: 1px solid var(--bhf-rand); background: var(--bhf-flaeche); box-shadow: -4px 0 14px rgba(0, 0, 0, .18); }
.bhf-schublade[hidden] { display: none; }
.bhf-schublade-zu { position: absolute; top: 2px; right: 4px; z-index: 2; }
.bhf-seite { flex: 1; min-height: 0; overflow: auto; padding: 10px 12px; padding-right: 56px; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.bhf-seite h3 { margin: 0 0 6px; font-size: 16px; min-height: 40px; display: flex; align-items: center; }
.bhf-seite h4 { margin: 12px 0 4px; font-size: 14px; }
.bhf-seite p { margin: 6px 0; }
.bhf-leise { color: var(--bhf-leise); font-size: 13px; }
.bhf-info { padding: 4px 12px; min-height: 30px; font-size: 14px; font-weight: 600; border-top: 1px solid var(--bhf-rand); background: var(--bhf-flaeche); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bhf-info[hidden] { display: none; }
.bhf-leiste { display: flex; flex-direction: row; gap: 3px; padding: 4px 6px; border-top: 1px solid var(--bhf-rand); background: var(--bhf-flaeche); }
.bhf-leiste button { flex: 1 1 0; min-width: 44px; min-height: 48px; padding: 0 1px; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.05; font-size: 11px; }
.bhf-leiste button span:first-child { font-size: 19px; line-height: 1; }
.bhf-zeile { display: flex; width: 100%; align-items: center; gap: 10px; text-align: left; min-height: 48px; margin: 0 0 4px; padding: 6px 10px; }
.bhf-zeile .zeit { font-variant-numeric: tabular-nums; font-weight: 700; min-width: 3.4em; }
.bhf-zeile .ziel { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bhf-zeile .gl { font-weight: 700; padding: 2px 8px; border-radius: 6px; background: var(--bhf-nummer); color: var(--bhf-nummer-text); }
.bhf-zeile .gl.ohne { background: transparent; color: var(--bhf-leise); border: 1px dashed var(--bhf-rand); }
.bhf-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.bhf-chips button { min-width: 52px; }
.bhf-chips button.abg { border-style: dashed; }
.bhf-schalter { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 4px; }
.bhf-schalter input { width: 22px; height: 22px; accent-color: var(--bhf-akzent); }
.bhf-fahrweg li { margin: 3px 0; }
.bhf-fahrweg { padding-left: 18px; margin: 6px 0; }
.bhf-kasten { border: 1px solid var(--bhf-warn-rand); background: var(--bhf-warn-grund); color: var(--bhf-warn); border-radius: 8px; padding: 8px 10px; margin: 8px 0; font-size: 13.5px; }
.bhf-platz { width: 100%; min-height: 84px; resize: none; border: 1px dashed var(--bhf-rand); border-radius: 8px; background: transparent; color: var(--bhf-leise); padding: 8px; font: inherit; }
.bhf-tabelle { border-collapse: collapse; width: 100%; font-size: 13px; }
.bhf-tabelle td, .bhf-tabelle th { text-align: left; padding: 3px 4px; border-bottom: 1px solid var(--bhf-rand); vertical-align: top; }
.bhf input[type="search"], .bhf input[type="text"] { width: 100%; min-height: 44px; font: inherit; padding: 0 10px; border-radius: 8px; border: 1px solid var(--bhf-rand); background: var(--bhf-grund); color: inherit; }
/* Plan (SVG): klare Rangfolge – Bahnsteiggleise kräftig mit großen Nummern, Hauptgleise mittel, Neben-/Rangiergleise dünn und blass */
.bhf svg text { font-family: system-ui, sans-serif; paint-order: stroke; stroke: var(--bhf-grund); stroke-width: 3px; stroke-linejoin: round; pointer-events: none; }
.bhf .g-gleis { fill: none; stroke: var(--bhf-gleis); stroke-width: 2.4px; vector-effect: non-scaling-stroke; stroke-linecap: round; stroke-linejoin: round; }
.bhf .g-gleis.g-bg { stroke-width: 4.4px; }
.bhf .g-rangier, .bhf .g-anschluss, .bhf .g-verbindung, .bhf .g-abstell { stroke: var(--bhf-neben); stroke-width: 1.1px; opacity: .5; }
.bhf .g-abstell { stroke-dasharray: 6 3; }
.bhf .g-tunnel { stroke-dasharray: 2 4; opacity: .7; }
.bhf .g-hit { fill: none; stroke: transparent; stroke-width: 14px; vector-effect: non-scaling-stroke; pointer-events: stroke; }
.bhf .g-hit.g-hit-neben { stroke-width: 9px; }
.bhf .g-bstg { fill: var(--bhf-bstg); stroke: var(--bhf-bstg-rand); stroke-width: 1.4px; vector-effect: non-scaling-stroke; }
.bhf .g-bstg.sel { stroke: var(--bhf-akzent); stroke-width: 3px; }
.bhf .g-bsk { display: none; }
.bhf .g-zugang { fill: none; stroke: var(--bhf-zugang); stroke-width: 1.6px; vector-effect: non-scaling-stroke; stroke-dasharray: 3 3; opacity: .8; }
.bhf .g-route { fill: none; stroke: var(--bhf-route); stroke-width: 8px; vector-effect: non-scaling-stroke; stroke-linecap: round; stroke-linejoin: round; }
.bhf .g-route-r { fill: none; stroke: var(--bhf-route-rand); stroke-width: 13px; vector-effect: non-scaling-stroke; stroke-linecap: round; stroke-linejoin: round; }
.bhf .g-wahl { fill: none; stroke: var(--bhf-akzent); stroke-width: 8px; vector-effect: non-scaling-stroke; stroke-linecap: round; opacity: .55; }
/* Fahrweg oder Auswahl: der Rest tritt zurück */
.bhf.hat-route .g-gleis, .bhf.hat-route .g-bstg { opacity: .45; }
.bhf.hat-route .m:not(.route):not(.ziel):not(.wahl) { opacity: .75; }
.bhf.hat-wahl:not(.hat-route) .g-gleis { opacity: .7; }
.bhf .m text { font-size: 12px; fill: var(--bhf-text); }
.bhf .m .hit { fill: transparent; stroke: none; }
.bhf .m-nummer rect { fill: var(--bhf-nummer); }
.bhf .m-nummer text { fill: var(--bhf-nummer-text); stroke: none; font-size: 16px; font-weight: 800; }
.bhf .m-nummer.gleisref rect { fill: var(--bhf-grund); stroke: var(--bhf-nummer); stroke-width: 1.5px; }
.bhf .m-nummer.gleisref text { fill: var(--bhf-nummer); font-size: 14px; }
.bhf .m-nummer.fahrplan rect { fill: var(--bhf-grund); stroke: var(--bhf-route); stroke-width: 2px; stroke-dasharray: 3 2; }
.bhf .m-nummer.fahrplan text { fill: var(--bhf-text); }
.bhf .m-nummer.wahl rect { stroke: var(--bhf-akzent); stroke-width: 3px; }
.bhf .m-bstg text { font-size: 12px; font-weight: 700; fill: var(--bhf-leise); }
.bhf .m-weiche .punkt { fill: var(--bhf-weiche); stroke: var(--bhf-grund); stroke-width: 1px; }
.bhf .m-weiche.wahl .punkt { r: 6px; stroke: var(--bhf-text); stroke-width: 2px; }
.bhf .m-weichennr text { fill: var(--bhf-weiche); font-weight: 700; }
.bhf .m-weiche.route .punkt { fill: var(--bhf-route); stroke: var(--bhf-route-rand); r: 4.6px; }
.bhf .m-signal path { fill: var(--bhf-signal); stroke: var(--bhf-grund); stroke-width: 1px; }
.bhf .m-km rect { fill: var(--bhf-km); }
.bhf .m-km text { fill: var(--bhf-nummer-text); stroke: none; font-size: 11px; font-weight: 700; }
.bhf .m-zugang circle { fill: var(--bhf-zugang); stroke: var(--bhf-grund); stroke-width: 1.5px; }
.bhf .m-zugang text { fill: var(--bhf-nummer-text); stroke: none; font-size: 11px; font-weight: 700; }
.bhf .m-prell rect { fill: var(--bhf-text); opacity: .6; }
.bhf .m-ort text { font-size: 12px; font-weight: 700; fill: var(--bhf-leise); }
.bhf .m-ziel circle { fill: var(--bhf-route); stroke: var(--bhf-route-rand); stroke-width: 2px; }
.bhf .m-ziel text { font-size: 13px; font-weight: 800; fill: var(--bhf-text); }
.bhf [data-i] { cursor: pointer; }
/* Ebenen */
.bhf:not(.eb-nummern) .m-nummer, .bhf:not(.eb-bstg) .m-bstg, .bhf:not(.eb-weichen) .m-weiche, .bhf:not(.eb-weichennr) .m-weichennr, .bhf:not(.eb-signale) .m-signal, .bhf:not(.eb-km) .m-km,
.bhf:not(.eb-zugaenge) .m-zugang, .bhf:not(.eb-zugaenge) .g-zugang, .bhf:not(.eb-abstell) .g-abstell, .bhf:not(.eb-abstell) .g-rangier, .bhf:not(.eb-abstell) .g-anschluss, .bhf:not(.eb-abstell) .g-verbindung, .bhf:not(.eb-abstell) .m-prell { display: none; }
/* 3D-Leiste (in der Welt, unten) */
.bhf-3d { position: fixed; left: 0; right: 0; bottom: 0; z-index: 80; display: flex; align-items: center; gap: 8px; padding: 6px 10px calc(6px + env(safe-area-inset-bottom, 0px)); background: var(--bhf-warn-grund); color: var(--bhf-warn); border-top: 1px solid var(--bhf-warn-rand); font: 12.5px/1.3 system-ui, sans-serif; }
.bhf-3d[hidden] { display: none; }
.bhf-3d span { flex: 1; min-width: 0; }
.bhf-3d button { font: inherit; min-width: 44px; min-height: 44px; border-radius: 8px; border: 1px solid var(--bhf-warn-rand); background: var(--bhf-flaeche); color: var(--bhf-text); padding: 0 12px; cursor: pointer; }
/* Breit (PC, Handy quer): Knopfleiste senkrecht rechts, Hinweis in der Kopfzeile; Hochformat: Leiste unten, Hinweis eigene schmale Zeile */
@media (min-width: 721px) {
  .bhf-mitte { flex-direction: row; }
  .bhf-leiste { flex-direction: column; width: 64px; flex: none; border-top: 0; border-left: 1px solid var(--bhf-rand); padding: 4px; }
  .bhf-leiste button { min-height: 44px; max-height: 76px; }
  .bhf-kopf { flex-wrap: nowrap; }
  .bhf-kopf h2 { flex: 0 1 auto; order: 1; }
  .bhf-hinweis { order: 2; flex: 1 1 0; margin: 0 2px; border: 1px solid var(--bhf-warn-rand); border-radius: 6px; padding: 2px 10px; }
  .bhf-umschalt { order: 3; }
}
@media (max-width: 1100px) { .bhf-kopf h2 small { display: none; } }
@media (max-width: 480px) { .bhf-hinweis .opt { display: none; } }
@media (max-width: 720px) {
  .bhf-schublade { top: auto; left: 0; width: auto; height: 58%; border-left: 0; border-top: 1px solid var(--bhf-rand); box-shadow: 0 -4px 14px rgba(0, 0, 0, .18); }
  .bhf-hinweis { font-size: 12px; }
  .bhf-kopf h2 { font-size: 16px; }
  .bhf-leiste button { min-height: 52px; }
}
@media (max-height: 520px) and (min-width: 721px) { .bhf-kopf { padding-block: 0; } .bhf-schublade { width: min(380px, 52%); } }
