:root {
  --bg: #0b0d10;
  --bg-elev: #12161c;
  --bg-soft: #1a2029;
  --line: rgba(255, 255, 255, 0.08);
  --text: #f3f5f7;
  --muted: #8b95a5;
  --accent: #ffc400;
  --accent-dim: rgba(255, 196, 0, 0.14);
  --danger: #ff5c6a;
  --ok: #3dd68c;
  --radius: 14px;
  --font: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(255, 196, 0, 0.08), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(60, 120, 255, 0.08), transparent 50%),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
}

button,
select,
a.btn {
  font-family: inherit;
}

.app {
  max-width: 1440px;
  margin: 0 auto;
  padding: 18px 18px 40px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

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

.brand-mark {
  width: 14px;
  height: 42px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--accent), #ff8a00);
  box-shadow: 0 0 24px rgba(255, 196, 0, 0.35);
}

.brand h1 {
  margin: 0;
  font-size: 1.35rem;
  letter-spacing: 0.02em;
}

.sub {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.top-actions,
.bar-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn,
a.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--text);
  padding: 9px 14px;
  border-radius: 10px;
  cursor: pointer;
  text-decoration: none;
  font-size: 0.92rem;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.btn:hover:not(:disabled),
a.btn:hover {
  border-color: rgba(255, 196, 0, 0.45);
  background: var(--accent-dim);
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:disabled,
a.btn[aria-disabled="true"] {
  opacity: 0.45;
  pointer-events: none;
}

.btn-ghost {
  background: transparent;
}

.btn-sm {
  padding: 6px 10px;
  font-size: 0.82rem;
}

.main-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.main-tab {
  flex: 1;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--muted);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.main-tab:hover {
  color: var(--text);
  border-color: rgba(255, 196, 0, 0.35);
}

.main-tab.active {
  color: #1a1200;
  background: linear-gradient(135deg, var(--accent), #ff9800);
  border-color: transparent;
  font-weight: 700;
}

.filters {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.filters.is-drama-mode {
  grid-template-columns: minmax(140px, 200px) minmax(0, 1fr);
  align-items: end;
}

.filters.is-drama-mode #langLabel,
.filters.is-drama-mode #sortLabel {
  display: none;
}

.filters.is-drama-mode #dramaBrowseLabel {
  display: flex;
}

.drama-browse-foot {
  margin-top: 14px;
  padding: 4px 0 8px;
}

.drama-waterfall-more,
.drama-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.drama-browse-status,
.drama-pager-info {
  color: var(--muted, #94a3b8);
  font-size: 0.82rem;
}

.drama-pager .btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.sub-cats {
  margin: 0 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-elev);
  padding: 8px 6px;
}

.sub-cats-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  padding: 2px 4px 6px;
}

.sub-cat-btn {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--muted);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 0.82rem;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.sub-cat-btn:hover {
  color: var(--text);
  border-color: rgba(255, 196, 0, 0.35);
}

.sub-cat-btn.active {
  color: #1a1200;
  background: linear-gradient(135deg, var(--accent), #ff9800);
  border-color: transparent;
  font-weight: 600;
}

.sub-cat-btn .cat-count {
  margin-left: 4px;
  opacity: 0.75;
  font-size: 0.75rem;
}

.filters label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--muted);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
}

.filters select {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  border: 0;
  border-radius: 8px;
  background: var(--bg-soft)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%238b95a5' d='M1 1l5 5 5-5'/%3E%3C/svg%3E")
    no-repeat right 10px center / 12px;
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
  padding: 6px 28px 6px 8px;
  color-scheme: dark;
}

.filters select option,
.filters select optgroup {
  background: #1a2029;
  color: #f3f5f7;
}

.quota {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 0.9rem;
  color: var(--accent);
}

.vip-gate {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background:
    radial-gradient(800px 400px at 20% 0%, rgba(255, 196, 0, 0.12), transparent 55%),
    rgba(8, 10, 14, 0.92);
  backdrop-filter: blur(8px);
}

.vip-gate[hidden] {
  display: none !important;
}

