:root {
  --bg: #0f0f0f;
  --bg-elevated: #1a1a1a;
  --text: #f5f5f5;
  --text-muted: #a3a3a3;
  --accent: #ff5a36;
  --radius: 10px;
  --header-h: 56px;
  --container: 960px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

a {
  color: inherit;
  text-decoration: none;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(15, 15, 15, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid #2a2a2a;
}

.site-header__inner {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 16px;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 16px;
}

.site-logo {
  font-weight: 700;
  white-space: nowrap;
}

.site-search {
  flex: 1;
  min-width: 0;
  max-width: 360px;
}

@media (min-width: 768px) {
  .site-search {
    flex: 0 1 320px;
  }

  /* 未登录：Logo 左，搜索右 */
  .site-header__inner:not(:has(.site-account)) .site-search {
    margin-left: auto;
  }

  /* 已登录：Logo 左，搜索 + 账号作为一组靠右 */
  .site-header__inner:has(.site-account) .site-search {
    flex: 0 1 280px;
    margin-left: auto;
  }

  .site-header__inner:has(.site-account) .site-account {
    margin-left: 16px;
    flex-shrink: 0;
  }
}

.site-search input {
  width: 100%;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid #333;
  background: #222;
  color: var(--text);
}

.site-account {
  display: flex;
  gap: 12px;
  font-size: 14px;
  color: var(--text-muted);
}

.site-account a:hover,
.site-account__link:hover {
  color: var(--accent);
}

.site-account__link {
  padding: 0;
  border: none;
  background: none;
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.site-account__points {
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
}

.site-account__points:hover {
  color: var(--accent);
}

.site-main {
  min-height: calc(100vh - var(--header-h) - 80px);
  padding: 20px 0 48px;
}

.container {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 16px;
}

.page-title {
  font-size: 1.35rem;
  margin: 0 0 20px;
}

.container--home {
  padding-top: 16px;
}

.naistv-banner {
  margin-bottom: 20px;
}

.naistv-banner__viewport {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
  background: #111;
  aspect-ratio: 16 / 7;
  touch-action: pan-y;
  cursor: grab;
  user-select: none;
}

.naistv-banner__viewport:active {
  cursor: grabbing;
}

.naistv-banner__track {
  display: flex;
  height: 100%;
  will-change: transform;
  transition: transform 0.38s ease;
}

.naistv-banner__track.is-dragging {
  transition: none;
}

.naistv-banner__slide {
  flex: 0 0 100%;
  width: 100%;
  height: 100%;
}

.naistv-banner__link {
  display: block;
  width: 100%;
  height: 100%;
}

.naistv-banner__slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}

.naistv-banner__dots {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 10px;
  z-index: 3;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 10px;
  pointer-events: none;
}

.naistv-banner__dot {
  width: 7px;
  height: 7px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.35);
  cursor: pointer;
  pointer-events: auto;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25);
}

.naistv-banner__dot.is-active {
  background: var(--accent);
  transform: scale(1.2);
}

.drama-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

@media (min-width: 640px) {
  .drama-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 18px;
  }
}

@media (min-width: 900px) {
  .drama-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.drama-card__poster {
  position: relative;
  aspect-ratio: 3 / 4;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-elevated);
}

.drama-card__badge {
  position: absolute;
  right: 6px;
  bottom: 6px;
  padding: 2px 7px;
  font-size: 11px;
  line-height: 1.4;
  color: #fff;
  background: rgba(0, 0, 0, 0.65);
  border-radius: 4px;
  pointer-events: none;
}

.drama-card__poster img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.drama-card__placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  font-size: 13px;
}

.drama-card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
}

