/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #06060a;
  --bg2: #0d0d14;
  --card: rgba(255,255,255,0.03);
  --card-hover: rgba(255,255,255,0.055);
  --border: rgba(255,255,255,0.06);
  --border-accent: rgba(99,102,241,0.4);
  --text: #e8e8e8;
  --text-secondary: #888;
  --accent: #6366f1;
  --accent-dim: rgba(99,102,241,0.15);
  --accent-hover: #7274f3;
  --danger: #ef4444;
  --success: #22c55e;
  --warn: #f59e0b;
  --r-card: 12px;
  --r-btn: 8px;
}

html { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
}

h1, h2, h3, h4, h5 {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* ===== UTILITIES ===== */
.hidden { display: none !important; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.w-full { width: 100%; }
.text-secondary { color: var(--text-secondary); }
.text-accent { color: var(--accent); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-btn);
  background: var(--card);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  user-select: none;
}
.btn:hover { background: var(--card-hover); border-color: rgba(255,255,255,0.12); }
.btn:active { transform: scale(0.97); }
.btn svg { width: 15px; height: 15px; flex-shrink: 0; }

.btn-primary {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); border-color: transparent; }

.btn-ghost {
  background: transparent;
  border-color: transparent;
}
.btn-ghost:hover { background: var(--card); border-color: var(--border); }

.btn-danger { background: rgba(239,68,68,0.15); border-color: rgba(239,68,68,0.3); color: #ef4444; }
.btn-danger:hover { background: rgba(239,68,68,0.25); }

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-sm svg { width: 13px; height: 13px; }

.btn-icon {
  padding: 7px;
  border-radius: var(--r-btn);
}
.btn-icon svg { width: 16px; height: 16px; }

/* ===== INPUTS ===== */
input[type="text"], input[type="file"], textarea, select {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: var(--r-btn);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  padding: 8px 12px;
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
}
input[type="text"]:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  background: rgba(99,102,241,0.05);
}
input::placeholder, textarea::placeholder { color: var(--text-secondary); }
select option { background: #1a1a2e; color: var(--text); }

/* ===== CARD ===== */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  backdrop-filter: blur(12px);
}

