:root {
  --bg: #1b1d22;
  --panel: #22252b;
  --panel-2: #282c33;
  --elev: #2d3139;
  --border: #2e323a;
  --border-2: #3a3f49;
  --text: #e8eaed;
  --muted: #9aa0ab;
  --faint: #6b7280;
  --accent: #5b63f5;
  --accent-hover: #6b72ff;
  --accent-soft: rgba(91, 99, 245, 0.16);
  --danger: #e05260;
  --good: #46c98b;
  --radius: 8px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 16px;
  height: 56px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}
.brand { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.brand .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); flex: 0 0 auto; align-self: center; }
.clipName {
  font-size: 14px; font-weight: 600; letter-spacing: 0.2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 320px;
}
.clipName.placeholder { color: var(--faint); font-weight: 500; }

.versionPicker { display: flex; align-items: center; gap: 8px; }
.versionPicker .label { color: var(--muted); font-size: 12px; }
select.vselect {
  appearance: none;
  background: var(--panel-2) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path d='M3 4.5L6 7.5L9 4.5' stroke='%239aa0ab' stroke-width='1.3' fill='none' stroke-linecap='round'/></svg>") no-repeat right 10px center;
  border: 1px solid var(--border-2);
  color: var(--text);
  border-radius: var(--radius);
  padding: 8px 30px 8px 12px;
  font-size: 13px;
  min-width: 240px;
  cursor: pointer;
}
select.vselect:hover { border-color: var(--accent); }

.spacer { flex: 1 1 auto; }

.ghost-btn {
  background: transparent; color: var(--muted);
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  padding: 8px 12px; font-size: 13px; cursor: pointer;
  transition: all .12s;
}
.ghost-btn:hover { color: var(--text); border-color: var(--accent); background: var(--panel-2); }

/* teach toggle switch */
.switch { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; user-select: none; font-size: 12px; color: var(--muted); }
.switch input { display: none; }
.switch .track { width: 36px; height: 20px; border-radius: 20px; background: var(--elev); border: 1px solid var(--border-2); position: relative; transition: background .15s, border-color .15s; flex: 0 0 auto; }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--muted); transition: transform .15s, background .15s; }
.switch input:checked + .track { background: var(--accent-soft); border-color: var(--accent); }
.switch input:checked + .track::after { transform: translateX(16px); background: var(--accent); }

.primary-btn {
  background: var(--accent); color: #fff; border: none;
  border-radius: var(--radius); padding: 9px 16px; font-size: 13px; font-weight: 600;
  cursor: pointer; transition: background .12s;
}
.primary-btn:hover { background: var(--accent-hover); }
.primary-btn:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- Main grid ---------- */
.main { display: flex; flex: 1 1 auto; min-height: 0; }

.stage {
  flex: 1 1 auto; min-width: 0;
  display: flex; flex-direction: column;
  padding: 20px 22px; gap: 16px;
}

