/* crabSDR APRS – gleiche Sprache wie die crabSDR-Oberfläche (web/ui.css): Schwarz, weiße Abstufungen, Smaragd,
   JetBrains Mono, flache Flächen mit feinen Linien, 4-px-Ecken. Hell/Dunkel über html[data-theme] bzw. .sysdark. */
@import url('fonts/fonts.css');
:root {
  --bg: #f6f7f8; --bg2: rgba(0,0,0,.04); --card: #ffffff; --line: rgba(0,0,0,.12); --line2: rgba(0,0,0,.06);
  --text: #111418; --strong: #000000; --muted: rgba(0,0,0,.5); --faint: rgba(0,0,0,.35);
  --accent: #059669; --accent2: #047857; --accent-fg: #ffffff; --accent-dim: rgba(5,150,105,.12);
  --ok: #059669; --warn: #b45309; --bad: #dc2626;
  --float: rgba(246,247,248,.95); --halo: #ffffff; --mapdot: #8a949e;
  --radius: 4px; --panel-w: 360px;
  color-scheme: light;
}
html[data-theme="dark"], html:not([data-theme="light"]).sysdark {
  --bg: #000000; --bg2: rgba(255,255,255,.05); --card: rgba(255,255,255,.03); --line: rgba(255,255,255,.12); --line2: rgba(255,255,255,.06);
  --text: #ffffff; --strong: #ffffff; --muted: rgba(255,255,255,.45); --faint: rgba(255,255,255,.3);
  --accent: #34d399; --accent2: #10b981; --accent-fg: #06110c; --accent-dim: rgba(52,211,153,.15);
  --ok: #34d399; --warn: #fbbf24; --bad: #f87171;
  --float: rgba(0,0,0,.92); --halo: #000000; --mapdot: #5b6570;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); display: flex; flex-direction: column; overflow: hidden;
  font: 13px/1.5 "JetBrains Mono", "Fira Code", Menlo, Consolas, monospace; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg2); }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }

/* ---------- Kopf (wie crabSDR .top) ---------- */
.top { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 6px 16px; border-bottom: 1px solid var(--line); background: var(--bg); z-index: 10; }
.brand { display: flex; align-items: center; gap: 10px; }
.logo { height: 38px; width: auto; flex: none; }
.brand h1 { margin: 0; font-size: 16px; letter-spacing: .12em; font-weight: 700; color: var(--strong); text-transform: uppercase; }
.brand h1 span { color: var(--accent); }
.sub { margin: 0; color: var(--faint); font-size: 10px; letter-spacing: .04em; }
.topright { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.btn { background: var(--bg2); color: var(--muted); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 10px;
  font: inherit; font-size: 12px; cursor: pointer; min-height: 34px; display: inline-flex; align-items: center; justify-content: center;
  touch-action: manipulation; transition: background .12s, color .12s, border-color .12s; user-select: none; }
.btn:hover { background: var(--line2); color: var(--text); }
.btn.on, .tog input:checked + .btn { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); font-weight: 700; }
.btn-icon { min-width: 34px; padding: 6px; }
.seg { display: flex; gap: 4px; }
.seg .btn { min-width: 46px; }

.live { display: inline-flex; align-items: center; gap: 6px; font-size: 10px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); padding: 0 4px; }
.live i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: beat 1.8s infinite; }
.live.off { color: var(--faint); } .live.off i { animation: none; }
@keyframes beat { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }

/* ---------- Karte + Seitenleiste ---------- */
.wrap { flex: 1; min-height: 0; position: relative; display: flex; }
#map { flex: 1; min-width: 0; position: relative; }
.maplibregl-ctrl-attrib { display: none; }
.maplibregl-ctrl-group { background: var(--float) !important; border: 1px solid var(--line); border-radius: var(--radius) !important; box-shadow: none !important; }
.maplibregl-ctrl-group button + button { border-top: 1px solid var(--line2) !important; }
html[data-theme="dark"] .maplibregl-ctrl-icon, html:not([data-theme="light"]).sysdark .maplibregl-ctrl-icon { filter: invert(1); }

