:root {
  color-scheme: dark;
  --bg: #07070b;
  --surface: #0f0f16;
  --surface2: #161622;
  --surface-glass: rgba(16, 16, 24, 0.82);
  --ink: #f4f4f8;
  --ink-secondary: #a3a1b4;
  --muted: #737184;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.16);
  --pill: rgba(0, 0, 0, 0.72);
  --accent: #c084fc;
  --accent2: #60a5fa;
  --accent-gradient: linear-gradient(135deg, #c084fc 0%, #60a5fa 100%);
  --glow: 0 0 28px rgba(192, 132, 252, 0.25);
  --radius: 14px;
  --radius-sm: 8px;
  --radius-full: 9999px;
  --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.6);
  --shadow-hover: 0 16px 40px rgba(0, 0, 0, 0.6), 0 0 24px rgba(192, 132, 252, 0.28);
  --ease-spring: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-tactile: cubic-bezier(0.2, 0.9, 0.3, 1.3);
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  min-height: 100dvh;
  overflow-x: hidden;
  user-select: none;
  -webkit-user-select: none;
}

/* Ambient 2026 Background Sheen */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(130% 90% at 50% -15%, rgba(192, 132, 252, 0.12), transparent 55%),
    radial-gradient(80% 50% at 85% 105%, rgba(96, 165, 250, 0.08), transparent 50%),
    radial-gradient(ellipse at center, transparent 60%, rgba(0, 0, 0, 0.65) 100%);
}

main, header {
  position: relative;
  z-index: 1;
}

.skip {
  position: absolute;
  left: -999px;
  top: 0;
  background: #fff;
  color: #000;
  padding: 0.6rem 1rem;
  z-index: 99;
  border-radius: 0 0 8px 0;
  font-weight: 600;
}
.skip:focus {
  left: 0;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

svg {
  width: 20px;
  height: 20px;
  flex: none;
}
button svg {
  pointer-events: none;
}

/* ----------------- Header HUD ----------------- */
.bar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(8, 8, 12, 0.84);
  backdrop-filter: blur(20px) saturate(190%);
  -webkit-backdrop-filter: blur(20px) saturate(190%);
  border-bottom: 1px solid var(--line);
  transition: border-color 0.2s ease;
}

.bar-inner {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0.85rem 1.25rem 0.5rem;
  display: flex;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.brand-title-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.brand h1 {
  font-size: 1.2rem;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.02em;
  background: linear-gradient(180deg, #fff 0%, #d4d4e0 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.live-pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
  display: inline-block;
  animation: pulse-ring 2s cubic-bezier(0.24, 0, 0.38, 1) infinite;
}
@keyframes pulse-ring {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.3); opacity: 1; box-shadow: 0 0 14px var(--accent); }
  100% { transform: scale(0.95); opacity: 0.8; }
}

.count {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

.bar-actions {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  flex: 1 1 320px;
  justify-content: flex-end;
}

.hud-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  border: 1px solid var(--line);
  background: var(--surface2);
  color: var(--accent);
  cursor: pointer;
  transition: all 0.18s var(--ease-spring);
}
.hud-toggle:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--line-strong);
  transform: translateY(-1px);
}
.hud-toggle:active {
  transform: scale(0.94);
}
.hud-toggle.off {
  color: var(--muted);
  border-color: var(--line);
}
.hud-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.search {
  position: relative;
  flex: 1 1 200px;
  max-width: 340px;
}
.search-ic {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  width: 16px;
  height: 16px;
  pointer-events: none;
  transition: color 0.15s ease;
}
.search input {
  width: 100%;
  padding: 0.6rem 2.2rem 0.6rem 2.3rem;
  font-size: 0.88rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-full);
  background: var(--surface2);
  color: var(--ink);
  min-height: 40px;
  transition: all 0.2s var(--ease-spring);
}
.search input:hover {
  border-color: var(--line-strong);
}
.search input:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(192, 132, 252, 0.2);
  background: var(--surface);
}
.search input:focus-visible + .search-ic {
  color: var(--accent);
}
.search input::placeholder {
  color: var(--muted);
}
.search-clear-btn {
  position: absolute;
  right: 0.6rem;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  padding: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}
