:root {
  --bg: #f5f2ec;
  --surface: #ffffff;
  --surface-2: #f9f7f3;
  --ink: #1e2329;
  --muted: #6b7078;
  --line: #e4ded3;
  --accent: #2c5f63;
  --accent-ink: #ffffff;
  --accent-soft: #e2eeee;
  --purple: #6a4c9c;
  --purple-soft: #eee8f7;
  --ok: #2f7d4f;
  --ok-soft: #e3f2e8;
  --warn: #9a6a12;
  --warn-soft: #fbf0d9;
  --danger: #b03a3a;
  --danger-soft: #f8e3e3;
  --shadow: 0 1px 2px rgba(30, 35, 41, .06), 0 4px 16px rgba(30, 35, 41, .05);
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14171a; --surface: #1c2024; --surface-2: #22272c; --ink: #ecebe7; --muted: #9aa0a6; --line: #2f353b;
    --accent: #5fa3a8; --accent-ink: #0f1a1b; --accent-soft: #1f3335; --purple: #a98bdb; --purple-soft: #2b2537;
    --ok: #6cc08e; --ok-soft: #1e3227; --warn: #e0b45e; --warn-soft: #362d1b; --danger: #ec8080; --danger-soft: #3a2224;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.2);
  }
}
:root[data-theme="dark"] {
  --bg: #14171a; --surface: #1c2024; --surface-2: #22272c; --ink: #ecebe7; --muted: #9aa0a6; --line: #2f353b;
  --accent: #5fa3a8; --accent-ink: #0f1a1b; --accent-soft: #1f3335; --purple: #a98bdb; --purple-soft: #2b2537;
  --ok: #6cc08e; --ok-soft: #1e3227; --warn: #e0b45e; --warn-soft: #362d1b; --danger: #ec8080; --danger-soft: #3a2224;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
}
h1, h2, h3 { font-family: Lora, Georgia, serif; font-weight: 600; line-height: 1.25; margin: 0 0 .4em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
a { color: var(--accent); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* Topo */
.topbar {
  position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 24px; padding: 10px 24px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 500; white-space: nowrap; }
.brand b { color: var(--accent); font-weight: 700; }
.brand-mark { width: 34px; height: 34px; border-radius: 50%; background: #000; object-fit: cover; display: block; }
.brand.big .brand-mark { width: 44px; height: 44px; }
.brand.big { font-size: 1.15rem; justify-content: center; }
.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; flex: 1; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a {
  text-decoration: none; color: var(--muted); padding: 8px 12px; border-radius: 10px; white-space: nowrap;
  font-weight: 500; display: inline-flex; align-items: center; gap: 6px;
}
.tabs a:hover { color: var(--ink); background: var(--surface-2); }
.tabs a.active { color: var(--accent); background: var(--accent-soft); }
.badge {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--purple); color: #fff;
  font-size: 12px; display: inline-grid; place-items: center; font-weight: 600;
}
.badge.soft { background: var(--line); color: var(--ink); }
.badge:empty { display: none; }

.container { max-width: 1180px; margin: 0 auto; padding: 24px 24px 80px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head p { margin: 0; }

/* Cartões */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.grid { display: grid; gap: 16px; }
.stats { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); margin-bottom: 20px; }
.stat { padding: 16px 18px; text-decoration: none; color: inherit; display: block; }
.stat .num { font-size: 2rem; font-weight: 700; font-family: Lora, serif; line-height: 1.1; }
.stat .label { color: var(--muted); font-size: .9rem; }
.stat.highlight { border-color: var(--purple); background: var(--purple-soft); }
.two-col { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.section { margin-top: 28px; }

.alert { border-radius: 12px; padding: 12px 14px; margin-bottom: 12px; display: flex; gap: 10px; align-items: flex-start; }
.alert.warn { background: var(--warn-soft); color: var(--warn); }
.alert.info { background: var(--accent-soft); color: var(--accent); }
.alert.danger { background: var(--danger-soft); color: var(--danger); }
.alert.ok { background: var(--ok-soft); color: var(--ok); }
.alert p { margin: 0; color: var(--ink); }
.alert strong { display: block; }

/* Botões e formulários */
.btn {
  appearance: none; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font: inherit; font-weight: 600; padding: 9px 14px; border-radius: 10px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none; white-space: nowrap;
  min-height: 40px;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.purple { background: var(--purple); color: #fff; border-color: var(--purple); }
.btn.danger { color: var(--danger); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { padding: 5px 10px; min-height: 32px; font-size: .88rem; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; }
.spacer { flex: 1; }

label.field { display: block; font-size: .85rem; font-weight: 600; color: var(--muted); margin-bottom: 12px; }
label.field > input, label.field > textarea, label.field > select { margin-top: 5px; }
input[type=text], input[type=password], input[type=number], input[type=url], input[type=datetime-local], input[type=time], textarea, select {
  width: 100%; font: inherit; color: var(--ink); background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 10px; padding: 9px 12px; min-height: 40px;
}
textarea { resize: vertical; line-height: 1.5; }
input:focus, textarea:focus, select:focus { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); border-color: var(--accent); }
.hint { font-weight: 400; color: var(--muted); font-size: .8rem; margin-top: 4px; }
.form-error { color: var(--danger); min-height: 1.2em; margin: 0; font-size: .9rem; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(380px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 28px; box-shadow: var(--shadow); display: grid; gap: 14px; text-align: center; }

/* Upload */
.drop {
  border: 2px dashed var(--line); border-radius: var(--radius); padding: 26px 18px; text-align: center; cursor: pointer;
  background: var(--surface-2); transition: border-color .15s, background .15s;
}
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop .icon { font-size: 28px; }
.progress { height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; margin-top: 10px; }
.progress > div { height: 100%; background: var(--accent); width: 0; transition: width .2s; }

/* Status */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip.processing { background: var(--accent-soft); color: var(--accent); }
.chip.processing::before { animation: pulse 1.2s infinite; }
.chip.pending { background: var(--purple-soft); color: var(--purple); }
.chip.scheduled, .chip.approved { background: var(--warn-soft); color: var(--warn); }
.chip.published, .chip.ready { background: var(--ok-soft); color: var(--ok); }
.chip.error, .chip.failed { background: var(--danger-soft); color: var(--danger); }
.chip.rejected, .chip.archived { background: var(--line); color: var(--muted); }
@keyframes pulse { 50% { opacity: .3; } }

/* Lista de vídeos */
.video-item { display: grid; gap: 12px; }
.video-top { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; }
.video-title { font-weight: 600; font-size: 1.02rem; overflow-wrap: anywhere; }
.thumbs { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; }
.thumb { position: relative; width: 92px; flex: none; text-decoration: none; color: inherit; }
.thumb img, .thumb .ph { width: 92px; height: 164px; object-fit: cover; border-radius: 10px; background: var(--surface-2); display: block; border: 1px solid var(--line); }
.thumb .ph { display: grid; place-items: center; color: var(--muted); font-size: .75rem; text-align: center; padding: 6px; }
.thumb .chip { position: absolute; left: 4px; bottom: 4px; font-size: .68rem; padding: 1px 7px; }

/* Cartão de corte */
.clips { display: grid; gap: 20px; }
.clip { display: grid; grid-template-columns: minmax(220px, 300px) 1fr; gap: 22px; padding: 18px; }
.clip video, .clip .video-ph { width: 100%; aspect-ratio: 9 / 16; border-radius: 12px; background: #000; display: block; object-fit: contain; }
.clip .video-ph { display: grid; place-items: center; color: #ccc; background: #222; text-align: center; padding: 16px; }
.clip-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; color: var(--muted); font-size: .85rem; margin-bottom: 6px; }
.reason { background: var(--surface-2); border-left: 3px solid var(--purple); padding: 8px 12px; border-radius: 0 8px 8px 0; font-size: .9rem; margin: 0 0 14px; }
.score { color: var(--purple); font-weight: 700; }
.saved { color: var(--ok); font-size: .8rem; font-weight: 600; opacity: 0; transition: opacity .3s; }
.saved.show { opacity: 1; }
.adjust { background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 12px; }
.adjust .times { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.nudge { display: flex; gap: 4px; margin-top: 4px; flex-wrap: wrap; }
.trim { display: grid; gap: 10px; margin-bottom: 10px; }
.trim-summary { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-size: .92rem; color: var(--muted); }
.trim-summary b { color: var(--ink); }
.trim-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.trim-label { width: 88px; font-weight: 600; font-size: .9rem; }
.trim-label { width: 96px; }
.trim-input { width: 112px !important; min-height: 32px !important; padding: 4px 8px !important; text-align: center; font-family: ui-monospace, "SF Mono", Consolas, monospace; font-weight: 600; font-variant-numeric: tabular-nums; }
.trim .hint { margin: 0; }
.schedule-box { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 14px; }
.schedule-box .row > label.field { flex: 1; min-width: 200px; margin: 0; }
.transcript { font-size: .88rem; color: var(--muted); max-height: 160px; overflow: auto; background: var(--surface-2); padding: 10px 12px; border-radius: 10px; margin: 0 0 12px; }

/* Criar corte */
.cutter { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.src-video { width: 100%; aspect-ratio: 16 / 9; background: #000; border-radius: 10px; display: block; }
.cut-times { display: grid; grid-template-columns: 1fr 1fr auto; gap: 12px; margin-top: 14px; align-items: start; }
.cut-duration { min-width: 120px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); color: var(--muted); font-size: .85rem; margin-top: 21px; }
.cut-duration b { display: block; font-size: 1.3rem; font-family: Lora, serif; color: var(--ink); }
.cut-duration.ok { background: var(--ok-soft); color: var(--ok); }
.cut-duration.warn { background: var(--warn-soft); color: var(--warn); }
.cut-side { position: sticky; top: 76px; }
.segs { max-height: calc(100vh - 190px); min-height: 300px; overflow-y: auto; margin: 0 -8px; }
.seg { display: grid; grid-template-columns: 44px 1fr auto; gap: 8px; padding: 7px 8px; border-radius: 8px; cursor: pointer; font-size: .9rem; align-items: start; }
.seg:hover { background: var(--surface-2); }
.seg-time { color: var(--muted); font-variant-numeric: tabular-nums; font-size: .8rem; padding-top: 2px; }
.seg-actions { display: flex; gap: 4px; opacity: 0; transition: opacity .1s; }
.seg:hover .seg-actions, .seg.in .seg-actions { opacity: 1; }
.seg-actions .btn { min-height: 26px; padding: 2px 8px; font-size: .75rem; }
.seg.in { background: var(--accent-soft); }
.seg.now .seg-text { font-weight: 600; color: var(--accent); }

/* Agenda */
.calendar { margin-bottom: 22px; }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-dow { font-size: .72rem; text-transform: uppercase; color: var(--muted); text-align: center; font-weight: 600; padding: 4px 0; }
.cal-day { min-height: 64px; border-radius: 10px; background: var(--surface-2); padding: 5px; font-size: .78rem; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cal-day.out { opacity: .35; }
.cal-day.today { outline: 2px solid var(--accent); }
.cal-day .d { font-weight: 600; color: var(--muted); }
.cal-pill { border-radius: 6px; padding: 1px 5px; font-size: .7rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.cal-pill.scheduled { background: var(--warn-soft); color: var(--warn); }
.cal-pill.published { background: var(--ok-soft); color: var(--ok); }

.list-item { display: grid; grid-template-columns: 72px 1fr; gap: 14px; padding: 14px; align-items: start; }
.list-item img, .list-item .ph { width: 72px; height: 128px; object-fit: cover; border-radius: 10px; background: var(--surface-2); }
.list-item .when { font-weight: 700; }
.caption-preview { white-space: pre-wrap; font-size: .9rem; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; margin: 4px 0 10px; }
.day-label { font-weight: 700; margin: 22px 0 10px; font-family: Lora, serif; font-size: 1.05rem; }
.day-label:first-child { margin-top: 0; }
.metrics { display: flex; gap: 14px; flex-wrap: wrap; margin: 6px 0 10px; }
.metric { font-size: .85rem; color: var(--muted); }
.metric b { color: var(--ink); font-size: 1.05rem; display: block; }

.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.empty .icon { font-size: 34px; display: block; margin-bottom: 6px; }

.tips ul { margin: 0; padding-left: 18px; }
.tips li { margin-bottom: 6px; }

.vtime { text-align: center; font-variant-numeric: tabular-nums; font-family: ui-monospace, "SF Mono", Consolas, monospace; font-size: .95rem; font-weight: 600; margin-top: 6px; color: var(--ink); }
.player-box .vtime { position: absolute; left: 0; right: 0; bottom: -30px; color: #fff; }

/* Player grande */
.player-modal {
  position: fixed; inset: 0; z-index: 60; background: rgba(8, 10, 12, .88);
  display: grid; place-items: center; padding: 16px; animation: fade .15s ease-out;
}
.player-box { position: relative; height: min(86vh, calc((100vw - 32px) * 16 / 9)); aspect-ratio: 9 / 16; }
.player-box video { width: 100%; height: 100%; border-radius: 16px; background: #000; display: block; }
.player-close {
  position: absolute; top: 0; right: -56px; width: 42px; height: 42px; border-radius: 50%; border: 0;
  background: rgba(255, 255, 255, .15); color: #fff; font-size: 18px; cursor: pointer;
}
.player-close:hover { background: rgba(255, 255, 255, .28); }
@media (max-width: 640px) { .player-close { right: 8px; top: 8px; background: rgba(0, 0, 0, .55); } }
@keyframes fade { from { opacity: 0; } }

.thumb-play { position: relative; padding: 0; border: 0; background: none; cursor: pointer; border-radius: 10px; display: block; }
.thumb-play img { display: block; }
.thumb-play span {
  position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-size: 22px;
  background: rgba(0, 0, 0, .25); border-radius: 10px; opacity: .85; transition: opacity .15s;
}
.thumb-play:hover span { opacity: 1; background: rgba(0, 0, 0, .4); }

.toasts { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); display: grid; gap: 8px; z-index: 50; width: min(440px, calc(100% - 32px)); }
.toast { background: var(--ink); color: var(--bg); padding: 11px 16px; border-radius: 12px; box-shadow: var(--shadow); font-weight: 500; animation: rise .2s ease-out; }
.toast.error { background: var(--danger); color: #fff; }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }

@media (max-width: 760px) {
  .topbar { padding: 10px 16px; gap: 8px; }
  .tabs { flex-basis: 100%; }
  .container { padding: 18px 16px 80px; }
  .clip { grid-template-columns: minmax(0, 1fr); padding: 14px; }
  .clip > div, .list-item > div { min-width: 0; }
  .schedule-box .row > label.field { min-width: 0; flex-basis: 100%; }
  .clip video, .clip .video-ph { max-width: 300px; margin: 0 auto; }
  .cutter { grid-template-columns: minmax(0, 1fr); }
  .cut-side { position: static; }
  .segs { max-height: 420px; }
  .seg-actions { opacity: 1; }
  .cut-times { grid-template-columns: 1fr 1fr; }
  .cut-duration { grid-column: 1 / -1; margin-top: 0; }
  .cal-day { min-height: 46px; }
  .cal-pill { font-size: 0; padding: 0; height: 6px; }
  h1 { font-size: 1.35rem; }
}
