/* Video Event Sync Studio */
:root {
  --bg: #0a0b0d;
  --panel: #111317;
  --panel-2: #15181d;
  --raise: #1b1f25;
  --raise-2: #232830;
  --line: #20242b;
  --line-2: #2e343d;
  --text: #e8eaef;
  --muted: #8d94a2;
  --dim: #5c6370;
  --accent: #7b6cff;
  --accent-hi: #988cff;
  --accent-soft: rgba(123, 108, 255, .14);
  --ok: #3fd39c;
  --warn: #f0b54a;
  --danger: #ff5f6e;
  --sans: "Geist", "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --r: 6px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 13px/1.4 var(--sans);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
h2, h3 { margin: 0; font-weight: 600; }
h2 { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
h3 { font-size: 14px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent-hi); outline-offset: 1px; }

.ic { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ic.xl { width: 34px; height: 34px; stroke-width: 1.3; color: var(--dim); }

/* ---------- layout */
.app {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  grid-template-rows: 52px minmax(0, 1fr) 196px;
  gap: 1px; height: 100vh; height: 100dvh;
  background: var(--line);
}
.panel { background: var(--panel); min-width: 0; min-height: 0; }
.topbar { grid-column: 1 / -1; }

/* ---------- botões */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 30px; padding: 0 11px; border-radius: var(--r);
  background: var(--raise); border: 1px solid var(--line-2); color: var(--text);
  font-weight: 500; white-space: nowrap;
  transition: background .12s, border-color .12s, transform .06s;
}
.btn:hover { background: var(--raise-2); border-color: #3a414c; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .4; cursor: default; pointer-events: none; }
.btn.icon { width: 30px; padding: 0; }
.btn.sm { height: 26px; padding: 0 9px; font-size: 12px; }
.btn.icon.sm { width: 26px; padding: 0; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hi); border-color: var(--accent-hi); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #16080a; font-weight: 600; }
.btn.toggle[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-hi); }
.sep { width: 1px; height: 18px; background: var(--line-2); margin: 0 4px; }

input[type="text"], input[type="number"], textarea, .select {
  background: var(--bg); border: 1px solid var(--line-2); border-radius: var(--r);
  color: var(--text); height: 30px; padding: 0 9px; min-width: 0;
  transition: border-color .12s;
}
input[type="text"]:focus, input[type="number"]:focus, textarea:focus, .select:focus { outline: none; border-color: var(--accent); }
input::placeholder, textarea::placeholder { color: var(--dim); }
textarea { height: auto; padding: 9px; width: 100%; resize: vertical; line-height: 1.55; font-size: 12px; }
.select { padding: 0 6px; cursor: pointer; }
kbd {
  font: 500 11px var(--mono); padding: 2px 6px; border-radius: 4px;
  background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .12);
}

/* ---------- topo */
.topbar { display: flex; align-items: center; gap: 12px; padding: 0 12px; background: var(--panel); }
.brand { display: flex; align-items: center; gap: 9px; flex: none; }
.brand-mark { width: 26px; height: 26px; }
.brand-name { font-size: 13px; font-weight: 500; letter-spacing: -.005em; color: var(--muted); }
.brand-name b { color: var(--text); font-weight: 600; }
.project-name {
  flex: 0 1 260px; background: transparent !important; border-color: transparent !important;
  font-weight: 500;
}
.project-name:hover { border-color: var(--line-2) !important; }
.project-name:focus { border-color: var(--accent) !important; background: var(--bg) !important; }
.save-state { font-size: 11px; color: var(--dim); flex: none; }
.save-state.err { color: var(--warn); }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }

/* ---------- player */
.player { display: flex; flex-direction: column; grid-column: 1; grid-row: 2; }
.stage { position: relative; flex: 1; min-height: 0; background: #000; overflow: hidden; }
.stage video { width: 100%; height: 100%; object-fit: contain; display: block; background: #000; }
.stage.drag::after { content: ""; position: absolute; inset: 8px; border: 2px dashed var(--accent); border-radius: 10px; pointer-events: none; }
.dropzone {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; padding: 24px; text-align: center; background: var(--bg);
}
.dropzone strong { font-size: 15px; font-weight: 600; }
.dropzone > span { color: var(--muted); max-width: 380px; }
.dropzone .btn { margin-top: 8px; height: 34px; padding: 0 14px; }
.stage.has-video .dropzone { display: none; }
.cue {
  position: absolute; left: 50%; bottom: 22px; transform: translate(-50%, 8px);
  padding: 8px 16px; border-radius: 8px; background: rgba(10, 11, 13, .86); border: 1px solid var(--accent);
  font: 600 15px var(--mono); letter-spacing: .04em; opacity: 0; pointer-events: none;
  transition: opacity .16s, transform .16s; max-width: 90%; text-align: center;
}
.cue.show { opacity: 1; transform: translate(-50%, 0); }
.badge-preview {
  position: absolute; top: 10px; left: 10px; display: none;
  font: 600 10px var(--mono); letter-spacing: .12em; padding: 3px 7px; border-radius: 4px;
  background: var(--accent); color: #fff;
}
.app.previewing .badge-preview { display: block; }

.scrub {
  -webkit-appearance: none; appearance: none; display: block; width: calc(100% - 24px); margin: 6px 12px 0;
  height: 18px; background: transparent; cursor: pointer; --p: 0%;
}
.scrub:disabled { opacity: .35; cursor: default; }
.scrub::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: linear-gradient(to right, var(--accent) var(--p), var(--line-2) var(--p)); }
.scrub::-webkit-slider-thumb { -webkit-appearance: none; width: 12px; height: 12px; margin-top: -4px; border-radius: 50%; background: #fff; border: 0; }
.scrub::-moz-range-track { height: 4px; border-radius: 2px; background: var(--line-2); }
.scrub::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--accent); }
.scrub::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 0; }

.transport { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 16px; padding: 6px 12px 12px; }
.clock { display: flex; flex-direction: column; min-width: 150px; }
.clock-main { font-size: 24px; font-weight: 500; letter-spacing: -.01em; line-height: 1.15; }
.clock-sub { font-size: 11px; color: var(--muted); }
.tbtns { display: flex; align-items: center; gap: 4px; }
.btn.play { width: 44px; height: 36px; background: var(--text); border-color: var(--text); color: #0a0b0d; }
.btn.play:hover { background: #fff; border-color: #fff; }
.btn.play .ic { width: 18px; height: 18px; }
.topts { margin-left: auto; display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }

.seg { display: inline-flex; background: var(--bg); border: 1px solid var(--line-2); border-radius: var(--r); padding: 2px; gap: 1px; }
.seg button {
  height: 24px; padding: 0 7px; border: 0; background: transparent; color: var(--muted);
  border-radius: 4px; font: 500 11px var(--mono);
}
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--raise-2); color: var(--text); }
.seg.wide { display: flex; }
.seg.wide button { flex: 1; height: 28px; font-family: var(--sans); font-size: 12px; }