/* ===== TOAST ===== */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: rgba(20,20,35,0.95);
  border: 1px solid var(--border);
  border-radius: var(--r-btn);
  backdrop-filter: blur(12px);
  padding: 10px 16px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: toastIn 0.2s ease;
  pointer-events: auto;
  min-width: 200px;
  max-width: 320px;
}
.toast.success { border-color: rgba(34,197,94,0.4); }
.toast.error { border-color: rgba(239,68,68,0.4); color: #fca5a5; }
.toast.info { border-color: var(--border-accent); }
@keyframes toastIn {
  from { transform: translateX(20px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

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

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.15s ease;
}
.modal {
  background: #0f0f1a;
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  padding: 24px;
  min-width: 380px;
  max-width: 500px;
  width: 90%;
}
.modal h3 { font-size: 16px; margin-bottom: 16px; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ============================================================
   INDEX PAGE
   ============================================================ */
.page-index {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.index-header {
  padding: 20px 32px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}
.logo svg { color: var(--accent); }

.index-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 64px 32px 48px;
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
}

.index-hero {
  text-align: center;
  margin-bottom: 48px;
}
.index-hero h1 {
  font-size: 36px;
  font-weight: 700;
  background: linear-gradient(135deg, #e8e8e8 0%, #888 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 12px;
}
.index-hero p { color: var(--text-secondary); font-size: 16px; }

/* Drop Zone */
.drop-zone {
  width: 100%;
  border: 2px dashed var(--border);
  border-radius: var(--r-card);
  padding: 56px 32px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--card);
  position: relative;
  margin-bottom: 32px;
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-dim);
}
.drop-zone input[type="file"] {
  position: absolute; inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%; height: 100%;
}
.drop-zone-icon {
  width: 56px; height: 56px;
  background: var(--accent-dim);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  color: var(--accent);
}
.drop-zone h3 { font-size: 18px; margin-bottom: 6px; }
.drop-zone p { color: var(--text-secondary); font-size: 13px; }
.drop-zone-progress {
  margin-top: 20px;
  background: rgba(255,255,255,0.05);
  border-radius: 4px;
  height: 4px;
  overflow: hidden;
}
.drop-zone-progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: width 0.2s;
  width: 0%;
}

.index-or {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  margin-bottom: 24px;
  color: var(--text-secondary);
  font-size: 13px;
}
.index-or::before, .index-or::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.paste-link-row {
  display: flex;
  gap: 8px;
  width: 100%;
  margin-bottom: 48px;
}
.paste-link-row input { flex: 1; }

/* Recent reviews */
.recent-section { width: 100%; }
.recent-section h2 {
  font-size: 16px;
  margin-bottom: 16px;
  color: var(--text-secondary);
  font-weight: 500;
}
.recent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
.review-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  color: var(--text);
  display: block;
}
.review-card:hover {
  border-color: rgba(255,255,255,0.12);
  background: var(--card-hover);
  transform: translateY(-2px);
}
.review-card-thumb {
  aspect-ratio: 16/9;
  background: rgba(255,255,255,0.03);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 32px;
  overflow: hidden;
  position: relative;
}
.review-card-thumb img {
  width: 100%; height: 100%;
  object-fit: cover;
}
.review-card-thumb .filetype-badge {
  position: absolute;
  top: 8px; right: 8px;
  background: rgba(0,0,0,0.7);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 10px;
  font-family: monospace;
  color: #aaa;
}
.review-card-info {
  padding: 12px;
}
.review-card-info h4 {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.review-card-info p { font-size: 11px; color: var(--text-secondary); }

.empty-state {
  grid-column: 1/-1;
  text-align: center;
  padding: 40px;
  color: var(--text-secondary);
}
.empty-state svg { color: rgba(255,255,255,0.1); margin-bottom: 12px; }

/* ============================================================
   REVIEW PAGE
   ============================================================ */
.page-review {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* TOP TOOLBAR */
.review-toolbar {
  height: 52px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  background: var(--bg2);
  z-index: 100;
}
.toolbar-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  padding-right: 12px;
  border-right: 1px solid var(--border);
  flex-shrink: 0;
}
.toolbar-logo svg { color: var(--accent); }

.toolbar-title {
  font-size: 14px;
  font-weight: 600;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toolbar-spacer { flex: 1; }

.version-selector {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-btn);
  padding: 4px;
}
.version-btn {
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  font-family: 'Space Grotesk', sans-serif;
  cursor: pointer;
  transition: all 0.15s;
  color: var(--text-secondary);
  background: transparent;
  border: none;
}
.version-btn:hover { color: var(--text); background: rgba(255,255,255,0.05); }
.version-btn.active { background: var(--accent); color: #fff; }

/* MAIN CONTENT AREA */
.review-body {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* VIEWER PANEL (left) */
.viewer-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: #030306;
}

.viewer-area {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #030306;
}

.viewer-media-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  max-height: 100%;
  cursor: crosshair;
}

#viewer-media {
  max-width: 100%;
  max-height: 100%;
  display: block;
  border-radius: 4px;
  user-select: none;
}

#annotation-canvas {
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: 4px;
}

#draw-canvas {
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: 4px;
  z-index: 2;
}

.viewer-media-wrap.drawing-mode #draw-canvas,
.viewer-media-wrap.placing-mode #draw-canvas {
  pointer-events: auto;
  cursor: crosshair;
}

