:root {
  --bg: #101317;
  --panel: #181c21;
  --tile: #1c242b;
  --text: #e8eef4;
  --muted: #9aa7b5;
  --accent: #0dbd8b;
  --accent-hi: #4db87e;
  --danger: #ff5b55;
  --warn: #c9a227;
  --input: #0d1216;
  --border: #2b3640;
  --halo: rgba(13, 189, 139, 0.45);
  --bar: #0c1014;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
}

.hidden { display: none !important; }

#whoBox { margin-bottom: 12px; }
#whoBox .sub { margin-bottom: 8px; }
#loginBox { margin-bottom: 8px; }

#lobby {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 10%, rgba(13, 189, 139, 0.14), transparent 42%),
    var(--bg);
}

.card {
  width: min(560px, 100%);
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px 24px 22px;
}

.badge {
  display: inline-block;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--accent);
  margin-bottom: 10px;
}

h1 { margin: 0 0 6px; font-size: 1.45rem; font-weight: 650; }
.sub { margin: 0 0 18px; color: var(--muted); font-size: 0.92rem; line-height: 1.45; }

label {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 12px 0 6px;
}

input, select {
  width: 100%;
  margin-bottom: 4px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--input);
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 0;
  font-size: 0.9rem;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text);
  cursor: pointer;
}
.toggle input { width: auto; margin: 0; }

.meter {
  height: 8px;
  border-radius: 99px;
  background: var(--input);
  overflow: hidden;
  margin: 6px 0 12px;
}
.meter i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
}

.warn-box {
  display: none;
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid color-mix(in srgb, var(--warn) 50%, var(--border));
  color: var(--muted);
  font-size: 0.85rem;
}
.warn-box.show { display: block; }

.row { display: flex; gap: 10px; margin-top: 16px; }
.row.tight { margin-top: 8px; }
.row.tight .ghost { flex: 1; }
button {
  font-family: inherit;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}
.primary {
  flex: 1;
  padding: 12px 16px;
  background: var(--accent);
  color: #042016;
}
.ghost {
  padding: 12px 16px;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
#status { margin-top: 12px; font-size: 0.86rem; color: var(--muted); }
#status.ok { color: var(--accent-hi); }
#status.err { color: var(--danger); }
#status.warn { color: var(--warn); }

#call {
  height: 100%;
  display: grid;
  grid-template-rows: 1fr auto;
  grid-template-columns: 1fr;
  background: #0a0d10;
}
#call.rail-open {
  grid-template-columns: 1fr min(320px, 38vw);
}

#stage {
  position: relative;
  min-height: 0;
  padding: 16px 16px 8px;
  display: flex;
  flex-direction: column;
}

#stageHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
#stageHeader h2 { margin: 0; font-size: 0.95rem; font-weight: 650; }
.meta { color: var(--muted); font-size: 0.8rem; display: flex; gap: 10px; align-items: center; }
.pill {
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
}
.pill.reconnecting { color: var(--warn); border-color: var(--warn); }

#reconnect {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 10, 12, 0.62);
  backdrop-filter: blur(4px);
}
#reconnect.hidden { display: none !important; }
.reconnect-card {
  width: min(360px, calc(100% - 32px));
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px 18px 16px;
  text-align: center;
}
.reconnect-card p { margin: 12px 0 14px; color: var(--text); }
.spin {
  width: 28px;
  height: 28px;
  margin: 0 auto;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

#tiles {
  flex: 1;
  min-height: 0;
  display: grid;
  gap: 12px;
  align-content: center;
  justify-content: center;
  grid-template-columns: repeat(auto-fit, minmax(180px, 240px));
}
#call.spotlight #tiles {
  grid-template-columns: 1fr;
  grid-template-rows: 1fr auto;
}
#call.spotlight .tile.spotlight {
  grid-column: 1 / -1;
  min-height: 48vh;
}
#call.spotlight .tile:not(.spotlight) {
  min-height: 88px;
}

.tile {
  position: relative;
  background: var(--tile);
  border: 1px solid var(--border);
  border-radius: 14px;
  min-height: 180px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  overflow: hidden;
}
.tile.speaking { box-shadow: inset 0 0 0 3px var(--accent); }
.tile.muted .avatar { opacity: 0.7; }
.avatar {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 1.4rem;
  background: #2a3540;
  background-size: cover;
  background-position: center;
}
.tile-name { font-size: 0.92rem; }
.tile-flags {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  gap: 6px;
}
.flag {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #0008;
  font-size: 0.85rem;
}
.flag.mute { background: var(--danger); }
.flag.hand { background: #c9a227; color: #111; }
.react-burst {
  position: absolute;
  bottom: 18px;
  font-size: 2rem;
  animation: pop 1.4s ease-out forwards;
  pointer-events: none;
}
@keyframes pop {
  0% { transform: translateY(8px) scale(0.6); opacity: 0; }
  20% { transform: translateY(0) scale(1.1); opacity: 1; }
  100% { transform: translateY(-40px) scale(1); opacity: 0; }
}

#dock {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  padding: 12px 16px 18px;
  background: linear-gradient(transparent, var(--bar) 30%);
}
.icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #232c34;
  color: var(--text);
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
}
.icon svg { width: 22px; height: 22px; fill: currentColor; }
.icon.on { background: var(--accent); color: #042016; }
.icon.danger { background: var(--danger); color: #fff; }
.icon.muted { background: var(--danger); color: #fff; }
#reactMenu {
  position: absolute;
  bottom: 84px;
  left: 50%;
  transform: translateX(-50%);
  display: none;
  gap: 6px;
  padding: 8px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
}
#reactMenu.open { display: flex; }
#reactMenu button {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #232c34;
  font-size: 1.15rem;
}

#rail {
  display: none;
  border-left: 1px solid var(--border);
  background: var(--panel);
  min-height: 0;
  grid-template-rows: auto 1fr auto;
}
#call.rail-open #rail { display: grid; }
#rail header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 8px;
}
#rail header button {
  flex: 1;
  padding: 8px;
  background: transparent;
  color: var(--muted);
  border-bottom: 2px solid transparent;
}
#rail header button.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}
#people, #chatLog {
  overflow: auto;
  padding: 10px 12px;
}
.person {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 4px;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
}
.person .av {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #2a3540;
  background-size: cover;
  font-size: 0.75rem;
  font-weight: 700;
}
.person .nm { flex: 1; min-width: 0; }
.person .nm small { display: block; color: var(--muted); font-size: 0.72rem; }
.person input[type="range"] { width: 72px; }
.chat-line { margin: 0 0 8px; font-size: 0.86rem; line-height: 1.35; }
.chat-line b { color: var(--accent-hi); font-weight: 650; }
#chatForm {
  display: flex;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid var(--border);
}
#chatForm input { margin: 0; }
#chatForm button { padding: 10px 12px; background: var(--accent); color: #042016; }

#settings {
  position: absolute;
  right: 16px;
  bottom: 84px;
  width: min(320px, calc(100% - 32px));
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  display: none;
}
#settings.open { display: block; }

@media (max-width: 720px) {
  #call.rail-open { grid-template-columns: 1fr; }
  #rail {
    position: absolute;
    inset: 0 0 76px 0;
    z-index: 5;
  }
  .tile { min-height: 140px; }
  .avatar { width: 64px; height: 88px; width: 72px; height: 72px; }
}
