/* ============================================================
 *  Presentation Camera — Editorial Broadcast
 *  A tiny broadcast booth for talking-head over slides.
 *  ============================================================ */

/* ─── Fonts ──────────────────────────────────────────────────── */

@font-face {
  font-family: 'Fraunces';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('vendor/fonts/fraunces-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6,
                 U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F,
                 U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Fraunces';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('vendor/fonts/fraunces-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7,
                 U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF,
                 U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0,
                 U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Fraunces';
  font-style: italic;
  font-weight: 400 700;
  font-display: swap;
  src: url('vendor/fonts/fraunces-italic-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6,
                 U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F,
                 U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Fraunces';
  font-style: italic;
  font-weight: 400 700;
  font-display: swap;
  src: url('vendor/fonts/fraunces-italic-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7,
                 U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF,
                 U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0,
                 U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ─── Tokens ─────────────────────────────────────────────────── */

:root {
  /* Warm cinema palette. Everything tinted toward amber/clay. */
  --bg-deep:      oklch(0.135 0.012 60);
  --bg-base:      oklch(0.165 0.014 60);
  --bg-raised:    oklch(0.205 0.016 60);
  --bg-elevated:  oklch(0.245 0.018 60);
  --bg-input:     oklch(0.115 0.010 60);

  --line-soft:    oklch(0.30 0.020 60);
  --line:         oklch(0.40 0.025 60);
  --line-bright:  oklch(0.55 0.040 60);

  --ink-strong:   oklch(0.96 0.012 80);
  --ink-body:     oklch(0.82 0.014 75);
  --ink-muted:    oklch(0.62 0.014 65);
  --ink-faint:    oklch(0.46 0.014 60);

  --accent:       oklch(0.78 0.155 70);    /* warm amber */
  --accent-deep:  oklch(0.70 0.180 60);
  --accent-soft:  oklch(0.78 0.155 70 / .14);
  --accent-line:  oklch(0.78 0.155 70 / .35);

  --live:         oklch(0.65 0.235 25);    /* broadcast red */
  --live-soft:    oklch(0.65 0.235 25 / .18);

  --focus-ring:   oklch(0.82 0.16 70 / .55);
  --on-accent:    oklch(0.18 0.030 60);    /* texto sobre el ámbar */

  --serif: 'Fraunces', 'Iowan Old Style', 'Hoefler Text', 'Apple Garamond',
           'Big Caslon', Georgia, serif;
  --sans:  ui-sans-serif, system-ui, -apple-system, 'Segoe UI Variable',
           'Segoe UI', sans-serif;
  --mono:  ui-monospace, 'SF Mono', 'JetBrains Mono', Menlo, Consolas, monospace;

  --radius-xs: 4px;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;

  --shadow-edge: 0 1px 0 oklch(1 0 0 / .05) inset, 0 0 0 1px oklch(0 0 0 / .35) inset;
  --shadow-low:  0 1px 2px oklch(0 0 0 / .4), 0 4px 12px -4px oklch(0 0 0 / .5);
  --shadow-mid:  0 8px 24px -8px oklch(0 0 0 / .55), 0 2px 4px oklch(0 0 0 / .35);
  --shadow-high: 0 24px 56px -16px oklch(0 0 0 / .65),
                 0 8px 20px -8px oklch(0 0 0 / .45),
                 0 0 0 1px oklch(1 0 0 / .04) inset;

  --grain: radial-gradient(120% 80% at 20% 0%,
                            oklch(0.30 0.040 55 / .35),
                            transparent 55%),
           radial-gradient(80% 60% at 100% 100%,
                            oklch(0.25 0.060 30 / .25),
                            transparent 60%);

  --ease-out:  cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in:   cubic-bezier(0.4, 0, 1, 1);
  --ease-soft: cubic-bezier(0.4, 0, 0.2, 1);

  color-scheme: dark;
}

/* Tema claro (CAM-TSK-0065): theme.js fija data-theme. Mismos tokens, papel
   cálido y tinta oscura; el ámbar se oscurece para leerse sobre claro. */
:root[data-theme="light"] {
  --bg-deep:      oklch(0.955 0.012 80);
  --bg-base:      oklch(0.975 0.010 80);
  --bg-raised:    oklch(0.990 0.006 80);
  --bg-elevated:  oklch(1 0 0);
  --bg-input:     oklch(0.930 0.014 75);

  --line-soft:    oklch(0.87 0.016 70);
  --line:         oklch(0.76 0.022 65);
  --line-bright:  oklch(0.60 0.040 60);

  --ink-strong:   oklch(0.20 0.020 55);
  --ink-body:     oklch(0.30 0.020 55);
  --ink-muted:    oklch(0.40 0.020 55);
  --ink-faint:    oklch(0.45 0.018 55);

  --accent:       oklch(0.50 0.140 55);
  --accent-deep:  oklch(0.44 0.150 50);
  --accent-soft:  oklch(0.50 0.140 55 / .12);
  --accent-line:  oklch(0.50 0.140 55 / .38);
  --on-accent:    oklch(0.99 0.006 80);

  --live:         oklch(0.55 0.220 25);
  --live-soft:    oklch(0.55 0.220 25 / .14);

  --focus-ring:   oklch(0.52 0.160 58 / .55);

  --shadow-edge: 0 1px 0 oklch(1 0 0 / .7) inset, 0 0 0 1px oklch(0 0 0 / .06) inset;
  --shadow-low:  0 1px 2px oklch(0 0 0 / .08), 0 4px 12px -4px oklch(0 0 0 / .12);
  --shadow-mid:  0 8px 24px -8px oklch(0 0 0 / .16), 0 2px 4px oklch(0 0 0 / .08);
  --shadow-high: 0 24px 56px -16px oklch(0 0 0 / .20),
                 0 8px 20px -8px oklch(0 0 0 / .10),
                 0 0 0 1px oklch(0 0 0 / .04) inset;

  --grain: radial-gradient(120% 80% at 20% 0%,
                            oklch(0.93 0.040 75 / .55),
                            transparent 55%),
           radial-gradient(80% 60% at 100% 100%,
                            oklch(0.92 0.050 40 / .35),
                            transparent 60%);

  color-scheme: light;
}

/* ─── Reset ──────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: var(--sans);
  font-size: 16px;
  font-feature-settings: "kern", "liga", "calt", "ss01";
  font-optical-sizing: auto;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;

  color: var(--ink-body);
  background: var(--bg-deep);
  background-image: var(--grain);
  background-attachment: fixed;
  min-height: 100vh;
  overflow-x: hidden;
}

button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
fieldset { border: none; }
legend { display: block; }
a { color: inherit; text-decoration: none; }
svg { display: block; }
kbd {
  font-family: var(--mono);
  font-size: 0.72em;
  letter-spacing: 0.04em;
  padding: 0.15em 0.45em;
  border-radius: 4px;
  background: oklch(1 0 0 / .06);
  border: 1px solid var(--line-soft);
  color: var(--ink-strong);
  text-transform: uppercase;
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ─── Setup layout ───────────────────────────────────────────── */

/* Una sola pantalla (CAM-TSK-0081): barra fina arriba y, debajo, vista previa
   grande y panel lateral. En pantallas estrechas las columnas se apilan. */
.setup {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Rejilla: en escritorio, vista previa y pie a la izquierda, panel a la derecha
   ocupando toda la altura (el pie aprovecha el hueco bajo la vista previa y no
   añade scroll); en pantallas estrechas, todo en una columna y el pie al final. */
.setup-grid {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
  gap: clamp(1rem, 2vw, 1.75rem);
  padding: clamp(1rem, 2vw, 1.75rem);
  max-width: 1680px;
  width: 100%;
  margin: 0 auto;
}
@media (min-width: 961px) {
  .setup-grid { grid-template-columns: minmax(0, 1fr) minmax(360px, 440px); grid-template-rows: auto 1fr; }
  .setup-panel { grid-column: 2; grid-row: 1 / span 2; }
  .site-footer { grid-column: 1; grid-row: 2; align-self: end; }
}
.site-footer { font-size: 0.8rem; color: var(--ink-muted); }
.recovery-notice { display: grid; gap: 0.75rem; padding: 1rem; border: 1px solid var(--live); border-radius: 12px; background: var(--live-soft); color: var(--ink-strong); font-size: 0.875rem; }
.recovery-notice[hidden] { display: none; }
.recovery-item { display: grid; gap: 0.6rem; }
.recovery-actions { display: flex; gap: 0.5rem; }
.site-footer a { color: var(--ink-body); text-decoration: underline; text-underline-offset: 2px; }
.site-footer a:hover { color: var(--accent); }
.site-footer a:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.setup-stage {
  min-width: 0;
  display: grid;
  gap: 0.9rem;
}
.setup-panel {
  min-width: 0;
  display: grid;
  gap: 1.4rem;
  padding: 1.5rem;
  border-radius: 18px;
  background: var(--bg-base);
  border: 1px solid var(--line-soft);
}

/* ─── Topbar ────────────────────────────────────────────────── */

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.25rem 1rem;
  padding: 0.35rem clamp(1rem, 2vw, 1.75rem);
  border-bottom: 1px solid var(--line-soft);
  font-size: 0.875rem;
  color: var(--ink-muted);
}

.wordmark {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.75rem;
}
.wordmark-mark {
  display: inline-flex;
  width: 22px; height: 22px;
  align-items: center; justify-content: center;
  color: var(--accent);
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--bg-raised);
}
.wordmark-text {
  font-family: var(--serif);
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--ink-strong);
}
.topbar-tagline { color: var(--ink-muted); }
.topbar-meta {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}
.topbar-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 0.85rem;
  border-radius: var(--radius-sm);
  color: var(--ink-body);
  transition: color .15s var(--ease-soft), background .15s var(--ease-soft);
}
.topbar-link:hover { color: var(--accent); background: var(--bg-raised); }
.topbar-link:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }

/* ─── Panels ────────────────────────────────────────────────── */

.panel {
  display: grid;
  gap: 0.75rem;
}

.panel-header {
  display: grid;
  grid-template-columns: auto auto 1fr;
  align-items: baseline;
  gap: 0.9rem;
}
.panel-num {
  font-family: var(--mono);
  font-size: 0.75rem;
  padding: 0.1rem 0.4rem;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}
.panel-title {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.25rem;
  color: var(--ink-strong);
}
.panel-rule {
  display: block;
  height: 1px;
  background: var(--line-soft);
  margin-bottom: 4px;
}

/* ─── Tu presentación (CAM-TSK-0083) ───────────────────────── */

.link-row { display: flex; gap: 0.5rem; }
.url-input {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  padding: 0 0.85rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-input);
  color: var(--ink-strong);
  font-size: 0.875rem;
}
.url-input::placeholder { color: var(--ink-faint); }
.url-input:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 1px; }

.row-btn {
  min-height: 44px;
  padding: 0 0.9rem;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: var(--bg-raised);
  color: var(--ink-body);
  font-size: 0.875rem;
  text-align: left;
}
.row-btn:hover { border-color: var(--line-bright); color: var(--ink-strong); }
.row-btn:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }

.upload-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  min-height: 52px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  color: var(--ink-body);
  font-size: 0.875rem;
}
.upload-btn:hover { border-color: var(--accent); color: var(--accent); }
.upload-btn:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.upload-btn:disabled { opacity: .6; cursor: progress; }
/* Menú del botón de subir: popover nativo anclado debajo del botón */
.upload-menu {
  position-anchor: --upload;
  inset: auto;
  top: anchor(bottom);
  left: anchor(left);
  width: anchor-size(width);
  margin: 0.35rem 0 0;
  padding: 0.35rem;
  display: none;
  gap: 0.35rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-elevated);
  color: var(--ink-body);
  box-shadow: var(--shadow-mid);
}
.upload-menu:popover-open { display: grid; }
.upload-btn { anchor-name: --upload; }

