/*
 * The phone radio (radio.atxrp.agency): one screen, dark, big targets, the PTT under the thumb.
 * No inline styles anywhere - the console's CSP refuses them - so every state is a class.
 */
:root {
  --bg: #111417;
  --panel: #1a1e23;
  --panel2: #22272d;
  --line: #2e343b;
  --text: #e8ecf0;
  --dim: #8d98a3;
  --accent: #3d8bfd;
  --rx: #36c26b;
  --tx: #e5383b;
  --warn: #f0a020;
  --emerg: #d7191c;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; }
.hidden { display: none !important; }

/* --- before the radio is on --------------------------------------------------------------- */
.gate {
  min-height: 100dvh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px 20px calc(24px + env(safe-area-inset-bottom));
  text-align: center; gap: 10px;
}
.gate-logo { width: 132px; height: auto; }
.gate h1 { margin: 4px 0 0; font-size: 24px; letter-spacing: .02em; }
.gate-msg { margin: 0; color: var(--dim); max-width: 340px; }
.gate-btn {
  margin-top: 14px; min-width: 240px; padding: 16px 22px;
  border: 0; border-radius: 14px; background: var(--accent); color: #fff;
  font-size: 17px; font-weight: 600; cursor: pointer;
}
.gate-btn:active { filter: brightness(.9); }
.gate-fine { margin: 6px 0 0; color: var(--dim); font-size: 13px; max-width: 340px; }

/* --- the radio ------------------------------------------------------------------------------- */
.app {
  height: 100dvh;
  display: flex; flex-direction: column;
  padding-top: env(safe-area-inset-top);
}
.top {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--panel);
}
.top-ic { width: 28px; height: 28px; }
.top-id { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.top-unit { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-sys { font-size: 12px; color: var(--dim); }
.top-sys.ok::before, .top-sys.bad::before, .top-sys.part::before {
  content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 1px;
}
.top-sys.ok::before { background: var(--rx); }
.top-sys.part::before { background: var(--warn); }
.top-sys.bad::before { background: var(--tx); }
.icon-btn {
  width: 44px; height: 44px; border: 0; border-radius: 10px; background: transparent;
  display: grid; place-items: center; cursor: pointer;
}
.icon-btn svg { width: 24px; height: 24px; }
.icon-btn:active { background: var(--panel2); }

/* Emergencies */
.emerg { padding: 8px 10px 0; display: flex; flex-direction: column; gap: 8px; }
.em {
  border-radius: 12px; padding: 10px 12px; background: var(--emerg); color: #fff;
  display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center;
}
.em.unacked { animation: flash 1s steps(2, start) infinite; }
.em.acked { background: #5a1a1b; }
@keyframes flash { 50% { background: #7d0a0c; } }
.em-t { font-weight: 700; letter-spacing: .02em; }
.em-d { grid-column: 1; font-size: 13px; opacity: .92; }
.em-b { grid-column: 2; grid-row: 1 / span 2; display: flex; gap: 6px; }
.em-b button {
  border: 1px solid rgba(255, 255, 255, .55); background: rgba(0, 0, 0, .18); color: #fff;
  border-radius: 9px; padding: 9px 12px; font-weight: 600; cursor: pointer; min-height: 40px;
}
.em-b button:active { background: rgba(0, 0, 0, .35); }

/* The selected channel */
.disp {
  display: flex; align-items: stretch; gap: 6px;
  margin: 10px; padding: 10px 6px; border-radius: 16px;
  background: var(--panel); border: 1px solid var(--line);
}
.disp.rx { border-color: var(--rx); box-shadow: 0 0 0 1px var(--rx) inset; }
.disp.tx { border-color: var(--tx); box-shadow: 0 0 0 1px var(--tx) inset; }
.disp.down { opacity: .7; }
.step {
  width: 48px; border: 0; border-radius: 12px; background: var(--panel2); cursor: pointer;
  display: grid; place-items: center;
}
.step svg { width: 26px; height: 26px; }
.step:active { background: var(--line); }
.disp-mid { flex: 1; min-width: 0; text-align: center; padding: 2px 0; }
.disp-zone { font-size: 12px; letter-spacing: .14em; color: var(--dim); text-transform: uppercase; }
.disp-name { font-size: 28px; font-weight: 700; letter-spacing: .02em; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.disp-talk { min-height: 22px; margin-top: 4px; font-size: 15px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.disp-talk.rx { color: var(--rx); font-weight: 600; }
.disp-talk.tx { color: var(--tx); font-weight: 700; }
.disp-talk.warn { color: var(--warn); }
.meter { height: 4px; margin: 8px 12px 0; border-radius: 2px; background: var(--panel2); overflow: hidden; }
.meter-bar { height: 100%; width: 0; background: var(--rx); transition: width 60ms linear; }
.meter-bar.tx { background: var(--tx); }

/* Tabs and the list */
.tabs { display: flex; gap: 6px; padding: 0 10px; }
.tab {
  flex: 1; padding: 9px 0; border: 0; border-radius: 10px; background: transparent; color: var(--dim);
  font-weight: 600; cursor: pointer;
}
.tab.on { background: var(--panel2); color: var(--text); }
.body { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 8px 10px 10px; }
.fold { margin: 6px 4px 4px; font-size: 12px; letter-spacing: .14em; color: var(--dim); }
.ch {
  display: flex; align-items: center; gap: 4px;
  margin-bottom: 6px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line);
}
.ch.sel { border-color: var(--accent); background: #18263a; }
.ch.rx .ch-who { color: var(--rx); }
.ch.tx .ch-who { color: var(--tx); }
.ch.em { border-color: var(--emerg); }
.ch-main {
  flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start;
  padding: 10px 12px; border: 0; background: transparent; text-align: left; cursor: pointer;
}
.ch-name { font-weight: 600; font-size: 16px; }
.ch-who { font-size: 13px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.ch-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--dim); flex: none; }
.ch-dot.up { background: var(--rx); }
.ch-dot.connecting, .ch-dot.reconnecting { background: var(--warn); }
.ch-dot.down { background: var(--tx); }
.mon {
  width: 52px; height: 52px; margin-right: 4px; border: 0; border-radius: 10px; background: transparent;
  color: var(--dim); display: grid; place-items: center; cursor: pointer;
}
.mon svg { width: 24px; height: 24px; }
.mon.on { color: var(--accent); }
.mon:active { background: var(--panel2); }
.mon:disabled { opacity: .35; }
.empty { color: var(--dim); text-align: center; padding: 24px 0; }

/* Activity */
.lg { display: grid; grid-template-columns: auto 1fr auto; gap: 2px 10px; padding: 9px 4px; border-bottom: 1px solid var(--line); }
.lg-t { color: var(--dim); font-variant-numeric: tabular-nums; font-size: 13px; }
.lg-w { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lg-w.live { color: var(--rx); }
.lg-w.me { color: var(--tx); }
.lg-w.emg { color: #ff6b6b; }
.lg-c { color: var(--dim); font-size: 13px; text-align: right; }
.lg-s { grid-column: 2 / span 2; color: var(--dim); font-size: 13px; }

/* PTT */
.dock { padding: 8px 10px calc(10px + env(safe-area-inset-bottom)); background: var(--bg); border-top: 1px solid var(--line); }
.ptt {
  width: 100%; height: 104px; border: 0; border-radius: 22px;
  background: #2b3540; color: #fff; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  box-shadow: 0 2px 0 #0b0d10, inset 0 1px 0 rgba(255, 255, 255, .06);
}
.ptt-t { font-size: 20px; font-weight: 800; letter-spacing: .08em; pointer-events: none; }
.ptt-s { font-size: 13px; color: rgba(255, 255, 255, .7); pointer-events: none; min-height: 17px; }
.ptt.busy { background: #8a5a00; }
.ptt.tx { background: var(--tx); box-shadow: 0 0 0 4px rgba(229, 56, 59, .35); }
.ptt.off { background: #23282e; color: var(--dim); }

/* Settings sheet */
.sheet-bg { position: fixed; inset: 0; background: rgba(0, 0, 0, .5); z-index: 10; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 11;
  max-height: 85dvh; overflow-y: auto;
  background: var(--panel); border-radius: 18px 18px 0 0; border-top: 1px solid var(--line);
  padding: 6px 16px calc(16px + env(safe-area-inset-bottom));
}
.sheet-h { display: flex; align-items: center; justify-content: space-between; font-weight: 700; font-size: 17px; }
.row { display: flex; flex-direction: column; gap: 6px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.row.tog { flex-direction: row; align-items: center; justify-content: space-between; }
.row.tog input { width: 24px; height: 24px; accent-color: var(--accent); }
.row input[type="range"] { width: 100%; accent-color: var(--accent); }
.row.btns { flex-direction: row; gap: 8px; border-bottom: 0; }
.row.btns button {
  flex: 1; padding: 12px 0; border: 1px solid var(--line); border-radius: 10px; background: var(--panel2); cursor: pointer;
}
.row.btns button.danger { color: #ff6b6b; }
.sheet-note { margin: 8px 0 0; font-size: 13px; color: var(--dim); }

.toast {
  position: fixed; left: 50%; bottom: calc(132px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 20;
  max-width: calc(100% - 32px); padding: 10px 14px; border-radius: 10px;
  background: #2b3036; border: 1px solid var(--line); font-size: 14px; text-align: center;
}
.toast.err { border-color: var(--tx); }

/* A wider screen (a tablet, a desktop window): the same radio, kept phone-width. */
@media (min-width: 640px) {
  .app { max-width: 520px; margin: 0 auto; border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
  .sheet { max-width: 520px; margin: 0 auto; }
}
