:root {
  --bg: #f6f6f8;
  --fg: #111114;
  --muted: #6b6b76;
  --accent: #5b4cf5;
  --accent-soft: #ecebff;
  --card: #ffffff;
  --border: #e7e7ec;
  --danger: #e5484d;
  --rec: #ff3b4e;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--fg);
  font: 14px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }

.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  padding: 12px 24px; background: rgba(246,246,248,.85); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border);
}
.logo { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; color: var(--fg); text-decoration: none; }
.logo svg { width: 26px; height: 26px; fill: var(--accent); }
.topbar nav { display: flex; gap: 8px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--border);
  background: var(--card); color: var(--fg); font: inherit; font-weight: 600; padding: 8px 14px; border-radius: 10px;
  cursor: pointer; text-decoration: none; transition: background .15s, border-color .15s, transform .1s; white-space: nowrap;
}
.btn:hover { border-color: #cfcfd8; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #4b3ce6; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: #ececf1; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.block { display: flex; width: 100%; }
.btn.small { font-size: 13px; padding: 6px 10px; }
.btn.big { padding: 12px 22px; font-size: 15px; }
.btn.whatsapp { background: #25d366; border-color: #25d366; color: #fff; }
.btn.record { background: var(--rec); border-color: var(--rec); color: #fff; padding: 12px 26px; font-size: 15px; border-radius: 999px; }
.btn.record .dot { width: 10px; height: 10px; border-radius: 50%; background: #fff; }

.wrap { max-width: 1200px; margin: 0 auto; padding: 24px; }
.wrap.narrow { max-width: 1000px; }
h1 { font-size: 26px; letter-spacing: -0.02em; margin: 8px 0 20px; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 13px; }
.empty { color: var(--muted); padding: 40px 0; }

/* Biblioteca */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 20px; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; display: flex; flex-direction: column; }
.card .thumb { position: relative; aspect-ratio: 16/9; background: #ddd center/cover no-repeat; display: block; }
.card .dur { position: absolute; right: 8px; bottom: 8px; background: rgba(0,0,0,.7); color: #fff; font-size: 12px; padding: 1px 6px; border-radius: 6px; }
.card .new { position: absolute; left: 8px; top: 8px; background: var(--accent); color: #fff; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.card .body { padding: 12px 14px 6px; flex: 1; }
.card .title { font-weight: 600; margin: 0 0 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .sub { color: var(--muted); font-size: 12.5px; }
.card .views-link { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; font-size: 12.5px; cursor: pointer; }
.card .actions { display: flex; gap: 4px; padding: 8px 10px 10px; flex-wrap: wrap; }
.card .actions .btn { padding: 5px 9px; font-size: 12.5px; }

/* Estudio */
.studio { display: grid; grid-template-columns: 1fr 320px; gap: 20px; padding: 20px 24px; max-width: 1600px; margin: 0 auto; }
.stage { min-width: 0; }
.canvas-wrap { position: relative; border-radius: 16px; overflow: hidden; box-shadow: 0 12px 40px rgba(20,16,60,.15); background: #000; }
#stage { display: block; width: 100%; height: auto; aspect-ratio: 16/9; }
.countdown { position: absolute; inset: 0; display: grid; place-items: center; font-size: 160px; font-weight: 800; color: #fff; background: rgba(0,0,0,.35); text-shadow: 0 6px 30px rgba(0,0,0,.4); }
.rec-badge { position: absolute; top: 14px; left: 14px; display: flex; align-items: center; gap: 8px; background: rgba(0,0,0,.65); color: #fff; padding: 5px 12px; border-radius: 999px; font-weight: 600; font-variant-numeric: tabular-nums; }
.rec-badge .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--rec); animation: blink 1s infinite; }
.rec-badge.paused .dot { animation: none; background: #ffb224; }
@keyframes blink { 50% { opacity: .3; } }
.rec-bar { display: flex; align-items: center; gap: 10px; margin-top: 16px; flex-wrap: wrap; }

.panel { background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 6px 18px 18px; align-self: start; position: sticky; top: 76px; max-height: calc(100vh - 96px); overflow: auto; }
.panel h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 18px 0 10px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-weight: 600; margin-bottom: 5px; font-size: 13px; }
.field.row label { margin-bottom: 3px; }
select, input[type=password], .title-input, .share-link input {
  width: 100%; font: inherit; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; background: #fff; color: var(--fg);
}
input[type=range] { width: 100%; accent-color: var(--accent); }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; margin: 6px 0; cursor: pointer; }
.check input { accent-color: var(--accent); }
.meter { height: 4px; background: #eee; border-radius: 2px; margin-top: 6px; overflow: hidden; }
.meter div { height: 100%; width: 0; background: linear-gradient(90deg, #30a46c, #f5d90a 70%, #e5484d); transition: width .08s; }

.layouts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.layouts button { position: relative; aspect-ratio: 16/10; border: 2px solid var(--border); border-radius: 10px; background: #f1f1f5; cursor: pointer; padding: 0; }
.layouts button.on { border-color: var(--accent); background: var(--accent-soft); }
.layouts i { position: absolute; background: #b9b6d6; border-radius: 3px; }
.layouts button.on i { background: var(--accent); }
.l-screen { left: 18%; top: 16%; right: 12%; bottom: 16%; }
.l-cam-small { left: 8%; bottom: 10%; width: 26%; height: 34%; border-radius: 5px !important; box-shadow: 0 0 0 2px #f1f1f5; }
.l-split-a { left: 8%; top: 18%; width: 54%; bottom: 18%; }
.l-split-b { right: 8%; top: 18%; width: 26%; bottom: 18%; }
.l-cam-big { left: 18%; top: 16%; right: 18%; bottom: 16%; }
.l-screen-full { left: 10%; top: 14%; right: 10%; bottom: 14%; }

.bgs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 8px; }
.bgs button { aspect-ratio: 16/10; border-radius: 8px; border: 2px solid transparent; padding: 0; cursor: pointer; background: #ddd center/cover; outline: 1px solid var(--border); }
.bgs button.on { border-color: var(--accent); outline-color: var(--accent); }
.seg { display: flex; background: #f1f1f5; border-radius: 10px; padding: 3px; }
.seg button { flex: 1; border: 0; background: none; font: inherit; font-size: 13px; padding: 5px; border-radius: 8px; cursor: pointer; color: var(--muted); }
.seg button.on { background: #fff; color: var(--fg); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.08); }

/* Editor */
.title-input { font-size: 22px; font-weight: 700; border-color: transparent; background: transparent; padding: 6px 8px; margin-bottom: 12px; letter-spacing: -0.01em; }
.title-input:hover, .title-input:focus { border-color: var(--border); background: #fff; outline: none; }
.edit-player { position: relative; border-radius: 16px; overflow: hidden; background: #000; aspect-ratio: 16/9; box-shadow: 0 12px 40px rgba(20,16,60,.15); }
.edit-player video { width: 100%; height: 100%; display: block; }
.busy { position: absolute; inset: 0; display: flex; flex-direction: column; gap: 14px; align-items: center; justify-content: center; background: rgba(15,15,18,.8); color: #fff; font-weight: 600; }
.spinner { width: 36px; height: 36px; border: 3px solid rgba(255,255,255,.25); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.timeline-tools { display: flex; align-items: center; gap: 14px; margin: 16px 0 10px; flex-wrap: wrap; }
.time { font-variant-numeric: tabular-nums; color: var(--muted); }
.saving { color: var(--accent); font-weight: 600; font-size: 13px; }
#timeline { width: 100%; height: 96px; display: block; border-radius: 12px; background: var(--card); border: 1px solid var(--border); cursor: pointer; touch-action: none; }
.edit-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
.upload-progress { position: relative; height: 34px; margin-top: 14px; background: var(--accent-soft); border-radius: 10px; overflow: hidden; }
.upload-progress div { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--accent); transition: width .2s; }
.upload-progress span { position: relative; display: block; text-align: center; line-height: 34px; font-weight: 600; color: #fff; mix-blend-mode: difference; }

dialog { border: 0; border-radius: 18px; padding: 24px; width: min(480px, calc(100vw - 32px)); box-shadow: 0 30px 80px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(15,15,25,.45); backdrop-filter: blur(3px); }
dialog h2 { margin: 0 0 6px; font-size: 20px; }
.share-link { display: flex; gap: 8px; margin: 14px 0; }
.share-buttons { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.share-buttons .btn { flex: 1; }
.error { color: var(--danger); }
#token-input { margin: 10px 0; }
.view-row { display: flex; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.view-row .pct { font-weight: 700; color: var(--accent); }

@media (max-width: 900px) {
  .studio { grid-template-columns: 1fr; padding: 16px; }
  .panel { position: static; max-height: none; }
  .wrap { padding: 16px; }
  .topbar { padding: 10px 16px; }
}
