:root {
  --bg: #0b0f14; --panel: rgba(13, 18, 25, .86); --line: rgba(255, 255, 255, .08); --text: #e6edf3; --dim: #8b98a5;
  --faint: #56626e; --accent: #ff7a45; --ok: #3ddc84; --bad: #ff5d5d; --mono: "JetBrains Mono", ui-monospace, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 14px/1.4 "Space Grotesk", system-ui, sans-serif; overflow: hidden; }
a { color: inherit; }
#map { position: fixed; inset: 0; }
.maplibregl-ctrl-attrib { display: none; }

/* ---------- Seitenleiste ---------- */
#panel {
  position: fixed; top: 12px; right: 12px; bottom: 12px; width: 380px; display: flex; flex-direction: column;
  background: var(--panel); backdrop-filter: blur(14px) saturate(1.3); -webkit-backdrop-filter: blur(14px) saturate(1.3);
  border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 20px 60px rgba(0, 0, 0, .45); overflow: hidden; z-index: 5;
}
.grab { display: none; }
header { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 6px; }
.brand { display: flex; align-items: baseline; gap: 8px; font-size: 20px; letter-spacing: -.02em; }
.brand .crab { font-size: 22px; filter: drop-shadow(0 0 8px rgba(255, 122, 69, .5)); }
.brand .sub { color: var(--accent); font-family: var(--mono); font-size: 13px; font-weight: 600; letter-spacing: .12em; }
.live { display: flex; align-items: center; gap: 7px; font: 600 11px var(--mono); text-transform: uppercase; letter-spacing: .1em; color: var(--ok); }
.live i { width: 8px; height: 8px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 0 currentColor; animation: beat 1.8s infinite; }
.live.off { color: var(--faint); } .live.off i { animation: none; }
@keyframes beat { 0% { box-shadow: 0 0 0 0 rgba(61, 220, 132, .6); } 70% { box-shadow: 0 0 0 8px rgba(61, 220, 132, 0); } 100% { box-shadow: 0 0 0 0 rgba(61, 220, 132, 0); } }

.totals { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; margin: 6px 16px 10px; border-radius: 10px; overflow: hidden; background: var(--line); }
.totals div { background: rgba(255, 255, 255, .02); padding: 8px 10px; }
.totals b { display: block; font: 600 18px var(--mono); }
.totals span { color: var(--dim); font-size: 11px; }

.controls { padding: 0 16px 10px; display: grid; gap: 8px; }
.seg { display: grid; grid-template-columns: repeat(4, 1fr); background: rgba(255, 255, 255, .04); border-radius: 9px; padding: 3px; }
.seg button { all: unset; text-align: center; padding: 5px 0; border-radius: 7px; cursor: pointer; font: 600 12px var(--mono); color: var(--dim); }
.seg button.on { background: rgba(255, 255, 255, .1); color: var(--text); }
.toggles { display: flex; flex-wrap: wrap; gap: 6px; }
.tog { cursor: pointer; user-select: none; }
.tog input { display: none; }
.tog span { display: inline-block; padding: 4px 10px; border-radius: 99px; border: 1px solid var(--line); color: var(--dim); font-size: 12px; transition: .15s; }
.tog input:checked + span { color: var(--text); border-color: rgba(255, 255, 255, .25); background: rgba(255, 255, 255, .07); }
.search input { width: 100%; background: rgba(255, 255, 255, .05); border: 1px solid var(--line); border-radius: 9px; color: var(--text);
  padding: 8px 11px; font: 13px var(--mono); outline: none; text-transform: uppercase; }
.search input:focus { border-color: rgba(255, 122, 69, .6); }
.search input::placeholder { text-transform: none; color: var(--faint); font-family: "Space Grotesk", sans-serif; }

/* ---------- Stationskarten ---------- */
#stations { padding: 0 12px 6px; display: grid; gap: 6px; }
.st { --c: #fff; position: relative; display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 10px 12px 10px 16px;
  border-radius: 11px; background: rgba(255, 255, 255, .03); border: 1px solid var(--line); cursor: pointer; transition: .15s; }
