:root {
  --bg: #0b0c0f;
  --bg-deep: #07080a;
  --bg-wash: #14161c;
  --panel: #15171d;
  --text: #f5f5f4;
  --muted: #a1a1aa;
  --accent: #f0c674;
  --accent-ink: #1a1408;
  --line: #272a33;
  --safe: #4ade80;
  --input: #0c0d10;
  --chip: #1c1f28;
  --avatar-ph: #2a2418;
  --shade-text: #d4d4d8;
  --overlay: rgba(0, 0, 0, 0.55);
  --card-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  --radius: 12px;
  --pad: 14px;
  font-family: "Avenir Next", "Segoe UI", "PingFang SC", "Helvetica Neue", sans-serif;
  color-scheme: dark;
}
html[data-theme="light"] {
  --bg: #f4f1ea;
  --bg-deep: #ebe6dc;
  --bg-wash: #faf8f3;
  --panel: #ffffff;
  --text: #1c1917;
  --muted: #78716c;
  --accent: #b45309;
  --accent-ink: #fff7ed;
  --line: #e7e0d4;
  --safe: #15803d;
  --input: #fafaf9;
  --chip: #f0ebe3;
  --avatar-ph: #ffedd5;
  --shade-text: #e7e5e4;
  --overlay: rgba(28, 25, 23, 0.4);
  --card-shadow: 0 6px 18px rgba(28, 25, 23, 0.08);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  color: var(--text);
  overscroll-behavior-x: none;
}
html {
  background: var(--bg-deep);
}
body {
  padding: env(safe-area-inset-top) 0 calc(16px + env(safe-area-inset-bottom));
  background:
    radial-gradient(120% 70% at 50% -10%, var(--bg-wash) 0%, transparent 58%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-deep) 100%);
  background-attachment: fixed;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; }

#main {
  max-width: 560px;
  margin: 0 auto;
  padding: 0 var(--pad);
}

/* —— Home: multi-drama shelf —— */
.home-bar {
  padding: 14px 0 10px;
}
.home-bar h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 750;
  letter-spacing: -0.02em;
}
.home-bar p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}
.home-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.home-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.icon-btn {
  flex: none;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 82%, transparent);
  color: var(--text);
  padding: 0;
  backdrop-filter: blur(8px);
}
.icon-btn svg { width: 18px; height: 18px; display: block; }
.home-tools .account-btn { max-width: 132px; }
.page-title {
  margin: 4px 0 12px;
  font-size: 24px;
  font-weight: 750;
  letter-spacing: -0.02em;
}
.cover-link { display: block; color: inherit; }
.poster-wrap { position: relative; width: 96px; }
.fav-heart {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  padding: 0;
}
.fav-heart svg { width: 18px; height: 18px; display: block; }
.fav-heart.on { color: #ff3b5c; }
.poster-wrap .fav-heart { top: 4px; right: 4px; width: 26px; height: 26px; }
.poster-wrap .fav-heart svg { width: 14px; height: 14px; }
.account-btn {
  max-width: 52%;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 82%, transparent);
  color: var(--text);
  border-radius: 999px;
  padding: 4px 10px 4px 4px;
  backdrop-filter: blur(8px);
}
.account-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  object-fit: cover;
  flex: none;
}
.account-avatar.ph {
  display: grid;
  place-items: center;
  background: var(--avatar-ph);
  color: var(--accent);
  font-size: 12px;
}
.account-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.account-btn:not(:has(.account-avatar)) {
  padding: 6px 12px;
}
.avatar-pick {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  margin: 8px 0 4px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
}
.avatar-pick img,
.avatar-pick .ph {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--avatar-ph);
  display: grid;
  place-items: center;
  color: var(--accent);
  font-size: 24px;
  flex: none;
}
.avatar-pick span { color: var(--accent); font-size: 14px; }
.login-sheet {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 20;
}
.login-sheet[hidden] { display: none; }
.login-card {
  width: min(560px, 100%);
  background: var(--panel);
  border-radius: 16px 16px 0 0;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
}
.login-card h2 { margin: 0 0 8px; }
.login-card label { display: block; margin: 12px 0; font-size: 14px; color: var(--muted); }
.login-card input {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--input);
  color: var(--text);
}
.login-card input[type="file"] { display: none; }
.login-actions { display: flex; gap: 8px; }
.login-actions button, .login-close {
  border-radius: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
}
.login-actions button:last-child { background: var(--accent); color: var(--accent-ink); }
.login-actions .ghost, .login-close { background: transparent; color: var(--text); }
.pay-group-title {
  margin: 12px 0 6px;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.pay-plans { display: grid; gap: 8px; margin: 0 0 8px; }
.pay-plan {
  appearance: none;
  width: 100%;
  border: 1px solid var(--line);
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 15px;
  font-weight: 650;
  cursor: pointer;
}
.account-page h1 {
  margin: 4px 0 12px;
  font-size: 24px;
  font-weight: 750;
  letter-spacing: -0.02em;
}
.account-page label { display: block; margin: 12px 0; font-size: 14px; color: var(--muted); }
.account-page input {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--input);
  color: var(--text);
}
.account-page input[type="file"] { display: none; }
.account-page .login-actions { margin-top: 8px; }
.account-page .login-actions button { background: var(--accent); color: var(--accent-ink); }