#panel { width: var(--panel-w); flex: none; display: flex; flex-direction: column; background: var(--bg); border-left: 1px solid var(--line); min-height: 0; }
.grab { display: none; }
h3.sec { margin: 0; padding: 10px 14px 6px; font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); font-weight: 600;
  display: flex; justify-content: space-between; align-items: center; }
.mini { font-size: 10px; letter-spacing: .04em; text-transform: none; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; font-weight: 400; }
.mini input { accent-color: var(--accent); margin: 0; }

.totals { display: grid; grid-template-columns: repeat(3, 1fr); border-bottom: 1px solid var(--line); }
.totals div { padding: 9px 14px 8px; border-right: 1px solid var(--line2); }
.totals div:last-child { border-right: 0; }
.totals b { display: block; font-size: 18px; font-weight: 700; color: var(--strong); line-height: 1.2; }
.totals span { color: var(--faint); font-size: 10px; letter-spacing: .04em; }

.controls { padding: 10px 14px 4px; display: grid; gap: 8px; }
.toggles { display: flex; flex-wrap: wrap; gap: 4px; }
.tog input { display: none; }
.tog .btn { min-height: 30px; padding: 4px 9px; font-size: 11px; }
#search { width: 100%; background: var(--bg2); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 6px 9px; font: inherit; font-size: 12px; min-height: 34px; text-transform: uppercase; }
#search::placeholder { text-transform: none; color: var(--faint); }
#search:focus { outline: 1px solid var(--accent); outline-offset: 0; }

/* Empfänger-Karten (wie crabSDR .band) */
#stations { padding: 0 14px 4px; display: grid; gap: 6px; }
.st { --c: var(--accent); position: relative; display: grid; grid-template-columns: 1fr auto; gap: 1px 10px; padding: 7px 10px 7px 13px;
  border-radius: var(--radius); background: var(--bg2); border: 1px solid var(--line); cursor: pointer; transition: border-color .12s, background .12s; }
.st::before { content: ""; position: absolute; left: -1px; top: -1px; bottom: -1px; width: 3px; border-radius: var(--radius) 0 0 var(--radius); background: var(--c); }
.st:hover { background: var(--line2); }
.st.focus { border-color: var(--c); background: color-mix(in srgb, var(--c) 10%, transparent); }
.st.dim { opacity: .45; }
.st .nm { font-weight: 700; color: var(--strong); letter-spacing: .04em; }
.st .nm small { color: var(--faint); font-weight: 400; margin-left: 6px; font-size: 10px; letter-spacing: .02em; }
.st .state { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .12em; 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: 12px; font-size: 11px; color: var(--muted); flex-wrap: wrap; }
.st .kv b { color: var(--text); font-weight: 700; }
.st .kv a { margin-left: auto; font-size: 10px; }
.st.rx::after { content: ""; position: absolute; inset: -1px; border-radius: var(--radius); border: 1px solid var(--c); animation: rx .9s ease-out forwards; pointer-events: none; }
@keyframes rx { from { opacity: 1; } to { opacity: 0; } }

/* Live-Liste */
.feedwrap { flex: 1; min-height: 0; display: flex; flex-direction: column; border-top: 1px solid var(--line); margin-top: 8px; }
#feed { list-style: none; margin: 0; padding: 0 6px 8px; overflow-y: auto; flex: 1; }
#feed li { display: grid; grid-template-columns: 8px 1fr auto; gap: 0 8px; padding: 4px 8px; border-radius: var(--radius); cursor: pointer; align-items: baseline; border-bottom: 1px solid var(--line2); }
#feed li:hover { background: var(--bg2); }
#feed li.new { animation: flash 1.4s ease-out; }
@keyframes flash { from { background: var(--accent-dim); } to { background: transparent; } }
#feed .dot { width: 7px; height: 7px; border-radius: 50%; align-self: center; }
#feed .who { font-size: 12px; font-weight: 700; color: var(--strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#feed .who em { font-style: normal; color: var(--muted); font-weight: 400; }
#feed .tm { font-size: 10px; color: var(--faint); }
#feed .cm { grid-column: 2 / -1; color: var(--muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#feed li.is .who { color: var(--muted); font-weight: 400; }
#feed li.is .dot { background: var(--faint); }

