:root {
  --bg: #060a07;
  --bg-2: #0a110d;
  --surface: rgba(13, 22, 16, 0.92);
  --surface-2: rgba(17, 29, 20, 0.82);
  --surface-3: rgba(8, 14, 10, 0.74);
  --line: rgba(170, 255, 176, 0.12);
  --line-strong: rgba(170, 255, 176, 0.22);
  --text: #efffed;
  --muted: #9aad9a;
  --soft: #cfe6ca;
  --green: #6cff64;
  --green-2: #26c64a;
  --green-dark: #0f3518;
  --danger: #ff646d;
  --warn: #ffd166;
  --shadow: 0 24px 80px rgba(0, 0, 0, .42);
  --radius: 24px;
}

* { box-sizing: border-box; }
html { color-scheme: dark; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font: 14px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(86, 255, 90, .10), transparent 30rem),
    radial-gradient(circle at 85% 10%, rgba(38, 198, 74, .08), transparent 26rem),
    linear-gradient(180deg, #050805 0%, #09100b 52%, #050705 100%);
}

button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .48; filter: saturate(.7); }

.app-shell {
  width: min(1180px, calc(100% - 36px));
  margin: 0 auto;
  padding: 22px 0 32px;
}

.app-header {
  position: sticky;
  top: 14px;
  z-index: 30;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(5, 10, 7, .82);
  backdrop-filter: blur(18px);
  box-shadow: 0 14px 44px rgba(0, 0, 0, .32);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  text-decoration: none;
  min-width: 0;
}
.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 14px;
  color: #041005;
  font-weight: 950;
  letter-spacing: -.04em;
  background: linear-gradient(180deg, var(--green), var(--green-2));
  box-shadow: 0 10px 28px rgba(108, 255, 100, .14);
}
.brand strong {
  display: block;
  font-size: 16px;
  letter-spacing: -.02em;
}
.brand small {
  display: block;
  margin-top: 1px;
  color: var(--muted);
  font-size: 12px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.server-status {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 220px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255,255,255,.025);
}
.server-status strong { display: block; font-size: 13px; }
.server-status small { display: block; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 210px; }
.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--warn);
  box-shadow: 0 0 0 5px rgba(255, 209, 102, .08);
  flex: 0 0 auto;
}
.dot.ok { background: var(--green-2); box-shadow: 0 0 0 5px rgba(38, 198, 74, .12); }
.dot.bad { background: var(--danger); box-shadow: 0 0 0 5px rgba(255, 100, 109, .12); }
.dot.warn { background: var(--warn); }

.account-widget { position: relative; }
.account-button, .primary-button, .ghost-button, .secondary, .link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 15px;
  border-radius: 14px;
  border: 1px solid var(--line);
  color: var(--text);
  background: rgba(255,255,255,.035);
  font-weight: 850;
  text-decoration: none;
  transition: transform .16s ease, border-color .16s ease, background .16s ease, box-shadow .16s ease;
}
.account-button:hover, .ghost-button:hover, .secondary:hover, .link-button:hover { border-color: var(--line-strong); background: rgba(255,255,255,.055); }
.primary-button {
  color: #051006;
  border: none;
  background: linear-gradient(180deg, var(--green), var(--green-2));
  box-shadow: 0 12px 26px rgba(38, 198, 74, .18);
}
.primary-button:hover { transform: translateY(-1px); }
.account-button.logged-in { border-color: rgba(108,255,100,.28); background: rgba(108,255,100,.09); }
.ghost-button.danger, .danger-soft { color: #ffd9dc; border-color: rgba(255,100,109,.18); background: rgba(255,100,109,.06); }
.ghost-button.tiny { min-height: 32px; padding: 0 11px; border-radius: 11px; font-size: 12px; }
.full-width { width: 100%; }

.account-menu {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  width: 292px;
  z-index: 40;
  border: 1px solid var(--line-strong);
  background: rgba(7, 13, 9, .98);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 12px;
}
.account-menu.open { display: block; }
.account-menu-head {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 11px;
  align-items: center;
  padding: 4px 2px 12px;
}
.profile-avatar, .tile-avatar {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  overflow: hidden;
  border-radius: 15px;
  color: #051006;
  background: linear-gradient(180deg, var(--green), var(--green-2));
  font-weight: 950;
  text-transform: uppercase;
}
.profile-avatar img, .tile-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.account-menu strong { display: block; }
.account-menu small { display: block; color: var(--muted); margin-top: 2px; }

.main-layout {
  display: grid;
  grid-template-columns: minmax(330px, .75fr) minmax(0, 1.25fr);
  gap: 18px;
  margin-top: 18px;
  align-items: start;
}
.card, .panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(16, 28, 19, .84), rgba(7, 13, 9, .84));
  box-shadow: var(--shadow);
  padding: 20px;
}
.room-card { grid-row: span 2; min-height: 540px; }
.privacy-card { display: flex; gap: 14px; align-items: flex-start; }
.privacy-card p:not(.eyebrow) { margin: 8px 0 0; color: var(--muted); }
.privacy-icon { color: var(--green); font-size: 18px; line-height: 1; margin-top: 4px; filter: drop-shadow(0 0 10px rgba(108,255,100,.25)); }

