/* ============================================================================
 * DramaStar — visual layer
 *
 * Loaded after the original stylesheets so it can retheme the shell without
 * touching the business code. Page-specific blocks live under ds* class names;
 * the player/series/search pages keep their original DOM and are rethemed by
 * the shared tokens below.
 * ========================================================================== */

:root {
  --bg: #0b0e12;
  --panel: #171b22;
  --panel2: #1f242d;
  --text: #ffffff;
  --muted: #949ba8;
  --accent: #ff5265;
  --accent2: #ff5265;
  --line: rgba(255, 255, 255, .08);
  --radius: 12px;
  --ds-page: 1360px;
  --ds-gutter: 24px;
}

html, body { background: var(--bg); }
body { color: var(--text); }

.app {
  background: var(--bg);
}

/* ---------------------------------------------------------------- topbar */

.topbar {
  height: 76px;
  padding: 0 max(var(--ds-gutter), calc((100vw - var(--ds-page)) / 2));
  gap: 22px;
  border-bottom: 1px solid rgba(255, 255, 255, .06);
  background: rgba(11, 14, 18, .92);
  backdrop-filter: blur(18px);
}

.brand { gap: 10px; }
/* Replacement horizontal logo (symbol + wordmark in one PNG). Sized by height
   so the 5:1 aspect ratio holds; never stretched. */
.logoImg {
  display: block;
  height: 34px;
  width: auto;
}
.logo {
  width: 30px;
  height: 30px;
  border-radius: 0;
  background: none;
  box-shadow: none;
  color: var(--accent);
}
.brandCopy { line-height: 1; }
.brandName {
  font-size: 21px;
  font-weight: 900;
  letter-spacing: -.6px;
}
.brandSlogan { display: none; }