.drama-card__title {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  margin: 0;
  font-weight: 600;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.drama-card__meta {
  flex-shrink: 0;
  margin: 0;
  font-size: 12px;
  line-height: 1.35;
  color: var(--text-muted);
  white-space: nowrap;
}

.drama-player-wrap {
  background: transparent;
  border-radius: var(--radius);
  overflow: visible;
  margin-bottom: 0;
}

.drama-player-wrap.is-player-active {
  background: #141414;
  overflow: hidden;
  margin-bottom: 20px;
}

/* 拿到播放地址前：不占位 */
.drama-player-wrap:not(.is-player-active) .drama-player-stage {
  height: 0;
  min-height: 0;
  overflow: hidden;
  visibility: hidden;
}

/* 初始化 TCPlayer 时：屏幕外渲染，避免首屏黑块 */
.drama-player-wrap.is-player-loading .drama-player-stage {
  position: fixed;
  left: -10000px;
  top: 0;
  width: 640px;
  height: 360px;
  visibility: hidden;
  pointer-events: none;
}

.drama-player-stage {
  margin: 0 auto;
  background: #000;
  position: relative;
  overflow: hidden;
}

.drama-player-stage.is-orientation-pending {
  width: 100%;
  max-width: var(--container);
  aspect-ratio: unset;
  min-height: 0;
  background: #000;
}

/* 竖版短剧 9:16，居中窄栏 */
.drama-player-stage.is-portrait {
  aspect-ratio: 9 / 16;
  width: min(420px, 100%, calc((100vh - 200px) * 9 / 16));
}

/* 横版 16:9，通栏（如古装横屏剧） */
.drama-player-stage.is-landscape {
  aspect-ratio: 16 / 9;
  width: 100%;
  max-width: var(--container);
}

.drama-player-stage .drama-player,
.drama-player-stage #naistv-player,
.drama-player-stage .video-js,
.drama-player-stage .tcplayer {
  width: 100% !important;
  height: 100% !important;
  max-width: 100%;
  display: block;
  background: #000;
}

.drama-player-stage .video-js .vjs-tech {
  object-fit: contain;
}

/* 封面可预加载，但不挡在播放器上 */
.drama-player-stage .vjs-poster,
.drama-player-stage .vjs-poster img {
  display: none !important;
  opacity: 0 !important;
  visibility: hidden !important;
}

/* TCPlayer 清晰度按钮（配置未生效时的兜底） */
.drama-player-stage .vjs-quality-menu,
.drama-player-stage .tcp-quality-switcher,
.drama-player-stage .vjs-menu-button-popup.vjs-quality-selector {
  display: none !important;
}

.drama-player-stage .vjs-contextmenu-ui,
.drama-player-stage .tcp-right-click-popup {
  display: none !important;
}

.drama-player-status {
  margin: 0;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--text-muted);
  background: #141414;
}

.drama-player-status:empty,
.drama-player-status[hidden] {
  display: none;
  padding: 0;
}

.drama-title {
  font-size: 1.4rem;
  margin: 0 0 8px;
}

.drama-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 20px;
  font-size: 13px;
  color: var(--text-muted);
}

.drama-meta__tag {
  padding: 2px 8px;
  border-radius: 4px;
  background: #2a2a2a;
}

.drama-meta__tag--ok {
  color: var(--accent);
  background: rgba(255, 90, 54, 0.15);
}

.section-title {
  font-size: 1rem;
  margin: 0 0 12px;
}

.episode-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 28px;
}

