/* ============================================================
   HiTV Mobile Web — Dark Theme CSS
   ============================================================ */

/* --- Reset & Base --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  /* The site already paints a dark theme. Prevent WebView auto-darkening
     from turning the yellow remote focus outline into dark brown. */
  color-scheme: dark;
  --bg: #0d0d12;
  --bg-card: #1a1a24;
  --bg-surface: #151520;
  --bg-elevated: #222230;
  --accent: #e91e8c;
  --accent-dim: rgba(233, 30, 140, 0.2);
  --accent-dark: #c01870;
  --text-primary: #ffffff;
  --text-secondary: #aaaaaa;
  --text-muted: #666680;
  --border: rgba(255,255,255,0.08);
  --shadow: 0 4px 24px rgba(0,0,0,0.5);
  --radius: 10px;
  --radius-sm: 6px;
  --nav-height: 54px;
  --topbar-height: 52px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  font-size: 16px;
}

html {
  height: 100%;
  /* Match the nav bar colour so any sub-viewport gap at the physical
     screen bottom (iOS safe-area quirk in standalone mode) is invisible */
  background: var(--bg-surface);
  touch-action: manipulation;
}

body {
  height: 100%;
  overflow: hidden; /* only .page-container scrolls, not the body */
  background: var(--bg);
  color: var(--text-primary);
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  touch-action: manipulation;
}

button {
  cursor: pointer;
  background: none;
  border: none;
  color: inherit;
  font: inherit;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

/* Prevent SVG children from capturing pointer/click events on LG WebOS and older browsers */
button svg,
a svg,
[role="button"] svg {
  pointer-events: none;
}

/* Prevent iOS from auto-zooming when focusing an input (requires font-size >= 16px) */
input, textarea, select {
  font-size: 16px;
}

img {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
  text-decoration: none;
}

/* ============================================================
   App Layout
   ============================================================ */

#app {
  display: flex;
  flex-direction: column;
  /* 100svh = "small viewport height" — always the height when browser chrome
     is fully visible. Fixes Safari's large-viewport gap without affecting
     Chrome or standalone mode (where svh = dvh = full screen height).
     Browsers that don't parse svh (Chrome <108/Safari <15.4 — common on
     low-end devices and TV browsers like LG WebOS's older Chromium) drop the
     declaration entirely, leaving #app with no height at all; since body has
     overflow:hidden and only .page-container is meant to scroll, that made
     anything below the fold (e.g. the episode grid) silently unreachable.
     The 100vh line is a real fallback via cascade, not a duplicate. */
  height: 100vh;
  height: 100svh;
  max-width: 480px;
  margin: 0 auto;
  overflow: hidden;
  background: var(--bg);
}

.page-container {
  flex: 1;
  min-height: 0; /* required for flex children to scroll correctly */
  overflow-y: auto;
  overflow-x: hidden;
  padding-bottom: 8px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

/* ============================================================
   Bottom Navigation
   ============================================================ */

.bottom-nav {
  /* Flex child — sits naturally at the bottom of #app (which = 100% viewport).
     No position:fixed means no iOS viewport-height bugs. */
  flex-shrink: 0;
  width: 100%;
  height: var(--nav-height);
  padding-bottom: 0;
  display: flex;
  align-items: center;
  justify-content: space-around;
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  z-index: 100;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

/* In standalone (home-screen) mode the browser chrome is gone and the home
   indicator sits directly over the nav — extend height to cover it. */
@media (display-mode: standalone) {
  .bottom-nav {
    height: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
}

.bottom-nav__btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 4px;
  color: var(--text-muted);
  transition: color 0.2s;
}

.bottom-nav__btn--active {
  color: var(--accent);
}

/* TV remote / keyboard focus indicator — see .drama-card:focus-visible */
.bottom-nav__btn:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: -3px;
}

.bottom-nav__btn:focus:not(:focus-visible) {
  outline: none;
}

.bottom-nav__btn--active .bottom-nav__icon svg {
  stroke: var(--accent);
}

.bottom-nav__icon {
  display: flex;
  align-items: center;
  justify-content: center;
}

.bottom-nav__label {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.3px;
}

/* ============================================================
   Top Bar
   ============================================================ */

.top-bar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--safe-top) 16px 0;
  height: calc(var(--topbar-height) + var(--safe-top));
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.top-bar__logo-text {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text-primary);
}

.top-bar__logo-accent {
  color: var(--accent);
}

.top-bar__search-btn {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--text-secondary);
  transition: background 0.2s, color 0.2s;
}

.top-bar__search-btn:hover, .top-bar__search-btn:active {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

/* ============================================================
   Tab Row
   ============================================================ */

.tab-row {
  display: flex;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch; /* momentum scrolling on older iOS Safari */
  scrollbar-width: none; /* Firefox */
}

.tab-row::-webkit-scrollbar {
  display: none; /* Chrome/Safari — swipeable tab bar, not a visible scroll area */
}

.tab-btn {
  padding: 12px 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  transition: color 0.2s, border-color 0.2s;
  letter-spacing: 0.5px;
  flex-shrink: 0; /* let the row overflow/scroll instead of squeezing labels to fit */
  white-space: nowrap;
}

.tab-btn--active {
  color: var(--text-primary);
  border-bottom-color: var(--accent);
}

/* ============================================================
   Hero Banner
   ============================================================ */

.hero-banner {
  position: relative;
  overflow: hidden;
  background: #000;
}

.hero-banner__slides {
  position: relative;
  width: 100%;
  aspect-ratio: 16/9;
}

.hero-banner__slide {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  opacity: 0;
  transition: opacity 0.5s ease;
  cursor: pointer;
}

.hero-banner__slide--active {
  opacity: 1;
}

.hero-banner__image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hero-banner__overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 24px 16px 12px;
  background: linear-gradient(to top, rgba(0,0,0,0.85) 0%, transparent 100%);
}