.topNav {
  gap: 2px;
  margin-left: 10px;
}
.navBtn {
  position: relative;
  color: var(--muted);
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 700;
  transition: color .15s, background .15s;
}
.navBtn:hover { background: rgba(255, 255, 255, .045); color: #fff; }
.navBtn.active { background: transparent; color: #fff; }
.navBtn.active::after {
  content: "";
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 3px;
  height: 2px;
  border-radius: 2px;
  background: var(--accent);
}

.toolbar { gap: 10px; }
.searchBox { position: relative; display: flex; align-items: center; }
.searchBox::before {
  content: "⌕";
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-52%);
  color: #737a87;
  font-size: 19px;
  pointer-events: none;
}
.searchInput {
  width: 280px;
  height: 40px;
  padding: 0 14px 0 37px;
  border: 1px solid rgba(255, 255, 255, .06);
  border-radius: 8px;
  background: var(--panel);
  font-size: 14px;
}
.searchInput:focus {
  width: 310px;
  border-color: rgba(255, 82, 101, .55);
}
.searchInput::placeholder { color: #737a87; }

.pill {
  height: 40px;
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, .07);
  border-radius: 8px;
  background: var(--panel);
  color: #dfe3e9;
  font-size: 13px;
  font-weight: 700;
}
.pill:hover { background: var(--panel2); }
.langBtn::before {
  content: "◎";
  margin-right: 6px;
  color: var(--muted);
  font-size: 14px;
}
.mobileSearchBtn { display: none; }

/* ---------------------------------------------------------------- shell */

.main { background: var(--bg); scrollbar-width: none; }
.main::-webkit-scrollbar { display: none; }
.view { padding-bottom: 0; }
.page {
  width: 100%;
  max-width: var(--ds-page);
  margin: 0 auto;
  padding: 26px var(--ds-gutter) 0;
}

/* Old surfaces inherit the new palette. */
.hero { border-radius: var(--radius); }
.heroCarousel { border-radius: var(--radius); }
.section { margin-top: 34px; }
.sectionHead h2 { font-size: 22px; font-weight: 900; letter-spacing: -.3px; }
.moreBtn { color: var(--muted); font-size: 13px; font-weight: 600; }
.moreBtn:hover { color: var(--accent); }

.card .cover { border-radius: 10px; }
.cardTitle { font-size: 14px; }
.cardSub { font-size: 12px; }

.sideList, .sideCard, .historyRow, .episodeCard, .genreTile {
  background: var(--panel);
  border-color: var(--line);
  border-radius: 10px;
}

.btn { border-radius: 8px; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: #ff6b7c; }
.cta { border-radius: 8px; background: var(--accent); }
.cta:hover { background: #ff6b7c; }

.siteFooter {
  max-width: var(--ds-page);
  margin: 56px auto 0;
  padding: 30px 0 44px;
  border-top: 1px solid var(--line);
  color: var(--muted);
}

/* ---------------------------------------------------------------- home shell */

.dsHomePage { padding-top: 24px; }
.dsHome { display: flex; flex-direction: column; gap: 38px; }
.dsSection { display: flex; flex-direction: column; gap: 16px; }
.dsSectionHead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.dsSectionHead h2 {
  font-size: 24px;
  font-weight: 900;
  letter-spacing: -.4px;
}
.dsMore {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.dsMore:hover { color: var(--accent); }

/* ---------------------------------------------------------------- hero banner */

.dsHero {
  position: relative;
  height: 462px;
  border-radius: 12px;
  overflow: hidden;
  background: var(--panel);
  isolation: isolate;
}
.dsHeroSlide {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity .5s ease;
}
.dsHeroSlide.active { opacity: 1; pointer-events: auto; }
.dsHeroImage,
.dsHeroFallback {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 24%;
}
.dsHeroFallback {
  background: linear-gradient(135deg, #3a1620, #171b22 55%, #0b0e12);
}
.dsHeroShade {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, #0b0e12 0%, rgba(11, 14, 18, .94) 30%, rgba(11, 14, 18, .35) 62%, rgba(11, 14, 18, .15) 100%),
    linear-gradient(0deg, #0b0e12 0%, rgba(11, 14, 18, 0) 42%);
}
.dsHeroContent {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  justify-content: center;
  height: 100%;
  max-width: 620px;
  padding: 44px 56px;
}
.dsHeroKicker {
  display: inline-flex;
  align-items: center;
  width: max-content;
  padding: 4px 10px;
  border-radius: 4px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .5px;
}
.dsHeroTitle {
  margin: 16px 0 14px;
  font-size: clamp(32px, 3.5vw, 50px);
  font-weight: 900;
  line-height: 1.04;
  letter-spacing: -1px;
  text-shadow: 0 2px 18px rgba(0, 0, 0, .45);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.dsHeroMeta { display: flex; flex-wrap: wrap; gap: 8px; }
.dsHeroMeta span {
  padding: 5px 10px;
  border-radius: 4px;
  background: rgba(255, 255, 255, .1);
  color: #dfe3e9;
  font-size: 12px;
  font-weight: 600;
}
.dsHeroSynopsis {
  max-width: 530px;
  margin: 18px 0 24px;
  color: #c5cad3;
  font-size: 14px;
  line-height: 1.7;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.dsHeroActions { display: flex; gap: 12px; align-items: center; }
.dsBtn {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 44px;
  padding: 0 24px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 800;
  transition: background .15s, transform .15s;
}
.dsBtn:hover { transform: translateY(-1px); }
.dsBtnPrimary { background: var(--accent); color: #fff; }
.dsBtnPrimary:hover { background: #ff6b7c; }
.dsBtnGhost { background: rgba(255, 255, 255, .12); color: #fff; }
.dsBtnGhost:hover { background: rgba(255, 255, 255, .18); }
.dsPlayGlyph { font-size: 11px; }

.dsHeroArrow {
  position: absolute;
  top: 50%;
  z-index: 4;
  width: 42px;
  height: 42px;
  margin-top: -21px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .14);
  background: rgba(0, 0, 0, .35);
  color: #fff;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background .15s;
}
.dsHeroArrow:hover { background: rgba(0, 0, 0, .62); }
.dsHeroArrow.prev { left: 18px; }
.dsHeroArrow.next { right: 18px; }

.dsHeroDots {
  position: absolute;
  right: 30px;
  bottom: 22px;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 7px;
}
.dsHeroDot {
  width: 7px;
  height: 7px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, .34);
  cursor: pointer;
  transition: width .2s, background .2s;
}
.dsHeroDot.active { width: 22px; background: var(--accent); }

/* ---------------------------------------------------------------- continue */

.dsContinueGrid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}
.dsContinueCard { display: block; min-width: 0; }
.dsContinueThumb {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: 8px;
  overflow: hidden;
  background: var(--panel);
}
.dsContinueThumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 28%;
  transition: transform .3s;
}
.dsContinueCard:hover .dsContinueThumb img { transform: scale(1.035); }
.dsContinueFallback { position: absolute; inset: 0; background: linear-gradient(135deg, #3a1620, #171b22); }
.dsContinuePlay {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 46px;
  height: 46px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: rgba(0, 0, 0, .48);
  border: 1px solid rgba(255, 255, 255, .25);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 15px;
  padding-left: 3px;
  backdrop-filter: blur(4px);
}
.dsContinueProgress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: rgba(255, 255, 255, .22);
}
.dsContinueProgress i {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
}
.dsContinueTitle {
  margin-top: 10px;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dsContinueMeta { margin-top: 4px; color: var(--muted); font-size: 12px; }

/* ---------------------------------------------------------------- poster grid */

.dsPosterGrid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 18px;
}
.dsPosterCard { display: block; min-width: 0; }
.dsPoster {
  position: relative;
  aspect-ratio: 2 / 3;
  border-radius: 10px;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, .04);
}
.dsPoster img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .35s ease;
}
.dsPosterCard:hover .dsPoster img { transform: scale(1.045); }
.dsPosterCard:hover .dsPoster { border-color: rgba(255, 82, 101, .45); }
.dsPosterFallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  padding: 14px;
  background: linear-gradient(150deg, #3a1620, #171b22 60%, #0b0e12);
  font-weight: 800;
  font-size: 15px;
  line-height: 1.3;
}
.dsPosterMarks {
  position: absolute;
  left: 8px;
  right: 8px;
  top: 8px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 6px;
  pointer-events: none;
}
.dsPosterBadge {
  padding: 3px 8px;
  border-radius: 4px;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .4px;
}
.dsPosterRating {
  margin-left: auto;
  padding: 3px 7px;
  border-radius: 4px;
  background: rgba(0, 0, 0, .68);
  color: #ffcf5c;
  font-size: 10px;
  font-weight: 800;
  backdrop-filter: blur(4px);
}
.dsPosterTitle {
  margin-top: 10px;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.7em;
}
.dsPosterMeta {
  display: flex;
  gap: 10px;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}
.dsPosterViews { color: #aeb5c0; }

/* ---------------------------------------------------------------- genre rail (H5 only) */

.dsGenreRail { display: none; }
.dsGenreItem {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 52px;
  flex: 0 0 auto;
}
.dsGenreIcon {
  width: 42px;
  height: 42px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  font-size: 20px;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(145deg, #ff5265, #9e2334);
}
.dsGenreIcon.c1 { background: linear-gradient(145deg, #ff9752, #a94b17); }
.dsGenreIcon.c2 { background: linear-gradient(145deg, #42a5ff, #1a5f9e); }
.dsGenreIcon.c3 { background: linear-gradient(145deg, #8b6bff, #4930a5); }
.dsGenreIcon.c4 { background: linear-gradient(145deg, #ff6fae, #a32b66); }
.dsGenreIcon.c5 { background: linear-gradient(145deg, #35d0a0, #137a5d); }
/* Drawn category tiles carry their own gradient + rounded corners inside the
   SVG. No background here, or the glyph would sit on a second colored tile. */
.dsGenreIconImg {
  width: 48px;
  height: 48px;
  display: block;
}
.dsGenreName {
  width: 52px;
  max-height: 2.4em;
  color: #c7ccd5;
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* ---------------------------------------------------------------- search */

.dsSearchPage { padding-top: 26px; }
.dsSearchTitle {
  margin-bottom: 18px;
  font-size: 28px;
  font-weight: 900;
  letter-spacing: -.5px;
}
.dsSearchBar {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 760px;
}
.dsSearchField {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1 1 auto;
  min-width: 0;
}
.dsSearchGlyph {
  position: absolute;
  left: 15px;
  top: 50%;
  transform: translateY(-52%);
  color: #737a87;
  font-size: 20px;
  pointer-events: none;
}
.dsSearchInput {
  width: 100%;
  height: 50px;
  padding: 0 44px 0 43px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: #fff;
  font-size: 15px;
  outline: none;
  transition: border-color .15s;
}
.dsSearchInput:focus { border-color: rgba(255, 82, 101, .55); }
.dsSearchInput::placeholder { color: #737a87; }
.dsSearchClear {
  position: absolute;
  right: 10px;
  width: 28px;
  height: 28px;
  display: none;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .09);
  color: #c7ccd5;
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
}
.dsSearchClear.show { display: grid; }
.dsSearchCancel {
  flex: 0 0 auto;
  padding: 8px 6px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.dsSearchCancel:hover { color: #fff; }
.dsSearchMeta {
  margin: 16px 0 18px;
  color: var(--muted);
  font-size: 13px;
}
.dsSearchGrid { margin-top: 0; }

.dsStateCard {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin: 12px 0;
  padding: 46px 24px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  text-align: center;
}
.dsStateIcon {
  margin-bottom: 4px;
  color: #5e6672;
  font-size: 42px;
  line-height: 1;
}
.dsStateCard h3 { color: #fff; font-size: 16px; font-weight: 700; }
.dsStateCard p { margin: 0; color: var(--muted); font-size: 13px; }
.dsStateQuery { color: #737a87; font-size: 12px; }

/* ---------------------------------------------------------------- category */

.dsCatPage { padding-top: 20px; }
.dsBreadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
  color: var(--muted);
  font-size: 13px;
}
.dsBreadcrumb a { color: #c9ced6; }
.dsBreadcrumb a:hover { color: var(--accent); }
.dsBreadcrumb .sep { color: #5e6672; }

.dsChipBar {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 0 6px;
  margin-bottom: 14px;
  scrollbar-width: none;
}
.dsChipBar::-webkit-scrollbar { display: none; }
.dsChip {
  flex: 0 0 auto;
  padding: 9px 19px;
  border-radius: 6px;
  background: var(--panel);
  color: #c7ccd5;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  border: 1px solid transparent;
  transition: background .15s, color .15s;
}
.dsChip:hover { background: var(--panel2); color: #fff; }
.dsChip.active { background: var(--accent); color: #fff; }

.dsSortBar {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}
.dsSortBtn {
  padding: 9px 20px;
  border-radius: 6px;
  background: var(--panel);
  color: #c7ccd5;
  font-size: 13px;
  font-weight: 700;
  transition: background .15s, color .15s;
}
.dsSortBtn:hover { background: var(--panel2); color: #fff; }
.dsSortBtn.active { background: var(--accent); color: #fff; }
.dsResultCount { margin-left: auto; color: var(--muted); font-size: 12px; }

.dsPosterGrid.dsPosterGrid4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.dsPager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 34px 0 4px;
}
.dsPageBtn {
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
  color: #d5d9e0;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.dsPageBtn:hover { background: var(--panel2); }
.dsPageBtn.active { background: var(--accent); border-color: transparent; color: #fff; }
.dsPageBtn:disabled { opacity: .35; cursor: default; }
.dsPageGap { color: var(--muted); font-size: 13px; }

.dsLoadMore {
  display: block;
  width: 100%;
  margin: 22px 0 4px;
  padding: 13px 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: #dfe3e9;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.dsLoadMore:disabled { opacity: .5; cursor: default; }

.dsSkeletonBreadcrumb { width: 150px; height: 14px; margin-bottom: 20px; }
.dsSkeletonChip { width: 76px; height: 36px; flex: 0 0 auto; }
.dsSkeletonSort { width: 72px; height: 34px; }

/* ---------------------------------------------------------------- skeleton */

.dsHomeSkeleton { gap: 24px; }
.dsSkeletonStatus {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}
.dsSkeletonStatus .spinner {
  width: 18px;
  height: 18px;
  border-width: 2px;
  border-top-color: var(--accent);
}
.skeleton {
  background: linear-gradient(90deg, #1a1f27 25%, #2b323d 50%, #1a1f27 75%);
  background-size: 200% 100%;
}
.dsSkeletonHero { height: 462px; border-radius: 12px; }
.dsSkeletonHead { width: 180px; height: 26px; margin-top: 8px; }
.dsSkeletonCard { min-width: 0; }
.dsSkeletonPoster { aspect-ratio: 2 / 3; border-radius: 10px; }
.dsSkeletonTitle { height: 14px; margin-top: 11px; width: 82%; }
.dsSkeletonMeta { height: 11px; margin-top: 7px; width: 48%; }

/* ---------------------------------------------------------------- empty */

.dsEmpty {
  padding: 70px 20px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  text-align: center;
  color: var(--muted);
}
.dsEmpty h3 { color: #fff; font-size: 18px; }


/* ---------------------------------------------------------------- episode sheet */

.sheetHandle {
  width: 38px;
  height: 4px;
  margin: -6px auto 12px;
  border-radius: 2px;
  background: rgba(255, 255, 255, .24);
}
.sheetGroups {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 0 0 12px;
  scrollbar-width: none;
}
.sheetGroups::-webkit-scrollbar { display: none; }
.sheetGroup {
  flex: 0 0 auto;
  padding: 8px 16px;
  border: 0;
  border-radius: 6px;
  background: var(--panel2);
  color: #c7ccd5;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.sheetGroup:hover { background: #2a303a; color: #fff; }
.sheetGroup.active { background: var(--accent); color: #fff; }
.episodeSheet[data-layout="mobile"] .sheetGrid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.episodeSheet[data-layout="desktop"] .sheetGrid { grid-template-columns: repeat(8, minmax(0, 1fr)); }
.episodeSheet .sheetPanel { background: #171b22; }


/* ---------------------------------------------------------------- transient states */

.offlineBanner {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(80px + env(safe-area-inset-bottom, 0px));
  z-index: 10000;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .4);
}
.dsErrorIcon {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border: 2px solid var(--accent);
  border-radius: 50%;
  color: var(--accent);
  font-size: 27px;
  font-weight: 800;
  line-height: 1;
}
.playerError { background: rgba(11, 14, 18, .95); }
.playerError h3 { font-size: 19px; }
.playerError .btn { border-radius: 6px; }
.playerError .btn.primary { background: var(--accent); color: #fff; }
.playerLoading .spinner { border-top-color: var(--accent); }



/* ---------------------------------------------------------------- history */

.historyToolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.historyCount { color: var(--muted); font-size: 12px; }
.historyTime {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 11px;
}
.historyCompleted { color: var(--accent); font-weight: 700; }
.historyNext { color: #c7ccd5; font-size: 12px; margin-top: 4px; }
.historyActions .iconBtn {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel2);
  color: #c7ccd5;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.historyActions .iconBtn:hover {
  color: #fff;
  border-color: rgba(255, 82, 101, .5);
}

/* ---------------------------------------------------------------- random play (H5) */

.randomPage {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: none;
  overflow: hidden;
  background: #000;
  color: #fff;
  touch-action: none;
  overscroll-behavior: none;
}
.randomPage.show { display: block; }
.randomPage video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  outline: none;
}
.randomPoster {
  position: absolute;
  inset: 0;
  z-index: 1;
  background-position: center;
  background-size: cover;
  filter: brightness(.72);
  transition: opacity .3s;
}
.randomPoster.hidden { opacity: 0; pointer-events: none; }
.randomGradient {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, .55) 0%, transparent 22%, transparent 55%, rgba(0, 0, 0, .9) 100%);
}
.randomBack {
  position: absolute;
  left: 14px;
  top: calc(14px + var(--safe-top));
  z-index: 20;
  width: 56px;
  height: 56px;
  font-size: 24px;
}
.randomHint {
  position: absolute;
  top: calc(24px + var(--safe-top));
  left: 50%;
  z-index: 9;
  transform: translateX(-50%);
  color: rgba(255, 255, 255, .62);
  font-size: 11px;
  white-space: nowrap;
  pointer-events: none;
  transition: opacity .5s;
}
.randomHint.fade { opacity: 0; }
.randomActions {
  position: absolute;
  right: 12px;
  bottom: calc(150px + var(--safe-bottom));
  z-index: 12;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.randomActionWrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}
.randomAction {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .16);
  background: rgba(0, 0, 0, .46);
  color: #fff;
  font: inherit;
  font-size: 18px;
  cursor: pointer;
  backdrop-filter: blur(4px);
}
.randomAction:hover { background: rgba(0, 0, 0, .7); }
.randomActionLabel { color: #e5e8ed; font-size: 10px; text-align: center; }
.randomInfo {
  position: absolute;
  left: 16px;
  right: 76px;
  bottom: calc(94px + var(--safe-bottom));
  z-index: 10;
  pointer-events: none;
}
.randomTitle {
  margin: 0 0 6px;
  color: #fff;
  font-size: 24px;
  font-weight: 900;
  line-height: 1.2;
  text-shadow: 0 2px 14px rgba(0, 0, 0, .85);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.randomEpisode {
  color: #fff;
  font-size: 13px;
  text-shadow: 0 2px 10px rgba(0, 0, 0, .85);
}
.randomProgressWrap {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 13;
  padding: 12px 14px calc(9px + var(--safe-bottom));
  background: linear-gradient(0deg, rgba(0, 0, 0, .86), transparent);
}
.randomProgressWrap .progressText {
  flex: 1 1 auto;
  margin: 0;
  padding: 0 4px;
  font-size: 11px;
}
.randomControls { margin-top: 6px; }
.randomPlayOverlay {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 16;
  width: 84px;
  height: 84px;
  padding: 0 0 0 4px;
  display: none;
  place-items: center;
  transform: translate(-50%, -50%);
  border: 1px solid rgba(255, 255, 255, .22);
  border-radius: 50%;
  background: rgba(0, 0, 0, .46);
  color: #fff;
  font-size: 30px;
  cursor: pointer;
  backdrop-filter: blur(4px);
}
.randomPlayOverlay.show { display: grid; }
.randomLoader {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 15;
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  transform: translate(-50%, -50%);
  color: #fff;
  font-size: 12px;
  text-align: center;
}
.randomLoader.show { display: flex; }
.randomLoader .spinner {
  width: 30px;
  height: 30px;
  border-top-color: var(--accent);
}
.randomUnmute {
  position: absolute;
  left: 50%;
  top: 16%;
  z-index: 17;
  display: none;
  transform: translateX(-50%);
}
.randomUnmute.show { display: inline-flex; }
.randomError {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 25;
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: min(340px, calc(100% - 40px));
  padding: 24px;
  transform: translate(-50%, -50%);
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(11, 14, 18, .96);
  text-align: center;
}
.randomError.show { display: flex; }
.randomError h2 { font-size: 18px; }
.randomError p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.randomError .btn { margin-top: 4px; }

/* ---------------------------------------------------------------- player (PC) */

.playerPage[data-layout="desktop"] {
  padding: 24px var(--ds-gutter) 60px;
}
.playerPage[data-layout="desktop"] .watchGrid {
  grid-template-columns: minmax(0, 620px) minmax(360px, 1fr);
  gap: 40px;
  max-width: var(--ds-page);
  margin: 0 auto;
  align-items: start;
}
.playerPage[data-layout="desktop"] .watchMain { min-width: 0; }
.playerPage[data-layout="desktop"] .playerFrame {
  width: 100%;
  height: min(78dvh, 860px);
  aspect-ratio: auto;
  margin: 0;
  border-radius: 12px;
  border: 1px solid var(--line);
}
.playerPage[data-layout="desktop"] .crumbs,
.playerPage[data-layout="desktop"] .epHead { display: none; }
.playerPage[data-layout="desktop"] .progressWrap { padding: 12px 16px 13px; }
.playerPage[data-layout="desktop"] .dsRelated { display: block; }

.watchSide { display: flex; flex-direction: column; gap: 0; min-width: 0; }
.dsSideTitleRow {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.dsSideTitle {
  margin: 0;
  font-size: clamp(24px, 2.3vw, 34px);
  font-weight: 900;
  line-height: 1.15;
  letter-spacing: -.6px;
}
.dsSideRating {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--accent);
  font-size: 18px;
  font-weight: 800;
  white-space: nowrap;
}
.dsSideHeart { font-size: 17px; }
.dsSideTags { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 0; }
.dsSideTag {
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--panel2);
  color: #c7ccd5;
  font-size: 12px;
  font-weight: 600;
}
a.dsSideTag:hover { border-color: var(--accent); color: #fff; }
.dsSideSynopsis {
  margin: 16px 0 0;
  color: #c5cad3;
  font-size: 14px;
  line-height: 1.7;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.dsSideSynopsis.expanded { display: block; -webkit-line-clamp: unset; }
.dsSideExpand {
  margin-top: 5px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.dsSideActions { display: flex; align-items: center; gap: 24px; margin: 18px 0 22px; }
.dsSideAction {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #c7ccd5;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.dsSideAction:hover { color: #fff; }
.dsSideActionIcon { font-size: 19px; line-height: 1; }
.dsSideEpHead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.dsSideEpHead h3 { font-size: 18px; font-weight: 800; }
.dsSideEpCurrent { color: var(--muted); font-size: 12px; }
.dsEpGroups { display: flex; gap: 8px; margin: 12px 0 14px; }
.dsEpGroup {
  flex: 1 1 0;
  padding: 9px 4px;
  border: 0;
  border-radius: 4px;
  background: var(--panel2);
  color: #c7ccd5;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.dsEpGroup:hover { background: #2a303a; color: #fff; }
.dsEpGroup.active { background: var(--accent); color: #fff; }
.dsEpGrid {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 6px;
}
.dsEpBtn {
  position: relative;
  aspect-ratio: 1;
  border: 0;
  border-radius: 4px;
  background: var(--panel2);
  color: #d5d9e0;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.dsEpBtn:hover { background: #2a303a; color: #fff; }
.dsEpBtn.active { background: var(--accent); color: #fff; }
.dsEpBtn.locked { color: #737a87; }
.dsEpBtn.locked::after {
  content: "";
  position: absolute;
  right: 3px;
  top: 3px;
  width: 13px;
  height: 13px;
  background-color: #cfd4dc;
  opacity: 1;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M7 10V8a5 5 0 0 1 10 0v2' fill='none' stroke='%23000' stroke-width='2.4' stroke-linecap='round'/%3E%3Crect x='4.5' y='10' width='15' height='11' rx='2' fill='%23000'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M7 10V8a5 5 0 0 1 10 0v2' fill='none' stroke='%23000' stroke-width='2.4' stroke-linecap='round'/%3E%3Crect x='4.5' y='10' width='15' height='11' rx='2' fill='%23000'/%3E%3C/svg%3E") center / contain no-repeat;
}
.dsEpBtn.locked:hover::after { background-color: #fff; }

.dsRelated {
  display: block;
  max-width: var(--ds-page);
  margin: 52px auto 0;
}
.dsRelated[hidden] { display: none; }
.dsRelatedHead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}
.dsRelatedHead h2 { font-size: 24px; font-weight: 900; }
.dsPosterGrid.dsRelatedGrid { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* Transport controls are shared by PC and H5. */
.dsControlRow {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}
.dsControlBtn {
  padding: 0;
  border: 0;
  background: transparent;
  color: #fff;
  font: inherit;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}
.dsControlBtn:hover { color: var(--accent); }
.playToggle { width: 20px; font-size: 15px; }
.speedBtn {
  padding: 3px 5px;
  border: 1px solid rgba(255, 255, 255, .22);
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
}
.progressWrap .progressText {
  flex: 1 1 auto;
  margin: 0;
  padding: 0 4px;
  font-size: 11px;
}
.sideActions .pickBtn {
  position: static;
  right: auto;
  bottom: auto;
  width: 48px;
  height: 48px;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(0, 0, 0, .46);
  border: 1px solid rgba(255, 255, 255, .14);
  font-size: 17px;
}
.sideActions .pickBtn:hover { background: rgba(0, 0, 0, .72); }

/* ================================================================ tablet */

@media (max-width: 1200px) and (min-width: 761px) {
  .dsPosterGrid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .dsPosterGrid.dsPosterGrid4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .dsHero { height: 420px; }
  .dsHeroContent { padding: 36px 44px; }
}

@media (max-width: 980px) and (min-width: 761px) {
  .dsPosterGrid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .dsPosterGrid.dsPosterGrid4 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .dsContinueGrid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* ================================================================ H5 */

@media (max-aspect-ratio: 4/5), (max-width: 760px) {
  :root { --ds-gutter: 14px; }

  .topbar {
    height: calc(58px + var(--safe-top));
    padding: var(--safe-top) 14px 0;
    justify-content: flex-start;
    gap: 10px;
    background: rgba(11, 14, 18, .94);
  }
  .mobileCategoryBtn { display: none !important; }
  .brand {
    position: static;
    left: auto;
    top: auto;
    transform: none;
    gap: 8px;
  }
  .logo { width: 24px; height: 24px; }
  .logoImg { height: 26px; }
  .brandName { font-size: 18px; letter-spacing: -.4px; }
  .topNav { display: none; }
  .toolbar {
    position: static;
    transform: none;
    margin-left: auto;
    gap: 8px;
  }
  .searchBox { display: none; }
  .mobileSearchBtn {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #fff;
    cursor: pointer;
  }
  .mobileSearchBtn svg { width: 21px; height: 21px; }
  .pill { height: 34px; padding: 0 10px; font-size: 12px; }
  .langBtn::before { display: none; }

  .page {
    max-width: none;
    padding: 16px var(--ds-gutter) 0;
  }
  .siteFooter { margin-top: 34px; padding: 24px 0 30px; }

  .dsHome { gap: 28px; }
  .dsHomePage { padding-top: 10px; }
  .dsSection { gap: 12px; }
  .dsSectionHead h2 { font-size: 20px; }
  .dsMore { font-size: 12px; }

  .dsHero {
    height: 376px;
    border-radius: 10px;
  }
  .dsHeroShade {
    background:
      linear-gradient(90deg, rgba(11, 14, 18, .55) 0%, rgba(11, 14, 18, .05) 55%, rgba(11, 14, 18, .3) 100%),
      linear-gradient(0deg, #0b0e12 0%, rgba(11, 14, 18, .86) 30%, rgba(11, 14, 18, 0) 62%);
  }
  .dsHeroImage, .dsHeroFallback { object-position: center 20%; }
  .dsHeroContent {
    justify-content: flex-end;
    max-width: none;
    padding: 20px 18px 42px;
  }
  .dsHeroKicker { font-size: 10px; padding: 3px 8px; }
  .dsHeroTitle {
    margin: 10px 0 10px;
    font-size: clamp(26px, 8vw, 34px);
    letter-spacing: -.6px;
  }
  .dsHeroMeta { gap: 6px; }
  .dsHeroMeta span { padding: 4px 8px; font-size: 10px; }
  .dsHeroSynopsis {
    margin: 12px 0 16px;
    font-size: 12px;
    line-height: 1.55;
    -webkit-line-clamp: 2;
  }
  .dsHeroActions { gap: 10px; }
  .dsBtn { min-height: 38px; padding: 0 18px; font-size: 13px; }
  .dsBtnGhost { display: none; }
  .dsHeroArrow {
    top: 12%;
    width: 32px;
    height: 32px;
    margin-top: 0;
    font-size: 22px;
    background: rgba(0, 0, 0, .32);
  }
  .dsHeroArrow.prev { left: 10px; }
  .dsHeroArrow.next { right: 10px; }
  .dsHeroDots { right: 16px; bottom: 16px; gap: 5px; }
  .dsHeroDot { width: 6px; height: 6px; }
  .dsHeroDot.active { width: 18px; }

  .dsGenreRail {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 0 2px 4px;
    scrollbar-width: none;
  }
  .dsGenreRail::-webkit-scrollbar { display: none; }

  .dsContinueGrid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }
  .dsContinueThumb { border-radius: 7px; }
  .dsContinuePlay { width: 36px; height: 36px; font-size: 12px; }
  .dsContinueTitle { margin-top: 8px; font-size: 13px; }
  .dsContinueMeta { font-size: 11px; }

  .dsPosterGrid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px 10px;
  }
  .dsPoster { border-radius: 8px; }
  .dsPosterTitle { margin-top: 8px; font-size: 14px; min-height: 2.7em; }
  .dsPosterMeta { margin-top: 4px; font-size: 11px; }
  .dsPosterBadge { font-size: 9px; padding: 3px 6px; }
  .dsPosterRating { font-size: 9px; padding: 3px 6px; }

  .dsSkeletonHero { height: 376px; border-radius: 10px; }

  /* ---- search ---- */
  .dsSearchPage { padding-top: 8px; }
  .dsSearchTitle { display: none; }
  .dsSearchBar { max-width: none; gap: 4px; }
  .dsSearchInput { height: 44px; font-size: 14px; padding-left: 40px; }
  .dsSearchGlyph { left: 13px; font-size: 18px; }
  .dsSearchClear { right: 8px; width: 26px; height: 26px; font-size: 16px; }
  .dsSearchCancel { font-size: 12px; padding: 6px 4px; }
  .dsSearchMeta { margin: 14px 0 12px; font-size: 12px; }
  .dsStateCard { padding: 38px 18px; }
  .dsStateIcon { font-size: 36px; }
  body:has(.dsSearchPage) .tabbar { display: none !important; }
  body:has(.dsSearchPage) .main { padding-bottom: 0; }

  /* ---- random play: page ends above the bottom navigation ---- */
  .randomPage {
    top: 0;
    left: 0;
    right: 0;
    bottom: calc(64px + var(--safe-bottom));
  }

  /* ---- player ---- */
  .playerPage[data-layout="mobile"] .backBtn {
    width: 56px;
    height: 56px;
    font-size: 24px;
  }
  .playerPage[data-layout="mobile"] .playIcon {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
  }
  .playerPage[data-layout="mobile"] .dsRelated { display: none; }
  .playerPage[data-layout="mobile"] .sideActions {
    right: 10px;
    bottom: calc(150px + var(--safe-bottom));
    gap: 12px;
  }
  .playerPage[data-layout="mobile"] .actionLabel { font-size: 10px; }
  .playerPage[data-layout="mobile"] .info {
    left: 16px;
    right: 74px;
    bottom: calc(94px + var(--safe-bottom));
  }
  .playerPage[data-layout="mobile"] .progressWrap {
    padding: 10px 14px calc(9px + var(--safe-bottom));
  }
  .dsControlRow { gap: 8px; margin-top: 6px; }
  .dsControlBtn { font-size: 13px; }
  .progressWrap .progressText { padding: 0 2px; font-size: 10px; }
  .sideActions .pickBtn { width: 44px; height: 44px; font-size: 16px; }

  /* ---- category ---- */
  .dsCatPage { padding-top: 10px; }
  .dsBreadcrumb { display: none; }
  .dsChipBar {
    gap: 7px;
    margin-bottom: 12px;
    -webkit-mask-image: linear-gradient(90deg, #000 92%, transparent);
    mask-image: linear-gradient(90deg, #000 92%, transparent);
  }
  .dsChip { padding: 8px 14px; font-size: 13px; }
  .dsSortBar { gap: 8px; margin-bottom: 16px; }
  .dsSortBtn { padding: 8px 16px; font-size: 12px; }
  .dsResultCount { display: none; }
  .dsPosterGrid.dsPosterGrid4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dsPager { display: none; }
  .dsLoadMore { margin-top: 18px; }

  /* Three tabs, matching the H5 reference. */
  .main { padding-bottom: calc(66px + var(--safe-bottom)); }
  .tabbar {
    grid-template-columns: repeat(4, 1fr);
    background: rgba(11, 14, 18, .97);
    border-top: 1px solid rgba(255, 255, 255, .07);
    padding-bottom: var(--safe-bottom);
  }
  .tabItem { gap: 3px; padding: 7px 0 6px; color: #7e8794; }
  .tabItem.active { color: #fff; }
  .tabIcon {
    display: grid;
    place-items: center;
    width: 34px;
    height: 30px;
    border-radius: 9px;
    background: transparent;
    color: inherit;
    font-size: 0;
    transition: background .15s, color .15s;
  }
  .tabItem.active .tabIcon { background: #ff4963; color: #fff; }
  .tabItem.active .tabLabel { color: #fff; font-weight: 800; }
  .tabIcon svg { width: 21px; height: 21px; display: block; }
  .tabLabel { font-size: 9.5px; font-weight: 700; white-space: nowrap; }
}