.card-head, .section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 16px;
}
.compact-head { margin-bottom: 14px; }
.eyebrow {
  margin: 0 0 4px;
  color: var(--green);
  font-size: 11px;
  font-weight: 950;
  letter-spacing: .16em;
  text-transform: uppercase;
}
h1, h2 { margin: 0; letter-spacing: -.035em; line-height: 1.04; }
h1 { font-size: clamp(28px, 4vw, 42px); }
h2 { font-size: 22px; }
.subtitle { color: var(--muted); }

.status-pill, .pill, .mode-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  border: 1px solid rgba(108,255,100,.16);
  border-radius: 999px;
  background: rgba(108,255,100,.07);
  color: var(--soft);
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.status-list {
  display: grid;
  gap: 8px;
  margin: 12px 0 18px;
}
.status-list > div {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  min-height: 40px;
  padding: 10px 12px;
  border: 1px solid rgba(255,255,255,.055);
  border-radius: 14px;
  background: rgba(0,0,0,.16);
}
.status-list span { color: var(--muted); }
.status-list strong { color: var(--soft); text-align: right; }

label, .field-label {
  display: block;
  margin: 12px 0 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
input, select {
  width: 100%;
  border: 1px solid rgba(255,255,255,.08);
  background: rgba(0,0,0,.22);
  color: var(--text);
  border-radius: 14px;
  padding: 12px 13px;
  outline: none;
}
input:focus, select:focus { border-color: rgba(108,255,100,.42); box-shadow: 0 0 0 4px rgba(108,255,100,.075); }

.button-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.primary-actions { margin-top: 16px; }
.primary-actions .primary-button { flex: 1 1 140px; }
.primary-actions .ghost-button { flex: 1 1 94px; }

.mini-log {
  margin-top: 14px;
  padding: 12px 13px;
  border: 1px solid rgba(255,255,255,.06);
  border-radius: 14px;
  background: rgba(0,0,0,.16);
  color: var(--muted);
  font-size: 13px;
}
.voice-log { margin-top: 10px; }
.good { color: var(--green); }
.bad { color: var(--danger); }
.warn { color: var(--warn); }
.muted { color: var(--muted); }

.room-summary-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
  color: var(--muted);
  font-size: 12px;
}
.room-summary-inline span {
  display: inline-flex;
  gap: 5px;
  align-items: center;
  padding: 6px 9px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.065);
  background: rgba(0,0,0,.15);
}
.room-summary-inline strong { color: var(--green); }