.ghost-button {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.7rem;
  font-size: 0.78rem;
  color: var(--ink-muted);
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  transition: color .15s, border-color .15s, background .15s;
  white-space: nowrap;
}
.ghost-button:hover {
  color: var(--accent);
  border-color: var(--accent-line);
  background: var(--accent-soft);
}
.ghost-button:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}
.panel > .ghost-button { justify-self: start; }
.ghost-button-wide {
  width: 100%;
  justify-content: flex-start;
  padding: 0.6rem 0.9rem;
}
.ghost-button-wide kbd { margin-left: auto; }

.panel-cta {
  display: grid;
  gap: 0.5rem;
  padding-top: 0.25rem;
}
.panel-cta-help {
  font-size: 0.78rem;
  color: var(--ink-faint);
  line-height: 1.5;
  max-width: 56ch;
}

/* Versión publicada (version.json), en la ayuda */
.app-version { font-family: var(--mono); letter-spacing: 0.04em; }

/* Presentaciones guardadas: elegir la activa y quitar las que sobran */
/* Recientes: su tecla 1–9, título y tipo, y «En uso» en la activa */
.saved-sources { display: grid; gap: 0.35rem; }
.saved-sources-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.saved-sources-list:empty { display: none; }
.saved-source { display: flex; align-items: center; gap: 0.25rem; }
.saved-source-pick {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
  min-height: 44px;
  padding: 0.25rem 0.6rem;
  border-radius: 10px;
  color: var(--ink-body);
  text-align: left;
}
.saved-source-pick:hover { background: var(--bg-elevated); }
.saved-source-pick[aria-pressed="true"] { background: var(--accent-soft); }
.saved-source-text { flex: 1; min-width: 0; display: grid; }
.saved-source-title { color: var(--ink-strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.saved-source-kind { font-size: 0.75rem; color: var(--ink-muted); white-space: nowrap; }
.saved-source-in-use { font-size: 0.75rem; color: var(--accent); white-space: nowrap; }
.saved-source-remove {
  width: 44px; height: 44px;
  border-radius: 10px;
  color: var(--ink-muted);
}
.saved-source-remove:hover { color: var(--accent); }
.saved-source-pick:focus-visible,
.saved-source-remove:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

/* ─── Vista previa 16:9 (CAM-TSK-0082) ─────────────────────── */
.stage-mock {
  position: relative;
  aspect-ratio: 16 / 9;
  background: linear-gradient(135deg, oklch(0.22 0.015 60), oklch(0.18 0.018 60));
  border: 1px solid var(--line-soft);
  border-radius: 16px;
  box-shadow: var(--shadow-high);
  overflow: hidden;
  isolation: isolate;
}

/* La diapositiva real de la presentación activa (setupPreview.js), inerte */
.stage-slide { position: absolute; inset: 0; }
.stage-slide iframe { display: block; width: 100%; height: 100%; border: 0; background: oklch(1 0 0); }

/* Silueta de la cámara: esquina, estilo y tamaño elegidos, en proporción a lo
   que se verá en directo (14/20/28 % del ancho). */
.stage-mock-cam {
  --cam-inset: 3%;
  position: absolute;
  z-index: 1;
  bottom: var(--cam-inset);
  right: var(--cam-inset);
  width: 20%;
  aspect-ratio: 4 / 3;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  overflow: hidden;
  color: oklch(0.86 0.06 60);
  background: oklch(0.40 0.05 55);
  border: 3px solid oklch(0.96 0.012 80);
  border-radius: 12px;
  box-shadow: var(--shadow-mid);
  transition: width .35s var(--ease-out);
}
.stage-mock-cam svg { width: 72%; height: auto; }
.setup:has(input[name="position"][value="top-left"]:checked)     .stage-mock-cam { top: var(--cam-inset); left: var(--cam-inset); bottom: auto; right: auto; }
.setup:has(input[name="position"][value="top-right"]:checked)    .stage-mock-cam { top: var(--cam-inset); right: var(--cam-inset); bottom: auto; left: auto; }
.setup:has(input[name="position"][value="bottom-left"]:checked)  .stage-mock-cam { bottom: var(--cam-inset); left: var(--cam-inset); top: auto; right: auto; }
.setup:has(input[name="webcam-size"][value="s"]:checked) .stage-mock-cam { width: 14%; }
.setup:has(input[name="webcam-size"][value="l"]:checked) .stage-mock-cam { width: 28%; }

/* Esquinas: los radios de posición, de 44 px, en las esquinas de la vista previa */
.stage-corners { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.stage-corner {
  position: absolute;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px dashed var(--line-bright);
  border-radius: 12px;
  background: oklch(0.135 0.012 60 / .55);
  cursor: pointer;
  pointer-events: auto;
}
.stage-corner::after {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  opacity: .55;
}
.stage-corner input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
.stage-corner:hover { border-color: var(--accent); }
.stage-corner:has(input:checked) { border-style: solid; border-color: var(--accent); background: oklch(0.78 0.155 70 / .25); }
.stage-corner:has(input:checked)::after { opacity: 1; }
.stage-corner:has(input:focus-visible) { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.stage-corner[data-pos="top-left"]     { top: 12px; left: 12px; }
.stage-corner[data-pos="top-right"]    { top: 12px; right: 12px; }
.stage-corner[data-pos="bottom-left"]  { bottom: 12px; left: 12px; }
.stage-corner[data-pos="bottom-right"] { bottom: 12px; right: 12px; }

/* Estado vacío (CAM-TSK-0085): sin presentaciones, la vista previa invita a
   elegir una; el panel muestra los tres pasos en vez de «Tu presentación». */
.stage-empty {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  padding: 2rem;
  text-align: center;
}
.stage-empty h1 {
  font-family: var(--serif);
  font-size: clamp(1.6rem, 3vw, 2.5rem);
  font-weight: 600;
  line-height: 1.15;
  color: var(--ink-strong);
}
.stage-empty p { max-width: 34rem; line-height: 1.5; color: var(--ink-body); }
.stage-empty .link-row { width: 100%; max-width: 35rem; }
.stage-empty-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.6rem; }
.stage-empty-note { font-size: 0.8rem; color: var(--ink-muted); }
.row-btn-accent { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.row-btn-accent:hover { color: var(--on-accent); background: var(--accent-deep); }
.first-steps { display: none; list-style: none; gap: 1rem; }
.first-steps li { display: flex; align-items: flex-start; gap: 0.75rem; }
.first-steps li > span:last-child { display: grid; gap: 0.15rem; font-size: 0.85rem; color: var(--ink-muted); }
.first-steps strong { font-size: 1rem; color: var(--ink-strong); }

.setup.is-empty .stage-mock { border: 2px dashed var(--line); background: var(--bg-base); box-shadow: none; }
.stage-mock.is-drop-target { outline: 3px dashed var(--accent); outline-offset: -3px; }
.setup.is-empty .stage-empty { display: flex; }
.setup.is-empty :is(.stage-slide, .stage-mock-cam, .stage-corners, .stage-hint) { display: none; }
.setup.is-empty .first-steps { display: grid; }
.setup.is-empty #panel-camera .panel-num { display: none; }
.setup.is-empty :is(section[aria-labelledby="panel-source"], .more-options) { display: none; }
.stage-hint {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  font-size: 0.875rem;
  color: var(--ink-muted);
}
.stage-hint-keys { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; }

/* fondo virtual (CAM-TSK-0061): el selector solo tiene sentido con el recorte */
.control.background-control { display: none; }
.setup:has(input[name="webcam-style"][value="cutout"]:checked) .control.background-control { display: block; }
.bg-gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 6px;
  background: var(--bg-input);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
}
.bg-item { position: relative; display: inline-flex; }
.bg-choice, .bg-upload {
  min-height: 46px;
  padding: 0 0.8rem;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--ink-muted);
  font-size: 0.78rem;
  cursor: pointer;
}
.bg-item .bg-choice { padding: 3px; }
.bg-choice img { display: block; width: 64px; height: 40px; object-fit: cover; border-radius: 4px; }
.bg-choice[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--ink-strong); }
.bg-remove {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  border: 1px solid var(--line-soft);
  border-radius: 50%;
  background: var(--bg-input);
  color: var(--ink-muted);
  line-height: 1;
  cursor: pointer;
}
.bg-choice:focus-visible, .bg-upload:focus-visible, .bg-remove:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* sin cámara: la maqueta no dibuja el recuadro (CAM-BUG-0019) */
.setup:has(input[name="webcam-style"][value="none"]:checked) .stage-mock-cam {
  display: none;
}

/* recortada: solo la silueta, sin recuadro */
.setup:has(input[name="webcam-style"][value="cutout"]:checked) .stage-mock-cam {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}

/* ─── Stage controls ────────────────────────────────────────── */

.stage-controls {
  display: grid;
  gap: 1rem;
}

.control {
  display: grid;
  gap: 0.5rem;
}
.control-label {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

/* Segmentado (cómo apareces / tamaño): opciones a lo ancho, 44 px */
.seg {
  display: flex;
  gap: 6px;
  padding: 4px;
  border-radius: 12px;
  background: var(--bg-input);
}
.seg-option { flex: 1 1 0; display: flex; }
.seg-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.seg-card {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 0.5rem;
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  color: var(--ink-body);
  font-size: 0.875rem;
  font-weight: 500;
  text-align: center;
  transition: background .15s, color .15s;
}
.seg-card:hover { background: var(--bg-elevated); }
.seg-option input:checked + .seg-card {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--ink-strong);
}
.seg-option input:focus-visible + .seg-card {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}
/* Sin cámara no hay tamaño que elegir */
.setup:has(input[name="webcam-style"][value="none"]:checked) .size-control { display: none; }

/* Select nativo (cámara) */
.select {
  min-height: 40px;
  padding: 0 0.6rem;
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink-strong);
  font-size: 0.875rem;
  cursor: pointer;
}
.select:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