.episode-btn {
  position: relative;
  box-sizing: border-box;
  min-width: 44px;
  height: 44px;
  padding: 0 10px;
  border: 1px solid #333;
  border-radius: 8px;
  background: #222;
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.episode-btn.is-locked::after {
  content: "";
  position: absolute;
  top: 3px;
  right: 3px;
  width: 11px;
  height: 11px;
  background-color: var(--accent);
  pointer-events: none;
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23000' d='M17 10h-1V7a4 4 0 00-8 0v3H7a2 2 0 00-2 2v8a2 2 0 002 2h10a2 2 0 002-2v-8a2 2 0 00-2-2zm-4-3a2 2 0 114 0v3h-4V7zm-1 9v2h2v-2a1 1 0 10-2 0z'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23000' d='M17 10h-1V7a4 4 0 00-8 0v3H7a2 2 0 00-2 2v8a2 2 0 002 2h10a2 2 0 002-2v-8a2 2 0 00-2-2zm-4-3a2 2 0 114 0v3h-4V7zm-1 9v2h2v-2a1 1 0 10-2 0z'/%3E%3C/svg%3E");
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
}

.episode-btn.is-active.is-locked::after {
  background-color: #fff;
}

.episode-btn.is-offline::after {
  content: "";
  position: absolute;
  top: 3px;
  right: 3px;
  width: 11px;
  height: 11px;
  background-color: var(--text-muted, #a3a3a3);
  pointer-events: none;
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23000' d='M12 2a10 10 0 100 20 10 10 0 000-20zm1 11h-4V7h2v4h2v2z'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23000' d='M12 2a10 10 0 100 20 10 10 0 000-20zm1 11h-4V7h2v4h2v2z'/%3E%3C/svg%3E");
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
}

.episode-btn:hover {
  border-color: var(--accent);
}

.episode-btn.is-active {
  border-color: var(--accent);
  background: rgba(255, 90, 54, 0.2);
  color: #fff;
}

.episode-btn.is-offline,
.episode-btn:disabled {
  color: #666;
  background: #1a1a1a;
  border-color: #2a2a2a;
  cursor: not-allowed;
  opacity: 0.85;
}

.episode-btn.is-offline:hover,
.episode-btn:disabled:hover {
  border-color: #2a2a2a;
}

.drama-desc {
  margin-top: 4px;
}

.drama-desc .section-title {
  margin-bottom: 10px;
}

.drama-desc__body {
  font-size: 14px;
  color: #d4d4d4;
  line-height: 1.65;
}

.drama-desc__body > :first-child {
  margin-top: 0;
}

.drama-desc__body p {
  margin: 0 0 0.75em;
}

.drama-desc__body p:last-child {
  margin-bottom: 0;
}

.drama-desc__body p:empty {
  display: none;
}

.drama-desc__collapsible {
  position: relative;
}

.drama-desc__collapsible.is-collapsed {
  max-height: 10.5em;
  overflow: hidden;
}

.drama-desc__collapsible.is-collapsed::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3.5em;
  pointer-events: none;
  background: linear-gradient(to bottom, transparent, var(--bg));
}

.drama-desc__toggle {
  margin-top: 10px;
  padding: 0;
  border: none;
  background: none;
  color: var(--accent);
  font-size: 14px;
  cursor: pointer;
}

.drama-desc__toggle:hover {
  text-decoration: underline;
}

.empty-hint {
  color: var(--text-muted);
}

.drama-load-more {
  margin: 24px 0 16px;
  text-align: center;
}

.drama-load-more__status {
  margin: 0;
  font-size: 14px;
  color: var(--text-muted);
}

.drama-load-more__sentinel {
  height: 1px;
  margin-top: 48px;
}

.site-footer {
  text-align: center;
  padding: 24px;
  font-size: 12px;
  color: var(--text-muted);
  border-top: 1px solid #222;
}

body.naistv-auth-modal-open {
  overflow: hidden;
}

.naistv-auth-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.naistv-auth-modal[hidden] {
  display: none !important;
}

.naistv-auth-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
}

.naistv-auth-modal__panel {
  position: relative;
  width: 100%;
  max-width: 400px;
  padding: 24px 24px 20px;
  border-radius: var(--radius);
  background: var(--bg-elevated);
  border: 1px solid #333;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
}

.naistv-auth-modal__close {
  position: absolute;
  top: 8px;
  right: 12px;
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}

.naistv-auth-modal__close:hover {
  color: var(--text);
}

.naistv-auth-modal__title {
  margin: 0 0 16px;
  font-size: 18px;
}

.naistv-auth-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.naistv-auth-tabs__btn {
  flex: 1;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid #333;
  background: #222;
  color: var(--text-muted);
  cursor: pointer;
  font: inherit;
}

.naistv-auth-tabs__btn.is-active {
  border-color: var(--accent);
  color: var(--text);
  background: rgba(255, 90, 54, 0.12);
}

.naistv-auth-modal__error {
  margin: 0 0 12px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(255, 80, 80, 0.12);
  color: #ffb4b4;
  font-size: 13px;
}

.naistv-auth-form label {
  display: block;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--text-muted);
}

.naistv-auth-form label span {
  display: block;
  margin-bottom: 4px;
}

.naistv-auth-form input[type="text"],
.naistv-auth-form input[type="email"],
.naistv-auth-form input[type="password"] {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid #333;
  background: #111;
  color: var(--text);
  font: inherit;
}

.naistv-auth-form__remember {
  display: flex !important;
  align-items: center;
  gap: 8px;
}

.naistv-auth-form__remember input {
  width: auto;
}

.naistv-auth-form__submit {
  width: 100%;
  margin-top: 4px;
  padding: 10px 16px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.naistv-auth-form__submit:disabled {
  opacity: 0.6;
  cursor: wait;
}

.naistv-auth-form__hint {
  margin: 12px 0 0;
  font-size: 12px;
  text-align: center;
}

.naistv-auth-form__switch {
  padding: 0;
  border: none;
  background: none;
  font: inherit;
  font-size: inherit;
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.naistv-auth-form__switch:hover {
  opacity: 0.9;
}

.drama-player-status__login {
  margin-left: 8px;
  padding: 2px 10px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: transparent;
  color: var(--accent);
  font-size: 12px;
  cursor: pointer;
  vertical-align: middle;
}