/* Annotation markers */
.ann-marker {
  position: absolute;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid rgba(255,255,255,0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  transform: translate(-50%, -50%);
  z-index: 10;
  transition: transform 0.15s, box-shadow 0.15s;
  pointer-events: auto;
  user-select: none;
  font-family: 'Space Grotesk', sans-serif;
}
.ann-marker:hover { transform: translate(-50%, -50%) scale(1.2); box-shadow: 0 0 0 4px rgba(99,102,241,0.3); }
.ann-marker.active { transform: translate(-50%, -50%) scale(1.25); box-shadow: 0 0 0 5px rgba(99,102,241,0.4); }

/* DRAWING TOOLBAR */
.draw-toolbar {
  height: 48px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 12px;
  background: var(--bg2);
  flex-shrink: 0;
}
.draw-toolbar .sep {
  width: 1px;
  height: 24px;
  background: var(--border);
  margin: 0 4px;
}

.tool-btn {
  width: 32px; height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid transparent;
}
.tool-btn:hover { color: var(--text); background: var(--card); }
.tool-btn.active {
  color: var(--accent);
  background: var(--accent-dim);
  border-color: var(--border-accent);
}
.tool-btn svg { width: 16px; height: 16px; }

.color-swatch {
  width: 20px; height: 20px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.15s;
  flex-shrink: 0;
}
.color-swatch:hover { transform: scale(1.15); }
.color-swatch.active { border-color: #fff; transform: scale(1.15); }

#color-picker-input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0; height: 0;
}

.stroke-width-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--text-secondary);
  font-size: 12px;
}
.stroke-width-wrap input[type="range"] {
  width: 60px;
  accent-color: var(--accent);
  padding: 0;
  background: transparent;
  border: none;
}

/* VIDEO TIMELINE */
.video-timeline {
  height: 52px;
  border-top: 1px solid var(--border);
  background: var(--bg2);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0 12px;
  gap: 4px;
}
.timeline-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}
.timeline-time {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 11px;
  color: var(--text-secondary);
  min-width: 90px;
}
.timeline-scrubber-wrap {
  flex: 1;
  position: relative;
  height: 16px;
  display: flex;
  align-items: center;
}
.timeline-scrubber {
  width: 100%;
  height: 4px;
  background: rgba(255,255,255,0.1);
  border-radius: 2px;
  cursor: pointer;
  position: relative;
}
.timeline-scrubber-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  pointer-events: none;
}
.timeline-scrubber-handle {
  position: absolute;
  top: 50%;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--accent);
  transform: translate(-50%, -50%);
  pointer-events: none;
  box-shadow: 0 0 0 2px rgba(99,102,241,0.3);
}
.timeline-marker {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--warn);
  pointer-events: auto;
  cursor: pointer;
  z-index: 5;
  transition: transform 0.1s;
}
.timeline-marker:hover { transform: translate(-50%, -50%) scale(1.3); }
.timeline-frame {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 11px;
  color: var(--text-secondary);
  min-width: 70px;
  text-align: right;
}

/* COMMENTS PANEL (right) */
.comments-panel {
  width: 300px;
  min-width: 260px;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border);
  background: var(--bg2);
  overflow: hidden;
}

.panel-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.panel-header h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.author-row {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.author-row label {
  font-size: 11px;
  color: var(--text-secondary);
  display: block;
  margin-bottom: 5px;
}

.comments-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.comment-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
}
.comment-item:hover { background: var(--card-hover); border-color: rgba(255,255,255,0.1); }
.comment-item.active {
  border-color: var(--border-accent);
  background: var(--accent-dim);
}
.comment-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 5px;
}
.comment-author {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  font-family: 'Space Grotesk', sans-serif;
}
.comment-time {
  font-size: 10px;
  color: var(--text-secondary);
  font-family: 'Space Grotesk', sans-serif;
}
.comment-text {
  font-size: 12px;
  line-height: 1.5;
  color: var(--text);
  word-break: break-word;
}
.comment-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}
.comment-badge {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(255,255,255,0.06);
  color: var(--text-secondary);
  font-family: monospace;
}
.comment-delete {
  position: absolute;
  top: 8px; right: 8px;
  opacity: 0;
  transition: opacity 0.15s;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 2px;
  border-radius: 4px;
}
.comment-delete:hover { color: var(--danger); background: rgba(239,68,68,0.1); }
.comment-item:hover .comment-delete { opacity: 1; }