.hero-banner__title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 10px;
  text-shadow: 0 1px 4px rgba(0,0,0,0.8);
  line-height: 1.3;
}

.hero-banner__watch-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  border-radius: 20px;
  transition: background 0.2s, transform 0.1s;
}

.hero-banner__watch-btn:active {
  background: var(--accent-dark);
  transform: scale(0.97);
}

.hero-banner__dots {
  display: flex;
  justify-content: center;
  gap: 6px;
  padding: 8px;
}

.hero-banner__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255,255,255,0.3);
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
}

.hero-banner__dot--active {
  background: var(--accent);
  transform: scale(1.3);
}

/* ============================================================
   Home Page
   ============================================================ */

.home-main {
  padding-bottom: 16px;
}

.home-block {
  margin-top: 20px;
}

.home-block__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px 10px;
}

.home-block__title {
  font-size: 16px;
  font-weight: 700;
}

.home-block__view-all {
  display: flex;
  align-items: center;
  gap: 2px;
  font-size: 12px;
  color: var(--accent);
  font-weight: 500;
}

/* ============================================================
   Drama Cards
   ============================================================ */

.drama-row {
  display: flex;
  gap: 10px;
  padding: 0 16px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
}

.drama-row::-webkit-scrollbar {
  display: none;
}

.drama-card {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  background: var(--bg-card);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
}

.drama-card:active {
  transform: scale(0.96);
}

/* TV remote / keyboard focus indicator — inset so overflow:hidden doesn't clip it */
.drama-card:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: -3px;
}

/* Older browsers that don't support :focus-visible */
.drama-card:focus:not(:focus-visible) {
  outline: none;
}

.drama-card--row {
  width: 110px;
  scroll-snap-align: start;
}

.drama-card__image-wrap {
  position: relative;
  aspect-ratio: 3/4;
  overflow: hidden;
  background: var(--bg-elevated);
}

.drama-card__image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s;
}

.drama-card:hover .drama-card__image {
  transform: scale(1.04);
}

.drama-card__badge {
  position: absolute;
  top: 6px;
  left: 0;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 0 3px 3px 0;
  max-width: 80%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.4;
}

.drama-card__overlay {
  padding: 6px 6px 5px;
}

.drama-card__title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.drama-card__score {
  font-size: 10px;
  color: #ffc107;
  margin-top: 2px;
}

/* Grid variant (2 columns) */
.drama-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 0 12px;
}

.drama-grid .drama-card {
  width: 100%;
}

.drama-grid .drama-card__image-wrap {
  aspect-ratio: 3/4;
}

.drama-grid .drama-card__title {
  font-size: 12px;
}

/* Wrapping variant of .drama-row — same card size (.drama-card--row), but
   wraps onto multiple lines instead of scrolling horizontally. */
.drama-wall {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 16px;
}

/* ============================================================
   Explore Page
   ============================================================ */

.explore-search-bar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(var(--safe-top) + 10px) 16px 10px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.explore-search-icon {
  color: var(--text-muted);
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.explore-search-input {
  flex: 1;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 8px 14px;
  font-size: 14px;
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.2s;
}

.explore-search-input::placeholder {
  color: var(--text-muted);
}

.explore-search-input:focus {
  border-color: var(--accent);
}

.explore-search-clear {
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  transition: background 0.2s;
}

.explore-search-clear:hover {
  background: var(--bg-elevated);
}

.filter-panel {
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 52px;
  z-index: 35;
}

.filter-row {
  display: flex;
  gap: 6px;
  padding: 4px 12px;
}

.filter-row--scroll {
  overflow-x: auto;
  scrollbar-width: none;
  flex-wrap: nowrap;
}

.filter-row--scroll::-webkit-scrollbar {
  display: none;
}

.filter-row--sort {
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
}

.filter-tab {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 6px 14px;
  border-radius: 16px;
  white-space: nowrap;
  transition: color 0.2s, background 0.2s;
}

.filter-tab--active {
  color: var(--accent);
  background: var(--accent-dim);
}

.filter-chip {
  font-size: 12px;
  color: var(--text-secondary);
  padding: 5px 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  white-space: nowrap;
  transition: color 0.2s, background 0.2s, border-color 0.2s;
  flex-shrink: 0;
}

.filter-chip--sm {
  font-size: 11px;
  padding: 4px 10px;
}

.filter-chip--active {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-dim);
}

.explore-grid-container {
  padding: 12px 0;
}

.scroll-sentinel {
  height: 10px;
  margin-bottom: 8px;
}

.end-of-list {
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  padding: 16px;
}

.empty-state {
  text-align: center;
  padding: 48px 16px;
  color: var(--text-muted);
  font-size: 14px;
}

/* ============================================================
   Details Page
   ============================================================ */

.details-player-wrap {
  position: sticky;
  top: 0;
  z-index: 30;
  background: #000;
  /* Push video below Dynamic Island / notch in standalone PWA mode */
  padding-top: env(safe-area-inset-top, 0px);
}

.player-container {
  width: 100%;
  aspect-ratio: 16/9;
  background: #000;
  position: relative;
  overflow: hidden;
}