.search-clear-btn:hover {
  color: #fff;
}
.search-clear-btn[hidden] {
  display: none;
}

/* ----------------- Filter Strip Ribbon ----------------- */
.filter-strip-wrap {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0.4rem 1.25rem 0.75rem;
  position: relative;
}
.filter-strip {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding: 2px 2px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}
.filter-strip::-webkit-scrollbar {
  display: none;
}
.filter-pill {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.85rem;
  font-size: 0.82rem;
  font-weight: 500;
  border-radius: var(--radius-full);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink-secondary);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.16s var(--ease-spring);
}
.filter-pill:hover {
  background: rgba(255, 255, 255, 0.09);
  color: #fff;
  border-color: var(--line-strong);
  transform: translateY(-1px);
}
.filter-pill:active {
  transform: scale(0.96);
}
.filter-pill.active {
  background: linear-gradient(135deg, rgba(192, 132, 252, 0.25) 0%, rgba(96, 165, 250, 0.25) 100%);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 0 14px rgba(192, 132, 252, 0.22);
}
.filter-pill .pill-badge {
  font-size: 0.72rem;
  opacity: 0.65;
  font-variant-numeric: tabular-nums;
}
.filter-pill.active .pill-badge {
  opacity: 1;
  color: var(--accent);
}

/* ----------------- Main Grid ----------------- */
main {
  max-width: 1440px;
  margin: 0 auto;
  padding: 1.25rem 1.25rem 5rem;
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}
@media (min-width: 640px) {
  .grid { grid-template-columns: repeat(3, 1fr); gap: 1.1rem; }
}
@media (min-width: 1080px) {
  .grid { grid-template-columns: repeat(4, 1fr); gap: 1.25rem; }
}
@media (min-width: 1440px) {
  .grid { grid-template-columns: repeat(5, 1fr); gap: 1.25rem; }
}

/* ----------------- Card Architecture ----------------- */
.card {
  margin: 0;
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-card);
  cursor: pointer;
  padding: 0;
  text-align: left;
  width: 100%;
  font: inherit;
  color: inherit;
  display: flex;
  flex-direction: column;
  transition: transform 0.28s var(--ease-spring), box-shadow 0.28s var(--ease-spring), border-color 0.28s var(--ease-spring);
  will-change: transform;
}

.card:hover {
  transform: translateY(-4px) scale(1.008);
  box-shadow: var(--shadow-hover);
  border-color: rgba(192, 132, 252, 0.4);
}
.card:active {
  transform: scale(0.975);
  transition: transform 0.08s var(--ease-tactile);
}
.card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.card.wide {
  grid-column: span 2;
}
.card.tall {
  grid-row: span 2;
}

/* Media Container & Shimmer Skeleton */
.card-media {
  position: relative;
  width: 100%;
  aspect-ratio: 9 / 16;
  background: #0d0d14;
  overflow: hidden;
}
.card.wide .card-media {
  aspect-ratio: 16 / 9;
}
.card.tall .card-media {
  aspect-ratio: 9 / 19;
}

/* High-tech Skeleton Animation */
.card-media::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.04) 50%, transparent 100%);
  background-size: 200% 100%;
  animation: shimmer 1.8s infinite;
  pointer-events: none;
  z-index: 1;
}
.card.loaded .card-media::before {
  display: none;
}
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* Progressive Image */
.card-thumb {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.4s ease, transform 0.5s var(--ease-spring);
  z-index: 2;
  background: #0d0d14;
}
.card-thumb.loaded {
  opacity: 1;
}
.card:hover .card-thumb {
  transform: scale(1.03);
}

/* Preview Video on Hover */
.card video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  z-index: 3;
  pointer-events: none;
  transition: opacity 0.35s ease;
}
.card.previewing video {
  opacity: 1;
}

/* Inline Hover Preview Mini Bar */
.card-preview-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  width: 0%;
  background: var(--accent-gradient);
  z-index: 6;
  transition: width 0.1s linear;
}

