:root {
  --bg: #f8f6f2;
  --bg2: #edeae4;
  --surface: #ffffff;
  --surface2: #f4f2ee;
  --text: #2c2a26;
  --text2: #5a5752;
  --text3: #8a8580;
  --accent: #4a7c9e;
  --accent2: #6b9fb8;
  --accent-soft: #d0e8f5;
  --gold: #c8a84b;
  --gold-soft: #f5e8c0;
  --border: #d8d4cc;
  --shadow: rgba(44,42,38,0.12);
  --shadow2: rgba(44,42,38,0.06);
  --nav-h: 60px;
  --hero-h: 500px;
  --transition: 0.3s ease;
}
[data-theme="dark"] {
  --bg: #181614;
  --bg2: #201e1b;
  --surface: #252320;
  --surface2: #2d2a26;
  --text: #e8e4dc;
  --text2: #a8a49c;
  --text3: #6a6660;
  --accent: #6aadcf;
  --accent2: #88c4de;
  --accent-soft: #1a3a4e;
  --gold: #d4b46e;
  --gold-soft: #2a2210;
  --border: #3a3630;
  --shadow: rgba(0,0,0,0.4);
  --shadow2: rgba(0,0,0,0.2);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Nunito', sans-serif;
  background: var(--bg);
  color: var(--text);
  transition: background var(--transition), color var(--transition);
  min-height: 100vh;
}

/* ===== SITE HEADER ===== */
#site-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 12px var(--shadow2);
  transition: background var(--transition), border-color var(--transition);
}
.header-inner {
  max-width: 1200px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; height: var(--nav-h);
}
.site-logo {
  font-family: 'Cinzel', serif; font-size: 1.1rem; font-weight: 700;
  color: var(--accent); text-decoration: none; letter-spacing: 0.05em;
  white-space: nowrap;
}

/* Search */
.search-wrap { position: relative; }
.search-wrap input {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 20px; padding: 7px 36px 7px 14px;
  font-family: 'Nunito', sans-serif; font-size: 0.85rem;
  color: var(--text); width: 200px;
  transition: all var(--transition);
  outline: none;
}
.search-wrap input:focus {
  width: 260px; border-color: var(--accent); background: var(--surface);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.search-wrap input::placeholder { color: var(--text3); }
.search-btn {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer;
  color: var(--text3); font-size: 1rem; padding: 0;
  transition: color var(--transition);
}
.search-btn:hover { color: var(--accent); }

/* NAV */
nav { display: flex; gap: 4px; }
.nav-item {
  position: relative;
  font-family: 'Nunito', sans-serif; font-size: 0.88rem;
  font-weight: 600; color: var(--text2);
  background: none; border: none; cursor: pointer;
  padding: 8px 12px; border-radius: 8px;
  transition: all var(--transition);
  text-decoration: none;
}
.nav-item:hover, .nav-item.active {
  color: var(--accent); background: var(--accent-soft);
}
.dropdown {
  position: absolute; top: 100%; left: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 8px;
  box-shadow: 0 8px 30px var(--shadow);
  min-width: 180px; z-index: 200;
  opacity: 0; visibility: hidden; transform: translateY(-6px);
  transition: all 0.2s ease;
}
.nav-item:hover .dropdown, .nav-item:focus-within .dropdown {
  opacity: 1; visibility: visible; transform: translateY(0);
}
.dropdown a {
  display: block; padding: 9px 14px;
  font-size: 0.86rem; color: var(--text2);
  text-decoration: none; border-radius: 7px;
  transition: all 0.18s;
}
.dropdown a:hover { background: var(--bg2); color: var(--accent); }

/* Dark mode toggle */
.dm-toggle {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 20px; padding: 6px 12px;
  cursor: pointer; font-size: 1rem;
  display: flex; align-items: center; gap: 6px;
  color: var(--text2); font-family: 'Nunito', sans-serif;
  font-size: 0.8rem; font-weight: 600;
  transition: all var(--transition);
  white-space: nowrap;
}
.dm-toggle:hover { border-color: var(--accent); color: var(--accent); }

/* ===== PAGE SYSTEM ===== */
.page { display: none; }
.page.active { display: block; }

/* ===== HERO ===== */
#hero {
  height: var(--hero-h); position: relative; overflow: hidden;
  margin-top: var(--nav-h);
  background-image: url('img/hero.jpg');
  background-size: cover; background-position: center;
}
.hero-overlay {
  position: absolute; inset: 0;
  background: linear-gradient(to bottom, rgba(20,18,14,0.35) 0%, rgba(20,18,14,0.55) 100%);
}
.hero-content {
  position: relative; z-index: 1;
  height: 100%; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center; padding: 20px;
}
.hero-title {
  font-family: 'Cinzel', serif; font-size: clamp(2.2rem, 6vw, 4rem);
  font-weight: 700; color: #fff;
  text-shadow: 0 2px 20px rgba(0,0,0,0.6), 0 0 60px rgba(106,172,207,0.3);
  letter-spacing: 0.08em; line-height: 1.1;
}
.hero-sub {
  font-family: 'Lora', serif; font-style: italic;
  font-size: 1.05rem; color: rgba(255,255,255,0.82);
  margin-top: 14px; letter-spacing: 0.05em;
}
.hero-divider {
  width: 80px; height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  margin: 18px auto 0;
}

