/* FilmyBazaar — cinematic minimal UI */

:root {
  --bg: #0c0c0c;
  --bg-raised: #161616;
  --bg-card: #1a1a1a;
  --bg-input: #222;
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #f5f5f5;
  --text-secondary: #a3a3a3;
  --text-muted: #737373;
  --accent: #dc2626;
  --accent-hover: #ef4444;
  --radius: 8px;
  --radius-lg: 12px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --max: 1200px;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

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

html { scroll-behavior: smooth; -webkit-font-smoothing: antialiased; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  font-size: 15px;
}

.app-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(ellipse 100% 60% at 50% -30%, rgba(220, 38, 38, 0.07), transparent 55%),
    var(--bg);
  pointer-events: none;
}

/* ── Nav ── */
.topnav {
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid var(--border);
  background: rgba(12, 12, 12, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.topnav-inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--accent);
  flex-shrink: 0;
}

.brand-name {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.topnav-actions { display: flex; align-items: center; gap: 8px; }

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  position: relative;
  transition: color 0.15s, background 0.15s;
}

.nav-link svg { width: 16px; height: 16px; opacity: 0.8; }
.nav-link:hover { color: var(--text); background: rgba(255, 255, 255, 0.05); }

.dl-nav-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 99px;
  background: var(--accent);
  color: #fff;
  font-size: 0.625rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Layout ── */
.app {
  position: relative;
  z-index: 1;
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 24px 80px;
}

.screen { display: none; }
.screen-active { display: block; animation: fadeIn 0.35s var(--ease); }
.panel.screen { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* ── Hero ── */
.hero {
  padding: 72px 0 40px;
  max-width: 560px;
}

.hero-title {
  font-size: clamp(2rem, 5vw, 2.75rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
}

.hero-sub {
  font-size: 1.0625rem;
  color: var(--text-secondary);
  line-height: 1.6;
  max-width: 440px;
}

/* ── Search ── */
.search-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 560px;
  padding: 6px 6px 6px 16px;
  background: var(--bg-raised);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  margin-bottom: 48px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-bar:focus-within {
  border-color: rgba(255, 255, 255, 0.22);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.04);
}

.search-icon {
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.search-bar input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.9375rem;
  outline: none;
  min-width: 0;
}

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

.btn-search {
  padding: 10px 20px;
  border: none;
  border-radius: calc(var(--radius-lg) - 2px);
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}

.btn-search:hover { background: var(--accent-hover); }

/* ── Buttons ── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

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

.btn-secondary, .btn-ghost, .btn-back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.btn-secondary:hover, .btn-ghost:hover, .btn-back:hover {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.04);
}

.btn-back { margin-bottom: 24px; }
.btn-back svg { width: 16px; height: 16px; }

.status-toast {
  padding: 12px 16px;
  margin-bottom: 24px;
  max-width: 480px;
  border-radius: var(--radius);
  background: var(--bg-raised);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 0.875rem;
}

/* ── Results ── */
.section-head { margin-bottom: 20px; }

.section-head h2 {
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 16px;
}

.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s var(--ease), opacity 0.2s;
}

.card:hover { transform: scale(1.03); }

.card-poster-wrap {
  position: relative;
  aspect-ratio: 2/3;
  overflow: hidden;
  background: var(--bg-raised);
}

.card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-type {
  position: absolute;
  top: 8px;
  left: 8px;
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 3px 7px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.72);
  color: #fff;
}

.card-play {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.45);
  opacity: 0;
  transition: opacity 0.2s;
}

.card-play svg { width: 40px; height: 40px; color: #fff; opacity: 0.95; }
.card:hover .card-play { opacity: 1; }

.card-body { padding: 10px 2px 4px; }

.card-title {
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.load-more { display: block; margin: 32px auto 0; }

/* ── Detail panel ── */
.panel-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 32px;
  align-items: start;
}

.poster-frame {
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-raised);
}

.poster-frame img {
  width: 100%;
  display: block;
  aspect-ratio: 2/3;
  object-fit: cover;
}

.panel-title {
  font-size: 1.375rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 20px 0 6px;
  line-height: 1.25;
}