/* Duration Tag */
.dur {
  position: absolute;
  right: 0.6rem;
  top: 0.6rem;
  background: var(--pill);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-full);
  font-variant-numeric: tabular-nums;
  z-index: 5;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

/* Center Play Badge */
.play-badge {
  position: absolute;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%) scale(0.9);
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(10, 10, 16, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  pointer-events: none;
  z-index: 5;
  transition: opacity 0.24s ease, transform 0.24s var(--ease-spring);
}
.play-badge svg {
  width: 24px;
  height: 24px;
  margin-left: 2px;
}
.card:hover .play-badge {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}
.card.previewing .play-badge {
  opacity: 0.85;
  animation: pulse-badge 1.4s ease-in-out infinite;
}
@keyframes pulse-badge {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  50% { transform: translate(-50%, -50%) scale(1.08); }
}

/* Card Metadata Overlay */
.meta {
  position: absolute;
  inset: auto 0 0 0;
  padding: 2.5rem 0.85rem 0.85rem;
  background: linear-gradient(180deg, transparent 0%, rgba(4, 4, 8, 0.8) 50%, rgba(4, 4, 8, 0.96) 100%);
  z-index: 4;
  pointer-events: none;
}
.meta .eyebrow {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 0.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.meta h2 {
  font-size: 0.92rem;
  font-weight: 600;
  margin: 0;
  color: #fff;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.35;
}

/* Empty State */
.empty {
  text-align: center;
  color: var(--ink-secondary);
  padding: 4rem 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.8rem;
}
.empty-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--surface2);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}
.empty button {
  background: linear-gradient(135deg, rgba(192, 132, 252, 0.2), rgba(96, 165, 250, 0.2));
  border: 1px solid var(--accent);
  color: #fff;
  font-size: 0.88rem;
  font-weight: 600;
  padding: 0.5rem 1.25rem;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 0.2s ease;
}
.empty button:hover {
  background: var(--accent);
  color: #000;
}
.empty[hidden] {
  display: none;
}

.hint {
  text-align: center;
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: 3rem;
}

/* ----------------- Modal Player Experience ----------------- */
.modal[hidden] {
  display: none;
}
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 3, 6, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

/* Dynamic Ambient Glow Behind Modal */
.ambient-glow {
  position: absolute;
  width: 70vw;
  height: 70vh;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(192, 132, 252, 0.18) 0%, rgba(96, 165, 250, 0.12) 40%, transparent 70%);
  filter: blur(60px);
  pointer-events: none;
  z-index: 1;
}

/* Modal Sheet — Apple OS Floating Glass Window */
.sheet {
  position: relative;
  z-index: 2;
  background: #000;
  color: #fff;
  border: 0.5px solid rgba(255, 255, 255, 0.2);
  border-radius: 24px;
  overflow: hidden;
  box-shadow: 0 32px 100px rgba(0, 0, 0, 0.85), 0 0 0 1px rgba(0, 0, 0, 0.5), var(--glow);
  width: min(960px, 94vw);
  max-height: 94dvh;
  display: flex;
  flex-direction: column;
  transition: width 0.35s var(--ease-spring), max-width 0.35s var(--ease-spring);
}

.ambient-canvas {
  position: absolute;
  inset: -40px;
  width: calc(100% + 80px);
  height: calc(100% + 80px);
  filter: blur(50px) saturate(200%);
  opacity: 0.45;
  pointer-events: none;
  z-index: 0;
}

/* SOTA Proportions: Portrait vs Landscape */
.sheet.is-portrait {
  width: min(440px, 94vw);
  max-width: 440px;
}
.sheet.is-landscape {
  width: min(1080px, 94vw);
  max-width: 1080px;
}

