:root {
  --bg: #0f111a;
  --bg-deep: #0a0c13;
  --surface: #191b24;
  --surface-2: #222533;
  --surface-3: #2a2e40;
  --glass: rgba(15, 17, 26, 0.82);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #f8fafc;
  --text-soft: #cbd5e1;
  --muted: #8b93a7;
  --gold: #ffd875;
  --gold-2: #f59e0b;
  --gold-glow: rgba(255, 216, 117, 0.32);
  --accent: #ffd875;
  --badge-sub: #3b4259;
  --badge-ep: #16a34a;
  --danger: #ef4444;
  --success: #22c55e;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --nav-h: 64px;
  --max-w: 1420px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Be Vietnam Pro", -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, sans-serif;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* App Shell */
.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  background:
    radial-gradient(ellipse 80% 45% at 50% -10%, rgba(255, 216, 117, 0.07), transparent 60%),
    var(--bg);
}

/* Tophim-Style Sticky Top Bar */
.top-bar {
  position: sticky;
  top: 0;
  z-index: 45;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(var(--safe-top) + 10px) 16px 10px;
  background: rgba(15, 17, 26, 0.86);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  border-bottom: 1px solid var(--border);
}

.top-left {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
  flex: 1;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  border: none;
  padding: 0;
  color: inherit;
  cursor: pointer;
  flex-shrink: 0;
  text-align: left;
}

.brand-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  object-fit: cover;
  border: 1.5px solid rgba(255, 216, 117, 0.55);
  box-shadow: 0 4px 14px rgba(255, 216, 117, 0.18);
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.12;
}

.brand-name {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(90deg, #fff 15%, var(--gold) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.status-pill {
  font-size: 10px;
  font-weight: 500;
  color: var(--muted);
}
.status-pill.ok { color: #4ade80; }
.status-pill.warn { color: var(--gold); }

/* Header Integrated Search */
.header-search {
  display: none;
  align-items: center;
  gap: 8px;
  width: 280px;
  max-width: 340px;
  padding: 0 14px;
  height: 38px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--border);
  transition: border-color 0.2s, background 0.2s;
}
.header-search:focus-within {
  border-color: rgba(255, 216, 117, 0.55);
  background: rgba(255, 255, 255, 0.11);
}
.search-ico {
  color: var(--muted);
  font-size: 15px;
  line-height: 1;
}
.header-search input {
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  outline: none;
}
.header-search input::placeholder { color: var(--muted); }

/* Desktop Top Nav */
.desktop-nav {
  display: none;
  align-items: center;
  gap: 4px;
}
.dnav-btn {
  padding: 8px 13px;
  border-radius: 999px;
  border: none;
  background: transparent;
  color: var(--text-soft);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.18s, background 0.18s;
  white-space: nowrap;
}
.dnav-btn:hover { color: #fff; background: rgba(255, 255, 255, 0.06); }
.dnav-btn.active {
  color: var(--gold);
  background: rgba(255, 216, 117, 0.12);
}

/* Plugin Switcher Pill */
.plugin-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 185px;
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid rgba(255, 216, 117, 0.36);
  background: linear-gradient(135deg, rgba(255, 216, 117, 0.14), rgba(245, 158, 11, 0.08));
  color: var(--gold);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.2s, background 0.2s;
}
.plugin-pill:hover {
  border-color: var(--gold);
  background: rgba(255, 216, 117, 0.2);
}
.plugin-pill #activePluginLabel {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pill-ico {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}
.pill-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 8px var(--gold);
  flex-shrink: 0;
}

/* Main Content */
.main-content {
  flex: 1;
  width: 100%;
  min-width: 0;
  padding-bottom: calc(var(--nav-h) + var(--safe-bottom) + 32px);
}

.page-container {
  width: 100%;
  max-width: var(--max-w);
  margin: 0 auto;
}

/* Mobile Floating Bottom Nav */
.bottom-nav {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(var(--safe-bottom) + 10px);
  z-index: 45;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  height: 58px;
  padding: 4px;
  border-radius: 20px;
  background: rgba(20, 22, 33, 0.9);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(255, 255, 255, 0.11);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.6);
}

.tab-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: none;
  background: transparent;
  color: var(--muted);
  border-radius: 15px;
  font-family: inherit;
  cursor: pointer;
  transition: color 0.18s, background 0.18s;
}
.tab-btn.active {
  color: var(--gold);
  background: rgba(255, 216, 117, 0.14);
}
.tab-ico { font-size: 17px; line-height: 1; }
.tab-lbl { font-size: 10px; font-weight: 600; }

