/* ============ FONTS ============ */
@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,500;9..144,700&family=Literata:opsz,wght@7..72,400;7..72,600&family=Nunito:wght@400;500;600;700;800&family=Nunito+Sans:wght@400;600;700;800&display=swap');

/* ============ THEME VARIABLES ============ */
:root {
  --bg: #ECEEF0;
  --bg-secondary: #F3EFE8;
  --text: #101826;
  --text-muted: #4A5568;
  --border: #C9CED6;
  --accent: #101826;
  --accent-hover: #1B2638;
  --accent-light: #DDE1E6;
  --card-bg: #ffffff;
  --shadow: 0 2px 16px rgba(16, 24, 38, 0.08);
  --font-heading: 'Fraunces', Georgia, serif;
  --font-sans: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  --font-serif: 'Nunito', Georgia, serif;
}

html.dark-mode {
  --bg: #0B111C;
  --bg-secondary: #151E2D;
  --text: #ECEEF0;
  --text-muted: #AAB3C2;
  --border: #2A364B;
  --accent: #C9B28A;
  --accent-hover: #DCC9A6;
  --accent-light: #1B2638;
  --card-bg: #151E2D;
  --shadow: 0 2px 16px rgba(0,0,0,0.35);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 18px;
  background: var(--bg);
  color: var(--text);
  transition: background 0.2s ease, color 0.2s ease;
  line-height: 1.6;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
}

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

/* ============ HEADER ============ */
.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
}
.logo { font-family: var(--font-heading); font-weight: 700; font-size: 1.4rem; color: var(--accent); }
.logo-img { display: block; height: 44px; width: auto; }
.logo-img-dark { display: none; }
html.dark-mode .logo-img-light { display: none; }
html.dark-mode .logo-img-dark { display: block; }
.auth-logo { display: block; margin: 56px auto 16px; text-align: center; }
.auth-logo .logo-img { height: 68px; margin: 0 auto; }
.auth-logo + .auth-form { margin-top: 8px; }
.logo-with-label { display: flex; align-items: center; gap: 10px; }
.logo-label { font-family: var(--font-heading); font-weight: 700; font-size: 1.1rem; color: var(--text); white-space: nowrap; }
.main-nav { display: flex; align-items: center; gap: 24px; }
.main-nav a { color: var(--text); font-size: 0.95rem; }
.nav-cta {
  background: var(--accent);
  color: #fff !important;
  padding: 8px 16px;
  border-radius: 6px;
}
.nav-cta:hover { background: var(--accent-hover); }
.nav-cart { position: relative; display: inline-flex; align-items: center; font-size: 1.15rem; text-decoration: none; }
.nav-cart-count {
  position: absolute; top: -8px; right: -10px; background: var(--accent); color: #fff;
  font-size: 0.68rem; font-weight: 700; min-width: 16px; height: 16px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center; padding: 0 3px; line-height: 1;
}
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 20px;
  width: 40px;
  height: 24px;
  cursor: pointer;
  position: relative;
  color: var(--text);
}
.icon-sun, .icon-moon { position: absolute; top: 50%; transform: translateY(-50%); font-size: 12px; }
.icon-sun { left: 5px; }
.icon-moon { right: 5px; display: none; }
html.dark-mode .icon-sun { display: none; }
html.dark-mode .icon-moon { display: inline; }
.mobile-nav-toggle { display: none; background: none; border: none; font-size: 1.5rem; color: var(--text); cursor: pointer; }

@media (max-width: 768px) {
  .main-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg);
    flex-direction: column;
    align-items: flex-start;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    gap: 16px;
  }
  .main-nav.open { display: flex; }
  .mobile-nav-toggle { display: block; }
}

/* ============ FOOTER ============ */
/* Fixed brand colors, not theme variables: the footer always stays the same
   dark-green band regardless of the site's light/dark toggle. */
