/* DK0IZ DX-Cluster – (c) Thomas Dreymann */

:root {
  --paper: #f6f7f5;
  --surface: #ffffff;
  --ink: #1d2328;
  --muted: #5d6973;
  --rule: #dde2e4;
  --rule-strong: #c5ccd1;
  --accent: #2456a6;
  --accent-soft: #e4ecf8;
  --good: #22804e;
  --possible: #b8830f;
  --unlikely: #a3abb2;
  --mine: #fff3cf;
  --new: #e9f2ff;
  --radius: 6px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #171c20;
    --surface: #1e2429;
    --ink: #e2e6e9;
    --muted: #97a2ab;
    --rule: #2b3338;
    --rule-strong: #3a444b;
    --accent: #86aeea;
    --accent-soft: #24334a;
    --good: #52c186;
    --possible: #e2b449;
    --unlikely: #58636b;
    --mine: #3b3520;
    --new: #1f2d40;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.45 var(--font);
  padding: env(safe-area-inset-top, 0) env(safe-area-inset-right, 0) env(safe-area-inset-bottom, 0) env(safe-area-inset-left, 0);
}
a { color: var(--accent); }
button, input, select { font: inherit; color: inherit; }
: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; }

/* ---------- Kopf ---------- */
.top {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 18px clamp(16px, 3vw, 32px) 14px;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 12px; margin-right: auto; }
.brand-mark { width: 34px; height: 34px; fill: none; stroke: var(--accent); stroke-width: 2.2; stroke-linecap: round; }
.brand-mark circle { fill: var(--accent); stroke: none; }
.brand h1 { font-size: 1.3rem; font-weight: 650; letter-spacing: -0.01em; margin: 0; line-height: 1.1; }
.brand-sub { margin: 2px 0 0; color: var(--muted); font-size: .85rem; }

.conditions { display: flex; gap: 22px; }
.cond { display: flex; flex-direction: column; }
.cond-label { font-size: .75rem; color: var(--muted); }
.cond-value { font-size: 1.05rem; font-weight: 600; font-variant-numeric: tabular-nums; }

.station {
  display: flex; flex-direction: column; align-items: flex-end;
  background: none; border: 1px solid var(--rule-strong); border-radius: var(--radius);
  padding: 5px 12px; cursor: pointer;
}
.station:hover { border-color: var(--accent); }
.station-call { font-weight: 650; letter-spacing: .02em; }
.station-loc { font-size: .8rem; color: var(--muted); }

/* ---------- Bandleiste ---------- */
.bands {
  display: flex;
  gap: 0;
  padding: 0 clamp(16px, 3vw, 32px);
  border-bottom: 1px solid var(--rule);
  overflow-x: auto;
  scrollbar-width: thin;
}
.band {
  flex: 1 0 64px;
  display: flex; flex-direction: column; align-items: flex-start;
  gap: 2px;
  background: none; border: 0;
  padding: 8px 10px 9px; cursor: pointer; text-align: left;
}
.band { border-radius: var(--radius) var(--radius) 0 0; }
.band:hover { background: var(--accent-soft); }
.band[aria-pressed="true"],
.band[aria-pressed="true"]:hover { background: var(--accent); color: var(--surface); }
.band[aria-pressed="true"] .band-name { color: inherit; font-weight: 650; }
.band[aria-pressed="true"] .band-count { color: inherit; opacity: .85; }
.band[aria-pressed="true"] .band-outlook { background: rgba(255, 255, 255, .35); box-shadow: 0 0 0 2px var(--surface); }
.bands-label {
  flex: 0 0 auto; align-self: flex-end;
  padding: 0 14px 6px 0; margin-right: 4px;
  font-size: .72rem; line-height: 1.25; color: var(--muted); text-align: right;
  border-right: 1px solid var(--rule); cursor: help;
}
.band-name { font-weight: 650; font-size: .95rem; }
.band-count { font-size: .78rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.band-outlook { display: block; width: 100%; height: 4px; border-radius: 2px; background: var(--rule); overflow: hidden; }
.band-outlook i { display: block; height: 100%; }
.band.is-empty .band-name { color: var(--muted); font-weight: 500; }

/* ---------- Filter ---------- */
.filters {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px;
  padding: 14px clamp(16px, 3vw, 32px) 6px;
}
.seg { display: inline-flex; border: 1px solid var(--rule-strong); border-radius: var(--radius); overflow: hidden; }
.seg button { background: var(--surface); border: 0; padding: 6px 12px; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--rule-strong); }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--surface); }
.field select, .field input {
  background: var(--surface); border: 1px solid var(--rule-strong); border-radius: var(--radius);
  padding: 6px 10px; min-height: 34px;
}
.callsearch { display: inline-flex; align-items: center; gap: 6px; }
.search input { width: 17rem; text-transform: uppercase; }
.search-hint { flex-basis: 100%; margin: -4px 0 0; font-size: .8rem; color: var(--possible); }
.search input::placeholder { text-transform: none; }
.check { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; }

