:root {
  --bg: #121216;
  --panel: #1b1b21;
  --panel-2: #24242c;
  --line: #2f2f39;
  --text: #ececf1;
  --muted: #9a9aa8;
  --accent: #e8476a;
  --accent-2: #ff6f8e;
  --ok: #3fbf7f;
  --warn: #f0b23c;
  --radius: 12px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { min-height: 100vh; }
a { color: var(--accent-2); text-decoration: none; }
button, .btn, select, input, textarea { font: inherit; color: inherit; }
button, .btn { cursor: pointer; border: 1px solid var(--line); background: var(--panel-2); border-radius: 8px; padding: 8px 14px; display: inline-flex; align-items: center; gap: 6px; }
button:hover, .btn:hover { border-color: #4a4a57; }
.primary { background: var(--accent); border: 1px solid var(--accent); color: #fff; border-radius: 8px; padding: 9px 16px; font-weight: 600; cursor: pointer; }
.primary:hover { background: var(--accent-2); }
.ghost { background: transparent; }
.small { font-size: 13px; padding: 5px 10px; }
.danger { color: #ff7b7b; }
.muted { color: var(--muted); }
.err { color: #ff7b7b; min-height: 1.2em; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
select { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; }
input[type=password], input[type=text], textarea { width: 100%; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; outline: none; }
input:focus, textarea:focus { border-color: var(--accent); }

.top { display: flex; align-items: center; justify-content: space-between; padding: 12px 20px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: rgba(18,18,22,.92); backdrop-filter: blur(8px); z-index: 5; }
.brand { color: var(--text); font-weight: 700; font-size: 18px; display: flex; align-items: center; gap: 10px; }
.logo { background: var(--accent); color: #fff; width: 28px; height: 28px; border-radius: 7px; display: grid; place-items: center; font-size: 13px; }
.top-right { display: flex; gap: 8px; }
main { padding: 20px; max-width: 1500px; margin: 0 auto; }

.login { max-width: 380px; margin: 12vh auto; padding: 28px; }
.login h1 { margin-top: 0; }
.login form { display: flex; flex-direction: column; gap: 12px; }

.list-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.list-head h1 { margin: 0 0 4px; }
.upload-btn { display: inline-flex; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.tile { display: block; color: var(--text); overflow: hidden; transition: transform .12s, border-color .12s; }
.tile:hover { transform: translateY(-2px); border-color: #4a4a57; }
.thumb { aspect-ratio: 16/10; background: #000; position: relative; overflow: hidden; }
.thumb video { width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.tile-body { padding: 12px 14px; }
.tile-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-meta { font-size: 13px; color: var(--muted); margin-top: 4px; display: flex; gap: 10px; flex-wrap: wrap; }
.pill { position: absolute; top: 8px; left: 8px; font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 99px; background: rgba(0,0,0,.65); }
.pill.changes { color: var(--warn); }
.pill.approved { color: var(--ok); }
.pill.open { color: var(--text); }
.count { position: absolute; top: 8px; right: 8px; font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 99px; background: var(--accent); color: #fff; }
.empty { text-align: center; padding: 60px 0; }

.up-row { padding: 12px 14px; margin-bottom: 10px; }
.up-row .bar { height: 6px; background: var(--panel-2); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.up-row .bar div { height: 100%; width: 0; background: var(--accent); transition: width .2s; }

.viewer { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 20px; align-items: start; }
.crumbs { display: flex; gap: 12px; align-items: center; margin-bottom: 10px; }
.v-title { font-weight: 700; font-size: 18px; outline: none; border-bottom: 1px dashed transparent; }
.v-title:focus { border-bottom-color: var(--muted); }
.stage { position: relative; background: #000; border-radius: var(--radius); overflow: hidden; display: flex; justify-content: center; max-height: 72vh; }
.stage video { max-width: 100%; max-height: 72vh; display: block; }
#ink { position: absolute; pointer-events: none; }
.stage.drawing #ink { pointer-events: auto; cursor: crosshair; }
.draw-hint { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); background: rgba(0,0,0,.7); padding: 5px 12px; border-radius: 99px; font-size: 13px; }

.timeline { position: relative; height: 26px; margin-top: 10px; cursor: pointer; }
.timeline::before { content: ""; position: absolute; left: 0; right: 0; top: 11px; height: 4px; background: var(--panel-2); border-radius: 99px; }
.tl-buffer, .tl-progress { position: absolute; left: 0; top: 11px; height: 4px; border-radius: 99px; }
.tl-buffer { background: #3a3a46; }
.tl-progress { background: var(--accent); }
.tl-head { position: absolute; top: 6px; width: 14px; height: 14px; margin-left: -7px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 3px rgba(232,71,106,.4); }
.tl-markers { position: absolute; inset: 0; }
.marker { position: absolute; top: 0; width: 10px; height: 10px; margin-left: -5px; border-radius: 50%; background: var(--warn); border: 2px solid var(--bg); }
.marker.done { background: var(--ok); }
.marker:hover { transform: scale(1.4); }

.controls { display: flex; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.icon { width: 40px; height: 36px; justify-content: center; padding: 0; }
.icon.small { width: 34px; }
.tc { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 14px; margin: 0 6px; }
.spacer { flex: 1; }

.side { position: sticky; top: 72px; display: flex; flex-direction: column; gap: 12px; max-height: calc(100vh - 92px); }
.composer { padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.comp-top, .comp-bottom { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.comp-top { justify-content: flex-start; }
.badge { background: var(--accent); color: #fff; font-weight: 700; font-size: 13px; padding: 3px 9px; border-radius: 6px; font-variant-numeric: tabular-nums; }
#drawBtn.on { border-color: var(--accent); color: var(--accent-2); }
textarea { resize: vertical; min-height: 70px; }
.side-head { display: flex; align-items: center; justify-content: space-between; }
.side-head h2 { font-size: 15px; margin: 0; }
.comments { list-style: none; margin: 0; padding: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.cm { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; cursor: pointer; }
.cm:hover { border-color: #4a4a57; }
.cm.active { border-color: var(--accent); }
.cm.done { opacity: .55; }
.cm.done .cm-text { text-decoration: line-through; }
.cm-head { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.cm-time { color: var(--accent-2); font-weight: 700; font-variant-numeric: tabular-nums; }
.cm-author { color: var(--muted); }
.cm-ink { font-size: 12px; color: var(--warn); }
.cm-text { margin-top: 6px; white-space: pre-wrap; word-break: break-word; line-height: 1.4; }
.cm-actions { display: flex; gap: 6px; margin-top: 8px; }
.cm-actions button { font-size: 12px; padding: 3px 8px; }

@media (max-width: 960px) {
  .viewer { grid-template-columns: 1fr; }
  .side { position: static; max-height: none; }
}
@media (max-width: 600px) {
  main { padding: 16px; }
  .list-head { flex-direction: column; align-items: stretch; }
}
