:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --panel-soft: #fbfcfd;
  --hover: #f0f3f7;
  --chip: #eef1f5;
  --highlight: #fff7e8;
  --active: #f2f7fd;
  --ok-bg: #e3f4e6;
  --warn-bg: #fdf0dc;
  --danger-bg: #fdecec;
  --map-bg: #e8ecf0;
  --border: #d9dde3;
  --text: #1f2933;
  --muted: #6b7480;
  --accent: #1b6ac9;
  --accent-dark: #14509a;
  --danger: #c62828;
  --ok: #2a9d3f;
  --warn: #e08a00;
  color-scheme: light;
  --topbar-h: 52px;
  --statusbar-h: 26px;
  --sidebar-w: 380px;
  --radius: 8px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  color: var(--text);
}


/* Dunkelmodus: wie das System (sofern nicht „hell“ gewählt) oder ausdrücklich „dunkel“ */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111418; --panel: #1b1f24; --panel-soft: #20252b; --hover: #262c33; --chip: #2a3138; --highlight: #3a2f14; --active: #1f2d3f;
    --ok-bg: #173b22; --warn-bg: #3d2a0c; --danger-bg: #3d1a1a; --map-bg: #1b1f24; --border: #313942; --text: #e6e9ed; --muted: #9aa3ad;
    --accent: #4f8fe0; --accent-dark: #86b4ec; --danger: #ef5350; --ok: #4caf50; --warn: #ffb74d; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111418; --panel: #1b1f24; --panel-soft: #20252b; --hover: #262c33; --chip: #2a3138; --highlight: #3a2f14; --active: #1f2d3f;
  --ok-bg: #173b22; --warn-bg: #3d2a0c; --danger-bg: #3d1a1a; --map-bg: #1b1f24; --border: #313942; --text: #e6e9ed; --muted: #9aa3ad;
  --accent: #4f8fe0; --accent-dark: #86b4ec; --danger: #ef5350; --ok: #4caf50; --warn: #ffb74d; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); display: flex; flex-direction: column; overflow: hidden; }