/* Portrait Ergonomic Top HUD */
.sheet.is-portrait .sheet-top-hud {
  top: 14px;
  left: 14px;
  right: 14px;
  gap: 0.45rem;
}
.sheet.is-portrait .top-hud-left {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
}
.sheet.is-portrait .top-hud-right {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
}
.sheet.is-portrait .brand-capsule {
  padding: 0.25rem 0.55rem;
  gap: 0.3rem;
  max-width: 100%;
  overflow: hidden;
}
.sheet.is-portrait .brand-capsule .sheet-brand {
  font-size: 0.6rem;
  letter-spacing: 0.1em;
}
.sheet.is-portrait .brand-capsule h2 {
  font-size: 0.76rem;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sheet.is-portrait .actions-capsule {
  padding: 0.18rem 0.25rem;
  gap: 0.12rem;
}
.sheet.is-portrait .hud-pill-btn {
  width: 26px;
  height: 26px;
}
.sheet.is-portrait .hud-pill-btn svg {
  width: 14px;
  height: 14px;
}

/* Apple OS Floating Top Pill HUD */
.sheet-top-hud {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 16px;
  z-index: 25;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  pointer-events: none;
  transition: opacity 0.35s cubic-bezier(0.16, 1, 0.3, 1), transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}
.top-hud-left {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
}
.top-hud-right {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
}

.hud-capsule {
  background: rgba(18, 18, 26, 0.72);
  backdrop-filter: blur(28px) saturate(200%);
  -webkit-backdrop-filter: blur(28px) saturate(200%);
  border: 0.5px solid rgba(255, 255, 255, 0.22);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  pointer-events: auto;
}

.brand-capsule {
  padding: 0.35rem 0.85rem;
  gap: 0.5rem;
  max-width: min(340px, 52vw);
}
.brand-capsule .sheet-brand {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--accent);
  flex: none;
}
.brand-capsule .capsule-dot {
  color: rgba(255, 255, 255, 0.35);
  font-size: 0.8rem;
  flex: none;
}
.brand-capsule h2 {
  font-size: 0.84rem;
  font-weight: 600;
  margin: 0;
  color: #fff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.actions-capsule {
  padding: 0.25rem 0.35rem;
  gap: 0.25rem;
}
.hud-pill-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 0;
  background: transparent;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.16s var(--ease-spring);
  text-decoration: none;
}
.hud-pill-btn:hover {
  background: rgba(255, 255, 255, 0.18);
  transform: translateY(-1px);
}
.hud-pill-btn:active {
  transform: scale(0.92);
}
.hud-pill-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.hud-pill-btn.close-circle-btn {
  background: rgba(255, 255, 255, 0.16);
}
.hud-pill-btn.close-circle-btn:hover {
  background: rgba(255, 255, 255, 0.28);
}
.hud-pill-btn.off {
  color: var(--muted);
  opacity: 0.6;
}

/* Stage Area (Adaptive video container) */
.stage {
  position: relative;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  width: 100%;
  z-index: 1;
}

/* Portrait stage fit */
.sheet.is-portrait .stage {
  height: calc(88dvh);
  max-height: 760px;
}
.sheet.is-portrait .stage video#player {
  width: auto;
  height: 100%;
  max-height: 100%;
  max-width: 100%;
  object-fit: contain;
  display: block;
}

/* Landscape stage fit */
.sheet.is-landscape .stage {
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: calc(84dvh);
}
.sheet.is-landscape .stage video#player {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.gesture {
  position: absolute;
  inset: 0;
  z-index: 5;
  touch-action: manipulation;
  cursor: pointer;
}

/* Apple Spring Center Play/Pause Badge */
.tap-badge {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(0.8);
  z-index: 8;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: rgba(18, 18, 26, 0.72);
  backdrop-filter: blur(28px) saturate(200%);
  -webkit-backdrop-filter: blur(28px) saturate(200%);
  border: 0.5px solid rgba(255, 255, 255, 0.35);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.3);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.24s var(--ease-spring);
}
.tap-badge svg {
  width: 32px;
  height: 32px;
}
.tap-badge.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}
.tap-badge .seek-txt {
  position: absolute;
  bottom: -1.7rem;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
  background: var(--pill);
  padding: 0.15rem 0.55rem;
  border-radius: var(--radius-full);
}

.ripple {
  position: absolute;
  width: 16px;
  height: 16px;
  margin: -8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.45);
  pointer-events: none;
  z-index: 7;
  animation: ripple-anim 0.5s ease-out forwards;
}
@keyframes ripple-anim {
  from { transform: scale(1); opacity: 0.8; }
  to { transform: scale(8); opacity: 0; }
}