/* Floats over the top-left of the player/poster — a sibling of
   .player-container (not a child), so it isn't pulled into fullscreen with
   the video, and .details-player-wrap's own position:sticky gives it a
   containing block to anchor to. Nothing in our own layout occupies that
   corner (the play-icon overlay is centered, My List/Share sit further
   down) — but browser-native <video controls> chrome (Picture-in-Picture /
   maximize icons some browsers draw in that same corner) sits in its own
   compositing layer above any page z-index, so the only real fix is
   clearing that zone entirely: pushed down below the native icon row
   instead of hugging the very top edge. Same value at every breakpoint —
   the native icon row's height doesn't scale with the video's, and this
   still lands comfortably inside .player-container's 16/9 box down to the
   narrowest supported width (~180px tall at 320px wide).
*/
.details-back-btn {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 52px);
  left: 10px;
  z-index: 2;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s;
}

.details-back-btn:active {
  background: rgba(0, 0, 0, 0.65);
}

.player-container--loading::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
}

.player-placeholder {
  width: 100%;
  height: 100%;
  position: relative;
  cursor: pointer;
}

.player-placeholder__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.player-placeholder__overlay {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.3);
}

.player__video {
  width: 100%;
  height: 100%;
  background: #000;
}

/* In-player exit for phones in fullscreen — see attachFullscreenExit() in
   client/components/player.ts. Hidden outside fullscreen (the page's own
   .details-back-btn covers that) and in TV remote mode (its control bar has
   its own Fullscreen toggle). Sits above .player__error so a failed
   episode can't trap the viewer in fullscreen. */
.player__fs-exit { display: none; }
.player-container:fullscreen > .player__fs-exit {
  display: flex;
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 16px);
  left: calc(env(safe-area-inset-left, 0px) + 16px);
  z-index: 5;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  border: none;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  transition: opacity 0.3s;
}
.player-container:fullscreen > .player__fs-exit--hidden { opacity: 0; pointer-events: none; }
body.tv-remote .player-container:fullscreen > .player__fs-exit { display: none; }
/* Android's fullscreen Toast covers the bottom ~80px for ~3.5s; keep the
   native controls clear of it until it's gone (see liftForToast()). */
.player-container:fullscreen {
  box-sizing: border-box;
  transition: padding-bottom 0.3s;
}
.player-container--fs-toast:fullscreen {
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 88px);
}

.player__error {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(0,0,0,0.8);
  color: #ff6b6b;
  font-size: 13px;
  text-align: center;
  padding: 16px;
}

.player-error {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #000;
  gap: 8px;
}

.player-error__icon {
  font-size: 28px;
  color: var(--accent);
}

.player-error__msg {
  font-size: 13px;
  color: var(--text-secondary);
  text-align: center;
  padding: 0 16px;
  max-width: 280px;
}

.details-info {
  padding: 14px 16px 0;
}

.details-title {
  font-size: 20px;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 8px;
}

.details-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 10px;
  line-height: 1.6;
}

.details-genres {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.genre-chip {
  font-size: 11px;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px 9px;
}

.details-cast {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 10px;
  line-height: 1.5;
}

.details-cast__link {
  color: var(--accent);
  font-size: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  padding: 0;
}

.details-plot-wrap {
  margin-bottom: 14px;
}

.details-plot {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
  transition: max-height 0.3s;
}

.details-plot--collapsed {
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

.details-plot-more {
  font-size: 12px;
  color: var(--accent);
  margin-top: 4px;
  font-weight: 600;
}

.details-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.details-action-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 8px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.details-action-btn--active {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-dim);
}

.details-action-btn:active {
  background: var(--bg-card);
}

/* TV remote / keyboard focus indicator — see .drama-card:focus-visible */
.details-action-btn:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.details-action-btn:focus:not(:focus-visible) {
  outline: none;
}

/* Episodes */
.details-episodes {
  padding: 0 16px 16px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}

.section-title {
  font-size: 15px;
  font-weight: 700;
  padding: 14px 0 10px;
  color: var(--text-primary);
}

.episode-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.episode-btn {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.episode-btn--active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.episode-btn:active {
  transform: scale(0.93);
}

/* TV remote / keyboard focus indicator — see .drama-card:focus-visible */
.episode-btn:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.episode-btn:focus:not(:focus-visible) {
  outline: none;
}

/* Related */
.details-related {
  border-top: 1px solid var(--border);
  padding: 0 16px;
}

.details-related .drama-row {
  padding: 0;
}

/* ============================================================
   Me Page
   ============================================================ */

.me-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: calc(var(--safe-top) + 20px) 16px 20px;
  border-bottom: 1px solid var(--border);
}

.me-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 2px solid var(--border);
}

/* Add-to-Home-Screen button (iOS Safari) */
.me-a2hs {
  flex: 1;
  display: flex;
  align-items: center;
}

.me-a2hs-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 20px;
  transition: background 0.2s;
}

.me-a2hs-btn:active { background: var(--bg-card); }

/* Log Out button */
.me-logout-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 20px;
  flex-shrink: 0;
  transition: border-color 0.2s, color 0.2s;
}

.me-logout-btn:active {
  border-color: #e53935;
  color: #e53935;
}

/* Add-to-Home-Screen guide sheet */
.a2hs-overlay {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background: rgba(0,0,0,0.6);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.a2hs-sheet {
  width: 100%;
  max-width: 480px;
  background: var(--bg-surface);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 20px 20px calc(20px + var(--safe-bottom));
}

.a2hs-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.a2hs-sheet-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.a2hs-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--text-muted);
}

.a2hs-close:active { background: var(--bg-elevated); }

.a2hs-steps {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 0;
}