.st::before { content: ""; position: absolute; left: 0; top: 9px; bottom: 9px; width: 3px; border-radius: 3px; background: var(--c); box-shadow: 0 0 12px var(--c); }
.st:hover { background: rgba(255, 255, 255, .06); }
.st.focus { border-color: var(--c); background: color-mix(in srgb, var(--c) 10%, transparent); }
.st.dim { opacity: .45; }
.st .nm { font-weight: 700; letter-spacing: .01em; } .st .nm small { color: var(--dim); font-weight: 400; margin-left: 6px; }
.st .state { font: 600 10px var(--mono); text-transform: uppercase; letter-spacing: .08em; align-self: center; }
.st .state.online { color: var(--ok); } .st .state.offline { color: var(--bad); } .st .state.unbekannt { color: var(--faint); }
.st .kv { grid-column: 1 / -1; display: flex; gap: 14px; font: 12px var(--mono); color: var(--dim); flex-wrap: wrap; }
.st .kv b { color: var(--text); font-weight: 600; }
.st.rx::after { content: ""; position: absolute; inset: -1px; border-radius: 11px; border: 1px solid var(--c); animation: rx .9s ease-out forwards; pointer-events: none; }
@keyframes rx { from { opacity: 1; box-shadow: 0 0 18px var(--c); } to { opacity: 0; box-shadow: 0 0 0 var(--c); } }

/* ---------- Live-Liste ---------- */
.feedwrap { flex: 1; min-height: 0; display: flex; flex-direction: column; border-top: 1px solid var(--line); margin-top: 6px; }
.feedwrap h3 { margin: 0; padding: 10px 16px 6px; font: 600 11px var(--mono); text-transform: uppercase; letter-spacing: .12em; color: var(--dim);
  display: flex; justify-content: space-between; align-items: center; }
.mini { font: 11px "Space Grotesk", sans-serif; text-transform: none; letter-spacing: 0; cursor: pointer; }
#feed { list-style: none; margin: 0; padding: 0 8px 8px; overflow-y: auto; flex: 1; scrollbar-width: thin; scrollbar-color: #2a333d transparent; }
#feed li { display: grid; grid-template-columns: 10px 1fr auto; gap: 0 8px; padding: 5px 8px; border-radius: 7px; cursor: pointer; align-items: baseline; }
#feed li:hover { background: rgba(255, 255, 255, .05); }
#feed li.new { animation: flash 1.4s ease-out; }
@keyframes flash { from { background: rgba(255, 255, 255, .12); } to { background: transparent; } }
#feed .dot { width: 8px; height: 8px; border-radius: 50%; align-self: center; }
#feed .who { font: 600 12.5px var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#feed .who em { font-style: normal; color: var(--dim); font-weight: 400; }
#feed .tm { font: 11px var(--mono); color: var(--faint); }
#feed .cm { grid-column: 2 / -1; color: var(--dim); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#feed li.is .who { color: #9aa6b2; font-weight: 400; }
#feed li.is .dot { background: #4a5561; }

footer { padding: 8px 16px 12px; font-size: 10.5px; color: var(--faint); border-top: 1px solid var(--line); line-height: 1.6; }
footer a { color: var(--dim); text-decoration: none; }

/* ---------- Stationsmarker ---------- */
.stm { --c: #fff; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; cursor: pointer; font-size: 19px;
  background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--c) 45%, #111), #0b0f14 75%); border: 2px solid var(--c);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--c) 18%, transparent), 0 0 24px color-mix(in srgb, var(--c) 60%, transparent); }
/* KEIN position:relative – MapLibre setzt position:absolute auf .maplibregl-marker, sonst stapeln sich die Marker */
.stm::after { content: ""; position: absolute; inset: -2px; border-radius: 50%; border: 2px solid var(--c); opacity: 0; }
.stm.rx::after { animation: ring 1.2s ease-out; }
.stm.offline { filter: grayscale(1) brightness(.6); }
.stm .lbl { position: absolute; top: 42px; left: 50%; transform: translateX(-50%); white-space: nowrap; font: 700 11px var(--mono);
  color: var(--c); text-shadow: 0 0 4px #000, 0 0 8px #000; letter-spacing: .04em; }
@keyframes ring { from { transform: scale(1); opacity: 1; } to { transform: scale(3.2); opacity: 0; } }

/* ---------- Detailkarte ---------- */
#detail { position: fixed; left: 12px; top: 12px; width: 360px; max-height: calc(100% - 24px); overflow-y: auto; z-index: 6;
  background: var(--panel); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border: 1px solid var(--line);
  border-radius: 16px; box-shadow: 0 20px 60px rgba(0, 0, 0, .45); padding: 14px 16px 12px; scrollbar-width: thin; }