.videoWrap {
  position: relative; flex: 1 1 auto; min-height: 0;
  background: #000; border: 1px solid var(--border);
  border-radius: 10px; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
video { max-width: 100%; max-height: 100%; display: block; }
#pinLayer { position: absolute; inset: 0; pointer-events: none; }
#pinLayer.arming { pointer-events: auto; cursor: crosshair; }
.pinDot {
  position: absolute; width: 24px; height: 24px; margin: -12px 0 0 -12px;
  border: 2px solid var(--accent); border-radius: 50%;
  background: var(--accent-soft); box-shadow: 0 0 0 2px rgba(0,0,0,.55);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 11px; font-weight: 700;
}
.dropHint { color: var(--muted); text-align: center; padding: 40px; }
.dropHint strong { color: var(--text); }
.dropHint .hint { color: var(--faint); font-size: 12px; }

/* transport */
.transport { display: flex; align-items: center; gap: 12px; flex: 0 0 auto; }
.tbtn {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--border-2);
  border-radius: var(--radius); height: 38px; min-width: 42px; padding: 0 12px;
  font-size: 14px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: all .12s;
}
.tbtn:hover { border-color: var(--accent); background: var(--elev); }
.tbtn:disabled { opacity: .4; cursor: not-allowed; }
.tbtn.play { background: var(--accent); border-color: var(--accent); color: #fff; min-width: 54px; font-weight: 600; }
.tbtn.play:hover { background: var(--accent-hover); }
.tbtn.active { border-color: var(--accent); color: var(--accent); }

.timecode {
  font-variant-numeric: tabular-nums;
  font-size: 20px; font-weight: 600; letter-spacing: 0.5px;
  min-width: 118px; text-align: center;
}
.timecode .frames { color: var(--accent); }
.timecode .dur { color: var(--faint); font-size: 13px; font-weight: 500; }

.fpsField { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; margin-left: auto; }
.fpsField input {
  width: 68px; background: var(--panel-2); border: 1px solid var(--border-2);
  color: var(--text); border-radius: 6px; padding: 7px 8px; font-size: 12px; font-variant-numeric: tabular-nums;
}

/* ---------- Timeline (Frame.io signature) ---------- */
.timeline-wrap { flex: 0 0 auto; padding-top: 2px; }
.timeline {
  position: relative; height: 26px; cursor: pointer;
  display: flex; align-items: center;
}
.timeline .track {
  position: absolute; left: 0; right: 0; top: 50%; transform: translateY(-50%);
  height: 6px; border-radius: 6px; background: var(--elev);
}
.timeline .progress {
  position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  height: 6px; border-radius: 6px; background: var(--accent); width: 0%;
}
.timeline .playhead {
  position: absolute; top: 50%; width: 14px; height: 14px; margin-left: -7px;
  transform: translateY(-50%); border-radius: 50%; background: #fff;
  box-shadow: 0 0 0 3px rgba(91,99,245,.4); left: 0%; pointer-events: none;
}
.timeline .marker {
  position: absolute; top: 50%; width: 11px; height: 11px; margin-left: -5.5px;
  transform: translateY(-50%); border-radius: 50%;
  background: var(--good); border: 2px solid var(--bg); cursor: pointer; z-index: 2;
  transition: transform .1s;
}
.timeline .marker:hover { transform: translateY(-50%) scale(1.35); }
.tl-tooltip {
  position: fixed; z-index: 60; background: var(--elev); color: var(--text);
  border: 1px solid var(--border-2); border-radius: 6px; padding: 6px 10px;
  font-size: 12px; max-width: 240px; pointer-events: none; opacity: 0;
  transform: translate(-50%, -8px); transition: opacity .1s; box-shadow: 0 6px 20px rgba(0,0,0,.4);
}
.tl-tooltip.show { opacity: 1; }
.tl-tooltip .tt-ts { color: var(--accent); font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- Comments sidebar ---------- */
.sidebar {
  flex: 0 0 362px; width: 362px;
  border-left: 1px solid var(--border); background: var(--panel);
  display: flex; flex-direction: column; min-height: 0;
}
.side-head {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 18px; border-bottom: 1px solid var(--border); flex: 0 0 auto;
}
.side-head h2 { margin: 0; font-size: 14px; font-weight: 600; }
.badge {
  background: var(--elev); color: var(--muted); border-radius: 20px;
  padding: 1px 9px; font-size: 12px; font-variant-numeric: tabular-nums;
}
.side-head .mini-acts { margin-left: auto; display: flex; gap: 6px; }
.mini-btn {
  background: transparent; color: var(--faint); border: 1px solid transparent;
  border-radius: 6px; padding: 5px 9px; font-size: 12px; cursor: pointer;
}
.mini-btn:hover { color: var(--text); border-color: var(--border-2); }
.mini-btn.danger:hover { color: var(--danger); border-color: var(--danger); }

.list { flex: 1 1 auto; overflow-y: auto; padding: 10px 12px; }
.list .empty { color: var(--faint); text-align: center; padding: 40px 18px; font-size: 13px; }

.card {
  border: 1px solid var(--border); border-radius: 10px; padding: 12px;
  margin-bottom: 10px; background: var(--panel-2); cursor: pointer; transition: border-color .12s;
}
.card:hover { border-color: var(--border-2); }
.card .row1 { display: flex; align-items: center; gap: 8px; margin-bottom: 7px; }
.ts-chip {
  background: var(--accent-soft); color: var(--accent); border-radius: 6px;
  padding: 2px 9px; font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums;
  cursor: pointer; border: 1px solid transparent;
}
.ts-chip:hover { border-color: var(--accent); }
.pin-ind { color: var(--muted); font-size: 11px; display: inline-flex; align-items: center; gap: 3px; }
.card .acts { margin-left: auto; display: flex; gap: 4px; opacity: 0; transition: opacity .1s; }
.card:hover .acts { opacity: 1; }
.card .acts button { background: transparent; border: none; color: var(--faint); cursor: pointer; font-size: 12px; padding: 3px 6px; border-radius: 5px; }
.card .acts button:hover { color: var(--text); background: var(--elev); }
.card .acts button.del:hover { color: var(--danger); }
.card .note { white-space: pre-wrap; word-break: break-word; font-size: 13.5px; line-height: 1.5; }
.card .noteEdit { width: 100%; background: var(--bg); border: 1px solid var(--accent); color: var(--text); border-radius: 6px; padding: 7px 9px; font: inherit; resize: vertical; }

/* composer */
.composer { border-top: 1px solid var(--border); padding: 14px 16px; flex: 0 0 auto; display: flex; flex-direction: column; gap: 10px; }
.composer .meta { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.composer .meta .at-chip {
  background: var(--accent-soft); color: var(--accent); border-radius: 6px;
  padding: 2px 9px; font-weight: 600; font-variant-numeric: tabular-nums;
}
.composer .pin-chip {
  display: none; align-items: center; gap: 6px; background: var(--elev); color: var(--text);
  border: 1px solid var(--border-2); border-radius: 6px; padding: 2px 8px; font-size: 11px;
}
.composer .pin-chip.show { display: inline-flex; }
.composer .pin-chip .clear { cursor: pointer; color: var(--faint); font-weight: 700; }
.composer .pin-chip .clear:hover { color: var(--danger); }
.composer-input { display: flex; gap: 10px; align-items: flex-end; }
.composer textarea {
  flex: 1 1 auto; resize: none; min-height: 42px; max-height: 140px;
  background: var(--panel-2); border: 1px solid var(--border-2); color: var(--text);
  border-radius: var(--radius); padding: 11px 12px; font: inherit;
}
.composer textarea:focus { outline: none; border-color: var(--accent); }
.composer .add-btn {
  background: var(--accent); color: #fff; border: none; border-radius: var(--radius);
  padding: 0 16px; height: 42px; font-size: 13px; font-weight: 600; cursor: pointer; flex: 0 0 auto;
}
.composer .add-btn:hover { background: var(--accent-hover); }
.composer .add-btn:disabled { opacity: .45; cursor: not-allowed; }

.hintbar { font-size: 11px; color: var(--faint); display: flex; gap: 14px; flex-wrap: wrap; }
kbd { background: var(--panel-2); border: 1px solid var(--border-2); border-radius: 4px; padding: 1px 5px; font-size: 11px; font-family: inherit; color: var(--muted); }

/* toast */
.toast {
  position: fixed; bottom: 22px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--elev); border: 1px solid var(--good); color: var(--good);
  padding: 10px 18px; border-radius: 8px; font-size: 13px;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 80;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Responsive: phone stacks to single column ---------- */
@media (max-width: 760px) {
  body { overflow: auto; height: auto; min-height: 100vh; }
  .topbar { flex-wrap: wrap; height: auto; padding: 10px 14px; gap: 10px; }
  .topbar .versionPicker { order: 3; width: 100%; }
  select.vselect { flex: 1 1 auto; min-width: 0; width: 100%; }
  .topbar .spacer { display: none; }
  .main { flex-direction: column; }
  .stage { padding: 14px; }
  .videoWrap { min-height: 210px; height: 46vw; max-height: 300px; flex: 0 0 auto; }
  .sidebar { flex: 1 1 auto; width: 100%; border-left: none; border-top: 1px solid var(--border); }
  .list { max-height: none; }
  .timecode { font-size: 17px; min-width: 96px; }
  .fpsField { margin-left: 0; }
  .transport { flex-wrap: wrap; }
}
