:root {
  --bg: #0b1020;
  --panel: #141b34;
  --panel2: #1a2242;
  --line: #26304f;
  --text: #eaf0ff;
  --muted: #93a0c4;
  --accent: #4ade80;
  --accent2: #38bdf8;
  --danger: #f87171;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 10% -10%, #1b2a5e55, transparent),
    radial-gradient(900px 500px at 110% 10%, #0ea5e933, transparent),
    var(--bg);
  overflow: hidden;
}

/* ---------- header ---------- */
.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px; gap: 12px;
  border-bottom: 1px solid var(--line);
  background: #0b1020cc; backdrop-filter: blur(6px);
}
.top-right { display: flex; align-items: center; gap: 10px; }
.brand { display: flex; align-items: center; gap: 7px; }
.brand-logo { height: 24px; width: 24px; object-fit: cover; display: block; border-radius: 6px; }
.brand h1 { font-size: 15px; margin: 0; letter-spacing: .2px; }
.dot { width: 11px; height: 11px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 12px var(--accent); }
.free-badge {
  font-size: 12px; padding: 6px 10px; border-radius: 999px;
  background: #4ade8018; color: var(--accent);
  border: 1px solid #4ade8044; white-space: nowrap;
}
.clock { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; }

/* ---------- lobby ---------- */
.lobby { display: flex; justify-content: center; padding: 3vh 16px; overflow-y: auto; height: calc(100vh - 60px); }
.lobby-card {
  width: min(720px, 100%); background: var(--panel); border: 1px solid var(--line);
  border-radius: 20px; padding: 20px; text-align: center;
  box-shadow: 0 24px 60px #00000066;
}
.preview-wrap { position: relative; border-radius: 16px; overflow: hidden; background: #060a16; aspect-ratio: 16/9; }
.src-video { position: fixed; width: 2px; height: 2px; opacity: 0; left: -10px; top: -10px; pointer-events: none; z-index: -1; }
.cam-start {
  position: absolute; inset: auto; left: 50%; top: 50%; transform: translate(-50%, -50%);
  background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #06121f;
  border: 0; font-weight: 700; font-size: 16px; padding: 14px 24px; border-radius: 14px; cursor: pointer;
}
.preview-wrap video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); display: block; }
.preview-off { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--muted); }
.preview-fx {
  position: absolute; right: 12px; bottom: 12px;
  background: #000000aa; color: var(--text); border: 1px solid #ffffff33;
  padding: 8px 12px; border-radius: 999px; font-size: 13px; cursor: pointer;
}
.lobby-controls { display: flex; gap: 14px; justify-content: center; margin: 16px 0 10px; }
.name-input {
  width: min(360px, 100%); margin: 8px auto 4px; display: block;
  background: var(--panel2); color: var(--text); border: 1px solid var(--line);
  padding: 12px 14px; border-radius: 12px; font-size: 15px; text-align: center;
}
.lobby-actions { display: flex; flex-direction: column; gap: 8px; align-items: center; margin-top: 12px; }
button.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #06121f; border: 0; font-weight: 700; font-size: 17px;
  padding: 14px 30px; border-radius: 14px; cursor: pointer; min-width: 220px;
}
button.primary:active { transform: scale(.98); }
button.ghost {
  background: transparent; color: var(--muted); border: 1px solid var(--line);
  padding: 10px 18px; border-radius: 12px; cursor: pointer; font-size: 14px;
}
button.ghost.small { font-size: 13px; padding: 8px 12px; }
.muted { color: var(--muted); line-height: 1.5; font-size: 14px; }
.small-note { font-size: 12.5px; margin: 12px 0 0; }
.error { color: var(--danger); margin-top: 14px; line-height: 1.6; font-size: 14px; }