.a2hs-steps li {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.a2hs-step-icon {
  width: 40px;
  height: 40px;
  background: var(--bg-elevated);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  flex-shrink: 0;
}

.a2hs-steps li strong { color: var(--text-primary); }

.me-section {
  padding: 0 16px 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

.me-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.me-clear-btn {
  font-size: 12px;
  color: var(--accent);
  padding: 4px 8px;
  font-weight: 600;
}

.me-empty {
  font-size: 13px;
  color: var(--text-muted);
  padding: 16px 0;
  text-align: center;
}

.me-section .drama-row {
  padding: 0;
}

/* Settings */
.me-settings {
  border-bottom: none;
}

.settings-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  text-align: left;
  transition: background 0.15s;
}

.settings-row:last-child {
  border-bottom: none;
}

.settings-row:active {
  background: var(--bg-elevated);
}

.settings-row__icon {
  color: var(--text-muted);
  display: flex;
  align-items: center;
}

.settings-row__label {
  flex: 1;
  font-size: 14px;
  color: var(--text-secondary);
}

.settings-row--toggle {
  cursor: default;
}

.settings-row--toggle:active {
  background: none;
}

.segment-control {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
}

.segment-control__btn {
  padding: 4px 12px;
  font-size: 13px;
  color: var(--text-secondary);
  border-right: 1px solid var(--border);
}

.segment-control__btn:last-child {
  border-right: none;
}

.segment-control__btn--active {
  background: var(--accent);
  color: #fff;
}

.toggle-switch {
  position: relative;
  width: 44px;
  height: 26px;
  flex-shrink: 0;
  cursor: pointer;
}

.toggle-switch__input {
  opacity: 0;
  width: 100%;
  height: 100%;
  position: absolute;
  inset: 0;
}

.toggle-switch__track {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  border-radius: 13px;
  background: var(--border);
  transition: background 0.2s;
}

.toggle-switch__track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s;
}

.toggle-switch__input:checked + .toggle-switch__track {
  background: var(--accent);
}

.toggle-switch__input:checked + .toggle-switch__track::after {
  transform: translateX(18px);
}

/* ============================================================
   Loading & Error States
   ============================================================ */

.loading-spinner {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 48px;
}

.loading-spinner::after {
  content: '';
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.loading-spinner--inline {
  padding: 20px;
}

.loading-spinner--inline::after {
  width: 24px;
  height: 24px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.error-msg {
  text-align: center;
  padding: 32px 16px;
  color: #ff6b6b;
  font-size: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.btn-retry {
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  padding: 8px 20px;
  border-radius: 20px;
  transition: background 0.2s;
}

.btn-retry:active {
  background: var(--accent-dark);
}

/* TV remote / keyboard focus indicator — see .drama-card:focus-visible */
.btn-retry:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 2px;
}

.btn-retry:focus:not(:focus-visible) {
  outline: none;
}

/* ============================================================
   Page Placeholder (Downloads)
   ============================================================ */

.page-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  gap: 12px;
  padding: 32px;
}

.page-placeholder__title {
  font-size: 20px;
  font-weight: 700;
}

.page-placeholder__sub {
  font-size: 14px;
  color: var(--text-muted);
  text-align: center;
  max-width: 240px;
  line-height: 1.5;
}

/* ============================================================
   Toast Notification
   ============================================================ */

.toast {
  position: fixed;
  bottom: calc(var(--nav-height) + var(--safe-bottom) + 16px);
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  padding: 10px 20px;
  border-radius: 20px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
  z-index: 200;
  white-space: nowrap;
  max-width: calc(100vw - 32px);
}

.toast--visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ============================================================
   Scrollbar Styling
   ============================================================ */

.page-container::-webkit-scrollbar {
  width: 4px;
}

.page-container::-webkit-scrollbar-track {
  background: transparent;
}

.page-container::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

/* ============================================================
   Utility
   ============================================================ */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* Base dimensions for category row thumbnail and text (overridden by responsive rules below) */
.cat-row__thumb {
  width: 70px;
  height: 100px;
}

.cat-row__name { font-size: 14px; }
.cat-row__cast { font-size: 12px; }
.cat-row__meta { font-size: 11px; }

/* ============================================================
   Fallbacks for browsers without `aspect-ratio` support
   (Chrome <88 / old embedded Chromium — e.g. LG WebOS TV browsers on
   older firmware, and some low-end/Android-Go devices). Without this,
   every box below collapses to 0 height, since their children are sized
   with width/height:100% against a parent whose height never resolves.
   Padding-top percentage is always resolved against the CONTAINING
   BLOCK'S WIDTH regardless of box-sizing, so height:0 + padding-top:X%
   reliably reserves height proportional to width without aspect-ratio.
   ============================================================ */
@supports not (aspect-ratio: 1/1) {
  .hero-banner__slides {
    height: 0;
    padding-top: 56.25%; /* 16:9 */
  }

  .player-container {
    height: 0;
    padding-top: 56.25%; /* 16:9 */
  }
  .player-container > .player__video,
  .player-container > .player-placeholder {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
  }

  .drama-card__image-wrap {
    height: 0;
    padding-top: 133.33%; /* 3:4 */
  }
  .drama-card__image-wrap > .drama-card__image {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
  }

  .featured-card {
    height: 0;
    padding-top: 56.25%; /* 16:9 */
  }
  .featured-card > .featured-card__img {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
  }
}

/* ============================================================
   Responsive – Tablet / Landscape (640px+)
   ============================================================ */

@media (min-width: 640px) {
  #app {
    max-width: 100%;
  }

  /* Bigger cards in horizontal rows */
  .drama-card--row {
    width: 140px;
  }

  /* 3-column drama grid */
  .drama-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    padding: 0 16px;
  }

  /* Wider home block rows */
  .home-block__header {
    padding: 0 20px 10px;
  }

  .drama-row {
    padding: 0 20px;
  }

  /* Wider top-bar padding (preserve safe-top) */
  .top-bar {
    padding: var(--safe-top) 20px 0;
  }

  /* Explore filters */
  .explore-filter-row {
    padding-left: 16px;
  }

  /* Category list */
  .cat-row {
    padding: 10px 24px;
  }

  .cat-row__thumb {
    width: clamp(80px, 6vw, 260px);
    height: clamp(114px, 8.57vw, 371px);
  }

  .cat-row__name { font-size: 15px; }
  .cat-row__cast { font-size: 13px; }
  .cat-row__meta { font-size: 12px; }

  /* Me page */
  .me-header {
    padding: 24px 28px 16px;
  }

  .me-section {
    padding: 0 12px;
  }

  /* Search */
  .search-topbar {
    padding: 10px 20px;
  }
}