/* Fußzeile (wie crabSDR .foot) */
.foot { flex: none; display: flex; justify-content: space-between; gap: 12px; padding: 3px 16px 5px; color: var(--faint); font-size: 10px;
  letter-spacing: .02em; border-top: 1px solid var(--line2); background: var(--bg); }
.foot a { color: var(--muted); }
.made { display: inline-flex; align-items: center; gap: 6px; text-transform: uppercase; letter-spacing: .12em; white-space: nowrap; }
.made img { height: 14px; }

/* ---------- Empfänger-Marker: crabSDR-Krabbe in Stationsfarbe ---------- */
.stm { --c: var(--accent); width: 32px; height: 32px; cursor: pointer; border-radius: 50%; background: var(--float); border: 2px solid var(--c);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--c) 18%, transparent), 0 0 10px color-mix(in srgb, var(--c) 45%, transparent); }
.stm .crab { position: absolute; inset: 5px 3px; background: var(--c); -webkit-mask: url(crabsdr-logo.svg) center / contain no-repeat; mask: url(crabsdr-logo.svg) center / contain no-repeat; }
.stm::after { content: ""; position: absolute; left: 50%; top: 50%; width: 32px; height: 32px; margin: -16px 0 0 -16px; border-radius: 50%; border: 2px solid var(--c); opacity: 0; }
.stm.rx::after { animation: ring 1.2s ease-out; }
.stm.offline { border-color: var(--faint); box-shadow: none; } .stm.offline .crab { background: var(--faint); }
.stm .lbl { position: absolute; top: 34px; left: 50%; transform: translateX(-50%); white-space: nowrap; font-size: 10px; font-weight: 700;
  color: var(--c); letter-spacing: .1em; text-shadow: 0 0 3px var(--halo), 0 0 6px var(--halo), 0 0 10px var(--halo); }
@keyframes ring { from { transform: scale(1); opacity: 1; } to { transform: scale(3.4); opacity: 0; } }

/* ---------- Detailkarte (schwebt links über der Karte) ---------- */
#detail { position: absolute; left: 10px; top: 10px; width: 350px; max-height: calc(100% - 20px); overflow-y: auto; z-index: 6;
  background: var(--float); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px 10px; }