.panel-meta {
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.panel-desc {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 12px;
  line-height: 1.65;
}

.tv-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 20px;
  align-items: flex-end;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.field select {
  padding: 9px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: var(--bg-input);
  color: var(--text);
  font: inherit;
  font-size: 0.875rem;
  min-width: 120px;
}

.field select:disabled { opacity: 0.5; cursor: not-allowed; }

.ep-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.mode-bar {
  display: flex;
  gap: 0;
  margin-top: 20px;
  padding: 4px;
  background: var(--bg-raised);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  position: relative;
  isolation: isolate;
}

.mode-indicator {
  position: absolute;
  top: 4px;
  left: 4px;
  height: calc(100% - 8px);
  border-radius: calc(var(--radius-lg) - 2px);
  background: var(--bg-card);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(255, 255, 255, 0.04);
  transition: transform 0.45s cubic-bezier(0.34, 1.2, 0.64, 1), width 0.45s cubic-bezier(0.34, 1.2, 0.64, 1);
  z-index: 0;
  pointer-events: none;
}

.mode-btn {
  flex: 1;
  padding: 10px 16px;
  border: none;
  border-radius: calc(var(--radius-lg) - 2px);
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.25s var(--ease);
  position: relative;
  z-index: 1;
}

.mode-btn.active {
  color: var(--text);
  background: transparent;
  box-shadow: none;
}

/* ── Player ── */
.fb-player {
  position: relative;
  width: 100%;
  aspect-ratio: 16/9;
  background: #000;
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.fb-player video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.fb-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: rgba(0, 0, 0, 0.6);
  z-index: 4;
  pointer-events: none;
}

.fb-overlay.hidden,
.fb-big-play.hidden,
.fb-overlay-spinner.hidden { display: none !important; }

.fb-overlay[data-click-play="1"] { pointer-events: auto; cursor: pointer; }

.fb-overlay-text {
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.875rem;
  text-align: center;
  padding: 0 24px;
}

.fb-overlay-spinner {
  width: 36px;
  height: 36px;
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.fb-big-play {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.95);
  color: #000;
  cursor: pointer;
  z-index: 5;
  transition: transform 0.15s;
}

.fb-big-play:hover { transform: scale(1.05); }
.fb-big-play svg { width: 28px; height: 28px; margin-left: 3px; }

.fb-top-bar {
  position: absolute;
  top: 0; left: 0; right: 0;
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(180deg, rgba(0,0,0,0.65), transparent);
  z-index: 3;
  opacity: 0;
  transition: opacity 0.25s;
}

.fb-player.controls-visible .fb-top-bar,
.fb-player:hover .fb-top-bar { opacity: 1; }

.fb-now-title { font-size: 0.875rem; font-weight: 500; }
.fb-quality-badge {
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

.fb-controls {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 0 16px 14px;
  background: linear-gradient(0deg, rgba(0,0,0,0.8), transparent);
  z-index: 6;
  opacity: 0;
  transition: opacity 0.25s;
}

.fb-player.controls-visible .fb-controls,
.fb-player:hover .fb-controls { opacity: 1; }

.fb-seek-wrap { position: relative; padding: 8px 0; touch-action: none; }

.fb-seek-track {
  position: relative;
  height: 4px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 99px;
  cursor: pointer;
}

.fb-seek-buffered, .fb-seek-played {
  position: absolute;
  top: 0; left: 0;
  height: 100%;
  border-radius: 99px;
  pointer-events: none;
}

.fb-seek-buffered { background: rgba(255, 255, 255, 0.25); width: 0; }
.fb-seek-played { background: var(--accent); width: 0; transition: width 0.08s linear; }

.fb-player.is-buffering .fb-seek-played { opacity: 0.7; }

.fb-seek-thumb {
  position: absolute;
  top: 50%; left: 0;
  width: 12px; height: 12px;
  background: #fff;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
}

.fb-seek-wrap:hover .fb-seek-thumb,
.fb-seek-wrap:active .fb-seek-thumb,
.fb-player.is-seeking .fb-seek-thumb { opacity: 1; }

.fb-seek {
  position: absolute;
  inset: -10px 0;
  width: 100%;
  opacity: 0;
  cursor: pointer;
  margin: 0;
  z-index: 2;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
}

.fb-seek::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 24px;
  height: 24px;
  cursor: pointer;
}

.fb-seek::-moz-range-thumb {
  width: 24px;
  height: 24px;
  border: none;
  background: transparent;
  cursor: pointer;
}

.fb-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.fb-bar-left, .fb-bar-right {
  display: flex;
  align-items: center;
  gap: 4px;
}

.fb-btn {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: #fff;
  cursor: pointer;
  transition: background 0.15s;
}

.fb-btn:hover { background: rgba(255, 255, 255, 0.1); }
.fb-btn svg { width: 18px; height: 18px; }

.fb-btn-play::before {
  content: '';
  border-style: solid;
  border-width: 6px 0 6px 10px;
  border-color: transparent transparent transparent #fff;
  margin-left: 2px;
}

.fb-btn-play.is-playing::before {
  width: 10px; height: 12px;
  border: none; margin: 0;
  background: linear-gradient(to right, #fff 0 38%, transparent 38%, transparent 62%, #fff 62%);
}

.fb-time {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.75);
  font-variant-numeric: tabular-nums;
  margin-left: 4px;
}

.fb-volume { width: 64px; accent-color: #fff; }

.stream-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.field-grow { flex: 1; min-width: 140px; }

/* ── Downloads panel ── */
.page-header { margin-bottom: 32px; }
.page-title {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-top: 8px;
}

.dl-section { margin-bottom: 40px; }

.dl-section-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.dl-section-head h2 {
  font-size: 0.9375rem;
  font-weight: 600;
  margin: 0;
}

.count-badge {
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.count-badge-ok { color: #4ade80; border-color: rgba(74, 222, 128, 0.25); }

.dl-active-list { display: flex; flex-direction: column; gap: 12px; }

.dl-progress-card {
  padding: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.dl-progress-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 14px;
}

.dl-progress-head h4 { margin: 0 0 4px; font-size: 0.9375rem; font-weight: 600; }
.dl-meta { font-size: 0.8125rem; color: var(--text-muted); }

.dl-cancel-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 30px;
  height: 30px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.875rem;
}

.dl-cancel-btn:hover { border-color: var(--accent); color: var(--accent); }

.dl-progress-bar {
  height: 4px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 12px;
}

.dl-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
  transition: width 0.3s var(--ease);
}

.dl-progress-shimmer { display: none; }

.dl-progress-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.dl-percent { font-weight: 600; color: var(--text); }
.dl-speed { color: #4ade80; }

.dl-library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.dl-library-card {
  display: flex;
  gap: 14px;
  padding: 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: border-color 0.15s;
}

.dl-library-card:hover { border-color: var(--border-strong); }

.dl-lib-poster {
  width: 64px;
  height: 96px;
  border-radius: var(--radius);
  background: var(--bg-raised) center/cover no-repeat;
  flex-shrink: 0;
  position: relative;
}

.dl-lib-res {
  position: absolute;
  bottom: 4px;
  left: 4px;
  padding: 2px 5px;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.8);
  font-size: 0.625rem;
  font-weight: 600;
  color: #fff;
}

.dl-lib-body { flex: 1; min-width: 0; }
.dl-lib-body h4 { margin: 0 0 4px; font-size: 0.875rem; font-weight: 600; line-height: 1.3; }
.dl-lib-actions { display: flex; gap: 8px; margin-top: 10px; }
.dl-lib-actions .btn-primary { padding: 7px 14px; font-size: 0.8125rem; }
.dl-lib-actions .btn-ghost { padding: 7px 12px; font-size: 0.8125rem; }

.dl-empty, .empty {
  color: var(--text-muted);
  padding: 32px 24px;
  text-align: center;
  font-size: 0.875rem;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}

.dl-picker-head { margin-bottom: 20px; }
.dl-picker-head h3 { margin: 0 0 6px; font-size: 1rem; font-weight: 600; }
.dl-picker-head p { margin: 0; font-size: 0.8125rem; color: var(--text-muted); }

.dl-quality-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px;
}

.dl-quality-card {
  padding: 20px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  text-align: center;
  transition: border-color 0.15s;
}

.dl-quality-card:hover { border-color: var(--border-strong); }

.dl-quality-res {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}

.dl-quality-meta { font-size: 0.8125rem; color: var(--text-secondary); margin-bottom: 4px; }
.dl-quality-format { font-size: 0.75rem; color: var(--text-muted); margin-bottom: 16px; }

.dl-quality-btn {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px;
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.dl-quality-btn:hover { background: var(--accent-hover); }
.dl-quality-btn svg { width: 14px; height: 14px; }
.dl-quality-btn:disabled { opacity: 0.5; cursor: wait; }

.sub-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

.sub-btn {
  padding: 8px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--text-secondary);
  font: inherit;
  font-size: 0.8125rem;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.sub-btn:hover { border-color: rgba(255, 255, 255, 0.2); color: var(--text); }

.dl-btn {
  padding: 9px 16px;
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
}

.dl-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  margin-bottom: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.dl-row strong { font-size: 0.9375rem; min-width: 56px; }
.dl-row span { flex: 1; color: var(--text-muted); font-size: 0.8125rem; }

.subtitles-panel h3 {
  font-size: 0.9375rem;
  font-weight: 600;
  margin-bottom: 8px;
}

/* ── Footer ── */
.footer {
  border-top: 1px solid var(--border);
  padding: 24px;
  text-align: center;
}

.footer p {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.hidden { display: none !important; }

/* ── Responsive ── */
@media (max-width: 900px) {
  .panel-layout { grid-template-columns: 1fr; }
  .panel-side { display: grid; grid-template-columns: 120px 1fr; gap: 16px; align-items: start; }
  .poster-frame { grid-row: span 2; }
  .panel-title { margin-top: 0; font-size: 1.125rem; }
  .mode-bar { grid-column: 1 / -1; }
}

@media (max-width: 600px) {
  .topnav-inner { padding: 0 16px; }
  .app { padding: 0 16px 64px; }
  .hero { padding: 48px 0 32px; }
  .hero-title { font-size: 1.75rem; }
  .search-bar { flex-wrap: wrap; padding: 12px; }
  .search-bar input { width: 100%; order: 1; padding: 4px 0; }
  .search-icon { order: 0; }
  .btn-search { order: 2; width: 100%; margin-top: 4px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 12px; }
  .panel-side { grid-template-columns: 1fr; }
  .poster-frame { max-width: 160px; }
  .nav-link span:not(.dl-nav-badge) { display: none; }
}

/* ═══════════════════════════════════════════════════════════
   MOTION — cinematic transitions & micro-interactions
   ═══════════════════════════════════════════════════════════ */

:root {
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-out-back: cubic-bezier(0.34, 1.25, 0.64, 1);
  --ease-spring: cubic-bezier(0.22, 1, 0.36, 1);
  --dur-fast: 0.2s;
  --dur-med: 0.45s;
  --dur-slow: 0.7s;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .film-grain { display: none; }
}

/* Ambient background drift */
.app-bg {
  animation: ambientDrift 18s ease-in-out infinite alternate;
}

@keyframes ambientDrift {
  0% { opacity: 1; transform: scale(1); }
  100% { opacity: 0.92; transform: scale(1.03); }
}

/* Film grain overlay */
.film-grain {
  position: fixed;
  inset: -50%;
  z-index: 9999;
  pointer-events: none;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grainShift 0.5s steps(2) infinite;
}

@keyframes grainShift {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(-2%, -2%); }
}

/* Nav entrance */
.topnav {
  animation: navSlideDown 0.6s var(--ease-out-expo) both;
}

@keyframes navSlideDown {
  from { opacity: 0; transform: translateY(-100%); }
  to { opacity: 1; transform: none; }
}

.brand-mark {
  animation: brandPop 0.7s var(--ease-out-back) 0.15s both;
}

@keyframes brandPop {
  from { opacity: 0; transform: scale(0.6) rotate(-8deg); }
  to { opacity: 1; transform: none; }
}

.brand-name {
  animation: fadeSlideRight 0.6s var(--ease-out-expo) 0.25s both;
}

@keyframes fadeSlideRight {
  from { opacity: 0; transform: translateX(-12px); }
  to { opacity: 1; transform: none; }
}

/* Hero stagger */
.reveal-line {
  display: block;
}

.motion-ready .reveal-line {
  animation: lineReveal 0.85s var(--ease-out-expo) calc(0.12s + var(--i, 0) * 0.1s) both;
}

@keyframes lineReveal {
  from {
    opacity: 0;
    transform: translateY(110%);
    filter: blur(8px);
  }
  to {
    opacity: 1;
    transform: none;
    filter: none;
  }
}

.motion-ready .reveal-fade {
  animation: fadeUp 0.75s var(--ease-out-expo) calc(0.35s + var(--i, 0) * 0.08s) both;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: none; }
}

/* Search bar focus & loading */
.search-bar.is-loading .btn-search {
  pointer-events: none;
  position: relative;
  color: transparent;
}

.search-bar.is-loading .btn-search::after {
  content: '';
  position: absolute;
  inset: 0;
  margin: auto;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
}

.search-bar.is-loading input {
  opacity: 0.65;
}

/* Status toast */
.status-toast:not(.hidden) {
  animation: toastIn 0.4s var(--ease-out-expo) both;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-8px) scale(0.96); }
  to { opacity: 1; transform: none; }
}

