:root {
  color-scheme: dark;
  --bg: #171d20;
  --panel: #252d31;
  --panel-2: #30393f;
  --panel-3: #111719;
  --line: #3d4a51;
  --line-bright: #58666e;
  --ink: #f4f7f4;
  --muted: #aab6ae;
  --dim: #737f78;
  --green: #55ee91;
  --green-dark: #178447;
  --amber: #f0b53e;
  --red: #f05252;
  --blue: #5fb7ff;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.36);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 18% 10%, rgba(85, 238, 145, 0.09), transparent 28%),
    radial-gradient(circle at 82% 20%, rgba(95, 183, 255, 0.08), transparent 30%),
    linear-gradient(135deg, #0f1416, #22292d 54%, #14191b);
  font-family:
    Inter, "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.app-shell {
  display: grid;
  min-height: 100vh;
  padding: 10px;
}

.talk-surface {
  display: grid;
  grid-template-rows: auto auto auto minmax(218px, 1fr) auto minmax(76px, 116px);
  gap: 10px;
  width: min(100%, 430px);
  min-height: calc(100vh - 20px);
  margin: 0 auto;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.02)),
    var(--panel);
  box-shadow: var(--shadow);
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.topbar h1 {
  margin: 2px 0 0;
  color: var(--green);
  font-size: 34px;
  line-height: 1;
}

.icon-action {
  min-width: 48px;
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line-bright);
  border-radius: 8px;
  color: var(--ink);
  background: #1a2225;
  font-size: 13px;
  font-weight: 900;
}

.status-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
}

.speaker-badge {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  max-width: 100%;
  padding: 0 11px;
  overflow: hidden;
  border: 1px solid rgba(85, 238, 145, 0.35);
  border-radius: 8px;
  color: #0a1b10;
  background: var(--green);
  font-size: 14px;
  font-weight: 950;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.speaker-badge.idle {
  color: var(--muted);
  background: #202a2e;
  border-color: var(--line);
}

.speaker-badge.busy {
  color: #221803;
  background: var(--amber);
  border-color: rgba(240, 181, 62, 0.5);
}

.signal-bars {
  display: flex;
  align-items: end;
  gap: 3px;
  height: 16px;
  margin-left: auto;
}

.signal-bars span {
  display: block;
  width: 4px;
  border-radius: 2px 2px 0 0;
  background: var(--green);
}

.signal-bars span:nth-child(1) {
  height: 7px;
}

.signal-bars span:nth-child(2) {
  height: 10px;
}

.signal-bars span:nth-child(3) {
  height: 14px;
}

.signal-bars span:nth-child(4) {
  height: 18px;
}

.battery {
  position: relative;
  width: 30px;
  height: 14px;
  padding: 2px;
  border: 2px solid var(--muted);
  border-radius: 4px;
}

.battery::after {
  position: absolute;
  top: 3px;
  right: -5px;
  width: 3px;
  height: 6px;
  border-radius: 0 2px 2px 0;
  background: var(--muted);
  content: "";
}

.battery span {
  display: block;
  width: 80%;
  height: 100%;
  border-radius: 2px;
  background: var(--green);
}

.alert-stack {
  display: grid;
  gap: 6px;
  min-height: 0;
}

.hidden {
  display: none !important;
}

.alert {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 10px;
  border: 1px solid rgba(240, 82, 82, 0.45);
  border-left: 6px solid var(--red);
  border-radius: 8px;
  background: rgba(240, 82, 82, 0.12);
}

.alert strong {
  display: block;
}

.alert span {
  color: #ffd4d4;
  font-size: 13px;
}

.emergency-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px;
  border: 1px solid rgba(240, 82, 82, 0.75);
  border-left: 8px solid var(--red);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(240, 82, 82, 0.28), rgba(240, 82, 82, 0.1)),
    #21181a;
  box-shadow: 0 16px 42px rgba(240, 82, 82, 0.16);
}

.emergency-panel p,
.emergency-panel h2 {
  margin: 0;
}

.emergency-panel p {
  color: #ffd4d4;
  font-size: 13px;
  font-weight: 900;
}

.emergency-panel h2 {
  margin-top: 3px;
  font-size: 22px;
  line-height: 1;
}

.emergency-panel span {
  display: block;
  margin-top: 6px;
  color: #ffd4d4;
  font-size: 14px;
}

.emergency-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.small {
  min-height: 34px !important;
  min-width: 78px !important;
  padding: 0 10px;
  text-decoration: none;
}

.meter-wrap {
  display: grid;
  place-items: center;
  min-height: 0;
}

