/* ═══════════════════════════════════════════
   SimpleReplay — Design System
   Dark premium theme, desktop-first
   ═══════════════════════════════════════════ */

/* ── CSS Variables ── */
:root {
  /* Colors */
  --bg-primary: #0f1117;
  --bg-secondary: #161922;
  --bg-tertiary: #1e2130;
  --bg-elevated: #252839;
  --bg-hover: #2a2e42;
  --bg-active: #32365a;

  --text-primary: #e8eaf0;
  --text-secondary: #9ca3b8;
  --text-muted: #636a80;
  --text-inverse: #0f1117;

  --accent: #6366f1;
  --accent-hover: #818cf8;
  --accent-glow: rgba(99, 102, 241, 0.25);
  --accent2: #06b6d4;
  --accent2-glow: rgba(6, 182, 212, 0.2);

  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;

  --border: #2a2d3e;
  --border-focus: #6366f1;

  /* Spacing */
  --sp-xs: 4px;
  --sp-sm: 8px;
  --sp-md: 12px;
  --sp-lg: 16px;
  --sp-xl: 24px;
  --sp-2xl: 32px;

  /* Radius */
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-xl: 16px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px var(--accent-glow);

  /* Transitions */
  --tr-fast: 150ms ease;
  --tr-normal: 250ms ease;
  --tr-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Layout */
  --header-h: 56px;
  --panel-w: 340px;
}

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

html {
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

button {
  cursor: pointer;
  font-family: inherit;
}

input,
select {
  font-family: inherit;
}

/* ── Scrollbar ── */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--bg-hover);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ═══════════════════════════════════════════
   HEADER
   ═══════════════════════════════════════════ */
#app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-h);
  padding: 0 var(--sp-lg);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  position: relative;
}

.header-left {
  display: flex;
  align-items: center;
  gap: var(--sp-md);
  transition: opacity 0.2s ease;
}

.header-left:hover {
  opacity: 0.8;
}

.logo-icon {
  flex-shrink: 0;
}

.app-title {
  font-family: 'Aldrich', sans-serif;
  font-size: 1.25rem;
  font-weight: 400;
  letter-spacing: -0.3px;
  color: #ffffff;
}

.app-title-simple {
  color: #ffffff;
}

.app-title-replay {
  color: #6366f1;
}

.header-center {
  display: flex;
  align-items: center;
}

.header-right {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
}

.header-divider {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 2px;
}

.btn-save {
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.btn-save:hover {
  background: rgba(34, 197, 94, 0.25);
}

.btn-share {
  background: rgba(59, 130, 246, 0.15);
  color: #3b82f6;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.btn-share:hover {
  background: rgba(59, 130, 246, 0.25);
}

.btn-projects {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.btn-projects:hover {
  background: rgba(245, 158, 11, 0.25);
}

.btn-reset-filters {
  color: var(--danger);
  margin-top: 4px;
  font-size: 0.72rem;
}

/* Project list modal */
.project-list {
  max-height: 300px;
  overflow-y: auto;
}

.project-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  margin-bottom: 4px;
}

.project-item:hover {
  background: var(--bg-hover);
}

.project-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.project-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}

.project-date {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.project-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

/* Clip checkbox */
.clip-checkbox {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

/* View mode selection bar */
.view-selection-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  background: var(--accent-glow);
  border: 1px solid var(--accent);
  border-radius: var(--r-sm);
  font-size: 0.75rem;
  color: var(--accent-hover);
  margin-top: 4px;
}

/* Chat panel */
.clip-chat-panel {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  width: 280px;
  z-index: 60;
  box-shadow: var(--shadow-lg);
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 8px;
  max-height: 200px;
  display: flex;
  flex-direction: column;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  max-height: 130px;
  margin-bottom: 6px;
}

.chat-message {
  font-size: 0.75rem;
  padding: 3px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.chat-name {
  font-weight: 700;
  color: var(--accent-hover);
  margin-right: 4px;
}

.chat-mention {
  background: rgba(99, 102, 241, 0.2);
  color: var(--accent-hover);
  border-radius: 3px;
  padding: 0 3px;
  font-weight: 600;
}

.chat-time {
  font-size: 0.6rem;
  color: var(--text-muted);
  margin-left: 4px;
}

.drawing-delete-btn {
  background: none;
  border: none;
  padding: 0 3px;
  font-size: 0.75rem;
  opacity: 0.4;
  cursor: pointer;
  vertical-align: middle;
  transition: opacity var(--tr-fast);
}

.drawing-delete-btn:hover {
  opacity: 1;
}


.chat-input-row {
  display: flex;
  gap: 4px;
}

.chat-input-row input {
  flex: 1;
  font-size: 0.75rem;
  padding: 4px 6px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text-primary);
}

.chat-input-row button {
  font-size: 0.7rem;
  padding: 4px 8px;
}

.chat-name-input {
  max-width: 70px;
}

.clip-chat-btn {
  background: none;
  border: none;
  font-size: 0.7rem;
  padding: 2px 3px;
  opacity: 0.5;
  cursor: pointer;
  transition: all var(--tr-fast);
  line-height: 1;
}

.clip-chat-btn:hover {
  opacity: 1;
}

.clip-chat-btn.has-comments {
  opacity: 0.9;
}

/* Clip layout helpers */
.clip-item-spacer {
  flex: 1;
}

/* Flag button (🚩) */
.clip-flag-btn {
  background: none;
  border: none;
  font-size: 0.7rem;
  padding: 2px 3px;
  opacity: 0.4;
  cursor: pointer;
  transition: all var(--tr-fast);
  line-height: 1;
}

.clip-flag-btn:hover {
  opacity: 1;
}

.clip-flag-btn.has-flags {
  opacity: 0.9;
}

/* Flag popover */
.flag-popover {
  position: absolute;
  right: 0;
  top: 100%;
  z-index: 50;
  display: flex;
  gap: 2px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 4px;
  box-shadow: var(--shadow-lg);
}

.flag-popover-btn {
  background: none;
  border: 1px solid transparent;
  font-size: 0.85rem;
  padding: 4px 6px;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: all var(--tr-fast);
  opacity: 0.5;
}

.flag-popover-btn:hover {
  opacity: 1;
  background: var(--bg-tertiary);
}

.flag-popover-btn.active {
  opacity: 1;
  border-color: var(--accent);
  background: var(--accent-glow);
}

/* Clip action icons (playlist, delete) */
.clip-action-icon {
  background: none;
  border: none;
  font-size: 0.7rem;
  padding: 2px 3px;
  opacity: 0.35;
  cursor: pointer;
  transition: opacity var(--tr-fast);
  line-height: 1;
}

.clip-action-icon:hover {
  opacity: 1;
}

/* ── Mode Toggle ── */
.mode-toggle {
  display: flex;
  position: relative;
  background: var(--bg-tertiary);
  border-radius: var(--r-lg);
  padding: 3px;
  border: 1px solid var(--border);
  min-width: 270px;
}

.mode-btn {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 0;
  width: 33.333%;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: var(--r-md);
  transition: color var(--tr-fast);
  white-space: nowrap;
}

.mode-btn.active {
  color: #fff;
}

.read-only-label {
  display: none;
  align-items: center;
  justify-content: center;
  width: 100%;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  opacity: 0.8;
}

.mode-btn:hover:not(.active) {
  color: var(--text-primary);
}

.mode-slider {
  position: absolute;
  top: 3px;
  left: 3px;
  width: calc(33.333% - 3px);
  height: calc(100% - 6px);
  background: var(--accent);
  border-radius: var(--r-md);
  transition: transform var(--tr-slow);
  z-index: 1;
  box-shadow: var(--shadow-glow);
}

.mode-slider.right {
  transform: translateX(100%);
}

.mode-slider.right2 {
  transform: translateX(200%);
}

.mode-icon {
  font-size: 0.9rem;
}

/* ── Game Select ── */
.game-select {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 6px 12px;
  border-radius: var(--r-sm);
  font-size: 0.82rem;
  max-width: 220px;
  outline: none;
  transition: border-color var(--tr-fast);
}

.game-select:focus {
  border-color: var(--accent);
}

/* ═══════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  font-size: 0.85rem;
  font-weight: 600;
  transition: all var(--tr-fast);
  white-space: nowrap;
}

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

.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: var(--shadow-glow);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}

.btn-ghost:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.btn-outline {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border);
}

.btn-outline:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-glow);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border-color: var(--border);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.15);
  border-color: var(--danger);
}

.btn-sm {
  padding: 5px 12px;
  font-size: 0.8rem;
}

.btn-xs {
  padding: 3px 8px;
  font-size: 0.75rem;
}

/* ═══════════════════════════════════════════
   MAIN LAYOUT
   ═══════════════════════════════════════════ */
#app-main {
  display: flex;
  height: calc(100vh - var(--header-h));
  overflow: hidden;
}

