:root {
  --bg: #0b1016;
  --panel: #111922;
  --panel-2: #16202b;
  --line: #1f2b38;
  --text: #dbe6f0;
  --muted: #7f93a6;
  --faint: #56687a;
  --accent: #4cc9f0;
  --live: #ff6b6b;
  --amber: #f5b942;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 var(--sans);
  overflow: hidden;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------------------------------------------------------------- header */
.top {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  flex: none;
}
.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
  text-decoration: none;
  font-weight: 650;
  font-size: 17px;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.brand svg { color: var(--accent); }
.top-status { display: flex; align-items: center; gap: 10px; font-size: 13px; white-space: nowrap; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 12px;
}
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.pill.on::before { background: #4ade80; box-shadow: 0 0 6px #4ade80; }
.pill.off { color: var(--muted); }
.search { margin-left: auto; flex: 0 1 300px; min-width: 0; }
.search input, .side-head input[type="search"], .jump input {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 11px;
}
.jump { display: flex; align-items: center; gap: 7px; font-size: 13px; white-space: nowrap; }
.jump input { width: auto; padding: 6px 8px; font-size: 13px; }
.about-link { color: var(--accent); text-decoration: none; font-size: 13.5px; white-space: nowrap; }
.about-link:hover { text-decoration: underline; }
.ghost {
  background: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 12px;
}
.ghost:hover { background: var(--panel-2); }
.only-narrow { display: none; }

/* ---------------------------------------------------------------- band */
.band { position: relative; flex: none; border-bottom: 1px solid var(--line); background: #0a1018; }
#spectrum { display: block; width: 100%; height: 84px; cursor: crosshair; }
.spec-tip {
  position: absolute;
  top: 22px;
  padding: 2px 8px;
  border-radius: 6px;
  background: rgba(8, 12, 18, 0.92);
  border: 1px solid var(--line);
  font: 12px var(--mono);
  pointer-events: none;
  white-space: nowrap;
}

/* ---------------------------------------------------------------- layout */
.layout { display: flex; flex: 1; min-height: 0; }
.side {
  width: 310px;
  flex: none;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: var(--panel);
  min-height: 0;
}
.side-head { padding: 12px; display: grid; gap: 10px; border-bottom: 1px solid var(--line); }
.squelch { display: grid; grid-template-columns: auto 1fr 44px; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }
.squelch input { width: 100%; accent-color: var(--accent); }
.squelch output { font: 12px var(--mono); color: var(--text); text-align: right; }
.side-buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: none;
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}
.chip.on { border-color: var(--accent); color: var(--accent); background: rgba(76, 201, 240, 0.08); }
.chip.check input { accent-color: var(--accent); margin: 0; }
.chan-list { list-style: none; margin: 0; padding: 6px; overflow-y: auto; flex: 1; min-height: 0; }
.chan-list .pad { padding: 10px; }
.chan {
  width: 100%;
  display: grid;
  grid-template-columns: 10px 62px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: none;
  text-align: left;
}
.chan:hover { background: var(--panel-2); }
.chan.on { border-color: var(--accent); background: rgba(76, 201, 240, 0.08); }
.c-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--kind, var(--faint)); opacity: 0.55; }
.chan.live .c-dot { background: var(--live); opacity: 1; box-shadow: 0 0 8px var(--live); animation: pulse 1s ease-in-out infinite; }
.c-freq { font: 600 13px var(--mono); }
.c-label { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.c-n { font-size: 11px; color: var(--muted); white-space: nowrap; }
.chan.live .c-n { color: var(--live); }
.about { padding: 10px 12px; border-top: 1px solid var(--line); font-size: 11.5px; line-height: 1.5; }
.about b { color: var(--text); font-weight: 600; }

[data-kind="ctaf"] { --kind: #4ade80; }
[data-kind="tower"] { --kind: #f5b942; }
[data-kind="ground"], [data-kind="clearance"] { --kind: #2dd4bf; }
[data-kind="approach"] { --kind: #60a5fa; }
[data-kind="center"] { --kind: #c084fc; }
[data-kind="fss"] { --kind: #f472b6; }
[data-kind="guard"] { --kind: #ff6b6b; }
[data-kind="atis"], [data-kind="awos"] { --kind: #94a3b8; }
[data-kind="airtoair"], [data-kind="other"] { --kind: #fb923c; }
[data-kind="unknown"] { --kind: #64748b; }

/* ---------------------------------------------------------------- feed */
.feed-wrap { position: relative; flex: 1; min-width: 0; display: flex; flex-direction: column; }
.feed { flex: 1; overflow-y: auto; overscroll-behavior: contain; outline: none; }
.rows { list-style: none; margin: 0; padding: 0; }
.feed-edge { padding: 14px 18px; text-align: center; font-size: 13px; }
.feed-edge:empty { display: none; }
.day {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 5px 18px;
  background: rgba(11, 16, 22, 0.94);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.row {
  --p: 0;
  position: relative;
  display: grid;
  grid-template-columns: 68px 250px minmax(0, 1fr) 82px 46px;
  align-items: baseline;
  gap: 12px;
  padding: 7px 18px;
  border-bottom: 1px solid rgba(31, 43, 56, 0.55);
  cursor: pointer;
}
.row:hover { background: var(--panel); }
.row.hidden { display: none; }
.r-time { font: 12.5px var(--mono); color: var(--muted); }
.r-chan { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.r-freq { font: 600 13.5px var(--mono); color: var(--kind, var(--text)); }
.r-label { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.r-text { overflow-wrap: anywhere; }
.r-text.faint { color: var(--faint); font-style: italic; }
.also { font-size: 11.5px; color: var(--accent); border: 1px solid rgba(76, 201, 240, 0.4); background: rgba(76, 201, 240, 0.07); border-radius: 999px; padding: 0 7px; white-space: nowrap; font-style: normal; }
.r-meta { display: flex; align-items: baseline; justify-content: flex-end; gap: 8px; font: 12px var(--mono); color: var(--muted); }
.r-sig { display: inline-flex; align-items: flex-end; gap: 2px; height: 11px; }
.r-sig i { width: 3px; background: var(--line); border-radius: 1px; }
.r-sig i:nth-child(1) { height: 4px; }
.r-sig i:nth-child(2) { height: 6px; }
.r-sig i:nth-child(3) { height: 8px; }
.r-sig i:nth-child(4) { height: 11px; }
.r-sig[data-bars="1"] i:nth-child(-n+1),
.r-sig[data-bars="2"] i:nth-child(-n+2),
.r-sig[data-bars="3"] i:nth-child(-n+3),
.r-sig[data-bars="4"] i:nth-child(-n+4) { background: var(--muted); }
.r-act { display: flex; gap: 4px; justify-content: flex-end; opacity: 0; }
.row:hover .r-act, .row.playing .r-act, .row:focus-within .r-act { opacity: 1; }
.r-act a, .r-act button {
  color: var(--muted);
  background: none;
  border: 0;
  padding: 0 4px;
  text-decoration: none;
  font-size: 15px;
  line-height: 1;
}
.r-act a:hover, .r-act button:hover { color: var(--accent); }

.row.live::before {
  content: "";
  position: absolute;
  left: 6px;
  top: 50%;
  width: 7px;
  height: 7px;
  margin-top: -3.5px;
  border-radius: 50%;
  background: var(--live);
  animation: pulse 1s ease-in-out infinite;
}
.row.playing { background: linear-gradient(90deg, rgba(76, 201, 240, 0.13), rgba(76, 201, 240, 0.05)); }
.row.playing { box-shadow: inset 3px 0 0 var(--accent); }
.row.playing::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -1px;
  height: 2px;
  width: calc(var(--p) * 100%);
  background: var(--accent);
  transition: width 0.08s linear;
}
.row.playing .r-text { color: #fff; }
.row.target { box-shadow: inset 0 0 0 1px var(--amber); }
@keyframes pulse { 50% { opacity: 0.35; } }

.floating {
  position: absolute;
  right: 22px;
  bottom: 16px;
  border: 1px solid var(--accent);
  background: #0f2733;
  color: var(--accent);
  border-radius: 999px;
  padding: 7px 14px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
}
.notice {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 13px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
}

/* ---------------------------------------------------------------- transport */
.transport {
  flex: none;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--panel);
}
.tp-left, .tp-right { display: flex; align-items: center; gap: 8px; flex: none; }
.tp-now { flex: 1; min-width: 0; }
.now-line { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.now-sub { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.primary {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 0;
  background: var(--accent);
  color: #06222c;
}
.primary:hover { filter: brightness(1.1); }
.primary .i-pause { display: none; }
body.audio-on:not(.paused) .primary .i-play { display: none; }
body.audio-on:not(.paused) .primary .i-pause { display: block; }
body:not(.audio-on) .primary { animation: beckon 2s ease-in-out infinite; }
@keyframes beckon { 50% { box-shadow: 0 0 0 9px rgba(76, 201, 240, 0.16); } }
.icon { width: 36px; height: 36px; padding: 0; display: grid; place-items: center; border-color: transparent; color: var(--muted); }
.icon:hover { color: var(--text); }
.icon.on { color: var(--accent); border-color: var(--accent); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: none; padding: 6px 12px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: rgba(76, 201, 240, 0.12); color: var(--accent); }
.select { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; white-space: nowrap; }
.select select { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; font-size: 13px; }
.live-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--amber);
  color: var(--amber);
  background: rgba(245, 185, 66, 0.08);
  border-radius: 8px;
  padding: 6px 12px;
  font: 600 12.5px var(--mono);
  letter-spacing: 0.05em;
  white-space: nowrap;
}
.live-btn .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.live-btn.is-live { border-color: var(--line); color: var(--live); background: none; }
.live-btn.is-live .dot { animation: pulse 1.2s ease-in-out infinite; box-shadow: 0 0 8px var(--live); }
body:not(.audio-on) .live-btn { border-color: var(--line); color: var(--muted); background: none; }
.volume { width: 96px; accent-color: var(--accent); }

/* ---------------------------------------------------------------- narrow screens */
@media (max-width: 1100px) {
  .row { grid-template-columns: 62px 190px minmax(0, 1fr) 74px 40px; }
  .jump span { display: none; }
  .select span { display: none; }
}
@media (max-width: 820px) {
  .only-narrow { display: inline-block; }
  .top { flex-wrap: wrap; gap: 8px 10px; padding: 8px 12px; }
  .search { order: 5; flex: 1 1 55%; margin-left: 0; }
  .jump { order: 6; flex: 1 1 35%; }
  .jump input { width: 100%; }
  .top-status { margin-left: auto; }
  #listeners { display: none; }
  #spectrum { height: 64px; }
  .side {
    position: fixed;
    z-index: 5;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(88vw, 340px);
    transform: translateX(-102%);
    transition: transform 0.2s ease;
    box-shadow: 12px 0 40px rgba(0, 0, 0, 0.5);
  }
  body.side-open .side { transform: none; }
  .row {
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas: "time chan meta" "text text text";
    gap: 2px 10px;
    padding: 8px 12px;
  }
  .r-time { grid-area: time; }
  .r-chan { grid-area: chan; }
  .r-meta { grid-area: meta; }
  .r-text { grid-area: text; }
  .r-act { display: none; }
  .day { padding: 5px 12px; }
  .transport { flex-wrap: wrap; gap: 8px 10px; padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); }
  .tp-now { order: -1; flex: 1 1 100%; }
  .tp-right { flex: 1; justify-content: flex-end; flex-wrap: wrap; }
  .volume { display: none; }
  .select select { max-width: 120px; }
  #btnRepeat { display: none; }
}