/* Buffering Overlay */
.buffer {
  position: absolute;
  inset: 0;
  z-index: 9;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  align-items: center;
  justify-content: center;
  background: rgba(6, 6, 10, 0.65);
  backdrop-filter: blur(8px);
  color: #fff;
}
.buffer[hidden] {
  display: none;
}
.spinner {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 3.5px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--accent);
  animation: spin 0.9s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
.buffer p {
  font-size: 0.88rem;
  color: var(--ink);
  margin: 0;
}
.buffer button {
  min-width: 40px;
  min-height: 40px;
  padding: 0.5rem;
  border-radius: 50%;
  border: 0;
  cursor: pointer;
  background: #fff;
  color: #000;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Up Next Countdown Overlay */
.upnext {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  gap: 1.25rem;
  align-items: center;
  justify-content: center;
  background: rgba(6, 6, 12, 0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  color: #fff;
  padding: 1.5rem;
}
.upnext[hidden] {
  display: none;
}
.upnext img {
  width: 150px;
  max-width: 32vw;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 12px;
  border: 0.5px solid var(--line);
}
.up-kicker {
  margin: 0 0 0.25rem;
  color: var(--accent2);
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.upnext h3 {
  margin: 0 0 0.5rem;
  font-size: 1.05rem;
  max-width: 42ch;
  overflow: hidden;
  text-overflow: ellipsis;
}
.up-count {
  font-size: 0.88rem;
  color: var(--ink-secondary);
  margin-bottom: 0.4rem;
}
.up-bar {
  height: 4px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.18);
  overflow: hidden;
  margin-bottom: 1rem;
  max-width: 280px;
}
.up-fill {
  height: 100%;
  width: 0%;
  background: var(--accent-gradient);
  border-radius: var(--radius-full);
}
.up-btns {
  display: flex;
  gap: 0.6rem;
}
.up-btns button {
  min-width: 48px;
  min-height: 48px;
  padding: 0.6rem;
  border-radius: var(--radius-full);
  border: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.16s var(--ease-spring);
}
.up-btns button:hover {
  transform: scale(1.06);
}
.up-btns button:active {
  transform: scale(0.94);
}
#upPlay {
  background: #fff;
  color: #000;
}
#upPlay svg {
  width: 22px;
  height: 22px;
  margin-left: 2px;
}
#upCancel {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}

/* Error State */
.verror {
  position: absolute;
  inset: 0;
  z-index: 12;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  align-items: center;
  justify-content: center;
  background: rgba(8, 8, 14, 0.95);
  padding: 1.5rem;
  text-align: center;
}
.verror[hidden] {
  display: none;
}
.err-icon svg {
  width: 42px;
  height: 42px;
  color: var(--accent);
}
.verror h3 {
  margin: 0;
  font-size: 1.1rem;
}
.verror p {
  margin: 0 0 0.8rem;
  color: var(--ink-secondary);
  font-size: 0.88rem;
  max-width: 48ch;
}
.err-btns {
  display: flex;
  gap: 0.6rem;
  justify-content: center;
}
.err-btns button, .err-btns a {
  min-width: 46px;
  min-height: 46px;
  padding: 0.6rem;
  border-radius: var(--radius-full);
  border: 0;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
#errRetry {
  background: #fff;
  color: #000;
}

/* ----------------- Apple OS Floating Bottom Transport HUD ----------------- */
.sheet-bottom-hud {
  position: absolute;
  bottom: 18px;
  left: 16px;
  right: 16px;
  z-index: 25;
  display: flex;
  justify-content: center;
  pointer-events: none;
  transition: opacity 0.35s cubic-bezier(0.16, 1, 0.3, 1), transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.pvw-bar {
  pointer-events: auto;
  width: min(840px, 100%);
  background: rgba(18, 18, 26, 0.76);
  backdrop-filter: blur(36px) saturate(210%) brightness(1.08);
  -webkit-backdrop-filter: blur(36px) saturate(210%) brightness(1.08);
  border: 0.5px solid rgba(255, 255, 255, 0.22);
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.65), inset 0 1px 0 rgba(255, 255, 255, 0.3);
  border-radius: var(--radius-full);
  padding: 0.4rem 0.85rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  position: relative;
}