h2 { margin: 0 0 8px; font-size: 18px; }
h3 { margin: 12px 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
h3 .muted, h3 .badge { text-transform: none; letter-spacing: 0; font-weight: normal; }
p { margin: 6px 0; }
code { font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; word-break: break-all; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.grow { flex: 1; min-width: 0; }
kbd { font: 11px/1 ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--chip); border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 4px; padding: 2px 5px; }

/* Kopfzeile */
.topbar {
  height: var(--topbar-h); display: flex; align-items: center; gap: 8px; padding: 0 12px;
  background: var(--panel); border-bottom: 1px solid var(--border); flex: 0 0 auto; z-index: 30;
}
.brand { font-weight: 700; font-size: 16px; color: var(--accent); white-space: nowrap; }
.topbar input.draft-name { width: 220px; flex: 0 0 220px; font-weight: 600; }
.topbar input.draft-name:read-only { background: var(--chip); }
.dirty { color: var(--warn); font-size: 18px; line-height: 1; }
.search { position: relative; flex: 1 1 200px; max-width: 520px; min-width: 120px; }
.search input { width: 100%; }
.search-results {
  position: absolute; top: 100%; left: 0; right: 0; margin: 4px 0 0; padding: 4px 0; list-style: none;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 6px 24px rgba(0,0,0,.12);
  max-height: 320px; overflow: auto; z-index: 40;
}
.search-results li { padding: 0; }
.search-results li.muted { padding: 8px 12px; }
.search-results button { width: 100%; text-align: left; background: none; border: 0; padding: 8px 12px; cursor: pointer; font: inherit; color: inherit; }
.search-results button:hover { background: var(--hover); }
.topbar-actions { display: flex; gap: 6px; align-items: center; margin-left: auto; }

/* Eingaben & Buttons */
input[type="text"], input[type="search"], input[type="number"], select, textarea {
  font: inherit; color: inherit; background: var(--panel); border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(27,106,201,.35); border-color: var(--accent); }
textarea { resize: vertical; }
.btn, button.btn {
  font: inherit; font-weight: 600; color: var(--text); background: var(--panel); border: 1px solid var(--border); border-radius: 6px;
  padding: 7px 12px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; white-space: nowrap;
}
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-dark); }
.btn.danger { color: var(--danger); border-color: #f0b8b8; }
.btn.danger:hover { background: var(--danger-bg); }
.btn.small { padding: 5px 9px; font-size: 13px; }
.btn:disabled, .icon-btn:disabled, .tool:disabled { opacity: .45; cursor: default; }
.icon-btn {
  font: inherit; font-size: 17px; line-height: 1; width: 34px; height: 34px; border: 1px solid transparent; background: transparent;
  border-radius: 6px; cursor: pointer; color: var(--text);
}
.icon-btn:hover:not(:disabled) { background: var(--chip); border-color: var(--border); }
.btn-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.field { display: block; margin: 8px 0; font-size: 12px; color: var(--muted); }
.field > input, .field > select, .field > textarea { margin-top: 3px; color: var(--text); font-size: 14px; }
.check { display: flex; align-items: center; gap: 8px; margin: 8px 0; cursor: pointer; }
.radio-row { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 6px 0; }
.radio { display: flex; align-items: center; gap: 5px; cursor: pointer; }
.badge { font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 999px; text-transform: none; letter-spacing: 0; vertical-align: middle; white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.muted { background: var(--chip); color: var(--muted); }

/* Arbeitsbereich */
.workspace { flex: 1; display: flex; min-height: 0; position: relative; }
.sidebar {
  width: var(--sidebar-w); flex: 0 0 auto; background: var(--panel); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; min-height: 0; transition: margin-left .2s ease;
}
body.sidebar-hidden .sidebar { margin-left: calc(-1 * var(--sidebar-w)); }
.tabs { display: flex; border-bottom: 1px solid var(--border); flex: 0 0 auto; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  flex: 1 1 auto; font: inherit; font-size: 12.5px; font-weight: 600; background: none; border: 0; border-bottom: 3px solid transparent; padding: 10px 7px; cursor: pointer; color: var(--muted); white-space: nowrap;
}
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab { display: none; padding: 12px 14px; overflow: auto; flex: 1; }
.tab.active { display: block; }
.box { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; margin: 10px 0; background: var(--panel-soft); }
.box h3:first-child { margin-top: 0; }
details.box summary { cursor: pointer; font-weight: 600; }
.map-wrap { flex: 1; min-width: 0; position: relative; display: flex; flex-direction: column; }
.map { flex: 1; min-height: 0; background: var(--map-bg); position: relative; overflow: hidden; outline: none; }
.map:focus-visible { box-shadow: inset 0 0 0 3px rgba(27,106,201,.4); }

/* Karte (eigene Slippy-Map) */
.smap-canvas { position: absolute; inset: 0; display: block; }
.smap-zoom { position: absolute; top: 12px; left: 12px; display: flex; flex-direction: column; border: 1px solid #b5bcc5; border-radius: 6px; overflow: hidden; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.2); z-index: 5; }
.smap-zoom button { width: 32px; height: 32px; border: 0; background: var(--panel); color: var(--text); font: 700 20px/1 system-ui, sans-serif; cursor: pointer; color: #222; }
.smap-zoom button + button { border-top: 1px solid var(--border); }
.smap-zoom button:hover { background: var(--hover); }
.smap-scale { position: absolute; left: 12px; bottom: 26px; height: 16px; border: 2px solid #333; border-top: 0; font: 11px/12px system-ui, sans-serif; padding: 0 4px; background: rgba(255,255,255,.75); color: #222; white-space: nowrap; box-sizing: content-box; z-index: 5; }
.smap-attribution { position: absolute; right: 0; bottom: 0; font: 11px system-ui, sans-serif; background: rgba(255,255,255,.8); padding: 2px 6px; color: #333; z-index: 5; }
.smap-attribution a { color: var(--accent); }
.tooltip { position: absolute; left: 0; top: 0; pointer-events: none; background: rgba(31,41,51,.92); color: #fff; font-size: 12px; padding: 4px 8px; border-radius: 4px; white-space: nowrap; z-index: 6; }
.pin { position: absolute; left: 0; top: 0; z-index: 6; pointer-events: none; }
.pin-marker { width: 14px; height: 14px; border-radius: 50% 50% 50% 0; background: var(--accent); border: 2px solid #fff; transform: translate(-7px, -16px) rotate(-45deg); box-shadow: 0 1px 4px rgba(0,0,0,.4); }
.pin-label { position: absolute; left: 10px; top: -36px; background: var(--panel); border: 1px solid var(--border); border-radius: 6px; padding: 3px 4px 3px 8px; font-size: 12px; white-space: nowrap; box-shadow: 0 2px 8px rgba(0,0,0,.15); pointer-events: auto; display: flex; align-items: center; gap: 4px; }
.pin-label .icon-btn { width: 22px; height: 22px; font-size: 12px; }
.banner { display: flex; align-items: center; gap: 10px; padding: 8px 14px; background: var(--highlight); border-bottom: 1px solid #f2d9a6; color: #7a4d00; font-size: 13px; z-index: 5; }
.banner[hidden] { display: none; }
.banner span { flex: 1; }

/* Werkzeuge */
.tool-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 8px; }
.tool-grid .tool {
  position: relative; font: inherit; font-weight: 600; padding: 12px 6px 10px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--panel); cursor: pointer; color: var(--text); font-size: 13px;
}
.tool-grid .tool:hover:not(:disabled) { background: var(--hover); }
.tool-grid .tool.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.tool-grid .tool .tool-key { position: absolute; top: 3px; right: 5px; font-size: 10px; opacity: .6; font-family: ui-monospace, monospace; }
.segments { border-top: 1px dashed var(--border); margin-top: 8px; padding-top: 8px; }
.seg-head { font-weight: 600; margin-bottom: 4px; }
.seg-chips { display: flex; flex-wrap: wrap; gap: 3px; margin: 4px 0; }
.seg { font: 11px/1 inherit; width: 26px; height: 22px; border-radius: 4px; border: 1px solid var(--border); background: #fff; cursor: pointer; color: var(--text); }
.seg.seg-bridge { background: var(--active); }
.seg.seg-tunnel { background: var(--chip); }
.seg.active { outline: 2px solid var(--warn); border-color: var(--warn); }
.seg-nav { display: flex; align-items: center; gap: 8px; margin: 6px 0; font-size: 13px; }
.seg-nav button { font: inherit; border: 1px solid var(--border); background: var(--panel); color: var(--text); border-radius: 4px; cursor: pointer; padding: 2px 8px; }
.legend, .keys { list-style: none; padding: 0; margin: 6px 0; font-size: 12px; }
.legend li, .keys li { margin: 4px 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.swatch { display: inline-block; width: 34px; height: 8px; border-radius: 2px; background: #d7263d; border: 1px solid #2b2b2b; flex: 0 0 auto; }
.swatch.bridge { box-shadow: 0 0 0 2px #fff, 0 0 0 4px #1a1a1a; }
.swatch.tunnel { border: 0; background: repeating-linear-gradient(90deg, rgba(215,38,61,.55) 0 8px, transparent 8px 14px); }
.swatch.remove { border: 0; background: repeating-linear-gradient(90deg, #c62828 0 6px, transparent 6px 12px); }
.swatch.osm { border: 0; height: 2px; background: repeating-linear-gradient(90deg, rgba(61,90,254,.7) 0 3px, transparent 3px 8px); }

/* Ebenen */
.layer-row { display: flex; align-items: center; gap: 6px; padding: 6px 4px; border-bottom: 1px solid var(--border); }
.layer-row.active { background: var(--active); }
.layer-row .layer-name { flex: 1; min-width: 0; padding: 4px 6px; }
.layer-row .layer-color { width: 28px; height: 26px; padding: 0; border: 1px solid var(--border); border-radius: 4px; background: none; cursor: pointer; }
.layer-row .count { min-width: 18px; text-align: right; font-size: 12px; }
.layer-row .icon-btn { width: 26px; height: 26px; font-size: 12px; }

/* Listen */
.list-row { display: flex; align-items: center; gap: 8px; padding: 8px 4px; border-bottom: 1px solid var(--border); }
.list-row.active { background: var(--active); }
.list-row .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.undo-list { margin: 6px 0 0; padding-left: 20px; color: var(--muted); font-size: 12px; }
.link-row { display: flex; gap: 6px; margin: 10px 0; }
.link-row input { font-family: ui-monospace, monospace; font-size: 12px; }

/* Statuszeile */
.statusbar {
  height: var(--statusbar-h); display: flex; align-items: center; gap: 16px; padding: 0 12px; font-size: 12px;
  background: var(--panel); border-top: 1px solid var(--border); color: var(--muted); flex: 0 0 auto; white-space: nowrap; overflow: hidden;
}
.statusbar .grow { overflow: hidden; text-overflow: ellipsis; }
.statusbar .ok { color: var(--ok); }
.statusbar .error { color: var(--danger); }
#status-coords { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
/* Fortschritt länger laufender Arbeiten */
.progress { display: inline-flex; align-items: center; gap: 8px; max-width: 360px; overflow: hidden; }
.progress[hidden] { display: none; }
.progress .progress-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.progress .progress-bar { position: relative; width: 96px; height: 6px; border-radius: 3px; background: var(--border); overflow: hidden; flex: 0 0 auto; }
.progress .progress-bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.progress.indeterminate .progress-bar i { position: absolute; width: 40%; animation: progress-slide 1.2s ease-in-out infinite; }
@keyframes progress-slide { from { left: -40%; } to { left: 100%; } }
.progress.done { color: var(--ok); }
.progress.done.error { color: var(--danger); }
.progress.done .progress-bar { display: none; }
@media (prefers-reduced-motion: reduce) { .progress.indeterminate .progress-bar i { animation: none; width: 100%; opacity: .5; } }

/* Fahrt-Animation („Abfahren“) */
.race { margin: 8px 0; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel-soft); }
.race .btn-row { margin: 4px 0; align-items: center; }
.race-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.race-speeds { display: inline-flex; gap: 2px; }
.race-speed.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.race-timeline { display: flex; align-items: center; gap: 8px; margin: 6px 0; }
.race-timeline input[type="range"] { flex: 1; min-width: 60px; }
.race-clock { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; white-space: nowrap; }
.race-table td { padding: 3px 4px; }
.race-table td.race-bar-cell { width: 36%; }
.race-bar { display: block; height: 8px; border-radius: 4px; background: var(--border); overflow: hidden; }
.race-bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .1s linear; }
.race-glyph { font-size: 15px; }
.group-row { margin: 4px 0 8px; color: var(--muted); }
.group-badge { display: inline-block; font-weight: 700; color: var(--accent); }
.present-panel .race { padding: 6px 8px; }

/* Modal & Toasts */
.modal { position: fixed; inset: 0; background: rgba(20,30,40,.45); display: flex; align-items: center; justify-content: center; z-index: 200; padding: 16px; }
.modal[hidden] { display: none; }
.modal-card { background: var(--panel); border-radius: 12px; padding: 20px 22px; width: min(640px, 100%); box-shadow: 0 20px 60px rgba(0,0,0,.3); max-height: 90vh; overflow: auto; }
.toasts { position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; z-index: 210; pointer-events: none; }
.toast { background: #1f2933; color: #fff; padding: 9px 14px; border-radius: 8px; font-size: 13px; opacity: 0; transform: translateY(8px); transition: all .25s; box-shadow: 0 6px 20px rgba(0,0,0,.25); max-width: 80vw; }
.toast.show { opacity: 1; transform: none; }
.toast.ok { background: var(--ok); }
.toast.error { background: var(--danger); }

/* Schmale Bildschirme */
@media (max-width: 860px) {
  .topbar input.draft-name { width: 140px; flex-basis: 140px; }
  .brand { display: none; }
  /* Seitenleiste als Bottom-Sheet: die Tabs bleiben als Griff sichtbar */
  .sidebar {
    position: absolute; left: 0; right: 0; bottom: 0; top: auto; width: auto; height: 48vh; z-index: 20;
    border-right: 0; border-top: 1px solid var(--border); border-radius: 12px 12px 0 0; box-shadow: 0 -4px 20px rgba(0,0,0,.15);
    transition: transform .2s ease; margin-left: 0 !important;
  }
  body.sidebar-hidden .sidebar { transform: translateY(calc(100% - 42px)); }
  .tabs { cursor: pointer; }
  .draw-actions { bottom: calc(48vh + 12px); }
  body.sidebar-hidden .draw-actions { bottom: 56px; }
  .smap-scale, .smap-attribution { bottom: 44px; }
}
@media (max-width: 560px) {
  :root { --sidebar-w: 88vw; }
  .search { max-width: none; }
  .topbar { gap: 4px; padding: 0 6px; }
  .topbar input.draft-name { width: 100px; flex-basis: 100px; }
  #btn-save { display: none; }
}

/* Tempolimit */
.speed-row { display: flex; gap: 4px; align-items: center; margin-top: 3px; }
.speed-row input { width: 76px; flex: 0 0 auto; }
.speed { font: 600 12px/1 inherit; padding: 6px 7px; border: 1px solid var(--border); border-radius: 4px; background: #fff; cursor: pointer; color: var(--text); }
.speed.active { background: var(--danger-bg); border-color: var(--danger); color: var(--danger); }
.speed:disabled { opacity: .45; cursor: default; }
.sign { display: inline-block; width: 22px; height: 22px; border-radius: 50%; border: 3px solid #c62828; background: #fff; font: 700 9px/16px system-ui, sans-serif; text-align: center; color: #111; }
.swatch.route-cur { border: 0; height: 5px; background: #1b6ac9; }
.swatch.route-new { border: 0; height: 5px; background: repeating-linear-gradient(90deg, #2a9d3f 0 14px, transparent 14px 22px); }

/* Routen-Rechner */
.route-table { width: 100%; border-collapse: collapse; margin: 8px 0; font-size: 13px; }
.route-table th, .route-table td { text-align: right; padding: 6px 4px; border-bottom: 1px solid var(--border); }
.route-table th:first-child, .route-table td:first-child { text-align: left; color: var(--muted); font-weight: normal; }
.route-table th { font-weight: 600; color: var(--text); white-space: nowrap; }
.route-table .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; vertical-align: middle; }

/* Flächen und Kommentare */
.swatch.zone { border: 1.5px dashed #1b6ac9; background: rgba(27,106,201,.2); height: 12px; }
.swatch.comment { border: 0; width: 14px; height: 14px; border-radius: 50% 50% 50% 0; background: var(--warn); transform: rotate(-45deg); }
.comment-row { display: flex; align-items: flex-start; gap: 8px; padding: 8px 4px; border-bottom: 1px solid var(--border); }
.comment-row.active { background: var(--highlight); }
.comment-row.resolved .c-text { color: var(--muted); text-decoration: line-through; }
.comment-row .c-text { white-space: pre-wrap; word-break: break-word; font-size: 13px; margin-top: 2px; }
.c-focus { border: 0; background: none; padding: 0; cursor: pointer; }
.c-index { display: inline-block; width: 22px; height: 22px; border-radius: 50%; background: var(--warn); color: #fff; font: 700 11px/22px system-ui, sans-serif; text-align: center; }
.comment-row.resolved .c-index { background: #9aa3ad; }
.comment-row .icon-btn { width: 26px; height: 26px; font-size: 13px; }
.comment-form textarea { min-height: 70px; }
.check.small { font-size: 12px; margin: 0 0 0 auto; }

/* Export-Dialog */
.export-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }

/* Kommentar-Threads */
.thread { border-bottom: 1px solid var(--border); padding-bottom: 4px; }
.thread.active { background: var(--highlight); }
.thread .comment-row { border-bottom: 0; }
.thread.resolved > .comment-row .c-text { color: var(--muted); text-decoration: line-through; }
.thread.resolved .c-index { background: #9aa3ad; }
.comment-row.reply { margin-left: 30px; padding: 4px 4px 4px 10px; border-left: 2px solid var(--border); }
.thread-actions { margin-top: 2px; }
.link { border: 0; background: none; padding: 0; font: inherit; font-size: 12px; color: var(--accent); cursor: pointer; }
.link:disabled { color: var(--muted); cursor: default; }
.reply-form { margin: 4px 0 6px 30px; padding: 8px; border: 1px solid var(--border); border-radius: 6px; background: #fbfcfd; }
.reply-form input, .reply-form textarea { margin-bottom: 6px; }
.notify h3 { margin-top: 0; }

/* Höhenprofil */
.profile-box { border-top: 1px dashed var(--border); margin-top: 8px; padding-top: 8px; }
.profile-chart { display: block; width: 320px; max-width: 100%; height: 140px; background: var(--panel); border: 1px solid var(--border); border-radius: 6px; }

/* Aktionsleiste beim Zeichnen (Touch ohne Doppelklick/Enter) */
.draw-actions { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); display: flex; gap: 6px; z-index: 7; background: rgba(255,255,255,.95); padding: 6px; border-radius: 10px; box-shadow: 0 4px 16px rgba(0,0,0,.2); }
.draw-actions[hidden] { display: none; }
.draw-actions .btn { min-height: 40px; }

/* Präsentationsmodus */
body.present .sidebar, body.present .statusbar, body.present .topbar-actions, body.present #sidebar-toggle, body.present .search, body.present #dirty-indicator, body.present #readonly-indicator { display: none !important; }
body.present .topbar input.draft-name { border: 0; background: transparent; font-size: 18px; width: auto; flex: 1; }
body.present .banner { display: none !important; }
.present-panel { position: absolute; right: 12px; top: 12px; width: min(340px, 90%); background: rgba(255,255,255,.96); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; z-index: 8; box-shadow: 0 6px 24px rgba(0,0,0,.15); font-size: 13px; }
.present-panel[hidden] { display: none; }
.present-panel h2 { font-size: 16px; margin-bottom: 4px; }
.present-panel .legend { margin: 8px 0; }
.present-panel .route-table { font-size: 12px; }

/* Querschnitt-Editor und Abbiegeregeln */
.sec-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 8px; }
.sec-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; margin: 4px 0; }
.sec-row > span { min-width: 84px; }
.sec-row input[type="number"] { width: 64px; }
.check-row { display: flex; flex-wrap: wrap; gap: 4px 12px; margin: 4px 0; }

/* Analyse: Kosten und Normen-Check */
.route-table td.num, .route-table th.num { text-align: right; white-space: nowrap; }
.route-table tr.total td { border-top: 2px solid var(--border); }
.route-table tr.muted td { color: var(--muted); }
.cost-list, .check-list { list-style: none; margin: 6px 0; padding: 0; }
.cost-list li { display: flex; gap: 6px; align-items: baseline; padding: 3px 0; border-bottom: 1px dotted var(--border); font-size: 13px; }
.cost-list li .num { margin-left: auto; white-space: nowrap; }
.linkish { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; text-align: left; }
.linkish:hover { text-decoration: underline; }
.cost-group { margin: 6px 0 10px; }
.cost-item { display: grid; grid-template-columns: 1fr 110px 56px; gap: 6px; align-items: center; font-size: 12.5px; margin: 3px 0; }
.cost-item input { width: 100%; }
.check-list li { padding: 6px 8px; margin: 4px 0; border-left: 4px solid #9aa3ad; background: var(--bg); border-radius: 4px; font-size: 13px; }
.check-list li.warn { border-left-color: #e08a00; background: var(--highlight); }
.check-list li .linkish { color: inherit; }

/* Parzellen und Gebäude */
.parcel-list { list-style: none; margin: 4px 0; padding: 0; }
.parcel-list li { display: flex; gap: 6px; align-items: baseline; padding: 2px 0; border-bottom: 1px dotted var(--border); font-size: 12.5px; }
.parcel-list li .num { margin-left: auto; white-space: nowrap; }
.field.inline { display: inline-flex; align-items: center; gap: 6px; margin: 0; }

/* Routenpaare und Isochronen */
.route-table.pairs input.pair-name { width: 100%; min-width: 90px; }
.route-table.pairs td.pair-actions { white-space: nowrap; }
.route-table.pairs tr.active td { background: var(--highlight); }
.route-panel h4, #route-panel h4 { margin: 14px 0 4px; font-size: 13px; }

/* QR, Versionsvergleich */
.qr-row { display: flex; gap: 12px; align-items: center; margin: 6px 0 10px; }
.qr-row .qr svg { display: block; border: 1px solid var(--border); border-radius: 4px; }
.compare-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 13px; }
.compare-row select { max-width: 180px; }
.diff-list { list-style: none; margin: 6px 0; padding: 0; }
.diff-list li { padding: 4px 8px; margin: 3px 0; border-left: 4px solid #9aa3ad; background: var(--bg); border-radius: 4px; font-size: 13px; }
.diff-list li.added { border-left-color: #2a9d3f; }
.diff-list li.changed { border-left-color: #e08a00; }
.diff-list li.removed { border-left-color: #c62828; }
.diff-list li .linkish { color: inherit; font-weight: 600; }

/* Buslinien */
.bus-line { border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 10px; margin: 6px 0; }
.bus-line.active { border-color: #e08a00; background: var(--highlight); }
.bus-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.bus-head input.bus-name { width: 56px; }
.bus-head input.bus-dwell { width: 56px; }
.bus-head input.bus-color { width: 28px; height: 24px; padding: 0; border: 0; background: none; }
.bus-stops { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0; }
.stop-chip { display: inline-flex; align-items: center; gap: 2px; background: var(--chip); border-radius: 12px; padding: 2px 6px; font-size: 12px; }
.stop-chip .icon-btn { width: 20px; height: 20px; font-size: 10px; }

/* Bestehende Linien aus OSM */
.transit { margin-top: 10px; border-top: 1px solid var(--border); padding-top: 8px; }
.transit-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; flex-wrap: wrap; }
.transit-list { list-style: none; padding: 0; margin: 4px 0; max-height: 280px; overflow: auto; }
.transit-list li { display: flex; align-items: center; gap: 6px; padding: 3px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.transit-list .transit-name { flex: 1 1 120px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bus-badge { color: #fff; border-radius: 4px; padding: 0 6px; font-weight: 600; font-size: 12px; min-width: 26px; text-align: center; text-shadow: 0 0 2px rgba(0,0,0,0.5); }

/* Zuversicht: drei Stufen mit Gründen */
.conf-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: #9e9e9e; vertical-align: middle; margin-right: 4px; }
.conf-dot.conf-high, .conf.conf-high .conf-dot { background: var(--ok); }
.conf-dot.conf-medium, .conf.conf-medium .conf-dot { background: var(--warn); }
.conf-dot.conf-low, .conf.conf-low .conf-dot { background: var(--danger); }
details.conf { margin: 4px 0 8px; font-size: 12px; }
details.conf > summary { cursor: pointer; color: var(--muted); list-style: none; }
details.conf > summary::-webkit-details-marker { display: none; }
details.conf > summary::after { content: ' ▸'; font-size: 10px; }
details.conf[open] > summary::after { content: ' ▾'; }
.conf-reasons { margin: 4px 0 0 14px; padding: 0 0 0 14px; color: var(--muted); }
.conf-reasons li { margin: 1px 0; }

/* Kontextmenü */
.context-menu { position: fixed; z-index: 60; min-width: 190px; max-height: 80vh; overflow: auto; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 6px 24px rgba(0,0,0,0.18); padding: 4px 0; font-size: 13px; }
.context-menu .menu-header { padding: 5px 12px 2px; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.context-menu .sep { border-top: 1px solid var(--border); margin: 4px 0; }
.context-menu button { display: block; width: 100%; text-align: left; padding: 6px 12px 6px 26px; background: none; border: 0; cursor: pointer; position: relative; color: inherit; font: inherit; }
.context-menu button:hover:not(:disabled), .context-menu button:focus-visible { background: var(--hover); outline: none; }
.context-menu button:disabled { opacity: .45; cursor: default; }
.context-menu button.checked::before { content: '✓'; position: absolute; left: 9px; color: var(--accent); }
.context-menu button.danger { color: var(--danger); }
/* Elementliste */
.filter { width: 100%; box-sizing: border-box; margin: 6px 0; }
.element-list { list-style: none; padding: 0; margin: 0; max-height: 260px; overflow: auto; }
.element-list li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; padding: 3px 0; border-bottom: 1px solid var(--border); }
.element-list li.selected { background: var(--highlight); }
.element-list .el-row .dot { margin-right: 4px; }
.check.small { font-size: 12px; margin: -2px 0 8px; }
.btn.danger { color: var(--danger); border-color: #f0b8b8; }

/* Zuversicht-Punkte tragen zusätzlich ein Zeichen (✓ ! ✕), damit die Stufe auch ohne Farbe lesbar ist */
.conf-dot { width: 13px; height: 13px; position: relative; }
.conf-dot::after { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font: 700 9px/1 system-ui, sans-serif; color: #fff; }
.conf-dot.conf-high::after, .conf.conf-high .conf-dot::after { content: '✓'; }
.conf-dot.conf-medium::after, .conf.conf-medium .conf-dot::after { content: '!'; }
.conf-dot.conf-low::after, .conf.conf-low .conf-dot::after { content: '✕'; }
/* Dunkelmodus: Oberflächen, die noch helle Standardfarben hatten */
.topbar, .sidebar, .statusbar, .tabs { background: var(--panel); color: var(--text); }
.modal-card, .present-panel { color: var(--text); }
:root[data-theme="dark"] .present-panel, :root[data-theme="dark"] .smap-attribution, :root[data-theme="dark"] .smap-scale { background: rgba(27,31,36,0.92); color: var(--text); border-color: var(--border); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .present-panel, :root:not([data-theme="light"]) .smap-attribution, :root:not([data-theme="light"]) .smap-scale { background: rgba(27,31,36,0.92); color: var(--text); border-color: var(--border); }
}

/* Etappen */
.phase-row { display: flex; align-items: center; gap: 6px; padding: 4px 0; border-bottom: 1px solid var(--border); }
.phase-row .phase-name { flex: 1 1 100px; min-width: 0; }
.phase-row .phase-year { width: 72px; }
/* Varianten und Parkplätze */
.route-table.variants { font-size: 12px; }
.route-table.variants th, .route-table.variants td { padding: 3px 4px; }
.parking-list { list-style: none; padding: 0; margin: 4px 0; }
.parking-list li { padding: 3px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.parking-list .badge { min-width: 34px; text-align: center; display: inline-block; }

.schedule-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 6px 0; }
.unsafe { margin-top: 2px; }
