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

:root {
  --loom-blue: #4169E8;
  --loom-blue-hover: #3457c9;
  --text-primary: #1a1a2e;
  --text-secondary: #73737a;
  --text-tertiary: #a1a1a8;
  --border: #e8e8eb;
  --bg: #ffffff;
  --bg-hover: #f5f5f5;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ═══════════════════════════════════
   HEADER — full width, thin
   ═══════════════════════════════════ */

.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
}

.header-logo {
  display: flex;
  align-items: center;
  text-decoration: none;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-btn-login {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  text-decoration: none;
  padding: 7px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: background 0.15s;
}
.header-btn-login:hover {
  background: var(--bg-hover);
}

/* ═══════════════════════════════════
   MAIN — two-column layout
   ═══════════════════════════════════ */

.main {
  padding: 20px 20px 80px;
}

.two-col {
  display: flex;
  gap: 0;
  align-items: flex-start;
}

.col-left {
  flex: 7;
  min-width: 0;
  padding-left: 25%;
  padding-right: 24px;
}

.col-right {
  flex: 3;
  min-width: 200px;
  align-self: stretch;
  border-left: 1px solid var(--border);
  padding-left: 24px;
}

.col-right .right-header,
.col-right .right-divider,
.col-right .comments-panel {
  position: sticky;
  top: 56px;
}

/* ═══════════════════════════════════
   RIGHT SIDEBAR — Activity panel
   ═══════════════════════════════════ */

.right-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-bottom: 12px;
}

.icon-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid var(--border);
  border-radius: 50%;
  cursor: pointer;
  color: var(--text-secondary);
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}
.icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.activity-tab {
  font-size: 14px;
  font-weight: 600;
  color: var(--loom-blue);
  padding-bottom: 10px;
  border-bottom: 2px solid var(--loom-blue);
}

.right-divider {
  width: 100%;
  height: 1px;
  background: var(--border);
  margin-bottom: 0;
}

.comments-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 300px;
}

.comments-disabled {
  text-align: center;
  color: var(--text-secondary);
}
.comments-disabled strong {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}
.comments-disabled p {
  font-size: 13px;
  color: var(--text-tertiary);
  line-height: 1.5;
}

/* ═══════════════════════════════════
   VIDEO TITLE + CREATOR INFO
   ═══════════════════════════════════ */

.video-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
  margin-bottom: 4px;
}

.creator-info {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--text-secondary);
}

.creator-name { font-weight: 500; }
.creator-sep { color: var(--text-tertiary); }

/* ═══════════════════════════════════
   VIDEO PLAYER
   ═══════════════════════════════════ */

.video-container {
  width: 100%;
  margin-bottom: 24px;
}

.player-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 16px rgba(0,0,0,0.08);
}

.player {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  background: #000;
}

/* CTA Overlay */

.cta-overlay {
  position: absolute;
  top: 12px;
  right: 12px;
  padding: 10px 24px;
  background: #FF3000;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  border-radius: 6px;
  text-decoration: none;
  z-index: 10;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  transition: background 0.2s, transform 0.15s;
}
.cta-overlay:hover {
  background: #e62b00;
  transform: translateY(-1px);
}

/* Fullscreen: scale CTA button ~3x for visibility on big screens.
   Browsers vary on which element gets :fullscreen, so we cover all common cases. */
.player-wrapper:fullscreen .cta-overlay,
.player-wrapper:-webkit-full-screen .cta-overlay,
.video-container:fullscreen .cta-overlay,
.video-container:-webkit-full-screen .cta-overlay,
:fullscreen .cta-overlay,
:-webkit-full-screen .cta-overlay {
  top: 32px;
  right: 32px;
  padding: 26px 56px;
  font-size: 36px;
  font-weight: 700;
  border-radius: 14px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.55);
  letter-spacing: 0.3px;
}

/* Play overlay */

.play-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.15);
  cursor: pointer;
  transition: opacity 0.3s;
  z-index: 5;
}
.play-overlay.hidden { opacity: 0; pointer-events: none; }

.play-btn {
  background: none;
  border: none;
  cursor: pointer;
  width: 72px;
  height: 72px;
  transition: transform 0.15s;
}
.play-btn:hover { transform: scale(1.08); }

/* Controls */

.controls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 12px;
  background: linear-gradient(transparent, rgba(0,0,0,0.7));
  opacity: 0;
  transition: opacity 0.25s;
  z-index: 6;
}
.player-wrapper:hover .controls,
.controls.visible { opacity: 1; }