.radio-ring {
  --voice-border: rgba(85, 238, 145, 0.16);
  --voice-glow: 0px;
  --voice-scale: 1;
  --voice-wash: rgba(85, 238, 145, 0.08);
  position: relative;
  display: grid;
  place-items: center;
  width: min(62vw, 260px);
  max-width: 100%;
  aspect-ratio: 1;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 50%;
  transform: scale(var(--voice-scale));
  transition: transform 80ms linear, border-color 80ms linear, box-shadow 80ms linear;
  background:
    radial-gradient(circle at center, #111719 0 34%, transparent 35%),
    repeating-radial-gradient(circle at center, var(--voice-wash) 0 7px, transparent 8px 23px),
    linear-gradient(145deg, #2b3338, #151a1d);
  box-shadow:
    inset 0 0 58px rgba(0, 0, 0, 0.52),
    inset 0 0 0 11px rgba(255, 255, 255, 0.025),
    0 0 var(--voice-glow) rgba(85, 238, 145, 0.22),
    0 16px 42px rgba(0, 0, 0, 0.26);
}

.radio-ring::before,
.radio-ring::after {
  position: absolute;
  border-radius: 50%;
  content: "";
}

.radio-ring::before {
  inset: 9%;
  border: 1px dashed rgba(170, 182, 174, 0.22);
}

.radio-ring::after {
  inset: 20%;
  border: 1px solid rgba(85, 238, 145, 0.18);
}

.radio-ring.active {
  border-color: var(--voice-border);
}

.radio-ring.warning {
  border-color: rgba(240, 181, 62, 0.9);
}

.radio-core {
  z-index: 1;
  display: grid;
  place-items: center;
  width: 48%;
  aspect-ratio: 1;
  padding: 13px;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent),
    #101619;
  box-shadow: inset 0 0 35px rgba(85, 238, 145, 0.08), 0 12px 34px rgba(0, 0, 0, 0.3);
}

.radio-core small {
  color: var(--blue);
  font-size: 12px;
  font-weight: 950;
}

.radio-core span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.radio-core strong {
  max-width: 100%;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 20px;
  line-height: 1.05;
}

.controls {
  display: grid;
  gap: 9px;
  justify-items: center;
}

.ptt-button {
  display: grid;
  place-items: center;
  width: min(100%, 100%);
  min-height: 76px;
  padding: 12px;
  border: 1px solid rgba(85, 238, 145, 0.38);
  border-radius: 8px;
  color: #06130b;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.42), rgba(255, 255, 255, 0)),
    linear-gradient(180deg, #9be6bb, #2f8e5d);
  box-shadow:
    inset 0 -6px 0 rgba(0, 0, 0, 0.16),
    0 12px 26px rgba(38, 185, 101, 0.2);
  touch-action: none;
  user-select: none;
}

.ptt-button span {
  font-size: 24px;
  font-weight: 950;
  line-height: 1.1;
}

.ptt-button.pressed {
  transform: translateY(3px);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.34), rgba(255, 255, 255, 0)),
    linear-gradient(180deg, #ffcd5d, #f08f2a);
  border-color: rgba(240, 181, 62, 0.85);
  box-shadow:
    inset 0 -3px 0 rgba(0, 0, 0, 0.18),
    0 10px 26px rgba(240, 181, 62, 0.2);
}

.ptt-button.denied {
  background: linear-gradient(180deg, #ff8b8b, #d94343);
}

.secondary-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.danger-action,
.ghost-action,
.text-action {
  min-height: 40px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 900;
}

.danger-action {
  min-width: 96px;
  color: #fff;
  background: linear-gradient(180deg, #ff6868, #9f3338);
}

.ghost-action {
  min-width: 132px;
  color: var(--ink);
  background: #303a40;
  border: 1px solid var(--line-bright);
}

.ghost-action.active {
  color: #06130b;
  background: var(--green);
}

.log-panel,
.settings-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-3);
}

.log-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 6px;
  min-height: 0;
  padding: 9px 10px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-head h2 {
  margin: 0;
  font-size: 13px;
}

.section-head span {
  color: var(--muted);
  font-size: 13px;
}

.text-action {
  min-height: auto;
  padding: 4px 8px;
  color: var(--green);
  background: transparent;
}

.event-log {
  display: grid;
  align-content: start;
  gap: 5px;
  min-height: 0;
  overflow: auto;
  color: var(--muted);
  font-size: 12px;
}

.event-log p {
  margin: 0;
  padding: 6px 8px;
  border-radius: 8px;
  background: #182024;
}

.settings-dialog {
  width: min(92vw, 460px);
  padding: 0;
  color: var(--ink);
  border: 0;
  border-radius: 8px;
  background: transparent;
}

.settings-dialog::backdrop {
  background: rgba(0, 0, 0, 0.58);
  backdrop-filter: blur(5px);
}

.settings-card {
  display: grid;
  gap: 16px;
  max-height: min(86vh, 760px);
  padding: 18px;
  overflow: auto;
  box-shadow: var(--shadow);
}

.dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.dialog-head h2 {
  margin: 0;
  color: var(--green);
  font-size: 24px;
}

.dialog-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.close-action {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #1a2225;
  font-size: 24px;
  line-height: 1;
}

.settings-grid {
  display: grid;
  gap: 13px;
}

.field,
.setting-row {
  display: grid;
  gap: 8px;
}

.field label,
.setting-row label,
.switch-row span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.field input,
.field select {
  width: 100%;
  height: 46px;
  padding: 0 12px;
  color: var(--ink);
  background: #182024;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: 0;
}

.field select {
  color: var(--green);
  font-weight: 950;
}

.field input:focus,
.field select:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(85, 238, 145, 0.14);
}