.vip-card {
  width: min(400px, 100%);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px 24px 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.vip-card h2 {
  margin: 0;
  font-size: 1.25rem;
}

.vip-desc {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.5;
}

.vip-card label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--muted);
}

.vip-card input {
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.95rem;
  outline: none;
}

.vip-card input:focus {
  border-color: rgba(255, 196, 0, 0.5);
}

.vip-submit {
  margin-top: 4px;
  background: var(--accent-dim);
  border-color: rgba(255, 196, 0, 0.45);
  color: var(--accent);
  font-weight: 600;
}

.vip-buy {
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
}

.vip-err {
  margin: 0;
  color: var(--danger);
  font-size: 0.85rem;
}

.vip-user {
  align-self: center;
  color: var(--accent);
  font-size: 0.85rem;
}

.layout {
  display: grid;
  grid-template-columns: minmax(280px, 380px) 1fr;
  gap: 16px;
  min-height: 70vh;
}

.list-pane,
.player-pane {
  min-width: 0;
}

.list-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.85rem;
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  max-height: calc(100vh - 220px);
  overflow: auto;
  padding-right: 4px;
}

.card {
  border: 1px solid var(--line);
  background: var(--bg-elev);
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  text-align: left;
  padding: 0;
  color: inherit;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.card:hover,
.card.active {
  border-color: rgba(255, 196, 0, 0.55);
  transform: translateY(-1px);
}

.card img {
  width: 100%;
  /* 直播封面横图 */
  aspect-ratio: 16 / 9;
  object-fit: cover;
  display: block;
  background: #000;
}

/*
 * AI短剧封面：对齐源站 playlist-detail-view / result-grid--vertical
 * 手机：3 列；桌面(.app--desktop)：6 列
 * 竖封面 10/16 + object-fit:cover + scale(1.055)；gap 8px
 */
body.is-drama-mode {
  --app-vw: 100vw;
  --color-bg-card: #14141a;
  --color-bg: #0a0a0c;
  --color-text: #ffffff;
  --color-text-secondary: #94a3b8;
  --color-primary: #ffe300;
  --color-border: rgba(255, 255, 255, 0.06);
  /* 由外层 CMS 页面滚动，面板内不出现嵌套滚动条 */
  overflow-x: hidden;
  overflow-y: visible;
  height: auto;
  min-height: 0;
}

html:has(body.is-drama-mode),
body.is-drama-mode .app,
body.is-drama-mode .layout,
body.is-drama-mode .list-pane {
  overflow: visible !important;
  height: auto;
  max-height: none;
}

body.is-drama-mode .card.is-drama {
  /* 源站 .result-card */
  display: flex;
  flex-direction: column;
  gap: 5px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  border: 0;
  background: transparent;
  border-radius: 0;
  contain: content;
  cursor: pointer;
}

body.is-drama-mode .card.is-drama:hover,
body.is-drama-mode .card.is-drama.active {
  border-color: transparent;
  transform: none;
}

/* 源站 .thumb-wrap + .video-thumb-wrap--vertical / .sk-thumb--vertical */
body.is-drama-mode .card-thumb,
body.is-drama-mode .thumb-wrap--vertical {
  position: relative;
  display: block;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  aspect-ratio: 10 / 16;
  background: var(--color-bg-card, #14141a);
  overflow: hidden;
  border-radius: 6px;
}

/* 源站 .video-thumb-img */
body.is-drama-mode .card-thumb-img,
body.is-drama-mode .video-thumb-img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1.055);
  display: block;
  max-width: 100%;
  -webkit-user-drag: none;
  user-select: none;
  background: var(--color-bg-card, #14141a);
}

body.is-drama-mode .card.is-drama .card-body {
  padding: 0;
  background: transparent;
}

/* 源站 .result-title */
body.is-drama-mode .card.is-drama .card-name {
  font-size: 12px;
  font-weight: 400;
  color: var(--color-text-secondary, #94a3b8);
  line-height: 1.4;
  min-height: 1.4em;
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
  text-overflow: unset;
}

body.is-drama-mode .card.is-drama .card-meta {
  display: none;
}

/* AI短剧浏览页：不显示播放器；网格 = 源站 .result-grid--vertical */
body.is-drama-mode:not(.is-drama-playing) .player-pane {
  display: none !important;
}
body.is-drama-mode:not(.is-drama-playing) .app {
  padding-left: 0;
  padding-right: 0;
}
body.is-drama-mode:not(.is-drama-playing) .layout {
  grid-template-columns: 1fr;
  min-height: 0;
}
/* 源站 .works-section：padding 0 12px 12px */
body.is-drama-mode:not(.is-drama-playing) .list-pane {
  padding: 0 12px 12px;
  box-sizing: border-box;
}
body.is-drama-mode:not(.is-drama-playing) .topbar,
body.is-drama-mode:not(.is-drama-playing) .main-tabs,
body.is-drama-mode:not(.is-drama-playing) .sub-cats,
body.is-drama-mode:not(.is-drama-playing) .filters {
  padding-left: 12px;
  padding-right: 12px;
}
body.is-drama-mode:not(.is-drama-playing) .grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  align-content: start;
  max-height: none !important;
  overflow: visible !important;
  padding-right: 0;
}
body.is-drama-mode:not(.is-drama-playing) .list-meta {
  margin-bottom: 8px;
  padding-top: 4px;
  font-size: 15px;
  font-weight: 600;
  color: var(--color-text, #fff);
}

/* 源站桌面：.app--desktop .playlist-detail-view .result-grid--vertical → 6 列 */
@media (min-width: 768px) {
  body.is-drama-mode:not(.is-drama-playing) .grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}

/* AI短剧播放页：隐藏列表，专注播放 + 选集 */
body.is-drama-mode.is-drama-playing .list-pane,
body.is-drama-mode.is-drama-playing .main-tabs,
body.is-drama-mode.is-drama-playing .sub-cats,
body.is-drama-mode.is-drama-playing .filters {
  display: none !important;
}
body.is-drama-mode.is-drama-playing .layout {
  grid-template-columns: 1fr;
  min-height: 0;
}
body.is-drama-mode.is-drama-playing .player-pane {
  display: block;
}
body.is-drama-mode.is-drama-playing .player-shell {
  border-radius: 14px;
}
body.is-drama-mode.is-drama-playing .player-host {
  max-height: min(78vh, 860px);
  aspect-ratio: var(--player-ar, 9 / 16);
}
body.is-drama-mode.is-drama-playing .btn-back-list:not([hidden]) {
  display: inline-flex;
  align-items: center;
}
body.is-drama-mode.is-drama-playing .topbar .brand h1 {
  font-size: 1rem;
}

/* 播放页：SEO 信息 + 底部推荐 */
.drama-play-info {
  margin: 14px 12px 8px;
  padding: 0 4px 12px;
  border-bottom: 1px solid var(--color-border, rgba(255, 255, 255, 0.06));
}
.drama-play-h1 {
  margin: 0 0 8px;
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  line-height: 1.3;
}
.drama-play-desc {
  margin: 0 0 8px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--color-text-secondary, #94a3b8);
  word-break: break-word;
}
.drama-play-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.85);
}
.drama-play-meta .stat-sep {
  opacity: 0.5;
}
.drama-play-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.drama-tag {
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  color: var(--color-text-secondary, #94a3b8);
  background: var(--color-bg-card, #14141a);
  border: 1px solid var(--color-border, rgba(255, 255, 255, 0.06));
}
/* 推荐区与列表页 list-pane / result-grid--vertical 同宽同列同封面 */
.drama-recommend {
  padding: 8px 12px 28px;
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
}
.drama-recommend-title {
  margin: 0 0 10px;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  padding-top: 4px;
}
body.is-drama-mode.is-drama-playing .drama-recommend-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  align-content: start;
  align-items: start;
  max-height: none !important;
  overflow: visible !important;
  width: 100%;
}
body.is-drama-mode.is-drama-playing .drama-recommend-grid .card.is-drama {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: auto;
  align-self: start;
}
/* 强制与列表页相同的竖封面规格，避免被 .card img 16/9 覆盖 */
body.is-drama-mode.is-drama-playing .drama-recommend-grid .card-thumb,
body.is-drama-mode.is-drama-playing .drama-recommend-grid .thumb-wrap--vertical {
  position: relative;
  width: 100%;
  aspect-ratio: 10 / 16 !important;
  border-radius: 6px;
  overflow: hidden;
  background: var(--color-bg-card, #14141a);
}
body.is-drama-mode.is-drama-playing .drama-recommend-grid .card-thumb-img,
body.is-drama-mode.is-drama-playing .drama-recommend-grid .video-thumb-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1.055);
  aspect-ratio: auto !important;
}
@media (min-width: 768px) {
  body.is-drama-mode.is-drama-playing .drama-recommend-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}