/* ============================================================
   Responsive – Large screen / Android TV (1024px+)
   ============================================================ */

@media (min-width: 1024px) {
  /* App becomes a row: sidebar nav + scrollable content */
  #app {
    flex-direction: row;
    max-width: 100%;
  }

  /* Sidebar navigation */
  .bottom-nav {
    position: sticky;
    top: 0;
    order: -1;
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch;
    width: 220px;
    min-width: 220px;
    max-width: none;
    height: 100vh;
    height: 100svh;
    border-top: none;
    border-right: 1px solid var(--border);
    padding: 20px 0 16px;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  .bottom-nav__btn {
    flex-direction: row;
    justify-content: flex-start;
    padding: 13px 24px;
    gap: 14px;
    border-radius: var(--radius);
    margin: 2px 8px;
  }

  .bottom-nav__btn--active {
    background: rgba(233, 30, 140, 0.12);
  }

  .bottom-nav__label {
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0;
  }

  /* Page content fills remaining space */
  .page-container {
    flex: 1;
    min-height: 0;
    height: 100vh;
    height: 100svh;
    padding-bottom: 24px;
    min-width: 0;
  }

  /* 4-column drama grid */
  .drama-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    padding: 0 20px;
  }

  /* Bigger row cards */
  .drama-card--row {
    width: 155px;
  }

  /* Hero banner height cap */
  .hero-banner__slides {
    max-height: 440px;
  }

  .hero-banner__title {
    font-size: 22px;
  }

  /* Wider category rows */
  .cat-row {
    padding: 12px 28px;
  }

  .cat-row__thumb {
    width: clamp(100px, 7vw, 300px);
    height: clamp(143px, 10vw, 429px);
  }

  .cat-row__name { font-size: clamp(18px, 1.3vw, 24px); }
  .cat-row__cast { font-size: clamp(15px, 1.1vw, 20px); }
  .cat-row__meta { font-size: clamp(13px, 0.95vw, 17px); }

  /* Search */
  .search-topbar {
    padding: 10px 28px;
  }

  .search-series-row {
    padding: 12px 28px;
  }

  .search-actress-row {
    padding: 10px 28px;
  }

  /* Actress page hero */
  .actress-hero {
    padding: 24px 28px 20px;
  }

  /* Me page */
  .me-header {
    padding: 28px 32px 20px;
  }

  .me-section {
    padding: 0 16px;
  }

  .settings-row {
    padding: 16px 28px;
  }

  /* Details page – two-column layout: video+info left, episodes+related right */
  .details-layout {
    display: flex;
    flex-direction: row;
    height: 100%;
    min-height: 0;
    overflow: hidden;
  }

  .details-left-panel {
    flex: 0 0 62%;
    max-width: 62%;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .details-right-panel {
    flex: 1;
    min-width: 0;
    min-height: 0;
    overflow-y: auto;
    border-left: 1px solid var(--border);
    -webkit-overflow-scrolling: touch;
  }

  /* Player is no longer sticky — the left panel scrolls independently */
  .details-layout .details-player-wrap {
    position: relative;
    padding-top: 0;
  }

  /* Bigger tap targets for 10-foot/D-pad viewing distance — unlike
     .cat-row__thumb/.drama-card--row, episode buttons never grew past
     their 44px mobile size, making them hard to aim at and read on TV. */
  .episode-btn {
    width: 56px;
    height: 56px;
    font-size: 15px;
  }
}

/* ============================================================
   Responsive – Very large / Wide TV (1440px+)
   ============================================================ */

@media (min-width: 1440px) {
  .bottom-nav {
    width: 260px;
    min-width: 260px;
  }

  .drama-grid {
    grid-template-columns: repeat(5, 1fr);
    gap: 16px;
  }

  .drama-card--row {
    width: 175px;
  }

  .hero-banner__slides {
    max-height: 520px;
  }
}

/* ============================================================
   Responsive – Very wide / 4K TV (1920px+)
   ============================================================ */

@media (min-width: 1920px) {
  .drama-grid {
    grid-template-columns: repeat(6, 1fr);
  }

  .drama-card--row {
    width: 200px;
  }
}

/* ============================================================
   Responsive – Landscape mobile (short viewport, wide)
   ============================================================ */

@media (max-height: 500px) and (orientation: landscape) {
  .hero-banner__slides {
    aspect-ratio: unset;
    height: 180px;
  }

  .bottom-nav {
    height: calc(52px + var(--safe-bottom));
  }

  .bottom-nav__label {
    display: none;
  }

  .bottom-nav__btn {
    padding: 6px 4px;
  }
}

/* ============================================================
   Video player subtitle styling
   ============================================================ */

video::cue {
  background: rgba(0,0,0,0.7);
  color: #fff;
  font-size: 12px;
  font-family: system-ui, sans-serif;
}

/* landscape video::cue font-size is injected dynamically by applySubtitleSize() in app.ts */

/* ============================================================
   Pull-to-refresh prevention
   ============================================================ */

html {
  overscroll-behavior-y: contain;
}

/* ============================================================
   Featured card  (Movies "Trending Now" large landscape hero)
   ============================================================ */

