:root {
  --bg: #000000;
  --surface: #0a0a0a;
  --surface-elev: #121212;
  --line: rgba(255, 255, 255, 0.12);
  --line-strong: rgba(255, 255, 255, 0.28);
  --fg: #ffffff;
  --fg-sec: rgba(255, 255, 255, 0.72);
  --fg-muted: rgba(255, 255, 255, 0.45);
  --font-sans: 'Helvetica Neue', 'Inter', -apple-system, 'PingFang SC', 'Hiragino Sans GB', sans-serif;
  --font-mono: 'SFMono-Regular', 'JetBrains Mono', Menlo, Consolas, monospace;
  --topbar-h: 48px;
  --footer-h: 38px;
}

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

html,
body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  min-height: 100%;
  -webkit-font-smoothing: antialiased;
}

body.mode-stage {
  height: 100dvh;
  overflow: hidden;
  user-select: none;
}

body.mode-stream {
  min-height: 100dvh;
  overflow-x: hidden;
  overflow-y: auto;
}

.hidden {
  display: none !important;
}

/* ==================== GATEWAY / LOCK / STATUS ==================== */
.gateway-screen {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: #000000;
}

.gateway-card {
  width: 100%;
  max-width: 440px;
  border: 1px solid var(--line);
  background: #070707;
  padding: 36px 32px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 14px;
}

.brand-mono {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  color: var(--fg-muted);
  text-transform: uppercase;
}

.gateway-title {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.3;
  color: #ffffff;
}

.gateway-sub {
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--fg-sec);
}

.lock-input-row {
  width: 100%;
  display: flex;
  gap: 8px;
  margin-top: 6px;
}

.lock-input {
  flex: 1;
  min-width: 0;
  background: #000000;
  border: 1px solid var(--line-strong);
  color: #ffffff;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
}

.lock-input:focus {
  border-color: #ffffff;
}

.lock-error {
  font-size: 12.5px;
  color: #f87171;
}

/* ==================== BUTTONS & PILLS ==================== */
.dk-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 30px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 500;
  font-family: var(--font-sans);
  color: var(--fg-sec);
  background: transparent;
  border: 1px solid var(--line);
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.14s ease, border-color 0.14s ease, background 0.14s ease;
}

.dk-btn:hover {
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.45);
  background: rgba(255, 255, 255, 0.06);
}

.dk-btn-solid {
  background: #ffffff;
  color: #000000;
  border-color: #ffffff;
  font-weight: 600;
  height: 36px;
  padding: 0 14px;
}

.dk-btn-solid:hover {
  background: #e5e5e5;
  color: #000000;
  border-color: #e5e5e5;
}

.dk-btn-accent {
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.45);
  background: rgba(255, 255, 255, 0.09);
}

.dk-btn-accent.is-playing {
  background: #ffffff;
  color: #000000;
  border-color: #ffffff;
}

.dk-btn-icon {
  padding: 0 9px;
}

.client-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.22);
  white-space: nowrap;
}

/* ==================== TOP BAR ==================== */
.deck-topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--topbar-h);
  padding: 0 16px;
  background: rgba(0, 0, 0, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  z-index: 40;
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.topbar-left {
  flex: 1;
}

.brand-wordmark {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: #ffffff;
  text-decoration: none;
  white-space: nowrap;
}

.topbar-sep {
  color: var(--fg-muted);
  font-size: 12px;
}

.top-chapter-label {
  font-size: 12.5px;
  color: var(--fg-sec);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ==================== CHAPTER DRAWER ==================== */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 55;
}

.chapter-drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(360px, 88vw);
  background: #080808;
  border-right: 1px solid var(--line);
  z-index: 60;
  display: flex;
  flex-direction: column;
  transform: translateX(-102%);
  transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

.chapter-drawer.open {
  transform: translateX(0);
}

.drawer-head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.drawer-deck-title {
  font-size: 13.5px;
  font-weight: 600;
  color: #ffffff;
  margin-top: 3px;
}

.drawer-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px 12px 28px;
}

.drawer-section-head {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  color: var(--fg-muted);
  padding: 14px 4px 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  margin-bottom: 6px;
  text-transform: uppercase;
}

.drawer-item {
  width: 100%;
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 10px;
  align-items: center;
  padding: 7px;
  margin-bottom: 4px;
  background: transparent;
  border: 1px solid transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.14s ease, border-color 0.14s ease;
}

.drawer-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.drawer-item.active {
  background: rgba(255, 255, 255, 0.09);
  border-color: rgba(255, 255, 255, 0.32);
}

.drawer-thumb {
  width: 92px;
  aspect-ratio: 16 / 9;
  background: #141414;
  object-fit: cover;
  display: block;
}

