/* BipTV Web-App – dunkles Kino-Thema wie Mac-App und Fire TV */
:root {
  --bg: #0A0B10; --sidebar: #0F1117; --surface: #171A23; --surface-high: #222634;
  --text: #fff; --text2: rgba(255,255,255,.62); --text3: rgba(255,255,255,.40);
  --accent: #FF5E62; --accent-end: #FF9966; --success: #4DD98C;
  --grad: linear-gradient(90deg, var(--accent), var(--accent-end));
  --safe-top: env(safe-area-inset-top); --safe-bottom: env(safe-area-inset-bottom);
  --safe-left: env(safe-area-inset-left); --safe-right: env(safe-area-inset-right);
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body { font: 15px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif; overscroll-behavior: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
/* Karten sind Links: wie normaler Text aussehen (nicht blau, nicht unterstrichen) */
a, a:visited, a:hover, a:active { color: inherit; text-decoration: none; }
.card .t { color: var(--text); }
input { font: inherit; }
img { display: block; }

/* Rahmen: Seitenleiste (quer) bzw. Leiste unten (hoch) */
.shell { display: flex; height: 100vh; height: 100dvh; }
.nav { width: 210px; flex: none; background: var(--sidebar); padding: calc(24px + var(--safe-top)) 14px 20px calc(14px + var(--safe-left));
       display: flex; flex-direction: column; gap: 4px; }
.nav .brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 22px; font-weight: 800; font-size: 19px; }
.nav .brand img { width: 40px; height: 40px; border-radius: 10px; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 12px; color: var(--text2);
         text-decoration: none; font-weight: 600; }
.nav a.on { background: rgba(255,94,98,.14); color: var(--text); }
.nav a .i { width: 22px; text-align: center; font-size: 17px; }
.main { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding-bottom: calc(30px + var(--safe-bottom)); }
@media (orientation: portrait), (max-width: 760px) {
  .shell { flex-direction: column-reverse; }
  .nav { width: auto; flex-direction: row; padding: 6px calc(6px + var(--safe-left)) calc(6px + var(--safe-bottom)); justify-content: space-around;
         border-top: 1px solid rgba(255,255,255,.06); }
  .nav .brand { display: none; }
  .nav a { flex-direction: column; gap: 2px; padding: 6px 8px; font-size: 11px; }
  .nav a.on { background: none; color: var(--accent); }
  .main { padding-bottom: 20px; }
}

.page { padding: calc(22px + var(--safe-top)) calc(26px + var(--safe-right)) 20px 26px; }
.head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.head h1 { font-size: 28px; font-weight: 800; margin: 0; flex: 1; }
.msg { color: var(--text2); text-align: center; padding: 60px 20px; }
.err { color: var(--accent-end); }

/* Reihen und Raster */
.shelf { margin: 8px 0 26px; }
.shelf h2 { font-size: 19px; margin: 0 0 10px; }
.row { display: flex; gap: 14px; overflow-x: auto; scroll-snap-type: x proximity; padding-bottom: 6px; scrollbar-width: none; }
.row::-webkit-scrollbar { display: none; }
.row > * { flex: none; scroll-snap-align: start; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 22px 16px; }
.card { width: 140px; text-align: left; }
.grid .card { width: auto; }
.poster { position: relative; aspect-ratio: 2/3; border-radius: 10px; overflow: hidden; background: linear-gradient(135deg, var(--surface-high), var(--surface));
          box-shadow: 0 3px 10px rgba(0,0,0,.35); }
.poster img { width: 100%; height: 100%; object-fit: cover; }
.poster .ph { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 10px; text-align: center;
              color: var(--text2); font-size: 13px; font-weight: 600; }
.badge4k { position: absolute; top: 6px; right: 6px; font-size: 10px; font-weight: 800; padding: 2px 5px; border-radius: 4px; background: rgba(0,0,0,.55); }
.card .t { font-size: 13px; font-weight: 600; margin-top: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .s { font-size: 11.5px; color: var(--text3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar { height: 4px; border-radius: 2px; background: rgba(255,255,255,.25); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--grad); }
.poster .bar { position: absolute; left: 6px; right: 6px; bottom: 6px; }
.wide { position: relative; width: 280px; aspect-ratio: 16/9; border-radius: 10px; overflow: hidden; background: var(--surface); text-align: left; }
.wide img { width: 100%; height: 100%; object-fit: cover; }
.wide .shade { position: absolute; inset: 0; background: linear-gradient(transparent 35%, rgba(0,0,0,.9)); }
.wide .info { position: absolute; left: 10px; right: 10px; bottom: 10px; }
.wide .info b { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wide .info span { font-size: 12px; color: var(--text2); }
.wide .info .bar { margin-top: 5px; }
.wide .x { position: absolute; top: 6px; right: 6px; width: 30px; height: 30px; border-radius: 15px; background: rgba(0,0,0,.55); font-size: 14px; }

/* Bedienelemente */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 14px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: 8px 14px; border-radius: 99px; background: rgba(255,255,255,.08); color: var(--text2); font-weight: 600; font-size: 14px; white-space: nowrap; }
.chip.on { background: var(--grad); color: #fff; }
.chip small { opacity: .7; font-weight: 400; margin-left: 4px; }
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 11px 20px; border-radius: 99px; font-weight: 700; background: rgba(255,255,255,.12); }
.btn.primary { background: var(--grad); }
.btn.small { padding: 7px 14px; font-size: 14px; }
.icon-btn { width: 40px; height: 40px; border-radius: 20px; background: rgba(255,255,255,.1); font-size: 20px; font-weight: 700; }
.search { width: 100%; padding: 12px 18px; border-radius: 99px; border: 0; background: rgba(255,255,255,.1); color: #fff; font-size: 17px; outline: none; }

/* Detailseite */
.hero { position: relative; min-height: 420px; display: flex; align-items: flex-end; }
.hero .bd { position: absolute; inset: 0; background-size: cover; background-position: center top; }
.hero .bd::after { content: ""; position: absolute; inset: 0;
  background: linear-gradient(rgba(10,11,16,.2), var(--bg)), linear-gradient(90deg, rgba(10,11,16,.92), transparent 70%); }
.hero .in { position: relative; display: flex; gap: 24px; align-items: flex-end; padding: calc(70px + var(--safe-top)) 28px 20px; }
.hero .poster { width: 170px; flex: none; }
.hero .kind { font-size: 11px; font-weight: 800; letter-spacing: 1.6px; color: var(--accent); }
.hero h1 { font-size: 32px; line-height: 1.1; margin: 4px 0 8px; font-weight: 800; }
.hero .meta { color: var(--text2); font-size: 13px; font-weight: 500; }
.hero .plot { color: var(--text2); font-size: 14px; margin: 8px 0 0; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.hero .actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.back { position: absolute; top: calc(14px + var(--safe-top)); left: 18px; z-index: 2; }
.section { padding: 4px 28px 0; }
.section h3 { font-size: 18px; margin: 14px 0 10px; }
.item { display: flex; gap: 14px; padding: 10px; border-radius: 12px; background: var(--surface); margin-bottom: 10px; width: 100%; text-align: left; align-items: flex-start; }
.item .thumb { position: relative; width: 180px; flex: none; aspect-ratio: 16/9; border-radius: 8px; overflow: hidden; background: var(--surface-high);
               display: flex; align-items: center; justify-content: center; color: var(--text3); }
.item .thumb img { width: 100%; height: 100%; object-fit: cover; position: absolute; inset: 0; }
.item .thumb .bar { position: absolute; left: 6px; right: 6px; bottom: 6px; }
.item .thumb .play { position: relative; font-size: 24px; color: #fff; }
.item .body { flex: 1; min-width: 0; }
.item .line { display: flex; gap: 8px; align-items: baseline; }
.item .num { color: var(--accent); font-weight: 800; font-size: 13px; }
.item .title { font-weight: 600; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .dur { color: var(--text3); font-size: 12px; white-space: nowrap; }
.item .seen { color: var(--success); font-size: 11px; white-space: nowrap; }
.item .desc { color: var(--text2); font-size: 13px; margin-top: 4px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.tag { display: inline-block; font-size: 10px; font-weight: 700; padding: 2px 5px; border-radius: 4px; background: rgba(255,255,255,.12); margin-right: 4px; }
@media (max-width: 760px) { .item .thumb { width: 130px; } .hero .poster { width: 120px; } .hero h1 { font-size: 24px; } }

/* Fenster (Merken) */
.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; z-index: 50; }
.sheet { width: min(460px, 92vw); max-height: 80vh; overflow-y: auto; background: var(--surface); border-radius: 16px; padding: 20px; }
.sheet .top { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.sheet h2 { margin: 0; flex: 1; font-size: 20px; }
.sheet .sub { color: var(--text3); font-size: 12px; margin-bottom: 12px; }
.sheet .opt { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px; border-radius: 10px; background: rgba(255,255,255,.05); margin-bottom: 8px; }
.sheet .opt .c { width: 22px; height: 22px; border-radius: 11px; border: 2px solid var(--text3); flex: none; }
.sheet .opt.on .c { border: 0; background: var(--grad); }
.sheet .opt span { flex: 1; text-align: left; }
.sheet .opt small { color: var(--text3); }

/* Player */
html.playing, html.playing body { overflow: hidden; height: 100%; }
html.playing .shell { visibility: hidden; }
.player { position: fixed; inset: 0; background: #000; z-index: 100; overflow: hidden; }
.player video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
.player .tap { position: absolute; inset: 0; }
.player .ui { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: space-between;
              padding: calc(18px + var(--safe-top)) calc(24px + var(--safe-right)) calc(18px + var(--safe-bottom)) calc(24px + var(--safe-left));
              background: linear-gradient(rgba(0,0,0,.65), transparent 30%, transparent 65%, rgba(0,0,0,.75)); transition: opacity .2s; pointer-events: none; }
.player .ui > * { pointer-events: auto; }
.player .ui.hidden { opacity: 0; }
.player .ui.hidden > * { pointer-events: none; }
.player .top { display: flex; align-items: flex-start; gap: 12px; }
.player .top .tt { flex: 1; }
.player .top b { font-size: 18px; display: block; }
.player .top span { font-size: 14px; color: rgba(255,255,255,.75); }
.player .center { display: flex; justify-content: center; gap: 60px; align-items: center; align-self: center; }
.player .center button { font-size: 30px; width: 70px; height: 70px; border-radius: 35px; background: rgba(255,255,255,.12); }
.player .center .pp { width: 86px; height: 86px; border-radius: 43px; font-size: 38px; }
.player .bottom { display: flex; align-items: center; gap: 12px; font-size: 13px; font-variant-numeric: tabular-nums; }
.player input[type=range] { flex: 1; accent-color: var(--accent); }
.player .next { padding: 9px 14px; border-radius: 8px; background: #fff; color: #000; font-weight: 700; font-size: 15px; white-space: nowrap; }
.player .credits { position: absolute; right: calc(36px + var(--safe-right)); bottom: calc(40px + var(--safe-bottom)); display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.player .credits .row2 { display: flex; gap: 10px; }
.player .credits .skip { padding: 11px 18px; border-radius: 8px; background: #fff; color: #000; font-weight: 700; font-size: 16px; }
.player .credits .watch { padding: 10px 14px; border-radius: 8px; background: rgba(0,0,0,.6); font-weight: 600; }
.player .credits small { background: rgba(0,0,0,.5); padding: 3px 8px; border-radius: 4px; }
.player .state { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none; }
.player .state .box { background: rgba(0,0,0,.7); padding: 16px 20px; border-radius: 12px; max-width: 80%; text-align: center; pointer-events: auto; }
.spinner { width: 46px; height: 46px; border-radius: 50%; border: 4px solid rgba(255,255,255,.25); border-top-color: #fff; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.trailer iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.trailer .close { position: absolute; top: calc(16px + var(--safe-top)); left: calc(16px + var(--safe-left)); z-index: 2; }

/* Koppeln */
.pair { max-width: 520px; margin: 0 auto; padding: calc(60px + var(--safe-top)) 24px; text-align: center; }
.pair img { width: 96px; height: 96px; border-radius: 22px; margin: 0 auto 18px; }
.pair h1 { font-size: 28px; margin: 0 0 10px; }
.pair p { color: var(--text2); }
.pair .code { text-align: center; font: 800 44px/1.2 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: 6px; padding: 18px; border-radius: 16px;
              background: rgba(255,255,255,.08); margin: 14px 0; user-select: all; }
.hint { background: rgba(255,94,98,.12); border-radius: 12px; padding: 12px 14px; color: var(--text); font-size: 14px; margin-bottom: 18px; }

/* Einstellungen */
.set { background: var(--surface); border-radius: 14px; padding: 6px 0; margin-bottom: 18px; }
.set .r { display: flex; align-items: center; gap: 12px; padding: 10px 16px; }
.set .r + .r { border-top: 1px solid rgba(255,255,255,.05); }
.set .r span { flex: 1; }
.set h4 { margin: 16px 4px 6px; color: var(--text3); font-size: 12px; text-transform: uppercase; letter-spacing: .8px; font-weight: 700; }
.set-foot { color: var(--text3); font-size: 12.5px; margin: -10px 6px 18px; }
.switch { width: 50px; height: 30px; border-radius: 15px; background: rgba(255,255,255,.18); position: relative; flex: none; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 12px; background: #fff; transition: left .15s; }
.switch.on { background: var(--accent); }
.switch.on::after { left: 23px; }
select { background: rgba(255,255,255,.1); color: #fff; border: 0; border-radius: 8px; padding: 6px 10px; font: inherit; }