/* NEW COMMENT FORM */
.new-comment-area {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg);
}
.new-comment-area h4 {
  font-size: 11px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}
.place-marker-hint {
  font-size: 11px;
  color: var(--text-secondary);
  padding: 8px 10px;
  border-radius: 6px;
  background: var(--accent-dim);
  border: 1px dashed var(--border-accent);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.place-marker-hint svg { color: var(--accent); width: 13px; height: 13px; flex-shrink: 0; }
.new-comment-area textarea {
  resize: none;
  height: 72px;
  margin-bottom: 8px;
  font-size: 13px;
}
.comment-submit-row {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

/* LOADING OVERLAY */
.viewer-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(3,3,6,0.8);
  z-index: 50;
  color: var(--text-secondary);
}

/* EMPTY PANEL */
.panel-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text-secondary);
  font-size: 13px;
  padding: 24px;
  text-align: center;
}
.panel-empty svg { opacity: 0.3; margin-bottom: 4px; }

/* VERSION UPLOAD MODAL */
.version-upload-drop {
  border: 2px dashed var(--border);
  border-radius: var(--r-card);
  padding: 32px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  margin-bottom: 16px;
}
.version-upload-drop:hover, .version-upload-drop.drag-over {
  border-color: var(--accent);
  background: var(--accent-dim);
}
.version-upload-drop input {
  position: absolute; inset: 0;
  opacity: 0; cursor: pointer;
  width: 100%; height: 100%;
}

/* ============================================================
   PHASE 2 STYLES
   ============================================================ */

/* ── Compare Bar ──────────────────────────────────────────── */
.compare-bar {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 6px 16px;
  flex-shrink: 0;
  z-index: 99;
}
.compare-bar-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.compare-sep {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 4px;
}
.compare-version-selector {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-btn);
  padding: 3px;
}
.compare-opacity-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ── Compare Split View ───────────────────────────────────── */
.viewer-area {
  display: flex;
  flex-direction: row;
}

.viewer-pane {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #030306;
  min-width: 0;
}

.viewer-pane + .viewer-pane {
  border-left: 2px solid var(--accent);
}

.pane-label {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(99,102,241,0.85);
  color: #fff;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  z-index: 20;
  pointer-events: none;
  display: none;
}

.viewer-area.compare-mode .pane-label {
  display: block;
}

/* Overlay mode: compare pane stacks over primary */
.viewer-area.overlay-mode {
  position: relative;
}
.viewer-area.overlay-mode .viewer-pane-compare {
  position: absolute;
  inset: 0;
  background: transparent;
  border: none;
}
.viewer-area.overlay-mode .viewer-pane-compare .viewer-media-wrap {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Compare canvas */
#compare-annotation-canvas {
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: 4px;
  z-index: 3;
}

/* ── Audio Recording ──────────────────────────────────────── */
.audio-record-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  min-height: 32px;
  flex-wrap: wrap;
}
.audio-recording-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #ef4444;
}
.rec-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ef4444;
  animation: recPulse 1s ease-in-out infinite;
  flex-shrink: 0;
}
@keyframes recPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}
.audio-preview {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
}

/* Audio player in comments */
.comment-audio {
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(99,102,241,0.08);
  border: 1px solid rgba(99,102,241,0.2);
  border-radius: 6px;
  padding: 4px 8px;
}

audio::-webkit-media-controls-panel {
  background: rgba(255,255,255,0.05);
}