/* ===== LATEST UPDATES ===== */
.section { padding: 48px 24px; max-width: 1200px; margin: 0 auto; }
.section-label {
  font-family: 'Cinzel', serif; font-size: 0.72rem; font-weight: 600;
  color: var(--gold); letter-spacing: 0.2em; text-transform: uppercase;
  margin-bottom: 8px;
}
.section-title {
  font-family: 'Cinzel', serif; font-size: 1.6rem; font-weight: 600;
  color: var(--text); margin-bottom: 30px;
}
.cards-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px;
}
@media(max-width:768px) { .cards-grid { grid-template-columns: 1fr; } }
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; overflow: hidden;
  box-shadow: 0 2px 12px var(--shadow2);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  cursor: pointer;
}
.card:hover { transform: translateY(-4px); box-shadow: 0 8px 30px var(--shadow); }
.card-thumb {
  height: 160px; background: var(--bg2);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; position: relative;
}
.card-thumb img { width: 100%; height: 100%; object-fit: cover; }
.card-thumb-placeholder {
  font-size: 2.5rem; color: var(--text3); opacity: 0.4;
}
.card-tag {
  position: absolute; top: 10px; left: 10px;
  background: var(--accent); color: #fff;
  font-size: 0.68rem; font-weight: 700; letter-spacing: 0.1em;
  text-transform: uppercase; padding: 3px 9px; border-radius: 20px;
}
.card-body { padding: 18px; }
.card-meta {
  font-size: 0.76rem; color: var(--text3); margin-bottom: 6px;
  font-family: 'Nunito', sans-serif; letter-spacing: 0.03em;
}
.card-title {
  font-family: 'Lora', serif; font-size: 1rem; font-weight: 500;
  color: var(--text); margin-bottom: 8px; line-height: 1.4;
}
.card-desc {
  font-size: 0.83rem; color: var(--text2); line-height: 1.6;
  margin-bottom: 14px;
}
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 18px; border-radius: 8px;
  font-family: 'Nunito', sans-serif; font-size: 0.83rem; font-weight: 700;
  cursor: pointer; border: none; transition: all 0.2s;
  text-decoration: none;
}
.btn-primary {
  background: var(--accent); color: #fff;
}
.btn-primary:hover { background: var(--accent2); transform: translateX(2px); }
.btn-outline {
  background: transparent; color: var(--accent);
  border: 1.5px solid var(--accent);
}
.btn-outline:hover { background: var(--accent-soft); }

/* ===== CONTACT & FOOTER ===== */
.footer-area {
  background: var(--surface2); border-top: 1px solid var(--border);
  padding: 40px 24px 20px; margin-top: 20px;
  transition: background var(--transition);
}
.footer-inner { max-width: 1200px; margin: 0 auto; }
.footer-socials {
  display: flex; gap: 20px; justify-content: center; margin-bottom: 28px;
}
.social-link {
  display: flex; align-items: center; gap: 8px;
  color: var(--text2); text-decoration: none;
  font-size: 0.88rem; font-weight: 600;
  padding: 9px 18px; border-radius: 8px;
  border: 1px solid var(--border);
  transition: all var(--transition);
  background: var(--surface);
}
.social-link:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.social-icon { font-size: 1.1rem; }
.disclaimer {
  max-width: 700px; margin: 0 auto 24px;
  font-size: 0.78rem; color: var(--text3); line-height: 1.7;
  text-align: center; padding: 18px;
  background: var(--bg2); border-radius: 10px;
  border: 1px solid var(--border);
}
.footer-bottom {
  display: flex; justify-content: space-between; align-items: center;
  padding-top: 16px; border-top: 1px solid var(--border);
  font-size: 0.76rem; color: var(--text3);
}