/* ─── Footer + Start button ─────────────────────────────────── */

.setup-footer {
  display: grid;
  gap: 0.75rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line-soft);
}
.setup-footer .start-button { width: 100%; justify-content: center; }

.start-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.5rem 1rem 1.7rem;
  background: var(--accent);
  color: var(--on-accent);
  border-radius: var(--radius-md);
  min-height: 56px;
  font-family: var(--serif);
  font-size: 1.3rem;
  font-weight: 600;
  letter-spacing: -0.005em;
  box-shadow:
    0 1px 0 oklch(1 0 0 / .35) inset,
    0 -2px 0 oklch(0 0 0 / .15) inset,
    0 14px 30px -10px oklch(0.78 0.155 70 / .5),
    0 4px 10px -2px oklch(0 0 0 / .35);
  transition: transform .15s var(--ease-out),
              box-shadow .2s var(--ease-soft),
              background .15s var(--ease-soft);
  overflow: hidden;
}
.start-button-tape {
  position: absolute;
  top: 0;
  left: -2px;
  bottom: 0;
  width: 6px;
  background: repeating-linear-gradient(
    -45deg,
    oklch(0.18 0.030 60) 0px,
    oklch(0.18 0.030 60) 4px,
    oklch(0.78 0.155 70) 4px,
    oklch(0.78 0.155 70) 8px
  );
}
.start-button-label { position: relative; }
.start-button-arrow {
  position: relative;
  display: inline-flex;
  transition: transform .25s var(--ease-out);
}
.start-button:hover {
  transform: translateY(-1px);
  background: oklch(0.82 0.16 72);
  box-shadow:
    0 1px 0 oklch(1 0 0 / .35) inset,
    0 -2px 0 oklch(0 0 0 / .15) inset,
    0 20px 36px -12px oklch(0.78 0.155 70 / .65),
    0 6px 14px -4px oklch(0 0 0 / .4);
}
.start-button:hover .start-button-arrow { transform: translateX(4px); }
.start-button:active { transform: translateY(0); }
.start-button:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 4px; }
.start-button:disabled {
  background: var(--bg-raised);
  color: var(--ink-muted);
  box-shadow: none;
  cursor: not-allowed;
}
.start-button:disabled .start-button-tape { display: none; }


