:root {
  --bg: #0f1419;
  --panel: #182029;
  --panel2: #1f2a35;
  --text: #e8eef4;
  --muted: #8fa1b3;
  --accent: #3b82f6;
  --accent2: #2563eb;
  --ok: #22c55e;
  --warn: #f59e0b;
  --err: #ef4444;
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Gujarati", "Noto Sans Devanagari", sans-serif;
}

h1, h2 { margin: 0 0 .4em; }
a { color: var(--accent); }
[hidden] { display: none !important; }

button, select, input {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: 0;
  border-radius: 10px;
  padding: .65em 1.1em;
  background: var(--panel2);
}
button:hover { filter: brightness(1.15); }
button.primary { background: var(--accent2); color: #fff; font-weight: 600; }
button.danger { background: var(--err); color: #fff; }
button.off { background: #3a2226; color: #ffb4b4; }

input[type="text"], select {
  width: 100%;
  background: var(--panel2);
  border: 1px solid #2c3a48;
  border-radius: 10px;
  padding: .6em .8em;
}

label { display: block; margin: .9em 0 .3em; color: var(--muted); font-size: .9rem; }
label.check { display: flex; gap: .6em; align-items: center; color: var(--text); margin: 1em 0; }
label.check input { width: 1.1em; height: 1.1em; }

.hint { color: var(--muted); font-size: .88rem; line-height: 1.45; }
.error { color: var(--err); min-height: 1.2em; }

/* ---------- landing + pre-join ---------- */
.center {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 20px;
}

.card {
  width: min(520px, 100%);
  background: var(--panel);
  border-radius: var(--radius);
  padding: 26px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .35);
}

.card h1 { font-size: 1.6rem; }
.card .sub { color: var(--muted); margin: 0 0 1.2em; }
.row { display: flex; gap: .6em; }
.row > * { flex: 1; }
.row > button { flex: 0 0 auto; }
.divider { text-align: center; color: var(--muted); margin: 1.2em 0; font-size: .85rem; }
#preview { width: 100%; aspect-ratio: 16 / 9; background: #000; border-radius: 12px; object-fit: cover; transform: scaleX(-1); }

/* ---------- call screen ---------- */
#call { display: flex; flex-direction: column; height: 100%; }

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--panel);
}
.brand { font-weight: 700; }
.spacer { flex: 1; }

.chip {
  font-size: .8rem;
  padding: .3em .7em;
  border-radius: 999px;
  background: var(--panel2);
  color: var(--muted);
  max-width: 46ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chip.ok { background: #12301f; color: #7ee2a0; }
.chip.wait { background: #33290f; color: #f6c76a; }
.chip.err { background: #3a1a1a; color: #ff9d9d; }

.stage {
  position: relative;
  flex: 1;
  min-height: 0;
  padding: 12px;
}

.tile {
  position: relative;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
}
.tile video { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile.remote { width: 100%; height: 100%; }
.tile.local {
  position: absolute;
  right: 24px;
  bottom: 24px;
  width: min(26vw, 220px);
  aspect-ratio: 16 / 9;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .5);
}
.tile.local video { transform: scaleX(-1); }
.tag {
  position: absolute;
  left: 10px;
  bottom: 8px;
  font-size: .8rem;
  background: rgba(0, 0, 0, .55);
  padding: .15em .6em;
  border-radius: 8px;
}
#waiting {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--muted);
  padding: 20px;
}

.captions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 0 12px 8px;
}
.capbox {
  background: var(--panel);
  border-radius: 12px;
  padding: 8px 12px;
  min-height: 84px;
  max-height: 140px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}
.capbox > div { margin-top: auto; }
.capbox h3 { margin: 0 0 4px; font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.capbox .line { font-size: 1.02rem; line-height: 1.35; }
.capbox .line:not(:last-child) { opacity: .55; }
.capbox.translated .line:last-child { color: #a8d0ff; }

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  padding: 10px 14px 14px;
  background: var(--panel);
}
.controls .group { display: flex; align-items: center; gap: 8px; }
.controls label { margin: 0; display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: .85rem; }
.controls select { width: auto; padding: .45em .6em; }
.controls input[type="range"] { width: 110px; }

@media (max-width: 720px) {
  .captions { grid-template-columns: 1fr; }
  .tile.local { width: 34vw; right: 18px; bottom: 18px; }
}