.featured-card {
  position: relative;
  margin: 0 12px 4px;
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  aspect-ratio: 16 / 9;
  background: var(--bg-card);
}

.featured-card__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease;
}

.featured-card:active .featured-card__img {
  transform: scale(1.02);
}

.featured-card__overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 40px 14px 14px;
  background: linear-gradient(to top, rgba(0,0,0,0.85) 0%, transparent 100%);
}

.featured-card__title {
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 4px;
  text-shadow: 0 1px 4px rgba(0,0,0,0.8);
}

.featured-card__meta {
  font-size: 12px;
  color: rgba(255,255,255,0.7);
  margin-bottom: 10px;
}

.featured-card__btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.featured-card__btn:active {
  background: var(--accent-dark);
}

/* ============================================================
   Category / Block Detail Page
   ============================================================ */

/* Inner top-bar variant: back button + title */
.top-bar--inner .top-bar__back-btn {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--text-secondary);
  flex-shrink: 0;
  transition: background 0.2s;
}

.top-bar--inner .top-bar__back-btn:active {
  background: var(--bg-elevated);
}

.top-bar__page-title {
  flex: 1;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 8px;
}

.top-bar__spacer {
  width: 38px;
  flex-shrink: 0;
}

/* Series list */
.cat-list {
  display: flex;
  flex-direction: column;
  padding: 8px 0;
}

.cat-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  cursor: pointer;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.cat-row:active {
  background: var(--bg-card);
}

.cat-row:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: -3px;
}

.cat-row:focus:not(:focus-visible) {
  outline: none;
}

.cat-row__thumb {
  object-fit: cover;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  background: var(--bg-elevated);
}

.cat-row__info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cat-row__name {
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.35;
  /* Allow 2 lines max */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.cat-row__cast {
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cat-row__meta {
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cat-row__bookmark {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--text-muted);
  border-radius: 50%;
  transition: background 0.2s, color 0.2s;
}

.cat-row__bookmark:active {
  background: var(--bg-elevated);
}

.cat-row__bookmark--active {
  color: var(--accent);
}

/* ============================================================
   Search Page
   ============================================================ */

.search-topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(var(--safe-top) + 10px) 16px 10px;
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 50;
}

.search-input-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-elevated);
  border-radius: 22px;
  padding: 0 12px;
  height: 40px;
}

.search-input-icon {
  color: var(--text-muted);
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.search-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 14px;
  caret-color: var(--accent);
}

.search-input::placeholder { color: var(--text-muted); }

.search-input-clear {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--text-muted);
  border-radius: 50%;
  color: var(--bg);
  flex-shrink: 0;
}

.search-cancel-btn {
  font-size: 15px;
  color: var(--text-primary);
  white-space: nowrap;
  padding: 4px 0;
  flex-shrink: 0;
}

.search-body {
  padding-bottom: 16px;
}

/* Top searches / recent */
.search-suggestions {
  padding: 8px 0;
}

.search-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px 6px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
}

.search-section-header--results {
  color: var(--text-primary);
  font-size: 15px;
  padding-top: 12px;
}

.search-clear-recent {
  font-size: 12px;
  color: var(--accent);
}

.search-recent-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 14px;
  -webkit-tap-highlight-color: transparent;
}

.search-recent-row:active { background: var(--bg-card); }

.search-recent-icon { flex-shrink: 0; color: var(--text-muted); }

.search-top-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.search-top-row:active { background: var(--bg-card); }

.search-rank {
  width: 20px;
  font-size: 15px;
  font-weight: 700;
  text-align: center;
  flex-shrink: 0;
}