.transport-cluster {
  display: flex;
  align-items: center;
}

.cluster-left {
  gap: 0.25rem;
  flex: none;
}
.cluster-timeline {
  flex: 1 1 180px;
  min-width: 120px;
  gap: 0.65rem;
}
.cluster-right {
  gap: 0.35rem;
  flex: none;
}

/* Portrait Ergonomic Bottom HUD - 2-Row Apple Capsule */
.sheet.is-portrait .sheet-bottom-hud {
  bottom: 12px;
  left: 12px;
  right: 12px;
}
.sheet.is-portrait .pvw-bar {
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem 0.55rem;
  gap: 0.35rem 0.5rem;
  border-radius: 24px;
}
.sheet.is-portrait .cluster-timeline {
  order: 1;
  width: 100%;
  flex: 1 0 100%;
  gap: 0.55rem;
}
.sheet.is-portrait .cluster-timeline .seek {
  flex: 1 1 auto;
  height: 28px;
}
.sheet.is-portrait .cluster-timeline .time-label {
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.75);
}
.sheet.is-portrait .cluster-left {
  order: 2;
  gap: 0.2rem;
}
.sheet.is-portrait .cluster-right {
  order: 3;
  gap: 0.25rem;
}
.sheet.is-portrait .vol-group #vol {
  display: none;
}
.sheet.is-portrait .ctrl-btn {
  width: 30px;
  height: 30px;
}
.sheet.is-portrait .ctrl-btn svg {
  width: 16px;
  height: 16px;
}
.sheet.is-portrait .ctrl-btn.t-play-main {
  width: 36px;
  height: 36px;
}
.sheet.is-portrait .ctrl-btn.t-play-main svg {
  width: 18px;
  height: 18px;
}
.sheet.is-portrait .ctrl-btn.pill-val-btn {
  height: 30px;
  min-width: 34px;
  padding: 0 0.45rem;
  font-size: 0.72rem;
}

.ctrl-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 0;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.16s var(--ease-spring);
  padding: 0;
}
.ctrl-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}
.ctrl-btn:active {
  transform: scale(0.92);
}
.ctrl-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.ctrl-btn.t-play-main {
  width: 38px;
  height: 38px;
  background: #ffffff;
  color: #000;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
}
.ctrl-btn.t-play-main:hover {
  background: #f4f4f8;
  transform: scale(1.08);
}

.ctrl-btn.pill-val-btn {
  border-radius: var(--radius-full);
  padding: 0 0.55rem;
  width: auto;
  font-size: 0.74rem;
  font-weight: 600;
  min-width: 38px;
  background: rgba(255, 255, 255, 0.1);
}
.ctrl-btn.pill-val-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Apple Timeline Scrubber */
.time-label {
  font-size: 0.74rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: rgba(255, 255, 255, 0.85);
  white-space: nowrap;
  flex: none;
}