/* ─── Toast / status ────────────────────────────────────────── */

.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  padding: 0.7rem 1.1rem;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--ink-strong);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-mid);
  font-size: 0.88rem;
  max-width: min(90vw, 520px);
  z-index: 50;
  opacity: 0;
  transition: opacity .25s var(--ease-soft), transform .25s var(--ease-out);
  letter-spacing: -0.005em;
  pointer-events: none;
}
.toast:not([hidden]) {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast::before {
  content: "";
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  margin-right: 0.55rem;
  vertical-align: middle;
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.toast.error {
  color: oklch(0.92 0.04 25);
  border-color: oklch(0.65 0.235 25 / .55);
  background: linear-gradient(135deg,
    oklch(0.22 0.06 30) 0%,
    var(--bg-elevated) 80%);
}
.toast.error::before {
  background: var(--live);
  box-shadow: 0 0 0 4px var(--live-soft);
}

/* ─── In-presentation: iframe layer ─────────────────────────── */

#presentationSection {
  position: fixed;
  inset: 0;
  z-index: 0;
  background: var(--bg-deep);
}
#presentationSection[hidden] { display: none; }

/* Stack de iframes superpuestos. Cada source mantiene su propio iframe
 * cargado para conservar estado (slide actual, zoom...) entre cambios.
 * Solo el activo es visible. Usamos visibility + z-index en lugar de
 * display:none para que el navegador no pause el contenido inactivo. */
.iframe-stack {
  position: absolute;
  inset: 0;
}
.iframe-stack iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
  display: block;
  visibility: hidden;
  z-index: 0;
  background: var(--bg-deep);
}
.iframe-stack iframe.is-active {
  visibility: visible;
  z-index: 1;
}

