/* ─── Reset & Variables ─────────────────────────────────────────────────── */
:root {
  --bg0:       #0d0f14;
  --bg1:       #161b22;
  --bg2:       #1e2430;
  --bg3:       #252d3a;
  --border:    #2d3748;
  --text:      #e2e8f0;
  --text-dim:  #718096;
  --accent:    #7c5cbf;
  --accent-h:  #9470d6;
  --success:   #48bb78;
  --error:     #fc8181;
  --warn:      #f6ad55;

  /* annotation palette */
  --c-sibl:   #f56565;
  --c-over:   #ed8936;
  --c-clip:   #e53e3e;
  --c-noise:  #667eea;
  --c-sync:   #48bb78;
  --c-edit:   #4299e1;
  --c-custom: #a78bfa;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg0);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
}

button { cursor: pointer; font: inherit; border: none; outline: none; }
input, textarea, select { font: inherit; outline: none; }
a { color: var(--accent-h); text-decoration: none; }

/* ─── Screens ───────────────────────────────────────────────────────────── */
.screen { display: none; height: 100vh; flex-direction: column; }
.screen.active { display: flex; }

/* ─── Auth Screen ───────────────────────────────────────────────────────── */
#auth-screen {
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 60% 40%, #1a1035 0%, var(--bg0) 70%);
}

.auth-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  padding: 56px 64px;
  background: var(--bg1);
  border: 1px solid var(--border);
  border-radius: 16px;
  text-align: center;
  box-shadow: 0 24px 64px rgba(0,0,0,.5);
  max-width: 400px;
  width: 90%;
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.auth-logo svg { width: 36px; height: 36px; }

.auth-tagline {
  color: var(--text-dim);
  font-size: 13px;
  margin-top: -16px;
}

.btn-google {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 24px;
  background: #fff;
  color: #3c4043;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  transition: box-shadow .15s;
  width: 100%;
  justify-content: center;
}

.btn-google:hover { box-shadow: 0 2px 8px rgba(0,0,0,.3); }
.btn-google svg { width: 20px; height: 20px; flex-shrink: 0; }

/* ─── File Screen ───────────────────────────────────────────────────────── */
#file-screen { background: var(--bg0); }

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 52px;
  background: var(--bg1);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.top-bar-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 700;
}

.top-bar-logo svg { width: 22px; height: 22px; }

.top-bar-user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.user-name-text { font-size: 13px; color: var(--text-dim); }

.btn-link {
  background: none;
  color: var(--text-dim);
  font-size: 13px;
  padding: 4px 8px;
  border-radius: 6px;
  transition: color .15s, background .15s;
}
.btn-link:hover { color: var(--text); background: var(--bg3); }

.file-screen-body {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}

.file-card {
  width: 100%;
  max-width: 520px;
  background: var(--bg1);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.file-card h2 {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: -12px;
}

.file-card p { color: var(--text-dim); font-size: 13px; }

.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  transition: background .15s, transform .1s;
}
.btn-primary:hover { background: var(--accent-h); }
.btn-primary:active { transform: scale(.98); }
.btn-primary svg { width: 18px; height: 18px; }

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-dim);
  font-size: 12px;
}
.divider::before, .divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.link-input-row {
  display: flex;
  gap: 8px;
}

.link-input-row input {
  flex: 1;
  padding: 10px 14px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  transition: border-color .15s;
}
.link-input-row input:focus { border-color: var(--accent); }
.link-input-row input::placeholder { color: var(--text-dim); }

.btn-secondary {
  padding: 10px 16px;
  background: var(--bg3);
  color: var(--text);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  transition: background .15s;
  white-space: nowrap;
}
.btn-secondary:hover { background: var(--border); }

/* ─── Settings (file screen) ────────────────────────────────────────────── */
.setting-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.setting-hint {
  display: block;
  font-size: 11px;
  font-weight: 400;
  color: var(--text-dim);
  margin-top: 2px;
  opacity: .75;
}

.folder-row {
  display: flex;
  gap: 6px;
  align-items: center;
}

.folder-pick-btn {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-dim);
  font-size: 13px;
  text-align: left;
  transition: border-color .15s, color .15s;
  overflow: hidden;
}
.folder-pick-btn:hover { border-color: var(--accent); color: var(--text); }
.folder-pick-btn svg { flex-shrink: 0; }
.folder-pick-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-pick-btn.has-value { color: var(--text); }