/* ── Video Area ── */
#video-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: #000;
  position: relative;
}

#player-container {
  flex: 1;
  position: relative;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  overflow: hidden;
}

#youtube-player {
  width: 100%;
  height: 100%;
}

#youtube-player iframe {
  width: 100% !important;
  height: 100% !important;
}

.player-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  z-index: 5;
}

.overlay-content {
  text-align: center;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-lg);
}

.overlay-content p {
  font-size: 0.95rem;
}

/* ── Focus Overlay ── */
.focus-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: var(--sp-md) var(--sp-lg);
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
  z-index: 10;
  pointer-events: none;
}

.focus-info {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
}

.focus-clip-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

.focus-clip-flags {
  font-size: 1.1rem;
}

/* ── Video Chat Overlay ── */
/* Speed slider popup */
.speed-slider-popup {
  position: fixed;
  display: none;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  width: 220px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  z-index: 9999;
}

.speed-slider-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.video-chat-panel {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  max-height: 130px;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 15;
  padding: 8px 12px;
  overflow-y: auto;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.video-chat-panel .chat-messages {
  max-height: 70px;
  overflow-y: auto;
  margin-bottom: 6px;
  position: relative;
}

.video-chat-panel .chat-messages.has-more-above {
  border-top: 2px solid rgba(99, 102, 241, 0.5);
  box-shadow: inset 0 6px 8px -4px rgba(99, 102, 241, 0.3);
}

.video-chat-panel .chat-message {
  font-size: 0.75rem;
  padding: 2px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.9);
}

.video-chat-panel .chat-input-row {
  display: flex;
  gap: 4px;
}

.video-chat-panel .chat-input-row input {
  flex: 1;
  font-size: 0.75rem;
  padding: 4px 6px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--r-sm);
  color: #fff;
}

.video-chat-panel .chat-input-row button {
  font-size: 0.7rem;
  padding: 4px 8px;
}

.video-chat-panel .chat-name-input {
  max-width: 70px;
}

/* ── Custom Timeline ── */
.custom-timeline {
  position: relative;
  height: 24px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  cursor: pointer;
  width: 100%;
  display: flex;
  align-items: center;
  transition: background var(--tr-fast);
}

.custom-timeline:hover {
  background: var(--bg-hover);
}

.timeline-track {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  height: 6px;
  width: 100%;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  pointer-events: none;
}

.timeline-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 100%;
  background: var(--accent);
  opacity: 0.2;
  /* Very subtle background fill instead of solid */
  z-index: 1;
  pointer-events: none;
  transition: width 0.3s cubic-bezier(0.25, 1, 0.5, 1);
}

.timeline-playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--accent);
  z-index: 10;
  pointer-events: none;
  transform: translateX(-50%);
  box-shadow: 0 0 4px rgba(239, 68, 68, 0.5);
  /* Glow effect for the line */
  transition: left 0.3s cubic-bezier(0.25, 1, 0.5, 1), transform 0.1s ease;
}

/* Add a pseudo-element for the top handle of the playhead */
.timeline-playhead::before {
  content: '';
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 6px solid var(--accent);
}