/* Hide setup completely when presentation is on */
body:has(#presentationSection:not([hidden])) .setup { display: none; }

/* ─── In-presentation: live badge ───────────────────────────── */

.live-badge {
  position: fixed;
  top: 1rem;
  left: 1rem;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.4rem 0.8rem 0.4rem 0.65rem;
  background: oklch(0.16 0.014 60 / .85);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border: 1px solid oklch(0.65 0.235 25 / .55);
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  color: oklch(0.96 0.04 25);
  z-index: 10;
  box-shadow: 0 8px 24px -10px oklch(0 0 0 / .5);
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity .35s var(--ease-soft), transform .35s var(--ease-out);
}
.live-badge:not([hidden]) {
  opacity: 1;
  transform: translateY(0);
}
.live-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--live);
  box-shadow: 0 0 0 3px var(--live-soft);
  animation: pulse 1.4s var(--ease-soft) infinite;
}
.live-time {
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.08em;
  padding-left: 0.4rem;
  border-left: 1px solid oklch(1 0 0 / .1);
  margin-left: 0.1rem;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 3px var(--live-soft); }
  50%      { box-shadow: 0 0 0 6px oklch(0.65 0.235 25 / .05); }
}

/* ─── In-presentation: top action cluster ───────────────────── */

.top-actions {
  position: fixed;
  top: 1rem;
  right: 1rem;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  z-index: 10;
}
.top-actions[hidden] { display: none; }