/* ===== INNER PAGE LAYOUT ===== */
.page-hero {
  height: 180px; margin-top: var(--nav-h);
  background: linear-gradient(135deg, var(--bg2) 0%, var(--accent-soft) 100%);
  display: flex; align-items: center; justify-content: center;
  position: relative; overflow: hidden;
}
.page-hero::before {
  content: ''; position: absolute; inset: 0;
  background: repeating-linear-gradient(45deg, transparent, transparent 30px, rgba(106,172,207,0.04) 30px, rgba(106,172,207,0.04) 31px);
}
.page-hero-content { position: relative; z-index: 1; text-align: center; }
.page-hero-title {
  font-family: 'Cinzel', serif; font-size: 2rem; font-weight: 600;
  color: var(--text); letter-spacing: 0.06em;
}
.page-hero-sub {
  font-family: 'Lora', serif; font-style: italic;
  font-size: 0.95rem; color: var(--text2); margin-top: 8px;
}

/* Reading area */
.reading-wrap {
  min-height: 100vh; margin-top: var(--nav-h);
  position: relative; overflow: hidden;
}
.reading-bg {
  position: fixed; inset: 0; z-index: -1;
  background-size: cover; background-position: center;
  opacity: 0.12;
  transition: opacity 0.4s;
}
[data-theme="dark"] .reading-bg { opacity: 0.07; }
.reading-paper {
  max-width: 720px; margin: 0 auto;
  background: var(--surface); padding: 48px 52px;
  min-height: calc(100vh - var(--nav-h));
  box-shadow: 0 0 60px var(--shadow);
  line-height: 1.85; font-size: 1rem;
  font-family: 'Lora', serif; color: var(--text);
}
.reading-paper h1 {
  font-family: 'Cinzel', serif; font-size: 1.5rem;
  margin-bottom: 8px; color: var(--text);
}
.reading-paper .chap-meta {
  font-size: 0.82rem; color: var(--text3);
  font-family: 'Nunito', sans-serif; margin-bottom: 32px;
  padding-bottom: 18px; border-bottom: 1px solid var(--border);
}
.reading-paper p { margin-bottom: 1.2em; }
.chapter-nav {
  display: flex; justify-content: space-between; align-items: center;
  padding-top: 32px; margin-top: 32px;
  border-top: 1px solid var(--border);
  gap: 12px; flex-wrap: wrap;
}

/* About Me page */
.about-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 24px;
  margin-top: 16px;
}
@media(max-width:600px) { .about-grid { grid-template-columns: 1fr; } }
.about-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 30px;
  cursor: pointer; transition: all 0.25s;
  text-align: center;
}
.about-card:hover {
  transform: translateY(-4px); box-shadow: 0 8px 30px var(--shadow);
  border-color: var(--accent);
}
.about-card-icon { font-size: 2.5rem; margin-bottom: 14px; }
.about-card h3 {
  font-family: 'Cinzel', serif; font-size: 1.1rem; margin-bottom: 8px;
  color: var(--text);
}
.about-card p { font-size: 0.87rem; color: var(--text2); line-height: 1.6; }

/* Story list */
.story-list { list-style: none; }
.story-item {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; margin-bottom: 12px; overflow: hidden;
  transition: all 0.2s;
}
.story-item-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px; cursor: pointer;
  transition: background 0.2s;
}
.story-item-header:hover { background: var(--bg2); }
.story-item-title {
  font-family: 'Lora', serif; font-size: 1.05rem; font-weight: 500;
  color: var(--text);
}
.story-item-chevron {
  color: var(--text3); transition: transform 0.25s;
  font-size: 0.9rem;
}
.story-item.open .story-item-chevron { transform: rotate(180deg); }
.story-chapters {
  display: none; padding: 8px 22px 16px;
  border-top: 1px solid var(--border); background: var(--bg2);
}
.story-item.open .story-chapters { display: block; }
.chapter-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 8px;
  text-decoration: none; color: var(--text2);
  font-size: 0.87rem; transition: all 0.18s;
  border-bottom: 1px solid var(--border);
}
.chapter-link:last-child { border-bottom: none; }
.chapter-link:hover { background: var(--surface); color: var(--accent); padding-left: 18px; }
.chapter-num {
  font-size: 0.72rem; font-weight: 700; color: var(--text3);
  background: var(--bg); padding: 2px 7px; border-radius: 4px;
  white-space: nowrap;
}

