/* Phá Trời — Homepage Stylesheet */
:root {
      /* Typography Tokens */
      --font-reading: 'Lora', 'Georgia', serif;
      --font-ui: 'Be Vietnam Pro', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
      --font-family: var(--font-ui);
      --font-size: 19px;
      --reader-line-height: 1.85;
      --reader-max-width: 740px;

      /* Spacing Scale (8pt System) */
      --space-1: 4px;
      --space-2: 8px;
      --space-3: 12px;
      --space-4: 16px;
      --space-5: 24px;
      --space-6: 32px;
      --space-7: 48px;
      --space-8: 64px;

      /* Radii (Clean, non-pill) */
      --radius-sm: 4px;
      --radius-md: 6px;
      --radius-lg: 8px;

      /* Motion */
      --motion-fast: 150ms cubic-bezier(0.16, 1, 0.3, 1);
      --motion-base: 220ms cubic-bezier(0.16, 1, 0.3, 1);
    }

    /* Theme 1: Saigon Night (Mặc định - Deep Blue-Black & Rain Blue) */
    :root, html.theme-peaceful-dark, body.theme-peaceful-dark, html.theme-saigon-night, body.theme-saigon-night {
      --bg-color: #0b0f17;
      --bg-gradient: radial-gradient(ellipse at 50% 0%, #111827 0%, #0b0f17 75%);
      --text-color: #e2e8f0;
      --text-muted: #8492a6;
      --header-bg: #0b0f17;
      --card-bg: #111722;
      --card-bg-hover: #182232;
      --border-color: rgba(255, 255, 255, 0.08);
      --border-subtle: rgba(255, 255, 255, 0.04);
      --accent-primary: #517a8f;
      --accent-hover: #638fa6;
      --gold-primary: #e5c07b;
      --gold-hover: #f3d498;
      --cyan-subtle: #41677d;
    }

    /* Theme 2: Warm Dark (Trầm Ấm - Warm Charcoal & Warm Ivory) */
    html.theme-warm-dark, body.theme-warm-dark, html.theme-oled, body.theme-oled {
      --bg-color: #121110;
      --bg-gradient: radial-gradient(ellipse at 50% 0%, #1a1816 0%, #121110 75%);
      --text-color: #e6dfd5;
      --text-muted: #91887e;
      --header-bg: #121110;
      --card-bg: #181715;
      --card-bg-hover: #211f1c;
      --border-color: rgba(255, 255, 255, 0.08);
      --border-subtle: rgba(255, 255, 255, 0.04);
      --accent-primary: #8a7a60;
      --accent-hover: #a19074;
      --gold-primary: #e5c07b;
      --gold-hover: #f3d498;
      --cyan-subtle: #635847;
    }

    /* Theme 3: Sepia (Thư Tịch Cổ - Warm Paper & Dark Brown) */
    html.theme-sepia, body.theme-sepia {
      --bg-color: #f1e8d0;
      --bg-gradient: radial-gradient(circle at 50% 0%, #f8f1de 0%, #f1e8d0 85%);
      --text-color: #3b2d1d;
      --text-muted: #7d6a55;
      --header-bg: #f1e8d0;
      --card-bg: #e6dcbe;
      --card-bg-hover: #ded2b2;
      --border-color: rgba(100, 75, 50, 0.14);
      --border-subtle: rgba(100, 75, 50, 0.07);
      --accent-primary: #4d6d63;
      --accent-hover: #3b574e;
      --gold-primary: #8c5b1e;
      --gold-hover: #734814;
      --cyan-subtle: #415e55;
    }

    /* Theme 4: Paper (Giấy Sáng / Editorial Light - Soft Off-White & Dark Neutral) */
    html.theme-gentle-light, body.theme-gentle-light, html.theme-paper, body.theme-paper {
      --bg-color: #f7f5f0;
      --bg-gradient: radial-gradient(circle at 50% 0%, #ffffff 0%, #f7f5f0 85%);
      --text-color: #24221f;
      --text-muted: #6b665f;
      --header-bg: #f7f5f0;
      --card-bg: #ede9df;
      --card-bg-hover: #e4dfd3;
      --border-color: rgba(0, 0, 0, 0.09);
      --border-subtle: rgba(0, 0, 0, 0.05);
      --accent-primary: #3d6070;
      --accent-hover: #2e4b58;
      --gold-primary: #8f6b28;
      --gold-hover: #73541c;
      --cyan-subtle: #355363;
    }

    * { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
    html { scroll-behavior: smooth; background-color: var(--bg-color); }
    body {
      font-family: var(--font-family); background: var(--bg-gradient); background-color: var(--bg-color);
      color: var(--text-color); min-height: 100vh; overflow-x: hidden; line-height: var(--reader-line-height);
      transition: background 0.3s ease, color 0.3s ease;
      position: relative;
    }
    body::before {
      content: "";
      position: fixed;
      inset: 0;
      width: 100vw;
      height: 100vh;
      background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.02'/%3E%3C/svg%3E");
      pointer-events: none;
      z-index: 9999;
    }
    a { color: inherit; text-decoration: none; }

    /* Editorial Typography Principles */
    h1, h2, h3, h4, h5, h6 { text-wrap: balance; }
    p { text-wrap: pretty; }

    /* Accessibility focus and motion */
    :focus-visible { outline: 2px solid var(--accent-primary); outline-offset: 2px; }
    @media (prefers-reduced-motion: reduce) {
      *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
      }
    }

    ::-webkit-scrollbar { width: 6px; height: 6px; }
    ::-webkit-scrollbar-track { background: var(--bg-color); }
    ::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }
    ::-webkit-scrollbar-thumb:hover { background: var(--accent-primary); }

    #progressBarContainer {
      position: fixed; top: 0; left: 0; width: 100%; height: 2px; background: transparent; z-index: 1050; pointer-events: none;
    }
    #progressBar {
      height: 100%; width: 0%; background: var(--gold-primary);
      transition: width 0.1s ease-out;
    }

    header#topHeader {
      position: sticky; top: 0; left: 0; right: 0; width: 100%; max-width: 100vw; box-sizing: border-box;
      height: calc(56px + env(safe-area-inset-top, 0px));
      padding: env(safe-area-inset-top, 0px) 20px 0 20px;
      background: var(--header-bg);
      border-bottom: 1px solid var(--border-color);
      display: flex; align-items: center; justify-content: space-between; z-index: 999;
      transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), background 0.3s ease;
    }
    .header-left { display: flex; align-items: center; gap: 8px; flex-shrink: 0; z-index: 2; }
    .header-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; z-index: 2; margin-left: auto; }
    .btn-brand {
      display: inline-flex; align-items: center; gap: 10px; background: none; border: none;
      cursor: pointer; padding: 4px 6px; border-radius: 6px; transition: opacity 0.2s ease;
    }
    .btn-brand:hover { opacity: 0.85; }
    .nav-logo {
      width: 32px; height: 32px; border-radius: 50%; border: 1.5px solid var(--gold-primary);
      object-fit: cover;
    }
    .nav-brand-text {
      font-family: 'Lora', 'Georgia', serif; font-size: 15px; font-weight: 700; letter-spacing: 1.5px; color: var(--gold-primary);
    }
    .nav-live-badge {
      display: none; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 4px;
      background: transparent; border: 1px solid var(--border-color);
      font-size: 11px; font-weight: 500; color: var(--text-muted);
    }
    @media (min-width: 900px) { .nav-live-badge { display: inline-flex; } }

    .nav-header-pill {
      display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 4px;
      background: rgba(229, 192, 123, 0.08); border: 1px solid rgba(229, 192, 123, 0.28);
      font-size: 11px; font-weight: 600; color: var(--gold-primary); letter-spacing: 0.5px;
      text-decoration: none; transition: all 0.2s ease; margin-left: 4px;
    }
    .nav-header-pill:hover {
      background: rgba(229, 192, 123, 0.18); border-color: var(--gold-primary); transform: translateY(-1px);
    }
    @media (max-width: 640px) {
      .nav-header-pill { display: none; }
    }

    .header-center {
      position: absolute;
      left: 50%;
      top: 50%;
      transform: translate(-50%, -50%);
      text-align: center;
      padding: 0 8px;
      max-width: min(560px, calc(100% - 480px));
      min-width: 0;
      overflow: hidden;
      pointer-events: none;
      z-index: 1;
    }
    /* Header Center on Homepage - Hidden initially, revealed when scrolling past Hero */
    body.is-home .header-center {
      opacity: 0;
      transform: translate(-50%, -70%);
      pointer-events: none;
      transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1), transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    }
    body.is-home header#topHeader.scrolled-past-hero .header-center {
      opacity: 1;
      transform: translate(-50%, -50%);
      pointer-events: auto;
    }
    header#topHeader.scrolled-past-hero {
      border-bottom-color: rgba(229, 192, 123, 0.2);
      box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
    }
    .header-title {
      display: block; width: 100%;
      font-size: 13.5px; font-weight: 600; color: var(--text-color); white-space: nowrap;
      overflow: hidden; text-overflow: ellipsis; margin: 0; letter-spacing: 0.3px;
    }
    .header-sub {
      display: block; width: 100%;
      font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin: 0; opacity: 0.85;
    }
    .reader-progress-badge {
      font-size: 10.5px; font-weight: 600; color: var(--gold-primary);
      background: transparent; border: 1px solid var(--border-color);
      padding: 1px 6px; border-radius: 4px; display: inline-flex; align-items: center;
      margin-left: 6px; vertical-align: middle;
    }

    .btn-icon {
      background: none; border: 1px solid transparent; color: var(--text-muted); width: 36px; height: 36px;
      cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
      border-radius: 6px; transition: color 0.2s, border-color 0.2s; position: relative; flex-shrink: 0;
    }
    .btn-icon:hover { color: var(--gold-primary); border-color: var(--border-color); }
    .btn-icon:active { transform: scale(0.96); }

    .btn-nav-home-pill {
      display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: var(--radius-md);
      background: var(--card-bg); border: 1px solid var(--border-color);
      color: var(--text-muted); font-size: 12px; font-weight: 600; cursor: pointer; transition: all var(--motion-fast);
      white-space: nowrap;
    }
    .btn-nav-home-pill:hover { border-color: var(--gold-primary); color: var(--gold-primary); }

    @media (max-width: 768px) {
      .btn-nav-home-pill { display: none !important; }
      .header-desktop-only { display: none !important; }
      header#topHeader { padding: env(safe-area-inset-top, 0px) 10px 0 10px; }
      .header-left, .header-right { gap: 4px; }
      .header-center { max-width: calc(100% - 200px); }
      .btn-icon { width: 35px; height: 35px; }
      .nav-brand-text { font-size: 14px; letter-spacing: 0.8px; }
      .nav-logo { width: 30px; height: 30px; }
      body.is-home:not(.scrolled-past-hero) .header-center { display: none; }
      body.is-home header#topHeader.scrolled-past-hero .header-center { display: block; }
    }

    .dot-live {
      width: 6px; height: 6px; border-radius: 50%; background: var(--gold-primary);
      opacity: 0.85;
    }

    /* Chapter Meta Badges */
    .chapter-meta-pills {
      display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 8px; font-size: 12px;
    }
    .meta-pill {
      display: inline-flex; align-items: center; gap: 5px; padding: 4px 11px; border-radius: 20px;
      background: rgba(255, 255, 255, 0.05); border: 1px solid var(--border-color); color: var(--text-muted);
      font-size: 11.5px; font-weight: 500;
    }

    /* Modals, Drawers & Bottom Sheet */
    .modal-overlay {
      position: fixed; inset: 0; background: rgba(0, 0, 0, 0.72); backdrop-filter: blur(4px);
      z-index: 1000; opacity: 0; pointer-events: none; transition: opacity 0.25s ease;
    }
    .modal-overlay.open { opacity: 1; pointer-events: auto; }

    .drawer {
      position: fixed; top: 0; bottom: 0; width: 88%; max-width: 400px; background: var(--card-bg);
      border-left: 1px solid var(--border-color); z-index: 1001; display: flex; flex-direction: column;
      transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1); box-shadow: -8px 0 24px rgba(0, 0, 0, 0.4);
      box-sizing: border-box;
    }
    .drawer-left { left: 0; border-left: none; border-right: 1px solid var(--border-color); transform: translateX(-100%); box-shadow: 8px 0 24px rgba(0, 0, 0, 0.4); }
    .drawer-left.open { transform: translateX(0); }
    .drawer-right { right: 0; transform: translateX(100%); }
    .drawer-right.open { transform: translateX(0); }

    .drawer-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border-color); }
    .drawer-title { font-size: 15px; font-weight: 800; color: var(--gold-primary); margin: 0; letter-spacing: 0.5px; }
    .drawer-tabs { display: flex; padding: 10px 14px; gap: 6px; border-bottom: 1px solid var(--border-color); background: rgba(0,0,0,0.15); }
    .drawer-tab-btn {
      flex: 1; padding: 7px 4px; border-radius: 8px; background: transparent; border: 1px solid transparent;
      color: var(--text-muted); font-size: 12px; font-weight: 600; cursor: pointer; transition: all 0.2s; text-align: center;
    }
    .drawer-tab-btn.active { background: var(--card-bg); border-color: var(--border-color); color: var(--gold-primary); }
    .drawer-search { padding: 10px 16px; border-bottom: 1px solid var(--border-color); }
    .search-input {
      width: 100%; padding: 8px 12px; border-radius: 8px; background: rgba(0,0,0,0.2); border: 1px solid var(--border-color);
      color: var(--text-color); font-size: 13px; outline: none;
    }
    .search-input:focus { border-color: var(--accent-primary); }
    .drawer-body { flex: 1; overflow-y: auto; padding: 10px 14px; }

    /* TOC Progress Summary */
    .toc-progress-summary {
      padding: 12px 16px; border-bottom: 1px solid var(--border-color); background: rgba(0, 0, 0, 0.12);
    }
    .toc-progress-text {
      display: flex; justify-content: space-between; font-size: 12px; font-weight: 600;
      color: var(--text-muted); margin-bottom: 6px;
    }
    .toc-progress-text strong { color: var(--gold-primary); }
    .toc-progress-track {
      width: 100%; height: 5px; border-radius: 3px; background: rgba(255, 255, 255, 0.08); overflow: hidden;
    }
    .toc-progress-fill {
      height: 100%; background: linear-gradient(90deg, var(--gold-primary), var(--accent-primary));
      border-radius: 3px; transition: width 0.3s ease;
    }

    /* TOC items */
    .toc-item {
      padding: 10px 12px; border-radius: 8px; margin-bottom: 4px; cursor: pointer;
      display: flex; align-items: center; justify-content: space-between; border: 1px solid transparent;
      border-left: 2px solid transparent;
      transition: all 0.18s ease; text-decoration: none; color: inherit; box-sizing: border-box;
    }
    .toc-item:hover { background: var(--card-bg-hover); border-color: var(--border-color); border-left-color: var(--gold-primary); }
    .toc-item.active { background: rgba(229, 192, 123, 0.08); border-color: var(--gold-primary); border-left-color: var(--gold-primary); }
    .toc-item.active .toc-name { color: var(--gold-primary); font-weight: 700; }
    .toc-info { min-width: 0; flex: 1; margin-right: 10px; overflow: hidden; }
    .toc-num {
      font-size: 11px; color: var(--gold-primary); font-weight: 700; text-transform: uppercase;
      margin-bottom: 2px; display: flex; align-items: center; gap: 6px;
    }
    .toc-num::before {
      content: "❖";
      font-size: 8px;
      opacity: 0.85;
    }
    .toc-name { font-size: 13px; color: var(--text-color); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .toc-meta { font-size: 11px; color: var(--text-muted); flex-shrink: 0; }

    /* Chapter Status Indicators - Editorial */
    .ch-status-tag {
      font-size: 10px; font-weight: 600; padding: 1px 6px; border-radius: 3px;
      display: inline-flex; align-items: center; gap: 3px;
    }
    .ch-status-tag.read {
      background: transparent; color: var(--text-muted); border: 1px solid var(--border-subtle);
    }
    .ch-status-tag.current {
      background: rgba(229, 192, 123, 0.12); color: var(--gold-primary); border: 1px solid var(--gold-primary);
    }
    .ch-status-tag.unread {
      display: none;
    }

    /* Codex Drawer Styles */
    .codex-progress-pill {
      font-size: 11px; font-weight: 600; color: var(--gold-primary);
      background: transparent; border: 1px solid var(--border-color);
      padding: 2px 8px; border-radius: 4px; display: inline-flex; align-items: center; gap: 5px;
    }
    .codex-card {
      background: rgba(0,0,0,0.2); border: 1px solid var(--border-color); border-radius: 12px; padding: 14px; margin-bottom: 14px;
    }
    .codex-card.locked { border-style: dashed; opacity: 0.8; }
    .codex-badge {
      display: inline-block; font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 4px;
      background: rgba(245, 158, 11, 0.15); color: var(--gold-primary); margin-bottom: 6px;
    }
    .codex-badge.locked-badge { background: rgba(255, 255, 255, 0.08); color: var(--text-muted); }
    .codex-title { font-size: 15px; font-weight: 700; color: var(--gold-primary); margin: 0 0 6px 0; }
    .codex-desc { font-size: 13px; color: var(--text-color); opacity: 0.9; line-height: 1.6; margin: 0; }
    .codex-stat {
      display: flex; justify-content: space-between; font-size: 12px; padding: 6px 0;
      border-top: 1px dashed var(--border-color); margin-top: 8px; color: var(--text-muted);
    }
    .codex-stat-val { color: var(--accent-primary); font-weight: 600; }
    .codex-unlock-hint { margin-top: 8px; font-size: 11.5px; font-weight: 600; color: var(--accent-primary); }

    /* Settings Bottom Sheet */
    .sheet-bottom {
      position: fixed; bottom: 0; left: 0; right: 0; background: var(--card-bg); z-index: 1002;
      border-top: 1px solid var(--border-color); border-radius: 20px 20px 0 0; max-width: 580px; width: 100%;
      box-sizing: border-box; margin: 0 auto;
      padding: 20px 20px calc(36px + env(safe-area-inset-bottom, 0px)) 20px; transform: translateY(100%);
      transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1); max-height: 85vh; overflow-y: auto;
    }
    .sheet-bottom.open { transform: translateY(0); }
    .sheet-handle { width: 36px; height: 4px; border-radius: 2px; background: var(--border-color); margin: 0 auto 16px auto; }
    .setting-group { margin-bottom: 18px; }
    .setting-label { font-size: 12px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 10px; }
    .theme-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
    .theme-opt {
      padding: 10px 6px; border-radius: 10px; border: 2px solid var(--border-color); background: rgba(0,0,0,0.1);
      cursor: pointer; text-align: center; font-size: 12px; font-weight: 600; color: var(--text-color); transition: all 0.2s;
    }
    .theme-opt.active { border-color: var(--gold-primary); outline: 2px solid var(--gold-primary); outline-offset: 1px; }

    .stepper-ctrl {
      display: flex; align-items: center; justify-content: space-between; background: rgba(0,0,0,0.15);
      border-radius: 10px; padding: 4px; border: 1px solid var(--border-color);
    }
    .btn-step {
      width: 44px; height: 38px; background: var(--card-bg); border: 1px solid var(--border-color);
      color: var(--text-color); border-radius: 8px; font-size: 16px; font-weight: bold; cursor: pointer;
    }
    .stepper-val { font-size: 15px; font-weight: 700; color: var(--gold-primary); }

    .btn-opt-group { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
    .btn-opt-step {
      padding: 9px 4px; border-radius: 8px; border: 1px solid var(--border-color); background: rgba(0,0,0,0.15);
      color: var(--text-color); font-size: 12px; font-weight: 600; cursor: pointer; transition: all 0.2s; text-align: center;
    }
    .btn-opt-step:hover { border-color: var(--gold-primary); color: var(--gold-primary); }
    .btn-opt-step.active { background: rgba(229, 192, 123, 0.12); border-color: var(--gold-primary); color: var(--gold-primary); }

    .ambient-widget {
      display: flex; align-items: center; justify-content: space-between; padding: 10px 14px;
      border-radius: 10px; background: rgba(0,0,0,0.15); border: 1px solid var(--border-color); margin-top: 10px;
    }

    #liveToast {
      position: fixed; bottom: 74px; left: 50%; transform: translateX(-50%) translateY(30px);
      background: var(--card-bg); border: 1px solid var(--border-color); color: var(--text-color);
      font-size: 13px; font-weight: 600; padding: 9px 18px; border-radius: var(--radius-lg);
      box-shadow: 0 4px 16px rgba(0,0,0,0.3); opacity: 0; pointer-events: none;
      transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1); z-index: 2000; white-space: nowrap; display: flex; align-items: center; gap: 8px;
    }
    #liveToast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