.drawer-meta {
  min-width: 0;
}

.drawer-title {
  font-size: 12.5px;
  font-weight: 600;
  color: #ffffff;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.drawer-sub {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--fg-muted);
  margin-top: 4px;
}

/* ==================== DESKTOP 16:9 STAGE ==================== */
.stage-view {
  position: fixed;
  top: var(--topbar-h);
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  background: #000000;
}

.stage-canvas-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 20px;
}

.stage-frame {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stage-img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: contain;
  display: block;
  background: #000000;
}

.stage-spinner {
  position: absolute;
  bottom: 16px;
  right: 20px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--fg-muted);
  background: rgba(0, 0, 0, 0.72);
  padding: 4px 8px;
  border: 1px solid var(--line);
  pointer-events: none;
}

.stage-video-wrap {
  position: absolute;
  inset: 0;
  background: #000000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 22;
}

.stage-video {
  max-width: 100%;
  max-height: calc(100% - 48px);
  outline: none;
  background: #000000;
}

.video-floating-bar {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.video-clip-tabs {
  display: flex;
  gap: 6px;
}

.stage-hotzone {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 22%;
  background: transparent;
  border: none;
  cursor: pointer;
  z-index: 10;
  display: flex;
  align-items: center;
  opacity: 0;
  transition: opacity 0.16s ease;
}

.stage-hotzone:hover {
  opacity: 1;
}

.hotzone-prev {
  left: 0;
  justify-content: flex-start;
  padding-left: 18px;
}

.hotzone-next {
  right: 0;
  justify-content: flex-end;
  padding-right: 18px;
}

.hotzone-arrow {
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 10, 10, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: #ffffff;
  font-family: var(--font-mono);
  font-size: 15px;
}

/* ==================== STAGE FOOTER & PROGRESS ==================== */
.stage-footer {
  position: relative;
  height: var(--footer-h);
  padding: 0 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #000000;
  z-index: 25;
}

.footer-left {
  display: flex;
  align-items: center;
  gap: 6px;
}

.footer-nav-btn {
  background: transparent;
  border: none;
  color: var(--fg-sec);
  font-family: var(--font-mono);
  font-size: 12.5px;
  padding: 4px 7px;
  cursor: pointer;
}

.footer-nav-btn:hover {
  color: #ffffff;
}

.page-counter {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  color: #ffffff;
  min-width: 82px;
  text-align: center;
}

.footer-right {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.progress-track {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: rgba(255, 255, 255, 0.1);
  cursor: pointer;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: #ffffff;
  transition: width 0.15s ease;
}

/* ==================== MOBILE / WECHAT STREAM VIEW ==================== */
.stream-view {
  padding-top: var(--topbar-h);
  background: #000000;
}

.stream-hero {
  padding: 20px 16px 14px;
  border-bottom: 1px solid var(--line);
}

.stream-hero-title {
  font-size: 18px;
  font-weight: 600;
  color: #ffffff;
  line-height: 1.35;
}

.stream-hero-sub {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-muted);
  margin-top: 6px;
}

.stream-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 1120px;
  margin: 0 auto;
}

.stream-chapter-bar {
  position: sticky;
  top: var(--topbar-h);
  z-index: 15;
  background: rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 10px 14px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.stream-chapter-name {
  font-size: 13px;
  font-weight: 600;
  color: #ffffff;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stream-chapter-links {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.stream-slide-card {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #080808;
  overflow: hidden;
}

.stream-slide-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.stream-slide-img.loaded {
  opacity: 1;
}

.stream-slide-num {
  position: absolute;
  right: 8px;
  bottom: 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: rgba(255, 255, 255, 0.42);
  background: rgba(0, 0, 0, 0.52);
  padding: 1px 5px;
  pointer-events: none;
}

.stream-inline-video-box {
  width: 100%;
  background: #050505;
  padding: 8px 0 12px;
  border-bottom: 1px solid var(--line);
}

.stream-inline-video-box video {
  width: 100%;
  display: block;
  max-height: 75vh;
  background: #000;
}

.stream-end-foot {
  padding: 40px 20px 56px;
  text-align: center;
  border-top: 1px solid var(--line);
  margin-top: 16px;
}

@media (max-width: 760px) {
  .hide-sm {
    display: none !important;
  }
  .stage-canvas-wrap {
    padding: 4px 0;
  }
  .stage-hotzone {
    width: 28%;
  }
}

@media (max-width: 520px) {
  .hide-xs {
    display: none !important;
  }
  .deck-topbar {
    padding: 0 10px;
    gap: 6px;
  }
  .dk-btn {
    padding: 0 8px;
    font-size: 11.5px;
  }
}