.playhead-time {
  position: absolute;
  top: -26px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: white;
  padding: 2px 6px;
  font-size: 0.7rem;
  font-weight: 600;
  border-radius: 4px;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.timeline-clips {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.timeline-clip-segment {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  height: 6px;
  background: var(--accent-glow);
  border: 1px solid var(--accent);
  border-radius: 3px;
  pointer-events: auto;
  opacity: 0.7;
}

.timeline-clip-segment.rival {
  background: rgba(239, 68, 68, 0.15);
  border-color: #ef4444;
}

.timeline-clip-segment:hover {
  opacity: 1;
}

.clip-stretch-handle {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 6px;
  height: 14px;
  background: white;
  border-radius: 2px;
  cursor: ew-resize;
  pointer-events: auto;
}

.clip-stretch-handle.left {
  left: -3px;
}

.clip-stretch-handle.right {
  right: -3px;
}

/* ── Tag Bar (below video) ── */
.tag-bar {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: var(--sp-sm) var(--sp-md);
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
}

.tag-team-row {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
}

/* Rival row (bottom) tag buttons */
.tag-btn-rival {
  border-color: rgba(239, 68, 68, 0.3);
  color: #fca5a5;
}

.tag-btn-rival:hover {
  border-color: #ef4444;
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.25);
}

.tag-btn-rival.tag-flash {
  animation: tagFlashRival 0.5s ease;
}

@keyframes tagFlashRival {
  0% {
    background: #ef4444;
    color: #fff;
    transform: scale(0.95);
  }

  100% {
    background: var(--bg-tertiary);
    color: #fca5a5;
    transform: scale(1);
  }
}

.tag-buttons-row {
  display: flex;
  flex: 1;
  gap: var(--sp-xs);
}

.tag-buttons-row .tag-btn {
  flex: 1;
  text-align: center;
  padding: 7px 6px;
  font-size: 0.82rem;
}

/* Tag bar header with edit toggle */
.tag-bar-header {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-xs);
}

.tag-rows-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tag-editor-toggle {
  flex-shrink: 0;
  font-size: 0.8rem;
  padding: 6px 8px;
  margin-top: 2px;
}

.tag-editor-toggle.active {
  background: var(--accent-glow);
  border-color: var(--accent);
  color: var(--accent-hover);
}

/* Tag Edit Mode — buttons become clickable to edit */
.tag-btn.tag-edit-mode {
  cursor: pointer;
  border-style: dashed;
  border-color: var(--accent);
  opacity: 0.85;
}

.tag-btn.tag-edit-mode:hover {
  opacity: 1;
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.tag-btn.tag-editing {
  border-style: solid;
  border-color: var(--accent);
  background: var(--accent-glow);
  opacity: 1;
  box-shadow: 0 0 0 2px var(--accent);
}

.tag-btn.tag-btn-add {
  border-style: dashed;
  opacity: 0.5;
  font-size: 1.1rem;
  font-weight: 700;
  min-width: 42px;
  flex: 0;
}

.tag-btn.tag-btn-add:hover {
  opacity: 0.9;
}

/* Inline Tag Editor */
.tag-editor-inline {
  border-top: 1px solid var(--border);
  margin-top: 4px;
  padding: 6px 0 2px;
}

.tag-editor-inline-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.editor-lbl {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
}

.tag-edit-num {
  width: 48px;
  padding: 3px 4px;
  font-size: 0.78rem;
  text-align: center;
}

.tag-edit-row-select {
  padding: 3px 4px;
  font-size: 0.75rem;
}

.clip-edit-group {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-xs);
  padding-top: 4px;
  border-top: 1px solid var(--border);
  margin-top: 2px;
}

.ctrl-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.ctrl-separator {
  color: var(--border);
  margin: 0 4px;
}

/* ==========================================================================
   CLIP VIEW TOOLBAR
   ========================================================================== */
.clip-view-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 12px;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  gap: 12px;
  position: relative;
  z-index: 100;
  flex-shrink: 0;
}

.toolbar-section {
  display: flex;
  align-items: center;
  gap: 8px;
}

.timing-controls {
  flex: 1;
  justify-content: center;
}

.clip-toolbar-flags {
  display: flex;
  gap: 4px;
}

.flag-btn-mini {
  background: none;
  border: 1px solid transparent;
  padding: 4px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1.1rem;
  transition: all 0.2s ease;
  opacity: 0.7;
}

.flag-btn-mini:hover {
  background: var(--bg-hover);
  opacity: 1;
}

.flag-btn-mini.active {
  background: var(--bg-hover);
  border-color: var(--border);
  opacity: 1;
}

/* ==========================================================================
   SIDEBAR (RIGHT PANEL)
   ========================================================================== */
.side-panel {
  width: var(--panel-w);
  min-width: var(--panel-w);
  max-width: var(--panel-w);
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: relative;
  transition: width var(--tr-slow), min-width var(--tr-slow), max-width var(--tr-slow), opacity var(--tr-normal);
  overflow: visible;
  /* Allow floating button */
}

.side-panel.collapsed {
  width: 0;
  min-width: 0;
  max-width: 0;
  opacity: 0;
  border-left: none;
}

.btn-collapse {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  left: -28px;
  width: 28px;
  height: 60px;
  border-radius: var(--r-sm) 0 0 var(--r-sm);
  border: 1px solid var(--border);
  border-right: none;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  transition: all var(--tr-fast);
}

.btn-collapse:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  width: 34px;
  left: -34px;
}

.btn-expand {
  position: fixed;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 60px;
  border-radius: var(--r-sm) 0 0 var(--r-sm);
  border: 1px solid var(--border);
  border-right: none;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 1.2rem;
  z-index: 50;
  transition: all var(--tr-fast);
}

.btn-expand:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  width: 34px;
}

/* ── Panel Content ── */
.panel-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: var(--sp-lg) var(--sp-md) var(--sp-md);
}

.panel-section {
  margin-bottom: var(--sp-lg);
}

.panel-section.panel-section-fixed {
  flex-shrink: 0;
}

.panel-section.flex-grow {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.panel-section.flex-grow .clip-list {
  flex: 1;
  overflow-y: auto;
}

/* ── Filter Chips (multi-select) ── */
.filter-chips-container {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: var(--sp-sm);
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: var(--r-xl);
  background: var(--accent-glow);
  border: 1px solid var(--accent);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent-hover);
  white-space: nowrap;
}

.filter-chip.rival {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.4);
  color: #fca5a5;
}

