:root {
  --bg: #141210;
  --bg2: #1c1915;
  --bg3: #262019;
  --gold: #c4a882;
  --gold2: #d4b896;
  --cream: #f5f0eb;
  --muted: #8a8074;
  --danger: #d06a5a;
  --ok: #7fb069;
  --border: #33291f;
  --radius: 10px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--cream);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex; flex-direction: column;
}
header {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  background: var(--bg2); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 7px; color: var(--gold); font-size: 15px; }
.muted { color: var(--muted); font-size: 12px; }
.mono { font-variant-numeric: tabular-nums; font-size: 12px; color: var(--muted); min-width: 34px; text-align: center; }
.spacer { flex: 1; }
select, input, textarea, button {
  font: inherit; color: var(--cream); background: var(--bg3);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 7px 10px;
}
button { cursor: pointer; transition: filter .15s; }
button:hover { filter: brightness(1.15); }
button:disabled { opacity: .4; cursor: default; }
button.gold { background: var(--gold); color: #141210; font-weight: 700; border-color: transparent; }
.filebtn { display: inline-flex; align-items: center; cursor: pointer; background: var(--bg3); border: 1px dashed var(--gold); border-radius: var(--radius); padding: 7px 12px; color: var(--gold); }

main { flex: 1; display: flex; flex-direction: column; gap: 12px; padding: 12px; max-width: 1100px; width: 100%; margin: 0 auto; }

/* player */
#frameBox {
  position: relative; background: #000; border-radius: 14px; overflow: hidden;
  border: 1px solid var(--border); display: flex; align-items: center; justify-content: center;
  max-height: 62vh;
}
#frame { max-width: 100%; max-height: 62vh; display: block; }
#frameHint { position: absolute; color: var(--muted); }
#transport { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
#btnPlay { width: 42px; height: 42px; border-radius: 50%; background: var(--gold); color: #141210; font-size: 16px; border: 0; }
#scrub { flex: 1; accent-color: var(--gold); height: 34px; }

/* timeline */
#timelineWrap { display: flex; flex-direction: column; gap: 8px; }
#tl {
  position: relative; background: var(--bg2); border: 1px solid var(--border);
  border-radius: 12px; min-height: 96px; overflow-x: auto; overflow-y: hidden;
  touch-action: pan-x;
}
#tlRuler { height: 20px; position: relative; border-bottom: 1px solid var(--border); color: var(--muted); font-size: 10px; }
.tick { position: absolute; top: 4px; border-left: 1px solid var(--border); padding-left: 3px; }
#tlLanes { position: relative; height: 76px; }
.clip {
  position: absolute; top: 8px; height: 60px; background: linear-gradient(180deg, #3a3327, #2c2620);
  border: 1px solid var(--gold); border-radius: 8px; overflow: hidden; cursor: grab;
  display: flex; align-items: center; padding: 0 8px; font-size: 11px; color: var(--gold2);
  user-select: none; touch-action: none; white-space: nowrap;
}
.clip.sel { background: linear-gradient(180deg, #574a33, #3a3022); box-shadow: 0 0 0 2px var(--gold); }
.clip[style*="background-image"] {
  background-size: cover; background-position: center;
}
.clip[style*="background-image"] > span {
  background: rgba(20, 18, 16, .55); border-radius: 5px; padding: 1px 5px;
}
.clip .h { position: absolute; top: 0; bottom: 0; width: 12px; cursor: ew-resize; background: var(--gold); opacity: 0; }
.clip .h.l { left: 0; border-radius: 8px 0 0 8px; } .clip .h.r { right: 0; border-radius: 0 8px 8px 0; }
.clip:hover .h { opacity: .55; }
#playhead { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--cream); pointer-events: none; }
#tlTools { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.zoomctl { display: inline-flex; gap: 4px; }
.zoomctl button { padding: 6px 10px; }
label.block { display: block; }
dialog textarea { color: var(--cream); background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px; font: 13px/1.5 inherit; resize: vertical; }
dialog select { color: var(--cream); background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px; }
dialog input[type=color] { height: 34px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); }

/* clip list (mobile + fallback) */
#clipPanel h3, #reviewBox h3, #exportsBox h3 { margin: 4px 0 8px; color: var(--gold); font-size: 13px; text-transform: uppercase; letter-spacing: .08em; }
.clipCard {
  display: flex; align-items: center; gap: 8px; background: var(--bg2);
  border: 1px solid var(--border); border-radius: 12px; padding: 10px; margin-bottom: 8px; flex-wrap: wrap;
}
.clipCard .nm { font-weight: 600; min-width: 90px; }
.clipCard .st { font-size: 11px; color: var(--muted); }
.clipCard .ops { display: flex; gap: 4px; flex-wrap: wrap; margin-left: auto; }
.clipCard .ops button { padding: 5px 8px; font-size: 12px; }
.clipCard .ops .d { color: var(--danger); }

/* review */
#reviewBox { background: var(--bg2); border: 1px solid var(--border); border-radius: 12px; padding: 12px; }
#reviewBox textarea { width: 100%; min-height: 64px; margin-bottom: 8px; resize: vertical; }
#reviewBox div:last-of-type { display: flex; gap: 8px; }

#exportsList a { color: var(--gold2); display: inline-block; margin-right: 14px; }

dialog { background: var(--bg2); color: var(--cream); border: 1px solid var(--border); border-radius: 14px; padding: 16px; min-width: 280px; }
dialog::backdrop { background: rgba(0,0,0,.6); }
dialog label { display: flex; flex-direction: column; gap: 4px; margin: 8px 0; font-size: 12px; color: var(--muted); }
dialog input { color: var(--cream); }
dialog menu { display: flex; gap: 8px; justify-content: flex-end; padding: 0; margin: 12px 0 0; }
dialog .row { display: flex; gap: 10px; }

#toast {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
  background: var(--bg3); color: var(--cream); border: 1px solid var(--gold);
  padding: 10px 18px; border-radius: 99px; opacity: 0; pointer-events: none; transition: opacity .25s; z-index: 99;
}
#toast.show { opacity: 1; }

/* responsive */
@media (max-width: 760px) {
  main { padding: 8px; gap: 10px; }
  #frameBox { max-height: 48vh; } #frame { max-height: 48vh; }
  header { padding: 6px 8px; }
  #btnExport { flex: 1; }
  /* timeline horizontal se sustituye por lista de clips */
  #timelineWrap { display: none; }
}
@media (min-width: 761px) {
  #clipPanel { display: none; }
}