/* ── Projects Page ────────────────────────────────────────── */
.page-projects {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.projects-header {
  padding: 20px 32px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.projects-main {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 40px 32px;
}
.projects-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 32px;
}
.projects-title-row h1 {
  font-size: 28px;
  background: linear-gradient(135deg, #e8e8e8 0%, #888 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 48px;
}
.project-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  color: var(--text);
  display: block;
}
.project-card:hover {
  border-color: rgba(255,255,255,0.12);
  background: var(--card-hover);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
.project-card-thumbs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 80px 80px;
  background: rgba(255,255,255,0.02);
  overflow: hidden;
}
.project-card-thumbs img {
  width: 100%; height: 100%;
  object-fit: cover;
}
.project-card-thumb-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,0.1);
  font-size: 24px;
}
.project-thumb-single {
  grid-column: 1 / -1;
  grid-row: 1 / -1;
}
.project-card-info {
  padding: 16px;
}
.project-card-info h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 4px;
}
.project-card-info p {
  font-size: 12px;
  color: var(--text-secondary);
}
.project-card-footer {
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.project-reviews-badge {
  font-size: 11px;
  color: var(--text-secondary);
  background: rgba(255,255,255,0.05);
  padding: 2px 8px;
  border-radius: 10px;
}

/* Project detail: review list */
.project-reviews-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

/* New project modal */
.project-create-form {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
}
.project-create-form input { flex: 1; }

/* ── Mobile / Responsive ──────────────────────────────────── */
.hide-mobile { display: inline; }

@media (max-width: 768px) {
  /* Toolbar */
  .review-toolbar {
    padding: 0 8px;
    gap: 6px;
    height: 48px;
  }
  .toolbar-logo span, .hide-mobile { display: none; }
  .toolbar-title { max-width: 120px; font-size: 13px; }
  .version-selector { gap: 2px; padding: 2px; }
  .version-btn { padding: 3px 7px; font-size: 11px; }

  /* Review body: stack vertically on mobile */
  .review-body {
    flex-direction: column;
  }

  /* Viewer takes full width, fixed height */
  .viewer-panel {
    flex: none;
    height: 55vh;
    min-height: 260px;
  }

  /* Comments panel: full width at bottom */
  .comments-panel {
    width: 100%;
    min-width: 0;
    max-width: none;
    border-left: none;
    border-top: 1px solid var(--border);
    height: 45vh;
    min-height: 200px;
  }

  /* Draw toolbar: compact */
  .draw-toolbar {
    padding: 0 6px;
    gap: 2px;
    overflow-x: auto;
    height: 44px;
  }
  .tool-btn { width: 30px; height: 30px; }
  .color-swatch { width: 16px; height: 16px; }

  /* Video timeline */
  .video-timeline { height: 44px; padding: 0 6px; }
  .timeline-time, .timeline-frame { font-size: 10px; min-width: 60px; }

  /* Compare bar */
  .compare-bar-inner {
    gap: 6px;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 2px;
  }

  /* Panel header */
  .panel-header { padding: 10px 12px; }

  /* Comment form more compact */
  .new-comment-area { padding: 8px; }
  .new-comment-area textarea { height: 56px; }

  /* Index */
  .index-hero h1 { font-size: 24px; }
  .index-main { padding: 32px 16px 24px; }
  .projects-header, .projects-main { padding: 16px; }
  .projects-grid { grid-template-columns: 1fr 1fr; gap: 10px; }

  /* Touch: make canvas pointer events auto always */
  #draw-canvas { touch-action: none; }
}

@media (max-width: 480px) {
  .projects-grid { grid-template-columns: 1fr; }
  .toolbar-title { display: none; }
  .review-toolbar { gap: 4px; }
}

/* ── Active state for toolbar buttons ─────────────────────── */
.btn.active {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
}
.btn.active:hover { background: var(--accent-hover); }

/* ── Viewer pane sizing fix ───────────────────────────────── */
.viewer-pane-primary {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

/* Ensure draw canvas is within primary pane context */
.viewer-pane-primary .viewer-media-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  max-height: 100%;
}

/* Compare pane media wrap */
.viewer-pane-compare .viewer-media-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

/* Fix: ensure page-review lays out compare bar correctly */
.page-review {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}
.review-body {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-height: 0;
}

/* audio controls minimal style */
audio { border-radius: 4px; }