.filter-chip.playlist {
  background: rgba(6, 182, 212, 0.12);
  border-color: rgba(6, 182, 212, 0.4);
  color: #67e8f9;
}

.filter-chip-x {
  background: none;
  border: none;
  color: currentColor;
  font-size: 0.65rem;
  padding: 0;
  opacity: 0.6;
  cursor: pointer;
  line-height: 1;
  transition: opacity var(--tr-fast);
}

.filter-chip-x:hover {
  opacity: 1;
}

.section-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-bottom: var(--sp-sm);
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 700;
  background: var(--bg-hover);
  color: var(--text-secondary);
}

.panel-actions {
  padding: var(--sp-sm) 0;
  border-top: 1px solid var(--border);
}

/* ═══════════════════════════════════════════
   TAG BUTTONS
   ═══════════════════════════════════════════ */
.tag-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-xs);
}

.tag-btn {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-size: 0.82rem;
  font-weight: 500;
  transition: all var(--tr-fast);
  position: relative;
  overflow: hidden;
}

.tag-btn:hover {
  border-color: var(--accent);
  background: var(--accent-glow);
  color: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-glow);
}

.tag-btn:active {
  transform: scale(0.95);
}

.tag-buttons-row .tag-btn.tag-btn-small {
  flex: none !important;
  width: auto;
  padding: 4px 8px;
  min-width: 45px;
  font-size: 0.75rem;
}

.tag-btn.tag-flash {
  animation: tagFlash 0.5s ease;
}

@keyframes tagFlash {
  0% {
    background: var(--accent);
    color: #fff;
    transform: scale(0.95);
  }

  100% {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    transform: scale(1);
  }
}

/* ═══════════════════════════════════════════
   CLIP LIST
   ═══════════════════════════════════════════ */
.clip-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-bottom: 40px; /* Space for the flag popover for the last clip */
}

.clip-item {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  padding: 8px 10px;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: all var(--tr-fast);
  border: 1px solid transparent;
  position: relative;
}

.clip-item:hover {
  background: var(--bg-hover);
}

.clip-item.drag-over-top {
  border-top: 2px solid var(--primary) !important;
  background: var(--bg-hover);
}

.clip-item.drag-over-bottom {
  border-bottom: 2px solid var(--primary) !important;
  background: var(--bg-hover);
}

/* Fix HTML5 Drag flickering by ignoring child elements during drag */
body.is-dragging-clip .clip-item * {
  pointer-events: none !important;
}

.drag-handle {
  cursor: grab;
  color: var(--text-muted);
  opacity: 0.5;
  padding: 0 4px 0 2px;
  font-size: 1.1rem;
  user-select: none;
}
.drag-handle:active {
  cursor: grabbing;
}
.drag-handle:hover {
  opacity: 1;
  color: var(--text);
}

.clip-item.active {
  background: var(--accent-glow);
  border-color: var(--accent);
}

/* Clip actions row — hidden until hover */
.clip-actions-row {
  opacity: 0;
  pointer-events: none;
  align-items: center;
  gap: 2px;
  position: absolute;
  right: 10px;
  background: var(--bg-hover);
  padding-left: 10px;
  transition: opacity var(--tr-fast);
  display: flex;
}

.clip-item:hover .clip-actions-row,
.clip-item.active .clip-actions-row {
  opacity: 1;
  pointer-events: auto;
}

.clip-item.active .clip-actions-row {
  background: var(--accent-glow);
}

.clip-flags-display {
  transition: opacity var(--tr-fast);
}

.clip-item:hover .clip-flags-display {
  opacity: 0;
}

.clip-flag-toggle {
  background: none;
  border: none;
  font-size: 0.7rem;
  padding: 2px 3px;
  opacity: 0.35;
  cursor: pointer;
  transition: all var(--tr-fast);
  border-radius: var(--r-sm);
  line-height: 1;
}

.clip-flag-toggle:hover {
  opacity: 0.8;
  background: var(--bg-elevated);
}

.clip-flag-toggle.active {
  opacity: 1;
  background: var(--accent-glow);
}

.clip-tag-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--r-xl);
  font-size: 0.7rem;
  font-weight: 600;
  background: var(--bg-elevated);
  color: var(--accent-hover);
  white-space: nowrap;
  flex-shrink: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}

.clip-tag-badge.rival {
  color: #fca5a5;
  background: rgba(239, 68, 68, 0.15);
}

.clip-time {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.clip-flags-display {
  margin-left: auto;
  font-size: 0.85rem;
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}

/* Fixed-slot indicator row */
.clip-indicators-row {
  display: flex;
  align-items: center;
  gap: 1px;
  flex-shrink: 0;
}

.clip-flag-slot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  font-size: 0.6rem;
  opacity: 0.15;
  transition: opacity var(--tr-fast);
  line-height: 1;
}

.clip-flag-slot.on {
  opacity: 1;
}

.clip-flag-slot.action-slot {
  opacity: 0;
}

.clip-item:hover .clip-flag-slot.action-slot {
  opacity: 1;
}

/* Action icons in clip list */
.clip-action-icon {
  background: none;
  border: none;
  font-size: 0.6rem;
  padding: 0;
  cursor: pointer;
  transition: all var(--tr-fast);
  line-height: 1;
}

.clip-action-icon:hover {
  transform: scale(1.3);
}

/* Clip action buttons (playlist add, delete) */
.clip-action-btn {
  background: none;
  border: none;
  font-size: 0.75rem;
  padding: 2px 4px;
  cursor: pointer;
  opacity: 0;
  transition: all var(--tr-fast);
  line-height: 1;
}

.clip-item:hover .clip-action-btn {
  opacity: 0.6;
}

.clip-action-btn:hover {
  opacity: 1 !important;
  transform: scale(1.2);
}

/* clip-delete-btn styles now handled by .clip-action-btn */

/* ═══════════════════════════════════════════
   SOURCE SELECTOR & FLAGS
   ═══════════════════════════════════════════ */
.source-selector {
  display: flex;
  flex-direction: column;
  gap: var(--sp-sm);
}

/* Tag filter grid: compact wrap of small chips */
.tag-filter-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-height: 180px;
  overflow-y: auto;
}

