:root {
  color-scheme: dark;
  --bg: #0f0b08;
  --bg-strong: #17110d;
  --panel: rgba(29, 21, 16, 0.88);
  --panel-strong: rgba(39, 28, 21, 0.95);
  --panel-soft: rgba(80, 60, 45, 0.24);
  --border: rgba(225, 198, 158, 0.16);
  --border-strong: rgba(225, 198, 158, 0.28);
  --text: #f4ecdf;
  --muted: #c3b39a;
  --accent: #d6aa6c;
  --accent-strong: #f4d39d;
  --accent-shadow: rgba(214, 170, 108, 0.28);
  --chip: rgba(255, 245, 230, 0.08);
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
  --reader-max: 920px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(228, 182, 119, 0.22), transparent 24%),
    radial-gradient(circle at 85% 16%, rgba(150, 92, 54, 0.24), transparent 22%),
    linear-gradient(180deg, #17110d 0%, #0f0b08 42%, #16100c 100%);
  font-family:
    "Avenir Next",
    "Segoe UI",
    sans-serif;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0.02)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180' viewBox='0 0 180 180'%3E%3Cg fill='none' stroke='%23f0d0a0' stroke-opacity='0.1'%3E%3Cpath d='M12 38c25-13 52-13 81 0s56 13 83 0'/%3E%3Cpath d='M-18 96c38-19 74-19 113 0s75 19 113 0'/%3E%3Cpath d='M22 148c21-10 40-10 61 0s40 10 61 0'/%3E%3C/g%3E%3C/svg%3E");
  opacity: 0.72;
}

button,
select {
  font: inherit;
}

.site-shell {
  position: relative;
  z-index: 1;
  padding: 20px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
  padding: 14px 18px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: linear-gradient(135deg, rgba(29, 21, 16, 0.95), rgba(48, 34, 25, 0.9));
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.episode-rail,
.hero-card,
.summary-card,
.comments-card {
  border: 1px solid var(--border);
  border-radius: 24px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.toolbar-label,
.eyebrow,
.hero-kicker {
  margin: 0;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.76rem;
  font-weight: 800;
}

.brand-subtitle,
.hero-subtitle,
.summary-text {
  color: var(--muted);
}

h1,
h2 {
  margin: 0;
  line-height: 1.04;
  font-family:
    "Iowan Old Style",
    "Palatino Linotype",
    "Book Antiqua",
    serif;
  font-weight: 700;
}

h1 {
  font-size: clamp(1.3rem, 2vw, 1.9rem);
}

h2 {
  font-size: clamp(1.8rem, 2.8vw, 2.6rem);
}

.topbar h1 {
  flex: 1;
}

.toolbar-inline {
  display: flex;
  align-items: end;
  gap: 10px;
}

.toolbar-field {
  display: grid;
  gap: 6px;
  min-width: 150px;
}

.brand-subtitle,
.hero-subtitle {
  margin: 10px 0 0;
  font-size: 1rem;
  line-height: 1.55;
  max-width: 66ch;
}

.episode-button,
.nav-button {
  border: 0;
  cursor: pointer;
}

.episode-button:hover,
.nav-button:hover {
  transform: translateY(-1px);
}

#language-select,
#episode-select {
  min-width: 0;
  padding: 11px 40px 11px 14px;
  color: var(--text);
  border-radius: 14px;
  border: 1px solid var(--border);
  background:
    linear-gradient(135deg, rgba(255, 245, 230, 0.08), rgba(214, 170, 108, 0.08));
  appearance: none;
}

.content-shell {
  display: grid;
  grid-template-columns: minmax(280px, 320px) minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

.episode-rail {
  position: sticky;
  top: 96px;
  padding: 18px;
  max-height: calc(100vh - 164px);
  overflow: auto;
  background:
    linear-gradient(180deg, rgba(29, 21, 16, 0.98), rgba(24, 18, 14, 0.94));
}

.rail-header {
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.rail-header h2 {
  font-size: 1.35rem;
  margin-top: 8px;
}

.episode-nav {
  display: grid;
  gap: 10px;
  padding-top: 14px;
}

.episode-button {
  text-align: left;
  padding: 14px;
  border-radius: 18px;
  background: rgba(255, 245, 230, 0.04);
  border: 1px solid transparent;
  transition:
    transform 140ms ease,
    border-color 140ms ease,
    background 140ms ease;
}

.episode-button.active {
  border-color: var(--border-strong);
  background: linear-gradient(135deg, rgba(214, 170, 108, 0.16), rgba(96, 63, 35, 0.16));
}

.episode-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 40px;
  margin-bottom: 10px;
  border-radius: 999px;
  background: rgba(214, 170, 108, 0.16);
  color: var(--accent-strong);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.episode-card-title {
  display: block;
  margin-bottom: 5px;
  font-family:
    "Iowan Old Style",
    "Palatino Linotype",
    "Book Antiqua",
    serif;
  font-size: 1.08rem;
  font-weight: 700;
  color: var(--text);
}

.episode-card-subtitle,
.episode-card-meta {
  display: block;
  color: var(--muted);
  line-height: 1.5;
}

.episode-card-subtitle {
  font-size: 0.92rem;
}

.episode-card-meta {
  margin-top: 8px;
  font-size: 0.84rem;
}

.reader-shell {
  display: grid;
  gap: 16px;
}

.hero-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 22px 24px;
  background:
    radial-gradient(circle at top right, rgba(214, 170, 108, 0.16), transparent 34%),
    linear-gradient(135deg, rgba(31, 23, 18, 0.98), rgba(51, 36, 25, 0.92));
}

.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.meta-pill {
  padding: 10px 12px;
  border-radius: 999px;
  background: rgba(255, 245, 230, 0.08);
  color: var(--muted);
  white-space: nowrap;
}

.summary-card {
  padding: 18px 20px;
  background: linear-gradient(180deg, rgba(37, 27, 21, 0.94), rgba(28, 21, 16, 0.88));
}

.comments-card {
  padding: 20px;
  background: linear-gradient(180deg, rgba(31, 23, 18, 0.98), rgba(26, 19, 14, 0.92));
}

.summary-text {
  margin: 0;
  line-height: 1.7;
  font-size: 1rem;
}

.reader-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.nav-button {
  padding: 12px 16px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(214, 170, 108, 0.2), rgba(244, 211, 157, 0.1));
  color: var(--text);
  font-weight: 700;
  border: 1px solid var(--border);
}

.nav-button:disabled {
  opacity: 0.42;
  cursor: not-allowed;
  transform: none;
}

.slice-stack {
  width: min(100%, var(--reader-max));
  margin: 0 auto;
  display: grid;
  gap: 0;
}

.slice-frame {
  margin: 0;
}

.slice-link {
  display: block;
  overflow: hidden;
  border-radius: 0;
  border: 0;
  background: transparent;
}

.slice-image {
  display: block;
  width: 100%;
  height: auto;
}

.video-frame {
  width: min(100%, 1080px);
  margin: 0 auto;
}

.video-shell {
  position: relative;
  background: #000;
}

.episode-video {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  background: #000;
}

.media-start-button {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  min-height: 44px;
  padding: 12px 16px;
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  background: rgba(15, 11, 8, 0.86);
  color: var(--text);
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.32);
}

