:root {
  --bg: #0c0d11;
  --panel: #14161c;
  --panel-2: #1b1e26;
  --line: #262a35;
  --line-2: #323745;
  --text: #eef0f5;
  --muted: #9097a8;
  --faint: #626a7d;
  --accent: #ffd400;
  --accent-ink: #141414;
  --danger: #ff5a52;
  --ok: #2bd67b;
  --info: #4aa8ff;
  --radius: 12px;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 14px/1.45 Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
.hidden { display: none !important; }

/* ---------- botões e campos ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 14px; border-radius: 9px; border: 1px solid var(--line-2);
  background: var(--panel-2); cursor: pointer; font-weight: 600; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .05s;
  text-decoration: none;
}
.btn:hover { background: #232733; border-color: #3d4354; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { background: #ffe14d; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--panel-2); color: var(--text); }
.btn.danger:hover { border-color: var(--danger); color: var(--danger); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn.xs { height: 26px; padding: 0 8px; font-size: 12px; border-radius: 7px; }
.btn.lg { height: 44px; padding: 0 20px; font-size: 15px; border-radius: 11px; }
.btn.block { width: 100%; }
.icon-btn { width: 30px; padding: 0; }

.input, .select, textarea.input {
  width: 100%; height: 36px; padding: 0 11px; border-radius: 9px;
  background: #0f1116; border: 1px solid var(--line-2); outline: none;
}
textarea.input { height: auto; padding: 10px 11px; resize: vertical; line-height: 1.5; }
.input:focus, .select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255,212,0,.15); }
.label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin: 0 0 6px; text-transform: uppercase; letter-spacing: .04em; }
.field { margin-bottom: 14px; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12px; }
.mono { font-variant-numeric: tabular-nums; }

.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { display: none; }
.switch .track { width: 38px; height: 22px; border-radius: 22px; background: var(--line-2); position: relative; transition: background .15s; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: left .15s; }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { left: 19px; background: #111; }

.seg { display: inline-flex; background: #0f1116; border: 1px solid var(--line-2); border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 6px 11px; border-radius: 7px; cursor: pointer; color: var(--muted); font-weight: 600; font-size: 13px; }
.seg button.on { background: var(--panel-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-2); }

.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch { width: 28px; height: 28px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; box-shadow: inset 0 0 0 1px rgba(0,0,0,.3); }
.swatch.on { border-color: #fff; transform: scale(1.08); }

.progress { height: 6px; border-radius: 6px; background: var(--line); overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .3s; }
.progress.indet > i { width: 35% !important; animation: indet 1.2s ease-in-out infinite; }
@keyframes indet { 0% { transform: translateX(-100%); } 100% { transform: translateX(300%); } }

.badge { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px; border-radius: 22px; font-size: 11.5px; font-weight: 700; background: var(--panel-2); color: var(--muted); border: 1px solid var(--line-2); }
.badge.ok { color: var(--ok); border-color: rgba(43,214,123,.35); background: rgba(43,214,123,.08); }
.badge.run { color: var(--accent); border-color: rgba(255,212,0,.35); background: rgba(255,212,0,.08); }
.badge.err { color: var(--danger); border-color: rgba(255,90,82,.35); background: rgba(255,90,82,.08); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.run .dot { animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .3; } }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty h3 { color: var(--text); margin: 0 0 6px; font-size: 16px; }

/* ---------- login ---------- */
.login { min-height: 100%; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(800px 400px at 50% -10%, rgba(255,212,0,.10), transparent 70%); }
.login .card { width: 100%; max-width: 380px; padding: 30px; box-shadow: var(--shadow); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 17px; letter-spacing: -.01em; }
.brand .logo { width: 30px; height: 30px; border-radius: 8px; background: var(--accent); display: grid; place-items: center; }
.brand .logo::after { content: ""; border-left: 10px solid #111; border-top: 6px solid transparent; border-bottom: 6px solid transparent; margin-left: 3px; }

/* ---------- topo ---------- */
.topbar { height: 58px; display: flex; align-items: center; gap: 14px; padding: 0 18px; border-bottom: 1px solid var(--line); background: rgba(12,13,17,.9); backdrop-filter: blur(8px); position: sticky; top: 0; z-index: 20; }
.topbar .name { background: transparent; border: 1px solid transparent; border-radius: 8px; height: 34px; padding: 0 8px; font-weight: 700; font-size: 15px; min-width: 120px; max-width: 360px; }
.topbar .name:hover { border-color: var(--line-2); }
.topbar .name:focus { border-color: var(--accent); outline: none; }

/* ---------- painel ---------- */
.dash { max-width: 1180px; margin: 0 auto; padding: 28px 20px 60px; }
.dash h1 { font-size: 26px; letter-spacing: -.02em; margin: 0 0 4px; }
.drop {
  margin: 22px 0 30px; border: 2px dashed var(--line-2); border-radius: 16px; padding: 38px 20px; text-align: center;
  background: linear-gradient(180deg, rgba(255,212,0,.04), transparent); cursor: pointer; transition: border-color .15s, background .15s;
}
.drop:hover, .drop.over { border-color: var(--accent); background: rgba(255,212,0,.06); }
.drop .big { font-size: 18px; font-weight: 700; margin: 10px 0 4px; }
.drop .up-icon { width: 54px; height: 54px; border-radius: 14px; margin: 0 auto; background: var(--accent); display: grid; place-items: center; color: #111; }
.uploads { display: grid; gap: 10px; margin-bottom: 26px; }
.upload-item { padding: 14px 16px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.pcard { overflow: hidden; cursor: pointer; transition: transform .12s, border-color .12s; }
.pcard:hover { transform: translateY(-2px); border-color: var(--line-2); }
.pcard .cover { aspect-ratio: 16/9; background: #0a0b0e center/cover no-repeat; position: relative; }
.pcard .cover .dur { position: absolute; right: 8px; bottom: 8px; background: rgba(0,0,0,.75); padding: 2px 6px; border-radius: 5px; font-size: 12px; font-weight: 600; }
.pcard .body { padding: 12px 14px; display: flex; align-items: center; gap: 8px; }
.pcard .title { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- editor ---------- */
.editor { display: grid; grid-template-columns: minmax(0, 1fr) 460px; height: calc(100vh - 58px); }
.stage { display: flex; flex-direction: column; min-width: 0; border-right: 1px solid var(--line); }
.player-wrap { flex: 1; min-height: 0; min-width: 0; display: grid; place-items: center; padding: 18px; background: #08090b; }
.player { position: relative; max-width: 100%; max-height: 100%; display: inline-block; line-height: 0; }
.player video { max-width: 100%; max-height: calc(100vh - 58px - 230px); display: block; border-radius: 10px; background: #000; }
.player .ov-prev { position: absolute; inset: 0; border-radius: 10px; overflow: hidden; pointer-events: none; }
.player .ov-prev img { position: absolute; }
.player .ov-prev img.full { inset: 0; width: 100%; height: 100%; object-fit: cover; }
.player .ov-prev img.pip { right: 4%; top: 6%; width: 42%; border: 3px solid #fff; border-radius: 4px; box-shadow: var(--shadow); }
.player .sub-prev { position: absolute; left: 6%; right: 6%; text-align: center; pointer-events: none; line-height: 1.15; font-weight: 800; }
.player .sub-prev span { display: inline; padding: .05em .25em; }
.player .cut-flag { position: absolute; left: 10px; top: 10px; line-height: 1; }
.player-empty { color: var(--muted); text-align: center; line-height: 1.6; }

.controls { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-top: 1px solid var(--line); background: var(--panel); }
.timecode { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--muted); min-width: 110px; }

.timeline { position: relative; height: 128px; padding: 10px 16px 14px; background: var(--panel); border-top: 1px solid var(--line); user-select: none; }
.tl-track { position: relative; height: 100%; border-radius: 8px; overflow: hidden; background: #0a0b0e; cursor: pointer; }
.tl-strip { position: absolute; left: 0; right: 0; top: 0; height: 56px; display: flex; }
.tl-strip img { height: 100%; flex: 1 1 0; min-width: 0; object-fit: cover; opacity: .85; }
.tl-lanes { position: absolute; left: 0; right: 0; top: 60px; bottom: 0; }
.tl-seg { position: absolute; top: 0; height: 14px; border-radius: 3px; background: rgba(74,168,255,.45); }
.tl-seg.removed { background: repeating-linear-gradient(45deg, rgba(255,90,82,.6) 0 4px, rgba(255,90,82,.25) 4px 8px); }
.tl-ov { position: absolute; top: 19px; height: 20px; border-radius: 4px; background: var(--accent); color: #111; font-size: 10px; font-weight: 800; padding: 0 5px; overflow: hidden; white-space: nowrap; line-height: 18px; }
.tl-cut { position: absolute; top: 0; height: 56px; background: rgba(255,90,82,.35); border-left: 1px solid var(--danger); border-right: 1px solid var(--danger); }
.tl-trim { position: absolute; top: 0; bottom: 0; background: rgba(0,0,0,.65); }
.tl-head { position: absolute; top: 0; bottom: 0; width: 2px; background: #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.5); pointer-events: none; }
.tl-head::before { content: ""; position: absolute; top: -2px; left: -5px; border: 6px solid transparent; border-top-color: #fff; }

.side { display: flex; flex-direction: column; min-height: 0; background: var(--panel); }
.tabs { display: flex; gap: 2px; padding: 8px 10px 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button { border: 0; background: transparent; padding: 10px 12px; cursor: pointer; color: var(--muted); font-weight: 650; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; display: inline-flex; gap: 6px; align-items: center; }
.tabs button.on { color: var(--text); border-bottom-color: var(--accent); }
.tabs .tdot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.pane { flex: 1; overflow-y: auto; padding: 16px; }
.pane h3 { margin: 0 0 10px; font-size: 15px; }
.section { margin-bottom: 22px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }

.jobbox { padding: 14px; margin-bottom: 14px; }
.jobbox .msg { font-weight: 600; margin-bottom: 8px; }

/* pipeline */
.steps { display: flex; gap: 6px; align-items: center; margin-left: auto; overflow-x: auto; }
.step { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 650; color: var(--faint); padding: 5px 9px; border-radius: 20px; border: 1px solid var(--line); white-space: nowrap; }
.step.done { color: var(--ok); border-color: rgba(43,214,123,.3); }
.step.run { color: var(--accent); border-color: rgba(255,212,0,.4); }
.step.err { color: var(--danger); border-color: rgba(255,90,82,.4); }
.step .pct { font-variant-numeric: tabular-nums; }

/* transcrição */
.segs { display: grid; gap: 4px; }
.segrow { display: grid; grid-template-columns: 58px 1fr auto; gap: 8px; align-items: start; padding: 8px; border-radius: 9px; border: 1px solid transparent; }
.segrow:hover { background: var(--panel-2); }
.segrow.active { background: rgba(255,212,0,.07); border-color: rgba(255,212,0,.25); }
.segrow .t { font-size: 12px; font-weight: 700; color: var(--info); cursor: pointer; padding-top: 2px; font-variant-numeric: tabular-nums; }
.segrow .txt { outline: none; border-radius: 6px; padding: 1px 4px; margin: -1px -4px; min-height: 20px; }
.segrow .txt:focus { background: #0f1116; box-shadow: 0 0 0 1px var(--accent); }
.segrow.removed .txt { text-decoration: line-through; color: var(--faint); }
.segrow .acts { display: flex; gap: 2px; opacity: .3; }
.segrow:hover .acts, .segrow.active .acts { opacity: 1; }
.segrow .has-ov { color: var(--accent); }

/* imagens */
.ovitem { display: grid; grid-template-columns: 96px 1fr; gap: 12px; padding: 10px; margin-bottom: 10px; }
.ovitem img { width: 96px; aspect-ratio: 16/9; object-fit: cover; border-radius: 6px; background: #000; cursor: pointer; }
.time-in { width: 74px; height: 30px; padding: 0 8px; font-size: 13px; }
.sugg { padding: 12px; margin-bottom: 10px; }

/* thumbnail */
.thumb-main { width: 100%; aspect-ratio: 16/9; border-radius: 10px; background: #000 center/cover; border: 1px solid var(--line); display: block; object-fit: cover; }
.thumb-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.thumb-grid img { width: 100%; aspect-ratio: 16/9; object-fit: cover; border-radius: 7px; cursor: pointer; border: 2px solid transparent; }
.thumb-grid img.on { border-color: var(--accent); }
.frames { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.frames .fr { aspect-ratio: 16/9; border-radius: 6px; background: #000 center/cover; cursor: pointer; border: 2px solid transparent; position: relative; }
.frames .fr.on { border-color: var(--accent); }
.frames .fr.special { display: grid; place-items: center; background: var(--panel-2); font-size: 11px; font-weight: 700; color: var(--muted); text-align: center; padding: 4px; border: 1px dashed var(--line-2); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line-2); background: var(--panel-2); border-radius: 20px; padding: 4px 10px; font-size: 12px; font-weight: 650; cursor: pointer; }
.chip:hover { border-color: var(--accent); }
.style-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.style-opts button { text-align: left; padding: 9px 10px; border-radius: 9px; border: 1px solid var(--line-2); background: #0f1116; cursor: pointer; font-size: 12.5px; }
.style-opts button b { display: block; font-size: 13px; }
.style-opts button.on { border-color: var(--accent); background: rgba(255,212,0,.06); }

/* textos */
.title-opt { display: flex; gap: 10px; align-items: flex-start; padding: 10px; border-radius: 9px; border: 1px solid var(--line); margin-bottom: 6px; cursor: pointer; }
.title-opt.on { border-color: var(--accent); background: rgba(255,212,0,.05); }
.title-opt .n { color: var(--faint); font-size: 12px; }

/* exportar */
.presets { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.preset { padding: 12px; border-radius: 10px; border: 1px solid var(--line-2); background: #0f1116; cursor: pointer; text-align: left; }
.preset b { display: block; }
.preset span { font-size: 12px; color: var(--muted); }
.preset.on { border-color: var(--accent); background: rgba(255,212,0,.06); }
.file-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; }
.dl-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto; padding: 22px; box-shadow: var(--shadow); }
.modal h3 { margin: 0 0 4px; }

/* toasts */
#toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; z-index: 100; }
.toast { background: #222631; border: 1px solid var(--line-2); padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow); font-weight: 600; animation: tin .2s; }
.toast.err { border-color: var(--danger); }
@keyframes tin { from { opacity: 0; transform: translateY(8px); } }

kbd { font: 600 11px Inter, sans-serif; background: var(--panel-2); border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 4px; padding: 1px 5px; }

@media (max-width: 1100px) {
  .editor { grid-template-columns: minmax(0, 1fr); height: auto; }
  .player-wrap { padding: 10px; }
  .player { width: 100%; }
  .player video { width: 100%; }
  .stage { border-right: 0; }
  .player video { max-height: 52vh; }
  .side { min-height: 70vh; }
  .steps { display: none; }
}
@media (max-width: 560px) {
  .dash { padding: 18px 16px 40px; }
  .topbar { padding: 0 12px; gap: 8px; }
  .presets, .dl-grid, .style-opts { grid-template-columns: 1fr; }
  .thumb-grid { grid-template-columns: repeat(2, 1fr); }
  .controls { flex-wrap: wrap; }
}
