:root {
  color-scheme: dark;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #08110e;
  color: #f4f7f5;
  letter-spacing: 0;
  --bg: #08110e;
  --surface: #111d18;
  --surface-2: #16251e;
  --line: #294036;
  --muted: #9dafA6;
  --teal: #1597a5;
  --green: #21b56f;
  --amber: #e7aa3b;
  --red: #dc4e52;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); }
body { padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); }
button, input, select { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }

.topbar {
  min-height: 76px;
  padding: 13px max(16px, env(safe-area-inset-right)) 12px max(16px, env(safe-area-inset-left));
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #0b1511;
}

h1, h2, p { margin: 0; }
h1 { font-size: 22px; line-height: 1.15; }
.topbar p { color: var(--muted); font-size: 13px; margin-top: 4px; }
.connection-badge { padding: 7px 10px; border-radius: 6px; font-size: 13px; font-weight: 750; }
.connection-badge.online { color: #d7ffeb; background: #146e48; }
.connection-badge.connecting { color: #fff1cd; background: #735516; }
.connection-badge.offline { color: #ffdfe0; background: #702a2d; }

main { width: min(760px, 100%); margin: 0 auto; }
.auth-panel { padding: 28px 16px; }
.auth-panel form { width: min(420px, 100%); margin: 0 auto; }
.auth-panel h2 { font-size: 19px; margin-bottom: 20px; }
label { display: block; font-weight: 700; font-size: 14px; margin: 14px 0 7px; }
input, select {
  width: 100%;
  min-height: 48px;
  color: #fff;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  outline: none;
}
input:focus, select:focus { border-color: var(--teal); box-shadow: 0 0 0 2px #1597a533; }
.primary-command, .join-command, .quiet-command {
  border: 1px solid var(--line);
  border-radius: 6px;
  min-height: 46px;
  font-weight: 800;
}
.primary-command { width: 100%; margin-top: 20px; color: #fff; background: var(--teal); border-color: var(--teal); }
.error { min-height: 22px; margin-top: 10px; color: #ff9b9e; font-size: 14px; }

.radio-view { padding-bottom: 24px; }
.session-bar {
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.session-bar strong { display: block; font-size: 17px; }
.session-bar span { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; }
.quiet-command { background: transparent; color: #dce7e1; padding: 0 12px; }
.join-command { display: block; width: calc(100% - 32px); margin: 2px 16px 14px; color: #fff; background: var(--teal); border-color: var(--teal); }
.join-command:disabled { color: #8fa198; background: var(--surface); border-color: var(--line); cursor: default; }

.map-section { position: relative; width: 100%; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
#map { width: 100%; height: clamp(250px, 42vh, 390px); background: #12201a; }
.map-status {
  position: absolute;
  z-index: 500;
  left: 10px;
  bottom: 10px;
  max-width: calc(100% - 20px);
  padding: 6px 9px;
  border-radius: 5px;
  background: #08110ed9;
  color: #dce8e1;
  font-size: 12px;
  border: 1px solid #345044;
  cursor: pointer;
  text-align: left;
}
.map-status.active { color: #d7ffeb; border-color: #1d8058; }
.map-status.denied { color: #ffe0c2; border-color: #9b5c24; }
.leaflet-control-attribution { font-size: 9px; }
.person-marker {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid #e9f7f0;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 900;
  background: var(--teal);
  box-shadow: 0 3px 12px #0009;
}
.person-marker.self { background: var(--green); }
.person-marker.speaking { background: var(--red); animation: speak-pulse 0.9s infinite; }
@keyframes speak-pulse { 50% { box-shadow: 0 0 0 12px #dc4e5238, 0 3px 12px #0009; } }

.people-section { padding: 15px 16px 4px; }
.section-title { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.section-title h2 { font-size: 16px; }
.section-title span { color: var(--muted); font-size: 13px; }
.people-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(145px, 1fr)); gap: 8px; margin-top: 10px; }
.person-row {
  min-height: 56px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  background: var(--surface);
  display: flex;
  align-items: center;
  gap: 9px;
}
.person-row.speaking { border-color: var(--red); background: #2b1718; }
.person-dot { width: 10px; height: 10px; flex: 0 0 auto; border-radius: 50%; background: #66766e; }
.person-row.online .person-dot { background: var(--green); }
.person-row.speaking .person-dot { background: var(--red); }
.person-row strong { display: block; font-size: 14px; }
.person-row small { display: block; color: var(--muted); font-size: 11px; margin-top: 2px; }

.talk-section { padding: 16px; text-align: center; }
.speaker-text { min-height: 25px; color: #dce8e1; font-weight: 800; }
.talk-button {
  width: 174px;
  aspect-ratio: 1;
  margin-top: 9px;
  border-radius: 50%;
  border: 7px solid #254139;
  background: #176b4a;
  color: #fff;
  box-shadow: inset 0 0 0 2px #56c99555, 0 9px 25px #0008;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.talk-button span { display: block; font-size: 20px; font-weight: 950; }
.talk-button small { display: block; font-size: 11px; margin-top: 4px; opacity: 0.82; }
.talk-button:disabled { filter: grayscale(1); opacity: 0.45; cursor: default; }
.talk-button.requesting { background: var(--amber); border-color: #796024; }
.talk-button.transmitting { background: var(--red); border-color: #7c292c; transform: scale(0.97); }
.talk-button.busy { background: #5c3334; border-color: #6b4546; }

@media (min-width: 700px) {
  .topbar { padding-left: max(calc((100vw - 760px) / 2 + 16px), 16px); padding-right: max(calc((100vw - 760px) / 2 + 16px), 16px); }
  .radio-view { border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
}

@media (max-width: 390px) {
  h1 { font-size: 20px; }
  .connection-badge { font-size: 12px; }
  .talk-button { width: 154px; }
}