.voice-roster {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-top: 12px;
}
.empty-roster {
  color: var(--muted);
  border: 1px dashed rgba(170,255,176,.16);
  background: rgba(0,0,0,.16);
  border-radius: 18px;
  padding: 20px;
  text-align: center;
}
.speaker-tile {
  position: relative;
  display: grid;
  grid-template-columns: 48px 1fr auto;
  gap: 13px;
  align-items: center;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.07);
  background: rgba(255,255,255,.025);
  border-radius: 18px;
  padding: 13px;
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
.speaker-tile::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  background: radial-gradient(circle at 18% 0%, rgba(108,255,100,.15), transparent 56%);
  transition: opacity .18s ease;
}
.speaker-tile.speaking {
  transform: translateY(-1px);
  border-color: rgba(108,255,100,.42);
  box-shadow: 0 0 0 1px rgba(108,255,100,.08), 0 16px 38px rgba(0,0,0,.22), 0 0 38px rgba(108,255,100,.09);
  background: rgba(108,255,100,.045);
}
.speaker-tile.speaking::before { opacity: 1; }
.speaker-tile.self { border-color: rgba(255,255,255,.13); }
.speaker-tile.inaudible { opacity: .66; }
.tile-avatar, .tile-main, .tile-side { position: relative; z-index: 1; }
.tile-main { min-width: 0; }
.tile-name-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.tile-main strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; }
.tile-main small { display: block; margin-top: 3px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-side { display: grid; justify-items: end; gap: 8px; min-width: 132px; }
.tile-state {
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 999px;
  padding: 5px 9px;
  color: var(--muted);
  background: rgba(0,0,0,.20);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.speaker-tile.speaking .tile-state { color: #041005; background: linear-gradient(180deg, var(--green), var(--green-2)); border-color: transparent; }
.tile-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tile-chip {
  color: var(--muted);
  border: 1px solid rgba(255,255,255,.07);
  background: rgba(0,0,0,.18);
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 800;
}
.tile-chip.good, .tile-chip.nearby { color: var(--green); }
.tile-chip.warn, .tile-chip.out { color: var(--warn); }
.tile-chip.bad { color: var(--danger); }
.tile-meter {
  width: 112px;
  height: 7px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(108,255,100,.08);
  border: 1px solid rgba(108,255,100,.075);
}
.tile-meter > i {
  display: block;
  width: var(--level, 0%);
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(108,255,100,.5), var(--green));
  transition: width .1s linear;
}

.audio-settings-card { align-self: start; }
.slider-field {
  border: 1px solid rgba(255,255,255,.065);
  background: rgba(0,0,0,.15);
  border-radius: 16px;
  padding: 13px;
  margin-top: 10px;
}
.slider-field label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin: 0 0 8px;
  color: var(--soft);
  font-weight: 850;
  font-size: 13px;
}
.slider-field output { color: var(--green); font-size: 12px; font-weight: 950; font-variant-numeric: tabular-nums; }
.slider-field small { display: block; margin-top: 7px; color: var(--muted); font-size: 12px; }
input[type="range"] { accent-color: var(--green); padding: 0; height: 24px; background: transparent; border: 0; }
.calibration-meter {
  height: 8px;
  margin: 9px 0 7px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(108,255,100,.08);
  border: 1px solid rgba(108,255,100,.075);
}
.calibration-meter > i {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(108,255,100,.45), var(--green));
  box-shadow: 0 0 18px rgba(108,255,100,.18);
  transition: width .09s linear;
}
.calibration-meter.open > i { background: linear-gradient(90deg, var(--green), #d9ff78); }
.slider-field small.good { color: var(--green); }
.slider-field small.warn { color: var(--warn); }
.slider-field small.bad { color: var(--danger); }

.audio-mount audio { display: none; }
.voice-meter.hidden-meter { display: none; }

.shell, .narrow-shell { width: min(1180px, calc(100% - 36px)); margin: 0 auto; padding: 22px 0 32px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.span-2 { grid-column: span 2; }
.hero { display: flex; justify-content: space-between; align-items: center; gap: 18px; }
.glow { box-shadow: var(--shadow); }
.label-hint { color: var(--muted); font-size: 11px; font-weight: 700; margin-left: 6px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.steps { color: var(--muted); margin: 0; padding-left: 20px; }
.steps li { margin: 10px 0; }
code { color: var(--green); background: rgba(108,255,100,.08); border: 1px solid rgba(108,255,100,.12); border-radius: 8px; padding: 2px 6px; }
.table-wrap { overflow: auto; border-radius: 16px; border: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; min-width: 800px; }
th, td { text-align: left; padding: 13px 14px; border-bottom: 1px solid rgba(108,255,100,.08); vertical-align: top; }
th { color: var(--green); font-size: 12px; text-transform: uppercase; letter-spacing: .12em; background: rgba(108,255,100,.05); }
td { color: #dff9de; }
.audio-card { display: none; }

body.release-mode .local-only, body.release-mode .map-panel, body.release-mode .status-panel { display: none !important; }
body.local-mode .prod-only { display: none !important; }
body.local-mode .local-only { display: revert; }
body.local-mode.app-v16::after {
  content: "Local profile mode";
  position: fixed;
  left: 18px;
  bottom: 18px;
  z-index: 50;
  padding: 7px 10px;
  border: 1px solid rgba(255,209,102,.22);
  border-radius: 999px;
  color: var(--warn);
  background: rgba(8, 14, 10, .88);
  font-size: 12px;
  font-weight: 900;
  box-shadow: 0 8px 26px rgba(0,0,0,.28);
}

@media (max-width: 980px) {
  .main-layout { grid-template-columns: 1fr; }
  .room-card { grid-row: auto; min-height: 0; }
  .app-header { position: static; }
}
@media (max-width: 760px) {
  .app-shell, .shell, .narrow-shell { width: min(100% - 24px, 1180px); padding-top: 12px; }
  .app-header { align-items: stretch; flex-direction: column; }
  .header-right { width: 100%; flex-direction: column; align-items: stretch; }
  .server-status, .account-button { width: 100%; }
  .account-menu { left: 0; right: 0; width: auto; }
  .card { padding: 16px; border-radius: 20px; }
  .card-head { flex-direction: column; align-items: stretch; }
  .room-summary-inline { justify-content: flex-start; }
  .speaker-tile { grid-template-columns: 42px 1fr; }
  .tile-side { grid-column: 1 / -1; justify-items: stretch; min-width: 0; }
  .tile-meter { width: 100%; }
  .grid, .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
}
