/* Design system: warm charcoal, cream, gold — warmer feel with transitioning gradients */
/* Inter = UI/headings, Lora = reading content */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Lora:ital,wght@0,400;0,600;0,700;1,400&family=Merriweather:ital,wght@0,400;0,700;1,400&display=swap');

:root {
  --charcoal: #1a1814;
  --charcoal-deep: #141210;
  --off-white: #e8e4dc;
  --gold: #c9a227;
  --gold-hover: #b8921f;
  --gold-muted: rgba(201, 162, 39, 0.18);
  --warm-1: #2c261e;
  --warm-2: #1f1c17;
  --warm-3: #251f18;
  --warm-glow: rgba(201, 162, 39, 0.08);
  /* Safe areas for notched / rounded devices */
  --safe-top: env(safe-area-inset-top, 0);
  --safe-right: env(safe-area-inset-right, 0);
  --safe-bottom: env(safe-area-inset-bottom, 0);
  --safe-left: env(safe-area-inset-left, 0);
}

* { box-sizing: border-box; }

html {
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
  /* App-like: use dynamic viewport on mobile */
  min-height: 100dvh;
  min-height: -webkit-fill-available;
}

body {
  font-family: 'Inter', system-ui, sans-serif;
  background-color: var(--charcoal);
  color: var(--off-white);
  margin: 0;
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
  padding-bottom: var(--safe-bottom);
  min-height: 100vh;
  min-height: 100dvh;
  min-height: -webkit-fill-available;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

/* Transitioning warm gradients (layered, no image) */
body::before {
  content: '';
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0;
  z-index: -2;
  background: linear-gradient(
    165deg,
    var(--charcoal-deep) 0%,
    var(--warm-2) 25%,
    var(--warm-3) 50%,
    var(--charcoal) 75%,
    var(--warm-1) 100%
  );
  background-size: 100% 200%;
  animation: gradient-shift 18s ease-in-out infinite alternate;
}

body::after {
  content: '';
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0;
  z-index: -1;
  background: radial-gradient(
    ellipse 120% 80% at 50% -20%,
    var(--warm-glow) 0%,
    transparent 50%
  );
  pointer-events: none;
}

@keyframes gradient-shift {
  0% { background-position: 0% 0%; }
  100% { background-position: 0% 100%; }
}

/* Sticky header: respect safe area at top (notched devices) */
header:first-of-type {
  padding-top: var(--safe-top);
}

main { flex: 1; }

a { color: inherit; text-decoration: none; }
a:hover { color: var(--gold); }

/* Skip link: visible when focused (keyboard/screen reader users) */
.skip-link {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 200;
  padding: 0.75rem 1.25rem;
  background: var(--gold);
  color: var(--charcoal);
  font-weight: 600;
  text-decoration: none;
  border-radius: 0 0 0.375rem 0;
  transform: translateY(-100%);
  transition: transform 0.2s ease;
}
.skip-link:focus {
  transform: translateY(0);
  outline: 2px solid var(--off-white);
  outline-offset: 2px;
}

/* Visible focus for keyboard users (don’t rely on color alone) */
a:focus-visible,
button:focus-visible,
summary:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/* Respect reduced motion — no shifting gradient */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .skip-link { transition: none; }
  body::before {
    animation: none;
    background-position: 0% 50%;
  }
}

/* Buttons */
.btn-primary {
  display: inline-block;
  background: var(--gold);
  color: var(--charcoal);
  font-weight: 600;
  padding: 0.75rem 1.5rem;
  border-radius: 0.375rem;
  border: none;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.2s;
}
.btn-primary:hover { background: var(--gold-hover); }

.btn-secondary {
  display: inline-block;
  background: transparent;
  color: var(--gold);
  font-weight: 600;
  padding: 0.75rem 1.5rem;
  border-radius: 0.375rem;
  border: 2px solid var(--gold);
  cursor: pointer;
  font-family: inherit;
  transition: background 0.2s;
}
.btn-secondary:hover { background: var(--gold-muted); }

/* Form inputs */
.input-field {
  width: 100%;
  background: var(--charcoal);
  border: 1px solid rgba(232, 228, 220, 0.3);
  color: var(--off-white);
  padding: 0.75rem 1rem;
  border-radius: 0.375rem;
  font-family: inherit;
}
.input-field::placeholder { color: rgba(232, 228, 220, 0.5); }
.input-field:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 2px var(--gold-muted);
}