.controls-left,
.controls-right {
  display: flex;
  align-items: center;
  gap: 2px;
}

.ctrl-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.9;
  transition: opacity 0.15s, transform 0.12s;
  color: #fff;
  min-width: 36px;
  height: 36px;
  border-radius: 6px;
}
.ctrl-btn:hover { opacity: 1; background: rgba(255,255,255,0.12); }
.ctrl-btn:active { transform: scale(0.92); }

/* Volume slider — always visible on desktop, sits to the right of the
   speaker icon (YouTube-style). The `--vol-pct` CSS variable is set
   from JS and paints the filled portion of the track: white to the
   left of the thumb, semi-transparent to the right. */
.volume-wrapper {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-right: 4px;
}
#volume-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 80px;
  height: 14px;           /* bigger vertical hit target than the track */
  background: transparent;
  cursor: pointer;
  margin: 0;
  padding: 0;
}
/* WebKit track + filled portion */
#volume-slider::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(to right,
    #fff 0%,
    #fff var(--vol-pct, 100%),
    rgba(255,255,255,0.35) var(--vol-pct, 100%),
    rgba(255,255,255,0.35) 100%);
}
/* Firefox track (uses progress instead of gradient) */
#volume-slider::-moz-range-track {
  height: 4px;
  border-radius: 2px;
  background: rgba(255,255,255,0.35);
}
#volume-slider::-moz-range-progress {
  height: 4px;
  border-radius: 2px;
  background: #fff;
}
/* Thumb — round white dot, slightly bigger on hover for YouTube feel */
#volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
  border: none;
  margin-top: -4px;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,0.4);
  transition: transform 0.12s ease;
}
#volume-slider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
  border: none;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,0.4);
  transition: transform 0.12s ease;
}
.volume-wrapper:hover #volume-slider::-webkit-slider-thumb,
#volume-slider:focus::-webkit-slider-thumb {
  transform: scale(1.25);
}
.volume-wrapper:hover #volume-slider::-moz-range-thumb,
#volume-slider:focus::-moz-range-thumb {
  transform: scale(1.25);
}
#volume-slider:focus {
  outline: none;
}

/* Skip buttons (back/forward 5s) — larger touch target.
   The "5" label is a real <span> layered on top of the circular
   arrow SVG so we can guarantee (a) it's actually the digit 5 and
   (b) it's pixel-perfect centered inside the arrow's interior,
   unlike the original YouTube SVG where the digit was a glyph path
   with subpixel hit-and-miss rendering. */
.skip-btn {
  position: relative;
  min-width: 44px;
  height: 44px;
  padding: 8px;
}
.skip-btn svg { width: 28px; height: 28px; }
.skip-num {
  position: absolute;
  top: 50%;
  left: 50%;
  /* pull down 2px so the digit sits inside the lower part of the arc */
  transform: translate(-50%, calc(-50% + 2px));
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  color: #fff;
  font-family: inherit;
  pointer-events: none;
  user-select: none;
}

/* Speed button */

.speed-wrapper { position: relative; }

.speed-btn {
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  min-width: auto;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(255,255,255,0.15);
}
.speed-btn:hover { background: rgba(255,255,255,0.25); }

#speed-label {
  font-size: 12px;
  font-weight: 600;
  pointer-events: none;
}

.speed-menu {
  display: none;
  position: absolute;
  bottom: 36px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(28,28,30,0.95);
  backdrop-filter: blur(10px);
  border-radius: 8px;
  padding: 4px;
  min-width: 72px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  z-index: 20;
}
.speed-menu.open { display: block; }

.speed-menu button {
  display: block;
  width: 100%;
  background: none;
  border: none;
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  padding: 10px 14px;
  min-height: 40px;
  border-radius: 6px;
  cursor: pointer;
  text-align: center;
  transition: background 0.1s;
}
.speed-menu button:hover { background: rgba(255,255,255,0.12); }
.speed-menu button.active { color: var(--loom-blue); font-weight: 700; }

/* Progress bar */

.progress-container {
  flex: 1;
  display: flex;
  align-items: center;
  padding: 0 4px;
}

.progress-bar {
  position: relative;
  width: 100%;
  height: 4px;
  background: rgba(255,255,255,0.40);
  border-radius: 999px;
  cursor: pointer;
  transition: height 0.12s;
  /* Larger click area via padding */
  padding: 12px 0;
  background-clip: content-box;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.18);
}
.progress-bar:hover { height: 6px; }

