:root {
  --bg: #000000;
  --surface: #0a0a0c;
  --surface-2: #101014;
  --border: rgba(255, 255, 255, 0.1);
  --border-strong: rgba(255, 255, 255, 0.22);
  --text: #f5f5f5;
  --muted: #a3a3a3;
  --dim: #737373;
  --cobalt: #4b7cf3;
  --cobalt-hover: #5e8bf7;
  --gold: #f5b942;
  --font-sans: -apple-system, BlinkMacSystemFont, "Inter", "Noto Sans SC", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html { background: var(--bg); color: var(--text); scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
html, body {
  margin: 0; background: var(--bg); color: var(--text); font-family: var(--font-sans);
  line-height: 1.55; -webkit-font-smoothing: antialiased; overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }

.container { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 24px; }
.reader-container { max-width: 860px; }

/* ---------- TOP NAV (matches / & /memes/) ---------- */
.nav-header {
  position: sticky; top: 0; z-index: 50; min-height: 60px;
  background: rgba(0, 0, 0, 0.86); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}
.nav-inner {
  max-width: 1120px; min-height: 60px; margin: 0 auto; padding: 0 24px;
  display: flex; align-items: center; gap: 16px;
}
.brand { display: inline-flex; align-items: center; gap: 6px; font-size: 15.5px; letter-spacing: -0.02em; margin-inline-end: auto; flex-shrink: 0; }
.brand-strong { font-weight: 700; color: #fff; }
.brand-muted { color: var(--muted); }
.nav-links { display: flex; align-items: center; gap: 18px; font-size: 13.5px; color: var(--muted); }
.nav-link, .nav-star-link { white-space: nowrap; flex-shrink: 0; }
.nav-link:hover, .nav-star-link:hover { color: #fff; }
.nav-link.is-current { color: #fff; font-weight: 600; }
.nav-star-link { color: #e5e5e5; font-weight: 500; }

.lang-picker {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.14); background: rgba(255, 255, 255, 0.04); color: #f5f5f5;
  flex-shrink: 0;
}
.lang-select { background: transparent; border: 0; color: inherit; font: inherit; font-size: 12.5px; cursor: pointer; outline: none; max-width: 176px; }
.lang-select option { background: #111114; color: #f5f5f5; }
.ico-sm { width: 15px; height: 15px; flex-shrink: 0; }

/* ---------- HERO ---------- */
.story-hero {
  padding: 28px 0 18px;
  background: radial-gradient(ellipse 80% 55% at 50% 0%, rgba(75, 124, 243, 0.12), transparent 72%);
}
.hero-h1 {
  margin: 0; font-size: clamp(24px, 4vw, 38px); font-weight: 650;
  line-height: 1.12; letter-spacing: -0.03em; color: #fff; text-wrap: balance;
}

/* ---------- PODCAST PLAYER CARD ---------- */
.podcast-card[hidden] { display: none; }
.podcast-card {
  margin-top: 16px; padding: 12px 14px; border-radius: 13px;
  background: linear-gradient(180deg, #101218, #0a0a0e);
  border: 1px solid rgba(75, 124, 243, 0.3);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.5);
  display: flex; flex-direction: column; gap: 10px;
}
.pod-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.pod-title-wrap { display: flex; align-items: center; gap: 8px; min-width: 0; flex-wrap: wrap; }
.pod-badge { font-size: 16px; line-height: 1; flex-shrink: 0; }
.pod-title { font-size: 13.5px; font-weight: 600; color: #fff; line-height: 1.3; }
.pod-meta { font-size: 12px; color: var(--muted); font-family: var(--font-mono); }
.pod-player-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pod-audio {
  flex: 1 1 280px; width: 100%; height: 40px; border-radius: 999px;
  color-scheme: dark; outline: none;
}
.pod-dl-btn { min-height: 38px; padding: 0 13px; border-radius: 999px; }

/* ---------- STICKY EPISODE JUMP BAR ---------- */
.reader-bar {
  position: sticky; top: 60px; z-index: 35;
  background: rgba(0, 0, 0, 0.88); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.reader-bar-inner {
  display: flex; align-items: center; justify-content: center;
  padding-top: 10px; padding-bottom: 10px;
}
.ep-pills {
  display: flex; align-items: center; gap: 6px; overflow-x: auto; scrollbar-width: none;
  -webkit-overflow-scrolling: touch; padding: 2px 0;
}
.ep-pills::-webkit-scrollbar { display: none; }
.ep-pill {
  display: inline-flex; align-items: center; justify-content: center; height: 30px; padding: 0 11px;
  border-radius: 999px; border: 1px solid var(--border); background: rgba(255, 255, 255, 0.03);
  color: var(--muted); font-family: var(--font-mono); font-size: 12px; font-weight: 500;
  white-space: nowrap; flex-shrink: 0; transition: border-color 140ms ease, background 140ms ease, color 140ms ease;
}
.ep-pill:hover { color: #fff; border-color: var(--border-strong); }
.ep-pill.is-active { background: rgba(75, 124, 243, 0.2); border-color: rgba(75, 124, 243, 0.6); color: #dbeafe; }

/* ---------- COMIC EPISODE CARDS ---------- */
.reader-sec { padding: 28px 0 76px; }
.story-reader { display: flex; flex-direction: column; gap: 36px; }

.ep-card {
  scroll-margin-top: 130px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 18px;
  overflow: hidden; box-shadow: 0 24px 64px rgba(0, 0, 0, 0.65);
}
.ep-head {
  padding: 12px 18px; border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  display: flex; align-items: center; gap: 10px;
}
.ep-num {
  font-family: var(--font-mono); font-size: 12px; font-weight: 600; letter-spacing: 0.04em;
  color: #fde68a; padding: 2px 7px; border-radius: 6px;
  background: rgba(245, 185, 66, 0.12); border: 1px solid rgba(245, 185, 66, 0.28);
  flex-shrink: 0;
}
.ep-title { margin: 0; font-size: clamp(16px, 2vw, 19px); font-weight: 600; letter-spacing: -0.015em; color: #fff; line-height: 1.3; }

.ep-media-btn {
  display: block; width: 100%; padding: 14px; border: 0; background: #070709;
  cursor: zoom-in; text-align: center;
}
.ep-img-frame {
  position: relative; border-radius: 12px; overflow: hidden;
  background: #141418; border: 1px solid rgba(255, 255, 255, 0.08);
}
.ep-img-frame img {
  display: block; width: 100%; height: auto; transition: transform 220ms ease;
}
.ep-media-btn:hover .ep-img-frame img { transform: scale(1.008); }

.ep-foot {
  padding: 12px 18px; border-top: 1px solid rgba(255, 255, 255, 0.07);
  background: #0c0c10; display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap;
}
.ep-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; width: 100%; }

/* ---------- BUTTONS ---------- */
.act-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  min-height: 34px; padding: 5px 11px; border-radius: 8px;
  border: 1px solid var(--border); background: rgba(255, 255, 255, 0.04); color: #e5e5e5;
  font: inherit; font-size: 12.5px; font-weight: 500; cursor: pointer; white-space: nowrap;
}
.act-btn:hover { background: rgba(255, 255, 255, 0.11); color: #fff; }
.act-primary { background: rgba(255, 255, 255, 0.09); border-color: rgba(255, 255, 255, 0.22); }
.act-cobalt {
  margin-inline-start: auto;
  background: rgba(75, 124, 243, 0.14); border-color: rgba(75, 124, 243, 0.36); color: #bfdbfe;
}
.act-cobalt:hover { background: var(--cobalt); border-color: var(--cobalt); color: #fff; }

.btn-gold {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: 10px;
  border: 1px solid rgba(245, 185, 66, 0.6); cursor: pointer; font: inherit; font-size: 14px; font-weight: 600;
  background: linear-gradient(135deg, #f5b942, #d97706); color: #0a0a0a;
}
.btn-gold:hover { filter: brightness(1.06); }
.btn-cobalt {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 20px; border-radius: 10px; background: var(--cobalt); color: #fff;
  font-size: 14px; font-weight: 600; box-shadow: 0 8px 28px rgba(75, 124, 243, 0.3);
}
.btn-cobalt:hover { background: var(--cobalt-hover); }
.btn-outline {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 44px; padding: 0 18px; border-radius: 10px;
  border: 1px solid var(--border-strong); background: rgba(255, 255, 255, 0.03);
  color: var(--text); font-size: 14px; font-weight: 500;
}
.btn-outline:hover { background: rgba(255, 255, 255, 0.08); }

/* ---------- BOTTOM CTA BOX ---------- */
.story-cta-box {
  margin-top: 32px; padding: 18px; border-radius: 14px;
  background: #0a0a0e; border: 1px solid rgba(255, 255, 255, 0.1);
  display: flex; justify-content: center;
}
.story-cta-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }

/* ---------- FOOTER ---------- */
.footer { border-top: 1px solid rgba(255, 255, 255, 0.08); padding: 26px 0 max(26px, env(safe-area-inset-bottom)); font-size: 13px; color: var(--dim); }
.footer-inner { display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.footer-links { display: flex; gap: 18px; }
.footer-links a:hover { color: #fff; }

/* ---------- LIGHTBOX & TOAST ---------- */
.lb[hidden] { display: none; }
.lb { position: fixed; inset: 0; z-index: 90; display: flex; align-items: center; justify-content: center; padding: 18px; }
.lb-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.9); backdrop-filter: blur(8px); }
.lb-dialog {
  position: relative; z-index: 1; width: min(920px, 100%); max-height: 94dvh;
  background: #0b0b0e; border: 1px solid rgba(255, 255, 255, 0.16); border-radius: 16px;
  overflow: hidden; display: flex; flex-direction: column;
}
.lb-head { padding: 12px 16px; border-bottom: 1px solid rgba(255, 255, 255, 0.08); display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.lb-head-left { display: flex; align-items: center; gap: 8px; min-width: 0; }
.lb-head-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.lb-counter { font-family: var(--font-mono); font-size: 11px; color: var(--muted); padding: 2px 7px; border-radius: 5px; background: rgba(255, 255, 255, 0.06); flex-shrink: 0; }
.lb-title { margin: 0; font-size: 14.5px; font-weight: 600; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-close { width: 34px; height: 34px; border-radius: 8px; border: 1px solid rgba(255, 255, 255, 0.14); background: rgba(255, 255, 255, 0.05); color: #fff; cursor: pointer; font-size: 15px; flex-shrink: 0; }
.lb-stage { position: relative; flex: 1; min-height: 0; overflow: auto; padding: 16px 54px; display: flex; align-items: flex-start; justify-content: center; background: #050507; }
.lb-img-box { max-width: 720px; width: 100%; display: flex; justify-content: center; }
.lb-img-box img { display: block; max-width: 100%; width: auto; height: auto; border-radius: 10px; }
.lb-nav {
  position: fixed; top: 50%; transform: translateY(-50%); width: 40px; height: 40px; border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.2); background: rgba(15, 15, 18, 0.92); color: #fff; font-size: 24px;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
}
.lb-prev { left: max(12px, calc(50% - 452px)); }
.lb-next { right: max(12px, calc(50% - 452px)); }
.lb-nav:hover { background: var(--cobalt); border-color: var(--cobalt); }
.lb-foot {
  padding: 12px 16px max(12px, env(safe-area-inset-bottom)); border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: #0c0c10;
}
.lb-foot-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.lb-mobile-nav { display: none; gap: 6px; }
.lb-actions { display: flex; gap: 8px; flex-wrap: wrap; flex: 1; }

.toast {
  position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 120;
  padding: 9px 16px; border-radius: 10px; background: #18181b; color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.18); font-size: 13px; font-weight: 500;
  max-width: calc(100vw - 32px); text-align: center;
}

@media (max-width: 640px) {
  .container { padding: 0 16px; }
  .nav-inner { flex-wrap: wrap; min-height: 0; padding: 8px 14px 0; row-gap: 6px; gap: 8px 10px; }
  .lang-picker { padding: 4px 8px; }
  .lang-select { max-width: 148px; font-size: 13px; }
  .nav-links {
    flex: 1 0 100%; margin: 2px -14px 0; padding: 8px 14px;
    border-top: 1px solid rgba(255, 255, 255, 0.07);
    overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
    gap: 16px; font-size: 13px;
  }
  .nav-links::-webkit-scrollbar { display: none; }

  .story-hero { padding: 24px 0 16px; }
  .podcast-card { padding: 12px; }
  .reader-bar { top: 84px; }
  .reader-bar-inner { justify-content: flex-start; }

  .ep-head { padding: 14px 15px 12px; }
  .ep-media-btn { padding: 8px; }
  .ep-foot { padding: 10px 12px; }
  .story-cta-box { padding: 22px 16px; }
  .story-cta-actions { flex-direction: column; width: 100%; }
  .story-cta-actions > * { width: 100%; }
  .footer-inner { flex-direction: column; align-items: flex-start; gap: 10px; }

  .lb { padding: 10px; }
  .lb-dialog { max-height: 94dvh; border-radius: 14px; }
  .lb-head { padding: 10px 12px; }
  .lb-title { font-size: 13.5px; }
  .lb-stage { padding: 10px; }
  .lb-nav { display: none; }
  .lb-mobile-nav { display: inline-flex; }
  .lb-foot { padding: 10px 12px max(10px, env(safe-area-inset-bottom)); }
  .act-btn { padding: 5px 9px; font-size: 12px; }
}