/* ---------- call layout ---------- */
#call { display: flex; flex-direction: column; height: calc(100vh - 60px); }
.call-body { flex: 1; display: flex; min-height: 0; gap: 12px; padding: 12px; }
.stage { position: relative; flex: 1; min-width: 0; }
.grid {
  height: 100%;
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  align-content: center;
}
.grid.single { grid-template-columns: minmax(0, 1fr); }
.tile {
  position: relative; background: #0a0f1f; border: 1px solid var(--line);
  border-radius: 16px; overflow: hidden; aspect-ratio: 16/10;
  display: flex; align-items: center; justify-content: center;
  max-height: 100%;
}
.grid.single { grid-template-columns: minmax(0, 1fr); place-items: center; }
.grid.single .tile { aspect-ratio: 16/9; width: min(760px, 100%); height: auto; max-height: 76%; }
.tile video { width: 100%; height: 100%; object-fit: cover; background: #0a0f1f; }
.tile.local video { transform: scaleX(-1); }
.tile.speaking { border-color: var(--accent); box-shadow: 0 0 0 2px #4ade8055; }
.tile .tag {
  position: absolute; left: 10px; bottom: 10px;
  background: #000000aa; padding: 5px 10px; border-radius: 8px; font-size: 13px;
  max-width: 70%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.hand-badge {
  position: absolute; top: 10px; left: 10px; background: #facc15; color: #231b00;
  width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
}
.tile .muted-ic { position: absolute; right: 10px; bottom: 10px; font-size: 14px;
  background: #000000aa; padding: 5px 8px; border-radius: 8px; }
.float-layer { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.float-emoji {
  position: absolute; bottom: 40px; font-size: 44px;
  animation: floatUp 3.2s ease-out forwards;
}
@keyframes floatUp {
  0% { transform: translateY(0) scale(.6); opacity: 0; }
  15% { opacity: 1; transform: translateY(-20px) scale(1.1); }
  100% { transform: translateY(-260px) scale(1); opacity: 0; }
}

/* ---------- side panel ---------- */
.side {
  width: 320px; flex-shrink: 0; background: var(--panel);
  border: 1px solid var(--line); border-radius: 16px;
  display: flex; flex-direction: column; min-height: 0;
}
.side-head { display: flex; align-items: center; justify-content: space-between;
  padding: 8px 8px 8px 10px; border-bottom: 1px solid var(--line); }
.side-tabs { display: flex; gap: 4px; }
.side-tab { background: transparent; border: 0; color: var(--muted); padding: 8px 12px;
  border-radius: 10px; cursor: pointer; font-size: 14px; }
.side-tab.active { background: var(--panel2); color: var(--text); }
.side-close { background: transparent; border: 0; color: var(--muted); font-size: 16px;
  cursor: pointer; padding: 8px 10px; }
.panel { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 10px; }
.people { list-style: none; margin: 0 0 10px; padding: 0; overflow-y: auto; flex: 1; }
.people li { display: flex; align-items: center; gap: 10px; padding: 9px 6px; border-bottom: 1px solid #ffffff10; font-size: 14px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #06121f; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; }
.people .role { margin-left: auto; font-size: 12px; color: var(--muted); }
.msgs { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding-right: 4px; }
.msg { background: var(--panel2); border: 1px solid #ffffff12; padding: 8px 10px; border-radius: 12px; font-size: 14px; }
.msg .who { display: block; font-size: 11.5px; color: var(--accent2); margin-bottom: 3px; }
.msg.mine { background: #4ade8018; border-color: #4ade8033; align-self: flex-end; }
.chat-form { display: flex; gap: 8px; margin-top: 8px; }
.chat-form input {
  flex: 1; background: var(--panel2); color: var(--text); border: 1px solid var(--line);
  padding: 10px 12px; border-radius: 12px; font-size: 14px;
}
.chat-form .send { background: var(--accent); border: 0; color: #06121f; border-radius: 12px;
  width: 42px; cursor: pointer; font-size: 15px; }

/* ---------- control bar ---------- */
.bar {
  display: flex; gap: 8px; justify-content: center; flex-wrap: wrap;
  padding: 8px 12px 4px; border-top: 1px solid var(--line);
  background: #0b1020cc; backdrop-filter: blur(6px);
}
.pill {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-width: 62px; padding: 8px 10px; border-radius: 14px;
  background: var(--panel); color: var(--text); border: 1px solid var(--line);
  cursor: pointer; font-size: 12px;
}
.pill .ic { font-size: 18px; line-height: 1; }
.pill .lb { color: var(--muted); font-size: 11px; }
.pill.off { background: #f8717122; border-color: #f8717166; }
.pill.off .ic, .pill.off .lb { color: var(--danger); }
.pill.active { background: #38bdf822; border-color: #38bdf866; }
.pill.leave { background: var(--danger); border: 0; color: #2b0b0b; }
.pill.leave .lb { color: #2b0b0b; font-weight: 700; }

.statusline {
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 16px 10px; color: var(--muted); font-size: 13px; gap: 10px;
}
.pill-note { color: var(--accent); font-size: 12.5px; }

/* ---------- reactions ---------- */
.react-bar {
  position: fixed; bottom: 92px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 6px; background: var(--panel); border: 1px solid var(--line);
  padding: 8px; border-radius: 999px; box-shadow: 0 12px 30px #00000088; z-index: 30;
}
.react-bar button { background: transparent; border: 0; font-size: 22px; cursor: pointer; padding: 4px 6px; }
.react-bar button:hover { transform: scale(1.2); }

/* ---------- modals / menu ---------- */
.modal {
  position: fixed; inset: 0; background: #000000aa; z-index: 40;
  display: flex; align-items: center; justify-content: center; padding: 18px;
}
.modal-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px;
  padding: 18px; width: min(560px, 100%); max-height: 86vh; overflow-y: auto;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.modal-head h3 { margin: 0; font-size: 17px; }
.fx-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.fx {
  background: var(--panel2); border: 1px solid var(--line); color: var(--text);
  border-radius: 14px; padding: 10px; cursor: pointer; font-size: 13px;
  display: flex; flex-direction: column; gap: 8px; align-items: center;
}
.fx.active { border-color: var(--accent); box-shadow: 0 0 0 2px #4ade8044; }
.swatch { width: 100%; height: 70px; border-radius: 10px; background-size: cover; background-position: center; }
.swatch.none { background: #0a0f1f; }
.swatch.blur { background: linear-gradient(135deg, #334155, #64748b); filter: blur(0.5px); }
.field { display: block; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.field select, .field input {
  display: block; width: 100%; margin-top: 6px; background: var(--panel2);
  color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 10px; font-size: 14px;
}
.check { display: flex; gap: 8px; align-items: center; font-size: 14px; margin-bottom: 12px; }
.menu {
  position: fixed; bottom: 88px; left: 50%; transform: translateX(-50%);
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 6px; display: flex; flex-direction: column; min-width: 220px; z-index: 35;
  box-shadow: 0 14px 34px #00000088;
}
.menu button { background: transparent; border: 0; color: var(--text); text-align: left;
  padding: 11px 14px; border-radius: 10px; cursor: pointer; font-size: 14px; }
.menu button:hover { background: var(--panel2); }
.captions {
  position: fixed; bottom: 150px; left: 50%; transform: translateX(-50%);
  background: #000000dd; border: 1px solid #ffffff22; color: #fff;
  padding: 10px 16px; border-radius: 12px; font-size: 17px; max-width: 70%;
  text-align: center; z-index: 32;
}

/* ---------- mobile ---------- */
@media (max-width: 760px) {
  .side { position: fixed; right: 0; top: 60px; bottom: 0; width: min(340px, 92vw); z-index: 25; border-radius: 16px 0 0 16px; }
  .pill { min-width: 54px; padding: 7px 8px; }
  .top { flex-wrap: wrap; }
  .grid { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
}