#detail .x { position: absolute; right: 10px; top: 8px; all: unset; position: absolute; right: 12px; top: 10px; cursor: pointer; color: var(--dim); font-size: 20px; line-height: 1; }
#detail .hd { display: flex; gap: 12px; align-items: center; margin-right: 24px; }
#detail .hd canvas { width: 36px; height: 36px; }
#detail h2 { margin: 0; font: 700 20px var(--mono); letter-spacing: -.01em; }
#detail .meta { color: var(--dim); font-size: 12px; }
#detail .cmt { margin: 10px 0 6px; font-size: 13px; color: #c4cdd6; word-break: break-word; }
#detail .by { display: grid; gap: 5px; margin: 10px 0; }
#detail .by > div { --c: #fff; display: grid; grid-template-columns: 10px 1fr auto; gap: 8px; align-items: center; font: 12px var(--mono);
  padding: 6px 8px; border-radius: 8px; background: color-mix(in srgb, var(--c) 9%, transparent); }
#detail .by i { width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
#detail .by > div > span, #detail .by b span { color: var(--dim); font-weight: 400; }
#detail .by .bar { grid-column: 2 / -1; height: 3px; border-radius: 3px; background: rgba(255, 255, 255, .06); overflow: hidden; }
#detail .by .bar b { display: block; height: 100%; background: var(--c); }
#detail .none { color: var(--faint); font-size: 12px; margin: 8px 0; }
#detail h4 { margin: 12px 0 4px; font: 600 10.5px var(--mono); text-transform: uppercase; letter-spacing: .12em; color: var(--dim); }
#detail ol { list-style: none; margin: 0; padding: 0; font: 11.5px var(--mono); }
#detail ol li { padding: 4px 0; border-bottom: 1px solid var(--line); color: #b8c2cc; word-break: break-all; }
#detail ol li .tm { color: var(--faint); margin-right: 6px; }
#detail ol li .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; }
#detail .links { display: flex; gap: 12px; margin-top: 10px; font-size: 12px; }
#detail .links a { color: var(--accent); text-decoration: none; }

#legend { position: fixed; left: 12px; bottom: 12px; z-index: 4; font-size: 11px; color: var(--dim); background: rgba(11, 15, 20, .72);
  backdrop-filter: blur(8px); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; display: grid; gap: 3px; }
#legend i { display: inline-block; vertical-align: middle; margin-right: 7px; width: 18px; }
.lg-ring { height: 12px; width: 12px !important; border-radius: 50%; border: 2px solid var(--accent); margin-left: 3px; margin-right: 10px !important; }
.lg-line { height: 2px; background: var(--accent); }
.lg-dash { height: 0; border-top: 2px dashed #cfd8e3; }
.lg-grey { height: 10px; width: 10px !important; border-radius: 50%; background: #56626e; margin-left: 4px; margin-right: 11px !important; }

.maplibregl-popup-content { background: #111820; color: var(--text); border-radius: 8px; padding: 6px 10px; font: 12px var(--mono); }
.maplibregl-popup-tip { border-top-color: #111820 !important; border-bottom-color: #111820 !important; }

/* ---------- Handy: Seitenleiste als Blatt unten ---------- */
@media (max-width: 760px) {
  #panel { top: auto; left: 0; right: 0; bottom: 0; width: auto; height: 46vh; border-radius: 18px 18px 0 0; transition: height .25s; }
  #panel.min { height: 118px; }
  .grab { display: block; width: 44px; height: 5px; border-radius: 3px; background: rgba(255, 255, 255, .25); margin: 8px auto 0; cursor: pointer; }
  header { padding-top: 6px; }
  #detail { left: 8px; right: 8px; top: 8px; width: auto; max-height: calc(100vh - 140px); }
  #detail .by > div { grid-template-columns: 10px 1fr; } #detail .by > div > span { grid-column: 2; }
  #legend { display: none; }
  .maplibregl-ctrl-top-right { display: none; }
}