/* =========================================================================
   TOPHIM CINEMA HERO SHOWCASE
   ========================================================================= */
.hero-showcase {
  position: relative;
  width: 100%;
  min-height: 360px;
  overflow: hidden;
  background: var(--bg-deep);
  margin-bottom: 20px;
}

.hero-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 22%;
  filter: brightness(0.68) saturate(1.1);
  transition: opacity 0.35s ease, transform 0.6s ease;
}

.hero-scrim-bottom {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(15, 17, 26, 0.15) 0%, rgba(15, 17, 26, 0.48) 52%, var(--bg) 100%);
}

.hero-scrim-left {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(15, 17, 26, 0.92) 0%, rgba(15, 17, 26, 0.52) 48%, rgba(15, 17, 26, 0.08) 100%);
}

.hero-inner {
  position: relative;
  z-index: 2;
  max-width: var(--max-w);
  margin: 0 auto;
  min-height: 360px;
  padding: 28px 16px 22px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 14px;
}

.hero-content {
  max-width: 620px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.hero-badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.01em;
}
.tag-pill.gold {
  background: linear-gradient(135deg, var(--gold), var(--gold-2));
  color: #14110b;
}
.tag-pill.imdb {
  background: rgba(245, 197, 24, 0.18);
  border: 1px solid rgba(245, 197, 24, 0.55);
  color: var(--gold);
}
.tag-pill.glass {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #fff;
  backdrop-filter: blur(8px);
}
.tag-pill.green {
  background: rgba(22, 163, 74, 0.88);
  color: #fff;
}

.hero-title {
  margin: 0;
  font-size: 24px;
  font-weight: 800;
  line-height: 1.18;
  letter-spacing: -0.02em;
  text-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
}

.hero-desc {
  margin: 0;
  font-size: 13px;
  line-height: 1.55;
  color: rgba(241, 245, 249, 0.82);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.hero-actions-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 4px;
}

.hero-cta {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-play-gold {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 22px;
  border-radius: 999px;
  border: none;
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-2) 100%);
  color: #14110b;
  font-family: inherit;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 8px 26px var(--gold-glow);
  transition: transform 0.18s, box-shadow 0.2s;
}
.btn-play-gold:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 32px rgba(255, 216, 117, 0.48);
}

.btn-circle-glass {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(25, 27, 36, 0.65);
  backdrop-filter: blur(12px);
  color: #fff;
  font-size: 17px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.18s, border-color 0.18s, color 0.18s;
}
.btn-circle-glass:hover {
  background: rgba(255, 216, 117, 0.18);
  border-color: var(--gold);
  color: var(--gold);
}

.hero-thumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 2px;
}
.hero-thumbs::-webkit-scrollbar { display: none; }

.hero-thumb {
  width: 64px;
  height: 38px;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.2);
  padding: 0;
  background: var(--surface);
  cursor: pointer;
  flex-shrink: 0;
  opacity: 0.65;
  transition: opacity 0.2s, border-color 0.2s, transform 0.2s;
}
.hero-thumb.active, .hero-thumb:hover {
  opacity: 1;
  border-color: var(--gold);
  transform: translateY(-2px);
}
.hero-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* =========================================================================
   TOPHIM TOPIC CARDS ("Bạn đang quan tâm gì?")
   ========================================================================= */
.topic-row {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 2px 16px 6px;
  scrollbar-width: none;
}
.topic-row::-webkit-scrollbar { display: none; }

