/* ==========================================================================
   TruyệnHub — Design system "Tiểu thư" (coral + hồng phấn), mobile-first
   ========================================================================== */

:root {
  /* Màu thương hiệu */
  --coral-50: #fff3ef;
  --coral-100: #fde3db;
  --coral-300: #f4a08c;
  --coral-500: #e6654a;
  --coral-600: #d5523a;
  --coral-700: #b5412d;
  --pink-50: #fff6f8;
  --pink-100: #fce8ec;
  --pink-200: #f7c6d0;
  --pink-300: #f0a7b7;
  --rose-500: #e88aa0;
  --rose-600: #d86f88;
  --gold-100: #fbf1d9;
  --gold-300: #e9cf8f;
  --gold-500: #c9a24a;
  --gold-600: #a8832f;
  --mint-100: #d9f5e8;
  --mint-700: #2c8e70;
  --peach-100: #ffecd9;
  --peach-700: #c8642c;

  /* Trung tính ấm */
  --ivory: #fff9f5;
  --paper: #fffdfb;
  --line: #f1e3dc;
  --line-strong: #e7d2c9;
  --ink: #3a2530;
  --ink-2: #5e4651;
  --muted: #8f7781;
  --white: #fff;

  /* Gradient & hiệu ứng */
  --grad-primary: linear-gradient(135deg, #ec7357 0%, #e6654a 35%, #e7809a 100%);
  --grad-soft: linear-gradient(160deg, #fff4f0 0%, #fde8ee 100%);
  --grad-gold: linear-gradient(135deg, #f6e3b0 0%, #d8b25f 55%, #b98c34 100%);
  --shadow-sm: 0 1px 2px rgba(122, 52, 70, 0.06), 0 2px 8px rgba(232, 138, 160, 0.08);
  --shadow-md: 0 6px 22px rgba(214, 111, 136, 0.16);
  --shadow-lg: 0 18px 44px rgba(196, 84, 108, 0.2);
  --shadow-btn: 0 8px 20px -6px rgba(230, 101, 74, 0.55);

  /* Kiểu chữ */
  --font-display: 'Playfair Display', 'Times New Roman', serif;
  --font-body: 'Be Vietnam Pro', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;

  /* Kích thước */
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 22px;
  --radius-pill: 999px;
  --header-h: 60px;
  --bottom-nav-h: 64px;
  --container: 1200px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--ivory);
  background-image:
    radial-gradient(1200px 500px at 110% -10%, rgba(247, 198, 208, 0.35), transparent 60%),
    radial-gradient(900px 400px at -10% 0%, rgba(253, 227, 219, 0.5), transparent 60%);
  background-repeat: no-repeat;
  padding-bottom: calc(var(--bottom-nav-h) + var(--safe-bottom));
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.2; margin: 0; letter-spacing: -0.01em; }
p { margin: 0; }
:focus-visible { outline: 2px solid var(--coral-500); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.container { width: 100%; max-width: var(--container); margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.serif { font-family: var(--font-display); }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: 8px; }
.hide-mobile { display: none !important; }
main { min-height: 60vh; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 20px; border-radius: var(--radius-pill);
  border: 1.5px solid transparent; font-weight: 600; font-size: 15px; white-space: nowrap;
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease), background 0.2s, color 0.2s, border-color 0.2s;
  -webkit-tap-highlight-color: transparent; user-select: none;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--grad-primary); color: #fff; box-shadow: var(--shadow-btn); }
.btn-primary:hover { box-shadow: 0 12px 26px -8px rgba(230, 101, 74, 0.7); transform: translateY(-1px); }
.btn-outline { background: var(--white); border-color: var(--line-strong); color: var(--ink); }
.btn-outline:hover { border-color: var(--coral-300); color: var(--coral-600); }
.btn-soft { background: var(--coral-50); color: var(--coral-600); }
.btn-soft:hover { background: var(--coral-100); }
.btn-gold { background: var(--grad-gold); color: #4a3510; box-shadow: 0 8px 20px -8px rgba(185, 140, 52, 0.6); }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--pink-50); }
.btn-block { width: 100%; }
.btn-lg { min-height: 52px; font-size: 16px; padding: 0 24px; }
.btn-sm { min-height: 36px; padding: 0 14px; font-size: 14px; }
.btn[disabled], .btn.is-loading { opacity: 0.6; pointer-events: none; }
.icon { width: 20px; height: 20px; flex: none; }
.icon-sm { width: 16px; height: 16px; }

/* ---------- Chips / tags / badges ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 14px;
  border-radius: var(--radius-pill); background: var(--white); border: 1px solid var(--line);
  font-size: 14px; font-weight: 500; color: var(--ink-2); white-space: nowrap;
  transition: all 0.2s var(--ease);
}
.chip:hover, .chip.is-active { border-color: var(--coral-300); color: var(--coral-600); background: var(--coral-50); }
.chip.is-active { font-weight: 600; }
.tag { color: var(--rose-600); font-weight: 500; font-size: 14px; }
.tag:hover { color: var(--coral-600); text-decoration: underline; }
.tag-pill { display: inline-flex; align-items: center; height: 30px; padding: 0 12px; border-radius: var(--radius-pill); border: 1px solid var(--pink-200); background: var(--pink-50); color: var(--rose-600); font-size: 13px; font-weight: 500; }
.tag-pill:hover { background: var(--pink-100); }
.badge { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 9px; border-radius: var(--radius-pill); font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge-full { background: var(--mint-100); color: var(--mint-700); }
.badge-ongoing { background: var(--peach-100); color: var(--peach-700); }
.badge-hot { background: var(--grad-primary); color: #fff; }
.badge-vip { background: var(--grad-gold); color: #4a3510; }
.badge-free { background: var(--pink-100); color: var(--rose-600); }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255, 249, 245, 0.86);
  backdrop-filter: saturate(160%) blur(14px); -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid rgba(241, 227, 220, 0.8);
  transition: transform 0.3s var(--ease);
}
.site-header.is-hidden { transform: translateY(-100%); }
.header-inner { height: var(--header-h); display: flex; align-items: center; gap: 12px; }
.logo { display: inline-flex; align-items: flex-start; gap: 2px; font-family: var(--font-display); font-weight: 700; font-size: 24px; color: var(--ink); letter-spacing: -0.02em; }
.logo b { color: var(--coral-500); font-weight: 700; }
.logo svg { width: 22px; height: 22px; margin: -6px 0 0 -4px; transform: rotate(14deg); }
.main-nav { display: none; }
.header-search { display: none; }
.header-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.coin-pill {
  display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 6px 0 8px; border-radius: var(--radius-pill);
  background: var(--grad-primary); color: #fff; font-weight: 600; font-size: 14px; box-shadow: var(--shadow-btn);
}
.coin-pill .coin { width: 22px; height: 22px; }
.coin-pill .plus { width: 22px; height: 22px; border-radius: 50%; background: rgba(255, 255, 255, 0.25); display: grid; place-items: center; font-size: 16px; line-height: 1; }
.avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; background: var(--pink-100); border: 2px solid #fff; box-shadow: var(--shadow-sm); display: grid; place-items: center; font-weight: 700; color: var(--rose-600); font-size: 15px; overflow: hidden; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: transparent; border: 0; color: var(--ink-2); }
.icon-btn:hover { background: var(--pink-50); color: var(--coral-600); }

/* Dropdown thể loại (desktop) */
.nav-item { position: relative; }
.nav-link { display: inline-flex; align-items: center; gap: 4px; height: var(--header-h); padding: 0 4px; font-weight: 500; font-size: 15px; color: var(--ink-2); border-bottom: 2px solid transparent; transition: color 0.2s, border-color 0.2s; }
.nav-link:hover, .nav-link.is-active { color: var(--coral-600); border-bottom-color: var(--coral-500); }
.mega {
  position: absolute; top: calc(100% - 6px); left: -16px; width: 560px; padding: 18px;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px;
  opacity: 0; visibility: hidden; transform: translateY(6px); transition: all 0.22s var(--ease);
}
.nav-item:hover .mega, .nav-item:focus-within .mega { opacity: 1; visibility: visible; transform: none; }
.mega a { padding: 8px 10px; border-radius: 10px; font-size: 14px; color: var(--ink-2); }
.mega a:hover { background: var(--pink-50); color: var(--coral-600); }

/* ---------- Search ---------- */
.search-box { position: relative; display: flex; align-items: center; }
.search-box input {
  width: 100%; height: 46px; padding: 0 16px 0 44px; border-radius: var(--radius-pill);
  border: 1.5px solid var(--line-strong); background: var(--white); font-size: 16px; outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.search-box input:focus { border-color: var(--coral-300); box-shadow: 0 0 0 4px rgba(230, 101, 74, 0.1); }
.search-box .icon { position: absolute; left: 15px; color: var(--muted); pointer-events: none; }
.mobile-search { padding: 4px 0 8px; }

/* ---------- Bottom nav (mobile) ---------- */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  background: rgba(255, 253, 251, 0.95); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line); padding-bottom: var(--safe-bottom);
  box-shadow: 0 -6px 24px rgba(214, 111, 136, 0.08);
}
.bottom-nav ul { list-style: none; margin: 0 auto; padding: 6px 6px; display: grid; grid-template-columns: repeat(5, 1fr); max-width: 560px; }
.bottom-nav a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px; border-radius: 16px; font-size: 11px; font-weight: 600; color: var(--muted); -webkit-tap-highlight-color: transparent; }
.bottom-nav a .icon { width: 24px; height: 24px; }
.bottom-nav a.is-active { color: var(--coral-600); }
.bottom-nav a.is-active .nav-ico { background: var(--grad-primary); color: #fff; box-shadow: var(--shadow-btn); }
.bottom-nav .nav-ico { width: 48px; height: 30px; border-radius: 15px; display: grid; place-items: center; transition: all 0.25s var(--ease); }

/* ---------- Section ---------- */
.section { padding: 22px 0 6px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.section-title { display: flex; align-items: center; gap: 10px; font-size: 22px; font-weight: 700; color: var(--ink); }
.section-title::before {
  content: ''; width: 26px; height: 14px; flex: none;
  background: radial-gradient(circle, var(--pink-300) 2px, transparent 2.5px) 0 0 / 7px 7px;
  border-radius: 3px; opacity: 0.9;
}
.section-title .sprig { width: 44px; height: 22px; color: var(--rose-500); opacity: 0.75; flex: none; }
.section-more { font-size: 14px; font-weight: 600; color: var(--coral-600); display: inline-flex; align-items: center; gap: 2px; white-space: nowrap; }
.section-more:hover { color: var(--coral-700); }

/* ---------- Hero slider ---------- */
.hero { padding-top: 12px; }
.slider { position: relative; }
.slides { display: flex; gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; margin: 0 -16px; padding: 4px 16px 6px; }
.slides::-webkit-scrollbar { display: none; }
.slide {
  position: relative; flex: 0 0 92%; scroll-snap-align: center; border-radius: var(--radius-lg); overflow: hidden;
  min-height: 210px; display: flex; align-items: flex-end; color: #fff; box-shadow: var(--shadow-md); isolation: isolate;
}
.slide-bg { position: absolute; inset: 0; z-index: -2; background-size: cover; background-position: center 30%; transform: scale(1.02); transition: transform 6s ease; }
.slide:hover .slide-bg { transform: scale(1.08); }
.slide::after { content: ''; position: absolute; inset: 0; z-index: -1; background: linear-gradient(180deg, rgba(58, 37, 48, 0) 20%, rgba(58, 37, 48, 0.78) 100%); }
.slide-body { padding: 18px; width: 100%; display: flex; gap: 14px; align-items: flex-end; }
.slide-cover { width: 84px; flex: none; aspect-ratio: 2/3; border-radius: 10px; object-fit: cover; box-shadow: 0 10px 24px rgba(0,0,0,0.3); border: 2px solid rgba(255,255,255,0.7); }
.slide-title { font-size: 22px; font-weight: 700; text-shadow: 0 2px 12px rgba(0,0,0,0.25); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.slide-meta { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 0; }
.slide-meta .tag-pill { background: rgba(255,255,255,0.18); border-color: rgba(255,255,255,0.35); color: #fff; backdrop-filter: blur(6px); }
.slide-desc { display: none; }
.slide-actions { display: none; }
.dots { display: flex; justify-content: center; gap: 6px; margin-top: 10px; }
.dots button { width: 8px; height: 8px; padding: 0; border: 0; border-radius: 8px; background: var(--pink-200); transition: all 0.3s var(--ease); }
.dots button.is-active { width: 26px; background: var(--grad-primary); }
.petals { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 1; }
.petal { position: absolute; top: -20px; width: 12px; height: 10px; background: radial-gradient(circle at 30% 30%, #ffe1e8, #f3a4b8); border-radius: 12px 1px 12px 1px; opacity: 0.85; animation: fall linear infinite; }
@keyframes fall { to { transform: translate3d(-60px, 340px, 0) rotate(300deg); opacity: 0; } }

/* ---------- Category chips row ---------- */
.chip-row { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 2px 16px 4px; }
.chip-row::-webkit-scrollbar { display: none; }

/* ---------- Book card ---------- */
.book-row { display: flex; gap: 12px; overflow-x: auto; scroll-snap-type: x proximity; scrollbar-width: none; margin: 0 -16px; padding: 4px 16px 12px; }
.book-row::-webkit-scrollbar { display: none; }
.book-row > .book { flex: 0 0 31%; min-width: 108px; max-width: 150px; scroll-snap-align: start; }
.book-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px 12px; }
.book { position: relative; display: flex; flex-direction: column; gap: 8px; }
.book-cover {
  position: relative; aspect-ratio: 2 / 3; border-radius: 12px; overflow: hidden; background: var(--pink-100);
  box-shadow: var(--shadow-sm); transition: transform 0.35s var(--ease), box-shadow 0.35s var(--ease);
}
.book-cover img { width: 100%; height: 100%; object-fit: cover; }
.book:hover .book-cover { transform: translateY(-4px); box-shadow: var(--shadow-md); }
.book-cover .badges { position: absolute; left: 6px; bottom: 6px; display: flex; gap: 4px; flex-wrap: wrap; }
.ribbon {
  position: absolute; top: 9px; right: -26px; width: 90px; transform: rotate(45deg); text-align: center;
  background: var(--grad-gold); color: #4a3510; font-size: 10px; font-weight: 800; letter-spacing: 0.12em; padding: 3px 0;
  box-shadow: 0 2px 6px rgba(120, 80, 20, 0.3);
}
.hot-flag { position: absolute; top: 6px; left: 6px; }
.book-title { font-size: 14px; font-weight: 600; line-height: 1.35; color: var(--ink); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.book:hover .book-title { color: var(--coral-600); }
.book-sub { font-size: 12px; color: var(--muted); margin-top: -4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Rank list ---------- */
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); padding: 16px; position: relative; }
.panel-lace::before {
  content: ''; position: absolute; inset: -5px; border-radius: calc(var(--radius-lg) + 5px); z-index: -1;
  background: radial-gradient(circle, var(--pink-200) 2.2px, transparent 2.7px) 0 0 / 9px 9px;
  -webkit-mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0); mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  padding: 5px;
}
.panel-title { font-size: 20px; font-weight: 700; margin-bottom: 10px; }
.tabs { display: flex; gap: 4px; background: var(--pink-50); padding: 4px; border-radius: var(--radius-pill); margin-bottom: 10px; }
.tabs button, .tab-link { flex: 1; height: 34px; border: 0; border-radius: var(--radius-pill); background: transparent; font-size: 13px; font-weight: 600; color: var(--muted); display: grid; place-items: center; }
.tabs button.is-active, .is-active-tab { background: var(--white); color: var(--coral-600); box-shadow: var(--shadow-sm); }
.rank-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.rank-item { display: flex; align-items: center; gap: 12px; padding: 8px 4px; border-radius: 12px; }
.rank-item:hover { background: var(--pink-50); }
.rank-no { width: 28px; flex: none; font-family: var(--font-display); font-size: 22px; font-weight: 700; color: var(--pink-300); text-align: center; }
.rank-item:nth-child(1) .rank-no { color: var(--coral-500); }
.rank-item:nth-child(2) .rank-no { color: var(--rose-500); }
.rank-item:nth-child(3) .rank-no { color: var(--gold-500); }
.rank-cover { width: 44px; height: 62px; flex: none; border-radius: 8px; object-fit: cover; background: var(--pink-100); }
.rank-info { min-width: 0; flex: 1; }
.rank-title { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank-meta { font-size: 12px; color: var(--muted); }

/* ---------- Update list ---------- */
.update-list { list-style: none; margin: 0; padding: 0; }
.update-item { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px dashed var(--line-strong); align-items: center; }
.update-item:last-child { border-bottom: 0; }
.update-cover { width: 52px; height: 72px; flex: none; border-radius: 9px; object-fit: cover; background: var(--pink-100); }
.update-info { min-width: 0; flex: 1; }
.update-title { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.update-title:hover { color: var(--coral-600); }
.update-meta { font-size: 13px; color: var(--muted); display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.update-meta .dot::before { content: '·'; }

/* ---------- Story page ---------- */
.story-hero { position: relative; overflow: hidden; padding: 20px 0 0; isolation: isolate; }
.story-hero-bg { position: absolute; inset: -40px; z-index: -2; background-size: cover; background-position: center; filter: blur(36px) saturate(130%); opacity: 0.55; }
.story-hero::after { content: ''; position: absolute; inset: 0; z-index: -1; background: linear-gradient(180deg, rgba(255, 238, 242, 0.35) 0%, var(--ivory) 78%); }
.story-head { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 14px; }
.story-cover { width: 170px; position: relative; }
.story-cover .book-cover { box-shadow: var(--shadow-lg); border-radius: 14px; }
.story-title { font-size: 28px; font-weight: 700; }
.story-byline { font-size: 14px; color: var(--ink-2); }
.story-byline a { color: var(--coral-600); font-weight: 500; }
.story-stats { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 12px; align-items: center; font-size: 14px; color: var(--ink-2); }
.stat-chip { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: var(--radius-pill); background: rgba(255,255,255,0.75); border: 1px solid var(--line); font-weight: 500; }
.stars { color: #f2b33d; letter-spacing: 1px; }
.tag-list { display: flex; flex-wrap: wrap; gap: 6px 8px; justify-content: center; }
.cta-card { margin-top: 18px; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.cta-combo { position: relative; }
.save-badge { position: absolute; top: -10px; right: 14px; background: var(--gold-100); color: var(--gold-600); border: 1px solid var(--gold-300); font-size: 12px; font-weight: 700; padding: 2px 10px; border-radius: var(--radius-pill); }
.cta-row { display: flex; gap: 10px; align-items: center; }
.cta-row .btn { flex: 1; }
.owned-note { display: flex; align-items: center; gap: 8px; justify-content: center; color: var(--mint-700); font-weight: 600; font-size: 14px; }
.note-box { display: flex; gap: 10px; padding: 12px 14px; border-radius: var(--radius); background: var(--pink-50); border: 1px solid var(--pink-100); color: var(--ink-2); font-size: 14px; line-height: 1.5; }
.note-box .icon { color: var(--rose-500); margin-top: 1px; }
.desc { position: relative; color: var(--ink-2); font-size: 15px; line-height: 1.75; white-space: pre-line; }
.desc.is-clamped { max-height: 9.5em; overflow: hidden; }
.desc.is-clamped::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 3em; background: linear-gradient(transparent, var(--ivory)); }
.link-btn { background: none; border: 0; color: var(--coral-600); font-weight: 600; padding: 6px 0; font-size: 14px; }
.chapter-tools { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.chapter-tools input { flex: 1; height: 40px; border-radius: var(--radius-pill); border: 1.5px solid var(--line-strong); padding: 0 14px; background: #fff; font-size: 15px; min-width: 0; }
.chapter-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr; }
.chapter-list a { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 0 4px; border-bottom: 1px solid var(--line); font-size: 15px; }
.chapter-list a:hover { color: var(--coral-600); }
.chapter-list .ch-title { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chapter-list .ch-lock { display: inline-flex; align-items: center; gap: 4px; color: var(--rose-600); font-size: 13px; font-weight: 600; white-space: nowrap; }
.chapter-list .ch-owned { color: var(--mint-700); font-size: 13px; font-weight: 600; }
.chapter-list a.is-read { color: var(--muted); }
.sticky-cta {
  position: fixed; left: 0; right: 0; bottom: calc(var(--bottom-nav-h) + var(--safe-bottom)); z-index: 55; padding: 10px 16px;
  background: linear-gradient(180deg, rgba(255,249,245,0) 0%, rgba(255,249,245,0.96) 30%); transform: translateY(120%); transition: transform 0.3s var(--ease);
}
.sticky-cta.is-visible { transform: none; }
.sticky-cta .inner { display: flex; gap: 8px; max-width: 560px; margin: 0 auto; }
.sticky-cta .btn-outline { flex: 0 0 auto; }
.sticky-cta .btn-primary { flex: 1; }

/* ---------- Listing / filter ---------- */
.page-head { padding: 18px 0 6px; }
.page-title { font-size: 26px; font-weight: 700; }
.page-sub { color: var(--muted); font-size: 14px; margin-top: 4px; }
.breadcrumb { display: flex; flex-wrap: wrap; gap: 6px; font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.breadcrumb a:hover { color: var(--coral-600); }
.breadcrumb span + span::before, .breadcrumb a + span::before, .breadcrumb a + a::before { content: '›'; margin-right: 6px; color: var(--pink-300); }
.filter-bar { display: flex; gap: 8px; align-items: center; margin: 12px 0 16px; overflow-x: auto; scrollbar-width: none; }
.filter-bar::-webkit-scrollbar { display: none; }
.select { height: 38px; border-radius: var(--radius-pill); border: 1px solid var(--line-strong); background: #fff; padding: 0 30px 0 14px; font-size: 14px; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23d86f88' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
.empty { text-align: center; padding: 48px 16px; color: var(--muted); }
.empty svg { width: 80px; height: 80px; margin: 0 auto 12px; color: var(--pink-300); }
.pagination { display: flex; justify-content: center; gap: 6px; margin: 24px 0 8px; flex-wrap: wrap; }
.pagination a, .pagination span { min-width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; border: 1px solid var(--line); background: #fff; font-weight: 600; font-size: 14px; padding: 0 10px; }
.pagination a:hover { border-color: var(--coral-300); color: var(--coral-600); }
.pagination .is-current { background: var(--grad-primary); color: #fff; border-color: transparent; }
.cat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 12px; }
.cat-tile { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; border-radius: var(--radius); background: var(--paper); border: 1px solid var(--line); box-shadow: var(--shadow-sm); transition: all 0.25s var(--ease); }
.cat-tile:hover { border-color: var(--coral-300); transform: translateY(-2px); box-shadow: var(--shadow-md); background: var(--grad-soft); }
.cat-name { font-size: 18px; font-weight: 700; color: var(--ink); }
.cat-count { font-size: 13px; color: var(--muted); }

/* ---------- Bottom sheet & modal ---------- */
.sheet-backdrop { position: fixed; inset: 0; z-index: 90; background: rgba(58, 37, 48, 0.42); opacity: 0; visibility: hidden; transition: all 0.25s var(--ease); backdrop-filter: blur(2px); }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 91; max-height: 88vh; overflow-y: auto;
  background: var(--paper); border-radius: 24px 24px 0 0; padding: 10px 18px calc(20px + var(--safe-bottom));
  transform: translateY(105%); transition: transform 0.35s var(--ease); box-shadow: 0 -12px 40px rgba(122, 52, 70, 0.2);
}
.sheet::before { content: ''; display: block; width: 44px; height: 5px; border-radius: 5px; background: var(--line-strong); margin: 0 auto 12px; }
.sheet.is-open { transform: none; }
.sheet.is-open + .sheet-backdrop, .sheet-backdrop.is-open { opacity: 1; visibility: visible; }
.sheet-title { font-size: 22px; font-weight: 700; text-align: center; }
.sheet-sub { text-align: center; color: var(--muted); font-size: 14px; margin-top: 2px; }
.lace-top { position: relative; }
.lace-top::after { content: ''; position: absolute; left: 0; right: 0; top: -9px; height: 10px; background: radial-gradient(circle at 6px 10px, var(--paper) 6px, transparent 6.5px) 0 0 / 12px 10px repeat-x; }
.option-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 54px; padding: 0 2px; border-bottom: 1px solid var(--line); }
.option-row:last-child { border-bottom: 0; }
.combo-card { border: 1.5px solid var(--gold-300); background: linear-gradient(135deg, #fffaf0, #fdf1dc); border-radius: var(--radius); padding: 14px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.combo-card strong { font-size: 16px; }
.combo-card small { display: block; color: var(--gold-600); font-weight: 600; font-size: 13px; }
.alert { display: flex; gap: 8px; align-items: center; padding: 10px 12px; border-radius: 12px; font-size: 14px; font-weight: 500; }
.alert-warn { background: var(--coral-50); color: var(--coral-700); }
.alert-ok { background: var(--mint-100); color: var(--mint-700); }
.alert-info { background: var(--pink-50); color: var(--ink-2); }
.switch { position: relative; width: 50px; height: 30px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; border-radius: 30px; background: var(--line-strong); transition: background 0.2s; }
.switch span::before { content: ''; position: absolute; width: 24px; height: 24px; left: 3px; top: 3px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0,0,0,0.15); transition: transform 0.25s var(--ease); }
.switch input:checked + span { background: var(--coral-500); }
.switch input:checked + span::before { transform: translateX(20px); }

/* ---------- Forms ---------- */
.auth-wrap { max-width: 440px; margin: 0 auto; padding: 28px 16px 40px; }
.auth-card { padding: 26px 20px; }
.auth-title { font-size: 28px; text-align: center; }
.auth-sub { text-align: center; color: var(--muted); margin: 6px 0 20px; font-size: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 14px; font-weight: 600; color: var(--ink-2); }
.input, .textarea { width: 100%; min-height: 48px; padding: 0 14px; border-radius: 14px; border: 1.5px solid var(--line-strong); background: #fff; font-size: 16px; outline: none; transition: border-color 0.2s, box-shadow 0.2s; }
.textarea { padding: 12px 14px; min-height: 120px; resize: vertical; line-height: 1.6; }
.input:focus, .textarea:focus { border-color: var(--coral-300); box-shadow: 0 0 0 4px rgba(230, 101, 74, 0.1); }
.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; margin: 16px 0; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--line-strong); }
.btn-google { background: #fff; border: 1.5px solid var(--line-strong); color: var(--ink); }
.btn-google:hover { border-color: var(--pink-300); }
.form-foot { text-align: center; font-size: 14px; margin-top: 16px; color: var(--muted); }
.form-foot a { color: var(--coral-600); font-weight: 600; }
.form-error { margin-bottom: 14px; }

/* ---------- Wallet / topup ---------- */
.balance-card { position: relative; overflow: hidden; padding: 20px; border-radius: var(--radius-lg); background: linear-gradient(135deg, #fde3e9 0%, #fbd0da 50%, #f8c9bd 100%); box-shadow: var(--shadow-md); }
.balance-card .label { font-size: 14px; color: var(--ink-2); }
.balance-card .value { font-family: var(--font-display); font-size: 34px; font-weight: 700; }
.balance-card .coin-big { position: absolute; right: 18px; top: 50%; transform: translateY(-50%); width: 72px; height: 72px; filter: drop-shadow(0 8px 16px rgba(185, 140, 52, 0.4)); animation: float 4s ease-in-out infinite; }
@keyframes float { 50% { transform: translateY(-58%) rotate(-6deg); } }
.pkg-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.pkg { position: relative; overflow: hidden; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 92px; border-radius: var(--radius); border: 1.5px solid var(--line); background: #fff; cursor: pointer; transition: all 0.2s var(--ease); text-align: center; }
.pkg input { position: absolute; opacity: 0; }
.pkg strong { font-size: 19px; }
.pkg span { font-size: 14px; color: var(--ink-2); }
.pkg:hover { border-color: var(--pink-300); }
.pkg:has(input:checked) { border-color: var(--coral-500); background: var(--coral-50); box-shadow: 0 0 0 3px rgba(230, 101, 74, 0.12); }
.pkg .bonus { position: absolute; top: 6px; right: 6px; background: var(--pink-100); color: var(--rose-600); font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 8px; }
.pkg .pop { position: absolute; top: 10px; left: -24px; transform: rotate(-45deg); background: var(--grad-primary); color: #fff; font-size: 10px; font-weight: 700; width: 90px; text-align: center; padding: 2px 0; }
.qr-card { display: grid; grid-template-columns: 1fr; gap: 14px; padding: 16px; }
.qr-card img { width: 100%; max-width: 260px; margin: 0 auto; border-radius: 12px; border: 1px solid var(--line); }
.kv { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--line-strong); font-size: 14px; }
.kv:last-child { border-bottom: 0; }
.kv b { font-size: 15px; word-break: break-all; text-align: right; }
.copy-btn { border: 0; background: var(--pink-50); color: var(--rose-600); width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: none; }
.copy-btn:hover { background: var(--pink-100); }
.status-pill { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: var(--radius-pill); font-size: 12px; font-weight: 700; }
.status-pending { background: var(--peach-100); color: var(--peach-700); }
.status-approved, .status-paid { background: var(--mint-100); color: var(--mint-700); }
.status-rejected, .status-expired { background: #f3e6ea; color: var(--muted); }

/* ---------- Account ---------- */
.account-head { display: flex; align-items: center; gap: 14px; padding: 18px 0 8px; }
.account-head .avatar { width: 60px; height: 60px; font-size: 24px; }
.menu-list { list-style: none; margin: 0; padding: 0; }
.menu-list a, .menu-list button { width: 100%; display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 0 4px; border: 0; background: none; border-bottom: 1px solid var(--line); font-size: 15px; font-weight: 500; text-align: left; }
.menu-list a:hover, .menu-list button:hover { color: var(--coral-600); }
.menu-list .icon { color: var(--rose-500); }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.table th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 600; }
.plus-xu { color: var(--mint-700); font-weight: 700; }
.minus-xu { color: var(--coral-600); font-weight: 700; }

/* ---------- Footer ---------- */
.site-footer { margin-top: 40px; padding: 30px 0 24px; border-top: 1px solid var(--line); background: linear-gradient(180deg, transparent, rgba(252, 232, 236, 0.5)); font-size: 14px; color: var(--ink-2); }
.footer-grid { display: grid; gap: 20px; }
.footer-grid h3 { font-family: var(--font-body); font-size: 14px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink); margin-bottom: 8px; }
.footer-grid ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 14px; }
.footer-grid a:hover { color: var(--coral-600); }
.copyright { margin-top: 20px; font-size: 13px; color: var(--muted); text-align: center; }

/* ---------- Toast ---------- */
.toast-wrap { position: fixed; left: 50%; bottom: calc(var(--bottom-nav-h) + 16px + var(--safe-bottom)); transform: translateX(-50%); z-index: 120; display: flex; flex-direction: column; gap: 8px; width: min(92vw, 420px); pointer-events: none; }
.toast { pointer-events: auto; padding: 12px 16px; border-radius: 14px; background: var(--ink); color: #fff; font-size: 14px; font-weight: 500; box-shadow: var(--shadow-lg); animation: toastIn 0.35s var(--ease); }
.toast.ok { background: #2f6f5b; }
.toast.err { background: var(--coral-700); }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px); } }

/* ---------- Skeleton / misc ---------- */
.fade-in { animation: fadeIn 0.5s var(--ease) both; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } }
.grid-2 { display: grid; gap: 16px; }

/* ==========================================================================
   Tablet ≥ 640px
   ========================================================================== */
@media (min-width: 640px) {
  .container { padding: 0 24px; }
  .slides { margin: 0 -24px; padding: 4px 24px 6px; }
  .chip-row, .book-row { margin: 0 -24px; padding-left: 24px; padding-right: 24px; }
  .slide { flex-basis: 80%; min-height: 260px; }
  .slide-cover { width: 110px; }
  .book-grid { grid-template-columns: repeat(4, 1fr); gap: 20px 16px; }
  .book-row > .book { flex-basis: 22%; }
  .pkg-grid { grid-template-columns: repeat(3, 1fr); }
  .qr-card { grid-template-columns: 240px 1fr; align-items: center; }
  .chapter-list { grid-template-columns: 1fr 1fr; column-gap: 24px; }
  .cat-grid { grid-template-columns: repeat(3, 1fr); gap: 14px; }
  .footer-grid { grid-template-columns: 2fr 1fr 1fr; }
}

/* ==========================================================================
   Desktop ≥ 1024px
   ========================================================================== */
@media (min-width: 1024px) {
  body { padding-bottom: 0; }
  .bottom-nav, .mobile-search, .sticky-cta { display: none !important; }
  .hide-mobile { display: revert !important; }
  .hide-desktop { display: none !important; }
  :root { --header-h: 72px; }
  .logo { font-size: 28px; }
  .main-nav { display: flex; gap: 24px; margin-left: 28px; }
  .header-search { display: block; flex: 1; max-width: 320px; margin-left: auto; }
  .header-search input { height: 42px; }
  .header-actions { margin-left: 12px; }
  .coin-pill { height: 40px; padding: 0 8px 0 10px; font-size: 15px; }

  .home-top { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; align-items: start; }
  .slides { margin: 0; padding: 0; overflow: hidden; }
  .slide { flex-basis: 100%; min-height: 380px; align-items: center; }
  .slide::after { background: linear-gradient(90deg, rgba(58, 37, 48, 0.0) 0%, rgba(58, 37, 48, 0.1) 40%, rgba(58, 37, 48, 0.72) 100%); }
  .slide-body { padding: 36px; justify-content: flex-end; }
  .slide-cover { display: none; }
  .slide-text { max-width: 52%; }
  .slide-title { font-size: 40px; }
  .slide-desc { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; margin-top: 10px; font-size: 15px; opacity: 0.92; line-height: 1.6; }
  .slide-actions { display: flex; gap: 10px; margin-top: 18px; }
  .slide-actions .btn-outline { background: rgba(255,255,255,0.15); color: #fff; border-color: rgba(255,255,255,0.55); backdrop-filter: blur(6px); }
  .slider-arrow { position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; border-radius: 50%; border: 0; background: rgba(255,255,255,0.9); box-shadow: var(--shadow-md); display: grid; place-items: center; color: var(--ink); z-index: 3; transition: transform 0.2s; }
  .slider-arrow:hover { transform: translateY(-50%) scale(1.08); color: var(--coral-600); }
  .slider-arrow.prev { left: 14px; }
  .slider-arrow.next { right: 14px; }

  .section { padding: 36px 0 8px; }
  .section-title { font-size: 28px; }
  .book-row { overflow: visible; display: grid; grid-template-columns: repeat(6, 1fr); gap: 20px; margin: 0; padding: 4px 0 12px; }
  .book-row > .book { min-width: 0; max-width: none; }
  .book-grid { grid-template-columns: repeat(6, 1fr); gap: 26px 20px; }
  .book-title { font-size: 15px; }
  .home-split { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 28px; align-items: start; }

  .story-hero { padding: 40px 0 10px; }
  .story-head { flex-direction: row; align-items: flex-start; text-align: left; gap: 36px; }
  .story-cover { width: 240px; flex: none; }
  .story-title { font-size: 40px; }
  .story-stats, .tag-list { justify-content: flex-start; }
  .story-main { flex: 1; display: flex; flex-direction: column; gap: 14px; padding-top: 6px; }
  .cta-card { max-width: 560px; }
  .story-body { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 28px; align-items: start; }
  .chapter-list { grid-template-columns: 1fr 1fr 1fr; }
  .cat-grid { grid-template-columns: repeat(4, 1fr); gap: 16px; }

  .sheet { left: 50%; right: auto; bottom: auto; top: 50%; width: 460px; border-radius: 24px; transform: translate(-50%, -46%) scale(0.96); opacity: 0; visibility: hidden; transition: all 0.25s var(--ease); }
  .sheet.is-open { transform: translate(-50%, -50%); opacity: 1; visibility: visible; }
  .sheet::before { display: none; }
  .toast-wrap { bottom: 24px; }
  .grid-2 { grid-template-columns: 1fr 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
  .petals { display: none; }
}