/* Homepage Layout & Components */
/* Hero Titlepage - Frontispiece & Title Block (Standard Ebooks, Readium & Foliate Principles) */
    .hero-titlepage {
      position: relative; width: 100%; box-sizing: border-box;
      padding: 56px 20px 60px 20px;
      border-bottom: 1px solid var(--border-color);
      background: var(--bg-color);
      display: flex; justify-content: center; align-items: center;
      overflow: hidden;
      min-height: 80vh;
    }
    .hero-titlepage-bg {
      position: absolute; inset: 0;
      background-image: url('/assets/tieu-thuyet-pha-troi-do-thi-tu-chan-sai-gon-huyen-ao.webp');
      background-position: center 22%;
      background-size: cover;
      background-repeat: no-repeat;
      opacity: 0.72;
      pointer-events: none;
      z-index: 0;
      filter: contrast(110%) brightness(1.06);
      transition: opacity 0.3s ease;
      will-change: transform;
    }
    .hero-titlepage-overlay {
      position: absolute; inset: 0;
      background: radial-gradient(ellipse at 50% 32%, rgba(11, 15, 23, 0.22) 0%, rgba(11, 15, 23, 0.58) 65%, var(--bg-color) 98%),
                  linear-gradient(to bottom, transparent 25%, rgba(11, 15, 23, 0.45) 50%, var(--bg-color) 92%);
      pointer-events: none;
      z-index: 1;
    }
    html.theme-warm-dark .hero-titlepage-overlay {
      background: radial-gradient(ellipse at 50% 32%, rgba(18, 17, 16, 0.25) 0%, rgba(18, 17, 16, 0.62) 65%, var(--bg-color) 98%),
                  linear-gradient(to bottom, transparent 25%, rgba(18, 17, 16, 0.5) 50%, var(--bg-color) 92%);
    }
    html.theme-sepia .hero-titlepage-bg {
      opacity: 0.3;
      filter: grayscale(30%) brightness(1.08);
    }
    html.theme-sepia .hero-titlepage-overlay {
      background: radial-gradient(ellipse at 50% 30%, rgba(241, 232, 208, 0.55) 0%, rgba(241, 232, 208, 0.8) 60%, var(--bg-color) 98%),
                  linear-gradient(to bottom, transparent 20%, rgba(241, 232, 208, 0.7) 45%, var(--bg-color) 92%);
    }
    html.theme-paper .hero-titlepage-bg,
    html.theme-gentle-light .hero-titlepage-bg {
      opacity: 0.25;
      filter: grayscale(25%) brightness(1.08);
    }
    html.theme-paper .hero-titlepage-overlay,
    html.theme-gentle-light .hero-titlepage-overlay {
      background: radial-gradient(ellipse at 50% 30%, rgba(247, 245, 240, 0.65) 0%, rgba(247, 245, 240, 0.85) 60%, var(--bg-color) 98%),
                  linear-gradient(to bottom, transparent 20%, rgba(247, 245, 240, 0.8) 45%, var(--bg-color) 92%);
    }
    .titlepage-container {
      position: relative; z-index: 2;
      max-width: 680px; width: 100%; display: flex; flex-direction: column; align-items: center; text-align: center;
    }
    .titlepage-cover-frame {
      width: 165px; height: 248px; border-radius: 3px; overflow: hidden; margin-bottom: 26px;
      box-shadow: 0 16px 36px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255, 255, 255, 0.08);
      position: relative;
      transition: transform 0.3s ease, box-shadow 0.3s ease;
      will-change: transform;
    }
    .titlepage-cover-frame:hover {
      transform: translateY(-3px);
      box-shadow: 0 20px 42px rgba(0, 0, 0, 0.8), 0 0 0 1px var(--gold-primary);
    }
    .titlepage-cover-img { width: 100%; height: 100%; object-fit: cover; display: block; }
    .titlepage-meta-block { width: 100%; display: flex; flex-direction: column; align-items: center; }
    .titlepage-imprint {
      font-size: 11px; font-weight: 500; letter-spacing: 0.28em; text-transform: uppercase;
      color: var(--text-muted); margin-bottom: 14px; opacity: 0.95;
      text-shadow: 0 1px 6px rgba(0, 0, 0, 0.9);
    }
    .titlepage-title {
      font-family: 'Lora', 'Georgia', serif; font-size: clamp(38px, 6vw, 54px); font-weight: 600;
      letter-spacing: 0.14em; line-height: 1.15; color: var(--gold-primary); margin: 0 0 8px 0;
      text-transform: uppercase;
      text-shadow: 0 2px 14px rgba(0, 0, 0, 0.95), 0 1px 3px rgba(0, 0, 0, 0.9);
    }
    .titlepage-sub {
      font-size: 12.5px; font-weight: 500; letter-spacing: 0.32em; text-transform: uppercase;
      color: var(--text-color); opacity: 0.88; margin-bottom: 12px;
      text-shadow: 0 1px 8px rgba(0, 0, 0, 0.9);
    }
    .titlepage-author {
      font-family: 'Lora', 'Georgia', serif; font-size: 14px; color: var(--text-muted); margin-bottom: 0;
      text-shadow: 0 1px 8px rgba(0, 0, 0, 0.9);
    }
    .titlepage-author em { font-style: italic; color: var(--text-color); font-weight: 500; margin-left: 2px; }
    .titlepage-ornament {
      width: 48px; height: 1px; background: var(--border-color); margin: 24px auto;
    }
    .titlepage-epigraph { max-width: 540px; margin: 0 auto 28px auto; padding: 0 16px; text-align: center; }
    .epigraph-quote {
      font-family: 'Lora', 'Georgia', serif; font-style: italic; font-size: 16px; line-height: 1.85;
      color: #f7f4ec; margin-bottom: 12px; text-wrap: balance;
      text-shadow: 0 2px 10px rgba(0, 0, 0, 0.95);
    }
    .epigraph-premise {
      font-family: var(--font-ui); font-size: 13px; font-weight: 400; line-height: 1.7;
      color: #c9d2de; text-wrap: pretty; margin: 0;
      text-shadow: 0 1px 8px rgba(0, 0, 0, 0.9);
    }
    .epigraph-premise strong { color: #f7f4ec; font-weight: 500; }
    .titlepage-colophon {
      display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 10px;
      font-size: 12px; color: var(--text-muted); margin-bottom: 30px; letter-spacing: 0.3px;
      border: none; padding: 0;
    }
    .titlepage-colophon strong { font-family: 'Lora', 'Georgia', serif; font-weight: 600; color: var(--text-color); }
    .col-sep { opacity: 0.35; font-size: 10px; }
    .col-status { color: var(--gold-primary); font-style: italic; }
    .titlepage-actions {
      display: flex; align-items: center; justify-content: center; gap: 14px; flex-wrap: wrap;
    }
    .btn-titlepage-read {
      padding: 11px 26px; border-radius: 3px; background: var(--gold-primary);
      border: 1px solid var(--gold-primary); color: #0b0f17; font-size: 13.5px; font-weight: 600;
      letter-spacing: 0.3px; cursor: pointer; display: inline-flex; align-items: center; gap: 8px;
      box-shadow: none;
      transition: background 0.15s ease, transform 0.15s ease;
    }
    .btn-titlepage-read:hover {
      background: var(--gold-hover); border-color: var(--gold-hover); transform: translateY(-1px);
      box-shadow: none;
    }
    .btn-titlepage-read:active { transform: scale(0.98); }
    .btn-titlepage-toc {
      padding: 11px 22px; border-radius: 3px; background: transparent;
      border: 1px solid var(--border-color); color: var(--text-color); font-size: 13.5px; font-weight: 500;
      cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
      transition: border-color 0.15s ease, color 0.15s ease;
    }
    .btn-titlepage-toc:hover { border-color: var(--gold-primary); color: var(--gold-primary); }
    .hero-scroll-hint {
      position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%);
      display: inline-flex; flex-direction: column; align-items: center; gap: 2px;
      color: var(--text-muted); opacity: 0.8; text-decoration: none; cursor: pointer;
      z-index: 3; transition: opacity 0.25s ease, transform 0.25s ease;
    }
    .hero-scroll-hint:hover { opacity: 1; color: var(--gold-primary); }
    .hero-scroll-hint.is-hidden { opacity: 0; pointer-events: none; transform: translateX(-50%) translateY(8px); }
    .scroll-hint-label {
      font-size: 10px; font-weight: 600; letter-spacing: 1.5px; text-transform: uppercase;
    }
    .scroll-hint-chevron {
      animation: heroChevronPulse 2s cubic-bezier(0.4, 0, 0.2, 1) infinite;
    }
    @keyframes heroChevronPulse {
      0%, 100% { transform: translateY(0); opacity: 0.55; }
      50% { transform: translateY(4px); opacity: 1; color: var(--gold-primary); }
    }
    @media (max-width: 600px) {
      .hero-titlepage { padding: 32px 16px 36px 16px; }
      .titlepage-cover-frame { width: 140px; height: 210px; margin-bottom: 16px; }
      .titlepage-actions { width: 100%; flex-direction: column; gap: 10px; }
      .btn-titlepage-read, .btn-titlepage-toc { width: 100%; justify-content: center; box-sizing: border-box; }
      .hero-scroll-hint { bottom: 8px; }
      .scroll-hint-label { font-size: 9px; }
    }
    @media (prefers-reduced-motion: reduce) {
      .scroll-hint-chevron { animation: none !important; }
      .hero-titlepage-bg, .titlepage-cover-frame { transform: none !important; }
    }

    /* Home Content Container */
    .home-container { max-width: 1100px; margin: 0 auto; padding: 24px 20px 80px 20px; box-sizing: border-box; width: 100%; }
    @media (max-width: 768px) {
      .home-container { padding: 18px 14px 80px 14px; }
      .continue-card { padding: 16px; gap: 14px; flex-direction: column; align-items: stretch; }
      .continue-left { gap: 12px; width: 100%; }
      .continue-thumb { width: 42px; height: 42px; }
      .continue-btn { text-align: center; width: 100%; box-sizing: border-box; display: block; }
      .continue-pill { white-space: nowrap; }
    }
    .section-title-wrap {
      display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px;
      margin: 36px 0 16px 0; padding-bottom: 12px; border-bottom: 1px solid var(--border-color);
    }
    .section-title {
      font-family: 'Lora', 'Georgia', serif; font-size: 18px; font-weight: 700;
      color: var(--gold-primary); letter-spacing: 0.8px; margin: 0;
      display: inline-flex; align-items: center; gap: 8px;
    }
    .section-title::before {
      content: "❖";
      font-size: 11px;
      opacity: 0.85;
    }

    /* Resume Reading Card */
    .continue-card {
      background: var(--card-bg); border: 1px solid var(--border-color); border-radius: 8px; padding: 16px 20px;
      display: flex; align-items: center; justify-content: space-between; gap: 16px;
      border-left: 3px solid var(--border-color);
      transition: border-color 0.2s; margin-top: 16px; box-sizing: border-box; width: 100%;
    }
    .continue-card:hover { border-color: var(--gold-primary); border-left-color: var(--gold-primary); }
    .continue-card.welcome-mode {
      background: rgba(81, 122, 143, 0.05); border-color: var(--border-color); border-left-color: var(--accent-primary);
    }
    .continue-left { display: flex; align-items: center; gap: 16px; min-width: 0; flex: 1; }
    .continue-thumb {
      width: 44px; height: 44px; border-radius: 6px; object-fit: cover; border: 1px solid var(--border-color); flex-shrink: 0;
    }
    .continue-info { min-width: 0; flex: 1; }
    .continue-pill {
      font-size: 11px; font-weight: 600; color: var(--gold-primary); letter-spacing: 1px; text-transform: uppercase; margin-bottom: 3px;
    }
    .continue-chapter-name {
      font-size: 15px; font-weight: 600; color: var(--text-color); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    }
    .continue-progress-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
    .continue-btn {
      padding: 9px 16px; border-radius: 6px; background: transparent; border: 1px solid var(--border-color);
      color: var(--gold-primary); font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap; transition: all 0.2s ease;
    }
    .continue-btn:hover { background: rgba(229, 192, 123, 0.08); border-color: var(--gold-primary); }

    /* Latest Chapter Highlight Banner */
    .latest-chapter-banner {
      background: rgba(229, 192, 123, 0.03); border: 1px solid var(--border-color);
      border-left: 3px solid var(--gold-primary); border-radius: 8px; padding: 14px 18px;
      margin-top: 12px; display: flex; align-items: center; justify-content: space-between; gap: 16px;
      transition: border-color 0.2s; box-sizing: border-box; width: 100%;
    }
    .latest-chapter-banner:hover { border-color: var(--gold-primary); }
    @media (max-width: 768px) {
      .latest-chapter-banner { flex-direction: column; align-items: stretch; padding: 14px; gap: 12px; }
    }

    /* TOC Grid - Editorial Catalog */
    .home-toc-filter-row { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
    .home-tabs { display: flex; gap: 18px; border-bottom: 1px solid var(--border-color); padding: 0 2px; }
    .home-tab-btn {
      padding: 8px 4px; background: none; border: none; border-bottom: 2px solid transparent;
      color: var(--text-muted); font-size: 13.5px; font-weight: 500; cursor: pointer; transition: all 0.2s;
      margin-bottom: -1px;
    }
    .home-tab-btn.active { color: var(--gold-primary); border-bottom-color: var(--gold-primary); font-weight: 600; }
    .home-search-box { position: relative; min-width: 220px; flex: 1; max-width: 340px; }
    .home-search-input {
      width: 100%; padding: 8px 12px 8px 34px; border-radius: 6px; background: var(--card-bg);
      border: 1px solid var(--border-color); color: var(--text-color); font-size: 13px; outline: none;
      transition: border-color 0.2s;
    }
    .home-search-input:focus { border-color: var(--gold-primary); }
    .home-search-icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; }
    
    .home-toc-grid {
      display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
      gap: 1px; background: var(--border-color); border: 1px solid var(--border-color);
      border-radius: 8px; overflow: hidden;
    }
    .home-ch-card {
      background: var(--bg-color); padding: 14px 18px; cursor: pointer;
      display: flex; align-items: center; justify-content: space-between; gap: 12px;
      border-left: 2px solid transparent;
      transition: background 0.15s ease, border-left-color 0.15s ease, transform 0.15s ease;
    }
    .home-ch-card:hover {
      background: rgba(229, 192, 123, 0.04);
      border-left-color: var(--gold-primary);
      transform: translateX(2px);
    }
    .home-ch-card:hover .home-ch-title { color: var(--gold-primary); }
    .home-ch-card:hover .home-ch-arrow { color: var(--gold-primary); transform: translateX(2px); }
    .home-ch-card.is-current {
      background: rgba(229, 192, 123, 0.06);
      border-left-color: var(--gold-primary);
    }
    .home-ch-card.is-current .home-ch-title { color: var(--gold-primary); font-weight: 600; }
    .home-ch-card.is-read { opacity: 0.85; }
    .home-ch-info { min-width: 0; flex: 1; }
    .home-ch-meta-top {
      display: flex; align-items: center; gap: 6px; font-size: 11px;
      color: var(--gold-primary); font-weight: 600; letter-spacing: 0.8px; margin-bottom: 4px;
    }
    .home-ch-meta-top::before {
      content: "❖";
      font-size: 8px;
      opacity: 0.85;
      color: var(--gold-primary);
    }
    .home-ch-title {
      font-size: 14.5px; font-weight: 500; color: var(--text-color);
      white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 3px;
      transition: color 0.15s ease;
    }
    .home-ch-meta-bottom { font-size: 11.5px; color: var(--text-muted); display: flex; gap: 8px; }
    .home-ch-arrow { color: var(--border-color); font-size: 14px; transition: transform 0.15s, color 0.15s; }

    /* Codex Preview Cards - Archival Dossiers */
    .home-codex-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; margin-bottom: 20px; }
    .home-codex-card {
      background: var(--card-bg); border: 1px solid var(--border-color); border-radius: 8px; padding: 16px;
      display: flex; flex-direction: column; cursor: pointer; transition: border-color 0.2s ease;
    }
    .home-codex-card:hover { border-color: var(--gold-primary); }
    .home-codex-card.locked { opacity: 0.65; border-style: dashed; }
    .home-codex-badge {
      align-self: flex-start; font-size: 10px; font-weight: 600; letter-spacing: 0.8px; padding: 2px 6px;
      border-radius: 3px; background: rgba(229, 192, 123, 0.1); color: var(--gold-primary); margin-bottom: 8px; text-transform: uppercase;
    }
    .home-codex-badge.locked-badge { background: rgba(255, 255, 255, 0.05); color: var(--text-muted); }
    .home-codex-name { font-size: 15px; font-weight: 600; color: var(--text-color); margin: 0 0 6px 0; }
    .home-codex-desc { font-size: 12.5px; color: var(--text-muted); line-height: 1.6; margin: 0; flex: 1; }

    /* Section: Cẩm Nang & Hồ Sơ Chuyên Đề (Magazine / Editorial Cards) */
    .home-articles-section { margin-top: 44px; margin-bottom: 24px; }
    .articles-header-badge {
      font-size: 11px; font-weight: 700; color: var(--gold-primary); letter-spacing: 1px;
      padding: 3px 8px; border-radius: 4px; border: 1px solid rgba(229, 192, 123, 0.3);
      background: rgba(229, 192, 123, 0.06); text-transform: uppercase;
    }
    .home-articles-grid {
      display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
      gap: 16px; margin-top: 16px;
    }
    .home-article-card {
      background: var(--card-bg); border: 1px solid var(--border-color); border-radius: 8px;
      padding: 20px 22px; display: flex; flex-direction: column; justify-content: space-between;
      text-decoration: none; transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
      position: relative; overflow: hidden;
    }
    .home-article-card:hover {
      border-color: var(--gold-primary); transform: translateY(-2px);
      background: var(--card-bg-hover); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
    }
    .home-article-card.is-featured {
      border-left: 3px solid var(--gold-primary);
      background: linear-gradient(135deg, rgba(229, 192, 123, 0.04) 0%, var(--card-bg) 60%);
    }
    .article-card-header {
      display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px;
    }
    .article-card-badge {
      font-size: 10.5px; font-weight: 700; letter-spacing: 0.8px; text-transform: uppercase;
      color: var(--gold-primary); background: rgba(229, 192, 123, 0.08); padding: 3px 8px;
      border-radius: 3px; border: 1px solid rgba(229, 192, 123, 0.2);
    }
    .article-card-time {
      font-size: 11.5px; color: var(--text-muted); font-weight: 500;
    }
    .article-card-title {
      font-family: 'Lora', 'Georgia', serif; font-size: 16.5px; font-weight: 600;
      color: var(--text-color); line-height: 1.45; margin: 0 0 10px 0;
      transition: color 0.15s ease;
    }
    .home-article-card:hover .article-card-title {
      color: var(--gold-primary);
    }
    .article-card-desc {
      font-size: 13px; line-height: 1.65; color: var(--text-muted);
      margin: 0 0 16px 0; flex: 1; text-wrap: pretty;
    }
    .article-card-footer {
      display: flex; align-items: center; justify-content: space-between;
      padding-top: 12px; border-top: 1px solid var(--border-subtle);
      font-size: 12px;
    }
    .article-card-author {
      color: var(--text-muted); font-style: italic;
    }
    .article-card-action {
      color: var(--gold-primary); font-weight: 600; display: inline-flex; align-items: center; gap: 4px;
      transition: transform 0.15s ease;
    }
    .home-article-card:hover .article-card-action {
      transform: translateX(3px);
    }

    /* Footer - Literary Editorial Colophon */
    .site-footer {
      margin-top: 64px; padding: 48px 20px 60px 20px; border-top: 1px solid var(--border-color);
      background: rgba(0, 0, 0, 0.15); width: 100%; box-sizing: border-box;
    }
    .footer-top-grid {
      max-width: 1100px; margin: 0 auto;
      display: grid; grid-template-columns: 1.35fr 1fr 1fr 1fr;
      gap: 32px; margin-bottom: 36px; text-align: left;
    }
    @media (max-width: 900px) {
      .footer-top-grid { grid-template-columns: 1fr 1fr; gap: 28px; }
    }
    @media (max-width: 600px) {
      .footer-top-grid { grid-template-columns: 1fr; gap: 24px; text-align: center; }
    }
    .footer-brand-header {
      display: flex; align-items: center; gap: 12px; margin-bottom: 12px;
    }
    @media (max-width: 600px) {
      .footer-brand-header { justify-content: center; }
    }
    .footer-logo {
      width: 44px; height: 44px; border-radius: 50%; border: 1.5px solid var(--gold-primary);
      object-fit: cover; flex-shrink: 0;
    }
    .footer-title {
      font-family: 'Lora', 'Georgia', serif; font-size: 18px; font-weight: 700; color: var(--gold-primary); letter-spacing: 1px;
    }
    .footer-tagline {
      font-size: 11.5px; color: var(--text-muted); letter-spacing: 0.5px; text-transform: uppercase;
    }
    .footer-summary {
      font-size: 12.5px; line-height: 1.65; color: var(--text-muted); margin-bottom: 14px;
    }
    .footer-summary strong { color: var(--text-color); font-weight: 600; }
    .footer-live-status {
      display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px;
      color: #34d399; font-weight: 500;
    }
    .footer-col-title {
      font-size: 12px; font-weight: 700; letter-spacing: 1px; color: var(--gold-primary);
      text-transform: uppercase; margin-bottom: 14px; padding-bottom: 6px; border-bottom: 1px solid var(--border-subtle);
    }
    .footer-links { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
    .footer-links li a {
      font-size: 13px; color: var(--text-muted); text-decoration: none; transition: color 0.15s ease, transform 0.15s ease;
      display: inline-block;
    }
    .footer-links li a:hover {
      color: var(--gold-primary); transform: translateX(3px);
    }
    .footer-bottom-bar {
      max-width: 1100px; margin: 0 auto; padding-top: 24px; border-top: 1px solid var(--border-subtle);
      display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px;
      font-size: 12px; color: var(--text-muted);
    }
    @media (max-width: 600px) {
      .footer-bottom-bar { flex-direction: column; text-align: center; }
    }
    .footer-bottom-bar strong { color: var(--text-color); }
    .footer-badge-note {
      font-size: 11px; letter-spacing: 0.8px; color: var(--gold-primary);
    }
    .drawer-footer-nav {
      padding: 12px 16px; border-top: 1px solid var(--border-color); background: rgba(0,0,0,0.1);
      display: flex; flex-direction: column; gap: 8px;
    }
    .drawer-guide-link {
      font-size: 12.5px; color: var(--gold-primary); text-decoration: none; font-weight: 600;
      transition: transform 0.15s;
    }
    .drawer-guide-link:hover { transform: translateX(3px); }