/* Reader content — base (overridden by card rules below) */

/* ========== Reader settings: theme, font size, font ========== */
.reader-settings-panel {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-width: 12rem;
}
.reader-settings-panel label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: inherit;
  opacity: 0.8;
}
.reader-settings-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.reader-settings-panel select {
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  border: 1px solid rgba(0,0,0,0.15);
  border-radius: 0.375rem;
  background: inherit;
  color: inherit;
  cursor: pointer;
  font-family: inherit;
}
body.reader-page .reader-settings-panel select {
  border-color: rgba(232,228,220,0.3);
}
/* Settings dropdown panel - always dark (in header) */
body.reader-page .reader-settings-panel { background: #1a1814; border-color: rgba(232,228,220,0.15); color: #e8e4dc; }
body.reader-page .reader-settings-panel select { background: #2c261e; color: #e8e4dc; }

/* Reader page: body, header, footer always dark */
body.reader-page { background: #1a1814 !important; color: #e8e4dc; }
body.reader-page .reader-header { background: rgba(26,24,20,0.95) !important; border-color: rgba(232,228,220,0.1) !important; color: #e8e4dc; }
body.reader-page .reader-footer { background: #1a1814 !important; border-color: rgba(232,228,220,0.1) !important; color: #e8e4dc; }
body.reader-page .reader-footer a[href] { color: #c9a227; }

/* Reader panel: always dark, just a scroll wrapper */
#reader-panel { flex: 1; min-height: 0; background: #1a1814; }

/* Reader content card: the text box that receives theme background */
.reader-content {
  max-width: 42rem;
  margin: 0 auto;
  padding: 2rem 2.25rem;
  border-radius: 0.75rem;
  line-height: 1.75;
  transition: background-color 0.2s ease, color 0.2s ease;
}

/* Discourage copying chapter text (deterrent; not full DRM) */
body.reader-page .reader-content,
body.reader-page .reader-content * {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
body.reader-page .reader-content::selection,
body.reader-page .reader-content *::selection {
  background: transparent;
  color: inherit;
}

/* Theme backgrounds — classes applied directly on .reader-content */
.reader-content.reader-theme-default { background: #232019 !important; color: #e8e4dc !important; }
.reader-content.reader-theme-default em { color: rgba(232,228,220,0.9); }

.reader-content.reader-theme-white { background: #ffffff !important; color: #1a1a1a !important; }
.reader-content.reader-theme-white em { color: #333; }

.reader-content.reader-theme-sepia { background: #f4ecd8 !important; color: #2c2419 !important; }
.reader-content.reader-theme-sepia em { color: #3d3225; }

/* Font size — classes applied directly on .reader-content */
.reader-content.reader-size-small { font-size: 1rem !important; }
.reader-content.reader-size-small h2 { font-size: 1.125rem !important; }
.reader-content.reader-size-medium { font-size: 1.125rem !important; }
.reader-content.reader-size-medium h2 { font-size: 1.25rem !important; }
.reader-content.reader-size-large { font-size: 1.25rem !important; }
.reader-content.reader-size-large h2 { font-size: 1.375rem !important; }

/* Font family — classes applied directly on .reader-content */
.reader-content.reader-font-lora { font-family: 'Lora', Georgia, serif !important; }
.reader-content.reader-font-georgia { font-family: Georgia, 'Times New Roman', serif !important; }
.reader-content.reader-font-inter { font-family: 'Inter', system-ui, sans-serif !important; }
.reader-content.reader-font-merriweather { font-family: 'Merriweather', Georgia, serif !important; }

/* Hide mobile menu by default; show when details open */
nav .mobile-menu { display: none; }
@media (max-width: 767px) {
  nav .desktop-links { display: none !important; }
  nav .mobile-menu {
    display: block;
    position: relative;
  }
  nav .mobile-trigger { display: inline-flex; }
  /* Dropdown panel: overlay below header, no stretch */
  nav .mobile-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.25rem;
    min-width: 12rem;
    padding: 0.5rem 0;
    background: var(--charcoal);
    border: 1px solid rgba(232, 228, 220, 0.15);
    border-radius: 0.5rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
    z-index: 60;
  }
}
nav .mobile-trigger { display: none; }

.news-card {
  border: 1px solid rgba(224, 224, 224, 0.1);
  border-radius: 0.5rem;
  padding: 1.5rem;
  background: var(--charcoal);
  transition: border-color 0.2s, background 0.2s;
}
.news-card:hover {
  border-color: rgba(201, 162, 39, 0.45);
  background: var(--gold-muted);
}

.chapter-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid rgba(224, 224, 224, 0.05);
  transition: background 0.2s;
}
.chapter-row:hover { background: var(--gold-muted); }
.chapter-row a { color: var(--off-white); }
.chapter-row:hover a { color: var(--gold); }

/* ========== Mobile & small screens — App-like styling ========== */

/* App shell on mobile: smooth scroll */
@media (max-width: 767px) {
  main {
    -webkit-overflow-scrolling: touch;
  }
}

/* Touch-friendly targets and spacing (phones) */
@media (max-width: 767px) {
  nav {
    padding: 0.75rem 1rem !important;
  }

  .mobile-trigger {
    min-height: 44px;
    min-width: 44px;
    padding: 0.75rem !important;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
  }

  .mobile-dropdown a {
    padding: 0.75rem 1rem !important;
    min-height: 44px;
    display: flex !important;
    align-items: center;
    -webkit-tap-highlight-color: transparent;
  }

  .btn-primary,
  .btn-secondary {
    min-height: 48px;
    padding: 0.875rem 1.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
  }

  .chapter-row {
    min-height: 48px;
    padding: 0.875rem 1rem;
    flex-wrap: wrap;
    -webkit-tap-highlight-color: transparent;
  }

  .chapter-row span:first-of-type {
    flex: 1;
    min-width: 0;
  }

  main {
    padding-left: 1rem !important;
    padding-right: 1rem !important;
  }

  .reader-content {
    padding: 0 0.25rem;
    font-size: 1.0625rem;
  }

  /* App-like header: rounded bottom, subtle shadow */
  body > header:first-of-type {
    border-radius: 0 0 1rem 1rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  }

  /* Main content: comfortable app padding */
  main {
    padding-left: 1.25rem !important;
    padding-right: 1.25rem !important;
    padding-bottom: 1.5rem !important;
  }

  /* Cards: app-style rounded corners */
  .news-card,
  .chapter-row {
    border-radius: 0.75rem;
  }
  .news-card {
    padding: 1.25rem;
  }
}

/* Reader pages: mobile — native body scroll with sticky header */
@media (max-width: 767px) {
  html.reader-page-html {
    height: auto;
  }
  body.reader-page {
    display: block;
    height: auto;
    min-height: 100dvh;
    min-height: 100vh;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  body.reader-page > header,
  body.reader-page > .reader-header {
    position: sticky;
    top: 0;
    z-index: 40;
    border-radius: 0 0 0.75rem 0.75rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
  }
  body.reader-page > #reader-panel {
    overflow: visible;
    min-height: 0;
  }
  body.reader-page #reader-panel article {
    padding: 1.5rem 1.25rem 1rem !important;
  }
  body.reader-page .reader-footer {
    padding: 1.25rem 1.25rem !important;
    padding-bottom: calc(1.25rem + var(--safe-bottom)) !important;
    background: transparent;
    border-top: 1px solid rgba(232, 228, 220, 0.1);
  }

  /* Reader content card: mobile sizing */
  .reader-content {
    font-size: 1.125rem !important;
    line-height: 1.85 !important;
    max-width: 100%;
    margin: 0 auto;
    padding: 1.5rem 1.25rem !important;
    border-radius: 0.625rem;
  }
  .reader-content p {
    margin-bottom: 1.25rem;
  }
  .reader-content h2 {
    font-size: 1.25rem !important;
    margin-bottom: 1.25rem !important;
  }

  /* Reader settings: prevent overflow on small screens */
  body.reader-page .reader-settings-panel {
    max-width: calc(100vw - 2rem);
    right: 0;
    left: auto;
  }
  /* Reader nav links inside footer */
  body.reader-page .reader-footer > div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    max-width: 100%;
  }
  body.reader-page .reader-footer a {
    padding: 0.5rem 0.75rem;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }
}

/* Form inputs: prevent zoom on focus (iOS) and comfortable touch size */
.input-field {
  min-height: 48px;
  font-size: 16px;
}
@media (max-width: 767px) {
  .input-field {
    min-height: 48px;
    padding: 0.875rem 1rem;
  }

  textarea.input-field {
    min-height: 120px;
  }

  select.input-field {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23e8e4dc' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    padding-right: 2.5rem;
  }
}

/* Forms: stack and full width on small screens */
@media (max-width: 480px) {
  form {
    flex-direction: column !important;
  }

  form .input-field,
  form input[type="email"],
  form button[type="submit"] {
    max-width: none !important;
    width: 100% !important;
    min-width: 0 !important;
  }
}

/* Very small phones: tighter spacing, single-column layout */
@media (max-width: 480px) {
  body {
    font-size: 15px;
  }

  section {
    padding-top: 2rem !important;
    padding-bottom: 2rem !important;
    padding-left: 1rem !important;
    padding-right: 1rem !important;
  }

  h1 {
    font-size: 1.5rem !important;
    line-height: 1.3 !important;
  }

  h2 {
    font-size: 1.375rem !important;
  }

  body:not(.reader-page) footer,
  body:not(.reader-page) footer > div {
    flex-direction: column;
    text-align: center;
    padding: 1.5rem 1rem !important;
    gap: 1rem;
  }

  body:not(.reader-page) footer a {
    padding: 0.25rem 0;
  }
}

/* Reader content on non-reader pages (e.g. book-info): mobile */
@media (max-width: 767px) {
  body:not(.reader-page) .reader-content {
    font-size: 1.0625rem;
    line-height: 1.75;
  }
  body:not(.reader-page) article {
    padding: 1.5rem 1rem !important;
  }
}

/* Prevent long words from breaking layout */
.reader-content p,
.news-card p,
.news-card h3 {
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* Blog intro popup: blurred overlay, shown when URL has #about-blog */
.blog-overlay {
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: rgba(26, 24, 20, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
  pointer-events: none;
}
.blog-overlay:target {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}
.blog-overlay__card {
  max-width: 36rem;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 2rem;
  background: var(--charcoal);
  border: 1px solid rgba(224, 224, 224, 0.15);
  border-radius: 0.5rem;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}
.blog-overlay__card h2 {
  margin: 0 0 1rem;
  font-size: 1.5rem;
  color: var(--off-white);
}
.blog-overlay__card p {
  margin: 0 0 1.5rem;
  line-height: 1.7;
  color: rgba(232, 228, 220, 0.9);
}
.blog-overlay__card .btn-primary {
  display: inline-block;
}

.blog-overlay__card h2:first-child {
  margin-top: 0;
}

/* ========== Reactions bar ========== */
.reactions-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(224, 224, 224, 0.1);
}
.reaction-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.7rem;
  border: 1px solid rgba(224, 224, 224, 0.15);
  border-radius: 2rem;
  background: transparent;
  color: rgba(224, 224, 224, 0.7);
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
  line-height: 1;
}
.reaction-btn:hover {
  background: rgba(201, 162, 39, 0.1);
  border-color: rgba(201, 162, 39, 0.3);
}
.reaction-btn.active {
  background: rgba(201, 162, 39, 0.18);
  border-color: var(--gold);
  color: var(--gold);
}
.reaction-btn .reaction-emoji {
  font-size: 1.05rem;
}
.reaction-btn .reaction-count {
  font-size: 0.75rem;
  font-weight: 600;
  min-width: 0.8rem;
  text-align: center;
}
.reaction-btn:disabled {
  cursor: default;
  opacity: 0.7;
}

/* ========== Comments section ========== */
.comments-section {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(224, 224, 224, 0.1);
}
.comments-section h3 {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--off-white);
  margin: 0 0 0.75rem;
}
.comments-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 18rem;
  overflow-y: auto;
  padding-right: 0.25rem;
}
.comment-item {
  padding: 0.75rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(224, 224, 224, 0.07);
  border-radius: 0.4rem;
}
.comment-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
  font-size: 0.75rem;
  color: rgba(224, 224, 224, 0.5);
}
.comment-author {
  font-weight: 600;
  color: var(--gold);
}
.comment-body {
  font-size: 0.875rem;
  line-height: 1.6;
  color: rgba(232, 228, 220, 0.85);
  margin: 0;
  white-space: pre-line;
}
.comment-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.75rem;
}
.comment-form textarea {
  width: 100%;
  min-height: 3.5rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid rgba(224, 224, 224, 0.15);
  border-radius: 0.4rem;
  background: rgba(0, 0, 0, 0.25);
  color: var(--off-white);
  font-family: inherit;
  font-size: 0.875rem;
  resize: vertical;
}
.comment-form textarea:focus {
  outline: none;
  border-color: var(--gold);
}
.comment-form button {
  align-self: flex-end;
  padding: 0.4rem 1rem;
  border: none;
  border-radius: 0.3rem;
  background: var(--gold);
  color: var(--charcoal);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}
.comment-form button:hover {
  background: var(--gold-hover);
}
.comment-form button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.comments-login-prompt {
  font-size: 0.8rem;
  color: rgba(224, 224, 224, 0.5);
  margin-top: 0.75rem;
}
.comments-login-prompt a {
  color: var(--gold);
}
.comments-empty {
  font-size: 0.8rem;
  color: rgba(224, 224, 224, 0.4);
  font-style: italic;
}

/* ========== Discussion-style comments (cards, votes, likes, reply) ========== */
.discussion-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.discussion-header h3 {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--off-white, #e8e4dc);
}
.discussion-compose {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(224, 224, 224, 0.1);
  overflow: visible;
  border-radius: 0.5rem;
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}
.discussion-compose-inner {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
}
.discussion-compose .comment-avatar {
  flex-shrink: 0;
}
.discussion-compose .comment-input-wrap {
  flex: 1;
  min-width: 0;
}
.discussion-compose textarea {
  width: 100%;
  min-height: 5rem;
  padding: 0.75rem 1rem;
  border: 1px solid rgba(224, 224, 224, 0.15);
  border-radius: 0.375rem;
  background: rgba(0, 0, 0, 0.25);
  color: var(--off-white);
  font-family: inherit;
  font-size: 0.9375rem;
  resize: vertical;
  transition: border-color 0.2s;
}
.discussion-compose textarea::placeholder {
  color: rgba(224, 224, 224, 0.4);
}
.discussion-compose textarea:focus {
  outline: none;
  border-color: var(--gold);
}
.discussion-compose-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}
.discussion-send-btn {
  padding: 0.5rem 1.25rem;
  border: none;
  border-radius: 0.375rem;
  background: var(--gold, #c9a227);
  color: #1a1814;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  width: 100%;
  max-width: 12rem;
}
.discussion-send-btn:hover {
  background: var(--gold-hover, #b8921f);
}
.discussion-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.discussion-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.comment-card {
  display: flex;
  flex-direction: row;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(224, 224, 224, 0.08);
  border-radius: 0.5rem;
  margin-bottom: 0.75rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}
.comment-card.is-reply {
  margin-left: 2rem;
  border-left: 2px solid rgba(201, 162, 39, 0.3);
}
.comment-vote-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.125rem;
  flex-shrink: 0;
}
.comment-vote-col button {
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  border: none;
  border-radius: 0.25rem;
  background: transparent;
  color: rgba(224, 224, 224, 0.5);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, background 0.2s;
}
.comment-vote-col button:hover:not(:disabled) {
  color: var(--gold);
  background: rgba(201, 162, 39, 0.1);
}
.comment-vote-col button:disabled {
  opacity: 0.4;
  cursor: default;
}
.comment-vote-col button.voted {
  color: var(--gold);
}
.comment-vote-count {
  font-size: 0.75rem;
  font-weight: 600;
  color: rgba(224, 224, 224, 0.7);
  min-width: 1.5rem;
  text-align: center;
}
.comment-body-col {
  flex: 1;
  min-width: 0;
}
.comment-card .comment-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
  flex-wrap: wrap;
}
.comment-card .comment-meta .comment-avatar {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(201, 162, 39, 0.4), rgba(201, 162, 39, 0.15));
  color: var(--off-white);
  font-size: 0.75rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.comment-card .comment-author {
  font-weight: 600;
  color: var(--off-white);
  font-size: 0.875rem;
}
.comment-card .comment-date {
  font-size: 0.75rem;
  color: rgba(224, 224, 224, 0.45);
}
.comment-card .comment-menu-btn {
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  margin-left: auto;
  border: none;
  border-radius: 0.25rem;
  background: transparent;
  color: rgba(224, 224, 224, 0.4);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, background 0.2s;
}
.comment-card .comment-menu-btn:hover {
  color: var(--off-white);
  background: rgba(255, 255, 255, 0.08);
}
.comment-card .comment-body {
  font-size: 0.9375rem;
  line-height: 1.6;
  color: rgba(232, 228, 220, 0.9);
  margin: 0 0 0.5rem;
  white-space: pre-line;
}
.comment-card-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.8125rem;
}
.comment-like-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0;
  border: none;
  background: transparent;
  color: rgba(224, 224, 224, 0.5);
  cursor: pointer;
  font-size: inherit;
  transition: color 0.2s;
}
.comment-like-btn:hover {
  color: rgba(232, 100, 100, 0.9);
}
.comment-like-btn.liked {
  color: #e86464;
}
.comment-reply-btn {
  background: none;
  border: none;
  padding: 0.25rem 0;
  color: var(--gold);
  cursor: pointer;
  font-size: inherit;
  text-decoration: none;
}
.comment-reply-btn:hover {
  text-decoration: underline;
}
.comment-menu-wrap {
  position: relative;
  margin-left: auto;
}
.comment-menu-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 0.25rem;
  min-width: 7rem;
  padding: 0.25rem;
  background: rgba(26, 24, 20, 0.98);
  border: 1px solid rgba(224, 224, 224, 0.15);
  border-radius: 0.375rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  z-index: 10;
}
.comment-menu-dropdown[hidden] {
  display: none;
}
.comment-menu-delete {
  display: block;
  width: 100%;
  padding: 0.4rem 0.75rem;
  border: none;
  border-radius: 0.25rem;
  background: transparent;
  color: rgba(232, 100, 100, 0.95);
  font-size: 0.8125rem;
  text-align: left;
  cursor: pointer;
}
.comment-menu-delete:hover {
  background: rgba(232, 100, 100, 0.15);
}
.discussion-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  max-height: none;
  overflow-y: visible;
  padding-right: 0;
}