.shelf {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px 20px;
  padding-bottom: 8px;
}
.home-shelves {
  display: flex;
  flex-direction: column;
  gap: 22px;
}
.shelf-block { min-width: 0; }
.shelf-title {
  margin: 0 0 12px;
  padding-left: 10px;
  border-left: 3px solid var(--accent);
  font-size: 16px;
  font-weight: 750;
  letter-spacing: -0.01em;
  line-height: 1.2;
}
@media (min-width: 420px) {
  .shelf { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.show-card {
  display: block;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--card-shadow);
  position: relative;
}
.show-card .cover-wrap {
  position: relative;
  aspect-ratio: 3 / 4;
  background: var(--chip);
}
.show-card img.cover,
.show-card .cover.ph {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.show-card .cover.ph {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
}
.cover-chip {
  position: absolute;
  left: 8px;
  top: 8px;
  z-index: 2;
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.62);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(4px);
}
.cover-chip.free { color: #bbf7d0; }
.cover-chip.paid { color: #fde68a; }
.card-meta {
  padding: 8px 9px 10px;
}
.card-meta h3 {
  margin: 0 0 4px;
  font-size: 13px;
  font-weight: 650;
  line-height: 1.3;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-meta .card-sub {
  margin: 0;
  font-size: 11px;
  color: var(--muted);
}

.badge {
  display: inline-block;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 999px;
  border: 1px solid var(--line);
  white-space: nowrap;
}
.badge.free { color: var(--safe); border-color: rgba(74, 222, 128, 0.4); }
.badge.paid { color: var(--accent); border-color: rgba(240, 198, 116, 0.4); }

/* —— Detail —— */
.nav-back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 12px 0 10px;
  color: var(--muted);
  font-size: 13px;
}

.drama-hero {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 12px;
  align-items: end;
  margin-bottom: 14px;
}
.drama-hero .poster {
  width: 96px;
  aspect-ratio: 3 / 4;
  border-radius: 10px;
  object-fit: cover;
  background: var(--chip);
  border: 1px solid var(--line);
}
.drama-hero .poster.ph {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 11px;
}
.drama-hero h1 {
  margin: 0 0 6px;
  font-size: 18px;
  line-height: 1.25;
}
.drama-hero .sub {
  color: var(--muted);
  font-size: 12px;
  margin-top: 6px;
}

.player-wrap {
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  margin-bottom: 16px;
}
.player-wrap video,
.player-wrap #veplayer {
  width: 100%;
  display: block;
  background: #000;
  max-height: 62vh;
  aspect-ratio: 9 / 16;
  object-fit: contain;
}
.player-wrap #veplayer {
  min-height: 240px;
}
/* 全屏时去掉页内高度限制，画面居中铺满 */
#veplayer.xgplayer-is-fullscreen,
#veplayer.xgplayer-is-cssfullscreen,
.xgplayer-fullscreen-parent #veplayer,
.player-wrap:fullscreen,
.player-wrap:-webkit-full-screen,
.player-wrap:fullscreen video,
.player-wrap:-webkit-full-screen video,
.player-wrap:fullscreen #veplayer,
.player-wrap:-webkit-full-screen #veplayer {
  max-height: none !important;
  min-height: 0 !important;
  aspect-ratio: auto !important;
  width: 100% !important;
  height: 100% !important;
  border-radius: 0 !important;
  border: 0 !important;
  margin: 0 !important;
}
#veplayer.xgplayer-is-fullscreen video,
#veplayer.xgplayer-is-cssfullscreen video,
.xgplayer-fullscreen-parent video,
.xgplayer-is-fullscreen video,
.xgplayer-is-cssfullscreen video {
  width: 100% !important;
  height: 100% !important;
  max-height: none !important;
  object-fit: contain;
  object-position: center center;
}
.player-empty {
  aspect-ratio: 9 / 16;
  max-height: 62vh;
  display: grid;
  place-items: center;
  gap: 12px;
  padding: 24px;
  text-align: center;
  color: var(--muted);
  background: var(--chip);
}
.pay-cta {
  appearance: none;
  border: 0;
  border-radius: 12px;
  padding: 12px 18px;
  font-size: 15px;
  font-weight: 700;
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
}