.end-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.5rem 0.9rem 0.5rem 0.75rem;
  background: oklch(0.16 0.014 60 / .85);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  color: var(--ink-body);
  box-shadow: 0 8px 24px -10px oklch(0 0 0 / .5);
  transition: color .15s, border-color .15s, background .15s, transform .15s var(--ease-out);
  opacity: 0;
  transform: translateY(-6px);
  animation: topAppear .35s var(--ease-out) forwards;
}
.end-button-ghost {
  background: oklch(0.16 0.014 60 / .55);
}
.end-button-label { white-space: nowrap; }
@keyframes topAppear {
  to { opacity: 1; transform: translateY(0); }
}
.end-button:hover {
  color: oklch(0.92 0.04 25);
  border-color: oklch(0.65 0.235 25 / .55);
  background: oklch(0.20 0.05 30 / .85);
}
.end-button:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 3px;
}
.end-button .kbd-hint {
  opacity: .55;
  font-size: 0.6rem;
  padding: 0.1em 0.4em;
  margin-left: 0.25rem;
}

/* Fullscreen icon swap */
#fullscreenBtn .fs-icon-exit { display: none; }
#fullscreenBtn.is-fullscreen .fs-icon-enter { display: none; }
#fullscreenBtn.is-fullscreen .fs-icon-exit  { display: block; }

/* On narrow screens hide the labels, keep icons */
@media (max-width: 640px) {
  .end-button-label { display: none; }
  .end-button .kbd-hint { display: none; }
}

/* ─── Webcam stage (during presentation) ────────────────────── */

#webcamSection.video-container {
  position: fixed;
  z-index: 2;
  padding: 0;
  overflow: visible;
  width: 20vw;
  max-width: 320px;
  aspect-ratio: 4 / 3;
  transition: top .35s var(--ease-out),
              left .35s var(--ease-out),
              right .35s var(--ease-out),
              bottom .35s var(--ease-out),
              width .25s var(--ease-out);
}
#webcamSection[hidden] { display: none; }

/* Corners */
#webcamSection.bottom-right { bottom: 1.5rem; right: 1.5rem; top: auto;  left: auto; }
#webcamSection.bottom-left  { bottom: 1.5rem; left: 1.5rem;  top: auto;  right: auto; }
#webcamSection.top-right    { top: 1.5rem;    right: 1.5rem; bottom: auto; left: auto; }
#webcamSection.top-left     { top: 1.5rem;    left: 1.5rem;  bottom: auto; right: auto; }

/* Sizes */
#webcamSection.size-s { width: 14vw; max-width: 220px; }
#webcamSection.size-m { width: 20vw; max-width: 320px; }
#webcamSection.size-l { width: 28vw; max-width: 460px; }

/* Framed: rounded card with subtle accent ring + soft shadow */
#webcamSection.frame {
  border-radius: var(--radius-md);
  background: oklch(0.10 0.012 60 / .85);
  box-shadow:
    0 1px 0 oklch(1 0 0 / .08) inset,
    0 0 0 1px oklch(0.78 0.155 70 / .15),
    0 24px 60px -18px oklch(0 0 0 / .7),
    0 8px 20px -8px oklch(0 0 0 / .4);
  padding: 6px;
}
#webcamSection.frame canvas {
  border-radius: calc(var(--radius-md) - 6px);
  overflow: hidden;
}

/* Cutout: no chrome, just the silhouette */
#webcamSection.cutout {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
}

#webcamSection canvas {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  transform: scaleX(-1);
}
#webcamVideo { display: none; }

/* Marco: el <video> se muestra directamente (sin bucle de canvas por frame). */
#webcamSection.frame #webcamVideo {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
  border-radius: calc(var(--radius-md) - 6px);
}
#webcamSection.frame canvas { display: none; }
/* Sin espejo (CAM-TSK-0079): la cámara, y por tanto la grabación, al derecho. */
#webcamSection.no-mirror canvas,
#webcamSection.no-mirror #webcamVideo { transform: none; }

/* La cámara es solo imagen: deja pasar los clics a la presentación de debajo
   (p. ej. las flechas de reveal.js en la esquina inferior derecha). Solo su
   tira de herramientas recibe eventos. */
#webcamSection { pointer-events: none; }

/* Webcam tools: floating strip below the camera, siempre visible pero discreta
   (sin pointer-events en la cámara, el :hover sobre ella no se dispara). */