.rank-1 { color: #e91e8c; }
.rank-2 { color: #ff5722; }
.rank-3 { color: #ff9800; }
.rank-other { color: var(--text-muted); }

.search-top-text {
  flex: 1;
  font-size: 14px;
  color: var(--text-primary);
}

.search-tag {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  flex-shrink: 0;
}

.search-tag--hot { background: #e53935; color: #fff; }
.search-tag--new { background: #f59e0b; color: #fff; }

/* Actress section in search results */
.search-actress-section {
  border-bottom: 1px solid var(--border);
  padding-bottom: 4px;
  margin-bottom: 4px;
}

.search-actress-list { display: flex; flex-direction: column; }

.search-actress-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s;
}

.search-actress-row:active { background: var(--bg-card); }

.search-actress-avatar {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg-elevated);
}

.search-actress-info { flex: 1; min-width: 0; }

.search-actress-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.search-actress-orig {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.search-actress-arrow { color: var(--text-muted); display: flex; }

.search-actress-more {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 100%;
  padding: 10px;
  font-size: 13px;
  color: var(--accent);
}

/* Series list rows in search results */
.search-series-list { display: flex; flex-direction: column; }

.search-series-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.search-series-row:active { background: var(--bg-card); }

.search-series-thumb-wrap {
  position: relative;
  flex-shrink: 0;
  width: 80px;
}

.search-series-thumb {
  width: 80px;
  height: 110px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  display: block;
}

.search-series-score {
  position: absolute;
  bottom: 0;
  left: 0;
  background: rgba(0,0,0,0.65);
  color: #ffd700;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 0 var(--radius-sm) 0 var(--radius-sm);
}

.search-series-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-top: 2px;
}

.search-series-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
}

.search-series-meta {
  font-size: 12px;
  color: var(--text-secondary);
}

.search-series-starring {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-play-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 20px;
  padding: 5px 14px;
  font-size: 12px;
  font-weight: 600;
  margin-top: 4px;
  align-self: flex-start;
}

.search-play-btn:active { background: var(--accent-dark); }

/* ============================================================
   Actress Profile Page
   ============================================================ */

.top-bar--transparent {
  background: transparent;
  border-bottom: none;
  position: absolute;
  width: 100%;
}

.top-bar__back-btn--light {
  color: #fff;
}

.actress-hero {
  min-height: 200px;
  background: linear-gradient(135deg, #6c3db5 0%, #3b68c9 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 24px 28px;
  gap: 12px;
  text-align: center;
}

.actress-hero--loading {
  min-height: 200px;
  background: linear-gradient(135deg, #6c3db5 0%, #3b68c9 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 24px 28px;
}

.actress-avatar-wrap {
  position: relative;
}

.actress-avatar {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid rgba(255,255,255,0.8);
  background: rgba(255,255,255,0.15);
}

.actress-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.actress-name {
  font-size: 20px;
  font-weight: 700;
  color: #fff;
}

.actress-sub {
  font-size: 13px;
  color: rgba(255,255,255,0.75);
}

.actress-wiki-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(255,255,255,0.15);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 20px;
  padding: 5px 14px;
  font-size: 12px;
  font-weight: 500;
  text-decoration: none;
  margin-top: 4px;
}

.actress-wiki-btn:active { background: rgba(255,255,255,0.25); }

.actress-body {
  padding: 8px 0 16px;
}

.actress-section {
  margin-bottom: 4px;
}

.actress-section-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  padding: 16px 16px 10px;
  border-left: 3px solid var(--accent);
  margin-left: 16px;
  padding-left: 10px;
}

/* ============================================================
   Access Code Gate
   ============================================================ */

.access-gate {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: var(--bg);
}

.access-card {
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.access-lock {
  width: 88px;
  height: 88px;
  background: var(--accent-dim);
  border: 2px solid var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  margin-bottom: 4px;
}


.access-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  text-align: center;
}

.access-input-wrap {
  width: 100%;
}

.access-input {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 3px;
  text-align: center;
  padding: 14px 16px;
  outline: none;
  transition: border-color 0.2s;
  caret-color: var(--accent);
}

.access-input:focus {
  border-color: var(--accent);
}

.access-input--error {
  border-color: #e53935;
}

.access-input::placeholder {
  color: var(--text-muted);
  letter-spacing: 0;
  font-weight: 400;
  font-size: 14px;
}

.access-error {
  font-size: 13px;
  color: #e53935;
  text-align: center;
  min-height: 18px;
}

.access-submit {
  width: 100%;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 14px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.5px;
  transition: background 0.2s, opacity 0.2s;
}

.access-submit:active  { background: var(--accent-dark); }
.access-submit:disabled { opacity: 0.6; }

/* ── C-DRAMA2 toolbar (search + sync) ──────────────────────────────────── */

.cdrama2-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  flex-wrap: wrap;
}

.cdrama2-search-input {
  flex: 1;
  min-width: 160px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 14px;
  padding: 10px 14px;
  outline: none;
  transition: border-color 0.2s;
}

.cdrama2-search-input:focus {
  border-color: var(--accent);
}

.cdrama2-search-input::placeholder {
  color: var(--text-muted);
}

.cdrama2-sync-msg {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Explicit remote focus also works on WebViews without :focus-visible. */
body.tv-remote.tv-remote-focus :focus {
  outline: 3px solid #ffd54f !important;
  outline-offset: -3px !important;
}
body.tv-remote.tv-remote-focus .player-container:focus { outline: none !important; }
body.tv-remote.tv-remote-focus .toggle-switch__input:focus + .toggle-switch__track {
  outline: 3px solid #ffd54f;
  outline-offset: 2px;
}
body.tv-remote .page-container,
body.tv-remote .drama-row,
body.tv-remote .tab-row { scroll-behavior: auto; }
body.tv-remote .hero-banner__dot { min-width: 16px; min-height: 16px; }
.tv-player-controls { display: none; }
body.tv-remote .tv-player-controls {
  display: flex;
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  gap: 6px;
  align-items: center;
  justify-content: center;
  padding: 10px 6px;
  background: rgba(0, 0, 0, .8);
  z-index: 3;
}
.tv-player-controls button {
  min-height: 40px;
  padding: 8px;
  border-radius: 6px;
  background: #2b3340;
  font-size: 14px;
}
body.tv-remote .player-container:fullscreen > .tv-player-controls { z-index: 10; }
body.tv-remote .tv-player-controls-hidden .tv-player-controls {
  visibility: hidden;
  pointer-events: none;
}
body.tv-remote .player-container:fullscreen {
  width: 100vw;
  height: 100vh;
  padding: 0;
  aspect-ratio: auto;
}
body.tv-remote .player-container:fullscreen > video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* TV WebViews commonly report 960x540 CSS pixels, below the desktop
   breakpoint. Size browsing by available height, not the physical panel. */
@media (min-width: 640px) and (orientation: landscape) {
  body.tv-remote { --topbar-height: 40px; --nav-height: 46px; }
  body.tv-remote #app { flex-direction: column; max-width: 100%; }
  body.tv-remote .page-container { height: auto; padding-bottom: 8px; min-width: 0; }
  body.tv-remote .bottom-nav {
    position: relative; order: 0; flex-direction: row; justify-content: space-around;
    width: 100%; min-width: 0; height: var(--nav-height); padding: 0;
    border-right: 0; border-top: 1px solid var(--border); backdrop-filter: none;
  }
  body.tv-remote .bottom-nav__btn { flex-direction: row; justify-content: center; gap: 8px; padding: 8px; margin: 0; }
  body.tv-remote .bottom-nav__label { font-size: 13px; }
  body.tv-remote .bottom-nav__icon svg { width: 20px; height: 20px; }

  body.tv-remote .home-page { display: flex; flex-direction: column; overflow: hidden; padding-bottom: 0; }
  body.tv-remote .home-page > .top-bar { position: relative; flex-shrink: 0; }
  body.tv-remote .home-page > .tab-row { flex-shrink: 0; padding: 0 16px; }
  body.tv-remote .tab-btn { padding: 9px 10px; font-size: 12px; }
  body.tv-remote .home-main { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; scroll-behavior: auto; }

  body.tv-remote .hero-banner__slides { aspect-ratio: auto; height: calc(var(--tv-vh, 1vh) * 25); max-height: 180px; padding-top: 0; }
  body.tv-remote .hero-banner__image { object-position: center 35%; }
  body.tv-remote .hero-banner__overlay { padding: 12px 20px 10px; }
  body.tv-remote .hero-banner__title { font-size: 18px; margin-bottom: 6px; }
  body.tv-remote .hero-banner__watch-btn { padding: 6px 16px; }
  body.tv-remote .hero-banner__dots { position: absolute; right: 16px; bottom: 10px; padding: 4px; }
  body.tv-remote .hero-banner__dot { min-width: 12px; min-height: 12px; }
  body.tv-remote .home-block { margin-top: 12px; }
  body.tv-remote .home-block__header { padding: 0 20px 8px; }
  body.tv-remote .home-block__title { font-size: 15px; }
  body.tv-remote .drama-row { gap: 12px; scroll-snap-type: none; }
  body.tv-remote .drama-card--row { width: clamp(100px, calc(var(--tv-vh, 1vh) * 20), 160px); }
  body.tv-remote .drama-card__title { font-size: 12px; }
  body.tv-remote .drama-card__image-wrap { padding-top: 0; }
  body.tv-remote .drama-card:hover .drama-card__image { transform: none; }
  body.tv-remote .drama-card { transition: none; }
  body.tv-remote .drama-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
  body.tv-remote .featured-card { aspect-ratio: auto; height: calc(var(--tv-vh, 1vh) * 28); max-height: 190px; padding-top: 0; }

  /* Category browsing has no slideshow: use the space for legible posters.
     Six complete cards and a preview of the next one indicate the row scrolls. */
  body.tv-remote .home-main[data-catalog="kdrama"] .drama-card--row,
  body.tv-remote .home-main[data-catalog="cdrama"] .drama-card--row {
    width: clamp(118px, 14vw, 184px);
  }
  body.tv-remote .home-main[data-catalog="kdrama"] .drama-card__image-wrap,
  body.tv-remote .home-main[data-catalog="cdrama"] .drama-card__image-wrap { aspect-ratio: 2/3; }
  body.tv-remote .home-main[data-catalog="kdrama"] .drama-card__overlay,
  body.tv-remote .home-main[data-catalog="cdrama"] .drama-card__overlay { padding: 8px; }
  body.tv-remote .home-main[data-catalog="kdrama"] .drama-card__title,
  body.tv-remote .home-main[data-catalog="cdrama"] .drama-card__title {
    font-size: clamp(13px, 1.35vw, 20px); height: 2.6em;
  }
  body.tv-remote .home-main[data-catalog="kdrama"] .drama-card__score,
  body.tv-remote .home-main[data-catalog="cdrama"] .drama-card__score {
    font-size: 12px; line-height: 16px; min-height: 16px; margin-top: 4px;
  }
  body.tv-remote .home-main[data-catalog="kdrama"] .home-block__view-all,
  body.tv-remote .home-main[data-catalog="cdrama"] .home-block__view-all {
    min-height: 30px; font-size: 13px; padding: 4px 8px;
  }

  body.tv-remote .details-layout { display: flex; height: 100%; min-height: 0; overflow: hidden; }
  body.tv-remote .details-left-panel {
    flex: 0 0 60%; max-width: 60%; min-width: 0; min-height: 0;
    overflow-y: auto; scroll-behavior: auto;
  }
  body.tv-remote .details-right-panel {
    flex: 1; min-width: 0; min-height: 0; overflow-y: auto;
    border-left: 1px solid var(--border); scroll-behavior: auto;
  }
  body.tv-remote .details-layout .details-player-wrap { position: relative; padding-top: 0; }
  body.tv-remote .player-container:not(:fullscreen) { aspect-ratio: auto; height: calc(var(--tv-vh, 1vh) * 54); max-height: 380px; padding-top: 0; }
  body.tv-remote .player__video { object-fit: contain; }
  body.tv-remote .details-back-btn { top: 12px; }
  body.tv-remote .details-info { padding: 12px 16px; }
  body.tv-remote .details-title { font-size: 20px; }
  body.tv-remote .details-episodes { padding: 0 14px 16px; margin-top: 0; border-top: 0; }
  body.tv-remote .episode-grid { gap: 8px; }
  body.tv-remote .episode-btn { width: 44px; height: 40px; font-size: 14px; }
  body.tv-remote .details-right-panel .drama-card--row { width: 96px; }
  body.tv-remote .tv-player-controls { padding: 8px; gap: 4px; }
  body.tv-remote .tv-player-controls button { padding: 8px; font-size: 12px; min-height: 36px; }
}

/* Chrome <88 (LG webOS TV): the TV-mode rules above zero padding-top and rely
   on aspect-ratio, which these browsers ignore — the poster box collapsed to
   0 height and no thumbnails showed. Restore the padding-top ratio box. */
@supports not (aspect-ratio: 1/1) {
  @media (min-width: 640px) and (orientation: landscape) {
    body.tv-remote .drama-card__image-wrap { height: 0; padding-top: 133.33%; } /* 3:4 */
    body.tv-remote .home-main[data-catalog="kdrama"] .drama-card__image-wrap,
    body.tv-remote .home-main[data-catalog="cdrama"] .drama-card__image-wrap { padding-top: 150%; } /* 2:3 */
  }
}