.progress-fill {
  height: 100%;
  background: var(--loom-blue);
  border-radius: 999px;
  width: 0;
  pointer-events: none;
  box-shadow: 0 0 6px rgba(98,93,245,0.5);
}

.progress-thumb {
  position: absolute;
  top: 50%;
  left: 0;
  width: 16px;
  height: 16px;
  background: var(--loom-blue);
  border: 2px solid #fff;
  border-radius: 50%;
  /* transform set inline by player.js for edge-clamping (handles both X clamp and -50% Y center) */
  opacity: 1;
  pointer-events: none;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
  will-change: transform;
}

.time {
  font-size: 12px;
  color: rgba(255,255,255,0.7);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  min-width: 85px;
  text-align: center;
}

/* ═══════════════════════════════════
   BELOW VIDEO — Summary + Chapters
   ═══════════════════════════════════ */

.section {
  padding: 20px 0;
  border-top: 1px solid var(--border);
}

.section:first-of-type {
  border-top: none;
  padding-top: 4px;
}

.section-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 10px;
}

.summary-text {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-secondary);
}

.see-more-btn {
  background: none;
  border: none;
  color: var(--text-primary);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  padding: 0;
  margin-left: 4px;
}
.see-more-btn:hover { text-decoration: underline; }

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

.chapter-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-radius: 6px;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s;
}
.chapter-item:hover { background: var(--bg-hover); }

.chapter-time {
  font-size: 13px;
  font-weight: 600;
  color: var(--loom-blue);
  min-width: 36px;
  font-variant-numeric: tabular-nums;
}

.chapter-label {
  font-size: 14px;
  color: var(--text-primary);
}

/* ═══════════════════════════════════
   FLOATING CAMERA — blue rounded square
   ═══════════════════════════════════ */

.fab-camera {
  position: fixed;
  bottom: 20px;
  left: 20px;
  width: 44px;
  height: 44px;
  background: var(--loom-blue);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  box-shadow: 0 2px 10px rgba(65,105,232,0.35);
  transition: transform 0.15s, box-shadow 0.15s;
  z-index: 50;
}
.fab-camera:hover {
  transform: scale(1.06);
  box-shadow: 0 4px 18px rgba(65,105,232,0.45);
}

/* ═══════════════════════════════════
   MOBILE
   ═══════════════════════════════════ */

@media (max-width: 900px) {
  .two-col {
    flex-direction: column;
    gap: 24px;
  }

  .col-left {
    flex: none;
    width: 100%;
    padding-left: 0 !important;
    padding-right: 0;
  }

  .col-left > * {
    max-width: none;
  }

  .col-right {
    flex: none;
    width: 100%;
    min-width: 0;
    position: static;
    border-left: none;
    padding-left: 0;
    border-top: 1px solid var(--border);
    padding-top: 20px;
  }

  .comments-panel {
    min-height: 120px;
  }
}