.webcam-tools {
  position: absolute;
  left: 50%;
  bottom: -1.4rem;
  transform: translate(-50%, 4px);
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  background: oklch(0.14 0.014 60 / .92);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  opacity: .55;
  pointer-events: auto;
  transition: opacity .2s var(--ease-soft), transform .25s var(--ease-out);
  box-shadow: 0 12px 24px -8px oklch(0 0 0 / .6);
}
.webcam-tools:hover,
.webcam-tools:focus-within {
  opacity: 1;
  transform: translate(-50%, 0);
}
.tool-btn {
  width: 30px; height: 30px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-muted);
  transition: color .15s, background .15s;
}
.tool-btn:hover {
  color: var(--accent);
  background: oklch(0.78 0.155 70 / .12);
}
.tool-btn:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

/* Cutout has no chrome, but tools still appear */
#webcamSection.cutout .webcam-tools {
  bottom: -1.6rem;
}

/* Grabación: punto REC en el botón y toggle de auto-grabación */
.rec-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: currentColor;
  opacity: .5;
  flex: none;
}
#recordBtn.is-recording {
  color: #ff3b30;
}
#recordBtn.is-recording .rec-dot {
  background: #ff3b30;
  opacity: 1;
  animation: rec-pulse 1.2s ease-in-out infinite;
}
@keyframes rec-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .25; }
}
/* Casillas y opciones del panel: texto a la izquierda, control a la derecha (44 px) */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-height: 44px;
  font-size: 0.875rem;
  color: var(--ink-body);
  cursor: pointer;
}
.toggle-row input[type="checkbox"] { width: 20px; height: 20px; flex-shrink: 0; accent-color: var(--accent); cursor: pointer; }
.toggle-row .select { max-width: 60%; }
.toggle-row[hidden] { display: none; }
.setup-footer .rec-dot { vertical-align: middle; color: var(--live); opacity: 1; }

.more-options summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-height: 44px;
  font-weight: 500;
  color: var(--ink-strong);
  cursor: pointer;
}
.more-options summary:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.more-hint { font-size: 0.8rem; font-weight: 400; color: var(--ink-muted); }
.more-body { display: grid; padding-top: 0.25rem; }
.open-panel-btn { display: flex; align-items: center; justify-content: space-between; margin-top: 0.5rem; }
.share-note { font-size: 0.75rem; color: var(--ink-muted); text-align: center; }

/* ─── Ayuda (CAM-TSK-0086): <dialog> modal con todos los atajos ─ */
.help-dialog {
  width: min(560px, calc(100% - 2rem));
  max-height: 90vh;
  margin: auto;
  padding: clamp(1.5rem, 4vw, 2rem);
  overflow-y: auto;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-high);
  color: var(--ink-body);
  line-height: 1.5;
}
.help-dialog::backdrop { background: oklch(0 0 0 / .6); backdrop-filter: blur(2px); }
.help-dialog h2 { font-family: var(--serif); font-size: 1.5rem; color: var(--ink-strong); margin-bottom: 0.5rem; }
.help-dialog h3 { margin: 1.25rem 0 0.5rem; font-size: 1rem; color: var(--ink-strong); }
.help-close-form { position: absolute; top: 0.5rem; right: 0.5rem; }
.help-close { width: 44px; height: 44px; border-radius: 50%; color: var(--ink-muted); }
.help-close:hover { background: var(--bg-elevated); color: var(--ink-strong); }
.help-close:focus-visible { outline: 2px solid var(--focus-ring); }
.help-keys { display: grid; gap: 0.4rem; }
.help-keys > div { display: grid; grid-template-columns: 7rem 1fr; align-items: center; gap: 0.75rem; }
.help-keys dt { display: flex; gap: 0.25rem; }
.help-meta { margin-top: 0.75rem; font-size: 0.8rem; color: var(--ink-muted); }
.help-meta:empty { display: none; }

/* ─── Ocultar controles durante la grabación ─────────────────── */
/* Con body.chrome-hidden se ocultan los controles de la app para que no salgan
   en la grabación, avisos incluidos; la presentación y la cámara siguen visibles. */
body.chrome-hidden #topActions,
body.chrome-hidden #liveBadge,
body.chrome-hidden #statusMessage,
body.chrome-hidden #webcamSection .webcam-tools {
  display: none !important;
}
.show-chrome-btn {
  position: fixed;
  top: 0.9rem;
  left: 0.9rem;
  z-index: 60;
  width: 2rem;
  height: 2rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--ink-body);
  background: oklch(0 0 0 / .35);
  border: 1px solid oklch(1 0 0 / .15);
  opacity: .35;
  transition: opacity .15s ease;
}
.show-chrome-btn:hover { opacity: 1; }
.show-chrome-btn[hidden] { display: none; }

/* Reduced motion: kill the bigger animations */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
