:root{
  --bg:#101010;
  --panel:#181818;
  --panel2:#1f1f1f;
  --accent:#4285F4;
  --text:#ffffff;
  --muted:#d3d3d3;
  --danger:#ff4d4d;
  --safe-top: env(safe-area-inset-top);
  --safe-bottom: env(safe-area-inset-bottom);
}

/* When launched from iOS Home Screen, hide the marketing header/footer for an app feel */
body.standalone .site-header,
body.standalone .site-footer {
  display: none;
}

.watch-shell{
  background: var(--bg);
  color: var(--text);
  min-height: calc(100vh - 80px);
}

body.standalone .watch-shell{ min-height: 100vh; }

.watch-appbar{
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(16,16,16,0.92);
  backdrop-filter: blur(10px);
  padding: calc(10px + var(--safe-top)) 12px 10px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.watch-appbar-inner{
  display:flex;
  align-items:center;
  gap:10px;
}

.watch-brand{
  display:flex;
  align-items:center;
  gap:10px;
}

.watch-brand img{
  width: 34px;
  height: 34px;
  border-radius: 10px;
}

.watch-title{ font-size: 16px; font-weight: 900; letter-spacing: .2px; }
.watch-subtitle{ font-size: 12px; color: var(--muted); margin-top: 2px; }
.watch-grow{ flex: 1; }

.watch-search{
  display:flex;
  align-items:center;
  gap:8px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  padding: 8px 10px;
  max-width: 520px;
  flex: 1;
}

.watch-search input{
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  width: 100%;
  font-size: 14px;
}

.watch-tabs{
  display:flex;
  gap:8px;
  margin-top: 10px;
}

.watch-tab{
  flex: 1;
  text-align:center;
  padding: 10px 8px;
  border-radius: 14px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  color: var(--muted);
  font-weight: 900;
  cursor: pointer;
  user-select:none;
}

.watch-tab.active{
  background: rgba(66,133,244,0.18);
  border-color: rgba(66,133,244,0.35);
  color: #fff;
}

/* Main browse layout (Tubi-ish: full width, chips + poster grid) */
.watch-main{
  display:block;
  min-height: calc(100vh - 140px);
}

body.standalone .watch-main{
  min-height: calc(100vh - 118px);
}

.watch-content{
  padding: 14px;
}

.watch-meta{
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.watch-meta .chip{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.category-bar{
  display:flex;
  gap: 10px;
  overflow-x: auto;
  padding: 6px 2px 12px;
  margin-bottom: 6px;
  -webkit-overflow-scrolling: touch;
}

.category-bar::-webkit-scrollbar{ height: 6px; }
.category-bar::-webkit-scrollbar-thumb{ background: rgba(255,255,255,0.12); border-radius: 999px; }

.watch-cat{
  flex: 0 0 auto;
  padding: 8px 12px;
  border-radius: 999px;
  cursor: pointer;
  color: var(--muted);
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(255,255,255,0.04);
  font-weight: 900;
  font-size: 12px;
}

.watch-cat.active{
  background: rgba(66,133,244,0.18);
  border-color: rgba(66,133,244,0.40);
  color: #fff;
}

.watch-grid{
  display:grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  padding-bottom: calc(18px + var(--safe-bottom));
}

/* Poster cards */
.watch-card{
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 18px;
  overflow:hidden;
  cursor:pointer;
  position:relative;
}

.watch-thumb{
  width:100%;
  background: #0c0c0c;
  display:flex;
  align-items:center;
  justify-content:center;
  overflow:hidden;
}

/* Default to poster style */
body[data-tab="movie"] .watch-thumb,
body[data-tab="series"] .watch-thumb{
  height: 220px;
}

body[data-tab="live"] .watch-thumb{
  height: 96px;
}

.watch-thumb img{
  width: 100%;
  height: 100%;
  object-fit: cover;
}

body[data-tab="live"] .watch-thumb img{
  width: 78%;
  height: 78%;
  object-fit: contain;
}

.watch-card .title{
  padding: 10px 10px 12px;
  font-size: 13px;
  font-weight: 900;
  line-height: 1.2;
}

.watch-card .sub{
  padding: 0 10px 12px;
  margin-top: -8px;
  color: var(--muted);
  font-size: 12px;
}

/* Play overlay (movies/series) */
body[data-tab="movie"] .watch-card::before,
body[data-tab="series"] .watch-card::before{
  content: "";
  position:absolute;
  inset:0;
  background: radial-gradient(circle at 40% 40%, rgba(255,255,255,0.06), rgba(0,0,0,0.0) 55%),
              linear-gradient(to top, rgba(0,0,0,0.55), rgba(0,0,0,0.0) 60%);
  opacity: 0;
  transition: opacity 140ms ease;
  pointer-events:none;
}

body[data-tab="movie"] .watch-card:hover::before,
body[data-tab="series"] .watch-card:hover::before{ opacity: 1; }

.fav-btn{
  position:absolute;
  top:8px;
  right:8px;
  width: 34px;
  height: 34px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(0,0,0,0.35);
  color: #fff;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size: 16px;
}

.fav-btn.active{
  border-color: rgba(66,133,244,0.55);
  background: rgba(66,133,244,0.25);
}

/* Player + Series pages (no modals) */
.player-view,
.series-view{
  padding: 12px 14px calc(16px + var(--safe-bottom));
}

.player-top{
  display:flex;
  align-items:center;
  gap: 12px;
  padding: calc(8px + var(--safe-top)) 0 10px;
}

.back-btn{
  border: none;
  background: rgba(255,255,255,0.08);
  color: #fff;
  padding: 10px 12px;
  border-radius: 14px;
  font-weight: 900;
  cursor:pointer;
}

.player-title{
  font-weight: 900;
  font-size: 14px;
  overflow:hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-wrap{
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 18px;
  overflow:hidden;
}

.player-wrap video{
  width: 100%;
  height: auto;
  max-height: 70vh;
  background: #000;
}

.player-hint{
  padding: 12px;
}

.hint-title{ font-weight: 900; margin-bottom: 6px; }
.hint-sub{ color: var(--muted); font-size: 12px; line-height: 1.4; margin-bottom: 10px; }

.episodes{
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 18px;
  overflow:hidden;
}

.episode-row{
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,0.08);
  cursor:pointer;
}

.episode-row:first-child{ border-top:none; }
.episode-row:hover{ background: rgba(255,255,255,0.03); }
.episode-row .t{ font-weight: 900; }
.episode-row .s{ color: var(--muted); font-size: 12px; margin-top: 3px; }

/* Settings */
.settings{
  max-width: 520px;
  margin: 0 auto;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 18px;
  padding: 14px;
}

.settings h2{ margin: 0 0 10px; font-size: 18px; }

.field{ margin: 10px 0; }
.field label{ display:block; color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.field input{
  width: 100%;
  background: rgba(0,0,0,0.25);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 14px;
  padding: 10px 12px;
  color: #fff;
  outline:none;
}

.actions{ display:flex; gap:10px; margin-top: 12px; }

.btn{
  border:none;
  border-radius: 14px;
  padding: 10px 12px;
  font-weight: 900;
  cursor:pointer;
}

.btn.primary{ background: var(--accent); color:#fff; }
.btn.ghost{ background: rgba(255,255,255,0.08); color:#fff; }

.note{ margin-top: 10px; color: var(--muted); font-size: 12px; line-height: 1.4; }

@media (max-width: 560px){
  .watch-grid{ grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
  body[data-tab="movie"] .watch-thumb,
  body[data-tab="series"] .watch-thumb{ height: 200px; }
}