body.is-drama-mode:not(.is-drama-playing) .drama-play-info,
body.is-drama-mode:not(.is-drama-playing) .drama-recommend {
  display: none !important;
}

.card-body {
  padding: 8px 10px 10px;
}

.card-name {
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.75rem;
  display: flex;
  justify-content: space-between;
  gap: 6px;
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--danger);
  display: inline-block;
  margin-right: 4px;
  box-shadow: 0 0 0 0 rgba(255, 92, 106, 0.55);
  animation: pulse 1.6s infinite;
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(255, 92, 106, 0.45);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(255, 92, 106, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(255, 92, 106, 0);
  }
}

.player-shell {
  position: relative;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.drama-fs-hint {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  color: #fff;
  background: rgba(0, 0, 0, 0.45);
  pointer-events: none;
  white-space: nowrap;
}

.drama-fs-toast {
  position: absolute;
  left: 50%;
  bottom: 18%;
  transform: translateX(-50%);
  z-index: 8;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: #111;
  background: rgba(255, 227, 0, 0.92);
  pointer-events: none;
  white-space: nowrap;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}

/* 短剧 CSS 全屏（支持上滑切集，兼容无 Fullscreen API 环境） */
body.is-drama-fs {
  overflow: hidden;
}
body.is-drama-fs .player-shell {
  position: fixed;
  inset: 0;
  z-index: 10000;
  border: 0;
  border-radius: 0;
  background: #000;
}
body.is-drama-fs .player-host {
  width: 100%;
  height: 100%;
  max-height: none !important;
  aspect-ratio: auto !important;
}
body.is-drama-fs .player-host .live-video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}
body.is-drama-fs .player-bar,
body.is-drama-fs .episode-bar,
body.is-drama-fs .btn-back-list {
  display: none !important;
}
body.is-drama-fs .btn-fullscreen:not([hidden]) {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 7;
}
body.is-drama-fs .drama-fs-hint {
  display: block;
}