/* ========== Table of Contents overlay (reader pages) ========== */
.toc-overlay {
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0;
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
  pointer-events: none;
}
.toc-overlay.toc-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.toc-panel {
  width: 100%;
  max-width: 32rem;
  max-height: 75vh;
  background: #1e1b16;
  border: 1px solid rgba(232, 228, 220, 0.12);
  border-radius: 1rem 1rem 0 0;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.toc-open .toc-panel {
  transform: translateY(0);
}

.toc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid rgba(232, 228, 220, 0.1);
  flex-shrink: 0;
}
.toc-header h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--off-white);
}
.toc-close {
  background: none;
  border: none;
  color: rgba(232, 228, 220, 0.6);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  line-height: 1;
  border-radius: 0.25rem;
}
.toc-close:hover { color: var(--off-white); }

.toc-list {
  list-style: none;
  margin: 0;
  padding: 0.5rem 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.toc-list > li > a,
.toc-sublist > li > a {
  display: block;
  padding: 0.625rem 1.25rem;
  font-size: 0.9375rem;
  color: rgba(232, 228, 220, 0.8);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}
.toc-list > li > a:hover,
.toc-sublist > li > a:hover {
  background: rgba(201, 162, 39, 0.1);
  color: var(--gold);
}
.toc-list a.toc-active {
  color: var(--gold);
  font-weight: 600;
  background: rgba(201, 162, 39, 0.08);
}

.toc-group-title {
  display: block;
  padding: 0.75rem 1.25rem 0.25rem;
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--gold);
}
.toc-sublist {
  list-style: none;
  margin: 0;
  padding: 0;
}
.toc-sublist > li > a {
  padding-left: 2rem;
  font-size: 0.875rem;
}

@media (min-width: 768px) {
  .toc-overlay { align-items: center; }
  .toc-panel {
    border-radius: 0.75rem;
    max-height: 60vh;
    transform: translateY(2rem);
  }
  .toc-open .toc-panel { transform: translateY(0); }
}