@media (max-width: 768px) {
  /* Header: don't stick on mobile — prevents "frozen nav" on scroll */
  .header {
    position: relative;
  }

  .header-inner { padding: 8px 14px; }
  /* No side padding on .main — video & text get their own padding below.
     This eliminates the overflow caused by negative margins on .video-container. */
  .main { padding: 0 0 60px; }
  .video-title { font-size: 17px; }

  /* Video edge-to-edge — no negative margins (those caused right-side overflow) */
  .video-container {
    margin-left: 0;
    margin-right: 0;
    width: 100%;
    margin-bottom: 16px;
  }
  .player-wrapper { border-radius: 0; }
  .player { object-fit: contain; background: #000; }

  /* Side padding for text content (was previously inherited from .main) */
  .col-left .video-title,
  .col-left .creator-info,
  .col-left .section,
  .col-right { padding-left: 14px; padding-right: 14px; }
  .col-left .video-title { margin-top: 12px; }

  .cta-overlay {
    padding: 7px 14px;
    font-size: 11px;
    top: 6px;
    right: 6px;
    border-radius: 4px;
  }

  .play-btn { width: 56px; height: 56px; }

  /* Controls — bigger touch targets on mobile */
  .controls { gap: 6px; padding: 10px 8px; opacity: 1; }
  .ctrl-btn { min-width: 40px; height: 40px; padding: 6px; }
  .ctrl-btn svg { width: 20px; height: 20px; }
  .time { font-size: 11px; min-width: 76px; }

  /* Skip buttons — keep visible & easy to tap on mobile */
  .skip-btn { min-width: 46px; height: 46px; padding: 8px; }
  .skip-btn svg { width: 28px; height: 28px; }

  /* Hide PiP on mobile (rarely supported) */
  #ctrl-pip { display: none; }

  /* Hide inline volume slider on touch devices — not enough horizontal
     room next to the big skip buttons and every mobile user already has
     hardware volume buttons. The mute toggle button stays. */
  #volume-slider { display: none; }
  .volume-wrapper { gap: 0; padding-right: 0; }

  /* Bigger touch target for progress bar */
  .progress-bar { padding: 14px 0; height: 6px; }
  .progress-thumb { width: 18px; height: 18px; }

  .fab-camera { width: 38px; height: 38px; border-radius: 10px; bottom: 14px; left: 14px; }
  .fab-camera svg { width: 17px; height: 17px; }
}

@media (max-width: 480px) {
  .header-btn-login { font-size: 13px; padding: 5px 12px; }
  /* Same edge-to-edge approach as 768px */
  .main { padding: 0 0 60px; }
  .video-container { margin-left: 0; margin-right: 0; width: 100%; }
  .video-title { font-size: 16px; }
  .controls-right { gap: 0; }
  .time { font-size: 10px; min-width: 62px; }
  .chapter-item { padding: 6px 8px; }

  /* Side padding for text content */
  .col-left .video-title,
  .col-left .creator-info,
  .col-left .section,
  .col-right { padding-left: 12px; padding-right: 12px; }
}

/* ─────────────────────────────────────────
   FULLSCREEN MODE
   ───────────────────────────────────────── */

/* Default: controls visible in fullscreen */
.player-wrapper:fullscreen .controls,
.player-wrapper:-webkit-full-screen .controls {
  opacity: 1;
  padding: 18px 22px;
  gap: 10px;
}
.player-wrapper:fullscreen .player,
.player-wrapper:-webkit-full-screen .player {
  object-fit: contain;
  background: #000;
}

/* Auto-hide: applied via JS after mouse idle in fullscreen.
   Hides both controls AND cursor for clean cinematic look */
.player-wrapper:fullscreen.cursor-hidden,
.player-wrapper:-webkit-full-screen.cursor-hidden {
  cursor: none;
}
.player-wrapper:fullscreen.cursor-hidden .controls,
.player-wrapper:-webkit-full-screen.cursor-hidden .controls,
.player-wrapper:fullscreen .controls.auto-hidden,
.player-wrapper:-webkit-full-screen .controls.auto-hidden {
  opacity: 0 !important;
  pointer-events: none;
}

/* Bigger UI elements in fullscreen for visibility on TV/big monitors */
.player-wrapper:fullscreen .ctrl-btn,
.player-wrapper:-webkit-full-screen .ctrl-btn {
  min-width: 48px;
  height: 48px;
  padding: 10px;
}
.player-wrapper:fullscreen .ctrl-btn svg,
.player-wrapper:-webkit-full-screen .ctrl-btn svg {
  width: 26px;
  height: 26px;
}
.player-wrapper:fullscreen .skip-btn,
.player-wrapper:-webkit-full-screen .skip-btn {
  min-width: 60px;
  height: 60px;
  padding: 12px;
}
.player-wrapper:fullscreen .skip-btn svg,
.player-wrapper:-webkit-full-screen .skip-btn svg {
  width: 38px;
  height: 38px;
}

/* Slightly bigger progress bar in fullscreen — still slim & pill-shaped */
.player-wrapper:fullscreen .progress-bar,
.player-wrapper:-webkit-full-screen .progress-bar {
  height: 5px;
  padding: 16px 0;
  background: rgba(255,255,255,0.45);
  border-radius: 999px;
}
.player-wrapper:fullscreen .progress-bar:hover,
.player-wrapper:-webkit-full-screen .progress-bar:hover {
  height: 7px;
}
.player-wrapper:fullscreen .progress-thumb,
.player-wrapper:-webkit-full-screen .progress-thumb {
  width: 22px;
  height: 22px;
  border-width: 3px;
}

.player-wrapper:fullscreen .time,
.player-wrapper:-webkit-full-screen .time {
  font-size: 16px;
  min-width: 110px;
}
.player-wrapper:fullscreen .speed-btn,
.player-wrapper:-webkit-full-screen .speed-btn {
  font-size: 16px;
  padding: 6px 12px;
}
