:root { --bg: #0f0f0f; --panel: #1c1c1c; --line: #2a2a2a; --text: #f1f1f1; --muted: #aaa; --plex: #e5a00d; --yt: #ff0033; --r: 12px; color-scheme: dark; }
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.pad { padding: 24px; }
.spacer { flex: 1; }

.btn { display: inline-flex; align-items: center; gap: 6px; border: 0; border-radius: 999px; padding: 9px 18px; background: #272727; cursor: pointer; font-weight: 600; white-space: nowrap; }
.btn:hover { background: #3a3a3a; }
.btn.primary { background: var(--text); color: #0f0f0f; }
.btn.primary:hover { background: #d9d9d9; }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.iconbtn { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; border: 0; background: transparent; cursor: pointer; color: var(--text); }
.iconbtn:hover { background: rgba(255,255,255,.1); }

.center { min-height: 100vh; display: grid; place-items: center; }
.login { display: grid; gap: 14px; width: min(340px, 90vw); text-align: center; justify-items: center; }
.login h1 { margin: 0 0 8px; }
.login input { width: 100%; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); }
.login .btn { width: 100%; justify-content: center; }
.msg { color: #ff6b6b; min-height: 1.4em; }

.loading { display: flex; gap: 12px; align-items: center; justify-content: center; padding: 60px; color: var(--muted); }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid rgba(255,255,255,.2); border-top-color: #fff; animation: spin 0.9s linear infinite; }
.spinner.big { position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px; border-width: 4px; pointer-events: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.error { margin: 40px auto; max-width: 600px; padding: 16px; border-radius: var(--r); background: #3a1414; color: #ffb4b4; }

.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 12px; height: 56px; padding: 0 16px; background: rgba(15,15,15,.95); backdrop-filter: blur(10px); }
.brand { font-size: 20px; font-weight: 700; }
.search { display: flex; align-items: center; flex: 0 1 560px; margin-left: 12px; background: #121212; border: 1px solid #303030; border-radius: 999px; padding-left: 16px; }
.search input { flex: 1; min-width: 0; border: 0; background: transparent; outline: none; padding: 8px 0; }
.search .iconbtn { width: 56px; border-radius: 0 999px 999px 0; background: #222; height: 38px; }

/* apps */
.apps { padding: 32px 24px; max-width: 1100px; margin: 0 auto; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 20px; }
.tile { aspect-ratio: 16/9; border-radius: 18px; padding: 22px; display: flex; flex-direction: column; justify-content: flex-end; transition: transform .15s; }
.tile:hover { transform: scale(1.03); }
.tile.plex { background: linear-gradient(135deg, #282a2d, #1f2326); border: 2px solid var(--plex); }
.tile.plex .tile-logo { color: var(--plex); }
.tile.yt { background: linear-gradient(135deg, #ff0033, #a3001f); }
.tile.netflix { background: linear-gradient(135deg, #141414, #000); border: 2px solid #e50914; }
.tile.netflix .tile-logo { color: #e50914; }
.tile.crunchyroll { background: linear-gradient(135deg, #f47521, #b8480a); }
.tile.spotify { background: linear-gradient(135deg, #1db954, #0f6b30); }
.tile-logo { font-size: 34px; font-weight: 900; letter-spacing: 1px; }
.tile.spotify .tile-logo, .tile.crunchyroll .tile-logo { letter-spacing: 0; }
.tile-sub { opacity: .8; }

/* plex */
.plexlogo { color: var(--plex); font-weight: 900; letter-spacing: 2px; font-size: 22px; }
main.plex { padding: 8px 24px 40px; position: relative; }
.row { margin: 18px 0 28px; }
.row h3 { margin: 0 0 10px; font-size: 18px; }
.scroller { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 8px; scroll-snap-type: x proximity; }
.scroller .poster { flex: 0 0 150px; scroll-snap-align: start; }
.scroller .poster.wide { flex-basis: 300px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 18px 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 7px 14px; border-radius: 999px; background: #272727; }
.chip:hover { background: #3a3a3a; }
.poster .pimg, .pimg { position: relative; aspect-ratio: 2/3; border-radius: 8px; overflow: hidden; background: #222; }
.poster.wide .pimg, .pimg.wide { aspect-ratio: 16/9; }
.pimg img { width: 100%; height: 100%; object-fit: cover; display: block; }
.poster:hover .pimg { outline: 3px solid var(--plex); }
.pbar { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(0,0,0,.6); }
.pbar div { height: 100%; background: var(--plex); }
.badge { position: absolute; top: 6px; right: 6px; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: var(--plex); color: #000; font-size: 12px; font-weight: 800; display: grid; place-items: center; }
.badge.done { background: rgba(0,0,0,.7); color: var(--plex); }
.ptitle { margin-top: 6px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.psub { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.libhead { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.libhead select { background: #272727; border: 0; border-radius: 8px; padding: 8px 10px; }
.item .backdrop { position: absolute; inset: 0 0 auto 0; height: 520px; background-size: cover; background-position: center top; opacity: .28; mask-image: linear-gradient(#000 40%, transparent); -webkit-mask-image: linear-gradient(#000 40%, transparent); }
.itemhead { position: relative; display: flex; gap: 28px; padding: 30px 0; }
.bigposter { width: 240px; border-radius: 10px; align-self: flex-start; box-shadow: 0 10px 40px rgba(0,0,0,.6); }
.iteminfo h1 { margin: 6px 0 8px; font-size: 32px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 18px 0; }
.actions .btn.primary { background: var(--plex); color: #000; }
.summary { max-width: 760px; color: #ddd; }
.summary.small { font-size: 13px; color: var(--muted); margin: 4px 0 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.episodes { position: relative; display: grid; gap: 14px; }
.episode { display: grid; grid-template-columns: 260px 1fr; gap: 16px; padding: 8px; border-radius: 10px; }
.episode:hover { background: #1c1c1c; }
@media (max-width: 700px) { .itemhead { flex-direction: column; } .bigposter { width: 160px; } .episode { grid-template-columns: 140px 1fr; } }

/* youtube */
.ytlogo { display: flex; align-items: center; gap: 4px; font-weight: 700; font-size: 19px; letter-spacing: -0.5px; }
.ytplay { background: var(--yt); color: #fff; border-radius: 7px; font-size: 11px; padding: 3px 7px; }
.ytlayout { display: flex; }
.ytside { position: sticky; top: 56px; align-self: flex-start; display: flex; flex-direction: column; width: 220px; padding: 12px; flex: 0 0 auto; }
.ytside hr { border: 0; border-top: 1px solid var(--line); margin: 12px 0; }
.side { display: flex; align-items: center; gap: 22px; padding: 9px 12px; border-radius: 10px; }
.side:hover { background: #272727; }
.side.on { background: #272727; font-weight: 600; }
.ytmain { flex: 1; padding: 16px 24px 40px; min-width: 0; }
.ytgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr)); gap: 36px 16px; }
.ytcard { display: block; }
.ytthumb { position: relative; aspect-ratio: 16/9; border-radius: var(--r); overflow: hidden; background: #222; }
.ytthumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ytcard:hover .ytthumb { border-radius: 0; transition: border-radius .2s; }
.dur { position: absolute; right: 6px; bottom: 6px; background: rgba(0,0,0,.8); font-size: 12px; font-weight: 600; padding: 1px 5px; border-radius: 4px; }
.dur.live { background: var(--yt); }
.ytprog { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(255,255,255,.3); }
.ytprog div { height: 100%; background: var(--yt); }
.ytmeta { display: flex; gap: 12px; margin-top: 12px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; flex: 0 0 36px; background: #333; }
.yttitle { font-weight: 600; font-size: 16px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ytsub { color: var(--muted); font-size: 14px; }
.signin-card { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 20px; margin-bottom: 24px; border: 1px solid var(--line); border-radius: var(--r); }
.signin { padding: 16px 24px; }
.signin-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; }
.signin-head h2 { margin: 0; }
.signin-frame { width: 100%; height: calc(100vh - 200px); min-height: 500px; border: 1px solid var(--line); border-radius: var(--r); margin-top: 12px; background: #000; }
/* like YouTube: full sidebar on wide screens, slim icon column on medium ones (or when ☰ is pressed), bottom bar on phones */
.ytlayout.mini .ytside { width: 76px; padding: 4px; }
.ytlayout.mini .side { flex-direction: column; gap: 6px; padding: 14px 0; font-size: 10px; text-align: center; }
.ytlayout.mini .ytside hr { display: none; }
@media (max-width: 1300px) {
  .ytside { width: 76px; padding: 4px; }
  .side { flex-direction: column; gap: 6px; padding: 14px 0; font-size: 10px; text-align: center; }
  .ytside hr { display: none; }
  .ytmain { padding: 16px; }
}
@media (max-width: 700px) {
  .ytside { position: fixed; top: auto; bottom: 0; left: 0; right: 0; z-index: 20; width: auto !important; flex-direction: row; justify-content: space-around;
    padding: 2px 4px calc(2px + env(safe-area-inset-bottom)) !important; background: rgba(15,15,15,.97); border-top: 1px solid var(--line); }
  .side { flex: 1; padding: 6px 0 !important; }
  .side.on { background: transparent; color: #fff; }
  .side:not(.on) { color: #bbb; }
  .ytmain { padding: 12px 12px 80px; }
  .topbar.yt .ytlogo { font-size: 0; }
  .topbar.yt .ytlogo .ytplay { font-size: 11px; }
  .search { margin-left: 4px; }
}

/* player */
body.watching { background: #000; }
.watch { min-height: 100vh; }
.playerwrap { position: relative; background: #000; width: 100%; height: 100vh; overflow: hidden; user-select: none; -webkit-user-select: none; }
body.ytwatch .playerwrap { height: min(100vh - 120px, 56.25vw); }
.playerwrap:fullscreen, .playerwrap:-webkit-full-screen { height: 100vh !important; }
.screen { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; display: block; cursor: pointer; }
.ptop { position: absolute; left: 0; right: 0; top: 0; display: flex; gap: 10px; align-items: center; padding: 14px 16px 40px; background: linear-gradient(rgba(0,0,0,.7), transparent); }
.ptitle2 { font-size: 18px; font-weight: 600; }
.psub2 { color: #ccc; font-size: 14px; }
.controls { position: absolute; left: 0; right: 0; bottom: 0; padding: 40px 14px 6px; background: linear-gradient(transparent, rgba(0,0,0,.8)); }
.ptop, .controls { opacity: 0; transition: opacity .25s; }
.playerwrap.show .ptop, .playerwrap.show .controls, .playerwrap.paused .ptop, .playerwrap.paused .controls { opacity: 1; }
.playerwrap:not(.show):not(.paused) { cursor: none; }
.seekbar { position: relative; height: 18px; cursor: pointer; display: flex; align-items: center; }
.track { position: relative; width: 100%; height: 4px; background: rgba(255,255,255,.25); transition: height .1s; }
.seekbar:hover .track { height: 6px; }
.buffered, .played { position: absolute; left: 0; top: 0; bottom: 0; }
.buffered { background: rgba(255,255,255,.4); }
.played { background: var(--accent, var(--plex)); }
body.ytwatch .played, body.ytwatch .knob { --accent: var(--yt); }
.knob { position: absolute; top: 50%; width: 14px; height: 14px; margin: -7px; border-radius: 50%; background: var(--accent, var(--plex)); transform: scale(0); transition: transform .1s; }
.seekbar:hover .knob { transform: scale(1); }
.hovert { position: absolute; bottom: 22px; transform: translateX(-50%); background: rgba(0,0,0,.85); padding: 3px 7px; border-radius: 4px; font-size: 12px; }
.cbuttons { display: flex; align-items: center; gap: 4px; }
.time { margin-left: 8px; font-variant-numeric: tabular-nums; font-size: 14px; }
.vol { width: 80px; accent-color: #fff; }
.menu { position: absolute; right: 14px; bottom: 64px; min-width: 220px; max-height: 60%; overflow: auto; background: rgba(28,28,28,.95); border-radius: 12px; padding: 8px 0; }
.mhead { padding: 8px 16px 4px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.mitem { display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: 8px 16px 8px 34px; cursor: pointer; position: relative; }
.mitem:hover { background: rgba(255,255,255,.1); }
.mitem.on::before { content: "✓"; position: absolute; left: 12px; }
.stats { position: absolute; left: 14px; top: 70px; margin: 0; padding: 10px 14px; background: rgba(0,0,0,.75); border-radius: 8px; font: 12px/1.5 ui-monospace, Menlo, monospace; pointer-events: none; }
.perror { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); max-width: 80%; background: rgba(60,10,10,.9); padding: 14px 18px; border-radius: 10px; }
.ytbelow { display: grid; grid-template-columns: 1fr 400px; gap: 24px; padding: 16px 24px 40px; background: var(--bg); }
.ytinfo h1 { font-size: 20px; margin: 0 0 12px; }
.chan { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; }
.desc { background: #272727; border-radius: 12px; padding: 12px; white-space: pre-wrap; cursor: pointer; font-size: 14px; }
.desc.collapsed div { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.ytrelated { display: grid; gap: 10px; align-content: start; }
.ytrelated .ytcard { display: grid; grid-template-columns: 168px 1fr; gap: 8px; }
.ytrelated .ytthumb { border-radius: 8px; }
.ytrelated .ytmeta { margin: 0; }
.ytrelated .avatar { display: none; }
.ytrelated .yttitle { font-size: 14px; }
.ytrelated .ytsub { font-size: 12px; }
@media (max-width: 1000px) { .ytbelow { grid-template-columns: 1fr; padding: 12px; } body.ytwatch .playerwrap { height: 56.25vw; } }

/* Netflix window */
body.remote { overflow: hidden; background: #000; }
.remote-wrap { position: fixed; inset: 0; background: #000; }
.remote-frame { width: 100%; height: 100%; border: 0; display: block; }
.remote-tools { position: absolute; top: 50%; left: 0; transform: translateY(-50%); display: flex; flex-direction: column; gap: 4px; padding: 6px;
  background: rgba(20,20,20,.75); border-radius: 0 12px 12px 0; opacity: .25; transition: opacity .2s; }
.remote-tools:hover { opacity: 1; }
