/* SUBLIMERECORDER */
:root {
  --brand: #e5484d;
  --bg: #f6f6f8;
  --surface: #ffffff;
  --surface-2: #f0f0f3;
  --text: #17171c;
  --muted: #6b6b76;
  --border: #e3e3e8;
  --danger: #d93036;
  --ok: #1f9d55;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 16, 24, .06), 0 4px 16px rgba(16, 16, 24, .06);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111114;
    --surface: #1a1a1f;
    --surface-2: #24242b;
    --text: #ededf2;
    --muted: #9a9aa6;
    --border: #2e2e37;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 16px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
img, video { max-width: 100%; }
h1 { font-size: 1.5rem; margin: 0 0 .75rem; line-height: 1.25; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 0 0 .5rem; }
code, kbd { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9em; }
code { background: var(--surface-2); padding: .1em .35em; border-radius: 4px; }
kbd { border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 4px; padding: 0 .3em; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.danger { color: var(--danger) !important; }

/* ---------- Layout ---------- */
.container { width: 100%; max-width: 1200px; margin: 0 auto; padding: 24px 16px 48px; }
.container-wide { max-width: 1440px; }
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 10px 20px; background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; letter-spacing: .02em; }
.brand:hover { text-decoration: none; }
.brand img { height: 30px; width: auto; }
.nav { display: flex; gap: 4px; }
.nav a { color: var(--muted); padding: 6px 12px; border-radius: 8px; font-weight: 500; }
.nav a:hover, .nav a.active { background: var(--surface-2); color: var(--text); text-decoration: none; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.usermenu { position: relative; }
.usermenu summary {
  list-style: none; cursor: pointer; width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 700; font-size: .85rem;
  background: var(--brand); color: #fff;
}
.usermenu summary::-webkit-details-marker { display: none; }
.menu-head { display: flex; flex-direction: column; padding: 8px 12px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.menu-head span { color: var(--muted); font-size: .85rem; }
.powered { text-align: center; color: var(--muted); font-size: .85rem; padding: 16px; }

/* ---------- Botones y formularios ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 8px 16px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 600;
  cursor: pointer; text-decoration: none; white-space: nowrap; transition: filter .15s, background .15s;
}
.btn:hover { text-decoration: none; filter: brightness(.97); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--text); color: var(--surface); border-color: var(--text); }
.btn-record { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 5px 10px; font-size: .85rem; border-radius: 8px; }
.btn-lg { padding: 12px 20px; font-size: 1.05rem; }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.icon-btn {
  border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 1rem;
  width: 30px; height: 30px; border-radius: 8px; display: inline-grid; place-items: center; list-style: none;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn::-webkit-details-marker { display: none; }
.link-btn { border: 0; background: none; padding: 0; cursor: pointer; font: inherit; color: var(--brand); }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: currentColor; display: inline-block; }
.btn-record .rec-dot { background: #fff; }
.rec-dot.pulsing { background: var(--brand); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .3; } }

.form { display: flex; flex-direction: column; gap: 12px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-weight: 500; font-size: .92rem; }
.form label.check, label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; }
.form fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; display: flex; flex-direction: column; gap: 10px; margin: 0; }
.form legend { font-weight: 600; padding: 0 4px; }
.form-row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.form-row label { flex: 1 1 180px; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; width: 100%;
}
input[type="checkbox"] { width: auto; accent-color: var(--brand); }
input[type="color"] { padding: 2px; height: 40px; width: 80px; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--brand) 50%, transparent); outline-offset: 0; border-color: var(--brand); }
textarea { resize: vertical; }
form.inline { display: inline; }
form.inline select { width: auto; }

.alert { padding: 10px 14px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); margin-bottom: 12px; }
.alert-error { background: color-mix(in srgb, var(--danger) 10%, var(--surface)); border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); }
.flash {
  max-width: 1200px; margin: 16px auto 0; padding: 10px 16px; border-radius: 10px;
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap; width: calc(100% - 32px);
  background: color-mix(in srgb, var(--ok) 12%, var(--surface)); border: 1px solid color-mix(in srgb, var(--ok) 35%, var(--border));
}
.flash-error { background: color-mix(in srgb, var(--danger) 10%, var(--surface)); border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); }
.secret { font-size: 1rem; font-weight: 700; user-select: all; }

.card-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); margin-bottom: 20px; }
.card-panel.narrow { max-width: 440px; margin: 40px auto; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.steps { padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.error-code { font-size: 3rem; font-weight: 800; color: var(--brand); margin: 0; }
.lock-icon { font-size: 2.5rem; }
.pill { display: inline-block; font-size: .75rem; padding: 1px 8px; border-radius: 99px; background: var(--surface-2); color: var(--muted); }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { color: var(--muted); font-weight: 600; font-size: .85rem; }
.table td.actions { white-space: nowrap; text-align: right; }
.table tr.is-inactive td { opacity: .55; }
.logo-preview img { max-height: 60px; background: var(--surface-2); padding: 8px; border-radius: 8px; }

/* Menús desplegables */
.menu-wrap { position: relative; }
.menu-wrap > summary { list-style: none; cursor: pointer; }
.menu-wrap > summary::-webkit-details-marker { display: none; }
.menu {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 210px; z-index: 30;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow);
  padding: 4px; display: flex; flex-direction: column;
}
.menu a, .menu button {
  display: block; width: 100%; text-align: left; padding: 8px 12px; border: 0; border-radius: 6px;
  background: none; color: var(--text); font: inherit; cursor: pointer;
}
.menu a:hover, .menu button:hover { background: var(--surface-2); text-decoration: none; }

/* Diálogos */
.dialog { border: 0; border-radius: var(--radius); padding: 24px; width: min(420px, calc(100% - 32px)); background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.dialog::backdrop { background: rgba(10, 10, 15, .45); }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* Avisos */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0;
  background: var(--text); color: var(--surface); padding: 10px 18px; border-radius: 10px;
  pointer-events: none; transition: opacity .2s, transform .2s; z-index: 100; max-width: calc(100% - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast-error { background: var(--danger); color: #fff; }

/* ---------- Biblioteca ---------- */
.library { display: grid; grid-template-columns: 230px 1fr; gap: 28px; }
.sidebar { display: flex; flex-direction: column; gap: 2px; position: sticky; top: 76px; align-self: start; }
.side-link { display: flex; justify-content: space-between; gap: 8px; padding: 7px 12px; border-radius: 8px; color: var(--text); font-weight: 500; }
.side-link:hover, .side-link.active { background: var(--surface); text-decoration: none; box-shadow: var(--shadow); }
.side-link.folder { font-weight: 400; }
.side-link .count { color: var(--muted); font-size: .85rem; }
.side-head { display: flex; justify-content: space-between; align-items: center; margin: 18px 4px 4px 12px; color: var(--muted); font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.side-empty { color: var(--muted); font-size: .85rem; margin: 2px 12px; }
.lib-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.lib-toolbar h1 { margin: 0 auto 0 0; }
.search input { width: 240px; }
.upload-btn { cursor: pointer; }
.upload-progress { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px 16px; margin-bottom: 16px; display: flex; flex-direction: column; gap: 8px; }
.bar { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; min-width: 60px; }
.bar span { display: block; height: 100%; background: var(--brand); width: 0; transition: width .2s; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 20px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: visible; position: relative; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.thumb { position: relative; display: block; aspect-ratio: 16 / 9; background: #0e0e12; border-radius: var(--radius) var(--radius) 0 0; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .25s; }
.card:hover .thumb img { transform: scale(1.03); }
.thumb-ph { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-size: 2rem; opacity: .5; }
.badge-dur { position: absolute; right: 8px; bottom: 8px; background: rgba(0, 0, 0, .75); color: #fff; font-size: .78rem; padding: 1px 6px; border-radius: 6px; font-variant-numeric: tabular-nums; }
.badge-status { position: absolute; left: 8px; top: 8px; background: #f5a524; color: #111; font-size: .75rem; font-weight: 700; padding: 1px 8px; border-radius: 6px; }
.badge-failed { background: var(--danger); color: #fff; }
.card-body { padding: 12px 14px 4px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.card-title { color: var(--text); font-weight: 600; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-meta { color: var(--muted); font-size: .82rem; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.card-actions { display: flex; justify-content: flex-end; gap: 2px; padding: 4px 8px 8px; }
.menu-right { right: 0; }
.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty-icon { font-size: 3rem; margin: 0; }

/* ---------- Grabador ---------- */
.recorder { display: grid; grid-template-columns: 1fr 340px; gap: 24px; align-items: start; }
.rec-stage {
  position: relative; aspect-ratio: 16 / 9; background: #0b0b0f; border-radius: var(--radius);
  overflow: hidden; display: grid; place-items: center; box-shadow: var(--shadow);
}
.rec-stage > video#preview { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.stage-empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; color: #d8d8e0; padding: 24px; }
.stage-empty .muted { color: #9a9aa6; max-width: 420px; }
.stage-icon { font-size: 3rem; margin: 0; color: var(--brand); }
.cam-bubble-wrap { position: absolute; width: 22%; aspect-ratio: 1; border-radius: 50%; overflow: hidden; border: 3px solid var(--brand); box-shadow: 0 6px 24px rgba(0, 0, 0, .4); }
.cam-bubble-wrap[data-size="s"] { width: 16%; }
.cam-bubble-wrap[data-size="l"] { width: 30%; }
.cam-bubble-wrap[data-pos="bl"] { left: 3%; bottom: 4%; }
.cam-bubble-wrap[data-pos="br"] { right: 3%; bottom: 4%; }
.cam-bubble-wrap[data-pos="tl"] { left: 3%; top: 4%; }
.cam-bubble-wrap[data-pos="tr"] { right: 3%; top: 4%; }
.cam-bubble-wrap.square { border-radius: 12%; }
.cam-bubble-wrap.cam-full { inset: 0; width: 100%; height: 100%; aspect-ratio: auto; border-radius: 0; border: 0; box-shadow: none; }
.cam-bubble { width: 100%; height: 100%; object-fit: cover; display: block; }
.mirror { transform: scaleX(-1); }
/* Capa sobre la vista previa: arrastrar la burbuja y dibujar */
.draw-layer { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
#btn-draw[aria-pressed="true"], #btn-cam-toggle[aria-pressed="true"] { background: var(--surface-2); border-color: var(--brand); }
.countdown { position: absolute; inset: 0; display: grid; place-items: center; font-size: 8rem; font-weight: 800; color: #fff; background: rgba(0, 0, 0, .45); }
.rec-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; gap: 16px; box-shadow: var(--shadow); }
.rec-setup { display: flex; flex-direction: column; gap: 12px; }
.rec-setup label { display: flex; flex-direction: column; gap: 4px; font-weight: 500; font-size: .9rem; }
.rec-setup label.check { flex-direction: row; align-items: center; font-weight: 400; }
.rec-setup fieldset { border: 1px solid var(--border); border-radius: 10px; padding: 10px; display: flex; flex-direction: column; gap: 8px; margin: 8px 0 0; }
.rec-setup legend { font-weight: 600; font-size: .85rem; padding: 0 4px; }
.rec-advanced summary { cursor: pointer; font-weight: 600; font-size: .9rem; color: var(--muted); margin-bottom: 8px; }
.rec-advanced[open] { display: flex; flex-direction: column; gap: 10px; }
.meter { height: 4px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-top: -4px; }
.meter span { display: block; height: 100%; width: 0; background: var(--ok); transition: width .08s linear; }
.rec-actions { display: flex; flex-direction: column; gap: 10px; }
.rec-live { display: flex; flex-direction: column; gap: 10px; }
.rec-live-buttons { display: flex; gap: 8px; }
.rec-live-buttons .btn { flex: 1; }
.rec-indicator { display: flex; align-items: center; justify-content: center; gap: 10px; font-size: 1.8rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.recorder[data-phase="paused"] .rec-dot.pulsing { animation: none; opacity: .4; }
.shortcuts { margin: 0; }
.offscreen-video { position: fixed; left: -10000px; top: 0; width: 2px; height: 2px; opacity: 0; pointer-events: none; }

/* Ventana flotante (Document Picture-in-Picture): panel de control con vista previa.
   Chrome no la incluye en la captura de pantalla. */
.pip-body { margin: 0; background: #0b0b0f; overflow: hidden; display: block; min-height: 0; user-select: none; }
.pip { position: fixed; inset: 0; display: flex; flex-direction: column; }
.pip-stage { position: relative; flex: 1; min-height: 0; background: #000; }
.pip-preview { width: 100%; height: 100%; object-fit: contain; display: block; touch-action: none; }
.pip-count { position: absolute; inset: 0; display: grid; place-items: center; font: 800 4rem system-ui, sans-serif; color: #fff; background: rgba(0, 0, 0, .45); pointer-events: none; }
.pip-controls {
  display: flex; align-items: center; gap: 6px; padding: 6px 8px 6px 12px;
  background: #17171c; color: #fff; font: 600 14px system-ui, sans-serif;
}
.pip-rec { display: flex; align-items: center; gap: 6px; margin-right: auto; font-variant-numeric: tabular-nums; }
.pip-controls button { border: 0; background: rgba(255, 255, 255, .12); color: #fff; width: 32px; height: 32px; border-radius: 50%; cursor: pointer; font-size: 13px; }
.pip-controls button:hover { background: rgba(255, 255, 255, .25); }
.pip-controls .pip-stop { background: var(--brand); }
.pip-controls button[hidden] { display: none; }
.pip-notes { flex: 0 0 190px; overflow-y: auto; padding: 10px 14px; color: #f2f2f5; font: 500 15px/1.5 system-ui, sans-serif; white-space: pre-wrap; border-top: 1px solid rgba(255, 255, 255, .12); }
.pip-notes[hidden] { display: none; }
.draw-tools { display: flex; flex-direction: column; gap: 8px; padding: 10px; border: 1px solid var(--border); border-radius: 10px; }
.draw-row { display: flex; gap: 6px; flex-wrap: wrap; }
.draw-row button { width: 34px; height: 34px; border: 1px solid var(--border); background: var(--surface); border-radius: 8px; cursor: pointer; font-size: 15px; }
.draw-row button[aria-pressed="true"] { border-color: var(--brand); box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand) 35%, transparent); }
.draw-row .swatch { border-radius: 50%; width: 26px; height: 26px; }
.rewind { align-items: center; }
.rewind .btn { flex: 0 0 auto; }
.notes-live { max-height: 180px; overflow-y: auto; white-space: pre-wrap; background: var(--surface-2); border-radius: 10px; padding: 10px 12px; font-size: .95rem; line-height: 1.5; }
.rec-setup textarea { width: 100%; resize: vertical; }

/* ---------- Página del video ---------- */
.watch { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 28px; align-items: start; }
.player-wrap { position: relative; background: #000; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.player-wrap video { width: 100%; display: block; max-height: 78vh; background: #000; }
.float-layer { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.float-emoji { position: absolute; bottom: 60px; font-size: 2.2rem; animation: float-up 2.2s ease-out forwards; }
@keyframes float-up { from { transform: translateY(0) scale(.8); opacity: 1; } to { transform: translateY(-240px) scale(1.25); opacity: 0; } }
.timeline { position: relative; height: 26px; margin: 8px 4px 0; border-bottom: 2px solid var(--border); }
.marker { position: absolute; top: 0; transform: translateX(-50%); border: 0; background: none; cursor: pointer; font-size: 14px; padding: 0; line-height: 22px; }
.marker:hover { transform: translateX(-50%) scale(1.35); }
.player-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin: 10px 0 16px; }
.reactions, .speeds { display: flex; gap: 4px; flex-wrap: wrap; }
.emoji-btn { border: 1px solid var(--border); background: var(--surface); border-radius: 99px; width: 40px; height: 36px; font-size: 1.1rem; cursor: pointer; transition: transform .1s; }
.emoji-btn:hover { transform: scale(1.12); }
.speed-btn { border: 1px solid var(--border); background: var(--surface); color: var(--muted); border-radius: 8px; padding: 4px 10px; cursor: pointer; font: inherit; font-size: .85rem; font-weight: 600; }
.speed-btn.active { background: var(--text); color: var(--surface); border-color: var(--text); }
.watch-title { margin-bottom: 4px; }
.watch-meta { color: var(--muted); margin-bottom: 14px; }
.watch-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.watch-desc { white-space: normal; }
.watch-side { min-width: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); position: sticky; top: 76px; max-height: calc(100vh - 96px); display: flex; flex-direction: column; }
.tabs { display: flex; border-bottom: 1px solid var(--border); padding: 0 8px; overflow-x: auto; scrollbar-width: thin; flex-shrink: 0; }
.tab { border: 0; background: none; padding: 12px 9px; white-space: nowrap; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab.active { color: var(--text); border-bottom-color: var(--brand); }
.tab .count { font-size: .78rem; background: var(--surface-2); border-radius: 99px; padding: 0 6px; margin-left: 2px; }
.tab-panel { padding: 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; }
.comments { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.comment p { margin: 4px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.comment-head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.time-link { border: 0; background: color-mix(in srgb, var(--brand) 14%, transparent); color: var(--brand); border-radius: 6px; padding: 0 6px; font: inherit; font-size: .8rem; font-weight: 700; cursor: pointer; font-variant-numeric: tabular-nums; }
.comment-form { gap: 8px; border-top: 1px solid var(--border); padding-top: 14px; }
.comment-form-row { display: flex; justify-content: space-between; align-items: center; }
.panel-block { border-top: 1px solid var(--border); padding-top: 14px; }
.trim-row { display: flex; gap: 8px; align-items: flex-end; margin-bottom: 8px; }
.trim-row label { flex: 1; display: flex; flex-direction: column; gap: 4px; font-size: .9rem; font-weight: 500; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: var(--surface-2); border-radius: 10px; padding: 12px; display: flex; flex-direction: column; }
.stat strong { font-size: 1.4rem; }
.stat span { color: var(--muted); font-size: .82rem; }
.table .bar { margin-bottom: 2px; }
.cta { margin-top: 4px; }

/* ---------- Reproductor: pantalla completa, subtítulos y superposiciones ---------- */
.player-wrap:fullscreen { display: flex; align-items: center; justify-content: center; border-radius: 0; }
.player-wrap:fullscreen video { max-height: none; width: 100%; height: 100%; }
.cc-lang { width: auto; padding: 3px 8px; font-size: .85rem; }
.ov-layer, .cap-layer { position: absolute; left: 0; top: 0; pointer-events: none; overflow: hidden; }
.ov { position: absolute; }
.ov[hidden], .cap-layer[hidden] { display: none; }
.ov-text, .ov-link {
  display: flex; align-items: center; justify-content: center; text-align: center; padding: .2em .5em;
  border-radius: .35em; color: var(--c); background: color-mix(in srgb, var(--ovbg, #000) 82%, transparent);
  font-weight: 700; line-height: 1.15; overflow: hidden; overflow-wrap: anywhere; font-size: calc(var(--lh) * .045);
}
.ov-text[data-size="s"], .ov-link[data-size="s"] { font-size: calc(var(--lh) * .032); }
.ov-text[data-size="l"], .ov-link[data-size="l"] { font-size: calc(var(--lh) * .065); }
.ov-link { pointer-events: auto; background: var(--ovbg, #000); box-shadow: 0 4px 14px rgba(0, 0, 0, .35); cursor: pointer; }
.ov-link:hover { filter: brightness(1.08); text-decoration: none; }
.ov-box { border: max(3px, calc(var(--lh) * .007)) solid var(--c); border-radius: .6em; }
.ov-blur { backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); background: rgba(128, 128, 128, .12); border-radius: 6px; }
.ov-arrow { inset: 0; }
.ov-arrow svg { position: absolute; inset: 0; overflow: visible; }
.ov-layer.editing .ov { pointer-events: auto; outline: 1px dashed rgba(255, 255, 255, .75); cursor: move; }
.ov-layer.editing .ov-arrow, .ov-layer.editing .ov-arrow svg { pointer-events: none; outline: none; }
.ov-layer.editing .ov-arrow line { pointer-events: stroke; cursor: move; }
.ov-layer.editing .ov.selected { outline: 2px solid var(--brand); }
.ov-layer.editing .ov:not(.ov-arrow)::after { content: ''; position: absolute; right: 0; bottom: 0; width: 12px; height: 12px; background: var(--brand); border-radius: 3px 0 3px 0; cursor: nwse-resize; }
.cap-layer { display: flex; justify-content: center; padding: 0 6%; }
.cap-layer[data-pos="bottom"] { align-items: flex-end; padding-bottom: calc(var(--lh) * .11); }
.cap-layer[data-pos="top"] { align-items: flex-start; padding-top: calc(var(--lh) * .05); }
.cap-layer[data-pos="middle"] { align-items: center; }
.cap-line {
  color: var(--cap-color, #fff); font-weight: 700; text-align: center; line-height: 1.35; font-size: calc(var(--lh) * .05);
  padding: .05em .35em; border-radius: .2em; box-decoration-break: clone; -webkit-box-decoration-break: clone;
}
.cap-layer[data-size="s"] .cap-line { font-size: calc(var(--lh) * .038); }
.cap-layer[data-size="l"] .cap-line { font-size: calc(var(--lh) * .064); }
.cap-layer[data-size="xl"] .cap-line { font-size: calc(var(--lh) * .085); }
.cap-layer[data-bg="box"] .cap-line { background: rgba(0, 0, 0, .72); }
.cap-layer[data-bg="shadow"] .cap-line { text-shadow: 0 0 4px #000, 0 2px 3px #000, 0 0 12px rgba(0, 0, 0, .8); }
.cap-layer[data-font="serif"] .cap-line { font-family: Georgia, "Times New Roman", serif; }
.cap-layer[data-font="mono"] .cap-line { font-family: ui-monospace, Consolas, monospace; }
.cap-layer[data-font="impact"] .cap-line { font-family: Impact, "Arial Black", sans-serif; letter-spacing: .02em; font-weight: 400; }
.cap-layer.upper .cap-line { text-transform: uppercase; }
.cap-word.now { color: var(--cap-accent, #ffd60a); }
.marker-chapter { width: 3px; height: 14px; top: 6px; background: var(--muted); border-radius: 2px; }
.cut-band { position: absolute; bottom: -2px; height: 4px; background: var(--danger); opacity: .55; pointer-events: none; }

/* ---------- Resumen, transcripción y preguntas ---------- */
.ai-summary { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 20px; margin: 16px 0; box-shadow: var(--shadow); }
.ai-summary h2 { font-size: 1.05rem; margin: 0 0 6px; }
.ai-summary h3 { font-size: .95rem; margin: 14px 0 6px; }
.ai-summary p { margin: 0; }
.chapter-list, .task-list { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; }
.tr-tools { display: flex; gap: 8px; align-items: center; }
.tr-tools input { flex: 1; }
.tr-edit { display: flex; flex-direction: column; gap: 8px; background: var(--surface-2); border-radius: 10px; padding: 10px; }
.transcript { display: flex; flex-direction: column; gap: 6px; font-size: .92rem; line-height: 1.55; }
.tr-cue { margin: 0; padding: 4px 6px; border-radius: 8px; }
.tr-cue.now { background: color-mix(in srgb, var(--brand) 10%, transparent); }
.tr-word { cursor: pointer; border-radius: 3px; }
.tr-word:hover { background: var(--surface-2); }
.tr-word.cut { text-decoration: line-through; color: var(--muted); opacity: .65; }
.tr-word.sel { background: color-mix(in srgb, var(--brand) 30%, transparent); }
.transcript.editing { user-select: none; }
.ask-log { display: flex; flex-direction: column; gap: 10px; }
.ask-question { align-self: flex-end; background: var(--text); color: var(--surface); padding: 8px 12px; border-radius: 12px 12px 2px 12px; margin: 0; max-width: 90%; white-space: pre-wrap; }
.ask-answer { background: var(--surface-2); padding: 8px 12px; border-radius: 12px 12px 12px 2px; margin: 0; white-space: pre-wrap; }
.ask-error { color: var(--danger); margin: 0; }

/* ---------- Panel de edición ---------- */
.edit-block > summary { cursor: pointer; font-weight: 700; }
.edit-block[open] > summary { margin-bottom: 10px; }
.edit-block > * + * { margin-top: 8px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ai-panel { display: flex; flex-direction: column; gap: 8px; }
.ai-panel p { margin: 0; }
.job { font-size: .85rem; }
.job-done { color: var(--ok); }
.job-failed, .job-error { color: var(--danger); }
.ov-list, .stitch-list { margin: 0; display: flex; flex-direction: column; gap: 8px; }
.ov-list { list-style: none; padding: 0; }
.ov-item { border: 1px solid var(--border); border-radius: 10px; padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.ov-item.selected { border-color: var(--brand); }
.ov-item-head { display: flex; align-items: center; gap: 4px; }
.ov-item-head strong { margin-right: auto; font-size: .9rem; }
.ov-item-head input { width: 68px; padding: 4px 6px; font-size: .85rem; }
.ov-colors { display: flex; gap: 6px; align-items: center; }
.ov-colors input[type="color"] { width: 40px; height: 32px; padding: 2px; }
.ov-colors select { width: auto; }
.gif-box { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; margin-top: 10px; }
.gif-box img { max-width: 100%; border-radius: 8px; }
.stitch-list { padding-left: 22px; gap: 4px; }
.stitch-item { display: flex; justify-content: space-between; align-items: center; gap: 6px; font-size: .9rem; }
.stitch-tools { display: flex; gap: 2px; }

/* ---------- Espacios de trabajo ---------- */
.ws-banner { display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; padding: 8px 16px; background: color-mix(in srgb, var(--brand) 14%, var(--surface)); border-bottom: 1px solid var(--border); font-size: .9rem; }
.ws-banner form { margin: 0; }
.ws-rename { display: inline-flex; gap: 6px; align-items: center; }
.ws-rename input { width: 200px; }

/* ---------- Bloque, fondo del video ---------- */
.ov-block { background: var(--c); border-radius: 3px; }
.player-wrap.has-bg { background: var(--wrap-bg); padding: 4%; }
.player-wrap.has-bg video { border-radius: 10px; box-shadow: 0 10px 30px rgba(0, 0, 0, .35); background: #000; }
.studio-callout { display: flex; flex-direction: column; gap: 6px; }

/* ---------- Editor completo ---------- */
.studio-main { padding: 0; }
.studio { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; height: calc(100vh - 61px); min-height: 560px; }
.studio-head { display: flex; align-items: center; gap: 10px; padding: 8px 16px; border-bottom: 1px solid var(--border); background: var(--surface); }
.studio-title { flex: 1; font-size: 1.1rem; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.studio-save { color: var(--muted); font-size: .85rem; }
.studio-save.error { color: var(--danger); }
.studio-head .icon-btn { font-size: 1.15rem; }
.studio-head .icon-btn:disabled { opacity: .35; cursor: default; }
.studio-body { display: grid; grid-template-columns: minmax(0, 1fr) 340px 84px; min-height: 0; }
.studio-stage { display: flex; flex-direction: column; min-height: 0; background: #0f0f14; padding: 12px; gap: 8px; }
.studio-video { flex: 1; min-height: 0; display: flex; }
.studio .player-wrap { flex: 1; min-height: 0; border-radius: 10px; box-shadow: none; }
.studio .player-wrap video { width: 100%; height: 100%; max-height: none; object-fit: contain; cursor: pointer; }
.studio-transport { display: flex; align-items: center; gap: 6px; color: #e8e8ee; }
.studio-transport .icon-btn { color: #e8e8ee; font-size: 1.1rem; }
.studio-transport .icon-btn:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.studio-transport .speed-btn, .studio-transport select { background: rgba(255, 255, 255, .08); color: #e8e8ee; border-color: rgba(255, 255, 255, .2); }
.tp-time { font-variant-numeric: tabular-nums; font-size: .9rem; }
.spacer { flex: 1; }
.studio-redact { margin: 0; padding: 8px 12px; border-radius: 8px; font-size: .85rem; background: rgba(255, 255, 255, .08); color: #e8e8ee; }
.studio-redact[data-state="visual"] { background: color-mix(in srgb, var(--danger) 35%, #0f0f14); }
.studio-panel { border-left: 1px solid var(--border); background: var(--surface); overflow-y: auto; min-height: 0; }
.studio-pane { padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.studio-pane h2 { font-size: 1rem; margin: 0; }
.studio-rail { display: flex; flex-direction: column; gap: 2px; padding: 8px 4px; border-left: 1px solid var(--border); background: var(--surface); }
.studio-rail > button, .rail-menu > button {
  display: flex; flex-direction: column; align-items: center; gap: 2px; width: 100%; padding: 8px 2px; border: 0; border-radius: 10px;
  background: none; color: var(--text); font: inherit; font-size: .72rem; line-height: 1.15; cursor: pointer; text-align: center;
}
.studio-rail > button:hover, .rail-menu > button:hover, .studio-rail > button[aria-pressed="true"] { background: var(--surface-2); }
.rail-icon { font-size: 1.25rem; }
.rail-spacer { flex: 1; }
.rail-menu { position: relative; }
.rail-pop { position: absolute; right: calc(100% + 6px); top: 0; z-index: 20; min-width: 200px; }
.studio-timeline { border-top: 1px solid var(--border); background: var(--surface); padding: 6px 12px 4px; }
.tl-toolbar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tl-toolbar .btn:disabled { opacity: .45; cursor: default; }
.tl-toolbar input[type="range"] { width: 140px; }
.tl-scroll { overflow-x: auto; overflow-y: hidden; padding: 4px 12px 6px; }
.tl-inner { position: relative; user-select: none; touch-action: none; }
.tl-ruler { position: relative; height: 20px; cursor: pointer; border-bottom: 1px solid var(--border); }
.tl-tick { position: absolute; top: 2px; font-size: .7rem; color: var(--muted); padding-left: 3px; border-left: 1px solid var(--border); height: 16px; white-space: nowrap; }
.tl-ovtrack { position: relative; min-height: 28px; margin-top: 4px; }
.tl-ov { position: absolute; height: 20px; border-radius: 6px; background: color-mix(in srgb, var(--brand) 22%, var(--surface)); border: 1px solid color-mix(in srgb, var(--brand) 60%, var(--border)); overflow: hidden; cursor: grab; }
.tl-ov-blur, .tl-ov-block { background: color-mix(in srgb, #6b7280 30%, var(--surface)); border-color: #6b7280; }
.tl-ov.selected { outline: 2px solid var(--brand); z-index: 2; }
.tl-ov-label { display: block; font-size: .72rem; line-height: 18px; padding: 0 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none; }
.tl-ov-edge { position: absolute; top: 0; bottom: 0; width: 7px; cursor: ew-resize; background: color-mix(in srgb, var(--brand) 55%, transparent); }
.tl-ov-edge-start { left: 0; }
.tl-ov-edge-end { right: 0; }
.tl-clip { position: relative; height: 64px; margin-top: 4px; border: 2px solid var(--brand); border-radius: 10px; background: color-mix(in srgb, var(--brand) 6%, var(--surface)); cursor: text; }
.tl-clip canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; opacity: .55; }
.tl-part { position: absolute; top: 0; bottom: 0; }
.tl-trimmed { background: rgba(10, 10, 15, .55); }
.tl-cut { background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--danger) 55%, transparent) 0 6px, color-mix(in srgb, var(--danger) 20%, transparent) 6px 12px); cursor: pointer; }
.tl-cut.selected { outline: 2px solid var(--danger); z-index: 1; }
.tl-split { width: 2px; background: var(--text); margin-left: -1px; pointer-events: none; }
.tl-selection { background: color-mix(in srgb, var(--brand) 28%, transparent); border-left: 2px solid var(--brand); border-right: 2px solid var(--brand); pointer-events: none; }
.tl-handle { width: 12px !important; margin-left: -6px; background: var(--brand); border-radius: 6px; cursor: ew-resize; z-index: 3; }
.tl-playhead { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: #ff3b30; pointer-events: none; z-index: 4; }
.tl-playhead span { position: absolute; top: 0; left: -6px; width: 14px; height: 14px; background: #ff3b30; border-radius: 3px; pointer-events: auto; cursor: grab; }
.tl-hint { margin: 2px 0 0; }
.el-props { display: flex; flex-direction: column; gap: 10px; }
.el-props h3 { margin: 0; font-size: .95rem; }
.el-props label { display: flex; flex-direction: column; gap: 4px; font-size: .88rem; font-weight: 500; }
.el-props .el-time { flex-direction: row; align-items: center; gap: 8px; }
.el-time input { width: 96px; }
.el-colors { display: flex; gap: 12px; }
.el-colors input[type="color"] { width: 48px; height: 34px; padding: 2px; }
.el-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.el-item { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 8px; cursor: pointer; border: 1px solid transparent; }
.el-item:hover { background: var(--surface-2); }
.el-item.selected { border-color: var(--brand); }
.el-icon { width: 22px; text-align: center; }
.el-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bg-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.bg-tile { height: 64px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font: inherit; font-size: .85rem; font-weight: 600; cursor: pointer; display: grid; place-items: center; }
.bg-tile.selected { outline: 3px solid var(--brand); outline-offset: 1px; }
.bg-colors { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.bg-tile.bg-color { width: 28px; height: 28px; border-radius: 50%; }
.bg-colors input[type="color"] { width: 34px; height: 30px; padding: 2px; }
.transcript.editing .tr-word { cursor: text; }
@media (max-width: 1100px) {
  .studio-body { grid-template-columns: minmax(0, 1fr) 280px 72px; }
}
@media (max-width: 800px) {
  .studio { height: auto; }
  .studio-body { grid-template-columns: 1fr; }
  .studio-video { min-height: 220px; }
  .studio-rail { flex-direction: row; overflow-x: auto; border-left: 0; border-top: 1px solid var(--border); }
  .studio-rail > button, .rail-menu > button { width: 76px; }
  .rail-pop { right: auto; left: 0; top: 100%; }
}

/* ---------- Video insertado ---------- */
body.embed .player-wrap { position: fixed; inset: 0; border-radius: 0; box-shadow: none; }
body.embed .player-wrap video { max-height: none; }
body.embed .player-wrap.has-bg video { width: 100%; height: 100%; object-fit: contain; }
.embed-tools { position: fixed; right: 12px; bottom: 64px; display: flex; gap: 6px; }
.embed-tools .speed-btn, .embed-tools select { background: rgba(0, 0, 0, .6); color: #fff; border-color: rgba(255, 255, 255, .3); }
body.embed { background: #000; display: block; min-height: 0; overflow: hidden; }
body.embed video { width: 100vw; height: 100vh; object-fit: contain; display: block; }
.embed-cta { position: fixed; right: 12px; top: 12px; background: var(--brand); color: #fff; padding: 8px 14px; border-radius: 10px; font-weight: 700; }
.embed-brand { position: fixed; left: 12px; top: 12px; color: #fff; background: rgba(0, 0, 0, .55); padding: 4px 10px; border-radius: 8px; font-size: .8rem; }
.embed-msg { color: #fff; display: grid; place-items: center; height: 100vh; text-align: center; padding: 16px; }
.embed-msg a { color: #fff; text-decoration: underline; }

/* ---------- Responsive ---------- */
@media (max-width: 1000px) {
  .watch, .recorder { grid-template-columns: 1fr; }
  .watch-side { position: static; max-height: none; }
}
@media (max-width: 760px) {
  .library { grid-template-columns: 1fr; }
  .sidebar { position: static; flex-direction: row; flex-wrap: wrap; gap: 4px; }
  .side-head, .side-empty { display: none; }
  .nav { display: none; }
  .topbar { padding: 10px 14px; }
  .brand span { display: none; }
  .search input { width: 100%; }
  .search { flex: 1 1 100%; order: 3; }
  .table { font-size: .85rem; }
  .countdown { font-size: 5rem; }
}
