:root {
  --bg: #161a15;
  --panel: #1f241d;
  --panel-2: #283024;
  --line: #3a4434;
  --text: #e8ebe2;
  --muted: #a1aa95;
  --accent: #d9a441;
  --accent-ink: #1b1608;
  --olive: #6f7f45;
  --danger: #d9534f;
  --mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --top-h: 52px;
  --coord-h: 34px;
  --panel-w: 360px;
  color-scheme: dark;
  --rl-hell: .55;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.4 var(--sans); overflow: hidden; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

/* ---------- Kopfzeile ---------- */
#topbar {
  position: fixed; inset: 0 0 auto 0; height: var(--top-h); z-index: 1001;
  display: flex; align-items: center; gap: 8px; padding: 0 10px;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; font-size: 13px; white-space: nowrap; }
.brand-mark { color: var(--accent); font-size: 20px; }
#search { position: relative; flex: 1; max-width: 760px; }
#search-input {
  width: 100%; height: 36px; padding: 0 12px; border-radius: 6px;
  background: var(--bg); border: 1px solid var(--line); outline: none;
}
#search-input:focus { border-color: var(--accent); }
#search-results {
  position: absolute; top: 40px; left: 0; right: 0; margin: 0; padding: 4px; list-style: none;
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 8px 24px rgba(0,0,0,.4);
}
#search-results li { padding: 6px 8px; border-radius: 4px; cursor: pointer; }
#search-results li:hover { background: var(--panel-2); }
#search-results small { display: block; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.icon-btn, .tool-btn {
  height: 36px; min-width: 36px; padding: 0 10px; border-radius: 6px;
  background: var(--panel-2); border: 1px solid var(--line); font-size: 16px;
}
.tool-btn { font-size: 14px; font-weight: 600; }
.icon-btn:hover, .tool-btn:hover { border-color: var(--muted); }
.tool-btn.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
/* Phase 7: einheitliche Schaltflächen in der Bedienleiste (Desktop 36 px, Touch 44 px), Suchfeld gleich hoch */
.icon-btn { display: inline-flex; align-items: center; justify-content: center; }
#topbar .icon-btn { width: 36px; padding: 0; flex: none; }
#topbar .tool-btn { display: inline-flex; align-items: center; gap: 6px; flex: none; }
#topbar .ic-dot { fill: currentColor; }
@media (pointer: coarse) { #topbar .icon-btn { width: 44px; height: 44px; } #topbar .tool-btn { height: 44px; } #search-input { height: 44px; } #search-results { top: 48px; } }

/* ---------- Seitenleiste ---------- */
#panel {
  position: fixed; top: var(--top-h); bottom: 0; left: 0; width: var(--panel-w); z-index: 1000;
  background: var(--panel); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; transition: transform .2s ease;
}
.panel-closed #panel { transform: translateX(-100%); }
.tabs { display: flex; border-bottom: 1px solid var(--line); }
.tab { flex: 1 1 0; min-width: 0; padding: 10px 2px; font-size: 11px !important; letter-spacing: .02em !important; background: none; border: 0; border-bottom: 2px solid transparent; color: var(--muted); font-weight: 600; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; }
.tab { hyphens: manual; -webkit-hyphens: manual; overflow-wrap: anywhere; line-height: 1.2; }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.tab-body { padding: 14px; overflow-y: auto; flex: 1; }
.tab-body h4 { margin: 16px 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.tab-body h4:first-child { margin-top: 0; }
.tab-body label { display: block; margin-bottom: 10px; font-size: 12px; color: var(--muted); }
.tab-body label input[type=text], .tab-body label input[type=number], .tab-body label input[type=time], .tab-body select {
  display: block; width: 100%; margin-top: 4px; height: 34px; padding: 0 8px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 5px; color: var(--text);
}
.tab-body label.check { display: flex; gap: 8px; align-items: center; color: var(--text); font-size: 14px; }
.tab-body label.sub { padding-left: 24px; }
.hint { color: var(--muted); font-size: 13px; margin: 8px 0; }
.hint.small { font-size: 12px; }
.help { padding-left: 18px; margin: 0 0 8px; color: var(--muted); }
.help li { margin-bottom: 4px; }
.help .mono { color: var(--text); }
kbd { font-family: var(--mono); background: var(--panel-2); border: 1px solid var(--line); border-radius: 3px; padding: 0 5px; color: var(--text); }

.btn-row { display: flex; gap: 6px; margin: 10px 0; flex-wrap: wrap; }
.btn-row button, .btn-like, #offline-save {
  flex: 1; height: 34px; padding: 0 10px; border-radius: 5px; display: inline-flex; align-items: center; justify-content: center;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text); font-size: 13px; font-weight: 600; white-space: nowrap; cursor: pointer;
}
.tab-body label.btn-like { display: inline-flex; margin: 0; color: var(--text); font-size: 13px; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.danger { color: #ffb4b1; }
.btn-row button:hover, .btn-like:hover { border-color: var(--muted); }

.route-head { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 10px; }
.kpi { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 8px; text-align: center; }
.kpi-v { display: block; font: 700 17px var(--mono); color: var(--accent); }
.kpi-l { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; margin-top: 12px; align-items: end; }
.field-grid label { margin-bottom: 6px; overflow-wrap: anywhere; hyphens: manual; -webkit-hyphens: manual; }
.field-grid label { font-size: 11px; }

.route-tbl { width: 100%; border-collapse: collapse; font-size: 12px; }
.route-tbl th { text-align: left; color: var(--muted); font-weight: 600; font-size: 11px; padding: 4px 3px; border-bottom: 1px solid var(--line); }
.route-tbl td { padding: 4px 3px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.route-tbl td.n { font-weight: 700; color: var(--accent); width: 18px; }
.route-tbl td.r { text-align: right; white-space: nowrap; }
.route-tbl td small { display: block; color: var(--muted); font-size: 10px; }
.route-tbl td.x { width: 20px; }
.wp-input { width: 100%; min-width: 50px; background: transparent; border: 1px solid transparent; border-radius: 3px; padding: 2px 4px; }
.wp-input:hover, .wp-input:focus { border-color: var(--line); background: var(--bg); outline: none; }
.wp-del { background: none; border: 0; color: var(--muted); font-size: 16px; padding: 0 4px; }
.wp-del:hover { color: var(--danger); }

.radio-list { display: grid; gap: 6px; }
.tab-body label.radio { display: flex; gap: 10px; align-items: center; padding: 8px 10px; margin: 0; border: 1px solid var(--line); border-radius: 6px; color: var(--text); cursor: pointer; }
.tab-body label.radio.on { border-color: var(--accent); background: rgba(217,164,65,.08); }
.radio b { display: block; font-size: 13px; }
.radio small { color: var(--muted); font-size: 12px; }

/* ---------- Karte ---------- */
#stage { position: fixed; top: var(--top-h); left: var(--panel-w); right: 0; bottom: 0; transition: left .2s ease; }
.panel-closed #stage { left: 0; }
#map { position: absolute; inset: 0 0 var(--coord-h) 0; background: #dfe3d8; }
#map.placing { cursor: crosshair; }
#crosshair { position: absolute; left: 50%; top: calc(50% - var(--coord-h) / 2); width: 28px; height: 28px; margin: -14px 0 0 -14px; pointer-events: none; z-index: 500; }
#crosshair::before, #crosshair::after { content: ""; position: absolute; background: #000; box-shadow: 0 0 0 1px rgba(255,255,255,.8); }
#crosshair::before { left: 13px; top: 0; width: 2px; height: 28px; }
#crosshair::after { top: 13px; left: 0; height: 2px; width: 28px; }

#coordbar {
  position: absolute; left: 0; right: 0; bottom: 0; height: var(--coord-h);
  display: flex; align-items: center; gap: 18px; padding: 0 12px; overflow-x: auto; white-space: nowrap;
  background: var(--panel); border-top: 1px solid var(--line); font-size: 13px;
}
.cb-item { display: flex; gap: 6px; align-items: baseline; }
.cb-l { font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.cb-primary { order: -1; }
.cb-primary .mono { color: var(--accent); font-weight: 700; font-size: 14px; }
.cb-primary .cb-l { color: var(--accent); }
.cb-scale { margin-left: auto; }

.leaflet-container { font-family: var(--sans); }
.leaflet-control-attribution { font-size: 10px; max-width: 70%; }
.leaflet-bar a { background: var(--panel); color: var(--text); border-color: var(--line); }
.leaflet-bar a:hover { background: var(--panel-2); color: var(--text); }

/* Gitterbeschriftung */
.grid-label span, .grid-square-label span {
  position: absolute; white-space: nowrap; font: 700 12px var(--mono); color: #1d4fd6;
  text-shadow: 0 0 2px #fff, 0 0 2px #fff, 0 0 3px #fff;
}
.grid-label small { font-size: 9px; font-weight: 600; }
.grid-label-top span { transform: translate(-50%, 2px); }
.grid-label-left span { transform: translate(3px, -50%); }
.grid-square-label span { transform: translate(-50%, -50%); font-size: 22px; opacity: .35; letter-spacing: .05em; }

/* Posten */
/* Achtung: kein position:relative auf .wp-icon – Leaflet positioniert Marker absolut */
.wp-dot {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: #fff; border: 3px solid #e53935; color: #b71c1c; font: 800 12px var(--sans);
  box-shadow: 0 1px 4px rgba(0,0,0,.4);
}
.wp-start .wp-dot { background: #e53935; color: #fff; }
.wp-end .wp-dot { border-radius: 4px; background: #e53935; color: #fff; }
.wp-name {
  position: absolute; left: 32px; top: 4px; white-space: nowrap; font: 700 12px var(--sans); color: #b71c1c;
  text-shadow: 0 0 2px #fff, 0 0 2px #fff, 0 0 3px #fff; pointer-events: none;
}
.leg-label span {
  position: absolute; transform: translate(-50%, -50%); white-space: nowrap;
  background: rgba(255,255,255,.92); color: #b71c1c; border: 1px solid #e53935; border-radius: 3px;
  padding: 0 4px; font: 700 11px var(--mono);
}
.leg-label .ll-short { display: none; }
.leg-label.leg-short .ll-long { display: none; }
.leg-label.leg-short .ll-short { display: block; padding: 0 3px; font-size: 10px; }
.leg-label.leg-hidden { display: none; }
/* Druck: Darstellungsvarianten Standard (nur MKZ) und Detail (MKZ und Entfernung); Minimal ohne Beschriftung */
.leg-label .ll-pm, .leg-label .ll-pd { display: none; }
body.print-mode .leg-label .ll-long, body.print-mode .leg-label .ll-short { display: none; }
body.print-mode .leg-label.leg-pm .ll-pm, body.print-mode .leg-label.leg-pd .ll-pd { display: block; white-space: nowrap; }
body.print-mode .leg-label:not(.leg-pm):not(.leg-pd) { display: none; }

/* Popup */
.leaflet-popup-content-wrapper { background: var(--panel); color: var(--text); border-radius: 8px; }
.leaflet-popup-tip { background: var(--panel); }
.leaflet-container a.leaflet-popup-close-button { color: var(--muted); }
.coord-pop { min-width: 250px; }
.cp-title { font-weight: 700; margin-bottom: 6px; }
.cp-row { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 2px 0; }
.cp-row > span { font-size: 10px; text-transform: uppercase; color: var(--muted); letter-spacing: .05em; }
.cp-row .copy { background: none; border: 0; padding: 2px 4px; border-radius: 3px; text-align: right; font-size: 12.5px; }
.cp-row .copy:hover { background: var(--panel-2); }
.cp-row:first-of-type .copy { color: var(--accent); font-weight: 700; font-size: 14px; }
.cp-actions { margin-top: 8px; }
.cp-add { width: 100%; height: 30px; border-radius: 5px; background: var(--panel-2); border: 1px solid var(--line); font-weight: 600; }


/* ---------- Rotlichtmodus ----------
   Reines Rot: Helligkeitswerte werden linear auf den Rotkanal abgebildet, Grün und Blau bleiben 0
   (auch Weiß wird rot, nicht hell). Ein Filter über die ganze Seite erfasst Karte, Seitenleiste, Bedienleiste, Koordinatenleiste, Marschstrecke,
   Eingabefelder, Hilfe, Dialoge und Meldungen. Helligkeit: --rl-hell (js/rotlicht.js, 10 bis 100 %).
   Druck (@media print) und PDF (pdfout.js liest Elementfarben, keine Filter) bleiben in normalen Kartenfarben. */
html.night { background: #000; }
html.night body { filter: grayscale(1) brightness(.14) sepia(1) hue-rotate(-40deg) saturate(20) brightness(var(--rl-hell, .55)); }
#btn-night .ic-sun, html.night #btn-night .ic-moon { display: none; }
html.night #btn-night .ic-sun { display: block; }
html.night #btn-night { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
#btn-night { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; touch-action: manipulation; }
/* helle Leaflet-Standardflächen (Quellenvermerk, Maßstabsleiste) im Rotlichtmodus abdunkeln; Druckvorschau unberührt */
html.night body:not(.print-mode) .leaflet-control-attribution { background: rgba(22, 26, 21, .82); color: #c9cfbf; }
html.night body:not(.print-mode) .leaflet-control-attribution a { color: #e8ebe2; }
html.night body:not(.print-mode) .leaflet-control-scale-line { background: rgba(22, 26, 21, .7); color: #e8ebe2; border-color: #e8ebe2; }
/* Marschstrecke: Im Rotlicht gehen Farbunterschiede verloren. Deshalb eine Perlenkette: helle runde Punkte auf
   einem dunklen Band. Sie unterscheidet sich von Wanderwegen (breite Linien ohne Punkte), Bahnlinien (eckige
   Hell-Dunkel-Abschnitte) und Straßen (durchgehend hell). */
.route-casing { display: none; }
html.night body:not(.print-mode) #map .route-casing { display: inline; stroke-opacity: .95; stroke-linecap: round; stroke-linejoin: round; }
html.night body:not(.print-mode) #map .route-line:not(.route-line-print) { stroke: #fff; stroke-width: 5px; stroke-opacity: 1; stroke-dasharray: 0.1 10; stroke-linecap: round; }
/* Helligkeitsregelung */
#rl-pop { position: fixed; z-index: 1003; width: min(280px, calc(100vw - 16px)); padding: 8px 12px 10px;
  background: var(--panel); color: var(--text); border: 1px solid var(--olive); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.5); }
#rl-pop .rl-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
#rl-pop .rl-head .icon-btn { width: 32px; min-width: 32px; height: 32px; min-height: 32px; padding: 0; font-size: 20px; line-height: 1; }
#rl-pop .rl-row { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; }
#rl-pop output { font: 700 13px var(--mono); color: var(--accent); }
#rl-pop input[type="range"] { width: 100%; height: 32px; margin: 2px 0; accent-color: var(--accent); }
#rl-pop .hint { margin: 4px 0 0; }
@media (pointer: coarse) { #rl-pop input[type="range"] { height: 44px; } #rl-pop .rl-head .icon-btn { width: 44px; min-width: 44px; height: 44px; min-height: 44px; } }

/* ---------- Druckvorschau ---------- */
#print-wrap { display: none; }
body.print-mode #print-wrap {
  display: block; position: fixed; inset: var(--top-h) 0 0 var(--panel-w); z-index: 999; overflow: auto;
  background: #50564b; padding: 0 16px 24px;
}
body.print-mode.panel-closed #print-wrap { left: 0; }
.print-toolbar {
  position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 0; margin-bottom: 6px;
  background: #50564b; color: #f0f0e8; font-size: 13px;
}
.print-toolbar .pv-title { flex: 1; min-width: 12em; }
.print-toolbar .pv-title small { display: block; font-size: 12px; opacity: .85; }
.print-toolbar .pv-nav { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.print-toolbar .pv-nav button { width: 32px; padding: 0; font-size: 18px; line-height: 1; }
.print-toolbar button:disabled { opacity: .45; }
.pv-hint { max-width: 760px; margin: 0 auto 6px; color: #f0f0e8; font-size: 12px; }
.pv-check { max-width: 760px; margin: 0 auto 10px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--text); font-size: 13px; }
.pv-check.has-warn { border-color: #d9a441; }
.pv-check summary { cursor: pointer; font-weight: 600; min-height: 28px; display: flex; align-items: center; }
.pv-check ul { list-style: none; margin: 6px 0; padding: 0; display: grid; gap: 3px; }
.pv-check li span { display: inline-block; width: 1.2em; font-weight: 800; text-align: center; }
.pv-check li.pc-ok span { color: #2e7d32; }
.pv-check li.pc-warn span { color: #d9a441; }
.pv-check li.pc-err span { color: #e53935; }
.pv-check p { margin: 4px 0 2px; font-size: 12px; opacity: .85; }
.pr-adv label { margin-top: 10px; }
fieldset.pr-cols { border: 0; padding: 0; margin: 10px 12px 12px; min-width: 0; }
fieldset.pr-cols legend { font-weight: 600; padding: 0; margin-bottom: 4px; }
#pr-cols { display: grid; gap: 2px; margin: 4px 0 8px; }
#pr-cols label.check { margin: 0; }
.print-toolbar button { height: 32px; padding: 0 14px; border-radius: 5px; background: var(--panel); border: 1px solid var(--line); font-weight: 600; }
.print-toolbar button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
#print-sheet, #print-table .pp-page {
  margin: 0 auto 20px; background: #fff; color: #000; box-shadow: 0 4px 20px rgba(0,0,0,.35);
  color-scheme: light; font-family: var(--sans);
}
/* Folgeseiten: feste Seitengröße (Papierformat), Inhalt von print.js auf die Seiten verteilt */
#print-table { color-scheme: light; font-family: var(--sans); color: #000; }
#print-table .pp-page { overflow: hidden; }
#print-table .pp-body { height: 100%; overflow: hidden; display: flow-root; }
#print-table h3.mt-cont { font-size: 10pt; margin: 0 0 3mm; }
#print-header { height: 13mm; display: flex; justify-content: space-between; align-items: flex-end; border-bottom: .4mm solid #000; padding-bottom: 1.5mm; }
.ph-title { font-size: 16pt; font-weight: 800; letter-spacing: .02em; }
.ph-meta { font-size: 8pt; font-family: var(--mono); text-align: right; line-height: 1.35; }
/* Kartenrahmen: äußere Rahmenlinie, Randstreifen mit Gitterbeschriftung, innere Rahmenlinie (Kartenfläche) */
#print-map-slot { margin-top: 0; border: .25mm solid #000; line-height: 0; position: relative; width: max-content; }
/* Kartenfläche nach Gitter-Nord: #print-map-clip ist die Kartenfläche (innere Rahmenlinie), #map liegt gedreht darin
   (Drehung und Größe setzt print.js). Beschriftungen und Marschpunktsymbole gegengedreht, damit sie aufrecht stehen. */
#print-map-clip { position: relative; overflow: hidden; outline: .4mm solid #000; }
body.print-mode #print-map-clip #map { transform-origin: 50% 50%; }
body.print-mode #map .wp-tag, body.print-mode #map .wp-sym { rotate: var(--gn-gegen, 0deg); }
body.print-mode #map .leg-label span, body.print-mode #map .grid-square-label span { rotate: var(--gn-gegen, 0deg); transform-origin: 0 0; }
/* PDF speichern: Lage ungedreht auslesen, Drehung setzt pdfout.js selbst */
body.gn-pdf #map { transform: none !important; }
body.gn-pdf #map .wp-tag, body.gn-pdf #map .wp-sym, body.gn-pdf #map .leg-label span, body.gn-pdf #map .grid-square-label span { rotate: none !important; }
/* Kartenbild (print.js): zusammengesetzte, geprüfte Grundkarte für Vorschau, Drucken und PDF speichern. Ist es aktiv, ersetzt es
   die Kartenkacheln. Ohne fertiges Kartenbild wird im Druck keine Grundkarte ausgegeben, sondern ein Hinweis (nie eine
   unvollständige Karte, auch nicht beim Drucken über das Browsermenü). */
.leaflet-kartenbild-pane { display: none; }
.leaflet-kartenbild-pane img.pk-bild { position: absolute; display: block; max-width: none; max-height: none; margin: 0; padding: 0; border: 0;
  image-rendering: auto; -webkit-user-select: none; user-select: none; }
body.print-mode.pk-aktiv #map .leaflet-kartenbild-pane { display: block; }
body.print-mode.pk-aktiv #map .leaflet-tile-pane { visibility: hidden; }
#pk-hinweis { display: none; }
@media print {
  body.print-mode:not(.pk-aktiv) #map { visibility: hidden; }
  body.print-mode:not(.pk-aktiv) #pk-hinweis { display: flex; position: absolute; inset: 0; align-items: center; justify-content: center;
    padding: 10mm; text-align: center; font: 700 12pt/1.4 var(--sans); color: #000; background: #fff; }
}
body.print-mode #map .grid-label { display: none; }
#print-frame { position: absolute; left: 0; top: 0; pointer-events: none; }
.pfl { position: absolute; white-space: nowrap; line-height: 1; font: 700 6.5pt var(--mono); color: #1d4fd6; }
.pfl small { font-size: 5pt; font-weight: 600; }
.pfl-t { transform: translate(-50%, -100%); }
.pfl-b { transform: translate(-50%, 0); }
.pfl-l { transform: translate(-100%, -50%); }
.pfl-r { transform: translate(0, -50%); }
body.print-mode #map { position: absolute; inset: auto; }
body.print-mode #map .leaflet-control-zoom, body.print-mode #map .leaflet-control-scale, body.print-mode #map .leaflet-control-attribution { display: none; }
#print-footer { height: 30mm; overflow: hidden; display: grid; grid-template-columns: 104mm minmax(0, 1.1fr) minmax(0, 1fr); gap: 1.5mm 4mm; padding-top: 2mm; font-size: 7pt; }
#print-sheet.pf-narrow #print-footer { grid-template-columns: 104mm minmax(0, 1fr); }
#print-sheet.pf-narrow #print-footer .pf-attr { grid-column: 1 / -1; display: flex; gap: 4mm; }
#print-sheet.pf-narrow #print-footer .pf-attr > * { flex: 1; }
.pf-measure { display: flex; flex-direction: column; gap: 1.2mm; }
.pf-ctrl .ctrlsvg { display: block; }
.pf-nadel { font-weight: 800; border: .3mm solid #000; padding: 0 .8mm; display: inline-block; margin: .3mm 0; }
.pf-small { font-size: 6.8pt; line-height: 1.35; }
.pf-small a { color: inherit; text-decoration: none; }
.pf-decl { display: flex; gap: 2mm; align-items: flex-start; }
.scalebar { display: block; font-family: var(--sans); }
#print-table h3 { margin: 0 0 4mm; font-size: 13pt; }
#print-table .route-tbl { font-size: 9.5pt; }
#print-table .route-tbl th, #print-table .route-tbl td { border-bottom: .25mm solid #999; padding: 1.5mm 2mm; color: #000; }
#print-table .route-tbl td.n { color: #b71c1c; }
#print-table .route-tbl td small { color: #555; }
#print-table .route-tbl tr.sum td { font-weight: 700; border-top: .5mm solid #000; border-bottom: .5mm solid #000; background: #e4e4e4; }
/* Marschtabelle (Druck): schwarz-weiß-tauglich, dezente Zeilenhinterlegung, Kopf wiederholt sich, keine geteilten Zeilen */
#print-table .mt-tbl { width: 100%; font-size: 8.5pt; }
#print-table .mt-tbl th { text-align: right; vertical-align: bottom; font-size: 7.5pt; border-bottom: .4mm solid #000; padding: 1.2mm 1.2mm; }
#print-table .mt-tbl th.h-mp, #print-table .mt-tbl th.h-koord, #print-table .mt-tbl th.h-notiz { text-align: left; }
#print-table .mt-tbl td { padding: 1.3mm 1.2mm; }
#print-table .mt-tbl tbody tr.alt:not(.sum) td { background: #f1f1f1; }
#print-table .mt-tbl td.c-mp { min-width: 26mm; white-space: nowrap; }
#print-table .mt-tbl td.c-mp small { white-space: nowrap; }
#print-table .mt-tbl td.r small { white-space: normal; max-width: 22mm; margin-left: auto; font-size: 6.5pt; }
#print-table .mt-tbl td.c-mp .n { color: #000; margin-right: 1mm; }
#print-table .mt-tbl td.c-notiz { min-width: 30mm; }
#print-table .mt-tbl thead { display: table-header-group; }
#print-table .mt-tbl tr { break-inside: avoid; page-break-inside: avoid; }
.mt-kopf { display: grid; grid-template-columns: repeat(auto-fill, minmax(42mm, 1fr)); gap: 1mm 4mm; margin: 0 0 3mm; font-size: 8pt; }
.mt-kopf div { display: flex; flex-direction: column; border-left: .4mm solid #000; padding-left: 1.5mm; }
.mt-kopf dt { font-size: 6.5pt; text-transform: uppercase; letter-spacing: .03em; color: #333; }
.mt-kopf dd { margin: 0; font-weight: 700; }
.mt-desc { margin-top: 4mm; break-inside: auto; }
.mt-desc h4, .mt-notes h4 { margin: 0 0 2mm; font-size: 10pt; }
.mt-desc ol { list-style: none; margin: 0; padding: 0; font-size: 8.5pt; }
.mt-desc li { padding: 1.2mm 0; border-bottom: .2mm solid #999; break-inside: avoid; }
.mt-notes { margin-top: 6mm; break-inside: avoid; }
.mt-lines { border-top: .2mm solid #999; }
.mt-line { height: 7.7mm; border-bottom: .2mm solid #999; }
.pv-msg { max-width: 760px; margin: 0 auto 10px; padding: 8px 12px; border: 1px solid var(--accent); border-radius: 6px; background: var(--panel); color: var(--text); font-size: 13px; }
.pt-note { font-size: 8pt; color: #333; margin-top: 4mm; }

@media print {
  html, body { overflow: visible; height: auto; background: #fff; }
  html.night body { filter: none; }
  html.night { background: #fff; }
  #rl-pop { display: none !important; }
  #topbar, #panel, #stage, #meldungen, #hilfe-wrap, .print-toolbar { display: none !important; }
  body.print-mode #print-wrap { position: static; display: block; padding: 0; background: #fff; overflow: visible; }
  #print-sheet, #print-table .pp-page { margin: 0; box-shadow: none; }
  #print-table .pp-page { page-break-before: always; break-before: page; }
  .pv-msg, .pv-hint, .pv-check { display: none !important; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---------- Mobil ---------- */
@media (max-width: 760px) {
  :root { --panel-w: 100vw; }
  .brand, .tool-btn .lbl { display: none; }
  .icon-btn, .tool-btn { padding: 0 !important; width: 36px; min-width: 36px; justify-content: center; }
  .top-actions { gap: 4px !important; }
  #topbar { gap: 4px; padding: 0 8px; }
  #panel { top: auto; height: 58vh; width: 100%; border-right: 0; border-top: 1px solid var(--line); border-radius: 12px 12px 0 0; }
  .panel-closed #panel { transform: translateY(100%); }
  #stage, .panel-closed #stage { left: 0; }
  body:not(.panel-closed) #coordbar { bottom: 58vh; }
  .cb-item:not(.cb-primary) { display: none; }
  body.print-mode #print-wrap { left: 0; }
}

/* Nachträge */
.mgrs-sub { font-size: 11px; color: var(--muted); padding-left: 5px; white-space: nowrap; }
#print-sheet { overflow: hidden; }
@media print { #print-sheet { break-after: avoid; page-break-after: avoid; } }
.areas-list { display: grid; gap: 6px; margin-bottom: 10px; }
.area-item { text-align: left; padding: 8px 10px; border-radius: 6px; background: var(--bg); border: 1px solid var(--line); }
.area-item:hover { border-color: var(--accent); }
.area-item b { display: block; font-size: 13px; }
.area-item small { color: var(--muted); font-size: 12px; }
.cmd { margin: 6px 0; padding: 8px 10px; background: var(--bg); border: 1px solid var(--line); border-radius: 5px;
  font: 11.5px/1.45 var(--mono); white-space: pre-wrap; word-break: break-all; cursor: copy; color: var(--accent); }
.cmd:hover { border-color: var(--accent); }
.guide-link { display: block; padding: 10px 12px; margin-bottom: 12px; border: 1px solid var(--accent); border-radius: 6px;
  background: rgba(217,164,65,.08); color: var(--text); text-decoration: none; }
.guide-link small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.guide-link:hover { background: rgba(217,164,65,.16); }
a.icon-btn { display: inline-flex; align-items: center; justify-content: center; color: var(--text); text-decoration: none; }
a.btn-like { text-decoration: none; }

/* Legende */
.lg-group { margin-bottom: 10px; }
.lg-title { font-size: 11px; font-weight: 700; color: var(--text); margin: 6px 0 4px; }
.lg-list { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 3px; }
.lg-list li { display: grid; grid-template-columns: 52px minmax(0, 1fr); align-items: center; gap: 8px; font-size: 13px; }
.lg-sym { display: block; background: #f6f5ef; border-radius: 3px; padding: 0 4px; box-sizing: content-box; }
.lg-badge { display: inline-block; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  color: var(--accent-ink); background: var(--accent); border-radius: 3px; padding: 0 5px; }
#tab-legend a, #tab-layers a { color: var(--accent); }
.nowrap { white-space: nowrap; }

/* Zeichenerklärung im Druck */
.print-legend { margin-top: 8mm; }
.print-legend h3 { margin: 0 0 3mm; font-size: 13pt; }
.plg-cols { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2mm 6mm; }
#print-table .lg-title { color: #000; font-size: 8.5pt; margin: 1mm 0; }
#print-table .lg-list li { font-size: 8pt; color: #000; grid-template-columns: 13mm 1fr; gap: 2mm; }
#print-table .lg-sym { background: #fff; border: .2mm solid #ccc; }

/* Posten-Editor */
.route-tbl tr.sel td { background: rgba(217,164,65,.10); }
.wp-sel { background: none; border: 1px solid var(--line); border-radius: 4px; color: var(--accent); font-weight: 800; width: 24px; height: 24px; padding: 0; }
.wp-sel:hover { border-color: var(--accent); }
.wp-meta { font-size: 11px; color: var(--muted); padding-left: 5px; }
#wp-editor { margin-top: 10px; padding: 10px; border: 1px solid var(--accent); border-radius: 6px; background: var(--bg); }
.ed-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.ed-close { background: none; border: 0; color: var(--muted); font-size: 18px; }
.field-grid.two { grid-template-columns: 1fr 1fr; margin-top: 0; }
#route-end { margin: 6px 0 0; }
.route-tbl td small { display: block; }

/* Extras */
.rs-row { display: grid; grid-template-columns: 20px minmax(0, 1fr) 110px 22px; gap: 6px; align-items: center; margin-bottom: 6px; }
.rs-n { font-weight: 800; color: #ce93d8; }
.rs-row .small { font-size: 11px; }
.tab-body .rs-row label { margin: 0; font-size: 10px; }
.tab-body .rs-row input { height: 28px !important; }
.rs-del { background: none; border: 0; color: var(--muted); font-size: 16px; }
.rs-add-wp { margin-left: 6px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 4px; color: var(--text); font-size: 12px; }
.rs-tip { font-weight: 800; }
#ex-answer { flex: 2; min-width: 0; height: 34px; padding: 0 8px; background: var(--bg); border: 1px solid var(--line); border-radius: 5px; font-family: var(--mono); }
#ex-feedback.ok { color: #9ccc65; }
#ex-feedback.bad { color: #ff8a80; }
.ex-icon div { width: 26px; height: 26px; transform: rotate(45deg); background: #7b1fa2; border: 2px solid #fff; display: grid; place-items: center;
  box-shadow: 0 1px 4px rgba(0,0,0,.4); }
.ex-icon div { color: #fff; font: 800 13px var(--sans); }
.ex-icon div > * { transform: rotate(-45deg); }
.help-d { border-bottom: 1px solid var(--line); padding: 6px 0; }
.help-d summary { cursor: pointer; font-weight: 600; font-size: 13px; }
.help-d .hint { margin: 6px 0 2px; }
.help-tbl { border-collapse: collapse; font-size: 13px; color: var(--muted); margin: 4px 0 6px; }
.help-tbl th, .help-tbl td { text-align: left; padding: 2px 12px 2px 0; border-bottom: 1px solid var(--line, rgba(127,127,127,.25)); }
.help-tbl th { font-weight: 600; }

/* Dokumente: Laufkarte, Planzeiger */
#doc-wrap { display: none; }
body.doc-mode #doc-wrap { display: block; position: fixed; inset: var(--top-h) 0 0 0; z-index: 1500; overflow: auto; background: #50564b; padding: 0 16px 24px; }
.doc-page { width: 210mm; min-height: 297mm; margin: 0 auto 20px; background: #fff; color: #000; padding: 8mm; box-shadow: 0 4px 20px rgba(0,0,0,.35); font-family: var(--sans); color-scheme: light; }
.lk-card { border: .4mm solid #000; padding: 4mm; height: 132mm; overflow: hidden; display: flex; flex-direction: column; gap: 2.5mm; }
.lk-head { display: flex; justify-content: space-between; gap: 4mm; border-bottom: .3mm solid #000; padding-bottom: 2mm; }
.lk-title { font-size: 15pt; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; }
.lk-sub { font-size: 9pt; }
.lk-fields { display: grid; gap: 3mm; font-size: 9pt; text-align: right; align-content: end; }
.lk-tbl { width: 100%; border-collapse: collapse; font-size: 9pt; }
.lk-tbl th { text-align: left; font-size: 7.5pt; border-bottom: .3mm solid #000; padding: 1mm; }
.lk-tbl td { border-bottom: .2mm solid #999; padding: 1.4mm 1mm; height: 7.5mm; vertical-align: middle; }
.lk-tbl td small { display: block; font-size: 7pt; color: #444; }
.lk-tbl td.n { width: 8mm; font-weight: 800; }
.lk-tbl td:nth-child(3), .lk-tbl td:nth-child(4) { width: 28mm; border-left: .2mm solid #999; }
.lk-safe { margin-top: auto; font-size: 7.6pt; border: .3mm solid #000; padding: 1.5mm 2mm; background: #f3f3f3; }
.lk-cut { text-align: center; font-size: 8pt; color: #777; margin: 4mm 0; letter-spacing: .1em; }
.pz-svg { display: block; }

@media print {
  body.doc-mode #print-wrap, body.doc-mode #topbar, body.doc-mode #panel, body.doc-mode #stage, body.doc-mode .print-toolbar { display: none !important; }
  body.doc-mode #doc-wrap { position: static; display: block; padding: 0; background: #fff; overflow: visible; }
  body.doc-mode .doc-page { margin: 0; box-shadow: none; break-after: page; }
  body:not(.doc-mode) #doc-wrap { display: none !important; }
}
.pf-melde { margin-bottom: 1mm; }

/* Kompakte Posten (Druck / dichte Route) */
.wp-sym, .wp-lead, .wp-tag { display: none; }
.wp-compact .wp-dot, .wp-compact .wp-name { display: none; }
.wp-compact .wp-sym { display: block; position: absolute; left: 4px; top: 4px; width: 20px; height: 20px; overflow: visible; }
.wp-compact .wp-sym * { fill: none; stroke: #d81b60; stroke-width: .72; }
/* Druck: Symbole in physischen Maßen (viewBox in mm), Strichstärke 0,35 mm, Nummer 9 pt, Marschangaben 8 pt, einheitlich Magenta */
body.print-mode .wp-compact .wp-sym { left: calc(14px - 4mm); top: calc(14px - 4mm); width: 8mm; height: 8mm; }
body.print-mode .wp-compact .wp-sym * { stroke-width: .35; }
body.print-mode .wp-compact .wp-tag { font-size: 9pt; line-height: 1.15; color: #d81b60; }
body.print-mode .wp-compact .wp-lead line { stroke-width: .7; }
body.print-mode .route-line:not(.route-line-print) { display: none; }
body.print-mode .leg-label span { background: none; border: 0; color: #d81b60; font-size: 8pt; padding: 0;
  text-shadow: 0 0 1.5px #fff, 0 0 1.5px #fff, 0 0 2.5px #fff, 0 0 2.5px #fff; }
body.print-mode .leg-label.leg-short .ll-short { font-size: 8pt; }
.wp-compact .wp-lead { display: block; position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; }
.wp-compact .wp-lead line { stroke: #d81b60; stroke-width: 1; }
.wp-compact .wp-tag {
  display: block; position: absolute; white-space: nowrap; pointer-events: none;
  font: 800 11px/14px var(--sans); color: #ad1457; padding: 0 2px;
  text-shadow: 0 0 2px #fff, 0 0 2px #fff, 0 0 3px #fff, 0 0 3px #fff;
}
body.print-mode .route-line-print { stroke-width: .35mm; stroke-dasharray: 2mm 1mm; }
body.print-mode .grid-square-label span { opacity: .2; }
.wp-compact .wp-tag { max-width: 150px; overflow: hidden; text-overflow: ellipsis; }

/* Gebiet herunterladen */
button.wide { width: 100%; height: 38px; border-radius: 5px; font-weight: 700; margin: 4px 0 8px; }
button.primary:disabled { opacity: .45; cursor: not-allowed; }
.progress { height: 8px; background: var(--bg); border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: var(--accent); transition: width .4s; }
.progress-bar.err { background: var(--danger, #e53935); }
.seed-prog-row { display: flex; gap: 8px; align-items: flex-start; justify-content: space-between; }
.seed-prog-row .hint { margin: 6px 0; }
.link-btn { background: none; border: 0; color: var(--accent); font-size: 12px; padding: 6px 0; white-space: nowrap; cursor: pointer; }
details.adv { margin: 8px 0 4px; }
details.adv summary { cursor: pointer; font-size: 12px; color: var(--muted); }
details.adv[open] summary { margin-bottom: 4px; }

#panel-foot { padding: 8px 14px; border-top: 1px solid var(--line); font-size: 11px; color: var(--muted); }
#panel-foot a { color: var(--muted); }
#panel-foot a:hover { color: var(--accent); }

/* ---------- Kurzanleitung beim ersten Besuch ---------- */
button.linkish { background: none; border: 0; padding: 0; color: var(--accent); text-decoration: underline; }

/* Übung „Koordinaten ermitteln“: Fadenkreuz, Kreuzmitte = gesuchter Punkt (auch im Ausdruck) */
.ex-cross { position: relative; }
.ex-cross svg { display: block; overflow: visible; }
.ex-cross svg circle, .ex-cross svg path { stroke: #7b1fa2; stroke-width: 2; fill: none; }
.ex-cross svg .dot { fill: #7b1fa2; stroke: none; }
.ex-cross.ok svg circle, .ex-cross.ok svg path { stroke: #2e7d32; }
.ex-cross.ok svg .dot { fill: #2e7d32; }
.ex-cross.bad svg circle, .ex-cross.bad svg path { stroke: #c62828; }
.ex-cross.bad svg .dot { fill: #c62828; }
.ex-cross span { position: absolute; left: 26px; top: -6px; font: 800 13px var(--sans); color: #fff; background: #7b1fa2; border-radius: 9px; padding: 0 5px; line-height: 17px; }
.ex-cross.ok span { background: #2e7d32; }
.ex-cross.bad span { background: #c62828; }
#ex-opts { grid-template-columns: 1fr 1fr; }
#ex-opts label:last-child { grid-column: 1 / -1; }
.ex-cross.ok svg .dot, .ex-cross.bad svg .dot { stroke: none; }

/* Schmale Seitenleiste (Tablet 360 px, Handy): keine Trennung mitten im Wort, Felder bleiben in ihrer Spalte */
.tab { overflow-wrap: normal; word-break: normal; padding: 10px 1px; font-size: 10.5px !important; letter-spacing: 0 !important; }
@media (max-width: 359px) { .tab { font-size: 9.5px !important; } }
.field-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: stretch; }
.field-grid.two, #ex-opts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field-grid label { display: flex; flex-direction: column; justify-content: space-between; min-width: 0; }
.tab-body input, .tab-body select { min-width: 0; max-width: 100%; }
/* iOS/WebKit: Zeitfeld hat sonst eine Mindestbreite und eigene Textlage */
.tab-body input[type=time] { -webkit-appearance: none; appearance: none; line-height: 32px; text-align: left; }
.tab-body input[type=time]::-webkit-date-and-time-value { text-align: left; }
#search { min-width: 0; }
#search-input { min-width: 0; text-overflow: ellipsis; }
@media (max-width: 359px) {
  #panel .route-tbl { font-size: 11px; }
  #panel .route-tbl th, #panel .route-tbl td { padding: 3px 1px; }
  #panel .route-tbl td small { font-size: 9px; }
  #panel .route-tbl td.x { width: 16px; }
  #panel .route-tbl .wp-del { padding: 0 2px; }
  #panel .tab-body { padding: 12px 10px; }
}
#route-table { overflow-x: auto; }

/* ---------- UI Phase 1: Hauptmenü mit Symbolen, Menüpunkt „Marsch“ ---------- */
.ic { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
#btn-panel { display: inline-flex; align-items: center; justify-content: center; }
#btn-panel .ic-fill { stroke-width: 1.4; }
.tab { display: flex; flex-direction: column; align-items: center; gap: 3px; min-height: 52px; justify-content: center; }
.tab .ic { width: 22px; height: 22px; }
.tab.active { color: var(--accent); }
.tab.active .tab-l { color: var(--text); }
.tab:focus-visible, .btn-row button:focus-visible, .wp-sel:focus-visible, .wp-name-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Kennzahlenübersicht */
.route-head { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpi { min-width: 0; padding: 8px 4px; }
.kpi-l { display: block; hyphens: manual; -webkit-hyphens: manual; overflow-wrap: normal; line-height: 1.25; }
#route-sum { margin: 0 0 10px; }

/* einklappbare Bereiche (Marscheinstellungen, Import und Export, Zeichenerklärung) */
details.sec { border: 1px solid var(--line); border-radius: 6px; margin: 0 0 12px; background: var(--bg); }
details.sec > summary { list-style: none; cursor: pointer; min-height: 44px; padding: 0 12px; display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
details.sec > summary::-webkit-details-marker { display: none; }
details.sec > summary::after { content: ""; width: 8px; height: 8px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); margin: -4px 4px 0 8px; transition: transform .15s; }
details.sec[open] > summary::after { transform: rotate(-135deg); margin-top: 4px; }
details.sec[open] > summary { color: var(--text); border-bottom: 1px solid var(--line); }
details.sec > :not(summary) { margin-left: 12px; margin-right: 12px; }
details.sec .field-grid { margin-top: 10px; }
details.sec #legend-body { margin-top: 10px; }

/* Marschpunktübersicht: ausgewählter Marschpunkt goldgelb hinterlegt, ausreichend große Bedienflächen */
.route-tbl tr.sel td { background: rgba(217,164,65,.22); }
.route-tbl tr.sel td.n .wp-sel { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.wp-sel { width: 32px; height: 32px; }
.wp-name-btn { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 4px 5px; min-height: 30px; font-weight: 600; color: var(--text);
  overflow-wrap: anywhere; border-radius: 3px; }
.wp-name-btn:hover { background: var(--panel-2); }
.wp-del { min-width: 32px; min-height: 32px; font-size: 18px; }
.route-tbl tr.ed-row > td { padding: 0 0 8px; background: rgba(217,164,65,.08); }
.wp-editor { margin: 0; padding: 10px; border: 1px solid var(--accent); border-radius: 6px; background: var(--bg); }
.wp-editor .ed-close { min-width: 32px; min-height: 32px; }
.wp-editor label input[type=text], .wp-editor label input[type=number] { height: 38px; }
.wp-editor .btn-row { margin-bottom: 0; }
.wp-editor .btn-row button { height: 40px; }
.ed-times { color: var(--text); }

/* Streckenbearbeitung, Import und Export: Symbol und Beschriftung, untereinander auf schmalen Seitenleisten */
.act-row { flex-direction: column; }
.act-row button, .act-row .btn-like { justify-content: flex-start; gap: 10px; height: 42px; width: 100%; flex: none; }
.btn-row button:disabled { opacity: .4; cursor: not-allowed; border-color: var(--line); }
.confirm { border: 1px solid var(--danger); border-radius: 6px; padding: 8px 10px; margin: -4px 0 10px; background: rgba(217,83,79,.08); }
.confirm p { margin: 0 0 4px; font-size: 13px; }
.confirm .btn-row button { height: 40px; }

/* Karte: ausgewählter Marschpunkt mit dezentem goldgelbem Ring */
.wp-selected .wp-dot { box-shadow: 0 0 0 3px rgba(217,164,65,.95), 0 0 0 6px rgba(217,164,65,.30), 0 1px 4px rgba(0,0,0,.4); }
.wp-compact.wp-selected .wp-sym { filter: drop-shadow(0 0 2px #d9a441) drop-shadow(0 0 2px #d9a441); }

/* Karteninformationsfenster im olivgrünen Erscheinungsbild */
.wp-popup .leaflet-popup-content-wrapper { background: var(--panel); border: 1px solid var(--olive); box-shadow: 0 6px 20px rgba(0,0,0,.45); }
.wp-popup .leaflet-popup-tip { background: var(--panel); border: 1px solid var(--olive); }
.wp-popup .cp-title { color: var(--accent); }
.cp-desc { margin: 6px 0 2px; font-size: 12.5px; color: var(--text); overflow-wrap: anywhere; }
.cp-edit { width: 100%; min-height: 36px; border-radius: 5px; background: var(--accent); color: var(--accent-ink); border: 1px solid var(--accent); font-weight: 700; }
.leaflet-tooltip.wp-tip { background: var(--panel); color: var(--text); border: 1px solid var(--olive); box-shadow: 0 2px 8px rgba(0,0,0,.4); }
.leaflet-tooltip-top.wp-tip::before { border-top-color: var(--olive); }
#tab-layers a, #sec-legend a { color: var(--accent); }

@media (max-width: 359px) {
  .tab .ic { width: 20px; height: 20px; }
  .kpi-v { font-size: 15px; }
}
@media (pointer: coarse) {
  .tab-body label input[type=text], .tab-body label input[type=number], .tab-body label input[type=time], .tab-body select { height: 40px; }
}
#panel .route-tbl td.x { width: 34px; padding-left: 0; padding-right: 0; }
#panel .route-tbl td.n { width: 34px; }

/* ---------- UI Phase 2: Menüpunkt „Karte“ ---------- */
fieldset.radio-list { border: 0; padding: 0; margin: 0 0 6px; min-width: 0; }
#grid-opts { margin-bottom: 4px; }
.tab-body label.range-l { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 2px 8px; }
.range-l output { font: 600 12px var(--mono); color: var(--text); }
.range-l input[type=range] { grid-column: 1 / -1; width: 100%; height: 32px; margin: 0; accent-color: var(--accent); }
.sub-hint { padding-left: 24px; margin-top: -6px; }
.tab-body label.radio:focus-within, .tab-body label.check:focus-within { outline: 2px solid var(--accent); outline-offset: 1px; }
body[data-coord="dms"] .mgrs-sub, body[data-coord="dec"] .mgrs-sub { white-space: normal; }

/* Nordrichtungspfeil (Geografisch-Nord) */
.north-ctl { position: relative; clear: both; }
.north-btn { width: 40px; height: 52px; padding: 3px 0 2px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0;
  background: var(--panel); border: 2px solid var(--olive); border-radius: 6px; color: var(--accent); box-shadow: 0 1px 5px rgba(0,0,0,.4); }
.north-btn:hover, .north-btn[aria-expanded="true"] { border-color: var(--accent); }
.north-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.north-btn svg { width: 22px; height: 28px; overflow: visible; }
.north-btn .na-up { fill: var(--accent); stroke: var(--accent-ink); stroke-width: .8; stroke-linejoin: round; }
.north-btn text { font: 800 10px var(--sans); fill: var(--text); }
.north-sub { font: 600 8.5px/1 var(--sans); color: var(--muted); letter-spacing: .02em; }
.north-info { position: absolute; right: 48px; top: 0; width: min(300px, calc(100vw - 84px)); max-height: min(60vh, 420px); overflow: auto;
  background: var(--panel); color: var(--text); border: 1px solid var(--olive); border-radius: 8px; padding: 8px 12px; box-shadow: 0 6px 20px rgba(0,0,0,.45); font-size: 12.5px; }
.north-info .hint { font-size: 12.5px; margin: 6px 0; }
.ni-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.ni-head b { color: var(--accent); font-size: 13px; }
.ni-close { min-width: 32px; min-height: 32px; background: none; border: 0; color: var(--muted); font-size: 18px; }
body.print-mode .north-ctl { display: none; }
@media (pointer: coarse) { .leaflet-touch .leaflet-bar a { width: 40px; height: 40px; line-height: 40px; } }

/* ---------- UI Phase 3: Menüpunkt „Orientierung“ ---------- */
/* Hauptmenü: Breite nach Beschriftung, damit „Orientierung“ und „Ausbildung“ nicht getrennt werden */
.tab { flex: 1 1 auto; padding-left: 2px; padding-right: 2px; }
.tab .tab-l { white-space: nowrap; }
@media (max-width: 400px) { .tab { font-size: 9.5px !important; } }
@media (max-width: 340px) { .tab { font-size: 9px !important; } .tab .ic { width: 19px; height: 19px; } }

.orient-lead { margin: 0 0 10px; }
details.tool { border: 1px solid var(--line); border-radius: 8px; background: var(--bg); margin: 0 0 10px; }
details.tool[open] { border-color: var(--olive); }
details.tool > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 6px 12px; }
details.tool > summary::-webkit-details-marker { display: none; }
details.tool > summary::after { content: ""; margin-left: auto; width: 8px; height: 8px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); flex: none; transition: transform .15s; }
details.tool[open] > summary::after { transform: rotate(-135deg); }
details.tool > summary .ic { width: 26px; height: 26px; color: var(--accent); }
details.tool > summary .ic-dot { fill: currentColor; }
details.tool > summary .ic-box { fill: rgba(111,127,69,.5); stroke: var(--olive); }
details.tool > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 8px; }
.tool-t { display: flex; flex-direction: column; min-width: 0; }
.tool-t b { font-size: 14px; }
.tool-t small { color: var(--muted); font-size: 12px; }
.tool-body { padding: 0 12px 10px; border-top: 1px solid var(--line); }
.tool-desc { font-size: 13px; color: var(--text); margin: 10px 0 6px; }
.tool-more { margin: 8px 0 0; font-size: 12px; }
.tool-actions button { height: 44px; }
.tool-result { border: 1px solid var(--line); border-left: 4px solid var(--olive); border-radius: 6px; padding: 8px 10px; margin: 10px 0; background: var(--panel); }
.tool-result.ok { border-left-color: var(--accent); }
.tool-result.warn { border-left-color: var(--danger); }
.tool-result.empty { background: none; }
.tool-result .hint { margin: 4px 0; }
.res-k { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.res-v { font-size: 16px; font-weight: 700; color: var(--accent); overflow-wrap: anywhere; }
.res-big { font-size: 30px; font-weight: 800; color: var(--accent); line-height: 1.15; }
.res-big small { font-size: 14px; font-weight: 600; color: var(--text); }
.res-msg { color: #ffb4b1; font-size: 12.5px; margin: 4px 0; }
.res-row { display: flex; justify-content: space-between; gap: 10px; padding: 3px 0; font-size: 12.5px; border-bottom: 1px solid rgba(58,68,52,.6); }
.res-row:last-child { border-bottom: 0; }
.res-row span { color: var(--muted); }
.res-row b { text-align: right; }
.sm-done { color: #9ccc65; margin: 4px 0 0; }
.tool-fig { display: flex; flex-direction: column; align-items: center; margin: 4px 0; }
.fig-cap { text-align: center; margin: 2px 0 0; }

/* Standortbestimmung */
.pick-hint { display: flex; align-items: center; gap: 8px; border: 1px dashed var(--accent); border-radius: 6px; padding: 6px 8px; margin: 6px 0; font-size: 12.5px; color: var(--text); background: rgba(217,164,65,.08); }
.pick-hint span { flex: 1; }
.pick-hint button, .pick-banner button { min-height: 36px; padding: 0 12px; border-radius: 5px; background: var(--panel-2); border: 1px solid var(--line); font-weight: 700; }
.pick-banner { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); z-index: 900; display: flex; align-items: center; gap: 10px;
  max-width: calc(100% - 130px); padding: 6px 8px 6px 12px; background: var(--panel); color: var(--text); border: 2px solid var(--accent); border-radius: 8px; box-shadow: 0 4px 14px rgba(0,0,0,.45); font-size: 13px; }
@media (max-width: 760px) { .pick-banner { left: 8px; right: 60px; transform: none; max-width: none; } }
.rs-list { display: grid; gap: 6px; margin: 8px 0; }
.rs-list .rs-row { display: grid; grid-template-columns: 26px minmax(0, 1fr) 36px 36px; gap: 6px; align-items: center; margin: 0; padding: 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); }
.rs-list .rs-n { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: #7b1fa2; color: #fff; font-weight: 800; font-size: 12px; }
.rs-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.rs-main .mono { overflow-wrap: anywhere; }
.tab-body .rs-main label { margin: 2px 0 0; font-size: 11px; }
.tab-body .rs-main input { height: 36px !important; }
.rs-main input.bad { border-color: var(--danger) !important; }
.rs-show, .rs-list .rs-del { width: 36px; height: 36px; display: grid; place-items: center; background: none; border: 1px solid var(--line); border-radius: 5px; color: var(--muted); padding: 0; }
.rs-show:hover, .rs-list .rs-del:hover { border-color: var(--accent); color: var(--text); }
.rs-show .ic { width: 18px; height: 18px; }
.rs-pos svg { display: block; overflow: visible; }
.rs-pos rect { fill: var(--accent); stroke: #1b1608; stroke-width: 2; }
.rs-pos path { stroke: #1b1608; stroke-width: 2; }
.rs-pos span { position: absolute; left: 32px; top: 6px; white-space: nowrap; font: 800 12px var(--sans); color: #1b1608; background: var(--accent); border-radius: 3px; padding: 0 4px; }

/* Hindernisumgehung */
.hu-svg { width: 100%; max-width: 300px; height: auto; }
.hu-svg .hu-plan { stroke: #e53935; stroke-width: 2.5; stroke-dasharray: 8 6; }
.hu-svg .hu-obst { fill: rgba(111,127,69,.45); stroke: var(--olive); stroke-width: 1.5; }
.hu-svg .hu-obst-t { fill: var(--text); font: 600 11px var(--sans); }
.hu-svg .hu-path { fill: none; stroke: var(--accent); stroke-width: 3.5; stroke-linejoin: round; }
.hu-svg .hu-arr { fill: none; stroke: var(--accent); stroke-width: 3.5; stroke-linejoin: round; stroke-linecap: round; }
.hu-svg .hu-pt { fill: var(--accent); }
.hu-svg text { fill: var(--text); font: 700 11px var(--mono); }
.hu-steps { margin: 0; padding-left: 20px; font-size: 12.5px; }
.hu-steps li { margin: 2px 0; }

/* Sonnenstand */
fieldset.seg { display: flex; border: 1px solid var(--line); border-radius: 6px; padding: 0; margin: 8px 0; overflow: hidden; min-width: 0; }
.tab-body fieldset.seg label { flex: 1; margin: 0; font-size: 13px; color: var(--text); }
fieldset.seg input { position: absolute; opacity: 0; pointer-events: none; }
fieldset.seg span { display: flex; align-items: center; justify-content: center; min-height: 40px; cursor: pointer; font-weight: 600; }
fieldset.seg input:checked + span { background: var(--accent); color: var(--accent-ink); }
fieldset.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: -3px; }
.tab-body input[type=date] { display: block; width: 100%; margin-top: 4px; height: 34px; padding: 0 8px; background: var(--bg); border: 1px solid var(--line); border-radius: 5px; color: var(--text); -webkit-appearance: none; appearance: none; line-height: 32px; }
.sun-svg { width: 150px; height: 150px; }
.sun-svg .sr-ring { fill: var(--panel); stroke: var(--olive); stroke-width: 2; }
.sun-svg .sr-ticks line { stroke: var(--muted); stroke-width: 1.2; }
.sun-svg text { fill: var(--text); font: 700 11px var(--sans); text-anchor: middle; }
.sun-svg .sr-n { fill: var(--accent); }
.sun-svg .sr-dir { stroke: var(--accent); stroke-width: 2.5; }
.sun-svg .sr-sun { fill: var(--accent); stroke: #1b1608; stroke-width: 1.5; }
.sun-svg .sr-c { fill: var(--text); }
.sun-svg.below .sr-dir { stroke: var(--muted); stroke-dasharray: 4 3; }
.sun-svg.below .sr-sun { fill: var(--panel-2); stroke: var(--muted); }
.sun-ref svg { display: block; overflow: visible; }
.sun-ref circle, .sun-ref path { fill: none; stroke: #d9a441; stroke-width: 2.5; filter: drop-shadow(0 0 1.5px #000); }
.sun-ref span { position: absolute; left: 36px; top: 8px; white-space: nowrap; font: 700 11px var(--sans); color: #1b1608; background: rgba(217,164,65,.92); border-radius: 3px; padding: 0 4px; }
@media (pointer: coarse) { .tab-body input[type=date] { height: 40px; } }

/* ===== Phase 4: Menüpunkt „Ausbildung“ ===== */
.tab-body label textarea { display: block; width: 100%; margin-top: 4px; padding: 6px 8px; min-height: 52px; resize: vertical;
  background: var(--bg); border: 1px solid var(--line); border-radius: 5px; color: var(--text); font: 14px/1.35 var(--sans); }
@media (pointer: coarse) { .tab-body label textarea { font-size: 16px; } }
.tool-body h5.ex-h, h5.ex-h { margin: 14px 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); }
.area-links { margin: 4px 0 8px; padding-left: 18px; }
.area-links li { margin: 4px 0; }
.area-links a { color: var(--text); }
/* Inhaltsverzeichnis des Leitfadens (Seitenleiste und Vollbildseite) */
ol.lf-toc { list-style: none; margin: 8px 0 4px; padding: 0; }
ol.lf-toc > li { margin: 0 0 8px; }
ol.lf-toc > li > b { display: block; font-size: 13px; color: var(--text); }
ol.lf-toc .lf-n { color: var(--accent); font-family: var(--mono); margin-right: 4px; }
ol.lf-toc ul { list-style: none; margin: 2px 0 0; padding: 0 0 0 26px; }
ol.lf-toc ul li { margin: 3px 0; }
ol.lf-toc button.linkish { text-align: left; font-size: 13px; color: var(--muted); text-decoration: none; }
ol.lf-toc button.linkish:hover { color: var(--accent); text-decoration: underline; }
/* Übungen: Ablauf in vier Schritten */
ol.ex-steps { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; list-style: none; margin: 8px 0 10px; padding: 0; counter-reset: st; }
ol.ex-steps li { counter-increment: st; font-size: 11px; line-height: 1.2; color: var(--muted); border-top: 3px solid var(--line); padding-top: 4px; overflow-wrap: anywhere; hyphens: manual; }
ol.ex-steps li::before { content: counter(st) " "; font-weight: 800; }
ol.ex-steps li.done { border-top-color: var(--olive); }
ol.ex-steps li.on { border-top-color: var(--accent); color: var(--text); font-weight: 700; }
fieldset.ex-pick span { padding: 4px 8px; text-align: center; line-height: 1.25; }
#ex-task p { margin: 0 0 6px; }
#ex-error { margin: 4px 0; }
.ex-help { margin: 8px 0; }
.ex-eval-v { font-weight: 700; padding: 6px 8px; border-radius: 5px; margin: 0 0 6px; }
.ex-eval-v.ok { background: rgba(46,125,50,.18); color: #9ccc65; }
.ex-eval-v.bad { background: rgba(198,40,40,.18); color: #ef9a9a; }
table.ex-eval-t { width: 100%; border-collapse: collapse; font-size: 12.5px; table-layout: fixed; }
table.ex-eval-t th { width: 32%; text-align: left; vertical-align: top; color: var(--muted); font-weight: 600; padding: 4px 6px 4px 0; }
table.ex-eval-t td { vertical-align: top; padding: 4px 0; overflow-wrap: anywhere; }
table.ex-eval-t tr + tr > * { border-top: 1px solid var(--line); }
/* Übungsmodus: ausgeblendet bzw. gesperrt, was die Lösung verrät */
.ex-banner { display: none; }
body.ex-mode .ex-banner { display: flex; }
body.ex-mode #coordbar, body.ex-mode .leaflet-popup-pane { display: none !important; }
#topbar button:disabled, #search-input:disabled { opacity: .45; cursor: not-allowed; }
/* Laufkarten: Bausteine */
.lk-blank { display: inline-block; border-bottom: .2mm solid #000; height: 3.6mm; vertical-align: bottom; }
.lk-box { border: .2mm solid #000; padding: 1.2mm 2mm; font-size: 8.5pt; }
.lk-ref { font-size: 7.8pt; margin: 0; }
.lk-notes { border: .2mm solid #000; height: 16mm; padding: 1mm 2mm; font-size: 7.5pt; }
.lk-full .lk-notes { height: 30mm; }
.lk-safe p { margin: 1mm 0 0; }
.lk-safe-f { display: flex; flex-wrap: wrap; gap: 1mm 5mm; }
.lk-tail { display: flex; flex-direction: column; gap: 2.5mm; margin-top: auto; }
.lk-tail .lk-safe { margin-top: 0; }
.lk-foot { display: flex; justify-content: space-between; font-size: 7pt; color: #555; }
.lk-card .lk-foot { margin-top: auto; }
.lk-tail + .lk-foot { margin-top: 0; }
.lk-warn { font-size: 9pt; font-weight: 800; text-transform: uppercase; text-align: right; border: .4mm solid #000; padding: 1mm 2mm; align-self: center; }
.lk-tbl { table-layout: fixed; }
.lk-tbl th:nth-child(1) { width: 9mm; }
.lk-tbl th:nth-child(3), .lk-tbl th:nth-child(4) { width: 28mm; }
.lk-tbl td { overflow-wrap: anywhere; }
.lk-tbl thead th { vertical-align: bottom; }
.lk-tbl-a { font-size: 8pt; }
.lk-tbl-a th:nth-child(2) { width: auto; }
.lk-tbl-a th:nth-child(3) { width: 38mm; }
.lk-tbl-a th:nth-child(4) { width: 17mm; }
.lk-tbl-a th:nth-child(5) { width: 16mm; }
.lk-tbl-a th:nth-child(6) { width: 10mm; }
.lk-tbl-a th:nth-child(7) { width: 15mm; }
.lk-tbl-a th:nth-child(8) { width: 26mm; }
.lk-tbl-a td:nth-child(3), .lk-tbl-a td:nth-child(4) { width: auto; border-left: 0; }
.lk-tbl-a td:nth-child(8) { border-left: .2mm solid #999; }
.lk-full .lk-card { height: 281mm; }
.doc-page.lk-page { height: 297mm; min-height: 0; overflow: hidden; }
.lk-measure { position: absolute; left: -10000px; top: 0; visibility: hidden; font-family: var(--sans); color: #000; }
@media print { body.doc-mode .doc-page:last-child { break-after: auto; } }
/* Ausbildungsgrundlagen: Vollbildseite */
#lf-wrap { position: fixed; inset: 0; z-index: 2000; background: var(--bg); color: var(--text); display: flex; flex-direction: column; }
#lf-wrap[hidden] { display: none !important; }
.lf-bar { display: flex; align-items: center; gap: 10px; min-height: var(--top-h); padding: 6px max(16px, env(safe-area-inset-right, 0px)) 6px max(16px, env(safe-area-inset-left, 0px));
  background: var(--panel); border-bottom: 1px solid var(--line); flex: none; }
.lf-bar b { flex: 1; min-width: 0; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lf-back { min-height: 36px; padding: 0 12px; border-radius: 5px; background: var(--accent); color: var(--accent-ink); border: 0; font-weight: 700; white-space: nowrap; cursor: pointer; }
#lf-jump { display: none; height: 36px; max-width: 46vw; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 5px; padding: 0 6px; }
.lf-body { flex: 1; overflow: auto; display: grid; grid-template-columns: 260px minmax(0, 760px); gap: 32px; justify-content: center;
  padding: 16px max(16px, env(safe-area-inset-right, 0px)) 40px max(16px, env(safe-area-inset-left, 0px)); -webkit-overflow-scrolling: touch; }
.lf-nav { position: sticky; top: 0; align-self: start; max-height: calc(100vh - var(--top-h) - 32px); overflow: auto; }
.lf-doc { min-width: 0; }
.lf-lead { font-size: 15px; margin: 0 0 6px; }
.lf-note { font-size: 12px; color: var(--muted); margin: 0 0 16px; }
.lf-ch { margin: 0 0 28px; }
.lf-ch h2 { margin: 0 0 10px; padding-bottom: 6px; border-bottom: 2px solid var(--olive); font-size: 20px; }
.lf-ch h2 span { color: var(--accent); font-family: var(--mono); margin-right: 6px; }
.lf-topic { margin: 0 0 18px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); scroll-margin-top: 12px; }
.lf-topic h3 { margin: 0 0 8px; font-size: 16px; }
.lf-topic dl { margin: 0; }
.lf-topic dt { margin: 10px 0 2px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); }
.lf-topic dt:first-child { margin-top: 0; }
.lf-topic dd { margin: 0; font-size: 14px; }
.lf-topic dd .hint { color: var(--text); font-size: 14px; margin: 4px 0; }
.lf-merk { font-weight: 700; border-left: 3px solid var(--accent); padding-left: 8px; }
.lf-steps { margin: 4px 0; padding-left: 20px; }
.lf-steps li { margin: 2px 0; }
.lf-offen { margin: 10px 0 0; font-size: 12px; color: var(--muted); border-top: 1px dashed var(--line); padding-top: 6px; }
.lf-tblwrap { overflow-x: auto; }
.lf-fig { max-width: 320px; }
.lf-fig .hu-svg { width: 100%; height: auto; }
body.lf-mode { overflow: hidden; }
@media (max-width: 900px) {
  .lf-body { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .lf-nav { display: none; }
  #lf-jump { display: block; }
}
@media (max-width: 420px) { .lf-bar b { display: none; } #lf-jump { max-width: none; flex: 1; min-width: 0; } }
@media print {
  body.lf-mode > *:not(#lf-wrap) { display: none !important; }
  body.lf-mode #lf-wrap { position: static; background: #fff; color: #000; }
  body.lf-mode .lf-bar, body.lf-mode .lf-nav { display: none; }
  body.lf-mode .lf-body { display: block; overflow: visible; padding: 0; }
  body.lf-mode .lf-topic { background: #fff; break-inside: avoid; }
}
.lk-intro { display: flex; flex-direction: column; gap: 2.5mm; }
/* Hinweis auf neue Version */
#update-bar { position: fixed; left: 50%; bottom: 44px; transform: translateX(-50%); z-index: 2500; display: flex; align-items: center; gap: 12px;
  padding: 8px 10px 8px 14px; background: var(--panel); border: 1px solid var(--accent); border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.4); max-width: calc(100vw - 32px); }
#update-bar button { min-height: 36px; padding: 0 14px; border-radius: 5px; font-weight: 700; }
#print-footer .pf-attr .pf-small { overflow-wrap: anywhere; }

/* ================= Phase 6: Hilfe und Bedienung ================= */

/* 6.5 Meldungen: Farbe + Symbol + Typbezeichnung (für Bildschirmleser) */
:root { --m-ok: #3f9a4f; --m-info: #3b82c4; --m-warn: #d9a441; --m-err: #d9534f; }
/* Lage: am PC unten mittig über der Karte, oberhalb von Maßstab und Quellenangaben (verdeckt weder Bedienleisten noch Quellenangaben);
   auf schmalen Bildschirmen oben unter der Bedienleiste, weil unten die Seitenleiste liegt */
#meldungen { position: fixed; z-index: 3000; bottom: calc(var(--coord-h) + 40px); left: calc(var(--panel-w) + (100vw - var(--panel-w)) / 2); transform: translateX(-50%);
  width: min(480px, calc(100vw - var(--panel-w) - 24px)); display: flex; flex-direction: column-reverse; gap: 6px; pointer-events: none; }
.panel-closed #meldungen { left: 50%; width: min(480px, calc(100vw - 24px)); }
.meldung { pointer-events: auto; display: flex; align-items: flex-start; gap: 8px; padding: 8px 6px 8px 10px; border-radius: 7px; background: #0d0f0c; color: var(--text);
  border: 1px solid var(--line); border-left: 5px solid var(--m-info); box-shadow: 0 6px 20px rgba(0,0,0,.45); font-size: 13.5px; line-height: 1.4; }
.meldung .m-text { flex: 1; min-width: 0; padding-top: 3px; overflow-wrap: anywhere; }
.meldung .m-sym { flex: none; width: 22px; height: 22px; margin-top: 1px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.meldung .m-sym .m-ring { stroke-width: 0; }
.meldung .m-sym .m-dot { fill: currentColor; stroke-width: 1.6; }
.m-erfolg { border-left-color: var(--m-ok); } .m-erfolg .m-sym { color: #fff; } .m-erfolg .m-ring { fill: var(--m-ok); }
.m-info { border-left-color: var(--m-info); } .m-info .m-sym { color: #fff; } .m-info .m-ring { fill: var(--m-info); }
.m-warnung { border-left-color: var(--m-warn); background: #1f1a0c; } .m-warnung .m-sym { color: #1b1608; } .m-warnung .m-ring { fill: var(--m-warn); }
.m-fehler { border-left-color: var(--m-err); background: #220f0e; } .m-fehler .m-sym { color: #fff; } .m-fehler .m-ring { fill: var(--m-err); }
.m-laden { border-left-color: var(--muted); }
.m-spin { flex: none; width: 18px; height: 18px; margin: 3px 2px 0; border: 2.5px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: m-dreh .8s linear infinite; }
@keyframes m-dreh { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .m-spin { animation-duration: 2.4s; } }
.meldung .m-akt { flex: none; min-height: 32px; padding: 0 10px; border-radius: 5px; border: 0; background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.meldung .m-zu { flex: none; width: 32px; height: 32px; border: 0; background: none; color: var(--muted); font-size: 20px; line-height: 1; border-radius: 5px; }
.meldung .m-zu:hover { color: var(--text); background: var(--panel-2); }
.pv-msg.meldung { box-shadow: none; }
@media (pointer: coarse) { .meldung .m-zu, .meldung .m-akt { min-width: 44px; min-height: 44px; } }
/* Eingabefelder: ungültige Eingabe unmittelbar kennzeichnen */
.tab-body input[aria-invalid="true"], #search-input[aria-invalid="true"] { border-color: var(--m-err) !important; box-shadow: 0 0 0 1px var(--m-err); }
.feld-fehler { display: flex; gap: 6px; align-items: flex-start; margin-top: 4px; color: #f0a19e; font-size: 12px; line-height: 1.35; grid-column: 1 / -1; }
.feld-fehler .m-sym { flex: none; width: 16px; height: 16px; fill: none; stroke: #fff; stroke-width: 2.6; stroke-linecap: round; }
.feld-fehler .m-ring { fill: var(--m-err); stroke-width: 0; }
.rcc-list { margin: 4px 0 8px; padding-left: 18px; font-size: 13px; }
.rcc-list li { margin: 2px 0; }

/* 6.2 Informationssymbole: Klick und Antippen, keine Mouseover-Hilfe */
/* Symbol steht direkt hinter der Beschriftung; im Quelltext nach dem Feld, damit das Feld das beschriftete Element bleibt */
.tab-body label.has-info { display: flex; flex-direction: row; flex-wrap: wrap; align-items: center; align-content: space-between; column-gap: 2px; }
.tab-body label.has-info > .info-btn { order: 1; }
.tab-body label.has-info > input, .tab-body label.has-info > select, .tab-body label.has-info > textarea { order: 2; flex: 1 0 100%; }
.tab-body label.has-info > .feld-fehler { order: 3; flex: 1 0 100%; }
.tab-body label.check.has-info, .tab-body label.radio.has-info { display: flex; }
.info-btn { flex: none; width: 28px; height: 28px; padding: 3px; margin: -4px -2px -4px 0; border: 0; border-radius: 50%; background: none; color: var(--muted); cursor: pointer; vertical-align: middle; }
.info-btn svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.info-btn svg .ic-dot { fill: currentColor; }
.info-btn:hover, .info-btn[aria-expanded="true"] { color: var(--accent); }
.info-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; }
@media (pointer: coarse) { .info-btn { width: 40px; height: 40px; padding: 9px; margin: -10px -8px -10px -4px; } }
.info-slot { display: inline-block; }
th .info-slot .info-btn { width: 22px; height: 22px; padding: 2px; margin: -4px 0 -4px 1px; }
@media (pointer: coarse) { th .info-slot .info-btn { width: 36px; height: 36px; padding: 8px; margin: -10px -8px; } }
.info-pop { grid-column: 1 / -1; margin: 0 0 10px; padding: 8px 10px; background: var(--panel-2); border: 1px solid var(--olive); border-radius: 7px; font-size: 12.5px; color: var(--text); }
.info-pop p { margin: 4px 0 0; }
.ip-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.ip-head b { color: var(--accent); }
.ip-close { min-width: 32px; min-height: 32px; border: 0; background: none; color: var(--muted); font-size: 18px; }
@media (pointer: coarse) { .ip-close { min-width: 44px; min-height: 44px; } }
.ip-more { font-size: 12px; }
.info-demo { display: inline-grid; place-items: center; width: 18px; height: 18px; border: 1.5px solid var(--muted); border-radius: 50%; font: 700 11px var(--sans); color: var(--muted); }

/* 6.1 Hilfebereich: Seitenfenster rechts, auf dem Smartphone ganze Fläche */
#hilfe-wrap { position: fixed; inset: 0; z-index: 2100; background: rgba(10,12,9,.55); display: flex; justify-content: flex-end; }
#hilfe-wrap[hidden] { display: none !important; }
.hilfe-card { width: min(600px, 100%); height: 100%; display: flex; flex-direction: column; background: var(--bg); border-left: 1px solid var(--line); box-shadow: -8px 0 28px rgba(0,0,0,.4); }
.hilfe-bar { display: flex; align-items: center; gap: 10px; min-height: var(--top-h); flex: none; background: var(--panel); border-bottom: 1px solid var(--line);
  padding: max(6px, env(safe-area-inset-top, 0px)) max(14px, env(safe-area-inset-right, 0px)) 6px 14px; }
.hilfe-bar b { flex: 1; font-size: 15px; }
.hilfe-bar .lf-back { min-height: 44px; }
.hilfe-body { flex: 1; overflow: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  padding: 12px max(14px, env(safe-area-inset-right, 0px)) max(28px, env(safe-area-inset-bottom, 0px)) 14px; }
.hilfe-lead { margin: 0 0 10px; }
.hilfe-sec { border: 1px solid var(--line); border-radius: 8px; background: var(--panel); margin: 0 0 8px; }
.hilfe-sec[open] { border-color: var(--olive); }
.hilfe-sec > summary { min-height: 44px; display: flex; align-items: center; padding: 0 12px; font-weight: 700; cursor: pointer; list-style: none; }
.hilfe-sec > summary::-webkit-details-marker { display: none; }
.hilfe-sec > summary::after { content: "▾"; margin-left: auto; color: var(--muted); transition: transform .15s; }
.hilfe-sec[open] > summary::after { transform: rotate(180deg); }
.hilfe-in { padding: 0 12px 10px; font-size: 13.5px; }
.hilfe-in .help { padding-left: 18px; margin: 6px 0; }
.hilfe-in .help li { margin: 5px 0; }
.hilfe-h3 { margin: 4px 0 8px; font-size: 15px; color: var(--accent); }
.hilfe-h4 { margin: 14px 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.hilfe-steps { margin: 0; padding-left: 22px; }
.hilfe-steps li { margin: 0 0 10px; }
.hilfe-steps li::marker { color: var(--accent); font-weight: 800; }
.hilfe-steps b, .hilfe-steps span { display: block; }
.hilfe-steps span { color: var(--muted); }
.hilfe-steps .linkish { min-height: 32px; }
.hilfe-note { border-left: 3px solid var(--accent); padding: 2px 0 2px 10px; }
.hilfe-note p { margin: 6px 0; }
.hilfe-tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.hilfe-tbl th, .hilfe-tbl td { text-align: left; vertical-align: top; padding: 5px 6px; border-bottom: 1px solid var(--line); }
.hilfe-tbl thead th { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.hilfe-q { border-top: 1px solid var(--line); }
.hilfe-q > summary { min-height: 40px; display: flex; gap: 8px; align-items: baseline; padding: 10px 0 6px; cursor: pointer; }
.hilfe-q > summary small { color: var(--muted); }
.hilfe-dl { margin: 0 0 10px; }
.hilfe-dl dt { margin: 8px 0 2px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--accent); }
.hilfe-dl dd { margin: 0; overflow-wrap: anywhere; }
.hilfe-dl a, .hilfe-in a { color: var(--accent); }
.hilfe-pr th { width: 38%; font-weight: 600; }
.pr-st { font-weight: 700; white-space: nowrap; }
.pr-ja .pr-st { color: #7fcf8c; } .pr-nein .pr-st { color: #f0a19e; } .pr-bedingt .pr-st { color: var(--m-warn); } .pr-offen .pr-st, .pr-na .pr-st { color: var(--muted); }
body.hilfe-mode { overflow: hidden; }
@media (max-width: 760px) { .hilfe-card { width: 100%; border-left: 0; } }
#search-results li.sr-attr { cursor: default; font-size: 11px; color: var(--muted); padding: 6px 8px 2px; border-top: 1px solid var(--line); border-radius: 0; }
#search-results li.sr-attr:hover { background: none; }
#search-results li.sr-attr a { color: var(--muted); }

/* 6.4 Mobile Bedienung */
html, body { overscroll-behavior: none; }
#btn-search, #search-close { display: none; }
#topbar { padding-left: max(10px, env(safe-area-inset-left, 0px)); padding-right: max(10px, env(safe-area-inset-right, 0px)); }
@media (pointer: coarse) {
  /* iOS vergrößert die Seite beim Antippen von Feldern unter 16 px Schrift: verhindert unbeabsichtigte Seitenbewegungen */
  input, select, textarea, #search-input { font-size: 16px !important; }
  .icon-btn, .tool-btn { min-height: 44px; min-width: 44px; }
  .btn-row button, .btn-row .btn-like, .act-row button { min-height: 44px; }
  .wp-del { min-width: 40px; min-height: 40px; }
}
@media (max-width: 760px) {
  #panel { padding-bottom: env(safe-area-inset-bottom, 0px); }
  .leaflet-bottom { margin-bottom: env(safe-area-inset-bottom, 0px); }
  /* Quellenangaben bei eingeblendeter Seitenleiste über der Seitenleiste sichtbar halten */
  body:not(.panel-closed) #map .leaflet-bottom { bottom: 58vh; }
  .leaflet-control-attribution { max-width: calc(100vw - 16px); }
}
/* Schmale Bildschirme: Suche als Lupensymbol, Schaltflächen so groß wie möglich (Ziel 44 × 44 px) */
@media (max-width: 480px) {
  #topbar { --tb: clamp(36px, calc((100vw - 32px) / 6 - 2px), 44px); gap: 4px !important; }
  #topbar .icon-btn, #topbar .tool-btn { width: var(--tb) !important; min-width: var(--tb) !important; height: var(--tb) !important; min-height: var(--tb) !important; }
  .top-actions { gap: 4px !important; }
  #btn-search { display: inline-flex; align-items: center; justify-content: center; }
  #search { display: none; }
  body.search-open #search { display: flex; gap: 4px; position: absolute; left: max(8px, env(safe-area-inset-left, 0px)); right: max(8px, env(safe-area-inset-right, 0px)); top: 50%; transform: translateY(-50%); max-width: none; z-index: 2; }
  body.search-open #search-close { display: inline-flex; align-items: center; justify-content: center; flex: none; font-size: 22px; }
  body.search-open #search-input { height: var(--tb); }
  body.search-open #search-results { top: calc(var(--tb) + 4px); right: calc(var(--tb) + 4px); }
  body.search-open .top-actions, body.search-open #btn-panel, body.search-open #btn-search { visibility: hidden; }
}
/* Smartphone im Querformat: Seitenleiste links statt unten, damit die Karte nutzbar bleibt */
@media (max-width: 760px) and (orientation: landscape) and (min-aspect-ratio: 4/3) {
  :root { --panel-w: min(340px, 50vw); }
  #panel { top: var(--top-h); bottom: 0; height: auto; width: var(--panel-w); border-radius: 0; border-top: 0; border-right: 1px solid var(--line);
    padding-left: env(safe-area-inset-left, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
  .panel-closed #panel { transform: translateX(-100%); }
  body:not(.panel-closed) #stage { left: var(--panel-w); }
  body:not(.panel-closed) #coordbar { bottom: 0; }
  body:not(.panel-closed) #map .leaflet-bottom { bottom: 0; }
}
/* Bildschirmtastatur offen (iOS): Seitenleiste über die Tastatur rücken */
@media (max-width: 760px) and (orientation: portrait) {
  body.kb-open #panel { bottom: var(--kb, 0px); height: min(58vh, calc(var(--vvh, 100vh) - var(--top-h))); }
}
#coordbar { padding-left: max(12px, env(safe-area-inset-left, 0px)); padding-right: max(12px, env(safe-area-inset-right, 0px)); }
body.print-mode #meldungen, body.doc-mode #meldungen { top: auto; bottom: 16px; left: 50%; width: min(480px, calc(100vw - 24px)); }
@media (max-width: 760px) {
  #meldungen { bottom: auto; top: calc(var(--top-h) + 6px); left: 50%; width: calc(100vw - 16px); flex-direction: column; }
  body:has(#meldungen .meldung) .pick-banner { top: auto; bottom: 10px; }
}
@media (max-width: 760px) and (orientation: landscape) and (min-aspect-ratio: 4/3) {
  body:not(.panel-closed) #meldungen { left: calc(var(--panel-w) + (100vw - var(--panel-w)) / 2); width: calc(100vw - var(--panel-w) - 16px); }
}