/* ---------- lateral */
.side { display: flex; flex-direction: column; grid-column: 2; grid-row: 2; }
.sync-card { padding: 12px; border-bottom: 1px solid var(--line); background: var(--panel-2); }
.progress-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.progress-text { font-size: 11px; font-weight: 600; letter-spacing: .08em; }
.sync-last { font-size: 11px; color: var(--ok); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.progress { height: 3px; background: var(--line-2); border-radius: 2px; margin: 8px 0 10px; overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; background: var(--ok); border-radius: 2px; transition: width .25s ease; }

.sync-btn {
  width: 100%; height: 64px; padding: 0 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  border: 0; border-radius: 9px; background: var(--accent); color: #fff; text-align: left;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .18), 0 6px 20px -8px rgba(123, 108, 255, .7);
  transition: background .12s, transform .06s, box-shadow .2s;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent; user-select: none;
}
.sync-btn:hover { background: var(--accent-hi); }
.sync-btn:active { transform: scale(.985); }
.sync-btn.flash { animation: flash .35s ease-out; }
@keyframes flash { 0% { box-shadow: 0 0 0 0 rgba(255, 255, 255, .7); background: #fff; color: var(--accent); } 100% { box-shadow: 0 0 0 14px rgba(255, 255, 255, 0); } }
.sync-btn.idle { background: var(--raise-2); color: var(--muted); box-shadow: none; }
.sync-main { display: flex; flex-direction: column; min-width: 0; }
.sync-label { font-size: 17px; font-weight: 700; letter-spacing: .06em; }
.sync-sub { font-size: 12px; opacity: .85; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.list-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px 6px; }
.list-tools { display: flex; gap: 4px; }
.add-row { display: flex; gap: 6px; padding: 0 12px; margin: 0; }
.add-row input { flex: 1; }
.presets { display: flex; gap: 5px; padding: 8px 12px; overflow-x: auto; scrollbar-width: none; align-items: center; }
.presets::-webkit-scrollbar { display: none; }
.presets.manage { flex-wrap: wrap; overflow: visible; }
.chip {
  display: inline-flex; align-items: center; flex: none; height: 24px; border-radius: 12px;
  background: var(--raise); border: 1px solid var(--line-2); overflow: hidden;
}
.chip button { height: 100%; border: 0; background: transparent; color: var(--muted); font: 500 11px var(--mono); padding: 0 9px; white-space: nowrap; }
.chip button:hover { color: var(--text); background: var(--raise-2); }
.chip .chip-del { padding: 0 7px 0 5px; border-left: 1px solid var(--line-2); color: var(--danger); font-size: 13px; }
.chip.ghost { background: transparent; border-style: dashed; }
.chip.ghost button { font-family: var(--sans); }
.presets input { height: 24px; width: 130px; font-size: 11px; border-radius: 12px; flex: none; }

.list-wrap { flex: 1; min-height: 0; overflow-y: auto; border-top: 1px solid var(--line); scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
.events { list-style: none; margin: 0; padding: 4px 0; }
.empty { padding: 28px 20px; text-align: center; color: var(--muted); }
.empty b { display: block; color: var(--text); font-weight: 600; margin-bottom: 4px; }
.ev {
  position: relative; display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 8px 0 4px;
  border-left: 2px solid transparent; cursor: pointer; user-select: none;
}
.ev:hover { background: rgba(255, 255, 255, .03); }
.ev.is-selected { background: var(--accent-soft); border-left-color: var(--accent); }
.ev.is-active .ev-name { color: #fff; }
.ev.is-active .ev-idx { color: var(--ok); }
.ev.reached { animation: reached .9s ease-out; }
@keyframes reached { 0% { background: rgba(63, 211, 156, .28); } 100% { background: transparent; } }
.ev.is-dragging { opacity: .4; }
.ev.drop-before::before, .ev.drop-after::after { content: ""; position: absolute; left: 0; right: 0; height: 2px; background: var(--accent); }
.ev.drop-before::before { top: -1px; }
.ev.drop-after::after { bottom: -1px; }
.ev-grip { color: var(--dim); cursor: grab; display: flex; }
.ev-grip .ic { width: 12px; height: 14px; }
.ev-idx { font: 500 10px var(--mono); color: var(--dim); width: 18px; text-align: right; }
.ev-time { font: 500 12px var(--mono); font-variant-numeric: tabular-nums; width: 76px; flex: none; color: var(--ok); }
.ev:not(.is-synced) .ev-time { color: var(--warn); font-size: 11px; }
.ev.is-out .ev-time { color: var(--danger); }
.ev-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; color: #cfd3db; }
.ev-actions { display: flex; gap: 1px; flex: none; }
.ev-actions button {
  width: 24px; height: 24px; display: grid; place-items: center; border: 0; border-radius: 4px;
  background: transparent; color: var(--dim);
}
.ev-actions button:hover { background: var(--raise-2); color: var(--text); }
.ev-actions button[data-act="del"]:hover { color: var(--danger); }
.ev-actions button:disabled { opacity: .3; pointer-events: none; }
.ev-actions .ic { width: 14px; height: 14px; }

/* ---------- timeline */
.timeline { display: flex; flex-direction: column; grid-column: 1; grid-row: 3; }
.tl-head { display: flex; align-items: center; gap: 14px; height: 40px; padding: 0 12px; border-bottom: 1px solid var(--line); flex: none; }
.offset { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.offset label { font-size: 11px; color: var(--muted); }
.offset input { width: 76px; height: 26px; text-align: right; font-size: 12px; }
.offset .unit { font-size: 11px; color: var(--dim); }
.zoom { display: flex; align-items: center; gap: 6px; }
.zoom input { width: 110px; accent-color: var(--accent); }
.zoom-val { font-size: 11px; color: var(--muted); width: 34px; text-align: right; }
.tl-scroll { flex: 1; min-height: 0; overflow-x: auto; overflow-y: hidden; position: relative; scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
.tl-inner { position: relative; height: 100%; min-height: 130px; margin: 0 14px; width: calc(100% - 28px); }
.tl-ruler { position: absolute; left: 0; right: 0; top: 0; height: 26px; border-bottom: 1px solid var(--line-2); cursor: ew-resize; touch-action: none; }
.tick { position: absolute; top: 8px; bottom: 0; border-left: 1px solid var(--line-2); padding-left: 5px; font: 10px var(--mono); color: var(--dim); white-space: nowrap; pointer-events: none; }
.tick.minor { top: auto; height: 5px; padding: 0; }
.tl-track {
  position: absolute; left: 0; right: 0; top: 27px; bottom: 0; cursor: pointer;
  background: linear-gradient(to bottom, rgba(255, 255, 255, .02), transparent);
}
.tl-markers { position: absolute; left: 0; right: 0; top: 27px; bottom: 0; pointer-events: none; }
.marker { position: absolute; top: 0; bottom: 0; width: 0; }
.marker-line { position: absolute; top: 0; bottom: 0; left: 0; width: 1px; background: var(--accent); opacity: .55; }
.marker-flag {
  position: absolute; left: 0; top: calc(8px + var(--lane, 0) * 26px); height: 21px; max-width: 170px;
  padding: 0 8px; display: flex; align-items: center; border-radius: 0 4px 4px 0;
  background: var(--raise); border: 1px solid var(--line-2); border-left: 2px solid var(--accent);
  font: 500 11px var(--sans); color: #cfd3db; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  cursor: grab; pointer-events: auto; touch-action: none; user-select: none;
}
.marker.flip .marker-flag { left: auto; right: 0; border-radius: 4px 0 0 4px; border-left: 1px solid var(--line-2); border-right: 2px solid var(--accent); }
.marker-flag:hover { background: var(--raise-2); color: #fff; }
.marker.is-selected .marker-flag { background: var(--accent); border-color: var(--accent); color: #fff; }
.marker.is-selected .marker-line { opacity: 1; }
.marker.is-active .marker-line { background: var(--ok); opacity: 1; }
.marker.is-active:not(.is-selected) .marker-flag { border-left-color: var(--ok); color: #fff; }
.marker.is-out .marker-flag { border-left-color: var(--danger); }
.marker-time {
  position: absolute; left: 0; top: calc(32px + var(--lane, 0) * 26px); padding: 2px 6px; border-radius: 4px;
  background: #fff; color: #0a0b0d; font: 600 11px var(--mono); white-space: nowrap; display: none; z-index: 5;
}
.marker.flip .marker-time { left: auto; right: 0; }
.marker.is-dragging { z-index: 4; }
.marker.is-dragging .marker-time { display: block; }
.marker.is-dragging .marker-flag { cursor: grabbing; }
.playhead { position: absolute; top: 0; bottom: 0; left: 0; width: 1px; background: #fff; pointer-events: none; z-index: 3; }
.playhead::before { content: ""; position: absolute; top: 0; left: -5px; border: 5px solid transparent; border-top: 7px solid #fff; }

/* ---------- inspetor */
.inspector { grid-column: 2; grid-row: 3; padding: 0 12px 12px; display: flex; flex-direction: column; gap: 8px; }
.insp-head { display: flex; align-items: center; justify-content: space-between; height: 40px; margin: 0 -12px; padding: 0 12px; border-bottom: 1px solid var(--line); flex: none; }
.insp-tools { display: flex; gap: 4px; }
.insp-fields { display: grid; grid-template-columns: 1fr 132px; gap: 8px; margin-top: 4px; }
.insp-fields label { display: flex; flex-direction: column; gap: 4px; font-size: 11px; color: var(--muted); min-width: 0; }
.insp-fields input { width: 100%; }
.insp-fields input.bad { border-color: var(--danger); animation: shake .25s; }
@keyframes shake { 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }
.nudges { display: grid; grid-template-columns: repeat(8, 1fr); gap: 3px; }
.nudges button {
  height: 28px; border-radius: 5px; background: var(--raise); border: 1px solid var(--line-2);
  font: 500 11px var(--mono); color: var(--muted); padding: 0; touch-action: manipulation;
}
.nudges button:hover { background: var(--raise-2); color: var(--text); }
.nudges button:active { background: var(--accent); border-color: var(--accent); color: #fff; }
.inspector.is-empty .insp-fields, .inspector.is-empty .nudges, .inspector.is-empty .insp-tools { opacity: .35; pointer-events: none; }
.inspector.is-pending .nudges, .inspector.is-pending [data-insp="goto"], .inspector.is-pending [data-insp="clear"] { opacity: .35; pointer-events: none; }

/* ---------- toasts e diálogos */
.toasts { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; align-items: center; z-index: 50; pointer-events: none; width: max-content; max-width: calc(100vw - 24px); }
.toast {
  padding: 8px 13px; border-radius: 8px; background: #f2f3f6; color: #0a0b0d; font-weight: 500;
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, .8); animation: tin .16s ease-out; max-width: 100%;
}
.toast.warn { background: var(--warn); }
.toast.danger { background: var(--danger); }
.toast.ok { background: var(--ok); }
.toast.out { opacity: 0; transition: opacity .2s; }
@keyframes tin { from { opacity: 0; transform: translateY(6px); } }

dialog { padding: 0; border: 1px solid var(--line-2); border-radius: 12px; background: var(--panel); color: var(--text); width: min(560px, calc(100vw - 24px)); box-shadow: 0 30px 80px -20px #000; }
dialog::backdrop { background: rgba(4, 5, 7, .7); }
#dlgConfirm, #dlgKeys { width: min(420px, calc(100vw - 24px)); }
.dlg header { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 0; }
.dlg-body { padding: 12px 16px; display: flex; flex-direction: column; gap: 10px; }
.dlg-body p { margin: 0; }
.dlg footer { display: flex; justify-content: flex-end; gap: 8px; padding: 0 16px 16px; }
.dlg-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.hint { color: var(--muted); font-size: 12px; }
.radio-row { display: flex; gap: 16px; flex-wrap: wrap; }
.radio-row label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.radio-row input { accent-color: var(--accent); }
.radio-row.off { opacity: .35; pointer-events: none; }
.keys > div { display: flex; align-items: center; gap: 6px; }
.keys > div span { margin-left: auto; color: var(--muted); text-align: right; }

/* ---------- responsivo */
@media (max-width: 1180px) {
  .app { grid-template-columns: minmax(0, 1fr) 360px; }
  .brand-name { display: none; }
}
@media (max-width: 900px) {
  body { overscroll-behavior: auto; }
  .app { display: flex; flex-direction: column; height: auto; min-height: 100dvh; }
  .topbar { height: 50px; flex: none; position: sticky; top: 0; z-index: 20; gap: 6px; padding: 0 8px; border-bottom: 1px solid var(--line); }
  .top-actions { gap: 4px; }
  .top-actions .btn span, .save-state, .sep, #btnKeys { display: none; }
  .top-actions .btn { width: 32px; padding: 0; }
  .project-name { flex: 1 1 0; }
  .stage { flex: none; aspect-ratio: 16 / 9; max-height: 46vh; }
  .transport { gap: 8px 10px; padding-bottom: 10px; }
  .clock { min-width: 0; }
  .clock-main { font-size: 20px; }
  .tbtns { margin-left: auto; }
  .tbtns .btn.icon { width: 34px; height: 34px; }
  .topts { margin-left: 0; width: 100%; justify-content: space-between; }
  #btnPreview span { display: none; }
  .sync-btn { height: 72px; }
  .sync-btn kbd { display: none; }
  .list-wrap { flex: none; max-height: 44vh; }
  .ev { height: 40px; }
  .ev-actions button { width: 28px; height: 28px; }
  .timeline { height: 230px; flex: none; }
  .tl-head { gap: 8px; }
  .tl-head h2, .offset label, .zoom-val { display: none; }
  .offset { margin-left: 0; }
  .zoom { margin-left: auto; }
  .zoom input { width: 70px; }
  .inspector { padding-bottom: 20px; }
  .nudges button { height: 36px; font-size: 10px; }
  input[type="text"], input[type="number"], textarea { font-size: 16px; }
  .presets input { font-size: 16px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