.source-search-input {
  width: 100%;
  padding: 5px 8px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 0.72rem;
  margin-bottom: 6px;
}

.source-search-input::placeholder {
  color: var(--text-muted);
}

.source-search-input:focus {
  outline: none;
  border-color: var(--accent);
}

.source-btn {
  display: inline-flex;
  padding: 3px 8px;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 0.68rem;
  font-weight: 500;
  transition: all var(--tr-fast);
  white-space: nowrap;
  cursor: pointer;
}

.source-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--text-muted);
}

.source-btn.active {
  background: var(--accent-glow);
  border-color: var(--accent);
  color: var(--accent-hover);
}

.source-btn-rival.active {
  background: rgba(239, 68, 68, 0.15);
  border-color: var(--danger);
  color: #fca5a5;
}

.source-group {
  margin-top: 2px;
}

.source-group-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 6px 12px;
  text-align: left;
  border: none;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: all var(--tr-fast);
}

.source-group-toggle:hover {
  background: var(--bg-hover);
  color: var(--text-secondary);
}

.toggle-arrow {
  font-size: 0.7rem;
  transition: transform var(--tr-fast);
  display: inline-block;
}

.source-group-toggle.open .toggle-arrow {
  transform: rotate(90deg);
}

.source-group-body {
  overflow: hidden;
  transition: max-height var(--tr-normal);
  max-height: 500px;
  padding: var(--sp-sm);
}

.source-group-body.collapsed {
  max-height: 0;
  overflow: hidden;
  padding: 0 var(--sp-sm);
}

/* Flag buttons */
.flag-filter-bar {
  display: flex;
  gap: 4px;
}

.flag-btn {
  flex: 1;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg-secondary);
  font-size: 0.85rem;
  text-align: center;
  transition: all var(--tr-fast);
  cursor: pointer;
}

.flag-btn:hover {
  border-color: var(--accent);
  background: var(--bg-hover);
}

.flag-btn.active {
  border-color: var(--accent);
  background: var(--accent-glow);
  box-shadow: var(--shadow-glow);
}

.flag-btn.filter-active {
  border-color: var(--warning);
  background: rgba(245, 158, 11, 0.15);
}

/* Active Playlist Header */
.active-playlist-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.12), rgba(99, 102, 241, 0.12));
  border: 1px solid rgba(6, 182, 212, 0.3);
  border-radius: var(--r-sm);
}

.active-playlist-name {
  font-size: 0.9rem;
  font-weight: 700;
  color: #67e8f9;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.active-playlist-actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}

.btn-playlist-action {
  background: none;
  border: none;
  font-size: 0.75rem;
  padding: 3px 5px;
  border-radius: var(--r-sm);
  cursor: pointer;
  opacity: 0.6;
  transition: all var(--tr-fast);
}

.btn-playlist-action:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.08);
}

#btn-pl-close {
  color: #f87171;
  opacity: 0.9;
  font-weight: bold;
}

/* ═══════════════════════════════════════════
   PLAYLIST
   ═══════════════════════════════════════════ */
.playlist-create-row {
  display: flex;
  gap: var(--sp-xs);
  margin-bottom: var(--sp-sm);
}

.input-sm {
  flex: 1;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-size: 0.82rem;
  outline: none;
  transition: border-color var(--tr-fast);
}

.input-sm:focus {
  border-color: var(--accent);
}

.playlist-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.playlist-item {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  padding: 6px 10px;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background var(--tr-fast);
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.playlist-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.playlist-item .pl-icon {
  flex-shrink: 0;
}

.playlist-item .pl-count {
  margin-left: auto;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.playlist-select-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 300px;
  overflow-y: auto;
}

.playlist-select-item {
  display: block;
  width: 100%;
  padding: 8px 12px;
  text-align: left;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all var(--tr-fast);
}

.playlist-select-item:hover {
  border-color: var(--accent);
  background: var(--accent-glow);
}

/* ═══════════════════════════════════════════
   MODALS
   ═══════════════════════════════════════════ */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
  transition: opacity var(--tr-normal);
}

.modal.hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}

.modal-box {
  position: relative;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-xl);
  width: 420px;
  max-width: 90vw;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.3s ease;
}

.modal-sm {
  width: 320px;
}

.modal-md {
  width: 600px;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: translateY(-20px) scale(0.95);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-tabs {
  display: flex;
  gap: 2px;
  background: var(--bg-tertiary);
  padding: 4px;
  border-radius: var(--r-md);
  margin-bottom: var(--sp-lg);
  border: 1px solid var(--border);
}

.tab-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: var(--r-sm);
  transition: all var(--tr-fast);
}

.tab-btn:hover:not(.active) {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.tab-btn.active {
  background: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

.tab-icon {
  font-size: 1.1rem;
}

.tab-content.hidden {
  display: none;
}

.modal-box h2 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: var(--sp-lg);
  color: var(--text-primary);
}

.form-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: var(--sp-md);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.input {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-size: 0.9rem;
  outline: none;
  transition: border-color var(--tr-fast);
}

.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 400;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-sm);
  margin-top: var(--sp-lg);
}

/* ═══════════════════════════════════════════
   NAVIGATION ARROWS
   ═══════════════════════════════════════════ */
.nav-arrows {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 20;
}

.nav-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 80px;
  border: none;
  background: rgba(0, 0, 0, 0.4);
  color: #fff;
  font-size: 1.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  transition: all var(--tr-fast);
  backdrop-filter: blur(4px);
}

.nav-arrow:hover {
  background: rgba(99, 102, 241, 0.5);
}

.nav-arrow-left {
  left: 0;
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
}

.nav-arrow-right {
  right: var(--panel-w);
  border-radius: var(--r-sm) 0 0 var(--r-sm);
}

body.panel-collapsed .nav-arrow-right {
  right: 0;
}

/* ═══════════════════════════════════════════
   TOAST NOTIFICATIONS
   ═══════════════════════════════════════════ */
.toast-container {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: var(--sp-sm);
  pointer-events: none;
}

.toast {
  padding: 10px 20px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text-primary);
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.2s forwards;
  pointer-events: auto;
  white-space: nowrap;
}

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

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

