* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; background: #0b0b0f; color: #f2f2f5; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; overflow: hidden; overscroll-behavior: none; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
a { color: #7cc4ff; }
.hidden { display: none !important; }

/* Top bar */
#topbar { position: fixed; top: 0; left: 0; right: 0; z-index: 20; display: flex; align-items: center; gap: 8px;
  padding: calc(env(safe-area-inset-top) + 10px) 12px 10px; background: linear-gradient(#000a, #0000); pointer-events: none; }
#topbar > * { pointer-events: auto; }
.spacer { flex: 1; }
.pill { min-width: 0; max-width: 60vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: #ffffff22; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); padding: 8px 14px; border-radius: 999px; font-size: 14px; font-weight: 600; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; background: #ffffff22; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); font-size: 18px; }

/* Feed */
#feed { height: 100dvh; overflow-y: scroll; scroll-snap-type: y mandatory; scrollbar-width: none; }
#feed::-webkit-scrollbar { display: none; }
.card { position: relative; height: 100dvh; scroll-snap-align: start; scroll-snap-stop: always; overflow: hidden;
  display: flex; flex-direction: column; justify-content: center; }
.card .bg { position: absolute; inset: 0; background-size: cover; background-position: center; filter: blur(28px) brightness(.45); transform: scale(1.2); }
.card .stage { position: relative; width: 100%; aspect-ratio: 16/9; background: #000 center/cover no-repeat; z-index: 1; overflow: hidden; }
.card .stage iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
/* Optional setting (off by default): make the player 200px taller than its frame. YouTube centres the video and
   draws its title bar and logo in the extra space above/below, which the frame (overflow: hidden) then trims off. */
body.trim-yt .card .stage iframe { inset: auto; left: 0; top: -100px; height: calc(100% + 200px); }
.card .stage .play-hint { position: absolute; inset: 0; display: grid; place-items: center; font-size: 46px; opacity: .85; text-shadow: 0 2px 12px #000; }
.card .info { position: relative; z-index: 1; padding: 18px 76px 0 16px; }
.card h2 { font-size: 22px; line-height: 1.2; margin-bottom: 6px; }
.card .meta { font-size: 13px; color: #cfcfd8; display: flex; flex-wrap: wrap; gap: 6px 10px; margin-bottom: 8px; }
.card .badge { background: #e50914; color: #fff; padding: 2px 8px; border-radius: 6px; font-weight: 700; font-size: 12px; }
.card .badge.soon { background: #2d6cdf; }
.card .overview { font-size: 14px; color: #ddd; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card .overview.open { -webkit-line-clamp: unset; }
.card .actions { position: absolute; right: 12px; bottom: calc(env(safe-area-inset-bottom) + 90px); z-index: 2; display: flex; flex-direction: column; gap: 18px; align-items: center; }
.card .actions button { display: flex; flex-direction: column; align-items: center; font-size: 11px; color: #ddd; gap: 3px; }
.card .actions .ico { width: 48px; height: 48px; border-radius: 50%; background: #ffffff1f; display: grid; place-items: center; font-size: 22px; transition: transform .15s; }
.card .actions button:active .ico { transform: scale(.88); }
.card .actions .liked .ico { background: #e50914; }
.card .seen { font-size: 12px; color: #ffd27a; margin-top: 8px; }
.card .badge.now { background: #1f9d55; }
.card .cert { border: 1px solid #ffffff66; padding: 1px 6px; border-radius: 4px; font-size: 11px; font-weight: 700; }
.card .stream small { color: #8a8a96; font-size: 11px; }
.card .stream { font-size: 13px; color: #b9f3c9; margin-bottom: 6px; }
.card .chips-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; pointer-events: auto; }
.card .chips-row button { background: #ffffff1f; border: 1px solid #ffffff2a; padding: 7px 12px; border-radius: 999px; font-size: 13px; font-weight: 600; }
.card .chips-row button:active { transform: scale(.96); }
.card .why { font-size: 12px; color: #9fd3ff; margin-top: 8px; }

.status { position: fixed; bottom: calc(env(safe-area-inset-bottom) + 16px); left: 50%; transform: translateX(-50%); z-index: 15;
  font-size: 13px; color: #aaa; background: #000a; padding: 6px 12px; border-radius: 999px; pointer-events: none; }
.status:empty { display: none; }
.empty { height: 100dvh; display: grid; place-items: center; text-align: center; padding: 30px; color: #aaa; scroll-snap-align: start; }

/* Sheets */
.sheet { position: fixed; inset: 0; z-index: 30; background: #0008; display: flex; align-items: flex-end; }
.sheet-inner { width: 100%; max-height: 88dvh; overflow-y: auto; background: #16161d; border-radius: 18px 18px 0 0;
  padding: 18px 16px calc(env(safe-area-inset-bottom) + 20px); animation: up .2s ease-out; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.sheet h2 { font-size: 20px; }
.sheet h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: #999; margin: 18px 0 8px; }
.sheet h3 small { text-transform: none; letter-spacing: 0; }
.close { font-size: 20px; padding: 4px 8px; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button, .chips button { padding: 8px 12px; border-radius: 999px; background: #ffffff14; font-size: 14px; }
.seg button.on, .chips button.on { background: #f2f2f5; color: #111; font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.toggle { display: flex; gap: 10px; align-items: center; margin: 20px 0 4px; font-size: 15px; }
.toggle input { width: 20px; height: 20px; flex: none; }
.setting-toggle { margin: 0; padding: 12px 0; border-bottom: 1px solid #ffffff12; color: #ddd; }
.setting-toggle small { color: #888; font-size: 12px; }
.primary { display: block; width: 100%; margin-top: 18px; padding: 14px; border-radius: 12px; background: #e50914; color: #fff; font-weight: 700; font-size: 16px; }
.settings { margin-top: 22px; color: #aaa; }
.settings summary { padding: 6px 0; }
.settings button { display: block; width: 100%; text-align: left; padding: 12px 0; border-bottom: 1px solid #ffffff12; color: #ddd; }
.credits { font-size: 12px; color: #888; margin-top: 18px; line-height: 1.6; }
.credits a { color: #aaa; }
.tmdb-note { font-size: 11px; margin-top: 12px; color: #777; }

.list { margin-top: 12px; }
.list .row { display: flex; gap: 12px; align-items: center; padding: 8px 0; border-bottom: 1px solid #ffffff10; }
.list .noimg { width: 46px; height: 69px; border-radius: 6px; background: #222; flex: none; }
.list img { width: 46px; height: 69px; object-fit: cover; border-radius: 6px; background: #222; }
.list .t { font-weight: 600; }
.list .s { font-size: 12px; color: #999; }
.list .row-btns { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.list .row-btns button { font-size: 20px; padding: 4px; }
.list .row a { font-size: 13px; white-space: nowrap; }
.field { display: block; padding: 12px 0; border-bottom: 1px solid #ffffff12; color: #ddd; }
.field small { color: #888; }
.field select { display: block; width: 100%; margin-top: 8px; padding: 10px; border-radius: 10px; background: #0b0b0f; color: #fff; border: 1px solid #333; font: inherit; }
.where { display: grid; gap: 8px; }
.where select, .where input { width: 100%; padding: 11px 12px; border-radius: 10px; background: #0b0b0f; color: #fff; border: 1px solid #333; font: inherit; font-size: 15px; }
.where .hint { font-size: 12px; color: #888; }
.secondary { display: block; width: 100%; margin-top: 10px; padding: 14px; border-radius: 12px; background: #ffffff14; font-weight: 700; font-size: 16px; }
.cal-title { color: #ccc; margin: 4px 0 6px; }
.list .none { color: #888; padding: 20px 0; text-align: center; }

/* Setup */
.screen { position: fixed; inset: 0; z-index: 50; background: #0b0b0f; display: grid; place-items: center; padding: 24px; }
.setup-box { max-width: 420px; width: 100%; }
.setup-box h1 { font-size: 30px; margin-bottom: 10px; }
.setup-box p, .setup-box ol { color: #bbb; line-height: 1.5; margin-bottom: 14px; }
.setup-box ol { padding-left: 20px; }
.setup-box input { width: 100%; padding: 14px; border-radius: 12px; border: 1px solid #333; background: #16161d; color: #fff; font-size: 15px; }
.error { color: #ff6b6b; margin-top: 10px; font-size: 14px; }

/* Seek bar: our own, drawn under the player (YouTube's controls are switched off with its controls=0 setting) */
.card .scrub { --p: 0; position: relative; z-index: 4; height: 26px; display: flex; align-items: center; padding: 0 14px;
  touch-action: none; cursor: pointer; opacity: 0; pointer-events: none; transition: opacity .25s; }
.card .scrub.ready { opacity: 1; pointer-events: auto; }
.card .scrub .pp { flex: none; width: 34px; height: 26px; margin: 0 6px 0 -6px; display: grid; place-items: center; font-size: 15px; color: #fff; }
.card .scrub .pp::before { content: '❚❚'; letter-spacing: -2px; }
.card.paused .scrub .pp::before { content: '▶'; letter-spacing: 0; }
.card .scrub .track { position: relative; flex: 1; height: 3px; background: #ffffff38; border-radius: 3px; transition: height .15s; }
.card .scrub .bar { position: absolute; left: 0; top: 0; bottom: 0; width: calc(var(--p) * 100%); background: #e50914; border-radius: 3px; }
.card .scrub .knob { position: absolute; top: 50%; left: calc(var(--p) * 100%); width: 13px; height: 13px; border-radius: 50%;
  background: #fff; transform: translate(-50%, -50%) scale(.8); box-shadow: 0 1px 4px #0008; transition: transform .15s, opacity .25s; }
.card.calm .scrub .knob { opacity: 0; }
.card .scrub.drag .track, .card .scrub:hover .track { height: 6px; }
.card .scrub.drag .knob { opacity: 1; transform: translate(-50%, -50%) scale(1.3); }
.card .scrub .time { display: none; position: absolute; bottom: 30px; left: 50%; transform: translateX(-50%); background: #000c;
  padding: 4px 10px; border-radius: 8px; font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.card .scrub.drag .time { display: block; }

/* Phone turned sideways / browser full screen: video only. The player is kept clear of the top bar and the
   seek bar so nothing sits on top of it (YouTube's rules don't allow covering the player). */
@media (orientation: landscape) and (max-height: 520px) {
  .card .info, .card .actions, .card .bg { display: none; }
  .card .stage { position: absolute; top: 62px; left: 50%; transform: translateX(-50%); margin: 0;
    width: min(100vw, calc((100dvh - 94px) * 16 / 9)); aspect-ratio: 16/9; }
  .card .scrub { position: absolute; left: 50%; transform: translateX(-50%); bottom: 2px; margin: 0;
    width: min(100vw, calc((100dvh - 94px) * 16 / 9)); }
}
@media (orientation: landscape) {
  body.fs .card .info, body.fs .card .actions, body.fs .card .bg { display: none; }
  body.fs .card .stage { position: absolute; top: 62px; left: 50%; transform: translateX(-50%); margin: 0;
    width: min(100vw, calc((100dvh - 98px) * 16 / 9)); aspect-ratio: 16/9; border-radius: 0; box-shadow: none; }
  body.fs .card .scrub { position: absolute; left: 50%; transform: translateX(-50%); bottom: 4px; margin: 0;
    width: min(100vw, calc((100dvh - 98px) * 16 / 9)); }
}

/* PC / tablet: big centred video with the details underneath */
@media (min-width: 700px) and (min-height: 521px) {
  .card .stage, .card .info, .card .scrub { width: min(calc(100% - 180px), calc((100dvh - 240px) * 16 / 9)); margin: 0 auto; }
  .card .scrub { padding: 0; margin-top: 4px; }
  .card .stage { box-shadow: 0 20px 60px #000c; }
  .card .info { padding: 18px 0 0; }
  .card h2 { font-size: 26px; }
  .card .actions { right: 28px; bottom: auto; top: 50%; transform: translateY(-50%); }
}