.player-host {
  position: relative;
  width: 100%;
  aspect-ratio: var(--player-ar, 16 / 9);
  max-height: min(72vh, 820px);
  background: #000;
  margin: 0 auto;
}

.live-video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  display: block;
}

.player-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 24px;
  text-align: center;
  color: var(--muted);
}

.player-placeholder strong {
  color: var(--text);
  font-size: 1.05rem;
}

.trial-ended-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 10px;
}

.trial-ended .btn {
  min-width: 7.5rem;
}

.player-bar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
}

.quality-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.quality-wrap select {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--text);
  border-radius: 8px;
  padding: 6px 28px 6px 10px;
  font-size: 0.85rem;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 14px) 55%, calc(100% - 9px) 55%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  cursor: pointer;
}

.quality-wrap select:focus {
  outline: none;
  border-color: rgba(255, 196, 0, 0.45);
}

.episode-bar {
  border-top: 1px solid var(--line);
  padding: 10px 12px 12px;
  background: var(--bg-elev);
}

.episode-bar[hidden] {
  display: none !important;
}

.episode-bar-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 0.82rem;
  color: var(--muted);
}

.episode-preview-tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(61, 214, 140, 0.16);
  color: #3dd68c;
  font-size: 0.72rem;
}

.episode-preview-tag.is-preview {
  background: rgba(255, 92, 106, 0.16);
  color: #ff8a96;
}