.toast-migration {
  width: min(760px, calc(100vw - 32px));
  white-space: normal;
  line-height: 1.4;
  padding: 14px 16px;
  animation: toastIn 0.3s ease;
}

.toast-migration-message {
  font-size: 0.85rem;
}

.toast-migration-actions {
  margin-top: 10px;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes toastOut {
  from {
    opacity: 1;
  }

  to {
    opacity: 0;
    transform: translateY(-10px);
  }
}

/* ═══════════════════════════════════════════
   UTILITY
   ═══════════════════════════════════════════ */
.hidden {
  display: none !important;
}

/* Pulse animation for active clip */
@keyframes pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.6;
  }
}

/* Smooth transitions for panel collapse */
.side-panel,
#video-area {
  transition: all var(--tr-slow);
}

/* ═══════════════════════════════════════════
   PLAYLIST ONLY MODE
   ═══════════════════════════════════════════ */
body.playlist-only-mode #app-header .header-center,
body.playlist-only-mode #app-header .header-right #game-selector,
body.playlist-only-mode #app-header .header-right #btn-new-game,
body.playlist-only-mode #app-header .header-right .header-divider,
body.playlist-only-mode #app-header .header-right #btn-my-projects {
  display: none !important;
}

/* ═══════════════════════════════════════════
   NOVEDADES DROPDOWN (Header)
   ═══════════════════════════════════════════ */
.novedades-wrapper {
  display: inline-flex;
  align-items: center;
}

.novedades-btn {
  position: relative;
  font-size: 1.1rem;
  padding: 4px 8px;
}

.novedades-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #ef4444;
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  line-height: 1;
}

.novedades-dropdown {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  width: 340px;
  max-height: 420px;
  overflow-y: auto;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
  padding: 8px 0;
}

.novedades-dropdown .novedades-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

.novedades-dropdown .novedades-header h4 {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text);
}

.novedades-dropdown .nov-item {
  padding: 8px 12px;
  cursor: pointer;
  transition: background 0.15s;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.novedades-dropdown .nov-item.nov-chat {
  border-left: 3px solid var(--accent);
  padding-left: 9px;
}

.novedades-dropdown .nov-item.nov-activity {
  border-left: 3px solid var(--warning);
  padding-left: 9px;
}

.novedades-dropdown .nov-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.novedades-dropdown .nov-item:last-child {
  border-bottom: none;
}

.novedades-dropdown .nov-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 3px;
}

.novedades-dropdown .nov-label {
  font-size: 0.7rem;
  color: var(--accent-hover);
  font-weight: 600;
}

.novedades-dropdown .nov-time {
  font-size: 0.6rem;
  color: var(--text-muted);
}

.novedades-dropdown .nov-body {
  font-size: 0.78rem;
  color: var(--text);
}

.novedades-dropdown .nov-empty {
  text-align: center;
  padding: 20px 12px;
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* ═══════════════════════════════════════════
   READ ONLY MODE (View Only Link)
   ═══════════════════════════════════════════ */
body.read-only-mode #btn-mode-analyze,
body.read-only-mode #btn-mode-share,
body.read-only-mode #btn-mode-view,
body.read-only-mode #mode-slider,
body.read-only-mode #btn-new-game,
body.read-only-mode .header-divider,
body.read-only-mode #btn-share-project,
body.read-only-mode #btn-pl-share,
body.read-only-mode #btn-pl-wa,
body.read-only-mode .pl-wa-btn,
body.read-only-mode .pl-share-btn,
body.read-only-mode .share-wa-btn,
body.read-only-mode #btn-my-projects,
body.read-only-mode #btn-save-project {
  display: none !important;
}

body.read-only-mode .mode-toggle {
  min-width: 180px;
  padding: 8px 16px;
  background: var(--bg-secondary);
  border-color: rgba(255, 255, 255, 0.05);
}

body.read-only-mode .read-only-label {
  display: flex !important;
}

/* Ensure bell is visible in read-only mode */
body.read-only-mode #novedades-wrapper {
  display: inline-flex !important;
}

/* Let the save button show up IF they are also in a playlist link, per user request */
body.read-only-mode.playlist-only-mode #btn-save-project {
  display: inline-flex !important;
}

/* ═══════════════════════════════════════════
   DRAWING TOOL
   ═══════════════════════════════════════════ */
.drawing-canvas {
  position: absolute;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  cursor: crosshair;
  opacity: 0;
  transition: opacity var(--tr-fast);
  touch-action: none;
}

.drawing-canvas.active {
  pointer-events: auto;
  opacity: 1;
}

.drawing-toolbar {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  z-index: 30;
  display: flex;
  gap: 12px;
  background: rgba(22, 25, 34, 0.9);
  backdrop-filter: blur(8px);
  padding: 8px 16px;
  border-radius: var(--r-xl);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: all var(--tr-normal);
}

.drawing-toolbar.active {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

.draw-toolbar-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.draw-toolbar-group:not(:last-child)::after {
  content: '';
  width: 1px;
  height: 24px;
  background: var(--border);
  margin-left: 6px;
}

.draw-color-swatch {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform var(--tr-fast), border-color var(--tr-fast);
}

.draw-color-swatch:hover {
  transform: scale(1.15);
}

.draw-color-swatch.active {
  border-color: #fff;
  transform: scale(1.15);
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.5);
}

.draw-tool-btn {
  font-size: 1.1rem;
  padding: 4px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.draw-tool-btn.active {
  background: var(--bg-active);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.draw-size-slider {
  width: 60px;
  accent-color: var(--accent);
  cursor: pointer;
}

.drawing-preview-overlay {
  position: absolute;
  inset: 0;
  z-index: 25;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--tr-fast);
}

.drawing-preview-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.drawing-preview-overlay img {
  max-width: 100%;
  max-height: 100%;
}

.drawing-preview-close {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(239, 68, 68, 0.8);
  color: #fff;
  border: none;
  border-radius: var(--r-sm);
  width: 32px;
  height: 32px;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--tr-fast);
}

.drawing-preview-close:hover {
  background: #ef4444;
}

/* Description input inside drawing toolbar */
.draw-description-input {
  font-family: inherit;
  font-size: 0.75rem;
  padding: 4px 8px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--r-sm);
  color: #fff;
  outline: none;
  width: 180px;
  transition: border-color var(--tr-fast);
}

