:root {
  --bg: #0b0b0d; --bg-2: #121215; --panel: #16161a; --panel-2: #1d1d22; --hover: #26262d; --line: #2a2a31;
  --text: #f2f1ee; --text-2: #a9a8b0; --text-3: #7c7b84;
  --music: #3ddc84; --music-ink: #062512; --video: #e5383b; --accent: var(--music); --ink: var(--music-ink);
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
  --tab-h: 58px; --mini-h: 60px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, system-ui, sans-serif;
}
body.video { --accent: var(--video); --ink: #fff; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 15px; -webkit-font-smoothing: antialiased; overscroll-behavior-y: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, select { font: inherit; color: inherit; }
svg { width: 22px; height: 22px; fill: currentColor; flex: none; }
.boot { position: fixed; inset: 0; display: grid; place-items: center; }
.spin { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* layout */
#main { position: fixed; inset: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: calc(var(--safe-t) + 8px) 0 calc(var(--tab-h) + var(--safe-b) + 24px); }
body.has-mini #main { padding-bottom: calc(var(--tab-h) + var(--mini-h) + var(--safe-b) + 28px); }
.top { display: flex; align-items: center; gap: 12px; padding: 8px 16px 6px; min-height: 48px; }
.top h1 { font-size: 26px; margin: 0; letter-spacing: -0.4px; flex: 1; }
.top .back { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: rgba(255,255,255,0.07); }
.sticky-top { position: sticky; top: calc(-1 * var(--safe-t) - 8px); z-index: 5; background: linear-gradient(var(--bg) 70%, transparent); padding-top: calc(var(--safe-t) + 8px); margin-top: calc(-1 * var(--safe-t) - 8px); }
.switch { display: flex; gap: 8px; padding: 0 16px 10px; overflow-x: auto; scrollbar-width: none; }
.switch::-webkit-scrollbar { display: none; }
.chip { padding: 7px 14px; border-radius: 999px; background: var(--panel-2); color: var(--text); font-size: 13.5px; white-space: nowrap; }
.chip.on { background: var(--accent); color: var(--ink); font-weight: 600; }

/* tabs */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; padding: 6px 4px calc(var(--safe-b) + 4px); background: linear-gradient(rgba(11,11,13,0.6), rgba(11,11,13,0.98) 40%); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.tabs button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 11px; color: var(--text-3); height: 48px; justify-content: center; }
.tabs button.on { color: var(--text); }
.tabs button.on svg { color: var(--accent); }

/* shelves and cards */
.shelf { margin: 18px 0 6px; }
.shelf h2 { font-size: 19px; margin: 0 16px 10px; letter-spacing: -0.2px; display: flex; align-items: center; justify-content: space-between; }
.shelf h2 button { font-size: 13px; color: var(--text-2); font-weight: 500; }
.row { display: flex; gap: 12px; overflow-x: auto; padding: 0 16px 4px; scroll-snap-type: x proximity; scrollbar-width: none; }
.row::-webkit-scrollbar { display: none; }
.card { flex: none; width: 140px; text-align: left; scroll-snap-align: start; }
.card .art { width: 140px; height: 140px; }
.card b { display: block; font-size: 13.5px; margin-top: 7px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.card span { display: block; font-size: 12.5px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.card.round .art { border-radius: 50%; }
.card.round { text-align: center; }
.art { position: relative; border-radius: 6px; overflow: hidden; background: var(--panel-2); flex: none; }
.art img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.gen { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 700; font-size: 20px; color: rgba(255,255,255,0.9); text-align: center; padding: 8px; line-height: 1.15; overflow: hidden; }
.poster { width: 118px; } .poster .art { width: 118px; height: 177px; border-radius: 6px; }
.wide { width: 230px; } .wide .art { width: 230px; height: 130px; }
.bar { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(255,255,255,0.25); }
.bar i { display: block; height: 100%; background: var(--video); }
.quick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 6px 16px 4px; }
.quick button { display: flex; align-items: center; gap: 10px; background: var(--panel-2); border-radius: 6px; overflow: hidden; height: 56px; text-align: left; font-weight: 600; font-size: 13px; }
.quick .art { width: 56px; height: 56px; border-radius: 0; }
.quick b { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; padding-right: 6px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px 12px; padding: 6px 16px; }
.grid .card { width: auto; } .grid .card .art { width: 100%; height: auto; aspect-ratio: 1; }
.grid.posters { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); }
.grid.posters .card .art { aspect-ratio: 2 / 3; }
.empty { padding: 60px 30px; text-align: center; color: var(--text-2); line-height: 1.5; }
.empty b { display: block; color: var(--text); font-size: 18px; margin-bottom: 6px; }

/* hero */
.hero { position: relative; margin: 4px 16px 6px; border-radius: 12px; overflow: hidden; aspect-ratio: 16 / 10; background: var(--panel-2); }
.hero .bg { position: absolute; inset: 0; background-size: cover; background-position: center; }
.hero::after { content: ''; position: absolute; inset: 0; background: linear-gradient(transparent 30%, rgba(0,0,0,0.85)); }
.hero .txt { position: absolute; left: 16px; right: 16px; bottom: 14px; z-index: 1; }
.hero .kick { font-size: 11.5px; letter-spacing: 1.2px; text-transform: uppercase; color: rgba(255,255,255,0.75); font-weight: 600; }
.hero h3 { font-size: 24px; margin: 4px 0 10px; letter-spacing: -0.3px; }
.btns { display: flex; gap: 10px; flex-wrap: wrap; }
.btn { display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 18px; border-radius: 999px; font-weight: 700; font-size: 14.5px; background: var(--accent); color: var(--ink); }
.btn.white { background: #fff; color: #000; border-radius: 6px; }
.btn.ghost { background: rgba(255,255,255,0.14); color: #fff; }
.btn svg { width: 20px; height: 20px; }
.ibtn { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; color: var(--text-2); }
.ibtn.on { color: var(--accent); }
.play-big { width: 54px; height: 54px; border-radius: 50%; background: var(--accent); color: var(--ink); display: grid; place-items: center; }
.play-big svg { width: 28px; height: 28px; }

/* detail headers */
.dhead { padding: 6px 16px 10px; text-align: center; }
.dhead .art { width: 62vw; max-width: 260px; aspect-ratio: 1; height: auto; margin: 4px auto 16px; box-shadow: 0 12px 40px rgba(0,0,0,0.5); }
.dhead.round .art { border-radius: 50%; }
.dhead h2 { font-size: 23px; margin: 0; text-align: left; letter-spacing: -0.3px; }
.dhead .sub { color: var(--text-2); font-size: 13.5px; margin-top: 4px; text-align: left; }
.dctl { display: flex; align-items: center; gap: 6px; margin-top: 10px; }
.dctl .grow { flex: 1; }
.vhead { position: relative; margin-top: calc(-1 * var(--safe-t) - 8px); }
.vhead .bg { aspect-ratio: 16 / 10; width: 100%; background-size: cover; background-position: center 25%; position: relative; }
.vhead .bg::after { content: ''; position: absolute; inset: 0; background: linear-gradient(rgba(0,0,0,0.25), transparent 40%, var(--bg)); }
.vhead .back { position: absolute; top: calc(var(--safe-t) + 12px); left: 12px; z-index: 2; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: rgba(0,0,0,0.55); }
.vinfo { padding: 0 16px; margin-top: -26px; position: relative; }
.vinfo h2 { font-size: 26px; margin: 0 0 6px; letter-spacing: -0.4px; }
.meta { color: var(--text-2); font-size: 13px; display: flex; flex-wrap: wrap; gap: 4px 10px; }
.vinfo p { color: #d6d5db; line-height: 1.5; font-size: 14px; margin: 12px 0; }
.vinfo .btns .btn { flex: 1; justify-content: center; border-radius: 6px; }
.tagline { font-style: normal; color: var(--text-2); font-size: 13.5px; margin-top: 10px; }
.season { margin: 18px 16px 6px; }
.season select { background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 9px 12px; font-weight: 600; }
.ep { display: grid; grid-template-columns: 132px 1fr; gap: 12px; padding: 10px 16px; text-align: left; width: 100%; align-items: center; }
.ep .art { width: 132px; height: 74px; border-radius: 4px; }
.ep b { display: block; font-size: 14px; }
.ep small { display: block; color: var(--text-2); font-size: 12px; margin-top: 3px; }
.ep .desc { grid-column: 1 / -1; color: var(--text-2); font-size: 13px; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; margin-top: -2px; }
.ep.cur b { color: var(--video); }

/* track lists */
.list { padding: 4px 0; }
.trk { display: flex; align-items: center; gap: 12px; padding: 7px 16px; width: 100%; text-align: left; min-height: 58px; }
.trk .art { width: 46px; height: 46px; border-radius: 4px; }
.trk .num { width: 22px; text-align: center; color: var(--text-2); font-size: 14px; flex: none; }
.trk .t { flex: 1; min-width: 0; }
.trk b { display: block; font-weight: 500; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trk span { display: block; font-size: 13px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.trk.cur b { color: var(--accent); }
.trk .dur { color: var(--text-3); font-size: 13px; }
.more { display: block; margin: 12px auto; padding: 10px 20px; border-radius: 999px; border: 1px solid var(--line); color: var(--text-2); }

/* search */
.search { margin: 4px 16px 8px; display: flex; align-items: center; gap: 10px; background: #fff; color: #111; border-radius: 8px; padding: 0 12px; height: 46px; }
.search input { flex: 1; border: 0; outline: 0; background: none; color: #111; font-size: 16px; height: 100%; }
.search svg { color: #555; }
.sec-h { font-size: 13px; text-transform: uppercase; letter-spacing: 1px; color: var(--text-2); margin: 18px 16px 6px; font-weight: 600; }

/* mini player */
.mini { position: fixed; left: 8px; right: 8px; bottom: calc(var(--tab-h) + var(--safe-b) + 6px); height: var(--mini-h); z-index: 29; display: none; align-items: center; gap: 10px; padding: 0 6px 0 8px; border-radius: 8px; background: #2a2a31; overflow: hidden; box-shadow: 0 8px 24px rgba(0,0,0,0.4); }
body.has-mini .mini { display: flex; }
.mini .art { width: 44px; height: 44px; border-radius: 4px; }
.mini .t { flex: 1; min-width: 0; text-align: left; }
.mini b { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini span { display: block; font-size: 12.5px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini .ibtn { color: var(--text); }
.mini .prog { position: absolute; left: 8px; right: 8px; bottom: 0; height: 2px; background: rgba(255,255,255,0.15); }
.mini .prog i { display: block; height: 100%; background: #fff; width: 0; }

/* now playing sheet */
.np { position: fixed; inset: 0; z-index: 40; background: linear-gradient(var(--np, #333) 0%, #121215 70%); display: flex; flex-direction: column; padding: calc(var(--safe-t) + 10px) 24px calc(var(--safe-b) + 20px); transform: translateY(100%); transition: transform 0.28s cubic-bezier(.2,.8,.2,1); }
.np.open { transform: none; }
.np .bar-top { display: flex; align-items: center; justify-content: space-between; height: 44px; }
.np .bar-top small { font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--text-2); text-align: center; flex: 1; }
.np .big { flex: 1; display: flex; align-items: center; justify-content: center; min-height: 0; padding: 16px 0; }
.np .big .art { width: min(84vw, 46vh); aspect-ratio: 1; height: auto; border-radius: 8px; box-shadow: 0 18px 50px rgba(0,0,0,0.55); }
.np h3 { font-size: 22px; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.np .who { color: var(--text-2); margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seek { margin-top: 18px; }
.seek input { width: 100%; }
.times { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-2); margin-top: 2px; font-variant-numeric: tabular-nums; }
.ctl { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; }
.ctl .play-big { width: 66px; height: 66px; background: #fff; color: #000; }
.ctl .play-big svg { width: 32px; height: 32px; }
.ctl .ibtn { color: var(--text); }
.ctl .ibtn.dim { color: var(--text-2); }
.ctl .ibtn.on { color: var(--music); }
input[type=range] { -webkit-appearance: none; appearance: none; height: 22px; background: transparent; margin: 0; }
input[type=range]::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: linear-gradient(90deg, #fff var(--p, 0%), rgba(255,255,255,0.25) var(--p, 0%)); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%; background: #fff; margin-top: -5px; }
input[type=range]::-moz-range-track { height: 4px; background: rgba(255,255,255,0.25); border-radius: 2px; }
input[type=range]::-moz-range-progress { height: 4px; background: #fff; border-radius: 2px; }
input[type=range]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 0; }

/* video player */
.vp { position: fixed; inset: 0; z-index: 50; background: #000; display: flex; align-items: center; justify-content: center; }
.vp video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.vp .ui { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: space-between; background: linear-gradient(rgba(0,0,0,0.65), transparent 22%, transparent 70%, rgba(0,0,0,0.75)); padding: calc(var(--safe-t) + 8px) calc(env(safe-area-inset-right, 0px) + 14px) calc(var(--safe-b) + 12px) calc(env(safe-area-inset-left, 0px) + 14px); transition: opacity 0.2s; }
.vp.hide-ui .ui { opacity: 0; pointer-events: none; }
.vp .vtop { display: flex; align-items: center; gap: 10px; }
.vp .vtop .t { flex: 1; min-width: 0; }
.vp .vtop b { display: block; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vp .vtop span { display: block; font-size: 12.5px; color: rgba(255,255,255,0.7); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vp .ibtn { color: #fff; }
.vp .ibtn.on { color: var(--video); }
.vp .mid { display: flex; align-items: center; justify-content: center; gap: 46px; }
.vp .mid .ibtn svg { width: 34px; height: 34px; }
.vp .mid .pp { width: 70px; height: 70px; }
.vp .mid .pp svg { width: 46px; height: 46px; }
.vp .vbot .times { color: rgba(255,255,255,0.85); }
.vp .vbot .row2 { display: flex; align-items: center; gap: 4px; margin-top: 4px; }
.vp .vbot .row2 .grow { flex: 1; }
.vp .vbot input[type=range]::-webkit-slider-runnable-track { background: linear-gradient(90deg, var(--video) var(--p, 0%), rgba(255,255,255,0.3) var(--p, 0%)); }
.vp .vbot input[type=range]::-moz-range-progress { background: var(--video); }
.vp .wait { position: absolute; inset: 0; display: none; place-items: center; pointer-events: none; }
.vp.busy .wait { display: grid; }
.vp .note { position: absolute; left: 50%; top: 50%; transform: translate(-50%, 60px); background: rgba(0,0,0,0.6); padding: 8px 14px; border-radius: 6px; font-size: 13px; color: #ddd; pointer-events: none; display: none; }
.vp.busy .note.show { display: block; }
.vp .nextep { position: absolute; right: calc(env(safe-area-inset-right, 0px) + 18px); bottom: calc(var(--safe-b) + 92px); display: none; }
.vp.near-end .nextep { display: inline-flex; }
.vp video::cue { background: rgba(0,0,0,0.7); font-size: 1.05em; }

/* pairing */
.pair { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 30px; text-align: center; }
.pair .logo { width: 72px; height: 72px; border-radius: 18px; margin-bottom: 18px; }
.pair h1 { margin: 0 0 8px; font-size: 26px; }
.pair p { color: var(--text-2); line-height: 1.5; margin: 0 0 22px; max-width: 340px; }
.pair input { width: 220px; text-align: center; font-size: 30px; letter-spacing: 10px; padding: 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel-2); outline: none; }
.pair input:focus { border-color: var(--music); }
.pair .btn { margin-top: 18px; height: 46px; padding: 0 30px; }
.pair .err { color: #ff7b7b; min-height: 22px; margin-top: 12px; font-size: 14px; }

.toast { position: fixed; left: 50%; bottom: calc(var(--tab-h) + var(--safe-b) + 80px); transform: translateX(-50%); background: #f2f1ee; color: #111; padding: 10px 16px; border-radius: 8px; font-size: 14px; z-index: 60; max-width: 90vw; text-align: center; box-shadow: 0 8px 24px rgba(0,0,0,0.4); }
.offline { position: fixed; top: calc(var(--safe-t) + 6px); left: 50%; transform: translateX(-50%); z-index: 45; background: #3a1d1d; color: #ffc9c9; padding: 7px 14px; border-radius: 999px; font-size: 13px; display: none; }
body.is-offline .offline { display: block; }
.sheet { position: fixed; inset: 0; z-index: 55; background: rgba(0,0,0,0.5); display: flex; align-items: flex-end; }
.sheet > div { width: 100%; background: #222228; border-radius: 14px 14px 0 0; padding: 8px 0 calc(var(--safe-b) + 10px); max-height: 75vh; overflow-y: auto; }
.sheet h4 { margin: 10px 18px 8px; font-size: 15px; color: var(--text-2); font-weight: 600; }
.sheet button.opt { display: flex; align-items: center; gap: 14px; width: 100%; padding: 14px 18px; text-align: left; font-size: 15.5px; }
.sheet button.opt.on { color: var(--accent); }
@media (min-width: 700px) {
  .card { width: 168px; } .card .art { width: 168px; height: 168px; }
  .poster { width: 140px; } .poster .art { width: 140px; height: 210px; }
  .hero { aspect-ratio: 21 / 9; }
  .vhead .bg { aspect-ratio: 21 / 9; }
}
.vp .vbot input[type=range] { display: block; width: 100%; box-sizing: border-box; margin: 0; }
.vp video::cue { color: #fff; background: rgba(0,0,0,0.65); text-shadow: 0 1px 2px #000; font-size: 1.1em; }
.vp video::-webkit-media-text-track-display { transform: translateY(-64px); }
.vp.hide-ui video::-webkit-media-text-track-display { transform: none; }
.vp .subs { position: absolute; left: 16px; right: 16px; bottom: calc(var(--safe-b) + 40px); text-align: center; pointer-events: none; z-index: 3; transition: bottom .2s; line-height: 1.5; }
.vp:not(.hide-ui) .subs { bottom: calc(var(--safe-b) + 150px); }
.vp .subs span { color: #fff; background: rgba(0,0,0,0.7); padding: 2px 8px; border-radius: 4px; font-size: 17px; text-shadow: 0 1px 2px #000; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
/* casting */
.castbtn { display: none !important; }
body.can-cast .castbtn { display: inline-flex !important; }
.castbar { position: fixed; left: 8px; right: 8px; bottom: calc(var(--tab-h) + var(--safe-b) + 6px); height: 52px; z-index: 31; display: flex; align-items: center; gap: 12px; padding: 0 6px 0 14px; border-radius: 8px; background: #1f3a5f; box-shadow: 0 8px 24px rgba(0,0,0,0.4); }
body.has-mini .castbar { bottom: calc(var(--tab-h) + var(--mini-h) + var(--safe-b) + 12px); }
.castbar > svg { width: 22px; height: 22px; fill: currentColor; flex: none; }
.castbar .t { flex: 1; min-width: 0; }
.castbar b { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.castbar span { display: block; font-size: 12.5px; color: #b8c7da; }
.castbar .ibtn { color: #fff; }
body.has-cast #main { padding-bottom: calc(var(--tab-h) + 52px + var(--safe-b) + 34px); }
body.has-cast.has-mini #main { padding-bottom: calc(var(--tab-h) + var(--mini-h) + 52px + var(--safe-b) + 40px); }
.sheet-p { margin: 0 18px 12px; font-size: 14.5px; line-height: 1.45; color: var(--text); }
.cast-remote { padding: 0 18px; }
.cast-remote .ctl { justify-content: center; gap: 28px; }
.cast-remote .ctl.small { gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.cast-remote .ctl.small .chip { display: inline-flex; align-items: center; gap: 6px; }
.cast-remote .ctl.small svg { width: 16px; height: 16px; fill: currentColor; }
.cast-remote select.chip { border: 0; appearance: none; -webkit-appearance: none; }
.cast-remote .btn { width: calc(100% - 32px); }
.btns .castbtn svg { width: 18px; height: 18px; }