/* Fan art grid */
.fanart-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
}
.fanart-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; overflow: hidden; cursor: pointer;
  transition: all 0.25s;
}
.fanart-card:hover { transform: scale(1.02); box-shadow: 0 8px 30px var(--shadow); }
.fanart-img {
  height: 180px; background: var(--bg2);
  display: flex; align-items: center; justify-content: center;
  font-size: 2.5rem; color: var(--text3); opacity: 0.3;
}
.fanart-info { padding: 12px 14px; }
.fanart-title { font-size: 0.87rem; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.fanart-meta { font-size: 0.76rem; color: var(--text3); }

/* FAQ */
.faq-item {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; margin-bottom: 12px; overflow: hidden;
}
.faq-q {
  padding: 18px 22px; cursor: pointer;
  display: flex; justify-content: space-between; align-items: center;
  font-weight: 600; font-size: 0.93rem;
  transition: background 0.2s;
}
.faq-q:hover { background: var(--bg2); }
.faq-a {
  display: none; padding: 0 22px 18px;
  font-size: 0.87rem; color: var(--text2); line-height: 1.7;
  border-top: 1px solid var(--border); background: var(--bg2);
  padding-top: 14px;
}
.faq-item.open .faq-a { display: block; }
.faq-item.open .faq-q { color: var(--accent); }

/* Support */
.support-card {
  max-width: 500px; margin: 0 auto;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 40px; text-align: center;
  box-shadow: 0 4px 20px var(--shadow2);
}
.support-icon { font-size: 3rem; margin-bottom: 16px; }
.support-card h2 {
  font-family: 'Cinzel', serif; font-size: 1.4rem;
  margin-bottom: 14px; color: var(--text);
}
.support-card p {
  font-size: 0.9rem; color: var(--text2); line-height: 1.7;
  margin-bottom: 24px;
}
.btn-coffee {
  display: inline-flex; align-items: center; gap: 8px;
  background: #FFDD00; color: #1a1a1a;
  padding: 12px 28px; border-radius: 10px;
  font-weight: 700; font-size: 0.95rem;
  text-decoration: none; transition: all 0.2s;
  border: none; cursor: pointer;
}
.btn-coffee:hover { background: #f5cc00; transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,0.15); }

/* Submission form */
.form-group { margin-bottom: 20px; }
.form-label {
  display: block; font-size: 0.85rem; font-weight: 700;
  color: var(--text2); margin-bottom: 6px; letter-spacing: 0.03em;
}
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 10px 14px;
  background: var(--bg2); border: 1.5px solid var(--border);
  border-radius: 8px; color: var(--text);
  font-family: 'Nunito', sans-serif; font-size: 0.9rem;
  transition: all var(--transition); outline: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--accent); background: var(--surface);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.form-textarea { min-height: 100px; resize: vertical; line-height: 1.6; }
.form-note { font-size: 0.75rem; color: var(--text3); margin-top: 4px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media(max-width:500px) { .form-grid { grid-template-columns: 1fr; } }

/* Utility */
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-32 { margin-top: 32px; }
.mb-24 { margin-bottom: 24px; }
.text-center { text-align: center; }
.divider {
  height: 1px; background: var(--border);
  margin: 32px 0;
}
.badge {
  display: inline-block;
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.1em;
  text-transform: uppercase; padding: 3px 10px; border-radius: 20px;
  background: var(--gold-soft); color: var(--gold);
}
.back-btn {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--text3); font-size: 0.83rem; cursor: pointer;
  background: none; border: none; font-family: 'Nunito', sans-serif;
  transition: color 0.2s; padding: 0; margin-bottom: 24px;
}
.back-btn:hover { color: var(--accent); }

/* Fan art options */
.fanart-options {
  display: grid; grid-template-columns: 1fr 1fr; gap: 20px;
  margin-top: 16px;
}
@media(max-width:500px) { .fanart-options { grid-template-columns: 1fr; } }
.fanart-option-card {
  background: var(--surface); border: 2px solid var(--border);
  border-radius: 14px; padding: 30px; text-align: center;
  cursor: pointer; transition: all 0.25s;
}
.fanart-option-card:hover {
  border-color: var(--accent); transform: translateY(-4px);
  box-shadow: 0 8px 30px var(--shadow);
}
.fanart-option-card.selected {
  border-color: var(--accent); background: var(--accent-soft);
}

/* Author's More */
.authors-more-categories {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px; margin-top: 16px;
}
.am-cat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 22px; cursor: pointer;
  transition: all 0.22s;
}
.am-cat-card:hover {
  border-color: var(--accent); transform: translateY(-3px);
  box-shadow: 0 6px 24px var(--shadow);
}
.am-cat-card h4 {
  font-family: 'Lora', serif; font-size: 1rem; margin-bottom: 6px;
  color: var(--text);
}
.am-cat-card p { font-size: 0.8rem; color: var(--text3); }