.draw-description-input::placeholder {
  color: rgba(255, 255, 255, 0.4);
}

.draw-description-input:focus {
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.15);
}

/* Auto-show drawing overlays (during playback) */
.drawing-auto-overlay {
  position: absolute;
  inset: 0;
  z-index: 25;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: drawingOverlayIn 0.25s ease;
}

@keyframes drawingOverlayIn {
  from { opacity: 0; transform: scale(0.97); }
  to   { opacity: 1; transform: scale(1); }
}

.drawing-auto-overlay img {
  max-width: 100%;
  max-height: 100%;
  pointer-events: none;
}

.drawing-auto-overlay .drawing-auto-info {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  font-size: 0.8rem;
  padding: 5px 14px;
  border-radius: var(--r-xl);
  white-space: nowrap;
  pointer-events: none;
  max-width: 80%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.drawing-auto-overlay .drawing-auto-hint {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(99, 102, 241, 0.85);
  color: #fff;
  font-size: 0.7rem;
  padding: 3px 12px;
  border-radius: var(--r-xl);
  pointer-events: none;
  white-space: nowrap;
}

.drawing-auto-close {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(239, 68, 68, 0.8);
  color: #fff;
  border: none;
  border-radius: var(--r-sm);
  width: 32px;
  height: 32px;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--tr-fast);
}

.drawing-auto-close:hover {
  background: #ef4444;
}


/* Chat Drawing Thumbnails */
.clip-draw-btn {
  background: none;
  border: none;
  font-size: 0.7rem;
  padding: 2px 3px;
  opacity: 0.5;
  cursor: pointer;
  transition: all var(--tr-fast);
  line-height: 1;
}

.clip-draw-btn:hover {
  opacity: 1;
}

.clip-draw-btn.has-drawings {
  opacity: 0.9;
}

.chat-drawing {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.drawing-thumb-wrap {
  position: relative;
  width: 120px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: #000;
  overflow: hidden;
  cursor: pointer;
  transition: border-color var(--tr-fast);
  margin-top: 4px;
}

.drawing-thumb-wrap:hover {
  border-color: var(--accent);
}

.drawing-thumb-wrap img.drawing-thumbnail {
  width: 100%;
  height: auto;
  display: block;
}

.drawing-time-badge {
  position: absolute;
  bottom: 4px;
  right: 4px;
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  font-size: 0.6rem;
  padding: 2px 4px;
  border-radius: 3px;
}

/* Playlist-only mode: keep full View UI available */

/* ═══════════════════════════════════════════
   MOBILE RESPONSIVENESS
   ═══════════════════════════════════════════ */
@media (max-width: 768px) {
  html {
    height: auto;
  }

  html,
  body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
  }

  /* Desktop uses body { height:100vh; overflow:hidden } — that blocks page scroll on phones */
  body {
    height: auto;
    min-height: 100dvh;
    max-height: none;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  #app-header,
  #app-main {
    width: 100%;
    max-width: 100%;
  }

  /* Header adjustments */
  #app-header {
    height: 52px;
    padding: 0 8px;
    gap: 6px;
  }

  .header-left {
    min-width: 0;
    flex-shrink: 1;
  }

  .app-title {
    font-size: 0.82rem;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: min(140px, 38vw);
  }

  .header-right {
    gap: 4px;
  }

  .header-center {
    flex: 1;
    min-width: 0;
  }

  .mode-toggle {
    min-width: 0;
    width: 100%;
  }

  .btn {
    padding: 6px 10px;
    font-size: 0.8rem;
  }

  /* Collapse control sits off-canvas on narrow screens — hide to avoid horizontal overflow */
  .btn-collapse,
  .btn-expand {
    display: none !important;
  }

  /* Main Layout: Stack video and panel — page scroll lives on body (see body rules above) */
  #app-main {
    flex-direction: column;
    height: auto;
    min-height: calc(100vh - var(--header-h));
    overflow: visible;
  }

  /* Video area: full width; height comes from player (below) */
  #video-area {
    flex: none;
    width: 100%;
    min-width: 0;
    height: auto;
  }

  /*
   * Player: la caja coincide con 16:9 al ancho de pantalla. Antes forzábamos ~56vh
   * y el video real era más bajo → mucha franja negra vacía sin sentido.
   */
  #player-container {
    flex: none;
    width: 100%;
    min-width: 0;
    height: auto;
    aspect-ratio: 16 / 9;
    min-height: 0;
    max-height: none;
  }

  /* Side panel: must override desktop fixed 340px min-width */
  .side-panel {
    flex: none;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    height: auto;
    border-left: none;
    border-top: 1px solid var(--border);
  }

  .side-panel.collapsed {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    opacity: 1;
    border-top: 1px solid var(--border);
  }

  .panel-content {
    overflow: visible;
    /* Prevent double scrollbars if we let body scroll */
    padding: 10px 8px 8px;
  }

  .source-group-toggle {
    font-size: 0.76rem;
    padding: 8px 10px;
  }

  .source-btn {
    padding: 5px 10px;
    font-size: 0.74rem;
  }

  .flag-btn {
    min-height: 34px;
  }

  .clip-item {
    padding: 10px 8px;
    min-height: 42px;
    gap: 6px;
  }

  .clip-checkbox {
    width: 17px;
    height: 17px;
  }

  .clip-tag-badge {
    max-width: 42vw;
  }

  .clip-time {
    font-size: 0.72rem;
  }

  .view-selection-bar {
    position: sticky;
    bottom: 0;
    z-index: 20;
  }

  /* Tag Buttons wrap */
  .tag-buttons-row {
    flex-wrap: wrap;
    justify-content: center;
  }

  .tag-btn {
    flex: 0 0 calc(33.333% - 4px);
    margin-bottom: 4px;
    padding: 10px 4px;
  }

  /* Hide nav arrows on mobile */
  .nav-arrow {
    display: none;
  }

  /* Modals */
  .modal-content {
    width: 95%;
    margin: 10px;
  }

  /* Mobile focus for shared links / read-only players */
  body.read-only-mode #app-header {
    position: sticky;
    top: 0;
    z-index: 200;
  }

  /* Solo ocultamos acciones; la marca (logo + nombre) sí se ve */
  body.read-only-mode #app-header .header-right {
    display: none !important;
  }

  body.read-only-mode #app-header .header-left {
    display: flex !important;
  }

  body.read-only-mode #app-header .header-center {
    flex: 1;
    min-width: 0;
    width: auto;
  }

  body.read-only-mode .mode-toggle {
    padding: 6px 10px;
  }

  body.read-only-mode .read-only-label {
    font-size: 0.72rem;
    letter-spacing: 0.5px;
  }

  /*
   * Read-only shared links: let the document scroll (nested flex + overflow:hidden
   * breaks touch scroll on many mobile browsers).
   */
  body.read-only-mode #app-main {
    height: auto;
    min-height: calc(100dvh - 52px);
    max-height: none;
    overflow: visible;
    display: flex;
    flex-direction: column;
  }

  body.read-only-mode #video-area {
    flex: 0 0 auto;
    width: 100%;
  }

  body.read-only-mode .side-panel {
    flex: 0 0 auto;
    width: 100% !important;
    min-height: 0;
    overflow: visible;
    display: flex;
    flex-direction: column;
    border-top: 1px solid var(--border);
  }

  body.read-only-mode #panel-view {
    flex: 0 0 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: visible;
    padding-top: 8px;
  }

  body.read-only-mode #panel-view .panel-section.flex-grow {
    flex: 0 0 auto;
    min-height: 0;
    margin-bottom: 0;
    overflow: visible;
  }

  body.read-only-mode #panel-view .panel-section.flex-grow .clip-list {
    flex: 0 0 auto;
    overflow: visible;
    max-height: none;
  }

  body.read-only-mode #view-clip-list {
    padding-bottom: 10px;
  }

  /* ═══ Clip view toolbar (móvil): solo ⏪ / ⏯️ / ⏩ + Chat ═══ */
  #clip-view-toolbar {
    flex-wrap: nowrap;
    justify-content: center;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
  }

  #clip-view-toolbar .timing-controls,
  #clip-view-toolbar #btn-clip-mark-in,
  #clip-view-toolbar #btn-clip-mark-out,
  #clip-view-toolbar #btn-clip-speed,
  #clip-view-toolbar #btn-clip-draw,
  #clip-view-toolbar [data-action="delete-clip"],
  #clip-view-toolbar #btn-clip-close {
    display: none !important;
  }

  #clip-view-toolbar .ctrl-separator {
    display: none !important;
  }

  #clip-view-toolbar > .toolbar-section:nth-child(2) {
    flex: 1 1 auto;
    justify-content: center;
    gap: 12px !important;
    min-width: 0;
  }

  #clip-view-toolbar > .toolbar-section:nth-child(3) {
    flex: 0 0 auto;
    justify-content: center;
    gap: 0;
  }

  #clip-view-toolbar #btn-clip-chat {
    padding: 8px 12px;
    font-size: 0.85rem;
  }
}