.media-start-button:hover {
  transform: translateX(-50%) translateY(-1px);
}

.media-start-button[hidden] {
  display: none;
}

.comments-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.comments-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(280px, 0.85fr);
  gap: 16px;
}

.comments-feed,
.comment-form-card {
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(255, 245, 230, 0.04);
}

.comments-feed {
  padding: 16px;
}

.comments-empty {
  margin: 0;
  color: var(--muted);
}

.comments-list {
  display: grid;
  gap: 12px;
}

.comment-item {
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(255, 245, 230, 0.05);
  border: 1px solid rgba(225, 198, 158, 0.08);
}

.comment-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.comment-author {
  font-size: 1rem;
}

.comment-date,
.comment-country,
.comment-status {
  color: var(--muted);
}

.comment-country,
.comment-body {
  margin: 8px 0 0;
}

.comment-body {
  white-space: pre-wrap;
  line-height: 1.65;
}

.comment-form-card {
  padding: 16px;
}

.comment-form {
  display: grid;
  gap: 14px;
}

.comment-field {
  display: grid;
  gap: 8px;
  font-weight: 700;
}

.comment-field input,
.comment-field textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(255, 245, 230, 0.08);
  color: var(--text);
}

.comment-field textarea {
  resize: vertical;
  min-height: 132px;
}

.captcha-box {
  display: grid;
  gap: 10px;
}

.captcha-art {
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  border-radius: 14px;
  background: rgba(255, 245, 230, 0.06);
  border: 1px solid var(--border);
}

.captcha-art svg {
  display: block;
  width: 100%;
  max-width: 180px;
  height: auto;
}

.subtle-button {
  justify-self: start;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  background: rgba(255, 245, 230, 0.05);
  color: var(--muted);
  cursor: pointer;
}

.comment-status {
  min-height: 1.4em;
  margin: 0;
  font-size: 0.95rem;
}

.comment-status.error {
  color: #f3a9a9;
}

.comment-status.success {
  color: #a7ddb4;
}

.honeypot {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.desktop-only {
  display: block;
}

.mobile-only {
  display: none;
}

body[data-dir="rtl"] .topbar,
body[data-dir="rtl"] .toolbar-field,
body[data-dir="rtl"] .rail-header,
body[data-dir="rtl"] .episode-button,
body[data-dir="rtl"] .hero-copy,
body[data-dir="rtl"] .summary-card,
body[data-dir="rtl"] .slice-frame,
body[data-dir="rtl"] .comments-card,
body[data-dir="rtl"] .comment-item,
body[data-dir="rtl"] .comment-form {
  text-align: right;
}

body[data-dir="rtl"] .hero-meta {
  justify-content: flex-start;
}

@media (max-width: 980px) {
  .content-shell {
    grid-template-columns: 1fr;
  }

  .topbar {
    flex-direction: column;
    align-items: stretch;
    position: static;
  }

  .desktop-only {
    display: none;
  }

  .mobile-only {
    display: grid;
  }

  .toolbar-inline {
    width: 100%;
  }

  .toolbar-field {
    flex: 1;
  }

  .hero-card {
    flex-direction: column;
  }

  .hero-meta {
    justify-content: flex-start;
  }

  .comments-grid {
    grid-template-columns: 1fr;
  }

}

@media (max-width: 640px) {
  .site-shell {
    padding: 12px;
  }

  .topbar {
    padding: 12px 14px;
    border-radius: 16px;
  }

  .hero-card,
  .summary-card,
  .comments-card {
    border-radius: 20px;
  }

  .toolbar-inline {
    flex-direction: column;
    align-items: stretch;
  }

  .comments-card {
    padding: 16px;
  }

  .comments-header,
  .comment-meta {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 980px) {
  .slice-stack {
    width: 100vw;
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);
  }
}
