/* Phá Trời — Web Reader 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#topHeader.header-unpinned { transform: translateY(-100%) !important; }
    header#topHeader.header-pinned { transform: translateY(0) !important; }
    .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; } }

    .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-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% - 220px); }
      .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 .header-center { display: none; }
    }

    .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; }

/* Reader View Specific Layout */
/* Reader View Specific Layout */
    .app-layout { display: flex; max-width: 1400px; margin: 0 auto; position: relative; }

    .desktop-toc-sidebar {
      display: none; width: 280px; height: calc(100vh - 60px); position: sticky; top: 60px;
      overflow-y: auto; border-right: 1px solid var(--border-color); padding: 18px 12px;
      background: rgba(0,0,0,0.15); flex-shrink: 0;
    }
    @media (min-width: 1200px) { .desktop-toc-sidebar { display: block; } }

    .main-reader {
      flex: 1; min-width: 0; width: 100%; box-sizing: border-box;
      padding: 18px 16px calc(90px + env(safe-area-inset-bottom, 0px)) 16px;
      display: flex; flex-direction: column; align-items: center;
    }
    @media (min-width: 769px) {
      .main-reader { padding: 24px 20px 100px 20px; }
    }

    .btn-back-home-wrap {
      width: 100%; max-width: var(--reader-max-width); display: flex; align-items: center;
      justify-content: space-between; margin-bottom: 14px; box-sizing: border-box;
    }
    @media (max-width: 768px) {
      .btn-back-home-wrap { margin-bottom: 10px; }
      .header-vol-arc-hide-mobile { display: none; }
    }
    .btn-back-home {
      display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border-radius: 8px;
      background: var(--card-bg); border: 1px solid var(--border-color); color: var(--text-muted);
      font-size: 12.5px; font-weight: 600; cursor: pointer; transition: all 0.2s;
    }
    .btn-back-home:hover { color: var(--gold-primary); border-color: var(--gold-primary); }

    .chapter-hero {
      width: 100%; max-width: var(--reader-max-width); text-align: center;
      padding: 24px 0 20px 0; border-bottom: 1px solid var(--border-color); margin-bottom: 28px;
      box-sizing: border-box;
    }
    @media (min-width: 769px) {
      .chapter-hero { padding: 36px 0 28px 0; margin-bottom: 36px; }
    }
    .chapter-vol-arc {
      font-size: 11.5px; font-weight: 700; color: var(--gold-primary); letter-spacing: 2.5px;
      text-transform: uppercase; margin-bottom: 8px; opacity: 0.85; font-family: var(--font-ui);
    }
    .chapter-main-title {
      font-family: var(--font-reading); font-size: clamp(23px, 4vw, 30px); font-weight: 700; line-height: 1.35;
      color: var(--gold-primary); margin: 0 0 12px 0;
    }
    .chapter-hero-meta {
      display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap;
      font-size: 12.5px; color: var(--text-muted); font-family: var(--font-ui);
    }
    .chapter-hero-meta .meta-sep { opacity: 0.4; }

    .novel-body {
      width: 100%; max-width: var(--reader-max-width); font-family: var(--font-reading);
      font-size: var(--font-size); line-height: var(--reader-line-height); color: var(--text-color);
      letter-spacing: 0.1px; box-sizing: border-box;
      transition: font-size 0.2s ease, max-width 0.2s ease, line-height 0.2s ease;
    }
    .novel-body p {
      margin-bottom: 1.6em; text-align: left; text-wrap: pretty;
      word-break: break-word;
    }
    .novel-body blockquote {
      border-left: 2px solid var(--gold-primary); padding: 10px 18px; margin: 1.8em 0;
      background: rgba(196, 160, 89, 0.04); font-style: italic; color: var(--text-color);
    }
    .novel-body hr {
      border: none; height: 1px; width: 140px; margin: 3.5em auto; background: var(--border-color);
      position: relative; overflow: visible;
    }
    .novel-body hr::after {
      content: "· ✦ ·"; position: absolute; top: -0.7em; left: 50%; transform: translateX(-50%);
      background: var(--bg-color); padding: 0 10px; color: var(--gold-primary); font-size: 13px;
      letter-spacing: 4px;
    }

    /* Chapter End Colophon (Phase 3) */
    .chapter-end-colophon {
      width: 100%; max-width: var(--reader-max-width); margin: 48px auto 20px auto;
      padding: 32px 24px; border-top: 1px solid var(--border-color);
      text-align: center; display: flex; flex-direction: column; align-items: center; gap: 16px;
      box-sizing: border-box;
    }
    .chapter-end-dinkus {
      color: var(--gold-primary); font-size: 16px; letter-spacing: 6px; opacity: 0.75;
    }
    .chapter-end-meta { display: flex; flex-direction: column; align-items: center; gap: 6px; }
    .chapter-end-status {
      font-size: 11px; font-weight: 700; letter-spacing: 2px; text-transform: uppercase;
      color: var(--text-muted); font-family: var(--font-ui);
    }
    .chapter-end-next-title {
      font-family: var(--font-reading); font-size: clamp(18px, 3vw, 22px); font-weight: 700;
      color: var(--gold-primary); margin: 2px 0 4px 0; line-height: 1.4;
    }
    .chapter-end-next-meta {
      font-size: 12.5px; color: var(--text-muted); font-family: var(--font-ui);
    }
    .chapter-end-nav {
      display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%;
      margin-top: 8px; flex-wrap: wrap;
    }
    .btn-chapter-nav {
      flex: 1; min-width: 120px; max-width: 220px; padding: 12px 16px; border-radius: var(--radius-md);
      background: var(--card-bg); border: 1px solid var(--border-color); color: var(--text-color);
      font-family: var(--font-ui); font-size: 13px; font-weight: 600; cursor: pointer;
      text-decoration: none; display: inline-flex; align-items: center; justify-content: center;
      transition: border-color var(--motion-fast), color var(--motion-fast), background var(--motion-fast);
      box-sizing: border-box;
    }
    .btn-chapter-nav:hover:not(.disabled) {
      border-color: var(--gold-primary); color: var(--gold-primary); background: var(--card-bg-hover);
    }
    .btn-chapter-nav.next {
      background: rgba(229, 192, 123, 0.1); border-color: var(--gold-primary); color: var(--gold-primary);
    }
    .btn-chapter-nav.next:hover:not(.disabled) {
      background: var(--gold-primary); color: #0b0f17;
    }
    .btn-chapter-nav.disabled { opacity: 0.3; cursor: not-allowed; pointer-events: none; }

    /* Top Chapter Navigation & Progress */
    .top-chapter-nav {
      display: inline-flex; align-items: center; gap: 8px;
    }
    .btn-top-nav {
      display: inline-flex; align-items: center; justify-content: center;
      padding: 6px 12px; border-radius: var(--radius-sm); background: var(--card-bg);
      border: 1px solid var(--border-color); color: var(--text-color);
      font-family: var(--font-ui); font-size: 12px; font-weight: 600; text-decoration: none;
      transition: border-color var(--motion-fast), color var(--motion-fast), background var(--motion-fast);
      box-sizing: border-box;
    }
    .btn-top-nav:hover:not(.disabled) {
      border-color: var(--gold-primary); color: var(--gold-primary); background: var(--card-bg-hover);
    }
    .btn-top-nav.next {
      background: rgba(229, 192, 123, 0.08); border-color: var(--gold-primary); color: var(--gold-primary);
    }
    .btn-top-nav.next:hover:not(.disabled) {
      background: var(--gold-primary); color: #0b0f17;
    }
    .btn-top-nav.disabled { opacity: 0.3; cursor: not-allowed; pointer-events: none; }
    .top-nav-progress {
      font-size: 12px; font-weight: 600; color: var(--gold-primary); font-family: var(--font-ui);
      padding: 0 4px; white-space: nowrap;
    }

    /* Chapter Related Lore CTA */
    .chapter-lore-cta {
      width: 100%; max-width: var(--reader-max-width); margin: 40px auto 0 auto;
      padding: 24px 20px; border-radius: var(--radius-lg); background: var(--card-bg);
      border: 1px solid var(--border-color); box-sizing: border-box;
    }
    .chapter-lore-cta-title {
      font-size: 11px; font-weight: 700; letter-spacing: 2px; text-transform: uppercase;
      color: var(--gold-primary); margin-bottom: 8px; display: flex; align-items: center; gap: 6px;
      font-family: var(--font-ui);
    }
    .chapter-lore-cta-desc {
      font-size: 13px; color: var(--text-muted); margin-bottom: 16px; line-height: 1.6; font-family: var(--font-ui);
    }
    .chapter-lore-grid {
      display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; margin-bottom: 16px;
    }
    .lore-cta-link {
      display: block; padding: 12px 14px; border-radius: var(--radius-md);
      background: rgba(255, 255, 255, 0.02); border: 1px solid var(--border-color);
      text-decoration: none; transition: border-color var(--motion-fast), background var(--motion-fast);
      box-sizing: border-box;
    }
    .lore-cta-link:hover {
      border-color: var(--gold-primary); background: rgba(229, 192, 123, 0.04);
    }
    .lore-cta-link-title {
      font-size: 13px; font-weight: 600; color: var(--gold-primary); margin-bottom: 4px; font-family: var(--font-ui);
    }
    .lore-cta-link-desc {
      font-size: 11.5px; color: var(--text-muted); line-height: 1.4; font-family: var(--font-ui);
    }
    .chapter-lore-footer {
      font-size: 12px; color: var(--text-muted); display: flex; align-items: center;
      justify-content: space-between; flex-wrap: wrap; gap: 8px;
      border-top: 1px solid var(--border-subtle); padding-top: 12px; font-family: var(--font-ui);
    }

    /* Mobile Bottom Navigation Bar (Phase 1, 5, 9) */
    .bottom-bar {
      position: fixed; bottom: 0; left: 0; right: 0;
      height: calc(54px + env(safe-area-inset-bottom, 0px));
      padding-bottom: env(safe-area-inset-bottom, 0px);
      background: var(--header-bg);
      border-top: 1px solid var(--border-color);
      display: flex; align-items: center; justify-content: space-around; z-index: 998;
      transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1); box-sizing: border-box; max-width: 100vw;
    }
    .bottom-bar.bar-unpinned { transform: translateY(100%) !important; }
    .bottom-bar.bar-pinned { transform: translateY(0) !important; }
    @media (min-width: 769px) { .bottom-bar { display: none; } }
    .btn-bottom-item {
      background: none; border: none; color: var(--text-muted); display: flex; flex-direction: column;
      align-items: center; gap: 3px; font-size: 10.5px; font-family: var(--font-ui); font-weight: 500;
      cursor: pointer; padding: 6px 12px; border-radius: var(--radius-sm); text-decoration: none;
      -webkit-tap-highlight-color: transparent; transition: color var(--motion-fast);
    }
    .btn-bottom-item:active, .btn-bottom-item:hover { color: var(--gold-primary); }
    .btn-bottom-item.disabled { opacity: 0.3; pointer-events: none; }
    .btn-bottom-item svg { width: 19px; height: 19px; }

    /* ========================================================
       EDITORIAL ACTIONS ROW (AUDIO & QUOTE SHORTCUTS)
       ======================================================== */
    .reader-editorial-bar {
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 12px;
      margin: 0 auto 28px auto;
      padding: 8px 16px;
      max-width: var(--reader-max-width);
      border-radius: var(--radius-md);
      background: rgba(255, 255, 255, 0.02);
      border: 1px solid var(--border-subtle);
      box-sizing: border-box;
    }
    .editorial-btn {
      background: none;
      border: none;
      color: var(--text-muted);
      font-family: var(--font-ui);
      font-size: 12px;
      font-weight: 600;
      display: inline-flex;
      align-items: center;
      gap: 6px;
      cursor: pointer;
      padding: 4px 8px;
      border-radius: var(--radius-sm);
      transition: color var(--motion-fast), background var(--motion-fast);
    }
    .editorial-btn:hover {
      color: var(--gold-primary);
      background: rgba(229, 192, 123, 0.06);
    }
    .editorial-btn svg {
      color: var(--accent-primary);
      transition: color var(--motion-fast);
    }
    .editorial-btn:hover svg {
      color: var(--gold-primary);
    }
    .editorial-divider {
      color: var(--border-color);
      font-size: 14px;
    }

    /* Paragraph Audio Focus */
    .novel-body p.para-active {
      position: relative;
      border-left: 3px solid var(--gold-primary) !important;
      padding-left: 14px;
      margin-left: -14px;
      color: #ffffff !important;
      background: linear-gradient(90deg, rgba(229, 192, 123, 0.06) 0%, transparent 80%);
      border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
      transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    }

    /* ========================================================
       FEATURE 1: WEB SPEECH AUDIO CONTROLLER DOCK
       ======================================================== */
    .speech-audio-dock {
      position: fixed;
      bottom: 20px;
      left: 50%;
      transform: translateX(-50%) translateY(120%);
      width: 92%;
      max-width: 620px;
      background: rgba(14, 20, 32, 0.94);
      backdrop-filter: blur(20px) saturate(180%);
      -webkit-backdrop-filter: blur(20px) saturate(180%);
      border: 1px solid var(--border-color);
      border-radius: 16px;
      padding: 10px 14px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      z-index: 999;
      box-shadow: 0 16px 40px rgba(0, 0, 0, 0.7);
      opacity: 0;
      pointer-events: none;
      transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
      box-sizing: border-box;
    }
    .speech-audio-dock.dock-visible {
      transform: translateX(-50%) translateY(0);
      opacity: 1;
      pointer-events: auto;
    }
    @media (max-width: 768px) {
      .speech-audio-dock {
        bottom: 68px; /* Float above mobile bottom-bar */
        padding: 8px 12px;
      }
    }
    .audio-dock-left {
      display: flex;
      align-items: center;
      gap: 10px;
      min-width: 0;
      flex: 1;
    }
    .btn-audio-play-master {
      width: 42px;
      height: 42px;
      border-radius: 12px;
      background: var(--accent-primary);
      border: none;
      color: #ffffff;
      display: flex;
      align-items: center;
      justify-content: center;
      flex-shrink: 0;
      cursor: pointer;
      transition: background var(--motion-fast), transform var(--motion-fast);
      box-shadow: 0 4px 12px rgba(81, 122, 143, 0.25);
    }
    .btn-audio-play-master:hover {
      background: var(--accent-hover);
    }
    .btn-audio-play-master:active {
      transform: scale(0.95);
    }
    .audio-dock-info {
      min-width: 0;
      flex: 1;
    }
    .audio-dock-title-row {
      display: flex;
      align-items: center;
      gap: 8px;
    }
    .audio-dock-title {
      font-size: 12.5px;
      font-weight: 600;
      color: var(--text-color);
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      font-family: var(--font-ui);
    }
    .audio-soundwave {
      display: none;
      align-items: center;
      gap: 2px;
      height: 14px;
    }
    .audio-soundwave.active {
      display: flex;
    }
    .soundwave-bar {
      display: inline-block;
      width: 2.5px;
      background-color: var(--gold-primary);
      border-radius: 2px;
      animation: soundwaveAnim 1.2s ease-in-out infinite alternate;
    }
    .soundwave-bar:nth-child(1) { height: 5px; animation-delay: 0.1s; }
    .soundwave-bar:nth-child(2) { height: 13px; animation-delay: 0.35s; }
    .soundwave-bar:nth-child(3) { height: 8px; animation-delay: 0.2s; }
    .soundwave-bar:nth-child(4) { height: 15px; animation-delay: 0.45s; }
    .soundwave-bar:nth-child(5) { height: 6px; animation-delay: 0.15s; }
    @keyframes soundwaveAnim {
      0% { transform: scaleY(0.25); opacity: 0.5; }
      100% { transform: scaleY(1); opacity: 1; }
    }
    .audio-dock-sub {
      font-size: 11px;
      color: var(--text-muted);
      font-family: var(--font-ui);
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      display: flex;
      align-items: center;
      gap: 6px;
    }
    .audio-para-badge {
      color: var(--gold-primary);
      font-family: monospace;
      font-weight: 600;
    }
    .audio-dock-right {
      display: flex;
      align-items: center;
      gap: 6px;
      flex-shrink: 0;
    }
    .btn-audio-ctrl {
      background: rgba(255, 255, 255, 0.05);
      border: 1px solid var(--border-color);
      color: var(--text-muted);
      border-radius: 8px;
      padding: 6px 10px;
      font-size: 11.5px;
      font-family: var(--font-ui);
      cursor: pointer;
      transition: all var(--motion-fast);
      display: inline-flex;
      align-items: center;
      justify-content: center;
    }
    .btn-audio-ctrl:hover {
      color: var(--text-color);
      border-color: var(--gold-primary);
    }
    .btn-audio-speed {
      font-weight: 700;
      color: var(--gold-primary);
      font-family: monospace;
    }
    .select-audio-voice {
      background: rgba(255, 255, 255, 0.05);
      border: 1px solid var(--border-color);
      color: var(--text-muted);
      border-radius: 8px;
      padding: 5px 8px;
      font-size: 11px;
      font-family: var(--font-ui);
      outline: none;
      max-width: 110px;
      cursor: pointer;
    }
    @media (max-width: 600px) {
      .select-audio-voice { display: none; }
    }

    /* ========================================================
       FEATURE 2: SELECTION TOOLTIP & QUOTE STUDIO MODAL
       ======================================================== */
    .selection-quote-tooltip {
      position: absolute;
      display: none;
      z-index: 1050;
      transform: translate(-50%, -115%);
      pointer-events: auto;
      animation: tooltipPop 0.18s cubic-bezier(0.16, 1, 0.3, 1);
    }
    @keyframes tooltipPop {
      from { opacity: 0; transform: translate(-50%, -95%) scale(0.94); }
      to { opacity: 1; transform: translate(-50%, -115%) scale(1); }
    }
    .btn-quote-bubble {
      display: inline-flex;
      align-items: center;
      gap: 7px;
      padding: 6px 12px;
      border-radius: 20px;
      background: rgba(14, 20, 32, 0.96);
      backdrop-filter: blur(16px);
      -webkit-backdrop-filter: blur(16px);
      border: 1px solid var(--accent-primary);
      color: #ffffff;
      font-family: var(--font-ui);
      font-size: 11.5px;
      font-weight: 600;
      cursor: pointer;
      box-shadow: 0 10px 25px rgba(0, 0, 0, 0.6);
      transition: all var(--motion-fast);
      white-space: nowrap;
    }
    .btn-quote-bubble:hover {
      border-color: var(--gold-primary);
      color: var(--gold-primary);
      transform: scale(1.03);
    }
    .quote-bubble-dot {
      width: 6px;
      height: 6px;
      border-radius: 50%;
      background: var(--gold-primary);
    }

    /* Quote Modal Full */
    .quote-modal-overlay {
      position: fixed;
      inset: 0;
      background: rgba(7, 10, 15, 0.85);
      backdrop-filter: blur(16px);
      -webkit-backdrop-filter: blur(16px);
      z-index: 2000;
      display: none;
      align-items: center;
      justify-content: center;
      padding: 16px;
      opacity: 0;
      transition: opacity 0.25s ease;
      box-sizing: border-box;
    }
    .quote-modal-overlay.open {
      display: flex;
      opacity: 1;
    }
    .quote-modal-card {
      width: 100%;
      max-width: 900px;
      max-height: 92vh;
      background: var(--card-bg);
      border: 1px solid var(--border-color);
      border-radius: 16px;
      overflow: hidden;
      display: flex;
      flex-direction: column;
      box-shadow: 0 25px 60px rgba(0, 0, 0, 0.8);
    }
    .quote-modal-header {
      padding: 14px 20px;
      border-bottom: 1px solid var(--border-color);
      display: flex;
      align-items: center;
      justify-content: space-between;
    }
    .quote-modal-title {
      font-size: 14px;
      font-weight: 700;
      color: var(--gold-primary);
      letter-spacing: 1.5px;
      text-transform: uppercase;
      font-family: var(--font-ui);
      display: flex;
      align-items: center;
      gap: 8px;
    }
    .quote-modal-body {
      flex: 1;
      overflow-y: auto;
      padding: 20px;
      display: grid;
      grid-template-columns: 1.15fr 0.85fr;
      gap: 24px;
      align-items: center;
    }
    @media (max-width: 820px) {
      .quote-modal-body {
        grid-template-columns: 1fr;
      }
    }
    .quote-preview-wrap {
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      background: rgba(0, 0, 0, 0.25);
      border: 1px solid var(--border-subtle);
      border-radius: 12px;
      padding: 12px;
    }
    #quoteModalCanvas {
      max-height: 48vh;
      width: auto;
      max-width: 100%;
      border-radius: 8px;
      box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
    }
    .quote-controls {
      display: flex;
      flex-direction: column;
      gap: 16px;
      font-family: var(--font-ui);
    }
    .quote-control-label {
      font-size: 11px;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 1px;
      color: var(--text-muted);
      margin-bottom: 6px;
      display: block;
    }
    .quote-btn-grid {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: 6px;
    }
    .btn-quote-opt {
      padding: 8px 6px;
      border-radius: 8px;
      background: rgba(255, 255, 255, 0.04);
      border: 1px solid var(--border-color);
      color: var(--text-muted);
      font-size: 11px;
      font-weight: 600;
      text-align: center;
      cursor: pointer;
      transition: all var(--motion-fast);
    }
    .btn-quote-opt.active, .btn-quote-opt:hover {
      background: var(--card-bg-hover);
      border-color: var(--accent-primary);
      color: var(--text-color);
    }
    .btn-quote-opt.active {
      border-color: var(--gold-primary);
      color: var(--gold-primary);
    }
    .quote-theme-list {
      display: flex;
      flex-direction: column;
      gap: 6px;
    }
    .btn-theme-opt {
      padding: 8px 12px;
      border-radius: 8px;
      background: rgba(255, 255, 255, 0.04);
      border: 1px solid var(--border-color);
      color: var(--text-muted);
      font-size: 12px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      cursor: pointer;
      transition: all var(--motion-fast);
      text-align: left;
    }
    .btn-theme-opt.active, .btn-theme-opt:hover {
      background: var(--card-bg-hover);
      border-color: var(--accent-primary);
      color: var(--text-color);
    }
    .btn-theme-opt.active {
      border-color: var(--gold-primary);
      color: var(--gold-primary);
    }
    .quote-textarea {
      width: 100%;
      height: 70px;
      padding: 8px 10px;
      border-radius: 8px;
      background: rgba(0, 0, 0, 0.2);
      border: 1px solid var(--border-color);
      color: var(--text-color);
      font-family: var(--font-reading);
      font-size: 13px;
      line-height: 1.5;
      resize: none;
      outline: none;
      box-sizing: border-box;
    }
    .quote-textarea:focus {
      border-color: var(--accent-primary);
    }
    .btn-download-quote {
      width: 100%;
      padding: 12px 16px;
      border-radius: 10px;
      background: var(--accent-primary);
      border: none;
      color: #ffffff;
      font-family: var(--font-ui);
      font-size: 12.5px;
      font-weight: 700;
      letter-spacing: 0.5px;
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 8px;
      cursor: pointer;
      transition: background var(--motion-fast), transform var(--motion-fast);
      box-shadow: 0 4px 16px rgba(81, 122, 143, 0.3);
    }
    .btn-download-quote:hover {
      background: var(--accent-hover);
    }
    .btn-download-quote:active {
      transform: scale(0.98);
    }