.episode-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 120px;
  overflow: auto;
}

.episode-btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--text);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 0.8rem;
  cursor: pointer;
  min-width: 3.2rem;
  text-align: center;
}

.episode-btn:hover {
  border-color: rgba(255, 196, 0, 0.45);
}

.episode-btn.active {
  background: var(--accent-dim);
  border-color: rgba(255, 196, 0, 0.55);
  color: var(--accent);
  font-weight: 600;
}

.now #nowTitle {
  font-weight: 700;
}

.muted {
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: 2px;
}

.m3u8-box,
.log-box {
  margin-top: 12px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
}

.m3u8-label {
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 8px;
}

#m3u8Url {
  display: block;
  font-family: var(--mono);
  font-size: 0.78rem;
  word-break: break-all;
  color: var(--ok);
  line-height: 1.45;
}

.m3u8-lines {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.m3u8-lines a {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.72rem;
  word-break: break-all;
}

#log {
  margin: 0;
  max-height: 160px;
  overflow: auto;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
  white-space: pre-wrap;
  word-break: break-all;
}

.btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  line-height: 1;
}

.btn-back-list {
  display: none;
  position: absolute;
  z-index: 5;
  top: 10px;
  left: 10px;
  border: 0;
  border-radius: 999px;
  padding: 8px 14px;
  background: rgba(0, 0, 0, 0.62);
  color: #fff;
  font-size: 0.85rem;
  backdrop-filter: blur(6px);
  cursor: pointer;
}