/* ═══════════════════════════════════════════
   Teléfono en horizontal: solo video grande (sin chrome de la app)
   max-height evita activarlo en escritorio con ventana ancha pero alta
   ═══════════════════════════════════════════ */
@media (orientation: landscape) and (max-height: 520px) {
  html,
  body {
    height: 100%;
    max-height: 100%;
    overflow: hidden !important;
    width: 100%;
    max-width: 100%;
  }

  body {
    /* iPhone con notch / Dynamic Island */
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
    box-sizing: border-box;
  }

  #app-header,
  .side-panel,
  .btn-expand,
  #clip-view-toolbar,
  #custom-timeline,
  #tag-bar,
  #toast-container,
  #nav-arrows,
  #focus-overlay {
    display: none !important;
  }

  #app-main {
    flex-direction: column !important;
    height: 100dvh !important;
    min-height: 100dvh !important;
    max-height: 100dvh !important;
    overflow: hidden !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  #video-area {
    flex: 1 1 auto !important;
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    min-width: 0 !important;
    min-height: 0 !important;
    height: 100% !important;
    max-height: none !important;
  }

  #player-container {
    flex: 1 1 auto !important;
    width: 100% !important;
    min-height: 0 !important;
    height: 100% !important;
    max-height: none !important;
    aspect-ratio: unset !important;
  }

  #youtube-player,
  #youtube-player iframe {
    width: 100% !important;
    height: 100% !important;
  }

  /* Chat flotante: oculto en modo “solo video” (al volver a vertical, el JS sigue manejando el estado) */
  #video-chat-panel {
    display: none !important;
  }
}

/* ═══════════════════════════════════════════
   SHARE PANEL
   ═══════════════════════════════════════════ */

.share-action-card {
  padding: 12px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background var(--tr-fast), border-color var(--tr-fast);
  margin-bottom: 8px;
}

.share-action-body {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.share-action-card:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
}

.share-action-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
}

.share-action-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.share-action-icon {
  flex-shrink: 0;
  font-size: 1rem;
  opacity: 0.55;
  line-height: 1;
  cursor: pointer;
  padding: 4px;
  border-radius: var(--r-sm);
  transition: opacity var(--tr-fast), background var(--tr-fast);
}

.share-action-icon:hover {
  opacity: 1;
  background: var(--bg-hover);
}

.share-action-icon--down {
  font-size: 1.1rem;
  font-weight: 700;
  opacity: 0.55;
  cursor: default;
}

.share-action-icon--down:hover {
  background: none;
}

.share-icon-group {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.share-wa-icon {
  color: #25d366;
  opacity: 0.7;
  display: flex;
  align-items: center;
}

.share-wa-icon:hover {
  opacity: 1;
  background: rgba(37, 211, 102, 0.12);
}

.share-wa-btn {
  color: #25d366;
  padding: 5px 8px;
}

.share-wa-btn:hover {
  background: rgba(37, 211, 102, 0.12);
  color: #25d366;
}

.share-section-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin: 12px 0 6px;
}

.share-notice {
  padding: 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: 0.82rem;
  color: var(--text-muted);
  text-align: center;
}

.share-playlist-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}