.setting-row input[type="range"] {
  width: 100%;
  accent-color: var(--green);
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 38px;
}

.switch-row input {
  width: 42px;
  height: 22px;
  accent-color: var(--green);
}

.channel-block {
  display: flex;
  min-height: 0;
  max-height: 230px;
  flex-direction: column;
  gap: 12px;
}

.member-list {
  display: grid;
  align-content: start;
  gap: 8px;
  min-height: 0;
  overflow: auto;
}

.member-row {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: 8px;
  background: var(--panel-2);
  border: 1px solid transparent;
  border-radius: 8px;
}

.member-row.speaking {
  border-color: rgba(85, 238, 145, 0.58);
  background: rgba(85, 238, 145, 0.1);
}

.avatar {
  display: grid;
  place-items: center;
  width: 38px;
  aspect-ratio: 1;
  border-radius: 8px;
  color: #08150e;
  background: linear-gradient(180deg, #e6f0e9, #9fb4a9);
  font-size: 12px;
  font-weight: 950;
}

.member-name {
  min-width: 0;
  overflow: hidden;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.member-meta {
  margin-top: 2px;
  color: var(--dim);
  font-size: 12px;
}

.member-state {
  padding: 5px 8px;
  border-radius: 8px;
  color: var(--muted);
  background: #172024;
  font-size: 12px;
  font-weight: 900;
}

.member-row.speaking .member-state {
  color: #0b1d11;
  background: var(--green);
}

.radio-state {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 42px;
  padding: 0 12px;
  border-radius: 8px;
  background: #151b1e;
}

.radio-state span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.radio-state strong {
  color: var(--green);
  font-size: 15px;
}

.remote-audio {
  display: none;
}

@media (max-width: 640px) {
  body {
    background: linear-gradient(160deg, #111719, #22292d 55%, #14191b);
  }

  .app-shell {
    padding: 8px;
  }

  .talk-surface {
    grid-template-rows: auto auto auto minmax(190px, 0.78fr) auto minmax(72px, 106px);
    gap: 9px;
    min-height: calc(100vh - 16px);
    padding: 12px;
  }

  .topbar {
    gap: 10px;
  }

  .eyebrow {
    font-size: 11px;
    letter-spacing: 0;
  }

  .topbar h1 {
    margin-top: 2px;
    font-size: 34px;
    line-height: 1;
  }

  .icon-action {
    min-width: 44px;
    min-height: 34px;
    padding: 0 9px;
    font-size: 13px;
  }

  .status-row {
    gap: 8px;
    min-height: 34px;
  }

  .speaker-badge {
    min-height: 34px;
    padding: 0 11px;
    font-size: 15px;
  }

  .signal-bars {
    height: 15px;
  }

  .signal-bars span {
    width: 4px;
  }

  .battery {
    width: 29px;
    height: 14px;
  }

  .alert {
    padding: 9px 10px;
  }

  .emergency-panel {
    align-items: flex-start;
    padding: 11px;
    gap: 10px;
  }

  .emergency-panel h2 {
    font-size: 22px;
  }

  .radio-ring {
    width: min(58vw, 238px);
    box-shadow:
      inset 0 0 58px rgba(0, 0, 0, 0.5),
      inset 0 0 0 11px rgba(255, 255, 255, 0.025),
      0 0 var(--voice-glow) rgba(85, 238, 145, 0.22),
      0 16px 42px rgba(0, 0, 0, 0.24);
  }

  .radio-core {
    width: 48%;
    padding: 12px;
  }

  .radio-core small {
    font-size: 12px;
  }

  .radio-core span {
    font-size: 13px;
  }

  .radio-core strong {
    font-size: 20px;
    line-height: 1.05;
  }

  .controls {
    gap: 8px;
  }

  .ptt-button {
    width: 100%;
    min-height: 70px;
    padding: 10px;
    box-shadow:
      inset 0 -6px 0 rgba(0, 0, 0, 0.16),
      0 12px 26px rgba(38, 185, 101, 0.2);
  }

  .ptt-button span {
    font-size: 22px;
    line-height: 1.1;
  }

  .secondary-controls {
    gap: 9px;
  }

  .danger-action,
  .ghost-action {
    min-height: 42px;
    font-size: 14px;
  }

  .danger-action {
    min-width: 96px;
  }

  .ghost-action {
    min-width: 132px;
  }

  .log-panel {
    gap: 7px;
    padding: 10px;
  }

  .section-head h2 {
    font-size: 13px;
  }

  .event-log {
    gap: 5px;
    font-size: 12px;
  }

  .event-log p {
    padding: 6px 8px;
  }

  .settings-dialog {
    width: min(94vw, 420px);
  }

  .settings-card {
    gap: 13px;
    padding: 14px;
  }

  .dialog-head h2 {
    font-size: 20px;
  }

  .close-action {
    width: 34px;
    height: 34px;
    font-size: 21px;
  }

  .field input,
  .field select {
    height: 42px;
  }

  .member-row {
    grid-template-columns: 34px minmax(0, 1fr) auto;
    min-height: 50px;
  }

  .avatar {
    width: 34px;
  }
}