.statusline {
  display: flex; align-items: baseline; gap: 14px;
  padding: 4px clamp(16px, 3vw, 32px) 10px; color: var(--muted); font-size: .85rem;
}
.statusline p { margin: 0; }
.statusline .is-stale { color: var(--possible); }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; font-size: inherit; }

/* ---------- Tabelle ---------- */
main { padding: 0 clamp(8px, 2vw, 24px) 24px; }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); }
.spots { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.spots th {
  position: sticky; top: 0; z-index: 1;
  background: var(--surface); text-align: left; font-weight: 500; font-size: .8rem; color: var(--muted);
  border-bottom: 1px solid var(--rule-strong); padding: 0;
}
.spots th button { background: none; border: 0; width: 100%; text-align: inherit; padding: 9px 12px; cursor: pointer; color: inherit; font-size: inherit; }
.spots th button[aria-sort] { color: var(--ink); font-weight: 600; }
.spots th button[aria-sort="ascending"]::after { content: " ↑"; }
.spots th button[aria-sort="descending"]::after { content: " ↓"; }
.spots th.num, .spots td.num { text-align: right; }
.spots td { padding: 8px 12px; border-bottom: 1px solid var(--rule); vertical-align: top; }
.spots tr.spot { cursor: pointer; }
.spots tr.spot:hover td { background: var(--accent-soft); }
.spots tr.is-mine td { background: var(--mine); }
.spots tr.is-new td { animation: arrive 2.4s ease-out; }
@keyframes arrive { from { background: var(--new); } to { background: transparent; } }
@media (prefers-reduced-motion: reduce) { .spots tr.is-new td { animation: none; } }

.t-time { white-space: nowrap; }
.t-time small { display: block; color: var(--muted); font-size: .75rem; }
.t-freq { white-space: nowrap; font-weight: 500; }
.t-freq small { display: block; color: var(--muted); font-size: .75rem; font-weight: 400; }
.t-dx strong { font-size: 1rem; letter-spacing: .02em; }
.t-dx small { display: block; color: var(--muted); font-size: .8rem; }
.t-dx small.m-time { display: none; }
.t-dx .sig { display: inline-block; margin-left: 6px; font-size: .72rem; color: var(--accent); border: 1px solid currentColor; border-radius: 3px; padding: 0 4px; vertical-align: 2px; }
.t-dist { white-space: nowrap; }
.t-dist small { display: flex; justify-content: flex-end; align-items: center; gap: 4px; color: var(--muted); font-size: .78rem; }
.arrow { display: inline-block; width: 11px; height: 11px; }
.arrow svg { width: 11px; height: 11px; fill: var(--muted); display: block; }
.t-de small { display: block; color: var(--muted); font-size: .78rem; }
.t-comment { color: var(--muted); font-size: .85rem; max-width: 26ch; overflow-wrap: anywhere; }

/* Chance: Signalbalken wie beim S-Meter */
.chance { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.meter { display: inline-flex; align-items: flex-end; gap: 2px; height: 16px; }
.meter i { width: 4px; border-radius: 1px; background: var(--rule-strong); }
.meter i:nth-child(1) { height: 5px; }
.meter i:nth-child(2) { height: 8px; }
.meter i:nth-child(3) { height: 11px; }
.meter i:nth-child(4) { height: 14px; }
.meter i:nth-child(5) { height: 16px; }
.chance.good .meter i.on { background: var(--good); }
.chance.possible .meter i.on { background: var(--possible); }
.chance.unlikely .meter i.on { background: var(--unlikely); }
.chance-label { font-size: .85rem; }
.chance.good .chance-label { color: var(--good); font-weight: 600; }
.chance.possible .chance-label { color: var(--possible); font-weight: 600; }
.chance.unlikely .chance-label { color: var(--muted); }

/* Detailzeile */
tr.detail td { background: var(--paper); padding: 12px 16px 16px; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 8px 32px; }
.detail h3 { font-size: .85rem; font-weight: 600; margin: 0 0 6px; }
.detail ul { margin: 0; padding-left: 18px; }
.detail li { margin: 2px 0; }
.detail dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 14px; margin: 0; font-size: .88rem; }
.detail dt { color: var(--muted); }
.detail dd { margin: 0; }
.detail .links { margin-top: 10px; display: flex; gap: 16px; font-size: .88rem; }

.empty { padding: 28px 16px; margin: 0; text-align: center; color: var(--muted); }

/* ---------- Fuß ---------- */
.foot { padding: 8px clamp(16px, 3vw, 32px) 32px; color: var(--muted); font-size: .85rem; max-width: 80ch; }
.foot summary { cursor: pointer; color: var(--ink); }
.foot details p { margin: 8px 0; }
.credits { margin: 6px 0; }
.credits a { margin-right: 12px; }

/* ---------- Dialog ---------- */
dialog {
  border: 1px solid var(--rule-strong); border-radius: 10px; padding: 0;
  background: var(--surface); color: var(--ink);
  width: min(420px, calc(100vw - 32px));
}
dialog::backdrop { background: rgba(20, 26, 31, .45); }
dialog form { padding: 22px 24px 20px; }
dialog h2 { margin: 0 0 6px; font-size: 1.2rem; }
.setup-text { margin: 0 0 16px; color: var(--muted); }
.setup-field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.setup-field span { font-size: .85rem; font-weight: 600; }
.setup-field input {
  background: var(--paper); border: 1px solid var(--rule-strong); border-radius: var(--radius);
  padding: 9px 11px; font-size: 1.05rem; letter-spacing: .03em;
}
.setup-field input[aria-invalid="true"] { border-color: #c2412d; }
.setup-station { border: 0; padding: 0; margin: 14px 0 0; }
.setup-station legend { font-size: .85rem; font-weight: 600; margin-bottom: 6px; padding: 0; }
.setup-station label { display: flex; align-items: center; gap: 8px; padding: 3px 0; cursor: pointer; }
.setup-station input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
.setup-error { color: #c2412d; min-height: 1.2em; margin: 10px 0 0; font-size: .88rem; }
.setup-note { color: var(--muted); font-size: .8rem; margin: 6px 0 16px; }
.setup-actions { display: flex; justify-content: flex-end; gap: 10px; }
.btn-primary, .btn-secondary { border-radius: var(--radius); padding: 8px 16px; cursor: pointer; font-weight: 600; }
.btn-primary { background: var(--accent); color: var(--surface); border: 1px solid var(--accent); }
.btn-secondary { background: none; border: 1px solid var(--rule-strong); }

/* ---------- Schmale Bildschirme ---------- */
@media (max-width: 900px) {
  .col-comment, .t-comment { display: none; }
}
@media (max-width: 680px) {
  .top { gap: 12px; }
  .conditions { order: 3; width: 100%; justify-content: space-between; }
  .col-de, .t-de { display: none; }
  .chance-label { display: none; }
  .col-time { display: none; }
  .t-dx small.m-time { display: block; }
  .band-unit { display: none; }
  .bands-label { font-size: .68rem; padding-right: 10px; }
  .band { flex-basis: 52px; padding: 8px 8px 9px; }
  .spots td, .spots th button { padding-left: 8px; padding-right: 8px; }
  .callsearch { width: 100%; }
  .callsearch .search { flex: 1; }
  .search input { width: 100%; }
  .detail-grid { grid-template-columns: 1fr; }
}

/* ---------- Versionshinweise ---------- */
.version-new::after {
  content: ""; display: inline-block; width: 7px; height: 7px; margin-left: 5px;
  border-radius: 50%; background: var(--possible); vertical-align: 1px;
}
.version-tag { color: var(--muted); font-size: .85rem; }
#changelog { width: min(560px, calc(100vw - 32px)); }
.changelog { padding: 20px 24px 22px; max-height: min(80vh, 720px); overflow-y: auto; }
.changelog-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 8px; }
.changelog-head h2 { margin: 0; }
.release { padding: 12px 0; border-top: 1px solid var(--rule); }
.release:first-child { border-top: 0; }
.release h3 { margin: 0 0 2px; font-size: 1rem; }
.release .release-meta { margin: 0 0 6px; color: var(--muted); font-size: .85rem; }
.release ul { margin: 0; padding-left: 20px; }
.release li { margin: 3px 0; }