/* Results section */
.results:not(.hidden) {
  animation: sectionIn 0.55s var(--ease-out-expo) both;
}

@keyframes sectionIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: none; }
}

.section-head h2 {
  animation: fadeUp 0.5s var(--ease-out-expo) 0.05s both;
}

/* Card stagger reveal */
.card-reveal {
  animation: cardIn 0.55s var(--ease-out-expo) calc(var(--i, 0) * 0.045s) both;
}

@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(28px) scale(0.94);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.card {
  transition: transform 0.35s var(--ease-out-expo), box-shadow 0.35s var(--ease);
}

.card:hover {
  transform: scale(1.04) translateY(-4px);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.45);
}

.card-poster-wrap::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(0deg, rgba(0,0,0,0.55) 0%, transparent 45%);
  opacity: 0;
  transition: opacity 0.35s var(--ease);
}

.card:hover .card-poster-wrap::after { opacity: 1; }

.card-play {
  transform: scale(0.85);
  transition: opacity 0.3s, transform 0.4s var(--ease-out-back);
}

.card:hover .card-play {
  opacity: 1;
  transform: scale(1);
}

/* Skeleton loading */
.skeleton-card {
  aspect-ratio: 2/3;
  border-radius: var(--radius);
  background: linear-gradient(
    90deg,
    var(--bg-card) 0%,
    rgba(255, 255, 255, 0.06) 50%,
    var(--bg-card) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 1.2s ease-in-out infinite, cardIn 0.4s var(--ease-out-expo) calc(var(--i, 0) * 0.04s) both;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.grid.is-loading { min-height: 200px; }

/* Detail panel cinematic enter */
.panel:not(.hidden) {
  animation: panelIn 0.65s var(--ease-out-expo) both;
}

@keyframes panelIn {
  from {
    opacity: 0;
    transform: translateY(32px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.panel:not(.hidden) .poster-frame {
  animation: posterIn 0.8s var(--ease-out-expo) 0.08s both;
}

@keyframes posterIn {
  from {
    opacity: 0;
    transform: scale(0.92) translateY(16px);
    filter: blur(6px);
  }
  to {
    opacity: 1;
    transform: none;
    filter: none;
  }
}

.panel:not(.hidden) .panel-info,
.panel:not(.hidden) .tv-controls,
.panel:not(.hidden) .mode-bar {
  animation: fadeUp 0.55s var(--ease-out-expo) 0.18s both;
}

.panel:not(.hidden) .panel-main {
  animation: fadeUp 0.6s var(--ease-out-expo) 0.22s both;
}

.panel-main .stream-section,
.panel-main .downloads-panel:not(.hidden) {
  animation: contentSwap 0.4s var(--ease-out-expo) both;
}

@keyframes contentSwap {
  from { opacity: 0; transform: translateX(12px); }
  to { opacity: 1; transform: none; }
}

/* Player polish */
.fb-player {
  transition: box-shadow 0.4s var(--ease);
}

.fb-player:hover {
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}

.fb-big-play {
  animation: playPulse 2.5s ease-in-out infinite;
}

@keyframes playPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.35); }
  50% { box-shadow: 0 0 0 14px rgba(255, 255, 255, 0); }
}

.fb-player:not(.controls-visible) .fb-big-play:not(.hidden) {
  animation: playPulse 2.5s ease-in-out infinite, bigPlayIn 0.5s var(--ease-out-back) both;
}

@keyframes bigPlayIn {
  from { opacity: 0; transform: scale(0.5); }
  to { opacity: 1; transform: none; }
}

/* Download quality cards */
.dl-quality-card {
  transition: transform 0.35s var(--ease-out-expo), border-color 0.2s, box-shadow 0.35s;
}

.dl-quality-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}

.dl-quality-card:nth-child(1) { animation: fadeUp 0.45s var(--ease-out-expo) 0.05s both; }
.dl-quality-card:nth-child(2) { animation: fadeUp 0.45s var(--ease-out-expo) 0.1s both; }
.dl-quality-card:nth-child(3) { animation: fadeUp 0.45s var(--ease-out-expo) 0.15s both; }
.dl-quality-card:nth-child(4) { animation: fadeUp 0.45s var(--ease-out-expo) 0.2s both; }

/* Screen transitions (downloads hub) */
#screen-downloads.screen-active {
  animation: screenFade 0.5s var(--ease-out-expo) both;
}

@keyframes screenFade {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: none; }
}

.dl-progress-card {
  animation: fadeUp 0.45s var(--ease-out-expo) calc(var(--i, 0) * 0.06s) both;
}

.dl-library-card {
  animation: cardIn 0.5s var(--ease-out-expo) calc(var(--i, 0) * 0.06s) both;
}

/* Buttons tactile */
.btn-search:active,
.btn-primary:active,
.dl-quality-btn:active {
  transform: scale(0.97);
  transition: transform 0.1s;
}

.nav-link:active { transform: scale(0.96); }

/* Load more */
.load-more:not(.hidden) {
  animation: fadeUp 0.5s var(--ease-out-expo) 0.2s both;
}

.load-more:disabled {
  opacity: 0.5;
  cursor: wait;
}