.section-title {
  margin: 0 0 10px;
  font-size: 15px;
  font-weight: 650;
}

.ep-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 8px;
}
.ep-chip {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  border-radius: 10px;
  height: 40px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  position: relative;
}
.ep-chip.active {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(240, 198, 116, 0.3);
}
.ep-chip.locked {
  opacity: 0.45;
}
.ep-chip .lock {
  position: absolute;
  top: 3px;
  right: 4px;
  font-size: 9px;
  color: var(--muted);
  font-weight: 500;
}

.ep-now {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(22px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  z-index: 50;
  max-width: calc(100% - 32px);
}
.empty {
  padding: 56px 12px;
  text-align: center;
  color: var(--muted);
}
.muted { color: var(--muted); font-size: 13px; }

/* —— Novel: book detail / reader —— */
.read-cta {
  display: inline-flex;
  margin-top: 12px;
  padding: 10px 16px;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
  font-size: 14px;
}
.intro-block { margin: 8px 0 18px; }
.intro-text {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
}
.toc { display: flex; flex-direction: column; gap: 6px; margin-bottom: 24px; }
.toc-row {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 12px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel);
}
.toc-row.current { border-color: var(--accent); }
.toc-row.locked { opacity: 0.55; }
.toc-no {
  font-weight: 700;
  color: var(--muted);
  font-size: 13px;
}
.toc-title {
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.toc-meta { font-size: 12px; color: var(--muted); }

#main.reading { max-width: 680px; }
.read-shell { padding-bottom: 32px; }
.read-bar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0;
  background: linear-gradient(180deg, var(--bg) 70%, transparent);
  backdrop-filter: blur(6px);
}
.read-bar .nav-back {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin: 0;
}
.read-tools {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.read-tools #fontLabel {
  font-size: 12px;
  color: var(--muted);
  min-width: 36px;
  text-align: center;
}
button.sm {
  padding: 6px 10px;
  font-size: 13px;
  border-radius: 8px;
}
.read-article { padding: 8px 0 20px; }
.read-title {
  margin: 0 0 18px;
  font-size: 22px;
  line-height: 1.3;
  font-weight: 750;
}
.read-body {
  line-height: 1.8;
  letter-spacing: 0.01em;
}
.read-body p {
  margin: 0 0 1.1em;
}
.read-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 16px 0 8px;
  border-top: 1px solid var(--line);
}
.read-nav a.ghost,
.read-nav button.ghost,
.read-nav span.muted {
  min-width: 72px;
  text-align: center;
}
.book-hero .poster-wrap { position: relative; }

.ghost {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
