/* Diseño de la Suite Digital Carmelo: cabecera azul noche con dorado, pantallas claras.
   La zona de la cámara (escenario) queda oscura, como una pantalla de video. */
:root {
  --night: #0d0e32;
  --bg: #f5f6fb;
  --stage: #06071f;
  --logo-bg: #0D0D31;
  --surface: #ffffff;
  --surface-2: #f5f6fb;
  --surface-3: #e9ebf5;
  --border: #e4e6f0;
  --ink: #171923;
  --title: #0d0e32;
  --muted: #666b80;
  --gold: #D3AC49;
  --gold-hover: #E2BD5E;
  --gold-light: #F2D188;
  --gold-dark: #8a6a17;
  --gold-ink: #0d0e32;
  --gold-gradient: linear-gradient(135deg, #f7dc8a 0%, #d3ac49 45%, #a8812a 100%);
  --danger: #e0455f;
  --rec: #E5484D;
  --r: 14px;
  --shadow: 0 8px 24px rgba(23, 25, 35, .07);
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --font: Inter, "Segoe UI", system-ui, sans-serif;
  --serif: Georgia, "Times New Roman", serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--gold); color: var(--gold-ink); }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* Encabezado */
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px clamp(16px, 2.2vw, 32px);
  color: #fff;
  background:
    radial-gradient(ellipse at 18% 50%, rgba(211,172,73,.18), transparent 55%),
    radial-gradient(ellipse at 100% 0%, rgba(252,202,85,.10), transparent 45%),
    var(--night);
  border-bottom: 3px solid transparent;
  border-image: var(--gold-gradient) 1;
}
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.brand img { width: 64px; height: 64px; flex: none; object-fit: cover; mix-blend-mode: lighten; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand strong {
  font-family: Cinzel, serif; font-weight: 600; font-size: 28px; letter-spacing: .02em; line-height: 1.15; white-space: nowrap;
  background: linear-gradient(180deg, #fff3cf 0%, #fcca55 45%, #c99a2e 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.brand span { color: var(--gold); font-size: 11px; font-weight: 700; letter-spacing: .2em; text-transform: uppercase; white-space: nowrap; }
.tabs { display: flex; gap: 4px; align-items: center; }
.tab {
  background: none;
  border: 0;
  padding: 10px 14px;
  min-height: 44px;
  border-radius: 10px;
  cursor: pointer;
  color: rgba(255, 255, 255, .75);
  font-weight: 700;
  white-space: nowrap;
  transition: background-color 150ms ease, color 150ms ease;
}
.tab[aria-current="page"] { color: #fff; background: rgba(255, 255, 255, .12); }
.tab:disabled { opacity: .5; cursor: not-allowed; }
.tab-install { color: var(--gold); text-decoration: underline; text-underline-offset: .18em; text-decoration-thickness: .07em; }
.count {
  display: inline-block;
  min-width: 1.6em;
  padding: 0 6px;
  margin-left: 4px;
  border-radius: 99px;
  background: var(--gold);
  color: var(--gold-ink);
  font-size: 13px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

main { padding: clamp(16px, 2.2vw, 32px); }

/* Grabar */
.view-grabar, .view-revisar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 350px;
  gap: clamp(16px, 2vw, 28px);
  align-items: start;
}
.stage {
  position: relative;
  aspect-ratio: 16 / 9;
  background: var(--stage);
  border-radius: var(--r);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.stage canvas { display: block; width: 100%; height: 100%; object-fit: contain; background: var(--stage); }
/* Líneas de formato: misma caja 16:9 que el lienzo, aunque el escenario cambie de forma en el celular. */
.guide {
  position: absolute;
  inset: 0;
  margin: auto;
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  pointer-events: none;
}
.guide[hidden] { display: none; }
.guide-box {
  position: absolute;
  outline: 2px solid var(--gold, #d3ac49);
  outline-offset: -2px;
  box-shadow: 0 0 0 2000px rgba(4, 5, 20, 0.62);
}
.guide-name {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(8, 11, 30, 0.84);
  color: #f3e3b3;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.guide-safe { position: absolute; border: 1px dashed rgba(255, 255, 255, 0.75); }
.guide-safe[hidden] { display: none; }
.stage-gate {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: stretch;
  background: var(--logo-bg);
}
.gate-text {
  flex: 1 1 56%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: clamp(20px, 4vw, 52px);
  min-width: 0;
}
.gate-logo { flex: 0 1 44%; width: 44%; height: 100%; object-fit: contain; object-position: center; min-width: 0; }
.stage-gate h1 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(2rem, 1rem + 2.8vw, 4rem);
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--gold-light);
  margin: 0 0 14px -0.03em;
  max-width: 12ch;
  text-wrap: balance;
}
.stage-gate p { margin: 0 0 22px; color: #c9cbe0; max-width: 44ch; text-wrap: pretty; }
.gate-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; }
.gate-error { margin: 16px 0 0 !important; color: var(--danger) !important; }

.countdown {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(8, 11, 30, .62);
  color: var(--gold-light);
  font-family: var(--serif);
  font-size: clamp(6rem, 3rem + 12vw, 13rem);
  line-height: 1;
  cursor: pointer;
}
/* Marcar un pedazo de la pantalla sobre la foto */
.region {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: 14px;
  background: rgba(8, 11, 30, .9);
  touch-action: none;
  user-select: none;
}
.region[hidden], .region-sel[hidden] { display: none; }
.stage.picking .stage-gate { display: none; }
.region.ready { background: transparent; cursor: crosshair; }
.region-sel {
  position: absolute;
  outline: 2px solid var(--gold);
  box-shadow: 0 0 0 4000px rgba(4, 5, 20, .6);
  pointer-events: none;
}
.region-msg {
  position: relative;
  justify-self: center;
  margin: 0;
  padding: 6px 14px;
  border-radius: 10px;
  background: rgba(8, 11, 30, .84);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  text-align: center;
  text-wrap: pretty;
}
.region-bar {
  position: relative;
  grid-row: 3;
  justify-self: center;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  cursor: default;
}
.countdown small { position: absolute; bottom: 18px; font-family: var(--font); font-size: 15px; color: #fff; }

.recbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  padding: 10px 12px 10px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow);
}
.rec-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--rec); flex: none; }
.recbar.paused .rec-dot { background: var(--muted); }
.timer { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 20px; margin-right: auto; }
.hint { color: var(--muted); font-size: 14px; margin: 10px 0 0; }

/* Botones */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 18px;
  border: 0;
  border-radius: 10px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: transform 160ms var(--ease-out), background-color 150ms ease;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-gold { background: var(--gold-gradient); color: var(--gold-ink); box-shadow: 0 12px 28px -12px rgba(211,172,73,.8); }
.btn-quiet { background: var(--night); color: #fff; }
.btn-big { width: 100%; min-height: 56px; font-size: 18px; }
@media (hover: hover) and (pointer: fine) {
  .btn-gold:hover { filter: brightness(1.05); }
  .btn-quiet:hover { background: #06071f; }
  .tab:hover { color: #fff; }
}
.link {
  background: none;
  border: 0;
  padding: 8px 4px;
  min-height: 44px;
  cursor: pointer;
  color: var(--ink);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: .18em;
  text-decoration-thickness: .07em;
}
.link-sm { min-height: 36px; font-size: 14px; padding: 4px 0; }
.link-danger { color: var(--danger); align-self: flex-start; }

/* Panel de opciones */
.panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow);
}
.panel.locked { opacity: .55; }
.live-note { margin: 0; padding: 10px 12px; border-radius: 10px; background: rgba(211, 172, 73, .14); color: var(--title); font-size: 14px; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
fieldset:disabled { opacity: .45; }
legend, .field > span { display: block; padding: 0; margin-bottom: 8px; font-weight: 700; font-size: 14px; color: var(--title); }
.field { display: block; }
.seg {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 4px;
  background: var(--bg);
  border-radius: 10px;
}
.seg label { position: relative; display: flex; }
.seg input { position: absolute; inset: 0; opacity: 0; margin: 0; }
.seg span {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 6px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  cursor: pointer;
  transition: background-color 150ms ease, color 150ms ease;
}
.seg input:checked + span { background: #fff; color: var(--title); box-shadow: inset 0 0 0 2px var(--gold); }
.seg input:focus-visible + span { outline: 2px solid var(--gold); outline-offset: 2px; }
.seg input:disabled + span { cursor: not-allowed; opacity: .5; }

/* Fondos */
.bg-status { font-weight: 400; color: var(--muted); margin-left: 6px; }
.bgs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px 8px; }
.bgs label { position: relative; display: flex; flex-direction: column; gap: 4px; cursor: pointer; }
.bgs input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.bgs em { font-style: normal; font-size: 13px; color: var(--muted); text-align: center; line-height: 1.2; }
.sw {
  display: grid;
  place-items: center;
  aspect-ratio: 16 / 10;
  border-radius: 8px;
  background: var(--bg) center / cover no-repeat;
  outline: 2px solid transparent;
  outline-offset: 2px;
  transition: outline-color 150ms ease;
}
.bgs input:checked + .sw { outline-color: var(--gold); }
.bgs input:checked ~ em { color: var(--ink); }
.bgs input:focus-visible + .sw { outline-color: var(--gold-light); }
.sw-none { background: var(--surface-2); }
.sw-none::after { content: "—"; color: var(--muted); }
.sw-blur { background: radial-gradient(circle at 30% 40%, #6E7AA8 0, transparent 45%), radial-gradient(circle at 75% 60%, #8E7346 0, transparent 40%), #2A3152; filter: saturate(.8); }
.sw-green { background: #00B140; }
.sw-dc { background: var(--night); }
.sw-dc::after { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--gold); }
.sw-logo { background-color: var(--logo-bg); background-image: url("logo-dc.jpg"); background-size: contain; }
.sw-custom b { font-size: 13px; color: var(--gold-dark); }
.sw-custom { box-shadow: inset 0 0 0 1px var(--border); }
.sw-custom.has-img b { display: none; }

/* Menús plegables (fondo) y renglones compactos (cámara, micrófono) */
.fold { border: 1px solid var(--border); border-radius: 10px; }
.fold > summary {
  display: flex; align-items: center; gap: 8px;
  min-height: 44px; padding: 8px 12px;
  cursor: pointer; list-style: none; font-size: 14px;
}
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary::after { content: "▾"; margin-left: auto; color: var(--muted); transition: transform 150ms ease; }
.fold[open] > summary::after { transform: rotate(180deg); }
.fold-label { font-weight: 700; color: var(--title); }
.fold-now { color: var(--muted); }
.fold > fieldset { padding: 4px 12px 12px; }

.devices { display: grid; gap: 8px; }
.row-field { display: grid; grid-template-columns: 82px minmax(0, 1fr); align-items: center; gap: 8px; }
.row-field > span { font-weight: 700; font-size: 14px; color: var(--title); }
.row-field select { min-height: 38px; padding: 6px 10px; font-size: 14px; }
.devices .meter { margin: 0 0 0 90px; height: 4px; }
.check-sm { min-height: 36px; font-size: 14px; }
.tip { font-size: 13px; color: var(--muted); }
.tip summary { cursor: pointer; width: max-content; }
.tip p { margin: 6px 0 0; }

/* El botón de grabar queda siempre a la vista, aunque la ventana sea baja. */
#startBtn { position: sticky; bottom: 12px; }

/* Tu marca */
.brand-box { display: grid; gap: 10px; margin-top: 12px; }
.brand-logo { display: flex; align-items: center; gap: 10px; }
.brand-thumb { width: 44px; height: 44px; flex: none; border-radius: 8px; background: var(--bg) center / contain no-repeat; box-shadow: inset 0 0 0 1px var(--border); }
.brand-box .hint { margin: 0; }

select, input[type="text"] {
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
}
.meter { height: 6px; margin-top: 8px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.meter i { display: block; width: 0; height: 100%; background: var(--gold); transition: width 80ms linear; }

.check { display: flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; font-weight: 700; font-size: 15px; }
.check input { width: 20px; height: 20px; margin: 0; accent-color: var(--gold); flex: none; }
.check.off { opacity: .45; cursor: not-allowed; }

.bubble-row { display: flex; gap: 12px; align-items: stretch; }
.bubble-row .seg { flex: 1; }
.seg-4 { grid-template-columns: repeat(4, 1fr); }
.seg-shape { margin-top: 8px; }
.seg-shape span { min-height: 34px; font-size: 13px; }
.format-note { margin: 8px 0 0; color: var(--muted); font-size: 13px; line-height: 1.35; }
.corners {
  display: grid;
  grid-template-columns: repeat(2, 44px);
  grid-template-rows: repeat(2, 44px);
  gap: 4px;
  padding: 4px;
  background: var(--bg);
  border-radius: 10px;
}
.corners label { position: relative; }
.corners input { position: absolute; inset: 0; opacity: 0; margin: 0; }
.corners span { position: absolute; inset: 0; border-radius: 8px; cursor: pointer; }
.corners span::after { content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%; background: var(--muted); opacity: .35; }
.corners [data-c="tl"] span::after { top: 6px; left: 6px; }
.corners [data-c="tr"] span::after { top: 6px; right: 6px; }
.corners [data-c="bl"] span::after { bottom: 6px; left: 6px; }
.corners [data-c="br"] span::after { bottom: 6px; right: 6px; }
.corners input:checked + span { background: var(--surface-3); }
.corners input:checked + span::after { background: var(--gold); opacity: 1; }
.corners input:focus-visible + span { outline: 2px solid var(--gold); outline-offset: 2px; }

.form-error { margin: 0; color: var(--danger); font-size: 15px; font-weight: 700; }
.sys-warn { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; line-height: 1.4; }
.sys-warn[hidden] { display: none; }
.sys-warn span { flex: 1 1 320px; }
.cam-error { margin-top: 10px; padding: 12px; border-radius: 10px; background: var(--bg); }
.cam-error p { margin: 0 0 10px; color: var(--danger); font-size: 14px; font-weight: 700; line-height: 1.4; }

/* Revisar */
#player { display: block; width: 100%; aspect-ratio: 16 / 9; background: #000; border-radius: var(--r); }
.review-side { display: flex; flex-direction: column; gap: 12px; padding: 20px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow); }
.meta { margin: 0; color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
.saved { margin: 4px 0 0; color: var(--ok, #2E7D4F); font-size: 14px; font-weight: 700; }
.saved.bad { color: var(--danger); }
.preparing { margin: 10px 0 0; font-weight: 700; color: var(--title); }

/* Grabación que se cortó */
.recover {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px;
  margin: 0 0 20px; padding: 16px 20px;
  background: var(--surface); border: 2px solid var(--gold); border-radius: var(--r); box-shadow: var(--shadow);
}
.recover p { margin: 0; flex: 1 1 280px; font-weight: 700; color: var(--title); }
.recover-actions { display: flex; align-items: center; gap: 16px; }

.videos-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.view-videos > .meta, .view-videos > .form-error { margin: -12px 0 16px; }

/* Mis videos */
.view-videos h2 {
  font-weight: 700;
  font-size: clamp(1.6rem, 1.2rem + 1.4vw, 2.4rem);
  line-height: 1.1;
  color: var(--title);
  margin: 8px 0 24px;
}
.empty { color: var(--muted); margin: 0; }
.grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: clamp(24px, 2.4vw, 36px) clamp(12px, 1.4vw, 24px);
}
.thumb {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  padding: 0;
  border: 0;
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface-3);
  box-shadow: var(--shadow);
  cursor: pointer;
}
.thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.dur {
  position: absolute;
  right: 8px;
  bottom: 8px;
  padding: 2px 8px;
  border-radius: 6px;
  background: rgba(8, 11, 30, .88);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.item h3 { margin: 12px 0 2px; font-size: 17px; font-weight: 700; color: var(--title); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item p { margin: 0; color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
.item .actions { display: flex; gap: 16px; margin-top: 2px; }
.item .actions .link { min-height: 40px; font-size: 15px; }

/* Achicar video */
.view-achicar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 350px;
  gap: clamp(16px, 2vw, 28px);
  align-items: start;
}
.view-achicar h2 {
  font-weight: 700;
  font-size: clamp(1.6rem, 1.2rem + 1.4vw, 2.4rem);
  line-height: 1.1;
  color: var(--title);
  margin: 8px 0 12px;
}
.lead { margin: 0 0 24px; color: var(--muted); max-width: 52ch; text-wrap: pretty; }
.drop {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  padding: clamp(20px, 3vw, 36px);
  border: 2px dashed #c9cce0;
  border-radius: var(--r);
  background: var(--surface);
  transition: border-color 150ms ease;
}
.drop.over { border-color: var(--gold); }
.drop-name { margin: 0; font-weight: 700; font-size: 18px; overflow-wrap: anywhere; }
.presets { display: flex; flex-direction: column; gap: 8px; }
.presets label { position: relative; display: flex; }
.presets input { position: absolute; inset: 0; opacity: 0; margin: 0; }
.presets span {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--bg);
  outline: 2px solid transparent;
  outline-offset: -2px;
  cursor: pointer;
  transition: outline-color 150ms ease;
}
.presets em { font-style: normal; font-size: 14px; color: var(--muted); }
.presets input:checked + span { outline-color: var(--gold); }
.presets input:checked + span { background: #fffaf0; }
.presets b { color: var(--title); }
.presets input:focus-visible + span { outline-color: var(--gold-light); }
.progress { height: 8px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.progress i { display: block; width: 0; height: 100%; background: var(--gold); transition: width 200ms linear; }
.result { display: flex; flex-direction: column; gap: 12px; }
.result p { margin: 0; font-weight: 700; }

.sources {
  position: fixed;
  right: 0;
  bottom: 0;
  width: 2px;
  height: 2px;
  overflow: hidden;
  opacity: .01;
  pointer-events: none;
}
.sources video { width: 2px; height: 2px; }

@media (prefers-reduced-motion: no-preference) {
  .countdown span { display: block; animation: pop 600ms var(--ease-out); }
  @keyframes pop { from { opacity: 0; transform: scale(.9); } to { opacity: 1; transform: none; } }
}

@media (max-width: 1100px) {
  .gate-logo { display: none; }
}
@media (max-width: 960px) {
  .view-grabar, .view-revisar, .view-achicar { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .brand span, .tab-install { display: none; }
  .brand strong { font-size: 19px; overflow: hidden; text-overflow: ellipsis; }
  .tab { padding: 10px 8px; font-size: 15px; }
  .tabs { flex: none; }
  .stage { aspect-ratio: auto; min-height: 360px; }
  .stage canvas { position: absolute; inset: 0; }
  .recbar { flex-wrap: wrap; }
}