#detail .x { all: unset; position: absolute; right: 10px; top: 6px; cursor: pointer; color: var(--muted); font-size: 20px; line-height: 1; }
#detail .x:hover { color: var(--text); }
#detail .hd { display: flex; gap: 12px; align-items: center; margin-right: 24px; }
#detail .hd canvas { width: 34px; height: 34px; }
#detail h2 { margin: 0; font-size: 18px; font-weight: 700; color: var(--strong); letter-spacing: .02em; }
#detail .meta { color: var(--faint); font-size: 10px; letter-spacing: .02em; }
#detail .cmt { margin: 8px 0 4px; font-size: 12px; color: var(--text); word-break: break-word; }
#detail #dcmt[hidden] { display: none; }
#detail .none { color: var(--faint); font-size: 11px; margin: 8px 0; }
#detail h4 { margin: 12px 0 5px; font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); }
#detail ol { list-style: none; margin: 0; padding: 0; font-size: 11px; }
#detail ol li { padding: 3px 0; border-bottom: 1px solid var(--line2); color: var(--text); word-break: break-all; }
#detail ol li .tm { color: var(--faint); margin-right: 6px; }
#detail ol li .dot, #detail ol.rl .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 5px; }
#detail .rx { display: grid; gap: 6px; }
#detail .rxs { --c: var(--accent); padding: 7px 9px 6px 11px; border-radius: var(--radius); background: color-mix(in srgb, var(--c) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--c) 30%, transparent); position: relative; }
#detail .rxs::before { content: ""; position: absolute; left: -1px; top: -1px; bottom: -1px; width: 3px; border-radius: var(--radius) 0 0 var(--radius); background: var(--c); }
#detail .rxh { display: flex; align-items: baseline; gap: 7px; font-size: 12px; }
#detail .rxh i { display: none; }
#detail .rxh b { color: var(--strong); }
#detail .rxh span { color: var(--muted); font-size: 11px; }
#detail .rxt { color: var(--faint); font-size: 10px; margin: 2px 0 5px; }
#detail .chips { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 5px; }
#detail .chips span { font-size: 10px; color: var(--muted); background: var(--bg2); border: 1px solid var(--line2); border-radius: var(--radius); padding: 1px 6px; }
#detail .chips b { color: var(--text); }
#detail .spark { display: block; width: 100%; height: 30px; }
#detail ol.rl { max-height: 230px; overflow-y: auto; }
#detail ol.rl li { display: flex; align-items: center; gap: 1px; cursor: pointer; padding: 4px 2px; word-break: normal; }
#detail ol.rl li:hover { background: var(--bg2); }
#detail ol.rl li b { margin-left: 3px; color: var(--strong); }
#detail ol.rl li span { margin-left: auto; color: var(--muted); white-space: nowrap; }
#detail .links { display: flex; gap: 14px; margin-top: 10px; font-size: 11px; }

/* Legende */
#legend { position: absolute; left: 10px; bottom: 10px; z-index: 4; font-size: 10px; color: var(--muted); background: var(--float);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 7px 9px; display: grid; gap: 2px; }
#detail:not([hidden]) ~ #legend { display: none; }
#legend i { display: inline-block; vertical-align: middle; margin-right: 7px; width: 18px; }
.lg-ring { height: 11px; width: 11px !important; border-radius: 50%; border: 2px solid var(--accent); margin-left: 3px; margin-right: 11px !important; }
.lg-via { height: 9px; width: 9px !important; border-radius: 50%; background: var(--text); opacity: .3; margin-left: 4px; margin-right: 12px !important; }
.lg-line { height: 2px; background: var(--accent); }
.lg-rare { height: 0; border-top: 2px dotted var(--accent); margin-left: 6px; }
.lg-fan { height: 11px; background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 50%, transparent), color-mix(in srgb, var(--accent) 8%, transparent)); border-radius: 0 6px 6px 0; }
.lg-grey { height: 9px; width: 9px !important; border-radius: 50%; background: var(--mapdot); margin-left: 4px; margin-right: 12px !important; }

.maplibregl-popup-content { background: var(--float); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 10px; font: 11px/1.5 "JetBrains Mono", monospace; box-shadow: none; }
.maplibregl-popup-tip { display: none; }

/* ---------- Handy: Seitenleiste als Blatt unten ---------- */
@media (max-width: 760px) {
  .top { padding: 6px 10px; } .sub { display: none; } .logo { height: 30px; } .brand h1 { font-size: 14px; }
  .seg .btn { min-width: 38px; padding: 4px 6px; }
  .wrap { display: block; }
  #map { position: absolute; inset: 0; }
  #panel { position: absolute; left: 0; right: 0; bottom: 0; width: auto; height: 46%; border-left: 0; border-top: 1px solid var(--line); z-index: 7; transition: height .25s; }
  #panel.min { height: 96px; }
  .grab { display: block; width: 44px; height: 4px; border-radius: 2px; background: var(--line); margin: 6px auto 0; cursor: pointer; flex: none; }
  #detail { left: 6px; right: 6px; top: 6px; width: auto; max-height: calc(100% - 110px); }
  #detail .rxs { padding-right: 7px; }
  #legend, .maplibregl-ctrl-top-right, .foot { display: none; }
}