.btn-fullscreen {
  display: none;
  position: absolute;
  z-index: 5;
  top: 10px;
  right: 10px;
  border: 0;
  border-radius: 999px;
  padding: 8px 14px;
  background: rgba(0, 0, 0, 0.62);
  color: #fff;
  font-size: 0.85rem;
  backdrop-filter: blur(6px);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.btn-fullscreen:not([hidden]) {
  display: inline-flex;
  align-items: center;
}

.player-shell {
  position: relative;
}

.player-shell:fullscreen,
.player-shell:-webkit-full-screen {
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 0;
  background: #000;
  display: flex;
  flex-direction: column;
}

.player-shell:fullscreen .player-host,
.player-shell:-webkit-full-screen .player-host {
  flex: 1;
  max-height: none;
  aspect-ratio: auto;
  height: 100%;
  width: 100%;
}

.player-shell:fullscreen .player-bar,
.player-shell:-webkit-full-screen .player-bar {
  flex-shrink: 0;
}

.desktop-only {
  display: block;
}

@media (max-width: 960px) {
  html,
  body {
    height: 100%;
  }

  .app {
    padding: 10px 10px 28px;
    padding-bottom: calc(48px + env(safe-area-inset-bottom, 0px));
    min-height: 100%;
  }

  .layout {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 0;
  }

  /* 手机默认：列表在上；点播后播放器置顶 */
  .list-pane {
    order: 1;
  }

  .player-pane {
    order: 2;
  }

  body.is-mobile-playing .topbar {
    display: none;
  }

  body.is-mobile-playing .player-pane {
    order: 1;
  }

  body.is-mobile-playing .list-pane {
    order: 2;
    padding-bottom: calc(32px + env(safe-area-inset-bottom, 0px));
  }

  body.is-mobile-playing .list-meta::before {
    content: "推荐直播 · ";
  }

  body.is-mobile-playing .main-tabs,
  body.is-mobile-playing .sub-cats,
  body.is-mobile-playing .filters {
    display: none;
  }

  body.is-mobile-playing .app {
    padding-top: 8px;
    padding-bottom: calc(56px + env(safe-area-inset-bottom, 0px));
  }

  .btn-back-list:not([hidden]) {
    display: inline-flex;
    align-items: center;
  }

  .desktop-only {
    display: none !important;
  }

  .topbar {
    margin-bottom: 10px;
    gap: 10px;
  }

  .brand h1 {
    font-size: 1.1rem;
  }

  .sub {
    font-size: 0.75rem;
  }

  .vip-user {
    max-width: 42vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .main-tabs {
    gap: 6px;
    margin-bottom: 8px;
  }

  .main-tab {
    padding: 9px 10px;
    font-size: 0.9rem;
    border-radius: 10px;
  }

  .filters {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 10px;
  }

  .filters.is-drama-mode {
    grid-template-columns: 1fr;
  }

  .filters label,
  .quota {
    padding: 8px 10px;
    border-radius: 12px;
  }

  .quota {
    grid-column: 1 / -1;
    font-size: 0.82rem;
    padding: 8px;
  }

  .sub-cats {
    margin: 0 0 10px;
    padding: 6px 4px;
  }

  .sub-cat-btn {
    padding: 6px 10px;
    font-size: 0.78rem;
  }

  .list-meta {
    font-size: 0.8rem;
    margin-bottom: 8px;
  }

  .grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    max-height: none;
    overflow: visible;
    padding-right: 0;
  }

  body.is-drama-mode:not(.is-drama-playing) .grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    align-content: start;
  }

  body.is-drama-mode:not(.is-drama-playing) .list-pane {
    padding: 0 12px 12px;
  }

  body.is-drama-mode .card-thumb,
  body.is-drama-mode .thumb-wrap--vertical {
    aspect-ratio: 10 / 16;
    border-radius: 6px;
  }

  body.is-drama-mode .card.is-drama img {
    aspect-ratio: auto;
  }

  body.is-drama-mode.is-drama-playing .topbar {
    display: flex;
  }

  body.is-drama-mode.is-drama-playing .player-host {
    max-height: min(62vh, 720px);
    border-radius: 0;
  }

  body.is-drama-mode.is-drama-playing .player-shell {
    border-radius: 0;
    border-left: 0;
    border-right: 0;
  }

  body.is-drama-mode.is-drama-playing .app {
    padding-left: 0;
    padding-right: 0;
  }

  .card {
    border-radius: 10px;
    -webkit-tap-highlight-color: transparent;
  }

  .card:active {
    transform: scale(0.98);
  }

  .card img {
    aspect-ratio: 16 / 9;
  }

  /* 短剧封面比例由 .card-thumb(10/16) 控制，避免覆盖源站尺寸 */
  body.is-drama-mode .card.is-drama img {
    aspect-ratio: auto;
  }

  .card-name {
    font-size: 0.82rem;
  }

  .card-meta {
    font-size: 0.68rem;
  }

  .player-shell {
    border-radius: 12px;
  }

  .player-host {
    /* 默认按横屏；有画面后 JS 会写成真实比例，去掉多余黑边 */
    aspect-ratio: var(--player-ar, 16 / 9);
    max-height: min(42vh, 380px);
    width: 100%;
  }

  body.is-mobile-playing .player-host {
    max-height: min(48vh, 420px);
  }

  /* 竖屏流：略放高，仍限制别占满屏 */
  body.is-mobile-playing .player-host.is-portrait {
    max-height: min(58vh, 520px);
  }

  .player-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    padding: 10px 12px;
  }

  .now #nowTitle {
    font-size: 0.98rem;
  }

  .vip-card {
    padding: 22px 18px 18px;
    border-radius: 14px;
  }

  .vip-gate {
    padding: 16px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  }
}

@media (max-width: 560px) {
  .filters {
    grid-template-columns: 1fr 1fr;
  }

  .filters.is-drama-mode {
    grid-template-columns: 1fr;
  }

  .filters label {
    min-width: 0;
  }

  .quota {
    grid-column: 1 / -1;
  }

  .top-actions .btn:not(.btn-icon):not(.btn-sm) {
    display: none;
  }
}

@media (min-width: 961px) {
  .btn-back-list {
    display: none !important;
  }

  .layout {
    grid-template-columns: minmax(280px, 380px) 1fr;
  }

  .player-pane {
    order: 0;
  }

  .list-pane {
    order: 0;
  }
}
