:root {
  color-scheme: dark;
  --bg: #0f1015;
  --panel: #181a22;
  --panel-2: #1f1b2e;
  --line: #2a2d39;
  --text: #f4f4f8;
  --muted: #9297a8;
  --accent: #8b5cf6;
  --accent-soft: #b69aff;
  --green: #37d6a0;
  --red: #ff8f8f;
  --safe-top: var(--tg-content-safe-area-inset-top, 0px);
  --safe-bottom: var(--tg-content-safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(ellipse at 50% -15%, #2c1f4b 0, transparent 45%), var(--bg);
  color: var(--text);
  font: 15px/1.45 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
a { color: var(--accent-soft); }
button { font: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.micro { font-size: 11px; margin-top: 12px; }

.shell { max-width: 780px; margin: 0 auto; padding: calc(16px + var(--safe-top)) 16px calc(28px + var(--safe-bottom)); }
.top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.brand { display: flex; gap: 11px; align-items: center; }
.brand-mark { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: linear-gradient(135deg, #9b6bff, #6336cb); font-size: 16px; }
.brand b { letter-spacing: 1.5px; font-size: 13px; }
.brand small { display: block; color: var(--muted); font-size: 11px; margin-top: 2px; }

.status { display: flex; gap: 10px; align-items: center; padding: 16px; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); color: var(--muted); }
.status.inline { margin-top: 14px; justify-content: space-between; flex-wrap: wrap; }
.status.error { color: var(--red); border-color: #693a45; }
.spinner { width: 16px; height: 16px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

.movie { display: grid; grid-template-columns: auto 1fr; gap: 14px 16px; align-items: center; margin: 4px 0 24px; padding: 14px; border: 1px solid var(--line); border-radius: 18px; background: linear-gradient(120deg, var(--panel-2), var(--panel)); }
.poster { width: 84px; aspect-ratio: 2/3; border-radius: 11px; display: grid; place-items: center; overflow: hidden; background: linear-gradient(145deg, #6f48a8, #282039); font-size: 24px; }
.poster img { width: 100%; height: 100%; object-fit: cover; display: block; }
.movie-meta { min-width: 0; }
.movie h1 { font-size: 20px; line-height: 1.2; margin: 4px 0; overflow-wrap: anywhere; }
.movie p { margin: 0; font-size: 13px; }
.desc { grid-column: 1 / -1; margin: 0; color: #c5c8d4; font-size: 13px; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.movie.compact { grid-template-columns: auto 1fr; padding: 10px; margin-bottom: 14px; }
.movie.compact .poster { width: 44px; }
.movie.compact .desc, .movie.compact .tags { display: none; }
.movie.compact h1 { font-size: 16px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tag { font-size: 11px; padding: 3px 8px; border-radius: 20px; border: 1px solid var(--line); color: #c9c3dd; }
.tag.rating { color: #ffd166; border-color: #5d4c1f; }

.eyebrow { color: var(--accent-soft); font-size: 10px; font-weight: 700; letter-spacing: 1.5px; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 8px 0 6px; }
.section-head h2 { font-size: 20px; margin: 4px 0; overflow-wrap: anywhere; }
.count { font-size: 11px; letter-spacing: .5px; color: var(--green); border: 1px solid #23634e; padding: 4px 9px; border-radius: 30px; white-space: nowrap; }
.hint { color: var(--muted); font-size: 12.5px; margin: 6px 0 0; }

.sources { display: grid; gap: 10px; margin-top: 14px; }
.source { display: flex; justify-content: space-between; align-items: center; gap: 10px; text-align: left; width: 100%; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); color: var(--text); cursor: pointer; animation: rise .3s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
.source:active { transform: scale(.99); }
.source:hover, .source:focus-visible { border-color: var(--accent); background: #211b32; outline: none; }
.source-main { min-width: 0; }
.source strong { font-size: 15px; }
.source small { display: block; color: var(--muted); margin-top: 3px; font-size: 12px; overflow-wrap: anywhere; }
.badge { display: inline-block; margin-top: 6px; font-size: 10px; letter-spacing: .4px; color: var(--accent-soft); border: 1px solid #4a3a78; padding: 2px 7px; border-radius: 10px; }
.source .arrow { color: var(--accent-soft); font-size: 22px; flex: none; }

.stage { position: relative; width: 100%; aspect-ratio: 16/9; background: #000; border-radius: 14px; overflow: hidden; margin-top: 10px; }
.player-host, .player-host iframe, .player-host video { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #000; }
.player-message { position: absolute; inset: 0; display: grid; place-items: center; padding: 20px; text-align: center; color: var(--muted); }

.controls { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.ctrl { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--text); cursor: pointer; font-size: 13px; }
.ctrl.select span { color: var(--muted); font-size: 12px; }
.ctrl select { background: transparent; color: var(--text); border: 0; font: inherit; max-width: 46vw; }
.ctrl select option { background: var(--panel); }
.ghost { border: 1px solid var(--line); background: transparent; color: #d9d4e8; padding: 8px 12px; border-radius: 10px; cursor: pointer; white-space: nowrap; }
.ghost.small { padding: 5px 10px; font-size: 12px; }

/* Immersive mode: player covers the whole Mini App (used with Telegram fullscreen). */
body.immersive { overflow: hidden; }
body.immersive .stage { position: fixed; inset: 0; z-index: 50; margin: 0; border-radius: 0; aspect-ratio: auto; padding: var(--tg-safe-area-inset-top, 0) var(--tg-safe-area-inset-right, 0) var(--tg-safe-area-inset-bottom, 0) var(--tg-safe-area-inset-left, 0); }
body.immersive .player-host { inset: var(--tg-safe-area-inset-top, 0) var(--tg-safe-area-inset-right, 0) var(--tg-safe-area-inset-bottom, 0) var(--tg-safe-area-inset-left, 0); }
.exit-immersive { position: absolute; z-index: 2; top: calc(8px + var(--tg-safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px)); right: 10px; width: 36px; height: 36px; border-radius: 50%; border: 0; background: rgba(0,0,0,.55); color: #fff; cursor: pointer; }
.stage:fullscreen { border-radius: 0; }

footer { border-top: 1px solid var(--line); margin-top: 28px; padding-top: 14px; color: #74798a; font-size: 11px; }

@media (min-width: 600px) {
  .sources { grid-template-columns: 1fr 1fr; }
  .poster { width: 104px; }
}
@media (prefers-reduced-motion: reduce) {
  .source { animation: none; }
  .spinner { animation-duration: 2s; }
}
