:root {
  --bg: #17140f;
  --panel: #231e16;
  --panel-2: #30291e;
  --line: #463c2b;
  --text: #f7f1e5;
  --muted: #bcae97;
  --honey: #f2b134;
  --honey-ink: #2a1e06;
  --danger: #d9483b;
  --ok: #68c07f;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}

button, input, select { font: inherit; }

button {
  min-height: 44px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
}

button:hover { border-color: var(--honey); }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--honey); outline-offset: 2px; }
button:disabled { cursor: not-allowed; opacity: .5; }

button.primary { background: var(--honey); border-color: var(--honey); color: var(--honey-ink); font-weight: 600; }
button.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
button.off { background: #5a2a24; border-color: #8a3d33; }
button.active { background: var(--honey); border-color: var(--honey); color: var(--honey-ink); }

input {
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
}

.muted { color: var(--muted); }

.lobby { display: grid; place-items: center; min-height: 100%; padding: 16px; }

.card {
  width: min(100%, 400px);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
}

.brand { margin: 0; color: var(--honey); font-size: 30px; font-weight: 700; }
.brand.small { font-size: 20px; }
.company { margin: 0 0 20px; color: var(--muted); font-size: 14px; }
.card h1 { margin: 0 0 16px; font-size: 20px; }
.card label { display: block; margin-bottom: 6px; color: var(--muted); font-size: 14px; }
.card .primary { width: 100%; margin-top: 16px; }
.error { margin: 14px 0 0; color: #ff9a8e; }
.card .secondary { width: 100%; margin-top: 10px; }

.soundcheck { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.soundcheck h2 { margin: 0 0 8px; font-size: 18px; }
.soundcheck p { margin: 0 0 12px; white-space: pre-line; }
.meter.wide { height: 14px; margin-bottom: 12px; }
.sc-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.sc-buttons button, .card .sc-buttons .primary { flex: 1 1 40%; width: auto; margin-top: 0; }
.sc-player { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

.call { display: flex; flex-direction: column; height: 100%; }

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--line);
}

.topbar button { margin-left: auto; }

.banner { margin: 0; padding: 8px 16px; background: #5a2a24; }

.stage { display: flex; flex: 1; min-height: 0; }

.grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
  grid-auto-rows: minmax(180px, 1fr);
  gap: 10px;
  min-width: 0;
  padding: 12px 16px;
  overflow-y: auto;
}

.tile {
  position: relative;
  min-height: 0;
  overflow: hidden;
  border-radius: 10px;
  background: var(--panel);
  cursor: pointer;
}

.grid.has-focus {
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  grid-template-rows: minmax(0, 1fr) 110px;
  grid-auto-rows: 110px;
}

.tile.focused { grid-column: 1 / -1; grid-row: 1; }

.tile-actions {
  position: absolute;
  top: 6px;
  right: 6px;
  left: 84px;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px;
}

.tile-actions .mute-all { color: #ffb4a9; }

.host-badge {
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--honey);
  color: var(--honey-ink);
  font-size: 13px;
  font-weight: 600;
}

.tile-actions button {
  min-height: 30px;
  padding: 2px 10px;
  border-color: transparent;
  background: rgba(0, 0, 0, .7);
  font-size: 13px;
  opacity: 0;
  transition: opacity .15s;
}

.tile:hover .tile-actions button,
.tile-actions button:focus-visible,
.tile.focused .expand,
.tile.silenced .mute { opacity: 1; }

.tile.silenced .mute { border-color: var(--danger); color: #ffb4a9; }
.tile.screen .level { display: none; }

@media (hover: none) {
  .tile-actions button { opacity: 1; }
}

.tile video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
.tile.local:not(.screen) video { transform: scaleX(-1); }
.tile.no-video video { visibility: hidden; }

.tile::after {
  content: "";
  position: absolute;
  inset: 0;
  border: 3px solid transparent;
  border-radius: inherit;
  transition: border-color .15s;
  pointer-events: none;
}

.tile.speaking::after { border-color: var(--ok); }

.level {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 72px;
  height: 8px;
  overflow: hidden;
  border-radius: 4px;
  background: rgba(0, 0, 0, .7);
}

.level i, .meter i {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--ok);
  transform: scaleX(var(--level, 0));
  transform-origin: left;
  transition: transform .1s linear;
}

.avatar {
  position: absolute;
  top: 50%;
  left: 50%;
  display: none;
  width: 72px;
  height: 72px;
  place-items: center;
  border-radius: 50%;
  background: var(--honey);
  color: var(--honey-ink);
  font-size: 30px;
  font-weight: 700;
  transform: translate(-50%, -50%);
}

.tile.no-video .avatar { display: grid; }

.label {
  position: absolute;
  right: 8px;
  bottom: 8px;
  left: 8px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 14px;
  pointer-events: none;
}

.label span {
  max-width: 100%;
  padding: 2px 8px;
  overflow: hidden;
  border-radius: 6px;
  background: rgba(0, 0, 0, .7);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.label .status:empty { display: none; }

.chat {
  display: flex;
  flex: 0 0 320px;
  flex-direction: column;
  min-height: 0;
  border-left: 1px solid var(--line);
  background: var(--panel);
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
}

.chat-messages { flex: 1; margin: 0; padding: 12px; overflow-y: auto; list-style: none; }
.chat-messages li { margin-bottom: 12px; overflow-wrap: anywhere; }
.chat-messages .meta { display: block; color: var(--muted); font-size: 13px; }
.chat-form { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); }

.controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-top: 1px solid var(--line);
}

.mic-group { display: flex; align-items: center; gap: 8px; min-width: 0; }

.meter {
  flex: 0 0 64px;
  height: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--bg);
}

.mic-group select {
  width: 190px;
  min-width: 0;
  min-height: 44px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  text-overflow: ellipsis;
}

@media (max-width: 760px) {
  .chat { position: fixed; inset: 0; z-index: 10; flex: none; border-left: 0; }
  .controls button { flex: 1 1 28%; padding-inline: 6px; }
  .mic-group { flex: 1 1 100%; }
  .mic-group button { flex: 0 1 auto; }
  .mic-group select { flex: 1; width: auto; }
  .topbar { padding-inline: 16px; }
}