.seek {
  position: relative;
  flex: 1 1 100px;
  height: 32px;
  display: flex;
  align-items: center;
  touch-action: none;
  cursor: pointer;
}
.seek-track {
  position: absolute;
  left: 0;
  right: 0;
  height: 4px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.22);
  overflow: hidden;
  transition: height 0.16s ease;
}
.seek:hover .seek-track {
  height: 6px;
}
.seek-buf {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0%;
  background: rgba(255, 255, 255, 0.35);
}
.seek-played {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0%;
  background: var(--accent-gradient);
  border-radius: var(--radius-full);
}
.seek input {
  position: relative;
  width: 100%;
  background: transparent;
  accent-color: var(--accent);
  min-height: 32px;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

/* Scrub Hover/Drag Live Bubble */
.scrub-bubble {
  position: absolute;
  bottom: 46px;
  transform: translateX(-50%);
  z-index: 30;
  background: rgba(18, 18, 26, 0.95);
  border: 0.5px solid var(--line-strong);
  border-radius: 12px;
  padding: 0.35rem;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.7), var(--glow);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  align-items: center;
  pointer-events: none;
  min-width: 112px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.scrub-bubble[hidden] {
  display: none;
}
.scrub-bubble video {
  width: 116px;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 8px;
  background: #000;
}
.scrub-bubble video[hidden] {
  display: none;
}
.scrub-bubble span {
  font-size: 0.72rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: #fff;
}

/* Volume Control */
.vol-group {
  display: flex;
  align-items: center;
  gap: 0.2rem;
}
#vol {
  width: 60px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* Apple Frosted Glass Menus */
.menu-wrap {
  position: relative;
}
.apple-glass-menu {
  position: absolute;
  bottom: 48px;
  right: 0;
  z-index: 35;
  background: rgba(18, 18, 26, 0.88);
  backdrop-filter: blur(28px) saturate(200%);
  -webkit-backdrop-filter: blur(28px) saturate(200%);
  border: 0.5px solid rgba(255, 255, 255, 0.22);
  border-radius: 14px;
  padding: 0.35rem;
  min-width: 170px;
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.7);
}
.apple-glass-menu[hidden] {
  display: none;
}
.apple-glass-menu button {
  display: flex;
  width: 100%;
  justify-content: space-between;
  align-items: center;
  gap: 0.8rem;
  background: none;
  border: 0;
  color: #fff;
  font-size: 0.82rem;
  padding: 0.45rem 0.7rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.apple-glass-menu button:hover {
  background: rgba(255, 255, 255, 0.14);
}
.apple-glass-menu button svg {
  width: 15px;
  height: 15px;
  color: var(--accent);
  visibility: hidden;
}
.apple-glass-menu button[aria-checked="true"] svg {
  visibility: visible;
}
.apple-glass-menu .menu-sep {
  height: 1px;
  background: var(--line);
  margin: 0.25rem 0.35rem;
}

/* Apple Intelligent Auto-Hide Engine */
.sheet.idle-hidden {
  cursor: none;
}
.sheet.idle-hidden #sheetTopHud {
  opacity: 0;
  transform: translateY(-10px);
  pointer-events: none;
}
.sheet.idle-hidden #sheetBottomHud {
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
}

/* ----------------- Toast HUD ----------------- */
.hud {
  position: fixed;
  left: 50%;
  bottom: 2rem;
  transform: translateX(-50%) translateY(0);
  z-index: 120;
  background: rgba(18, 18, 26, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--line-strong);
  color: #fff;
  border-radius: var(--radius-full);
  padding: 0.55rem 1.25rem;
  font-size: 0.84rem;
  font-weight: 500;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6), var(--glow);
  pointer-events: none;
  max-width: 90vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  animation: hud-in 0.22s var(--ease-spring);
}
@keyframes hud-in {
  from { opacity: 0; transform: translateX(-50%) translateY(12px) scale(0.96); }
  to { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}
.hud[hidden] {
  display: none;
}

/* ----------------- FLIP Morph Clone ----------------- */
.flip-clone {
  position: fixed;
  z-index: 90;
  pointer-events: none;
  border-radius: var(--radius);
  overflow: hidden;
  background-size: cover;
  background-position: center;
  box-shadow: var(--shadow-hover);
}

/* ----------------- Responsive Tweaks ----------------- */
@media (max-width: 640px) {
  .pvw-bar {
    flex-wrap: wrap;
    gap: 0.35rem 0.5rem;
    padding: 0.5rem 0.65rem;
    border-radius: 22px;
  }
  .cluster-timeline {
    order: 1;
    flex: 1 0 100%;
    width: 100%;
    gap: 0.5rem;
  }
  .cluster-timeline .seek {
    flex: 1 1 auto;
    height: 28px;
  }
  .cluster-left {
    order: 2;
    gap: 0.2rem;
  }
  .cluster-right {
    order: 3;
    gap: 0.25rem;
  }
  .vol-group #vol {
    display: none;
  }
  .upnext img {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition: none !important;
    animation: none !important;
  }
}
