:root {
  --bg: #0e0e0f;
  --surface: #17171a;
  --surface-2: #1f1f23;
  --line: #2a2a2f;
  --text: #ededee;
  --muted: #8b8b92;
  --accent: #f2b544;
  --accent-ink: #1a1405;
  --ok: #5cc28a;
  --danger: #ef6a5b;
  --radius: 10px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 Inter, system-ui, -apple-system, Segoe UI, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
.num { font-variant-numeric: tabular-nums; }

/* top bar */
.bar {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 20px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: rgba(14,14,15,.92); backdrop-filter: blur(8px); z-index: 5;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -.01em; }
.brand-mark { width: 26px; height: 26px; border-radius: 7px; background: #111; border: 1px solid var(--line); display: grid; place-items: center; }
.brand-mark svg { width: 12px; height: 12px; }
.bar .spacer { flex: 1; }
.crumb { color: var(--muted); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--line); background: var(--surface-2);
  padding: 8px 14px; border-radius: 8px; cursor: pointer; font-weight: 500; white-space: nowrap;
}
.btn:hover { border-color: #3a3a41; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.05); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--surface-2); }
.btn.small { padding: 4px 9px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
.name-input { width: 84px; background: transparent; border: 1px solid transparent; border-radius: 6px; padding: 4px 6px; color: var(--muted); text-align: right; }
.name-input:hover, .name-input:focus { border-color: var(--line); color: var(--text); outline: none; }


/* library */
.library { padding: 24px 20px 60px; max-width: 1400px; margin: 0 auto; }
.library h1 { font-size: 22px; margin: 0 0 18px; letter-spacing: -.01em; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 18px; }
.card { display: grid; gap: 10px; cursor: pointer; }
.thumb {
  aspect-ratio: 4 / 5; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; display: grid; place-items: center; position: relative;
}
.thumb img { width: 100%; height: 100%; object-fit: contain; }
.thumb .play { color: #3a3a41; width: 36px; height: 36px; }
.card:hover .thumb { border-color: #45454d; }
.pill {
  position: absolute; top: 8px; right: 8px; background: rgba(0,0,0,.7); color: var(--text);
  font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 999px;
}
.pill.open { background: var(--accent); color: var(--accent-ink); }
.pill.left { right: auto; left: 8px; }
.card-title { font-weight: 600; line-height: 1.3; }
.card-meta { color: var(--muted); font-size: 13px; }
.empty { border: 1px dashed var(--line); border-radius: 14px; padding: 60px 20px; text-align: center; color: var(--muted); }
.empty strong { color: var(--text); display: block; font-size: 17px; margin-bottom: 6px; }

/* drop overlay */
.drop { position: fixed; inset: 0; background: rgba(14,14,15,.85); border: 2px dashed var(--accent); display: none; place-items: center; z-index: 30; font-size: 20px; font-weight: 600; }
body.dragging .drop { display: grid; }

/* modal */
.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: grid; place-items: center; z-index: 40; padding: 16px; }
.modal { width: min(460px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 22px; display: grid; gap: 14px; }
.modal h2 { margin: 0; font-size: 18px; }
.modal label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.modal .row { display: flex; gap: 10px; justify-content: flex-end; }
.file-pick { border: 1px dashed var(--line); border-radius: 10px; padding: 18px; text-align: center; color: var(--muted); cursor: pointer; }
.file-pick:hover { border-color: var(--accent); color: var(--text); }
.progress { height: 6px; background: var(--bg); border-radius: 99px; overflow: hidden; }
.progress > div { height: 100%; width: 0; background: var(--accent); transition: width .2s; }

/* review page */
.review { display: grid; grid-template-columns: minmax(0, 1fr) 400px; overflow: hidden; }
@media (min-width: 901px) {
  #app:has(.review) { height: 100vh; display: flex; flex-direction: column; }
  .review { flex: 1; min-height: 0; }
}
.stage, .panel { min-height: 0; }
.stage { display: flex; flex-direction: column; min-width: 0; padding: 16px 20px; gap: 12px; }
.player-wrap { flex: 1; min-height: 0; display: grid; place-items: center; background: #000; border-radius: var(--radius); overflow: hidden; position: relative; }
.player-wrap video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; display: block; }
.overlay-note {
  position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%);
  background: rgba(0,0,0,.78); padding: 8px 12px; border-radius: 8px; max-width: 80%;
  font-size: 14px; pointer-events: none; opacity: 0; transition: opacity .15s;
}
.overlay-note.show { opacity: 1; }
.overlay-note b { color: var(--accent); font-weight: 600; margin-right: 6px; }

.transport { display: flex; align-items: center; gap: 12px; }
.icon-btn { width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface-2); display: grid; place-items: center; cursor: pointer; flex: none; }
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn:hover { border-color: #3a3a41; }
.time { color: var(--muted); font-size: 13px; min-width: 120px; }
.timeline { flex: 1; position: relative; height: 36px; cursor: pointer; }
.timeline .track { position: absolute; left: 0; right: 0; top: 16px; height: 4px; background: var(--surface-2); border-radius: 99px; }
.timeline .fill { position: absolute; left: 0; top: 16px; height: 4px; background: #d9d9dc; border-radius: 99px; pointer-events: none; }
.timeline .head { position: absolute; top: 10px; width: 2px; height: 16px; background: #fff; margin-left: -1px; pointer-events: none; }
.marker {
  position: absolute; top: 2px; width: 12px; height: 12px; margin-left: -6px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--bg); cursor: pointer; z-index: 2;
}
.marker.resolved { background: #55555c; }
.marker.active, .marker:hover { transform: scale(1.3); }
.speed { background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; }

.versions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.versions a { padding: 4px 10px; border-radius: 99px; border: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.versions a.on { background: var(--text); color: var(--bg); border-color: var(--text); font-weight: 600; }

.panel { border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; background: var(--surface); }
.composer { padding: 14px 16px; border-bottom: 1px solid var(--line); display: grid; gap: 8px; }
.composer-head { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.stamp { background: var(--accent); color: var(--accent-ink); font-weight: 700; padding: 2px 8px; border-radius: 6px; font-size: 13px; }
.stamp.general { background: var(--surface-2); color: var(--muted); }
.composer textarea { resize: none; min-height: 64px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.composer textarea:focus { outline: none; border-color: var(--accent); }
.composer .hint { font-size: 12px; color: var(--muted); }
.filters { display: flex; gap: 4px; padding: 10px 16px; border-bottom: 1px solid var(--line); align-items: center; }
.filters button { background: none; border: 0; padding: 4px 10px; border-radius: 6px; color: var(--muted); cursor: pointer; font-size: 13px; font-weight: 500; }
.filters button.on { background: var(--surface-2); color: var(--text); }
.notes { overflow-y: auto; flex: 1; padding: 6px 0 40px; }
.note { padding: 12px 16px; display: grid; gap: 6px; border-bottom: 1px solid #222226; }
.note.active { background: var(--surface-2); }
.note.resolved .note-body { color: var(--muted); text-decoration: line-through; text-decoration-color: #55555c; }
.note-top { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.note-top .tc { background: var(--surface-2); color: var(--accent); font-weight: 700; padding: 2px 8px; border-radius: 6px; cursor: pointer; border: 0; }
.note.resolved .tc { color: var(--muted); }
.note-top .who { font-weight: 600; }
.note-top .when { color: var(--muted); }
.note-top .spacer { flex: 1; }
.note-body { white-space: pre-wrap; word-wrap: break-word; }
.note-actions { display: flex; gap: 2px; margin-left: -9px; }
.check { width: 22px; height: 22px; border-radius: 6px; border: 1.5px solid #4a4a52; background: none; cursor: pointer; display: grid; place-items: center; padding: 0; }
.check svg { width: 13px; height: 13px; opacity: 0; }
.check.on { background: var(--ok); border-color: var(--ok); }
.check.on svg { opacity: 1; }
.replies { display: grid; gap: 8px; margin: 4px 0 0 14px; }
.reply { font-size: 14px; display: grid; gap: 2px; }
.reply .who { font-weight: 600; font-size: 13px; }
.reply .when { color: var(--muted); font-size: 12px; font-weight: 400; margin-left: 6px; }
.reply-box { display: flex; gap: 6px; margin-left: 14px; }
.reply-box input { flex: 1; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; font-size: 14px; }
.reply-box input:focus { outline: none; border-color: var(--accent); }
.no-notes { color: var(--muted); padding: 30px 16px; text-align: center; font-size: 14px; }
.keys { padding: 10px 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; display: flex; flex-wrap: wrap; gap: 4px 12px; }
kbd { background: var(--surface-2); border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; font: inherit; font-size: 11px; color: var(--text); }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 8px 14px; border-radius: 8px; font-weight: 500; z-index: 50; }

@media (max-width: 900px) {
  .review { grid-template-columns: 1fr; height: auto; }
  .player-wrap { height: 62vh; flex: none; }
  .panel { border-left: 0; border-top: 1px solid var(--line); }
  .notes { overflow: visible; }
  .keys { display: none; }
  .bar { padding: 10px 16px; }
  .library { padding: 18px 16px 60px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
  .time { min-width: 0; }
}

.field { width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; color: var(--text); }
.field:focus { outline: none; border-color: var(--accent); }
.error { color: var(--danger); font-size: 14px; }
