:root {
  --bg: #0e0f13;
  --panel: #171920;
  --panel2: #1f222b;
  --line: #2a2e3a;
  --text: #eceef3;
  --muted: #8b91a1;
  --accent: #4f8cff;
  --rec: #ff3b4e;
  --ok: #2ecc71;
  --warn: #f5a623;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
[hidden] { display: none !important; }

.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px; border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--rec); }
.hint { color: var(--muted); font-size: 12px; }

.app { display: grid; grid-template-columns: 360px 1fr; height: calc(100% - 49px); }
.controls { overflow-y: auto; padding: 16px; border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 12px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.card h2 { margin: 0; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.card h2 .n { width: 22px; height: 22px; border-radius: 50%; background: var(--panel2); border: 1px solid var(--line); display: inline-grid; place-items: center; font-size: 12px; color: var(--muted); }

.small { font-size: 12px; }
.muted { color: var(--muted); }
p { margin: 0; }

.btn {
  appearance: none; border: 0; border-radius: 8px; padding: 10px 14px; cursor: pointer;
  background: var(--accent); color: #fff; font-weight: 600; font-size: 14px;
}
.btn:hover:not(:disabled) { filter: brightness(1.1); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.ghost { background: var(--panel2); border: 1px solid var(--line); color: var(--text); font-weight: 500; }
.btn.sm { padding: 6px 10px; font-size: 13px; }
.btn.rec { background: var(--rec); font-size: 16px; padding: 14px 26px; border-radius: 40px; }
.btn.rec.stop { background: #fff; color: var(--rec); }
.row { display: flex; gap: 8px; flex-wrap: wrap; }

.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.field b { color: var(--text); font-weight: 600; }
select, textarea, input[type=range] { width: 100%; }
select, textarea {
  background: var(--panel2); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px; font: inherit;
}
textarea { resize: vertical; }
input[type=range] { accent-color: var(--accent); }
.check { display: flex; gap: 8px; align-items: center; font-size: 13px; }

.seg { display: flex; background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 3px; }
.seg button { flex: 1; border: 0; background: none; color: var(--muted); padding: 7px; border-radius: 6px; cursor: pointer; font: inherit; font-size: 13px; }
.seg button.on { background: var(--accent); color: #fff; }

.qr-box { display: flex; gap: 12px; align-items: center; }
#qr { background: #fff; padding: 8px; border-radius: 8px; flex: none; }
#qr img, #qr canvas { display: block; width: 132px; height: 132px; }
.qr-box.connected #qr { display: none; }

.status-line { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.sdot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; }
.sdot.ok { background: var(--ok); }
.sdot.wait { background: var(--warn); }
.sdot.err { background: var(--rec); }

/* palco */
.stage { overflow: auto; padding: 20px; }
.stage-inner { display: flex; gap: 24px; align-items: flex-start; justify-content: center; }
.preview-wrap { position: relative; height: calc(100vh - 100px); max-height: 900px; aspect-ratio: 9 / 16; flex: none; }
#preview { width: 100%; height: 100%; border-radius: 14px; background: #000; display: block; box-shadow: 0 10px 40px rgba(0,0,0,.5); }
.safe-hint {
  position: absolute; left: 0; right: 0; bottom: 0; height: 17%;
  border-radius: 0 0 14px 14px; border-top: 1px dashed rgba(255,255,255,.35);
  background: repeating-linear-gradient(45deg, rgba(255,255,255,.04) 0 8px, transparent 8px 16px);
  color: rgba(255,255,255,.5); font-size: 11px; display: flex; align-items: flex-end; justify-content: center; padding-bottom: 6px;
  pointer-events: none;
}
.countdown {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 140px; font-weight: 800; color: #fff; background: rgba(0,0,0,.45); border-radius: 14px;
}
.rec-badge {
  position: absolute; top: 12px; left: 12px; background: rgba(0,0,0,.6); padding: 6px 10px; border-radius: 20px;
  font-weight: 700; font-size: 13px; display: flex; gap: 6px; align-items: center;
}
.rec-badge span { width: 10px; height: 10px; border-radius: 50%; background: var(--rec); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .2; } }

.side { width: 380px; display: flex; flex-direction: column; gap: 14px; }
.prompter {
  height: 260px; overflow: hidden; background: #000; border-radius: 12px; border: 1px solid var(--line);
  position: relative; padding: 0 18px;
  mask-image: linear-gradient(transparent, #000 18%, #000 82%, transparent);
}
.prompter-text { font-size: 26px; line-height: 1.4; font-weight: 600; white-space: pre-wrap; padding-top: 110px; will-change: transform; }
.recbar { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }

.bar { height: 6px; background: var(--panel2); border-radius: 4px; overflow: hidden; }
.bar > div { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.downloads { display: flex; flex-direction: column; gap: 6px; }
.downloads a {
  display: block; padding: 10px 12px; border-radius: 8px; background: var(--panel2); border: 1px solid var(--line);
  color: var(--text); text-decoration: none; font-size: 13px;
}
.downloads a.main { background: var(--ok); color: #062; border-color: transparent; font-weight: 700; }

/* recorte */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.8); display: grid; place-items: center; z-index: 10; }
.modal-card { background: var(--panel); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 12px; max-width: 95vw; }
.modal-head { display: flex; align-items: center; gap: 10px; }
.modal-head b { flex: 1; }
.crop-area { position: relative; cursor: crosshair; user-select: none; touch-action: none; }
.crop-area video { display: block; }
.crop-rect { position: absolute; border: 2px solid var(--accent); box-shadow: 0 0 0 9999px rgba(0,0,0,.55); pointer-events: none; }

.hidden-media { position: fixed; left: 0; top: 0; width: 4px; height: 4px; overflow: hidden; opacity: 0.01; pointer-events: none; }
.hidden-media video { width: 4px; height: 4px; }

@media (max-width: 1100px) {
  .app { grid-template-columns: 1fr; height: auto; }
  .stage-inner { flex-direction: column; align-items: center; }
  .preview-wrap { height: 70vh; }
}