.folder-clear-btn {
  padding: 8px 10px;
  background: var(--bg3);
  color: var(--text-dim);
  border-radius: 8px;
  font-size: 13px;
  flex-shrink: 0;
  transition: background .12s, color .12s;
}
.folder-clear-btn:hover { background: var(--border); color: var(--error); }

/* ─── Review Screen ─────────────────────────────────────────────────────── */
#review-screen { overflow: hidden; }

#review-screen .top-bar { gap: 12px; }

.file-title {
  font-size: 14px;
  font-weight: 600;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.review-body {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-height: 0;
}

/* ─── Player pane ───────────────────────────────────────────────────────── */
.player-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
  background: #000;
}

.media-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  overflow: hidden;
}

#video-player {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

#audio-display {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  width: 100%;
  height: 100%;
  background: var(--bg1);
}

#audio-display.visible { display: flex; }

#audio-player { display: none; }

.audio-icon { opacity: .25; }
.audio-icon svg { width: 96px; height: 96px; }

.audio-file-label {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-dim);
  max-width: 60%;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Spectrum canvas */
#spectrum-canvas {
  width: 100%;
  height: 80px;
  display: block;
  background: transparent;
}

.spectrum-wrapper {
  width: 100%;
  padding: 0 20px 8px;
  flex-shrink: 0;
}

/* ─── Timeline ──────────────────────────────────────────────────────────── */
.timeline-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--bg1);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  user-select: none;
}

.time-label {
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-dim);
  white-space: nowrap;
  min-width: 48px;
}
#time-current { text-align: right; }

.timeline-track-wrapper {
  position: relative;
  flex: 1;
  height: 28px;
  display: flex;
  align-items: center;
  cursor: pointer;
}

.timeline-track {
  position: absolute;
  inset: 0;
  margin: auto 0;
  height: 6px;
  background: var(--bg3);
  border-radius: 3px;
  overflow: visible;
}

.timeline-progress {
  position: absolute;
  top: 0; left: 0; bottom: 0;
  background: var(--accent);
  border-radius: 3px;
  width: 0%;
  transition: width .05s linear;
  pointer-events: none;
}

.annotation-markers-layer {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
}

.ann-marker {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 10px;
  height: 10px;
  border-radius: 50%;
  cursor: pointer;
  pointer-events: all;
  transition: transform .1s;
  border: 2px solid rgba(0,0,0,.4);
  z-index: 2;
}

.ann-marker:hover {
  transform: translate(-50%, -50%) scale(1.5);
  z-index: 10;
}

.ann-marker-tooltip {
  position: absolute;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg0);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 9px;
  font-size: 11px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity .15s;
  z-index: 20;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ann-marker:hover .ann-marker-tooltip { opacity: 1; }

.timeline-playhead {
  position: absolute;
  top: 50%;
  left: 0%;
  transform: translate(-50%, -50%);
  width: 14px;
  height: 14px;
  background: #fff;
  border-radius: 50%;
  cursor: grab;
  z-index: 5;
  box-shadow: 0 0 0 2px var(--accent), 0 2px 6px rgba(0,0,0,.5);
  transition: left .05s linear;
}

.timeline-track-wrapper:active .timeline-playhead { cursor: grabbing; }

/* ─── Transport controls ────────────────────────────────────────────────── */
.transport-row {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 16px;
  background: var(--bg1);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.transport-group {
  display: flex;
  align-items: center;
  gap: 3px;
}

.sep {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 6px;
}

.t-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 32px;
  padding: 0 8px;
  background: var(--bg3);
  color: var(--text);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  transition: background .12s, color .12s;
}
.t-btn:hover { background: var(--border); }

.t-btn-play {
  min-width: 42px;
  background: var(--accent);
  color: #fff;
  font-size: 16px;
}
.t-btn-play:hover { background: var(--accent-h); }

.speed-group { display: flex; align-items: center; gap: 3px; }
.speed-label { font-size: 11px; color: var(--text-dim); margin-right: 2px; }