.topic-card {
  position: relative;
  flex-shrink: 0;
  min-width: 136px;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #fff;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: transform 0.2s, filter 0.2s;
}
.topic-card:hover {
  transform: translateY(-3px);
  filter: brightness(1.08);
}
.topic-card .topic-name {
  font-size: 14px;
  font-weight: 800;
  line-height: 1.2;
}
.topic-card .topic-sub {
  font-size: 11px;
  opacity: 0.85;
  font-weight: 500;
}
.topic-c0 { background: linear-gradient(135deg, #3b5bfd, #1e3a8a); }
.topic-c1 { background: linear-gradient(135deg, #7c3aed, #4c1d95); }
.topic-c2 { background: linear-gradient(135deg, #059669, #064e3b); }
.topic-c3 { background: linear-gradient(135deg, #d97706, #78350f); }
.topic-c4 { background: linear-gradient(135deg, #e11d48, #881337); }
.topic-c5 { background: linear-gradient(135deg, #0284c7, #0c4a6e); }

/* =========================================================================
   SECTIONS & TOPHIM POSTER CARDS
   ========================================================================= */
.section-block {
  margin-bottom: 26px;
}
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 16px 12px;
}
.section-title {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.015em;
  display: inline-flex;
  align-items: center;
  gap: 9px;
}
.section-title::before {
  content: "";
  width: 4px;
  height: 18px;
  border-radius: 4px;
  background: linear-gradient(180deg, var(--gold), var(--gold-2));
}
.section-more {
  border: none;
  background: transparent;
  color: var(--text-soft);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 999px;
  transition: color 0.15s, background 0.15s;
}
.section-more:hover {
  color: var(--gold);
  background: rgba(255, 216, 117, 0.1);
}

.h-scroll {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding: 4px 16px 8px;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
}
.h-scroll::-webkit-scrollbar { display: none; }

.media-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding: 0 16px;
}
.media-grid.horizontal {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.media-card {
  display: flex;
  flex-direction: column;
  gap: 7px;
  cursor: pointer;
  scroll-snap-align: start;
  min-width: 0;
  position: relative;
}
.h-scroll .media-card {
  width: 132px;
  flex-shrink: 0;
}
.h-scroll .media-card.horizontal {
  width: 230px;
}

.poster-box {
  position: relative;
  width: 100%;
  aspect-ratio: 2 / 3;
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
}
.media-card.horizontal .poster-box {
  aspect-ratio: 16 / 9;
}
.poster-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.32s ease, filter 0.25s ease;
}
.media-card:hover .poster-box img {
  transform: scale(1.06);
  filter: brightness(0.82);
}
.media-card:hover .poster-box {
  border-color: rgba(255, 216, 117, 0.45);
}

.card-hover-play {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.22s ease;
  pointer-events: none;
}
.card-hover-play span {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold), var(--gold-2));
  color: #14110b;
  font-size: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding-left: 2px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
}
.media-card:hover .card-hover-play { opacity: 1; }

.card-rank {
  position: absolute;
  top: 6px;
  left: 6px;
  z-index: 3;
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  border-radius: 7px;
  background: linear-gradient(135deg, var(--gold), var(--gold-2));
  color: #14110b;
  font-size: 12px;
  font-weight: 900;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.card-top-right {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 2;
}

.card-bottom-badges {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  padding: 18px 6px 6px;
  background: linear-gradient(180deg, transparent, rgba(10, 12, 19, 0.92));
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 5px;
  background: rgba(59, 66, 89, 0.92);
  color: #f8fafc;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.badge.gold {
  background: linear-gradient(135deg, var(--gold), var(--gold-2));
  color: #14110b;
}
.badge.green {
  background: rgba(22, 163, 74, 0.92);
  color: #fff;
}
.badge.purple {
  background: rgba(124, 58, 237, 0.92);
  color: #fff;
}
.badge.dark {
  background: rgba(15, 17, 26, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.card-title {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.32;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  transition: color 0.15s;
}
.media-card:hover .card-title { color: var(--gold); }

.card-sub {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* =========================================================================
   CHIPS, INPUTS, BUTTONS
   ========================================================================= */
.chip-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 10px 16px;
  scrollbar-width: none;
}
.chip-row::-webkit-scrollbar { display: none; }

.chip {
  flex-shrink: 0;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-soft);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.16s;
}
.chip:hover { border-color: rgba(255, 216, 117, 0.45); color: #fff; }
.chip.active {
  background: linear-gradient(135deg, var(--gold), var(--gold-2));
  border-color: transparent;
  color: #14110b;
  font-weight: 800;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(135deg, var(--gold), var(--gold-2));
  color: #14110b;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.15s, filter 0.15s;
}
.btn-primary:hover { filter: brightness(1.06); }
.btn-primary:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 15px;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.btn-ghost:hover { border-color: rgba(255, 216, 117, 0.5); color: var(--gold); }

.btn-danger {
  padding: 7px 12px;
  border-radius: 9px;
  border: 1px solid rgba(239, 68, 68, 0.35);
  background: rgba(239, 68, 68, 0.14);
  color: #fca5a5;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.search-bar-wrap {
  padding: 14px 16px 4px;
  display: flex;
  gap: 8px;
}

.text-input, .select-input, .textarea-input {
  width: 100%;
  padding: 11px 14px;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: var(--bg-deep);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  outline: none;
}
.text-input:focus, .textarea-input:focus {
  border-color: var(--gold);
}
.textarea-input {
  min-height: 160px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}

/* =========================================================================
   PLUGIN HUB / STORE GRID ("william")
   ========================================================================= */
.hub-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(255, 216, 117, 0.16), rgba(245, 158, 11, 0.06));
  border: 1px solid rgba(255, 216, 117, 0.32);
}

.hub-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 10px;
}

.hub-card {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  transition: border-color 0.18s;
}
.hub-card:hover { border-color: rgba(255, 216, 117, 0.4); }
.hub-card.installed {
  border-color: rgba(34, 197, 94, 0.35);
  background: rgba(34, 197, 94, 0.06);
}
.hub-ico {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  object-fit: cover;
  background: var(--bg-deep);
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.hub-info {
  flex: 1;
  min-width: 0;
}
.hub-name {
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hub-meta {
  font-size: 11px;
  color: var(--muted);
}

/* =========================================================================
   MODALS, SHEETS & DETAIL SCREEN
   ========================================================================= */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(0, 0, 0, 0.68);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.sheet-panel {
  width: 100%;
  max-width: 580px;
  max-height: 78dvh;
  background: var(--surface);
  border-radius: 22px 22px 0 0;
  border-top: 1px solid var(--border-strong);
  padding: 10px 16px calc(var(--safe-bottom) + 18px);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.sheet-handle {
  width: 40px;
  height: 4px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.25);
  margin: 0 auto;
}
.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.sheet-header h3 { margin: 0; font-size: 16px; font-weight: 800; }
.sheet-list {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.full-modal {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}
.modal-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: calc(var(--safe-top) + 10px) 16px 10px;
  background: rgba(15, 17, 26, 0.9);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border);
}
.modal-title-trunc {
  flex: 1;
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.circle-btn, .icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.detail-scroll {
  flex: 1;
  overflow-y: auto;
  padding-bottom: calc(var(--safe-bottom) + 40px);
}
.detail-hero {
  position: relative;
  min-height: 250px;
  overflow: hidden;
  background: var(--bg-deep);
}
.detail-hero-inner {
  position: relative;
  z-index: 2;
  max-width: 1080px;
  margin: 0 auto;
  min-height: 250px;
  display: flex;
  align-items: flex-end;
  padding: 24px 16px 20px;
  gap: 16px;
}
.detail-hero-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: blur(10px) brightness(0.42);
  transform: scale(1.08);
}
.detail-hero-scrim {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(15, 17, 26, 0.25), var(--bg));
}
.detail-poster {
  width: 112px;
  aspect-ratio: 2 / 3;
  border-radius: 14px;
  object-fit: cover;
  border: 1.5px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.65);
  flex-shrink: 0;
}
.detail-info {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.detail-info h2 { margin: 0; font-size: 21px; font-weight: 800; line-height: 1.22; }
.detail-orig { font-size: 12.5px; color: var(--gold); opacity: 0.9; }
.detail-pad {
  max-width: 1080px;
  margin: 0 auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.detail-meta-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  font-size: 12.5px;
  color: var(--text-soft);
}
.detail-meta-grid b { color: var(--muted); font-weight: 600; }
.detail-desc {
  font-size: 13.5px;
  line-height: 1.65;
  color: rgba(241, 245, 249, 0.85);
  margin: 0;
}

.ep-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 8px;
}
.ep-btn {
  padding: 10px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: all 0.15s;
}
.ep-btn:hover { border-color: rgba(255, 216, 117, 0.5); color: var(--gold); }
.ep-btn.active {
  background: linear-gradient(135deg, var(--gold), var(--gold-2));
  border-color: transparent;
  color: #14110b;
  font-weight: 800;
}

/* =========================================================================
   PLAYER OVERLAY
   ========================================================================= */
.player-modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: #000;
  display: flex;
  flex-direction: column;
}
.player-topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(var(--safe-top) + 8px) 14px 8px;
  background: rgba(15, 17, 26, 0.94);
  border-bottom: 1px solid var(--border);
}
.player-meta { flex: 1; min-width: 0; }
.player-title {
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.player-submeta {
  font-size: 11.5px;
  color: var(--gold);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.player-top-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}
.mini-select, .pill-btn {
  padding: 6px 11px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
}
.mini-select option { background: var(--surface); color: #fff; }

.player-stage {
  position: relative;
  flex: 1;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.video-el, .embed-frame {
  width: 100%;
  height: 100%;
  border: none;
  background: #000;
  object-fit: contain;
}
.player-stage:fullscreen,
.player-stage:-webkit-full-screen {
  width: 100vw;
  height: 100vh;
  background: #000;
}
.player-stage:fullscreen .video-el,
.player-stage:-webkit-full-screen .video-el,
.player-stage:fullscreen .embed-frame,
.player-stage:-webkit-full-screen .embed-frame {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.player-modal.css-landscape-fs .player-topbar,
.player-modal.css-landscape-fs .subsource-bar,
.player-modal.css-landscape-fs .player-quickbar {
  display: none !important;
}
.player-modal.css-landscape-fs .player-stage {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  width: 100dvw;
  height: 100dvh;
  z-index: 95;
  background: #000;
}
@media (orientation: portrait) {
  .player-modal.css-landscape-fs .player-stage {
    inset: auto;
    top: 50%;
    left: 50%;
    width: 100vh;
    height: 100vw;
    width: 100dvh;
    height: 100dvw;
    transform: translate(-50%, -50%) rotate(90deg);
    transform-origin: center center;
  }
}
.player-modal.css-landscape-fs .video-el,
.player-modal.css-landscape-fs .embed-frame {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.exit-landscape-btn {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  right: max(14px, env(safe-area-inset-right));
  z-index: 20;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(15, 17, 26, 0.72);
  backdrop-filter: blur(8px);
  color: #fff;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.exit-landscape-btn:hover {
  border-color: var(--gold);
  color: var(--gold);
}
.sub-overlay {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 62px;
  text-align: center;
  pointer-events: none;
  z-index: 6;
}
.sub-overlay span {
  display: inline-block;
  padding: 5px 14px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.78);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.45;
  white-space: pre-line;
}
.player-loading, .player-error {
  position: absolute;
  inset: 0;
  z-index: 8;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  text-align: center;
}

.subsource-bar {
  display: flex;
  align-items: center;
  gap: 7px;
  overflow-x: auto;
  padding: 8px 14px;
  background: #12141e;
  border-top: 1px solid var(--border);
  scrollbar-width: none;
}
.subsource-bar::-webkit-scrollbar { display: none; }
.subsrc-label {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--muted);
  flex-shrink: 0;
}

.player-quickbar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 10px 14px calc(var(--safe-bottom) + 10px);
  background: rgba(15, 17, 26, 0.96);
  border-top: 1px solid var(--border);
  scrollbar-width: none;
}
.player-quickbar::-webkit-scrollbar { display: none; }
.q-btn {
  flex-shrink: 0;
  padding: 8px 13px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.q-btn.active {
  border-color: rgba(34, 197, 94, 0.55);
  background: rgba(34, 197, 94, 0.16);
  color: #86efac;
}

.drawer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 15;
  max-height: 64dvh;
  background: var(--surface);
  border-top: 1px solid var(--border-strong);
  border-radius: 18px 18px 0 0;
  padding: 12px 16px calc(var(--safe-bottom) + 16px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
}
.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.drawer-head h4 { margin: 0; font-size: 15px; }

/* Reader */
.reader-body { flex: 1; overflow-y: auto; background: #05060a; }
.reader-img-list { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.reader-img-list img { width: 100%; max-width: 820px; display: block; }
.reader-novel {
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 18px 40px;
  font-size: 17px;
  line-height: 1.85;
  color: rgba(243, 246, 255, 0.92);
  white-space: pre-wrap;
}
.reader-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px calc(var(--safe-bottom) + 10px);
  background: var(--surface);
  border-top: 1px solid var(--border);
}

/* Panels & Lists */
.panel-card {
  margin: 14px 16px;
  padding: 16px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.panel-card h3 { margin: 0; font-size: 15.5px; font-weight: 800; }

.list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: inherit;
}
.list-row.selected {
  border-color: var(--gold);
  background: rgba(255, 216, 117, 0.12);
}
.list-thumb {
  width: 56px;
  height: 80px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  background: #000;
}
.list-ico-sq {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  object-fit: cover;
  background: var(--bg-deep);
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.list-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.list-title { font-size: 13.5px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-sub { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prog-track { width: 100%; height: 4px; border-radius: 99px; background: rgba(255, 255, 255, 0.12); overflow: hidden; }
.prog-fill { height: 100%; background: var(--gold); }

.row-gap { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.row-gap-sm { display: flex; gap: 6px; align-items: center; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.muted-sm { font-size: 12px; color: var(--muted); line-height: 1.45; }

/* Console & Toast */
.console-overlay {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(var(--nav-h) + var(--safe-bottom) + 18px);
  z-index: 85;
  border-radius: 14px;
  overflow: hidden;
  background: rgba(10, 12, 19, 0.95);
  border: 1px solid rgba(255, 216, 117, 0.35);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.65);
}
.console-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 12px;
  background: var(--surface-2);
  font-size: 11.5px;
  font-weight: 700;
}
.console-body {
  height: 115px;
  overflow-y: auto;
  padding: 8px 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  line-height: 1.45;
}
.console-overlay.expanded .console-body { height: 270px; }
.log-ERROR { color: #f87171; }
.log-WARN { color: var(--gold); }
.log-PRINT { color: #4ade80; }
.log-TOAST { color: #38bdf8; }
.log-LOG { color: #e2e8f0; }

.mini-btn {
  padding: 5px 10px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
}
.mini-btn.gold {
  background: rgba(255, 216, 117, 0.16);
  border-color: rgba(255, 216, 117, 0.45);
  color: var(--gold);
}

.toast-banner {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + var(--safe-bottom) + 24px);
  transform: translateX(-50%);
  z-index: 120;
  max-width: 90vw;
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(20, 22, 33, 0.96);
  border: 1px solid rgba(255, 216, 117, 0.5);
  color: #fff;
  font-size: 12.5px;
  font-weight: 600;
  text-align: center;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.6);
}

.spinner {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.14);
  border-top-color: var(--gold);
  animation: spin 0.75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.center-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 60px 24px;
  text-align: center;
  color: var(--muted);
}

.tap-to-play-btn {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 14;
  padding: 14px 28px;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  background: linear-gradient(135deg, var(--gold), var(--gold-2));
  color: #14110b;
  font-family: inherit;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.7), 0 0 24px rgba(255, 216, 117, 0.4);
}
.tap-to-play-btn:active {
  transform: translate(-50%, -50%) scale(0.96);
}

/* =========================================================================
   GLOBAL MULTI-PLUGIN SEARCH (GROUPED BY PLUGIN)
   ========================================================================= */
.search-status-bar {
  margin: 12px 16px 4px;
  padding: 11px 14px;
  border-radius: 13px;
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.search-status-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.search-status-text {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text);
}
.search-status-meta {
  font-size: 12px;
  font-weight: 700;
  color: var(--gold);
}
.mini-spinner {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--gold);
  animation: spin 0.7s linear infinite;
  display: inline-block;
  flex-shrink: 0;
}
.search-prog-track {
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}
.search-prog-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--gold), var(--gold-2));
  transition: width 0.2s ease;
}
.search-filter-chips .chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.chip-ico {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  object-fit: cover;
  flex-shrink: 0;
}
.search-group {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.search-group-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.search-group-ico {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--surface-2);
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.search-count-pill {
  padding: 2px 9px;
  border-radius: 999px;
  background: rgba(255, 216, 117, 0.14);
  border: 1px solid rgba(255, 216, 117, 0.35);
  color: var(--gold);
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

/* =========================================================================
   TABLET & DESKTOP BREAKPOINT (Tophim Full Cinema Layout)
   ========================================================================= */
@media (min-width: 860px) {
  .top-bar { padding: 12px 28px; }
  .header-search { display: flex; }
  .desktop-nav { display: flex; }
  .bottom-nav { display: none; }
  .main-content { padding-bottom: 52px; }
  .hero-showcase, .hero-inner { min-height: 490px; }
  .hero-inner { padding: 48px 28px 34px; }
  .hero-title { font-size: 38px; }
  .hero-desc { font-size: 14.5px; }
  .hero-thumb { width: 78px; height: 46px; }
  .section-head, .h-scroll, .media-grid, .topic-row, .chip-row, .search-bar-wrap { padding-left: 28px; padding-right: 28px; }
  .search-status-bar { margin-left: 28px; margin-right: 28px; }
  .panel-card { margin-left: 28px; margin-right: 28px; }
  .media-grid { grid-template-columns: repeat(auto-fill, minmax(175px, 1fr)); gap: 16px; }
  .media-grid.horizontal { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
  .h-scroll .media-card { width: 175px; }
  .h-scroll .media-card.horizontal { width: 270px; }
  .section-title { font-size: 20px; }
  .detail-hero, .detail-hero-inner { min-height: 310px; }
  .detail-poster { width: 150px; }
  .detail-info h2 { font-size: 28px; }
  .console-overlay { left: 28px; right: 28px; bottom: 16px; }
  .toast-banner { bottom: 26px; }
}
