:root {
  --bg: #0c0d10;
  --panel: #131518;
  --panel-2: #1c1e22;
  --line: #26292f;
  --text: #e8eaed;
  --muted: #8b9099;
  --live: #ff3b30;
  --live-dim: #7a1c17;
  --ready: #30d158;
  --warn: #ff9f0a;
  --radius: 14px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body {
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           env(safe-area-inset-bottom) env(safe-area-inset-left);
  overscroll-behavior: none;
}

a { color: inherit; }

.mono {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-variant-numeric: tabular-nums;
}

/* ---------- talk screen ---------- */

.talk {
  display: flex;
  flex-direction: column;
  height: 100%;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.talk header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 18px 0 8px;
}

.talk header .grow { flex: 1; }

.talk header h1 {
  margin: 0;
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.route {
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.02em;
}

.stage {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 12px;
  min-height: 0;
}

.ptt {
  position: relative;
  width: min(74vw, 44vh, 320px);
  aspect-ratio: 1;
  border: none;
  border-radius: 50%;
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  padding: 0;
  cursor: pointer;
  touch-action: none;
  transition: background 120ms ease, transform 90ms ease, box-shadow 160ms ease;
  box-shadow: inset 0 0 0 1px var(--line);
}

.ptt .ring {
  position: absolute;
  inset: 0;
  transform: rotate(-90deg);
  pointer-events: none;
}

.ptt .ring circle {
  fill: none;
  stroke-width: 3;
  stroke-linecap: round;
}

.ptt .ring .track { stroke: var(--line); }
.ptt .ring .level {
  stroke: var(--ready);
  transition: stroke-dashoffset 60ms linear;
}

.ptt .cap {
  position: relative;
  font-size: clamp(15px, 4.6vw, 21px);
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.ptt .sub {
  position: relative;
  display: block;
  margin-top: 6px;
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.04em;
  text-transform: none;
  color: var(--muted);
}

.ptt[data-state="live"] {
  background: var(--live);
  box-shadow: 0 0 0 1px var(--live), 0 0 60px -8px var(--live);
  transform: scale(0.985);
}
.ptt[data-state="live"] .sub { color: rgba(255, 255, 255, 0.75); }
.ptt[data-state="live"] .ring .level { stroke: #fff; }
.ptt[data-state="connecting"] { opacity: 0.6; }
.ptt[data-state="error"] { box-shadow: inset 0 0 0 1px var(--live-dim); }

.talk footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 20px 22px;
}

.status {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  min-width: 0;
}

.status span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  flex: none;
}
.dot[data-s="ok"] { background: var(--ready); }
.dot[data-s="live"] { background: var(--live); }
.dot[data-s="bad"] { background: var(--warn); }

.mode {
  display: flex;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px;
  flex: none;
}

.mode button {
  border: none;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  letter-spacing: 0.04em;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
}

.mode button[aria-pressed="true"] {
  background: var(--panel-2);
  color: var(--text);
}

/* ---------- top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 8px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--line);
}

.topbar h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.topbar .grow { flex: 1; }

.back {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  min-width: 44px;
  min-height: 44px;
  padding: 0 10px 0 4px;
  border-radius: 10px;
  color: var(--muted);
  text-decoration: none;
  font-size: 15px;
}
.back:active { background: var(--panel-2); }
.back::before {
  content: "‹";
  font-size: 26px;
  line-height: 1;
  margin-top: -3px;
}

.forward {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 10px;
  color: var(--muted);
  text-decoration: none;
  font-size: 15px;
}
.forward:active { background: var(--panel-2); }
.forward::after {
  content: "›";
  font-size: 26px;
  line-height: 1;
  margin-top: -3px;
}

/* ---------- lists / admin ---------- */

.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 18px 20px 64px;
}

h2 {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 32px 0 10px;
}

.card {
  display: block;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 10px;
  text-decoration: none;
}

.card.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.card .name { font-weight: 600; }
.card .meta { color: var(--muted); font-size: 13px; margin-top: 2px; }

.field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}
.field:last-child { border-bottom: none; }
.field label { color: var(--muted); font-size: 14px; }

select, input[type="number"] {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 8px 10px;
  font: inherit;
  max-width: 60%;
}

button.action {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 9px 14px;
  font: inherit;
  cursor: pointer;
}
button.action:hover { background: #23262b; }

.banner {
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 14px;
}
.banner.bad { background: #2a1513; border: 1px solid var(--live-dim); color: #ffb4ae; }
.banner.warn { background: #2a2210; border: 1px solid #5c4611; color: #ffd699; }

.meter {
  height: 4px;
  border-radius: 2px;
  background: var(--line);
  overflow: hidden;
  width: 90px;
  flex: none;
}
.meter i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--ready);
  transition: width 60ms linear;
}

.qr {
  background: #fff;
  padding: 16px;
  border-radius: var(--radius);
  width: fit-content;
  margin: 0 auto 18px;
}
.qr svg { display: block; width: min(62vw, 260px); height: auto; }

.urls { list-style: none; padding: 0; margin: 0; }
.urls li {
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
  word-break: break-all;
}
.urls li:last-child { border-bottom: none; }

/* ---------- routing controls ---------- */

.seg {
  display: inline-flex;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px;
}

.seg button {
  border: none;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
  min-height: 32px;
}

.seg button[aria-pressed="true"] {
  background: var(--panel-2);
  color: var(--text);
}

.route-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.chip {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg);
  font-size: 12px;
  color: var(--muted);
}
.chip.bad { border-color: var(--live-dim); color: #ffb4ae; }

.hint {
  color: var(--muted);
  font-size: 13px;
  margin: -2px 0 14px;
}
