:root {
  --bg: #f5f3ee;
  --surface: #ffffff;
  --ink: #14161b;
  --ink-muted: #5b606b;
  --line: #e2ded5;
  --accent: #2e47d1;
  --accent-pressed: #2539ad;
  --on-accent: #ffffff;
  --danger: #c8372d;
  --warning-bg: #fbefd9;
  --warning-ink: #6b3f06;
  --call-bg: #0b0c0f;
  --radius: 20px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #0f1013;
    --surface: #17191e;
    --ink: #f2f1ee;
    --ink-muted: #a3a8b3;
    --line: #2a2d34;
    --accent: #4d63f0;
    --accent-pressed: #3f54d6;
    --warning-bg: #3a2a10;
    --warning-ink: #f6d39a;
    color-scheme: dark;
  }
}

:root[data-theme='dark'] {
  --bg: #0f1013;
  --surface: #17191e;
  --ink: #f2f1ee;
  --ink-muted: #a3a8b3;
  --line: #2a2d34;
  --accent: #4d63f0;
  --accent-pressed: #3f54d6;
  --warning-bg: #3a2a10;
  --warning-ink: #f6d39a;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

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

body {
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 17px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

[hidden] {
  display: none !important;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 20px 16px 0;
  max-width: 560px;
  margin: 0 auto;
  font-weight: 700;
  font-size: 20px;
  letter-spacing: -0.4px;
}

.panel {
  max-width: 560px;
  margin: 0 auto;
  padding: 32px 16px 48px;
}

h1 {
  font-size: 28px;
  line-height: 1.2;
  letter-spacing: -0.6px;
  margin: 0 0 12px;
}

.lead {
  color: var(--ink-muted);
  margin: 0 0 24px;
}

.tips {
  list-style: none;
  padding: 20px;
  margin: 0 0 28px;
  background: var(--surface);
  border-radius: var(--radius);
  display: grid;
  gap: 12px;
}

.tips li {
  position: relative;
  padding-left: 22px;
}

.tips li::before {
  content: '';
  position: absolute;
  left: 2px;
  top: 0.6em;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

label {
  display: block;
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 8px;
}

.muted {
  color: var(--ink-muted);
  font-weight: 400;
}

input {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 20px;
}

input:focus-visible,
button:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

button {
  font: inherit;
  cursor: pointer;
}

.primary {
  width: 100%;
  min-height: 60px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
  font-size: 18px;
}

.primary:active {
  background: var(--accent-pressed);
}

.primary:disabled {
  opacity: 0.6;
  cursor: progress;
}

.fineprint {
  color: var(--ink-muted);
  font-size: 14px;
  margin-top: 16px;
}

/* ---- Llamada ---- */

.call {
  position: fixed;
  inset: 0;
  background: var(--call-bg);
  color: #fff;
  display: flex;
  flex-direction: column;
}

.stage {
  flex: 1;
  display: grid;
  gap: 6px;
  padding: 6px;
  grid-template-columns: 1fr;
  grid-auto-rows: 1fr;
  min-height: 0;
}

@media (min-width: 760px) {
  .stage.two {
    grid-template-columns: 1fr 1fr;
  }
}

.tile {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  background: #16181d;
  min-height: 0;
}

.tile video {
  width: 100%;
  height: 100%;
  object-fit: contain; /* nunca recortar manos */
  display: block;
}

.tile .name {
  position: absolute;
  left: 10px;
  bottom: 10px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  font-size: 14px;
  font-weight: 600;
}

.tile.speaking {
  box-shadow: inset 0 0 0 3px #6f84ff;
}

.tile .placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #a3a8b3;
  font-size: 15px;
  text-align: center;
  padding: 16px;
}

.self {
  position: absolute;
  right: 16px;
  bottom: 112px;
  width: 112px;
  aspect-ratio: 3 / 4;
  border-radius: 14px;
  overflow: hidden;
  background: #16181d;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
}

.self video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}

.banner {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  max-width: calc(100% - 32px);
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--warning-bg);
  color: var(--warning-ink);
  font-weight: 600;
  font-size: 15px;
}

/* Abajo a la izquierda, al lado de la propia cámara: no tapa las señas. */
.captions-notice {
  position: absolute;
  left: 16px;
  bottom: 112px;
  z-index: 2;
  max-width: calc(100% - 160px);
  padding: 8px 14px;
  border-radius: 12px;
  background: rgba(22, 24, 29, 0.85);
  color: #fff;
  font-size: 14px;
  line-height: 1.35;
}

/* Algunos navegadores no reproducen sonido hasta que se toca la página. */
.audio-unlock {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 3;
  width: auto;
  max-width: calc(100% - 32px);
  padding: 0 28px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
}

.controls {
  display: flex;
  justify-content: center;
  gap: 12px;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
}

.control {
  min-width: 112px;
  min-height: 56px;
  border-radius: 999px;
  border: 0;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 18px;
}

.control .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #3ecf8e;
}

.control[aria-pressed='false'] {
  background: #fff;
  color: var(--call-bg);
}

.control[aria-pressed='false'] .dot {
  background: var(--danger);
}

.control.danger {
  background: var(--danger);
}

@media (max-width: 420px) {
  .control {
    min-width: 0;
    flex: 1;
  }
}