.speed-btn {
  height: 28px;
  padding: 0 8px;
  background: var(--bg3);
  color: var(--text-dim);
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  transition: background .12s, color .12s;
}
.speed-btn:hover { color: var(--text); background: var(--border); }
.speed-btn.active { background: var(--accent); color: #fff; }

.fps-group { display: flex; align-items: center; gap: 6px; }
.fps-label { font-size: 11px; color: var(--text-dim); }

.fps-select {
  height: 28px;
  padding: 0 6px;
  background: var(--bg3);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 11px;
  cursor: pointer;
}

/* ─── Annotations pane ──────────────────────────────────────────────────── */
.annotations-pane {
  width: 300px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg1);
  border-left: 1px solid var(--border);
  overflow: hidden;
}

.pane-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.pane-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 2px;
}

.sync-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--text-dim);
}

.sync-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-dim);
  flex-shrink: 0;
}

.sync-status.synced .sync-dot { background: var(--success); }
.sync-status.syncing .sync-dot {
  background: var(--warn);
  animation: pulse-dot 1s infinite;
}
.sync-status.error .sync-dot { background: var(--error); }
.sync-status.synced .sync-label { color: var(--success); }
.sync-status.syncing .sync-label { color: var(--warn); }
.sync-status.error .sync-label { color: var(--error); }

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50%       { opacity: .3; }
}

/* Quick annotation buttons */
.quick-btns {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
}

.quick-btn-row { display: flex; gap: 6px; }

.ann-btn {
  flex: 1;
  padding: 8px 6px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  border: 1px solid transparent;
  transition: opacity .12s, transform .1s, border-color .12s;
  color: #fff;
}
.ann-btn:hover { opacity: .85; }
.ann-btn:active { transform: scale(.96); }

.ann-btn.custom-btn {
  background: var(--bg3);
  color: var(--text);
  border-color: var(--border);
  font-size: 12px;
  padding: 10px;
}
.ann-btn.custom-btn:hover { border-color: var(--accent); color: var(--accent-h); }

/* Annotation list */
.ann-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px 6px;
  flex-shrink: 0;
}

.ann-list-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-dim);
}

.ann-count {
  background: var(--bg3);
  color: var(--text-dim);
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
}

.ann-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0 20px;
}

.ann-list::-webkit-scrollbar { width: 4px; }
.ann-list::-webkit-scrollbar-track { background: transparent; }
.ann-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.ann-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 14px;
  cursor: pointer;
  transition: background .12s;
  border-bottom: 1px solid rgba(255,255,255,.03);
}
.ann-item:hover { background: var(--bg2); }

.ann-item-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 4px;
  flex-shrink: 0;
}

.ann-item-body { flex: 1; min-width: 0; }

.ann-item-comment {
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}

.ann-item-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  color: var(--text-dim);
}

.ann-item-time {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--accent-h);
}

.ann-empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--text-dim);
  font-size: 12px;
}

/* ─── Custom note modal ─────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.65);
  z-index: 100;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(3px);
}

.modal-overlay.visible { display: flex; }

.modal-box {
  background: var(--bg1);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px;
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: 0 24px 64px rgba(0,0,0,.6);
}

.modal-title {
  font-size: 16px;
  font-weight: 700;
}

.modal-subtitle {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: -10px;
}

.modal-textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  resize: vertical;
  min-height: 80px;
  transition: border-color .15s;
}
.modal-textarea:focus { border-color: var(--accent); }
.modal-textarea::placeholder { color: var(--text-dim); }

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.btn-cancel {
  padding: 10px 18px;
  background: var(--bg3);
  color: var(--text);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  transition: background .12s;
}
.btn-cancel:hover { background: var(--border); }

/* ─── Toast notifications ───────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--text);
  animation: toast-in .2s ease forwards;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
}

.toast.success { border-color: var(--success); color: var(--success); }
.toast.error   { border-color: var(--error);   color: var(--error); }

@keyframes toast-in  { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toast-out { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(8px); } }

/* ─── Loading spinner ───────────────────────────────────────────────────── */
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Scrollbars (global) ───────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ─── Keyboard hint ─────────────────────────────────────────────────────── */
.kbd-hint {
  display: inline-block;
  padding: 1px 5px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 10px;
  font-family: monospace;
  color: var(--text-dim);
  vertical-align: middle;
}
