:root {
  --bg: #0e1015;
  --card: #171a21;
  --line: #262b36;
  --ink: #e6e9ef;
  --dim: #8b93a5;
  --accent: #5b8cff;
  --ok: #3ecf8e;
  --warn: #e6b450;
  --bad: #ef6461;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 ui-sans-serif, system-ui, "Segoe UI", Roboto, sans-serif;
}

main { max-width: 880px; margin: 0 auto; padding: 24px 20px 80px; }

.topbar {
  display: flex; align-items: baseline; gap: 10px;
  padding: 14px 20px; border-bottom: 1px solid var(--line);
}
.brand { color: var(--ink); font-weight: 650; text-decoration: none; letter-spacing: -.01em; }
.brand-sub { color: var(--dim); font-size: 13px; }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px; margin-bottom: 18px;
}
.card.warn { border-color: var(--warn); }
.card.warn h2 { color: var(--warn); margin-top: 0; }
.card.bad { border-color: var(--bad); }
.card.bad h2 { color: var(--bad); margin-top: 0; }
.card.warn ul, .card.bad ul { margin: 0; padding-left: 20px; }
.card.warn li, .card.bad li { margin: 4px 0; }

h1 { font-size: 20px; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: 15px; margin: 0 0 12px; color: var(--dim); font-weight: 600;
     text-transform: uppercase; letter-spacing: .06em; }
.muted { color: var(--dim); }
em.muted { font-style: normal; }

/* ---- form ---- */
.newproject { display: flex; flex-direction: column; gap: 14px; margin-top: 16px; }

.drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; padding: 30px; text-align: center; cursor: pointer;
  border: 1.5px dashed var(--line); border-radius: var(--radius);
  transition: border-color .15s, background .15s;
}
.drop:hover, .drop.over { border-color: var(--accent); background: #5b8cff11; }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop-text { font-weight: 550; }
.drop-hint { color: var(--dim); font-size: 13px; }

.field { display: flex; flex-direction: column; gap: 5px; }
.field span { font-size: 13px; color: var(--dim); }
input[type=text] {
  background: #0f1218; border: 1px solid var(--line); border-radius: 7px;
  padding: 9px 11px; color: var(--ink); font: inherit;
}
input[type=text]:focus { outline: none; border-color: var(--accent); }

.check { display: flex; gap: 9px; align-items: flex-start; font-size: 14px; }
.check input { margin-top: 4px; accent-color: var(--accent); }

.sources { border: 1px solid var(--line); border-radius: var(--radius);
           padding: 12px 14px 14px; margin: 0; }
.sources legend { font-size: 13px; color: var(--dim); padding: 0 6px; }
.radio { display: flex; gap: 9px; align-items: flex-start; font-size: 14px;
         padding: 7px 0; cursor: pointer; }
.radio + .radio { border-top: 1px solid var(--line); }
.radio input { margin-top: 4px; accent-color: var(--accent); }
.radio span { display: flex; flex-direction: column; gap: 2px; }
.radio em.muted { font-size: 13px; line-height: 1.45; }

button, .primary {
  font: inherit; font-weight: 550; cursor: pointer;
  background: #232833; color: var(--ink);
  border: 1px solid var(--line); border-radius: 7px; padding: 8px 14px;
}
button:hover { border-color: #3a4152; background: #2a303d; }
button.primary, .primary {
  background: var(--accent); border-color: var(--accent); color: #08101f;
  text-decoration: none; display: inline-block;
}
button.primary:hover, .primary:hover { background: #6f9aff; }
button.danger:hover { border-color: var(--bad); color: var(--bad); }

/* ---- project list ---- */
.projects { list-style: none; margin: 0; padding: 0; }
.projects li + li { border-top: 1px solid var(--line); }
.projects a {
  display: grid; grid-template-columns: 1fr auto 140px 44px;
  gap: 12px; align-items: center; padding: 11px 2px;
  color: var(--ink); text-decoration: none;
}
.projects a:hover .pname { color: var(--accent); }
.pname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pct { color: var(--dim); font-size: 13px; text-align: right;
       font-variant-numeric: tabular-nums; }

/* ---- badges ---- */
.badge {
  font-size: 11px; text-transform: uppercase; letter-spacing: .07em; font-weight: 650;
  padding: 3px 8px; border-radius: 20px; border: 1px solid var(--line); color: var(--dim);
  white-space: nowrap;
}
.badge.big { font-size: 12px; padding: 5px 11px; }
.s-running  { color: var(--accent); border-color: var(--accent); }
.s-queued   { color: var(--warn);   border-color: var(--warn); }
.s-done     { color: var(--ok);     border-color: var(--ok); }
.s-failed   { color: var(--bad);    border-color: var(--bad); }
.s-canceled { color: var(--dim); }

/* ---- progress ---- */
.bar { display: block; height: 5px; background: #0f1218; border-radius: 3px; overflow: hidden; }
.bar.big { margin: 16px 0 20px; height: 6px; }
.bar i { display: block; height: 100%; background: var(--accent); transition: width .4s ease; }

/* ---- stages ---- */
.phead { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }

.stages { list-style: none; margin: 0; padding: 0; }
.stages li {
  display: grid; grid-template-columns: 18px 150px 1fr 50px;
  gap: 10px; align-items: center; padding: 7px 0; color: var(--dim);
}
.stages .tick {
  width: 9px; height: 9px; border-radius: 50%;
  border: 1.5px solid var(--line); justify-self: center;
}
.st-done .tick    { background: var(--ok);  border-color: var(--ok); }
.st-skipped .tick { background: var(--line); }
.st-failed .tick  { background: var(--bad); border-color: var(--bad); }
.st-running .tick { background: var(--accent); border-color: var(--accent);
                    animation: pulse 1.3s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; } }

.st-done .slabel, .st-running .slabel { color: var(--ink); }
.st-running .slabel { font-weight: 600; }
.sdetail { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stime { font-size: 12px; text-align: right; font-variant-numeric: tabular-nums; }

/* ---- errors, actions, log ---- */
.errbox {
  margin: 16px 0; padding: 12px 14px; border-radius: 8px;
  background: #ef646111; border: 1px solid var(--bad);
}
.errbox pre { margin: 0; white-space: pre-wrap; font-size: 13px; color: #ffb3b1;
              font-family: ui-monospace, Consolas, monospace; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.actions form { margin: 0; }

video { width: 100%; border-radius: 8px; background: #000; display: block; }
.dl { margin-top: 12px; }

.log {
  margin: 0; max-height: 340px; overflow: auto;
  background: #0b0d12; border: 1px solid var(--line); border-radius: 8px; padding: 12px;
  font: 12.5px/1.6 ui-monospace, Consolas, monospace; color: #a9b2c4;
  white-space: pre-wrap; word-break: break-word;
}

/* ---- review player ---- */
.stage {
  position: relative; aspect-ratio: 16/9; width: 100%;
  background: #000; border-radius: 8px; overflow: hidden; margin: 14px 0 10px;
}
.stage .layer {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; opacity: 0; transition: opacity .12s linear;
}
.stage .layer.on { opacity: 1; }
.stagenote {
  position: absolute; inset: 0; display: flex; align-items: center;
  justify-content: center; color: var(--dim); font-size: 13px;
  letter-spacing: .06em; text-transform: uppercase; pointer-events: none;
}
.pop {
  position: absolute; left: 0; right: 0; bottom: 12%;
  text-align: center; font-weight: 800; font-size: clamp(20px, 4.2vw, 44px);
  letter-spacing: -.01em; color: #fff; opacity: 0;
  transform: translateY(8px) scale(.96);
  transition: opacity .12s ease, transform .16s cubic-bezier(.2,1.4,.4,1);
  text-shadow: 0 3px 18px rgba(0,0,0,.85), 0 1px 3px rgba(0,0,0,.9);
  padding: 0 6%; pointer-events: none;
}
.pop.on { opacity: 1; transform: translateY(0) scale(1); }

.transport { display: flex; align-items: center; gap: 11px; }
.transport button { min-width: 74px; }
.transport input[type=range] {
  flex: 1; accent-color: var(--accent); height: 4px; cursor: pointer;
}

.nowcue { margin: 11px 0 4px; font-size: 14px; display: flex;
          flex-wrap: wrap; gap: 8px; align-items: center; min-height: 22px; }

.strip { list-style: none; display: flex; gap: 6px; overflow-x: auto;
         padding: 10px 0 4px; margin: 0; }
.strip li { flex: 0 0 92px; cursor: pointer; opacity: .6;
            transition: opacity .12s; text-align: center; }
.strip li:hover { opacity: 1; }
.strip img { width: 92px; aspect-ratio: 16/9; object-fit: cover;
             border-radius: 4px; display: block; background: #0b0d12; }
.strip span { font-size: 11px; color: var(--dim);
              font-variant-numeric: tabular-nums; }

/* ---- review page ---- */
.tiles { list-style: none; display: flex; flex-wrap: wrap; gap: 10px;
         margin: 18px 0 12px; padding: 0; }
.tiles li { flex: 1 1 110px; background: #0f1218; border: 1px solid var(--line);
            border-radius: 8px; padding: 10px 12px; }
.tiles b { display: block; font-size: 19px; letter-spacing: -.02em;
           font-variant-numeric: tabular-nums; }
.tiles span { font-size: 12px; color: var(--dim); }
.tiles li.ok b { color: var(--ok); }
.tiles li.bad b { color: var(--bad); }
.tiles li.warn b { color: var(--warn); }

.sources-line { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 0; }
.chip { font-size: 11px; letter-spacing: .04em; text-transform: uppercase;
        font-weight: 650; padding: 2px 7px; border-radius: 20px;
        border: 1px solid var(--line); color: var(--dim); white-space: nowrap; }
.s-youtube { color: #ff8a80; border-color: #ff8a8055; }
.s-pexels { color: var(--ok); border-color: #3ecf8e55; }
.s-image { color: var(--accent); border-color: #5b8cff55; }
.s-library { color: #c792ea; border-color: #c792ea55; }
.s-none { color: var(--bad); border-color: var(--bad); }
.chip.score.sc-hi { color: var(--ok); border-color: #3ecf8e55; }
.chip.score.sc-mid { color: var(--warn); border-color: #e6b45055; }
.chip.score.sc-lo { color: var(--bad); border-color: #ef646155; }

.shots { list-style: none; margin: 0; padding: 0; }
.shots li { display: grid; grid-template-columns: 160px 1fr; gap: 14px;
            padding: 12px 0; border-top: 1px solid var(--line); }
.shots li:first-child { border-top: 0; }
.shots li.noasset { opacity: .55; }
.thumb { aspect-ratio: 16/9; background: #0b0d12; border-radius: 6px;
         overflow: hidden; display: flex; align-items: center; justify-content: center; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.nothumb { font-size: 11px; color: var(--dim); text-transform: uppercase;
           letter-spacing: .06em; }
.meta { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.line1 { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; }
.tc { font-size: 12px; color: var(--dim); font-variant-numeric: tabular-nums; }
.len { font-size: 12px; color: var(--dim); margin-left: auto; }
.query { font-weight: 550; }
.shotdesc { font-size: 13px; color: #a9b2c4; }
.narr { font-size: 13px; color: var(--dim); font-style: italic;
        overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2;
        -webkit-box-orient: vertical; }

.pops { list-style: none; margin: 0; padding: 0; }
.pops li { padding: 6px 0; border-top: 1px solid var(--line);
           display: flex; gap: 10px; align-items: baseline; }
.pops li:first-child { border-top: 0; }

@media (max-width: 620px) {
  .shots li { grid-template-columns: 110px 1fr; gap: 10px; }

  .projects a { grid-template-columns: 1fr auto; }
  .projects .bar, .projects .pct { display: none; }
  .stages li { grid-template-columns: 18px 1fr 46px; }
  .stages .sdetail { grid-column: 2 / -1; }
}

/* ---- auth ---- */
.signout { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.whoami { color: var(--dim); font-size: 13px; }
.signout button {
  background: none; border: 1px solid var(--line); color: var(--dim);
  border-radius: 6px; padding: 3px 10px; font-size: 13px; cursor: pointer;
}
.signout button:hover { color: var(--ink); border-color: var(--dim); }

.login { max-width: 380px; margin: 48px auto 0; }
.login h1 { margin-bottom: 14px; }
.loginerror {
  color: var(--bad); border: 1px solid var(--bad); border-radius: 6px;
  padding: 8px 12px; margin: 0 0 4px; font-size: 14px;
}
.cmd {
  background: var(--bg); border: 1px solid var(--line); border-radius: 6px;
  padding: 10px 12px; overflow-x: auto; font-size: 13px; color: var(--ink);
}

.disk { font-size: 13px; margin: 2px 0 0; }
.lowdisk { color: var(--bad); }

/* ---- timeline editor ---- */
.ed-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.ghost {
  background: none; border: 1px solid var(--line); color: var(--dim);
  border-radius: 6px; padding: 5px 12px; font-size: 13px; cursor: pointer;
  text-decoration: none; display: inline-block;
}
.ghost:hover { color: var(--ink); border-color: var(--dim); }
.ghost.on { color: var(--ink); border-color: var(--accent); background: #1d2740; }

.ed-stage { display: grid; grid-template-columns: 1fr 300px; gap: 18px; align-items: start; }
@media (max-width: 860px) { .ed-stage { grid-template-columns: 1fr; } }
.ed-preview video { width: 100%; border-radius: 8px; background: #000; display: block; }
.ed-novideo {
  aspect-ratio: 16/9; display: grid; place-items: center; text-align: center;
  border: 1px dashed var(--line); border-radius: 8px; padding: 20px;
}
.ed-inspector { border-left: 1px solid var(--line); padding-left: 16px; min-height: 200px; }
.ed-inspector h2 { margin-top: 16px; }
.ed-inspector h2:first-child { margin-top: 0; }
.ed-when { margin: 0 0 2px; font-variant-numeric: tabular-nums; }
.ed-scene-note { margin: 0 0 10px; font-size: 13px; }
.ed-current {
  width: 100%; border-radius: 6px; display: block; margin-bottom: 10px;
  aspect-ratio: 16/9; object-fit: cover; background: var(--bg);
}
.ed-current.empty {
  display: grid; place-items: center; color: var(--dim); font-size: 13px;
  border: 1px dashed var(--line); text-align: center; padding: 8px;
}
.ed-row { display: flex; gap: 8px; margin-bottom: 10px; }
.ed-row button { flex: 1; }
.ed-slider { display: block; font-size: 13px; color: var(--dim); margin-bottom: 10px; }
.ed-slider span { color: var(--ink); font-variant-numeric: tabular-nums; }
.ed-slider input { width: 100%; margin-top: 4px; }
.ed-picker { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.ed-alt {
  aspect-ratio: 16/9; border: 2px solid transparent; border-radius: 5px;
  background-size: cover; background-position: center; cursor: pointer; padding: 0;
}
.ed-alt:hover { border-color: var(--dim); }
.ed-alt.current { border-color: var(--accent); }
.ed-alt.used { opacity: .45; }

.ed-toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; gap: 12px; }
.ed-zoom { display: flex; align-items: center; gap: 8px; }
.ed-zoom button {
  width: 28px; height: 28px; border-radius: 6px; border: 1px solid var(--line);
  background: none; color: var(--ink); cursor: pointer; font-size: 15px;
}
.ed-actions { display: flex; align-items: center; gap: 10px; }
.ed-unsaved { color: var(--warn); font-size: 13px; }

.ed-scroll { overflow-x: auto; overflow-y: hidden; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.ed-track { position: relative; height: 108px; }
.ed-scene { position: absolute; top: 0; height: 108px; border-left: 1px solid var(--line); }
.ed-scene-label {
  position: absolute; top: 2px; left: 5px; right: 4px; font-size: 10px;
  color: var(--dim); white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; pointer-events: none; z-index: 2;
}
.ed-shot {
  position: absolute; top: 18px; height: 78px; background-size: cover;
  background-position: center; border-radius: 3px; cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.55);
  /* A 1px gap so adjacent stills read as separate shots at any zoom. */
  margin-right: 1px;
}
.ed-shot.sel { box-shadow: inset 0 0 0 2px var(--accent); }
.ed-shot.empty { background: repeating-linear-gradient(45deg, #171a21, #171a21 6px, #1d212b 6px, #1d212b 12px); }
.ed-shot-badge {
  position: absolute; left: 3px; bottom: 3px; font-size: 10px;
  background: rgba(0,0,0,.62); color: #fff; padding: 1px 4px;
  border-radius: 3px; pointer-events: none; font-variant-numeric: tabular-nums;
}
.ed-grip { position: absolute; top: 0; right: -3px; width: 7px; height: 100%; cursor: col-resize; z-index: 3; }
.ed-grip:hover { background: var(--accent); opacity: .8; border-radius: 2px; }
.ed-playhead { position: absolute; top: 0; width: 2px; height: 108px; background: var(--bad); z-index: 4; pointer-events: none; }
.ed-hint { font-size: 13px; margin: 10px 0 0; }

.ed-toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: var(--card); border: 1px solid var(--line); color: var(--ink);
  padding: 10px 16px; border-radius: 8px; font-size: 14px; max-width: 560px;
  opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s; z-index: 50;
}
.ed-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.ed-toast.bad { border-color: var(--bad); color: var(--bad); }
