*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Georgia, sans-serif;
  background: #fafafa;
  color: #18181b;
  line-height: 1.6;
}
a { color: inherit; }
.container { max-width: 1120px; margin: 0 auto; padding: 0 18px; }

/* Header */
.site-header {
  position: sticky; top: 0; z-index: 30;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid #e4e4e7;
}
.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  height: 60px; gap: 16px;
}
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 800; font-size: 1.15rem; letter-spacing: -0.02em; }
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--accent); color: #fff; font-weight: 900;
}
.main-nav { display: flex; gap: 18px; font-size: 0.95rem; font-weight: 500; color: #52525b; }
.main-nav a { text-decoration: none; }
.main-nav a:hover { color: var(--accent); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px; border-radius: 10px; font-weight: 600; font-size: 0.95rem;
  text-decoration: none; cursor: pointer; border: 1px solid transparent; transition: 0.15s ease;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-outline { background: #fff; border-color: #d4d4d8; color: #18181b; }
.btn-outline:hover { border-color: #18181b; }

/* Homepage */
.page-main { padding-top: 28px; padding-bottom: 56px; }
.hero {
  background: #fff; border: 1px solid #e4e4e7; border-radius: 18px;
  padding: 32px 28px; margin-bottom: 32px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.04);
}
.eyebrow {
  display: inline-block; font-size: 0.78rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--accent); margin-bottom: 10px;
}
.hero h1 { margin: 0 0 12px; font-size: clamp(1.6rem, 3.2vw, 2.35rem); line-height: 1.2; letter-spacing: -0.02em; }
.hero-summary { margin: 0 0 20px; color: #52525b; font-size: 1.05rem; max-width: 720px; }
.hero-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; }
.meta-note { color: #71717a; font-size: 0.9rem; font-weight: 500; }

.section-head { margin-bottom: 18px; }
.section-head h2 { margin: 0 0 4px; font-size: 1.45rem; }
.section-head p { margin: 0; color: #71717a; }

.story-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 22px; }
.story-card {
  background: #fff; border: 1px solid #e4e4e7; border-radius: 16px; overflow: hidden;
  display: flex; flex-direction: column;
}
.story-cover {
  display: flex; justify-content: space-between; align-items: flex-start;
  height: 150px; padding: 14px; text-decoration: none; color: #fff;
}
.genre-pill, .chapter-pill {
  background: rgba(0, 0, 0, 0.55); backdrop-filter: blur(4px);
  padding: 4px 10px; border-radius: 999px; font-size: 0.78rem; font-weight: 600;
}
.story-card-body { padding: 18px; display: flex; flex-direction: column; flex: 1; }
.story-card-body h2 { margin: 0 0 10px; font-size: 1.15rem; line-height: 1.35; }
.story-card-body h2 a { text-decoration: none; }
.story-card-body h2 a:hover { color: var(--accent); }
.story-card-body p { margin: 0 0 18px; color: #52525b; font-size: 0.94rem; flex: 1; }

/* Reader Layout */
.reader-layout {
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 32px;
  padding-top: 24px; padding-bottom: 64px;
}
@media (min-width: 1080px) {
  .reader-layout { grid-template-columns: minmax(0, 740px) 300px; justify-content: space-between; }
}
.reader-article {
  background: #fff; border: 1px solid #e4e4e7; border-radius: 18px;
  padding: 26px 20px;
}
@media (min-width: 640px) { .reader-article { padding: 36px 40px; } }

.breadcrumbs { display: flex; flex-wrap: wrap; gap: 8px; font-size: 0.85rem; color: #71717a; margin-bottom: 14px; }
.breadcrumbs a { text-decoration: none; }
.breadcrumbs a:hover { color: var(--accent); }
.chapter-header { margin-bottom: 26px; padding-bottom: 18px; border-bottom: 1px solid #f4f4f5; }
.story-kicker { margin: 0 0 8px; color: var(--accent); font-weight: 700; font-size: 0.9rem; }
.chapter-header h1 { margin: 0 0 10px; font-size: clamp(1.5rem, 3vw, 2.05rem); line-height: 1.25; }
.chapter-meta { display: flex; flex-wrap: wrap; gap: 8px; font-size: 0.88rem; color: #71717a; }

.prose { font-family: Georgia, "Times New Roman", serif; font-size: 1.24rem; line-height: 1.85; color: #1f2937; }
.prose p { margin: 0 0 1.35em; }

.chapter-nav { margin-top: 30px; padding-top: 22px; border-top: 1px solid #e4e4e7; display: flex; flex-direction: column; gap: 12px; }
.btn-next { width: 100%; padding: 14px 20px; font-size: 1rem; text-align: center; }
.chapter-nav-sub { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }

.related-section { margin-top: 38px; padding-top: 24px; border-top: 1px solid #e4e4e7; }
.related-section h2 { margin: 0 0 14px; font-size: 1.2rem; }
.related-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.related-card {
  display: block; text-decoration: none; padding: 16px; border-radius: 12px;
  border: 1px solid #e4e4e7; background: #fafafa;
}
.related-card:hover { border-color: var(--accent); background: #fff; }
.genre-pill-sm { display: inline-block; font-size: 0.74rem; font-weight: 700; color: var(--accent); margin-bottom: 6px; text-transform: uppercase; }
.related-card h3 { margin: 0 0 8px; font-size: 0.98rem; line-height: 1.35; }
.related-meta { font-size: 0.84rem; color: #71717a; }

/* Sidebar & TOC */
.reader-sidebar { display: none; }
@media (min-width: 1080px) { .reader-sidebar { display: block; } }
.sidebar-card {
  position: sticky; top: 80px; background: #fff; border: 1px solid #e4e4e7;
  border-radius: 16px; padding: 18px; max-height: calc(100vh - 104px); display: flex; flex-direction: column;
}
.sidebar-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.sidebar-head h3 { margin: 0; font-size: 1rem; }
.sidebar-head span { font-size: 0.85rem; color: #71717a; font-weight: 600; }
.toc-list { display: flex; flex-direction: column; gap: 6px; overflow-y: auto; }
.toc-link {
  display: flex; gap: 8px; padding: 9px 10px; border-radius: 8px; text-decoration: none;
  font-size: 0.88rem; color: #3f3f46; border: 1px solid transparent;
}
.toc-link:hover { background: #f4f4f5; }
.toc-link.active { background: #fef2f2; border-color: #fecaca; color: var(--accent); font-weight: 700; }
.toc-num { flex-shrink: 0; font-weight: 700; }

.floating-toc-btn {
  position: fixed; right: 16px; bottom: 72px; z-index: 35;
  background: var(--accent); color: #fff; border: none; border-radius: 999px;
  padding: 10px 16px; font-weight: 700; font-size: 0.88rem; cursor: pointer;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}
@media (min-width: 1080px) { .floating-toc-btn { display: none; } }

.toc-modal[hidden] { display: none; }
.toc-modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.toc-modal-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.5); }
.toc-modal-panel {
  position: relative; z-index: 1; width: 100%; max-width: 520px; max-height: 75vh;
  background: #fff; border-radius: 18px 18px 0 0; padding: 20px; display: flex; flex-direction: column;
}
.modal-close { background: none; border: none; font-size: 1.6rem; line-height: 1; cursor: pointer; color: #52525b; }

/* Static Pages */
.static-page { padding-top: 32px; padding-bottom: 64px; max-width: 820px; }
.prose-page { background: #fff; border: 1px solid #e4e4e7; border-radius: 18px; padding: 32px; }
.prose-page h1 { margin-top: 0; }
.prose-page h2 { margin-top: 24px; font-size: 1.2rem; }

/* Ad Wrappers (only present when configured) */
.ad-wrap { margin: 22px 0; text-align: center; overflow: hidden; }
.ad-anchor { position: fixed; bottom: 0; left: 0; right: 0; z-index: 25; text-align: center; background: #fff; border-top: 1px solid #e4e4e7; }

/* Footer */
.site-footer { border-top: 1px solid #e4e4e7; background: #fff; padding: 26px 0; color: #71717a; font-size: 0.9rem; }
.footer-inner { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 14px; }
.footer-links { display: flex; flex-wrap: wrap; gap: 16px; }
.footer-links a { text-decoration: none; }
.footer-links a:hover { color: var(--accent); }

.scroll-top-btn {
  position: fixed; right: 16px; bottom: 20px; z-index: 34;
  width: 40px; height: 40px; border-radius: 999px; border: 1px solid #d4d4d8;
  background: #fff; color: #18181b; font-weight: 700; cursor: pointer; display: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}
.scroll-top-btn.visible { display: inline-flex; align-items: center; justify-content: center; }
