:root {
  color-scheme: dark;
  --bg: #0b0c0e; --surface: #15161a; --surface-2: #1d1f24; --line: #2a2c33;
  --text: #e7e8eb; --muted: #9a9ea9; --accent: #cba052;
  --btn: #e7e8eb; --btn-text: #0b0c0e;
  --ok: #4cc38a; --warn: #e0a93a; --bad: #ef6a5b;
  --sans: "Work Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --serif: "Lora", Georgia, "Times New Roman", serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html { font-size: 16px; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.5 var(--sans); }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; margin: 0; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
.muted, .hint { color: var(--muted); }
.hint { font-size: 16px; }
.error { color: var(--bad); font-weight: 600; }
.eyebrow { text-transform: uppercase; letter-spacing: .06em; font-size: 16px; font-weight: 600; color: var(--muted); }

/* top bar */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 24px; background: #000; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.brand { font-family: var(--serif); font-size: 1.5rem; font-weight: 600; text-decoration: none; }
.brand small { font: 16px var(--sans); color: var(--muted); margin-left: 10px; }
.topright { display: flex; align-items: center; gap: 12px; position: relative; }
.pill { display: flex; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 2px; }
.stat { position: relative; background: none; border: 0; border-radius: 999px; padding: 6px 14px; color: var(--text); display: inline-flex; align-items: center; gap: 6px; }
.stat:hover, .stat:focus-visible { background: var(--surface-2); }
.stat b { font-weight: 600; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ok); display: inline-block; }
.dot.warn { background: var(--warn); } .dot.bad { background: var(--bad); }
.linkbtn { background: none; border: 0; color: var(--muted); text-decoration: underline; padding: 4px; }
.linkbtn:hover { color: var(--text); }

/* hover details */
.tip { display: none; position: absolute; top: calc(100% + 10px); left: 0; width: 280px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; text-align: left; font-weight: 400; box-shadow: 0 10px 30px rgba(0,0,0,.6); z-index: 30; }
.stat:last-child .tip { left: auto; right: 0; }
.stat:hover .tip, .stat:focus-visible .tip { display: block; }
.tip .tt { font-family: var(--serif); font-weight: 600; margin-bottom: 4px; }
.tip .kv { font-size: 16px; }

/* activity panel */
.panel { position: absolute; right: 0; top: 52px; width: min(460px, calc(100vw - 32px)); max-height: calc(100vh - 80px); overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 14px 40px rgba(0,0,0,.7); padding: 8px 20px 16px; display: none; z-index: 25; }
.panel.open { display: block; }
.panel h3 { font-size: 1.1rem; margin-bottom: 6px; }
.panel section { padding: 14px 0; border-top: 1px solid var(--line); }
.panel section:first-of-type { border-top: 0; }
.meter { height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; margin: 6px 0 8px; }
.meter i { display: block; height: 100%; background: var(--text); opacity: .85; }
.meter i.warn { background: var(--warn); opacity: 1; } .meter i.bad { background: var(--bad); opacity: 1; }
.kv { display: flex; justify-content: space-between; gap: 12px; }
.kv span:first-child { color: var(--muted); }
.kv span:last-child { text-align: right; }
.ok { color: var(--ok); } .warnc { color: var(--warn); } .badc { color: var(--bad); }

