:root {
  --bg: #0b0c0f;
  --panel: #15171d;
  --text: #f5f5f4;
  --muted: #a1a1aa;
  --accent: #f0c674;
  --line: #272a33;
  --safe: #4ade80;
  --radius: 12px;
  --pad: 14px;
  font-family: "Avenir Next", "Segoe UI", "PingFang SC", "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  overscroll-behavior-x: none;
}
body {
  padding: env(safe-area-inset-top) 0 calc(16px + env(safe-area-inset-bottom));
}
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;
}

.shelf {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 10px;
  padding-bottom: 8px;
}
@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);
  position: relative;
}
.show-card .cover-wrap {
  position: relative;
  aspect-ratio: 3 / 4;
  background: #1c1f28;
}
.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;
}
.show-card .shade {
  position: absolute;
  inset: auto 0 0;
  padding: 28px 8px 8px;
  background: linear-gradient(transparent, rgba(0,0,0,.88));
}
.show-card .shade h3 {
  margin: 0 0 4px;
  font-size: 13px;
  font-weight: 650;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.show-card .shade .row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 11px;
  color: #d4d4d8;
}

.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: #1c1f28;
  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;
}
.player-empty {
  aspect-ratio: 9 / 16;
  max-height: 62vh;
  display: grid;
  place-items: center;
  padding: 24px;
  text-align: center;
  color: var(--muted);
  background: #111;
}

.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: #1f2330;
  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; }
