: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; }
.ghost {
  background: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 12px;
}
.ghost:hover { background: var(--panel-2); }
.top-link { color: var(--text); text-decoration: none; white-space: nowrap; }
.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 6px; flex-wrap: wrap; }
.side-buttons .chip { padding: 4px 9px; white-space: nowrap; }
.side-switches { display: flex; gap: 6px; }     /* the two switches stay side by side: on the line below where there is no room beside the button */
.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 44px;
  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-count { font: 11.5px var(--mono); color: var(--text); opacity: 0.8; white-space: nowrap; }
.c-n { font-size: 11px; color: var(--muted); white-space: nowrap; text-align: right; }
.chan-sort { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.chan-sort .seg button { padding: 3px 10px; font-size: 12px; }
.chan-sort-key { margin-left: auto; font-size: 11px; color: var(--faint); 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; }
/* One speaker's turn to a line: a ground station at the margin, an aircraft set in from it behind a rule. */
.r-text .turn { display: block; }
.r-text .turn + .turn { margin-top: 3px; }
.r-text .turn[data-who="aircraft"] { margin-left: 4px; padding-left: 14px; border-left: 2px solid var(--line); }
/* Words the transcriber was less than sure of (a call sign, a number, a fix): a dotted line under them, and their
   figure beside them when they are pointed at or tapped. A dotted underline on a transmission's own words means this
   and nothing else: that the words may not be what was said. How a connection between things was come by is another
   matter, and whatever shows that one day is not to look like this. */
.r-text .heard.unsure {
  text-decoration: underline;               /* (each part by itself: a browser that knows only the first still marks the words) */
  text-decoration-style: dotted;
  text-decoration-color: var(--muted);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
  cursor: help;
}
.heard-tip {
  position: absolute;
  z-index: 4;
  padding: 3px 9px;
  border-radius: 6px;
  background: rgba(8, 12, 18, 0.96);
  border: 1px solid var(--line);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
  font-size: 12px;
  white-space: nowrap;
  pointer-events: none;
}
.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);
}

/* Shown after the page has reloaded itself for a release, in a browser that wants a tap before it plays sound again. */
.resume {
  flex: none;
  border: 0;
  border-top: 1px solid var(--accent);
  background: #0f2733;
  color: var(--accent);
  padding: 10px 16px;
  font-weight: 600;
  text-align: center;
}

/* ---------------------------------------------------------------- transport */
.transport {
  flex: none;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 16px 4px;
  border-top: 1px solid var(--line);
  background: var(--panel);
}
/* The last line of every page. Below the transport it is part of the same bar. */
.credit {
  flex: none;
  padding: 2px 16px calc(4px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--panel);
  font-size: 11.5px;
  line-height: 1.4;
  text-align: right;
}
.transport + .credit { border-top: 0; }
.credit a { color: var(--faint); text-decoration: none; }
.credit a:hover, .credit a:focus-visible { color: var(--accent); }
.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); }

/* ---------------------------------------------------------------- traffic board */
.board {
  width: 330px;
  flex: none;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-left: 1px solid var(--line);
  background: var(--panel);
}
.bd-head { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px 10px; border-bottom: 1px solid var(--line); }
.bd-head h2 { margin: 0 0 3px; font-size: 15px; font-weight: 650; }
.bd-head p { margin: 0; font-size: 11.5px; line-height: 1.4; }
.bd-close { display: none; margin-left: auto; padding: 2px 10px; font-size: 18px; line-height: 1.2; }
.board-btn { display: none; white-space: nowrap; }
.bd-body { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 10px 14px; }
.bd-group { padding-top: 10px; }
.bd-title { margin: 0 0 6px; padding: 0 4px; font-size: 13px; font-weight: 650; display: flex; align-items: baseline; gap: 8px; }
.bd-sub { font: 11.5px var(--mono); color: var(--muted); font-weight: 400; }
.bd-info { padding: 0 4px 6px; font-size: 12.5px; display: grid; gap: 3px; }
.bd-rwy { color: var(--muted); }
.bd-rwy b { color: var(--amber); font-weight: 600; }
.bd-wx { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 2px 4px; margin: 0 -4px; border-radius: 6px; font-size: 12.5px; color: var(--text); }
.bd-wx:hover { background: var(--panel-2); }
.bd-wx.old { color: var(--faint); }
.bd-wx b { font-weight: 600; }
.bd-none { padding: 2px 4px 4px; font-size: 12.5px; color: var(--faint); }
.bd-warn { margin: 10px 4px 0; padding: 7px 10px; border: 1px solid rgba(245, 185, 66, 0.5); border-radius: 8px; color: var(--amber); font-size: 12.5px; }
.ac {
  display: block;
  width: 100%;
  text-align: left;
  margin: 0 0 6px;
  padding: 7px 10px 8px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--ph, var(--faint));
  border-radius: 8px;
}
.ac:hover { border-color: var(--accent); border-left-color: var(--ph, var(--accent)); }
.ac-head { display: flex; align-items: baseline; gap: 8px; }
.ac-cs { font: 650 14px var(--mono); }
.ac-type { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ac-age { margin-left: auto; font: 11.5px var(--mono); color: var(--muted); white-space: nowrap; }
.ac-line { margin-top: 2px; font-size: 13px; display: flex; flex-wrap: wrap; gap: 2px 8px; }
.ac-phase { color: var(--ph, var(--muted)); font-weight: 600; }
.ac-intent { margin-top: 1px; font-size: 12.5px; color: var(--muted); }
.ac[data-phase="final"], .ac[data-phase="base"], .ac[data-phase="downwind"], .ac[data-phase="pattern"] { --ph: #4ade80; }
.ac[data-phase="inbound"] { --ph: #60a5fa; }
.ac[data-phase="departing"], .ac[data-phase="departed"] { --ph: #f5b942; }
.ac[data-phase="ground"], .ac[data-phase="landed"] { --ph: #94a3b8; }
.ac[data-phase="enroute"] { --ph: #c084fc; }

/* The feed's rows stack when the feed itself is narrow, whatever the window. */
.feed-wrap { container-type: inline-size; }
@container (max-width: 640px) {
  .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; }
}
@media (max-width: 1180px) {
  .board-btn:not([hidden]) { display: inline-block; }
  .bd-close { display: block; }
  .board {
    position: fixed;
    z-index: 5;
    top: 0;
    bottom: 0;
    right: 0;
    width: min(92vw, 360px);
    transform: translateX(102%);
    transition: transform 0.2s ease;
    box-shadow: -12px 0 40px rgba(0, 0, 0, 0.5);
  }
  body.board-open .board { transform: none; }
}

/* ---------------------------------------------------------------- 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 2px; }
  .credit { padding-left: 12px; padding-right: 12px; }
  .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; }
}