.site-footer {
  background: #101826;
  margin-top: 80px;
  padding: 32px 0;
  color: #B9C0CC;
  font-size: 0.9rem;
}
.site-footer a { color: #ffffff; }
.site-footer a:hover { color: #E4D6FA; }
.footer-inner { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px; }
.footer-inner p { margin: 0; }
.footer-copyright { justify-self: start; }
.footer-contact { justify-self: end; }
.footer-center { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; justify-self: center; }
.footer-logo { display: block; margin: 0 auto; }
.footer-logo .logo-img { height: 44px; margin: 0 auto; }
.footer-tagline { margin: 0; font-size: 0.85rem; display: flex; align-items: center; justify-content: center; gap: 6px; color: #B9C0CC; }
.footer-tagline .flag { display: block; border-radius: 2px; box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.35); }
@media (max-width: 768px) {
  .footer-inner { grid-template-columns: 1fr; text-align: center; gap: 12px; }
  .footer-copyright, .footer-contact { justify-self: center; }
  .footer-center { order: -1; }
}

/* ============ HERO / LANDING ============ */
.hero {
  padding: 90px 0 50px;
  text-align: center;
  background: var(--bg-secondary);
  border-radius: 0 0 32px 32px;
  margin-bottom: 20px;
}
.hero h1 { font-family: var(--font-heading); font-weight: 700; font-size: 3rem; line-height: 1.15; margin-bottom: 16px; color: var(--text); }
.hero .hero-divider { width: 64px; height: 4px; background: var(--accent); border-radius: 4px; margin: 0 auto 24px; }
.hero p { color: var(--text-muted); font-size: 1.2rem; max-width: 600px; margin: 0 auto; }

/* ============ BOOK GRID ============ */
.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 36px;
  padding: 50px 0 90px;
}
.book-card {
  background: var(--card-bg);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  border: 1px solid var(--border);
}
.book-card:hover { transform: translateY(-6px); box-shadow: 0 8px 24px rgba(16, 24, 38, 0.14); }
.book-card img { width: 100%; aspect-ratio: 2/3; object-fit: cover; display: block; background: var(--bg-secondary); }
.book-card-body { padding: 20px; }
.book-card-body h3 { font-family: var(--font-heading); font-weight: 600; margin: 0 0 6px; font-size: 1.15rem; color: var(--text); }
.book-card-body p { margin: 0; color: var(--text-muted); font-size: 0.9rem; }
.book-card-price { margin-top: 10px; font-weight: 700; color: var(--accent); font-size: 1.05rem; }

/* ============ HERO V2 ============ */
.eyebrow {
  display: inline-block;
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 700;
  font-size: 0.8rem;
  padding: 6px 14px;
  border-radius: 20px;
  margin-bottom: 20px;
  letter-spacing: 0.3px;
}
.hero-v2 { padding: 70px 0 60px; overflow: hidden; }
.hero-v2-inner { display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 56px; align-items: center; }
.hero-v2 h1 { font-family: var(--font-heading); font-weight: 700; font-size: 2.9rem; line-height: 1.15; color: var(--text); margin-bottom: 20px; }
.hero-v2 h1 span { color: var(--accent); }
.hero-v2 p { font-size: 1.1rem; color: var(--text-muted); max-width: 460px; margin-bottom: 30px; }
.hero-ctas { display: flex; gap: 14px; flex-wrap: wrap; }

.hero-visual { position: relative; }
.hero-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.hero-book-tile {
  aspect-ratio: 3/4;
  border-radius: 16px;
  box-shadow: 0 12px 28px rgba(16, 24, 38,0.18);
  display: flex;
  align-items: flex-end;
  padding: 16px;
  color: #fff;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1.25;
  background-size: cover;
  background-position: center;
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.hero-book-tile:hover { transform: translateY(-4px); box-shadow: 0 16px 32px rgba(16, 24, 38,0.25); }
.hero-book-tile.hero-book-placeholder {
  background: var(--bg-secondary);
  color: var(--text-muted);
  align-items: center;
  justify-content: center;
  text-align: center;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: default;
  box-shadow: none;
}
.hero-book-tile.hero-book-placeholder:hover { transform: none; }

/* Deterministic cover gradients used when no real cover image exists yet */
.cover-gradient-1 { background: linear-gradient(160deg, #4A5A72, #101826); }
.cover-gradient-2 { background: linear-gradient(160deg, #1B2638, #101826); }
.cover-gradient-3 { background: linear-gradient(160deg, #7a5c3a, #4d3a26); }
.cover-gradient-4 { background: linear-gradient(160deg, #2f5d68, #1c3940); }
.cover-gradient-muted { background: linear-gradient(160deg, #C9A24B, #a5822f); }

/* ============ FEATURES BAND ============ */
.features-band {
  padding: 60px 40px;
  background: var(--bg-secondary);
  border-radius: 28px;
  margin: 10px 0 20px;
}
.features-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 36px; }
.feature-item { text-align: center; }
.feature-icon {
  width: 52px; height: 52px;
  background: var(--card-bg);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  margin: 0 auto 14px;
  box-shadow: var(--shadow);
}
.feature-item h3 { font-family: var(--font-heading); font-weight: 600; font-size: 1.1rem; margin-bottom: 6px; color: var(--text); }
.feature-item p { color: var(--text-muted); font-size: 0.9rem; margin: 0; }

/* ============ BOOK SHOWCASE V2 ============ */
.books-section { padding: 70px 0 90px; }
.section-head { text-align: center; margin-bottom: 44px; }
.section-head h2 { font-family: var(--font-heading); font-weight: 700; font-size: 2.1rem; margin-bottom: 10px; color: var(--text); }
.section-head p { color: var(--text-muted); font-size: 1rem; margin: 0; }

.book-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: center;
  margin-bottom: 40px;
}
.filter-search {
  flex: 1 1 240px;
  max-width: 320px;
  padding: 11px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card-bg);
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
}
.filter-select {
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card-bg);
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
}
.filter-clear {
  color: var(--text-muted);
  font-size: 0.85rem;
  text-decoration: underline;
}

.book-grid-v2 { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 32px; }
.book-card-v2 {
  background: var(--card-bg);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  display: block;
}
.book-card-v2:hover { transform: translateY(-6px); box-shadow: 0 10px 28px rgba(16, 24, 38,0.16); }
.book-cover-v2 {
  aspect-ratio: 2/3;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  position: relative;
}
.book-cover-title {
  color: #fff;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.2rem;
  text-align: center;
  line-height: 1.3;
}
.book-badge {
  position: absolute; top: 14px; right: 14px;
  background: #fff; color: var(--accent);
  font-size: 0.68rem; font-weight: 700;
  padding: 4px 10px; border-radius: 20px;
}
.book-info-v2 { padding: 20px; }
.book-info-v2 h3 { font-family: var(--font-heading); font-weight: 600; font-size: 1.1rem; margin-bottom: 4px; color: var(--text); }
.book-info-v2 .author { color: var(--text-muted); font-size: 0.88rem; margin-bottom: 14px; }
.book-price-row { display: flex; align-items: center; justify-content: space-between; }
.price-old { text-decoration: line-through; color: var(--text-muted); font-size: 0.82rem; }
.price-new { font-weight: 700; color: var(--accent); font-size: 1.05rem; }
.book-cta { background: var(--bg-secondary); color: var(--accent); font-weight: 700; font-size: 0.78rem; padding: 7px 14px; border-radius: 8px; }

@media (max-width: 1150px) {
  .hero-visual { margin-top: 30px; max-width: 100%; }
}

@media (max-width: 768px) {
  .hero-v2-inner { grid-template-columns: 1fr; }
  .hero-v2 h1 { font-size: 2.2rem; }
  .features-grid {
    grid-template-columns: 1fr 1fr;
    gap: 18px;
  }
  .feature-item p { display: none; }
  .feature-icon { margin-bottom: 10px; }
  .feature-item h3 { font-size: 0.95rem; }
}

@media (max-width: 420px) {
  .hero-grid { gap: 10px; }
  .hero-book-tile { font-size: 0.82rem; padding: 10px; border-radius: 12px; }
}

/* ============ GENERIC PAGES ============ */
.simple-hero { padding: 60px 0 40px; text-align: left; }
.simple-hero h1 { font-family: var(--font-heading); font-weight: 700; font-size: 2.6rem; line-height: 1.15; color: var(--text); margin: 10px 0 14px; }
.simple-hero-sub { color: var(--text-muted); font-size: 1.1rem; max-width: 640px; }

.page-content { max-width: 760px; margin: 0 auto; padding: 20px 24px 100px; font-family: var(--font-sans); }
.page-content h2 { font-family: var(--font-heading); font-weight: 700; font-size: 1.7rem; margin: 36px 0 14px; color: var(--text); }
.page-content h3 { font-family: var(--font-heading); font-weight: 600; font-size: 1.3rem; margin: 28px 0 12px; color: var(--text); }
.page-content h4 { font-family: var(--font-heading); font-weight: 600; font-size: 1.1rem; margin: 24px 0 10px; color: var(--text); }
.page-content p { margin-bottom: 18px; line-height: 1.75; color: var(--text); }
.page-content blockquote { font-style: italic; border-left: 3px solid var(--border); padding-left: 16px; color: var(--text-muted); margin: 20px 0; }
.page-content ul, .page-content ol { margin: 0 0 18px 24px; }
.page-content li { margin-bottom: 8px; line-height: 1.6; }
.page-content img { max-width: 100%; border-radius: 12px; margin: 20px 0; }
.page-content a { color: var(--accent); text-decoration: underline; }

/* ============ BOOK DETAIL PAGE ============ */
.book-detail {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 56px;
  padding: 70px 0;
}
.book-detail img { width: 100%; border-radius: 14px; box-shadow: var(--shadow); }
.book-detail h1 { font-family: var(--font-heading); font-weight: 700; font-size: 2.4rem; line-height: 1.2; margin-bottom: 6px; color: var(--text); }
.book-detail .subtitle { color: var(--text-muted); font-size: 1.2rem; font-style: italic; margin-bottom: 20px; }
.book-detail .price-box {
  background: var(--bg-secondary);
  border-radius: 16px;
  padding: 28px;
  margin: 28px 0;
  border: 1px solid var(--border);
}
.btn {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  padding: 13px 26px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 700;
  font-family: var(--font-sans);
  text-align: center;
  transition: transform 0.15s ease, background 0.15s ease;
}
.btn:hover { background: var(--accent-hover); color: #fff; transform: translateY(-2px); }
.btn-secondary {
  background: transparent;
  color: var(--accent);
  border: 2px solid var(--accent);
}
.btn-secondary:hover { background: var(--bg-secondary); color: var(--accent-hover); transform: translateY(-2px); }

@media (max-width: 768px) {
  .book-detail { grid-template-columns: 1fr; }
  .book-detail img { max-width: 260px; margin: 0 auto; }
}

/* ============ BOOK DETAIL PAGE V2 ============ */
.book-detail-v2 {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 56px;
  padding: 60px 0 20px;
}
.book-detail-cover {
  aspect-ratio: 2/3;
  border-radius: 18px;
  box-shadow: 0 20px 40px rgba(16, 24, 38,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
}
.book-detail-info h1 { font-family: var(--font-heading); font-weight: 700; font-size: 2.3rem; line-height: 1.2; margin: 10px 0 6px; color: var(--text); }
.book-detail-info .subtitle { color: var(--text-muted); font-size: 1.15rem; font-style: italic; margin-bottom: 14px; }
.book-author-line { color: var(--text-muted); margin-bottom: 20px; }
.book-author-line strong { color: var(--text); }
.book-description { color: var(--text); line-height: 1.75; margin-bottom: 26px; max-width: 60ch; }

.price-box-v2 {
  background: var(--bg-secondary);
  border-radius: 18px;
  padding: 28px;
  border: 1px solid var(--border);
}
.price-row-v2 { margin-bottom: 20px; display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.price-new-lg { font-family: var(--font-heading); font-weight: 700; font-size: 1.8rem; color: var(--accent); }
.owned-label { font-weight: 700; color: var(--accent); margin-bottom: 20px; }

.chapter-list-section { padding: 50px 0 90px; max-width: 700px; }
.chapter-list-section h2 { font-family: var(--font-heading); font-weight: 700; font-size: 1.5rem; margin-bottom: 20px; color: var(--text); }
.chapter-list { border: 1px solid var(--border); border-radius: 16px; overflow: hidden; background: var(--card-bg); }
.chapter-list-item {
  display: flex; align-items: center; gap: 16px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--border);
}
.chapter-list-item:last-child { border-bottom: none; }
.chapter-list-num {
  font-family: var(--font-heading); font-weight: 700;
  color: var(--accent);
  width: 28px; flex-shrink: 0;
}
.chapter-list-title { flex: 1; color: var(--text); }
.chapter-list-free {
  background: var(--accent-light); color: var(--accent);
  font-size: 0.7rem; font-weight: 700;
  padding: 4px 10px; border-radius: 20px;
  flex-shrink: 0;
}

@media (max-width: 768px) {
  .book-detail-v2 { grid-template-columns: 1fr; }
  .book-detail-cover { max-width: 240px; margin: 0 auto; }
}

/* ============ RATINGS & REVIEWS ============ */
.book-rating-summary { margin: 0 0 14px; color: var(--text-muted); font-size: 0.95rem; }
.stars { color: #E6A817; letter-spacing: 1px; }

.review-section { padding: 20px 0 90px; max-width: 700px; }
.review-section h2 { font-family: var(--font-heading); font-weight: 700; font-size: 1.5rem; margin-bottom: 20px; color: var(--text); }

.review-form {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  margin-bottom: 30px;
  max-width: 500px;
}
.review-form label { display: block; margin: 14px 0 6px; font-size: 0.9rem; font-weight: 600; }
.review-form label:first-child { margin-top: 0; }
.review-form select, .review-form textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
}
.review-form button { margin-top: 16px; }

.review-list { display: flex; flex-direction: column; gap: 20px; }
.review-item {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
  background: var(--card-bg);
}
.review-item-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.review-badge {
  background: var(--accent-light); color: var(--accent);
  font-size: 0.7rem; font-weight: 700;
  padding: 3px 10px; border-radius: 20px;
}
.review-date { color: var(--text-muted); font-size: 0.8rem; margin-left: auto; }
.review-text { margin: 0; color: var(--text); }

/* ============ AUTH FORMS ============ */
.auth-form {
  max-width: 400px;
  margin: 80px auto;
  background: var(--card-bg);
  padding: 40px;
  border-radius: 10px;
  box-shadow: var(--shadow);
}
.auth-form h2 { margin-top: 0; }
.auth-form label { display: block; margin: 16px 0 6px; font-size: 0.9rem; font-weight: 600; }
.auth-form input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
}
.auth-form button:not(.password-toggle) { width: 100%; margin-top: 24px; }
.password-field { position: relative; }
.password-field input[type="password"], .password-field input[type="text"] { padding-right: 44px !important; }
.password-toggle {
  position: absolute !important; right: 4px; top: 50%; transform: translateY(-50%) !important;
  width: 34px; height: 34px; margin: 0 !important; border: none; background: transparent; cursor: pointer;
  display: flex; align-items: center; justify-content: center; color: var(--text); padding: 0;
  opacity: 0.4; transition: opacity 0.15s ease;
}
.password-toggle:hover { opacity: 0.65; }
.password-toggle.is-showing { opacity: 1; }
.form-error { background: #fdecea; color: #b3261e; padding: 10px 14px; border-radius: 6px; margin-bottom: 16px; font-size: 0.9rem; }
html.dark-mode .form-error { background: #3a1f1e; color: #ff8a80; }

/* ============ PHOTO CROPPER ============ */
.photo-crop-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 20px;
}
.photo-crop-overlay[hidden] { display: none; }
.photo-crop-box { background: var(--card-bg); border-radius: 14px; padding: 24px; width: 320px; max-width: 100%; text-align: center; box-shadow: var(--shadow); }
.photo-crop-frame {
  width: 260px; height: 260px; margin: 16px auto; border-radius: 50%; overflow: hidden;
  position: relative; background: #111; cursor: grab; touch-action: none; user-select: none;
}
.photo-crop-frame.is-dragging { cursor: grabbing; }
.photo-crop-frame img { position: absolute; top: 0; left: 0; max-width: none; will-change: transform; }
#photo-crop-zoom, .photo-crop-zoom { width: 100%; }
.cover-crop-frame { width: 240px; height: 360px; border-radius: 8px; background-size: cover; background-position: center; }
.photo-crop-actions { display: flex; gap: 10px; margin-top: 16px; }
.photo-crop-actions .btn { flex: 1; margin-top: 0; }

/* ============ LIBRARY ============ */
.library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 24px;
  padding: 40px 0 80px;
}

/* ============ READER ============ */
.reader-toolbar {
  position: sticky;
  top: 65px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  z-index: 90;
  padding: 12px 0;
}
.reader-toolbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.reader-chapter-label {
  font-weight: 600;
  font-size: 0.95rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.font-controls { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.font-controls button {
  width: 32px; height: 32px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 6px;
  cursor: pointer;
  font-size: 1rem;
}
.reader-content {
  max-width: 700px;
  margin: 0 auto;
  padding: 40px 24px 120px;
  font-family: var(--font-serif);
}
.reader-content .chapter-block { margin-bottom: 80px; scroll-margin-top: 130px; }
.reader-content h2 { font-family: var(--font-heading); font-weight: 700; font-size: 2.6rem; line-height: 1.15; margin-bottom: 8px; color: var(--accent); }
.reader-content h3.subtitle { font-weight: 500; font-style: italic; color: var(--text-muted); margin-top: 0; font-size: 1.2rem; }
.reader-content h4 { font-family: var(--font-heading); font-weight: 600; font-size: 1.5rem; margin-top: 40px; margin-bottom: 12px; color: var(--text); }
.reader-content p { margin-bottom: 20px; }
.reader-content strong { font-size: 1.06em; font-weight: 700; color: var(--text); }
.summary-box,
.reader-content blockquote {
  font-style: italic;
  border-top: 1px solid var(--border);
  border-left: none;
  padding: 16px 0 0;
  margin: 32px 0 0;
  color: var(--text-muted);
}

.chapter-locked {
  position: relative;
  padding: 40px 24px;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: 10px;
  margin-bottom: 80px;
}
.chapter-locked-blur {
  filter: blur(5px);
  user-select: none;
  pointer-events: none;
  max-height: 200px;
  overflow: hidden;
}
.chapter-locked-overlay {
  margin-top: 20px;
}

/* Font size classes applied to .reader-content by JS */
.font-size-1 { font-size: 15px; }
.font-size-2 { font-size: 17px; }
.font-size-3 { font-size: 19px; }
.font-size-4 { font-size: 21px; }
.font-size-5 { font-size: 23px; }
.font-size-6 { font-size: 25px; }
.font-size-7 { font-size: 27px; }

/* ============ DARK MODE: light-purple accent needs dark text on filled buttons ============ */
html.dark-mode .btn,
html.dark-mode .btn:hover,
html.dark-mode .nav-cta,
html.dark-mode .nav-cta:hover { color: #0B111C; }
html.dark-mode .nav-cart-count { color: #0B111C; }

/* =====================================================================
   REDESIGN 2026-10: purple brand, gold accent, rounder + calmer surfaces
   ===================================================================== */
:root {
  --gold: #C9B28A;
  --gold-soft: #E9DFCB;
  --gold-ink: #101826;
  --radius: 18px;
}
html.dark-mode { --gold: #E6A94A; --gold-soft: #4A3716; }

h1, h2, h3 { font-family: var(--font-heading); }
.btn { border-radius: 999px; padding: 13px 28px; }
.btn-secondary { border-radius: 999px; }
.btn-gold { background: var(--gold); color: var(--gold-ink); }
.btn-gold:hover { background: #B89F73; color: var(--gold-ink); }
html.dark-mode .btn-gold, html.dark-mode .btn-gold:hover { color: var(--gold-ink); }

.site-header { backdrop-filter: saturate(1.4) blur(8px); background: color-mix(in srgb, var(--bg) 88%, transparent); }
.main-nav a { font-weight: 700; }
.main-nav a:not(.nav-cta):hover { color: var(--accent); }
.nav-cta { border-radius: 999px; }

/* Hero */
.hero-v2 { background: linear-gradient(180deg, var(--bg-secondary) 0%, var(--bg) 100%); }
.hero-v2 h1 { font-size: clamp(2.2rem, 5vw, 3.6rem); line-height: 1.06; letter-spacing: -0.01em; }
.hero-v2 h1 span { color: var(--accent); }
.eyebrow { color: var(--accent); background: var(--accent-light); display: inline-block; padding: 6px 14px; border-radius: 999px; letter-spacing: 0.1em; font-weight: 800; font-size: 0.78rem; }
.hero-book-tile { border-radius: 8px 18px 18px 8px; box-shadow: 0 18px 40px rgba(16, 24, 38, 0.22); }

/* Feature band */
.feature-icon { background: var(--accent-light); border-radius: 16px; }

/* Category chips */
.category-chips { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin: 0 0 22px; }
.chip { display: inline-flex; align-items: center; min-height: 44px; padding: 0 20px; border-radius: 999px; border: 1px solid var(--border); background: var(--card-bg); color: var(--text); font-weight: 700; font-size: 0.95rem; }
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.is-active { background: var(--accent); border-color: var(--accent); color: #fff; }
html.dark-mode .chip.is-active { color: #0B111C; }

/* Book cards */
.book-card-v2 { position: relative; border-radius: var(--radius); }
.book-card-link { display: block; color: inherit; }
.book-card-link:hover { color: inherit; }
.book-cover-v2 { border-radius: 8px 18px 18px 8px; }
.book-badge { background: var(--gold); color: var(--gold-ink); border-radius: 999px; }

/* Wishlist heart */
.wish-form { margin: 0; }
.book-card-v2 > .wish-form { position: absolute; top: 12px; right: 12px; z-index: 2; }
.wish-btn { width: 40px; height: 40px; border-radius: 50%; border: 0; background: rgba(255,255,255,0.92); color: var(--text-muted); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; box-shadow: 0 2px 10px rgba(35,26,51,0.18); transition: transform .15s ease, color .15s ease; }
.wish-btn:hover { transform: scale(1.08); color: #7A6338; }
.wish-btn.is-saved { color: #7A6338; }
.book-quick-actions { display: flex; align-items: center; gap: 10px; margin: 0 0 18px; }
.book-quick-actions .wish-btn { border: 1px solid var(--border); background: var(--card-bg); box-shadow: none; }
.wish-label { color: var(--text-muted); font-size: 0.9rem; font-weight: 600; }

/* Continue reading strip */
.resume-strip { padding: 8px 0 26px; }
.resume-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
.resume-head h2 { margin: 0; font-size: 1.5rem; color: var(--accent); }
.streak-pill { display: inline-flex; align-items: center; gap: 6px; background: var(--gold-soft); color: #4D3F20; font-weight: 800; font-size: 0.85rem; padding: 6px 14px; border-radius: 999px; }
html.dark-mode .streak-pill { color: #E9DFCB; }
.streak-pill.is-idle { background: var(--bg-secondary); color: var(--text-muted); }
.resume-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.resume-card { display: flex; align-items: center; gap: 16px; background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 18px; color: var(--text); }
.resume-card:hover { border-color: var(--accent); color: var(--text); }
.resume-cover { width: 54px; height: 78px; border-radius: 4px 8px 8px 4px; flex: none; }
.resume-meta { flex: 1; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.resume-meta strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.resume-sub { color: var(--text-muted); font-size: 0.82rem; }
.resume-bar { height: 8px; border-radius: 99px; background: var(--accent-light); overflow: hidden; display: block; }
.resume-bar > span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.resume-go { background: var(--accent); color: #fff; font-weight: 800; font-size: 0.85rem; padding: 9px 18px; border-radius: 999px; }
html.dark-mode .resume-go { color: #0B111C; }

/* Gift banner */
.gift-banner { margin: 0 0 70px; }
.gift-banner-inner { background: var(--accent); color: #F3EFE8; border-radius: 24px; padding: 44px 48px; display: flex; flex-wrap: wrap; gap: 24px; align-items: center; justify-content: space-between; }
.gift-banner h2 { margin: 0 0 8px; font-size: 2rem; color: #fff; }
.gift-banner p { margin: 0; max-width: 520px; opacity: 0.9; }
html.dark-mode .gift-banner-inner { background: #1B2638; }
html.dark-mode .gift-banner h2 { color: #ECEEF0; }

/* Book detail extras */
.price-box-v2 { border-radius: 20px; box-shadow: 0 10px 30px rgba(16, 24, 38, 0.08); }
.book-detail-cover { border-radius: 8px 20px 20px 8px; box-shadow: 0 28px 60px rgba(16, 24, 38, 0.28); }
.related-section { padding: 10px 0 40px; }
.related-section h2 { color: var(--accent); }
.related-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 22px; }
.related-card { display: flex; flex-direction: column; gap: 8px; color: var(--text); }
.related-card:hover { color: var(--accent); }
.related-cover { aspect-ratio: 2/3; border-radius: 6px 14px 14px 6px; display: flex; align-items: flex-end; box-shadow: 0 10px 24px rgba(16, 24, 38, 0.18); overflow: hidden; }
.related-card strong { font-size: 0.95rem; line-height: 1.3; }
.related-price { color: var(--accent); font-weight: 800; font-size: 0.9rem; }
.chapter-list { border-radius: var(--radius); }
.review-item { border-radius: var(--radius); }

/* Footer */
.site-footer { background: #101826; }
html.dark-mode .site-footer { background: #120C1B; }

@media (max-width: 768px) {
  .gift-banner-inner { padding: 30px 24px; }
  .resume-list { grid-template-columns: 1fr; }
}

/* Card polish */
.book-card-v2 .book-badge { right: auto; left: 12px; }
.book-card-v2 .book-price-row { flex-wrap: wrap; gap: 8px; }
.related-cover .book-cover-title { padding: 10px; font-size: 0.95rem; }


/* =====================================================================
   READER v2
   ===================================================================== */
html.reader-sepia { --bg: #F4ECDD; --bg-secondary: #EBE0CB; --text: #3B2F20; --text-muted: #7A6A52; --border: #E0D3BB; --card-bg: #FBF5E8; --accent-light: #EBDFC7; }
.reader-toolbar { top: 65px; padding: 0; }
.reader-toolbar-inner { padding-top: 10px; padding-bottom: 10px; }
.reader-back { width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--border); display: inline-flex; align-items: center; justify-content: center; color: var(--text); flex: none; }
.reader-chapter-label { flex: 1; font-family: var(--font-heading); font-size: 1.02rem; }
.reader-actions { display: flex; gap: 8px; align-items: center; flex: none; }
.reader-pill, .reader-icon { height: 38px; min-width: 38px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--card-bg); color: var(--text); font-weight: 800; font-size: 0.85rem; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.reader-icon { padding: 0; }
.reader-icon.is-on { color: var(--accent); border-color: var(--accent); }
.reader-progress { height: 3px; background: var(--border); }
.reader-progress > span { display: block; height: 100%; width: 0; background: var(--gold); transition: width .1s linear; }
.display-panel { display: flex; flex-wrap: wrap; gap: 24px; padding: 16px 24px; border-bottom: 1px solid var(--border); background: var(--bg-secondary); }
.display-panel[hidden], .contents-drawer[hidden], .drawer-scrim[hidden], .highlight-pop[hidden], .note-box[hidden] { display: none; }
.display-group { display: flex; flex-direction: column; gap: 8px; }
.display-group > b { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-muted); }
.seg { display: flex; gap: 6px; }
.seg button { height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font-weight: 700; font-size: 0.85rem; cursor: pointer; }
.seg button.is-active { background: var(--accent); border-color: var(--accent); color: #fff; }
html.dark-mode .seg button.is-active { color: #0B111C; }
.font-controls button { border-radius: 999px; width: 40px; height: 36px; }

.reader-content { max-width: 720px; font-family: 'Literata', Georgia, serif; line-height: 1.8; }
.reader-content.face-sans { font-family: var(--font-sans); }
.reader-content.space-compact { line-height: 1.55; }
.reader-content.space-airy { line-height: 2.05; }
.reader-content .chapter-block > h2 { font-size: 2.3rem; letter-spacing: -0.01em; }
.reader-content .chapter-block > h2 + p::first-letter { float: left; font-family: var(--font-heading); font-weight: 700; font-size: 3.6em; line-height: 0.85; padding: 6px 10px 0 0; color: var(--accent); }
.reader-content p { margin-bottom: 1.1em; }
mark.hl { background: #E3D6F6; color: inherit; padding: 1px 2px; border-radius: 3px; }
mark.hl.has-note { border-bottom: 2px solid var(--accent); }
html.dark-mode mark.hl { background: #4A3470; }
html.reader-sepia mark.hl { background: #EBD6A8; }

.contents-drawer { position: fixed; top: 0; left: 0; bottom: 0; width: min(360px, 90vw); background: var(--bg); border-right: 1px solid var(--border); z-index: 300; display: flex; flex-direction: column; box-shadow: 8px 0 40px rgba(35, 26, 51, 0.2); }
.drawer-scrim { position: fixed; inset: 0; background: rgba(23, 17, 31, 0.45); z-index: 250; }
.drawer-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); font-family: var(--font-heading); font-size: 1.1rem; }
.drawer-tabs { display: flex; border-bottom: 1px solid var(--border); }
.drawer-tabs button { flex: 1; padding: 12px 6px; background: none; border: 0; border-bottom: 3px solid transparent; color: var(--text-muted); font-weight: 800; font-size: 0.85rem; cursor: pointer; }
.drawer-tabs button.is-active { color: var(--accent); border-bottom-color: var(--accent); }
.drawer-pane { overflow-y: auto; padding: 8px 0; flex: 1; }
.drawer-pane > a { display: block; padding: 12px 20px; color: var(--text); border-bottom: 1px solid var(--border); font-size: 0.95rem; }
.drawer-pane > a:hover { background: var(--bg-secondary); }
.drawer-empty { padding: 20px; color: var(--text-muted); font-size: 0.9rem; }
.note-card { padding: 14px 20px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 6px; }
.note-quote { font-style: italic; color: var(--text); font-size: 0.9rem; }
.note-text { margin: 0; font-size: 0.88rem; color: var(--text-muted); }
.highlight-pop { position: absolute; z-index: 200; display: flex; gap: 2px; background: #101826; border-radius: 999px; padding: 4px; box-shadow: 0 8px 24px rgba(0,0,0,0.3); }
.highlight-pop button { background: none; border: 0; color: #fff; font-weight: 800; font-size: 0.82rem; padding: 8px 14px; border-radius: 999px; cursor: pointer; }
.highlight-pop button:hover { background: rgba(255,255,255,0.14); }
.note-box { position: absolute; z-index: 210; width: 300px; background: var(--card-bg); border: 1px solid var(--border); border-radius: 16px; padding: 14px; box-shadow: 0 12px 36px rgba(35,26,51,0.25); }
.note-box label { font-size: 0.78rem; font-weight: 800; color: var(--text-muted); display: block; margin-bottom: 6px; }
.note-box textarea { width: 100%; box-sizing: border-box; border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; background: var(--bg); color: var(--text); font: inherit; font-size: 0.9rem; margin-bottom: 10px; }
@media (max-width: 640px) { .reader-pill { padding: 0 10px; } .reader-chapter-label { font-size: 0.9rem; } }

/* ============ HOMEPAGE: CATEGORY TILES, PROMOS, SPOTLIGHT, BLOG ============ */
.book-info-v2 { text-align: center; }
.book-info-v2 .book-price-row { justify-content: center; }
.card-cat { color: var(--accent); font-size: 0.78rem; font-weight: 700; margin: -6px 0 10px; }
.card-stars { color: #e7a900; font-size: 0.9rem; margin: -6px 0 10px; letter-spacing: 1px; }
.card-stars span { color: var(--text-muted); font-size: 0.8rem; letter-spacing: 0; }
.section-sub { color: var(--text-muted); margin: 4px 0 0; }

.cat-tiles { display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px; margin-bottom: 26px; }
.cat-tile { display: flex; flex-direction: column; align-items: center; gap: 4px; background: var(--card-bg); border: 1px solid var(--border); border-radius: 18px; padding: 20px 10px; text-align: center; color: var(--text); transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s; }
.cat-tile:hover { transform: translateY(-4px); border-color: var(--accent); box-shadow: 0 10px 24px rgba(16, 24, 38, 0.14); }
.cat-dot { width: 44px; height: 44px; border-radius: 50%; background: var(--accent-light); color: var(--accent); display: flex; align-items: center; justify-content: center; font-family: var(--font-heading); font-weight: 700; font-size: 1.1rem; margin-bottom: 6px; }
.cat-tile b { font-family: var(--font-heading); font-size: 0.95rem; }
.cat-tile small { color: var(--text-muted); font-size: 0.8rem; }

.promo-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.promo { border-radius: 20px; padding: 28px; min-height: 150px; display: flex; flex-direction: column; justify-content: flex-end; color: #fff; transition: transform 0.2s; }
.promo:hover { transform: translateY(-4px); }
.promo h3 { color: #fff; font-family: var(--font-heading); font-size: 1.25rem; margin: 0 0 6px; }
.promo small { opacity: 0.85; font-size: 0.9rem; }
.promo-1 { background: linear-gradient(160deg, #101826, #101826); }
.promo-2 { background: linear-gradient(160deg, #4A5A72, #101826); }
.promo-3 { background: linear-gradient(160deg, #8A9AAE, #4A5A72); }

.author-spotlight { background: var(--accent-light); margin: 30px 0; }
.author-spotlight-inner { display: grid; grid-template-columns: 340px 1fr; gap: 56px; align-items: center; padding-top: 56px; padding-bottom: 56px; }
.author-spotlight-photo { aspect-ratio: 1; border-radius: 28px; background: linear-gradient(150deg, #101826, #C9B28A) center / cover; display: flex; align-items: center; justify-content: center; color: #fff; font-family: var(--font-heading); font-size: 5rem; font-weight: 700; }
.author-spotlight h2 { font-family: var(--font-heading); font-size: 2.3rem; line-height: 1.15; margin: 14px 0; color: var(--text); }
.author-spotlight p { color: var(--text-muted); max-width: 56ch; }
.author-spotlight-meta { font-weight: 700; color: var(--accent) !important; margin-bottom: 22px; }

.post-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; }
.post-card { display: block; color: var(--text); }
.post-card-img { display: block; aspect-ratio: 16 / 10; border-radius: 16px; background: var(--bg-secondary) center / cover; transition: transform 0.25s; }
.post-card:hover .post-card-img { transform: translateY(-4px); }
.post-card small { display: block; margin-top: 14px; letter-spacing: 0.06em; font-size: 0.75rem; color: var(--accent); font-weight: 700; }
.post-card h3 { font-family: var(--font-heading); font-size: 1.2rem; line-height: 1.3; margin: 6px 0 0; color: var(--text); }
.post-card p { color: var(--text-muted); font-size: 0.92rem; margin: 8px 0 0; }

.blog-article { max-width: 760px; margin: 0 auto; padding: 48px 0 20px; }
.blog-article h1 { font-family: var(--font-heading); font-size: 2.6rem; line-height: 1.15; margin: 8px 0 14px; color: var(--text); }
.blog-meta { letter-spacing: 0.06em; font-weight: 700; color: var(--accent); font-size: 0.78rem; }
.blog-lead { font-size: 1.15rem; color: var(--text-muted); }
.blog-hero-img { width: 100%; border-radius: 20px; margin: 22px 0 10px; display: block; }

@media (max-width: 900px) {
  .cat-tiles { grid-template-columns: repeat(3, 1fr); }
  .promo-row, .post-grid { grid-template-columns: 1fr; }
  .author-spotlight-inner { grid-template-columns: 1fr; gap: 28px; }
  .author-spotlight-photo { max-width: 260px; }
}

/* ============ HOMEPAGE HERO (matches the approved mockup) ============ */
.hero-b { background: var(--bg-secondary); padding: 64px 0; }
.hero-b-inner { display: grid; grid-template-columns: 1.1fr 1fr; gap: 48px; align-items: center; }
.hero-b h1 { font-family: inherit; font-weight: 800; font-size: clamp(2.2rem, 4.6vw, 3.4rem); line-height: 1.1; letter-spacing: -0.015em; color: var(--text); margin: 0 0 18px; }
.hero-b p { font-size: 1.1rem; line-height: 1.6; color: var(--text-muted); max-width: 46ch; margin: 0 0 28px; }
.hero-b-collage { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: repeat(2, minmax(0, 1fr)); gap: 16px; height: 440px; }
.hero-b-tile { border-radius: 22px; background: linear-gradient(160deg, #101826, #4A5A72); display: flex; align-items: center; justify-content: center; padding: 18px; overflow: hidden; transition: transform 0.2s; }
.hero-b-tile-1 { grid-row: span 2; background: linear-gradient(170deg, #101826, #101826 60%, #C9B28A); }
.hero-b-tile-3 { background: linear-gradient(160deg, #DDE1E6, #C9B28A); }
.hero-b-tile img { max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; border-radius: 6px 12px 12px 6px; box-shadow: 0 14px 30px rgba(20, 8, 40, 0.4); }
a.hero-b-tile:hover { transform: translateY(-4px); }
@media (max-width: 900px) {
  .hero-b-inner { grid-template-columns: 1fr; gap: 32px; }
  .hero-b-collage { height: 360px; }
}