/* layout */
.shell { display: grid; grid-template-columns: 320px 1fr; gap: 24px; padding: 24px; max-width: 1500px; margin: 0 auto; }
@media (max-width: 900px) { .shell { grid-template-columns: 1fr; padding: 16px; } .topbar { padding: 10px 16px; flex-wrap: wrap; } .stat { padding: 6px 10px; } }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 16px; }
.btn { background: var(--btn); color: var(--btn-text); border: 0; border-radius: 6px; padding: 10px 18px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.btn:hover { background: #fff; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.drop { border: 1px dashed #3a3d46; border-radius: 8px; padding: 16px; text-align: center; margin-bottom: 20px; background: var(--surface); }
.drop.over { background: var(--surface-2); border-color: var(--text); }
.vlist { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.vitem { display: grid; grid-template-columns: 64px 1fr; gap: 12px; padding: 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); text-align: left; width: 100%; color: var(--text); }
.vitem:hover { background: var(--surface-2); }
.vitem.active { border-color: var(--text); }
.vitem img, .vitem .ph { width: 64px; height: 40px; object-fit: cover; border-radius: 4px; background: var(--surface-2); }
.vitem .t { font-weight: 600; overflow-wrap: anywhere; }
.badge { text-transform: uppercase; font-size: 16px; font-weight: 600; letter-spacing: .04em; }
.badge.ready { color: var(--ok); } .badge.queued, .badge.processing { color: var(--warn); } .badge.failed { color: var(--bad); }

/* player */
.stage { background: #000; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); }
video { width: 100%; max-height: 66vh; display: block; background: #000; }
.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 12px 0; }
.tc { font: 600 1.25rem var(--mono); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 4px 12px; min-width: 150px; text-align: center; }
.ctl { background: var(--surface); border: 1px solid #3a3d46; color: var(--text); border-radius: 6px; padding: 8px 14px; font-weight: 600; }
.ctl:hover { background: var(--surface-2); border-color: var(--text); }
.track { position: relative; height: 34px; background: var(--surface-2); border-radius: 6px; cursor: pointer; margin: 10px 0 4px; }
.track .fill { position: absolute; left: 0; top: 0; bottom: 0; background: rgba(231,232,235,.16); border-radius: 6px 0 0 6px; pointer-events: none; }
.track .head { position: absolute; top: -3px; bottom: -3px; width: 3px; background: var(--text); pointer-events: none; }
.track .mark { position: absolute; top: 5px; bottom: 5px; width: 8px; margin-left: -4px; background: var(--accent); border: 0; border-radius: 3px; padding: 0; }
.track .mark.done { background: #5b5f6a; }

/* comments */
.comments { margin-top: 16px; display: grid; gap: 16px; grid-template-columns: 1fr; }
.cform textarea { width: 100%; min-height: 84px; padding: 10px; border: 1px solid #3a3d46; border-radius: 6px; background: var(--bg); }
.cform textarea:focus, .cform input:focus { border-color: var(--text); }
.cform .row { display: flex; gap: 10px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
.cform input { padding: 8px 10px; border: 1px solid #3a3d46; border-radius: 6px; background: var(--bg); width: 200px; }
.clist { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.citem { display: grid; grid-template-columns: 120px 1fr auto; gap: 12px; align-items: start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.citem.done { opacity: .55; }
.citem .when { font: 600 16px var(--mono); color: var(--accent); background: none; border: 0; text-align: left; padding: 0; text-decoration: underline; }
.citem .by { font-weight: 600; }
.citem p { margin: 2px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.empty { padding: 48px 16px; text-align: center; color: var(--muted); }
.empty h2 { color: var(--text); margin-bottom: 8px; }
.progress { height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; margin-top: 10px; display: none; }
.progress i { display: block; height: 100%; width: 0; background: var(--text); }

/* login */
body.login { display: grid; place-items: center; min-height: 100vh; }
.login-box { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 32px; width: min(420px, calc(100vw - 32px)); }
.login-box h1 { font-size: 2rem; margin-bottom: 4px; }
.login-box label { display: block; font-weight: 600; margin: 20px 0 6px; }
.login-box input { width: 100%; padding: 10px; border: 1px solid #3a3d46; border-radius: 6px; background: var(--bg); }
.login-box button { margin-top: 16px; width: 100%; background: var(--btn); color: var(--btn-text); border: 0; border-radius: 6px; padding: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.sr { position: absolute; left: -9999px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

select, .cform input, #newproj { background: var(--bg); border: 1px solid #3a3d46; border-radius: 6px; padding: 8px 10px; color: var(--text); }
select { width: 100%; margin-top: 6px; }
#mvproj { width: auto; margin-top: 0; min-width: 180px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
#newproj { flex: 1; min-width: 0; }
select:focus, #newproj:focus { border-color: var(--text); }


/* player layout: landscape stacks, vertical video puts the player on the left and comments on the right */
.vwrap { position: relative; line-height: 0; }
#overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
#vgrid { display: block; }
#vgrid.portrait { --ph: max(600px, calc(100vh - 335px)); display: grid; grid-template-columns: calc(var(--ph) * var(--ar, 0.5625)) minmax(320px, 1fr); gap: 24px; align-items: start; }
#vgrid.portrait .vwrap { aspect-ratio: var(--ar, 0.5625); }
#vgrid.portrait video { width: 100%; height: 100%; max-height: none; object-fit: contain; }
#vgrid.portrait .rcol { position: sticky; top: 72px; max-height: calc(100vh - 90px); overflow: auto; padding-right: 4px; }
#vgrid.portrait .comments { margin-top: 0; }
#vgrid.portrait .obar { margin-bottom: 16px; }
.obtns { display: flex; flex-wrap: wrap; gap: 8px; }
.obtns button { display: inline-flex; align-items: center; gap: 8px; background: var(--surface-2); border: 1px solid #3a3d46; border-radius: 6px; padding: 8px 12px; color: var(--text); font-weight: 600; }
.obtns button svg { width: 20px; height: 20px; fill: currentColor; }
.obtns button[aria-pressed="true"] { background: var(--btn); color: var(--btn-text); border-color: var(--btn); }
.obtns button:disabled { opacity: .4; cursor: not-allowed; }
.chk { display: inline-flex; align-items: center; gap: 6px; }
.chk input { width: 18px; height: 18px; accent-color: var(--text); }
@media (max-width: 1100px) {
  #vgrid.portrait { grid-template-columns: 1fr; }
  #vgrid.portrait .vcol { max-width: calc(var(--ph) * var(--ar, 0.5625)); margin: 0 auto; width: 100%; }
  #vgrid.portrait .rcol { position: static; max-height: none; }
}

.vhead { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin: 0 0 12px; }
.vhead select { width: auto; margin-top: 0; min-width: 160px; padding: 6px 10px; }
@media (max-width: 700px) {
  .topbar { gap: 8px; }
  .topright { width: 100%; flex-wrap: wrap; gap: 8px; }
  .pill { flex: 1 1 100%; justify-content: space-between; }
  .stat { white-space: nowrap; padding: 6px 10px; }
  .shell { padding: 12px; }
}

/* minimal icon controls, one row */
.controls { display: flex; flex-wrap: nowrap; align-items: center; justify-content: space-between; gap: 2px; margin: 10px 0; }
.ic { width: 38px; height: 38px; flex: 0 0 auto; display: inline-grid; place-items: center; padding: 0; border-radius: 8px; background: transparent; border: 1px solid transparent; color: var(--text); text-decoration: none; }
.ic:hover { background: var(--surface-2); border-color: #3a3d46; }
.ic svg { width: 22px; height: 22px; fill: currentColor; display: block; }
.ic.primary { background: var(--btn); color: var(--btn-text); border-radius: 50%; width: 42px; height: 42px; }
.ic.primary:hover { background: #fff; }
.ic .i-pause { display: none; } .ic.on .i-pause { display: inline-grid; } .ic.on .i-play { display: none; }
.controls .tc { font: 600 1rem var(--mono); min-width: 0; padding: 4px 8px; border-radius: 6px; flex: 0 0 auto; }
.bigplay { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 88px; height: 88px; border-radius: 50%; display: grid; place-items: center; padding: 0; background: rgba(0,0,0,.55); border: 2px solid rgba(255,255,255,.85); color: #fff; cursor: pointer; z-index: 3; }
.bigplay:hover { background: rgba(0,0,0,.78); }
.bigplay[hidden] { display: none; }
.bigplay svg { width: 44px; height: 44px; fill: currentColor; margin-left: 5px; }
.speedpill { position: absolute; left: 10px; top: 10px; z-index: 3; background: rgba(0,0,0,.65); color: #fff; font: 600 16px/1 var(--sans); padding: 6px 12px; border-radius: 999px; pointer-events: none; }
.speedpill:empty { display: none; }
.vwrap video { cursor: pointer; }

.track .pmark { position: absolute; top: -4px; bottom: -4px; width: 12px; margin-left: -6px; border: 2px solid var(--accent); border-radius: 4px; background: rgba(203,160,82,.35); pointer-events: none; }
.track .pmark[hidden] { display: none; }
.keyhint { margin-left: 8px; padding: 1px 8px; border: 1px solid #3a3d46; border-radius: 6px; color: var(--muted); font-weight: 500; text-transform: none; letter-spacing: 0; }

.versrow { margin: 0; gap: 8px; }
.versrow .ctl { padding: 6px 12px; }
.obtns button.ver { padding: 6px 10px; }
.obtns button.ver { min-width: 52px; justify-content: center; position: relative; }
.obtns button.ver.ap-approved::after, .obtns button.ver.ap-changes::after { content: ""; position: absolute; top: 4px; right: 4px; width: 8px; height: 8px; border-radius: 50%; }
.obtns button.ver.ap-approved::after { background: var(--ok); }
.obtns button.ver.ap-changes::after { background: var(--warn); }
.ap-approved { color: var(--ok); } .ap-changes { color: var(--warn); }
#apcard { margin-bottom: 16px; }

.brand { display: inline-flex; align-items: center; gap: 10px; }
.brand-mark { width: 30px; height: 30px; display: block; }
.foot { max-width: 1500px; margin: 0 auto; padding: 8px 24px 28px; display: flex; gap: 16px; justify-content: flex-end; color: var(--muted); font-size: 16px; }
.foot a { color: var(--muted); }
.foot a:hover { color: var(--text); }