/* Animations */
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.page.active { animation: fadeIn 0.3s ease; }
.hero-content > * { animation: fadeIn 0.6s ease both; }
.hero-content > *:nth-child(2) { animation-delay: 0.15s; }
.hero-content > *:nth-child(3) { animation-delay: 0.3s; }

/* ============================================================
   ADDITIONS FOR THE DYNAMIC SITE
   ============================================================ */

/* Cards and option cards are now real links */
.card, .am-cat-card, .fanart-option-card, .back-btn { text-decoration: none; color: inherit; display: block; }
.back-btn { display: inline-flex; }
.fanart-option-card { text-align: center; }
.fanart-option-card h3 {
  font-family: 'Cinzel', serif; font-size: 1.1rem;
  margin-bottom: 8px; color: var(--text);
}
.fanart-option-card p { font-size: 0.85rem; color: var(--text2); }

/* Real uploaded artwork must not inherit the placeholder styling */
img.fanart-img {
  width: 100%; object-fit: cover; opacity: 1;
  display: block; font-size: 0;
}

/* Disabled prev/next */
.btn.is-disabled { opacity: 0.35; pointer-events: none; }

/* Author-written rich text */
.prose {
  font-family: 'Lora', serif; font-size: 1rem;
  line-height: 1.85; color: var(--text2);
}
.prose p { margin-bottom: 1.1em; }
.prose h1, .prose h2, .prose h3 {
  font-family: 'Cinzel', serif; color: var(--text);
  margin: 1.4em 0 0.5em; line-height: 1.3;
}
.prose h1 { font-size: 1.5rem; }
.prose h2 { font-size: 1.28rem; }
.prose h3 { font-size: 1.1rem; }
.prose ul, .prose ol { margin: 0 0 1.1em 1.4em; }
.prose li { margin-bottom: 0.4em; }
.prose img { max-width: 100%; border-radius: 10px; margin: 1em 0; }
.prose a { color: var(--accent); }
.prose blockquote {
  border-left: 3px solid var(--accent); padding-left: 16px;
  margin: 1.2em 0; font-style: italic; color: var(--text3);
}

/* Empty states */
.empty-note {
  text-align: center; padding: 48px 20px;
  color: var(--text3); font-size: 0.9rem;
  background: var(--surface); border: 1px dashed var(--border);
  border-radius: 14px;
}

/* Loading spinner */
.spinner {
  width: 30px; height: 30px; margin: 0 auto;
  border: 3px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Search results dropdown */
#search-results {
  position: absolute; top: calc(100% + 8px); right: 0;
  width: 340px; max-height: 400px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: 0 12px 40px var(--shadow);
  padding: 6px; z-index: 300; display: none;
}
#search-results.open { display: block; }
#search-results a {
  display: block; padding: 10px 12px; border-radius: 8px;
  text-decoration: none; transition: background 0.15s;
}
#search-results a:hover { background: var(--bg2); }
#search-results strong {
  display: block; font-size: 0.85rem; font-weight: 600;
  color: var(--text); margin-bottom: 2px;
}
#search-results span { font-size: 0.75rem; color: var(--text3); }
.search-empty { padding: 14px; font-size: 0.83rem; color: var(--text3); text-align: center; }

@media(max-width:900px) {
  #search-results { width: 260px; }
}
