:root {
      --bg-base: #090b10;
      --bg-surface: rgba(18, 21, 30, 0.75);
      --bg-canvas: #090b10;
      --border-subtle: rgba(255, 255, 255, 0.08);
      --border-hover: rgba(255, 255, 255, 0.18);
      --text-main: #f8fafc;
      --text-muted: #94a3b8;
      --text-dim: #64748b;
      --brand-red: #e11d48;
      --brand-red-glow: rgba(225, 29, 72, 0.25);
      --brand-amber: #f59e0b;
      --brand-emerald: #10b981;
    }

    * {
      box-sizing: border-box;
      margin: 0;
      padding: 0;
      user-select: none;
      -webkit-user-select: none;
      -moz-user-select: none;
    }

    html,
    body {
      height: 100%;
      background-color: var(--bg-base);
      color: var(--text-main);
      font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
      overflow: hidden;
      -webkit-font-smoothing: antialiased;
    }

    /* -------------------------------------------------------------
       TOP NAVIGATION BAR (MINIMALIST GLASS)
       ------------------------------------------------------------- */
    .topbar {
      position: fixed;
      top: 0;
      left: 0;
      right: 0;
      height: 52px;
      background: rgba(9, 11, 16, 0.82);
      backdrop-filter: blur(20px);
      -webkit-backdrop-filter: blur(20px);
      border-bottom: 1px solid var(--border-subtle);
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 0 18px;
      z-index: 100;
      transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s;
    }

    .topbar.auto-hide {
      transform: translateY(-100%);
      opacity: 0;
    }

    .topbar-left {
      display: flex;
      align-items: center;
      gap: 12px;
      min-width: 0;
    }

    .brand-pill {
      display: none !important;
    }

    .doc-title-wrapper {
      min-width: 0;
      display: flex;
      flex-direction: column;
      justify-content: center;
    }

    .doc-title {
      font-size: 14.5px;
      font-weight: 600;
      color: #f8fafc;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      max-width: 520px;
      line-height: 1.25;
    }

    .doc-author {
      font-size: 11.5px;
      color: #94a3b8;
      line-height: 1.25;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      max-width: 520px;
      margin-top: 2px;
    }

    .topbar-right {
      display: flex;
      align-items: center;
      gap: 12px;
      flex-shrink: 0;
    }

    .user-pill {
      display: inline-flex;
      align-items: center;
      gap: 7px;
      background: rgba(255, 255, 255, 0.05);
      border: 1px solid var(--border-subtle);
      padding: 4px 10px;
      border-radius: 20px;
      font-size: 12px;
      color: var(--text-muted);
    }

    .user-pill strong {
      color: #f8fafc;
      font-weight: 600;
    }

    .status-dot {
      width: 6px;
      height: 6px;
      background: var(--brand-emerald);
      border-radius: 50%;
      box-shadow: 0 0 8px var(--brand-emerald);
    }

    .btn-icon-subtle {
      background: transparent;
      border: 1px solid transparent;
      color: var(--text-muted);
      width: 32px;
      height: 32px;
      border-radius: 8px;
      display: flex;
      align-items: center;
      justify-content: center;
      cursor: pointer;
      transition: all 0.15s ease;
    }

    .btn-icon-subtle:hover {
      background: rgba(255, 255, 255, 0.08);
      color: #ffffff;
      border-color: var(--border-subtle);
    }

    /* -------------------------------------------------------------
       MAIN VIEWPORT & CANVAS CONTAINER
       ------------------------------------------------------------- */
    .viewport {
      position: absolute;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      overflow: auto;
      display: flex;
      justify-content: center;
      align-items: flex-start;
      padding: 80px 24px 100px;
      background: radial-gradient(circle at 50% 20%, rgba(30, 41, 59, 0.15) 0%, rgba(9, 11, 16, 1) 100%);
    }

    .canvas-paper {
      position: relative;
      background-color: #ffffff;
      border-radius: 4px;
      box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.05),
        0 20px 45px -10px rgba(0, 0, 0, 0.8),
        0 10px 20px -5px rgba(0, 0, 0, 0.5);
      transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s ease;
      transform-origin: center center;
    }

    /* -------------------------------------------------------------
       CHẾ ĐỘ LẬT SÁCH 3D ĐÍCH THỰC (REALISTIC 3D FLIPBOOK THEATER)
       ------------------------------------------------------------- */
    .book-stage {
      position: absolute;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      display: flex;
      align-items: center;
      justify-content: center;
      overflow: hidden;
      perspective: 2500px;
      user-select: none;
      -webkit-user-select: none;
      z-index: 10;
    }

    /* Bàn đọc sách Thư viện da thuộc cao cấp / Gỗ mun sâu thẳm */
    .book-desk-mat {
      position: absolute;
      width: 96%;
      max-width: 1440px;
      height: 92%;
      max-height: 860px;
      background: radial-gradient(ellipse at center, #182030 0%, #0d121c 60%, #07090e 100%);
      border-radius: 24px;
      box-shadow:
        inset 0 0 0 1px rgba(255, 255, 255, 0.07),
        inset 0 2px 24px rgba(0, 0, 0, 0.7),
        0 35px 90px -20px rgba(0, 0, 0, 0.95);
      pointer-events: none;
      z-index: 1;
    }

    /* Khung bọc cuốn sách (Book Wrap Container) */
    .book-wrap {
      position: relative;
      z-index: 5;
      display: flex;
      align-items: center;
      justify-content: center;
      border-radius: 6px;
      transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1);
    }

    /* Độ dày xấp giấy 2 bên cuốn sách (Paper Stack Depth) */
    .book-stack-depth {
      position: absolute;
      top: 8px;
      bottom: 8px;
      width: 12px;
      pointer-events: none;
      z-index: 3;
      transition: width 0.35s ease, opacity 0.35s ease;
    }

    .book-stack-depth.left {
      right: 100%;
      background: repeating-linear-gradient(to bottom,
          #f8fafc 0px,
          #e2e8f0 1px,
          #94a3b8 2px,
          #cbd5e1 3px);
      box-shadow: -4px 0 12px rgba(0, 0, 0, 0.5);
      border-radius: 4px 0 0 4px;
      border-left: 2px solid #475569;
    }

    .book-stack-depth.right {
      left: 100%;
      background: repeating-linear-gradient(to bottom,
          #f8fafc 0px,
          #e2e8f0 1px,
          #94a3b8 2px,
          #cbd5e1 3px);
      box-shadow: 4px 0 12px rgba(0, 0, 0, 0.5);
      border-radius: 0 4px 4px 0;
      border-right: 2px solid #475569;
    }

    /* Container chính St.PageFlip */
    #flipBook {
      position: relative;
      background: transparent;
      border-radius: 4px;
      overflow: visible !important;
      cursor: grab;
    }

    #flipBook:active {
      cursor: grabbing;
    }

    /* Gáy sách trung tâm với đổ bóng chiều sâu 3D (Book Spine Crease) */
    .book-spine-overlay {
      position: absolute;
      top: 0;
      bottom: 0;
      left: 50%;
      transform: translateX(-50%);
      width: 60px;
      background: linear-gradient(to right,
          rgba(0, 0, 0, 0) 0%,
          rgba(0, 0, 0, 0.12) 20%,
          rgba(0, 0, 0, 0.34) 42%,
          rgba(0, 0, 0, 0.55) 50%,
          rgba(0, 0, 0, 0.34) 58%,
          rgba(0, 0, 0, 0.12) 80%,
          rgba(0, 0, 0, 0) 100%);
      pointer-events: none;
      z-index: 25;
      transition: opacity 0.25s;
    }

    /* Mỗi trang sách lật (Flip Page) */
    .flip-page {
      background-color: #ffffff;
      overflow: hidden;
      position: relative;
      box-sizing: border-box;
      box-shadow: 0 20px 45px -8px rgba(0, 0, 0, 0.8), 0 8px 20px -4px rgba(0, 0, 0, 0.5), inset 0 0 24px rgba(0, 0, 0, 0.03);
    }

    /* Trang bìa cứng (Hard Cover) */
    .flip-page[data-density="hard"] {
      background: linear-gradient(135deg, #1e1b4b 0%, #0f172a 100%);
      color: #ffffff;
    }

    .flip-page[data-density="hard"]::before {
      content: '';
      position: absolute;
      top: 0;
      bottom: 0;
      left: 0;
      width: 8px;
      background: linear-gradient(to right, rgba(0, 0, 0, 0.5) 0%, rgba(0, 0, 0, 0.18) 60%, transparent 100%);
      z-index: 15;
      pointer-events: none;
    }

    .flip-page-canvas {
      display: block;
      pointer-events: none;
    }

    /* Số trang tinh tế ở chân mỗi trang lật */
    .flip-page-foot {
      position: absolute;
      bottom: 8px;
      font-size: 10.5px;
      font-weight: 600;
      color: #94a3b8;
      letter-spacing: 0.5px;
      z-index: 10;
      pointer-events: none;
    }

    .flip-page-foot.left {
      left: 20px;
    }

    .flip-page-foot.right {
      right: 20px;
    }

    /* Nút thao tác nhanh trên góc trang lật (Hover Page Action Buttons) */
    .flip-page-actions {
      position: absolute;
      top: 10px;
      right: 12px;
      z-index: 30;
      display: flex;
      align-items: center;
      gap: 6px;
      opacity: 0;
      transform: translateY(-4px);
      transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1), transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
      pointer-events: auto;
    }

    .flip-page:hover .flip-page-actions,
    .canvas-paper:hover .flip-page-actions {
      opacity: 1;
      transform: translateY(0);
    }

    .flip-page-actions.left-page {
      left: 12px;
      right: auto;
    }

    .page-action-pill {
      background: rgba(15, 23, 42, 0.82);
      backdrop-filter: blur(10px);
      -webkit-backdrop-filter: blur(10px);
      border: 1px solid rgba(255, 255, 255, 0.2);
      color: #f8fafc;
      width: 28px;
      height: 28px;
      border-radius: 8px;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      cursor: pointer;
      box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
      transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
      padding: 0;
    }

    .page-action-pill:hover {
      background: #dc2626;
      border-color: rgba(255, 255, 255, 0.4);
      color: #ffffff;
      transform: scale(1.1);
      box-shadow: 0 6px 16px rgba(220, 38, 38, 0.45);
    }

    .page-action-pill:active {
      transform: scale(0.95);
    }

    /* Badge góc xoay trên HUD */
    .hud-rotate-badge {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      font-size: 9.5px;
      font-weight: 800;
      background: #dc2626;
      color: #ffffff;
      padding: 1px 5px;
      border-radius: 4px;
      margin-left: 3px;
      line-height: 1.2;
    }

    /* Menu Xoay trang trên HUD (Rotate Dropdown Menu) */
    .hud-rotate-menu {
      position: absolute;
      bottom: calc(100% + 12px);
      left: 50%;
      transform: translateX(-50%) translateY(8px);
      background: rgba(15, 23, 42, 0.96);
      backdrop-filter: blur(16px);
      -webkit-backdrop-filter: blur(16px);
      border: 1px solid rgba(255, 255, 255, 0.14);
      border-radius: 14px;
      padding: 8px;
      min-width: 260px;
      box-shadow: 0 20px 45px -10px rgba(0, 0, 0, 0.85), 0 0 25px rgba(220, 38, 38, 0.2);
      z-index: 1000;
      opacity: 0;
      pointer-events: none;
      transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
      display: flex;
      flex-direction: column;
      gap: 4px;
    }

    .hud-rotate-menu.open {
      opacity: 1;
      pointer-events: auto;
      transform: translateX(-50%) translateY(0);
    }

    .rotate-menu-title {
      font-size: 11px;
      font-weight: 700;
      color: #94a3b8;
      text-transform: uppercase;
      letter-spacing: 0.05em;
      padding: 6px 10px 4px 10px;
      border-bottom: 1px solid rgba(255, 255, 255, 0.08);
      margin-bottom: 4px;
    }

    .rotate-menu-item {
      background: transparent;
      border: none;
      color: #f1f5f9;
      font-size: 12.5px;
      font-weight: 500;
      padding: 8px 12px;
      border-radius: 8px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      cursor: pointer;
      transition: all 0.15s ease;
      text-align: left;
      width: 100%;
      font-family: inherit;
    }

    .rotate-menu-item:hover {
      background: rgba(255, 255, 255, 0.1);
      color: #ffffff;
    }

    .rotate-menu-item.active {
      background: rgba(220, 38, 38, 0.2);
      color: #fb7185;
    }

    .rotate-menu-item kbd {
      font-size: 10px;
      font-weight: 700;
      background: rgba(255, 255, 255, 0.12);
      padding: 2px 6px;
      border-radius: 4px;
      color: #cbd5e1;
    }

    .rotate-menu-item.reset {
      color: #94a3b8;
      border-top: 1px solid rgba(255, 255, 255, 0.08);
      margin-top: 4px;
      padding-top: 8px;
    }

    .rotate-menu-item.reset:hover {
      color: #f87171;
      background: rgba(248, 113, 113, 0.1);
    }

    /* Giao diện trang sách bị khóa bản quyền trong 3D Book (Locked Sheet) */
    .flip-locked-sheet {
      width: 100%;
      height: 100%;
      background: #fafaf9;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      padding: 32px 24px;
      box-sizing: border-box;
      position: relative;
      overflow: hidden;
      border: 1px solid #f1f5f9;
    }

    .flip-locked-sheet::before {
      content: '';
      position: absolute;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      background: repeating-linear-gradient(-45deg,
          rgba(225, 29, 72, 0.025),
          rgba(225, 29, 72, 0.025) 12px,
          transparent 12px,
          transparent 24px);
      pointer-events: none;
    }

    .locked-emboss-seal {
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 10px;
      margin-bottom: 16px;
      z-index: 2;
    }

    .locked-seal-ring {
      width: 58px;
      height: 58px;
      border-radius: 50%;
      background: rgba(225, 29, 72, 0.08);
      border: 2px dashed rgba(225, 29, 72, 0.4);
      display: flex;
      align-items: center;
      justify-content: center;
      color: #e11d48;
      box-shadow: 0 4px 18px rgba(225, 29, 72, 0.12);
    }

    .locked-seal-text {
      font-size: 10px;
      font-weight: 800;
      letter-spacing: 1.5px;
      color: #e11d48;
      text-transform: uppercase;
    }

    .locked-page-heading {
      font-size: 15px;
      font-weight: 700;
      color: #0f172a;
      margin-bottom: 8px;
      text-align: center;
      z-index: 2;
    }

    .locked-page-notice {
      font-size: 12px;
      color: #475569;
      line-height: 1.6;
      text-align: center;
      max-width: 300px;
      margin-bottom: 18px;
      z-index: 2;
    }

    .locked-page-notice strong {
      color: #0f172a;
    }

    .locked-cta-box {
      background: #ffffff;
      border: 1px solid #e2e8f0;
      border-radius: 10px;
      padding: 12px 16px;
      text-align: center;
      max-width: 300px;
      box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
      z-index: 2;
    }

    .locked-cta-title {
      font-size: 11px;
      font-weight: 700;
      color: #1e293b;
      margin-bottom: 4px;
    }

    .locked-cta-desc {
      font-size: 10.5px;
      color: #64748b;
      line-height: 1.45;
    }

    .locked-faint-lines {
      width: 75%;
      display: flex;
      flex-direction: column;
      gap: 7px;
      margin-top: 20px;
      opacity: 0.35;
      z-index: 2;
    }

    .faint-line {
      height: 6px;
      background: #cbd5e1;
      border-radius: 4px;
    }

    /* Nút điều hướng nổi 2 bên mép bàn sách (Floating Nav Arrows) */
    .book-nav-arrow {
      position: absolute;
      top: 50%;
      transform: translateY(-50%);
      width: 46px;
      height: 46px;
      border-radius: 50%;
      background: rgba(18, 22, 33, 0.85);
      backdrop-filter: blur(16px);
      -webkit-backdrop-filter: blur(16px);
      border: 1px solid rgba(255, 255, 255, 0.15);
      color: #ffffff;
      display: flex;
      align-items: center;
      justify-content: center;
      cursor: pointer;
      z-index: 50;
      box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
      transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    }

    .book-nav-arrow:hover:not(:disabled) {
      background: rgba(225, 29, 72, 0.9);
      border-color: rgba(225, 29, 72, 1);
      transform: translateY(-50%) scale(1.1);
      box-shadow: 0 12px 30px rgba(225, 29, 72, 0.4);
    }

    .book-nav-arrow:disabled {
      opacity: 0.2;
      cursor: not-allowed;
    }

    .book-nav-arrow.prev {
      left: 24px;
    }

    .book-nav-arrow.next {
      right: 24px;
    }

    /* Gợi ý thao tác kéo góc trang */
    .flip-drag-hint {
      position: absolute;
      bottom: 22px;
      right: 32px;
      font-size: 11px;
      color: rgba(255, 255, 255, 0.5);
      background: rgba(0, 0, 0, 0.45);
      backdrop-filter: blur(8px);
      padding: 5px 12px;
      border-radius: 9999px;
      pointer-events: none;
      z-index: 10;
      letter-spacing: 0.3px;
    }

    #pdfCanvas {
      display: block;
    }

    /* -------------------------------------------------------------
       FLOATING HUD TOOLBAR (APPLE / LINEAR STYLE DOCK)
       ------------------------------------------------------------- */
    .floating-hud {
      position: fixed;
      bottom: 24px;
      left: 50%;
      transform: translateX(-50%);
      height: 48px;
      background: rgba(18, 22, 33, 0.88);
      backdrop-filter: blur(24px);
      -webkit-backdrop-filter: blur(24px);
      border: 1px solid rgba(255, 255, 255, 0.1);
      border-radius: 9999px;
      display: flex;
      align-items: center;
      padding: 0 10px;
      gap: 6px;
      box-shadow:
        0 20px 40px -10px rgba(0, 0, 0, 0.7),
        0 0 0 1px rgba(255, 255, 255, 0.05);
      z-index: 100;
      transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
    }

    .floating-hud.idle-fade {
      opacity: 0.35;
    }

    .floating-hud.idle-fade:hover {
      opacity: 1;
    }

    .hud-btn {
      background: transparent;
      border: none;
      color: var(--text-muted);
      height: 32px;
      padding: 0 8px;
      border-radius: 16px;
      display: flex;
      align-items: center;
      justify-content: center;
      cursor: pointer;
      transition: all 0.15s;
    }

    .hud-btn:hover:not(:disabled) {
      background: rgba(255, 255, 255, 0.1);
      color: #ffffff;
    }

    .hud-btn.active {
      background: rgba(225, 29, 72, 0.2);
      border: 1px solid rgba(225, 29, 72, 0.4);
      color: #fb7185;
    }

    .hud-btn:disabled {
      opacity: 0.3;
      cursor: not-allowed;
    }

    .hud-divider {
      width: 1px;
      height: 20px;
      background: rgba(255, 255, 255, 0.1);
      margin: 0 4px;
    }

    .hud-page-indicator {
      display: flex;
      align-items: center;
      gap: 6px;
      font-size: 13px;
      font-weight: 500;
      padding: 0 8px;
      color: var(--text-muted);
    }

    .hud-page-input {
      background: rgba(255, 255, 255, 0.08);
      border: 1px solid rgba(255, 255, 255, 0.12);
      color: #ffffff;
      font-family: inherit;
      font-size: 12.5px;
      font-weight: 600;
      width: 40px;
      height: 28px;
      border-radius: 6px;
      text-align: center;
    }

    .hud-page-input:focus {
      outline: none;
      border-color: var(--brand-red);
      background: rgba(255, 255, 255, 0.15);
    }

    .hud-zoom-label {
      font-size: 12px;
      font-weight: 600;
      color: var(--text-muted);
      min-width: 44px;
      text-align: center;
      cursor: pointer;
    }

    .hud-zoom-label:hover {
      color: #ffffff;
    }

    .hud-quota-chip {
      background: rgba(245, 158, 11, 0.15);
      border: 1px solid rgba(245, 158, 11, 0.3);
      color: #fcd34d;
      font-size: 11px;
      font-weight: 600;
      padding: 3px 9px;
      border-radius: 12px;
      display: flex;
      align-items: center;
      gap: 5px;
    }

    /* -------------------------------------------------------------
       NAVIGATION SIDEBAR (ACROBAT / PDF.JS DUAL-MODE RAIL & THUMBNAILS)
       ------------------------------------------------------------- */
    .sidebar-backdrop {
      position: fixed;
      top: 52px;
      left: 0;
      right: 0;
      bottom: 0;
      background: rgba(0, 0, 0, 0.5);
      backdrop-filter: blur(3px);
      z-index: 110;
      display: none;
    }

    .sidebar-backdrop.open {
      display: block;
    }

    @media (min-width: 1024px) {
      .sidebar-backdrop {
        display: none !important;
      }

      .viewport {
        transition: left 0.25s cubic-bezier(0.16, 1, 0.3, 1);
      }

      .viewport.sidebar-docked {
        left: 285px;
      }
    }

    .reader-sidebar {
      position: fixed;
      top: 52px;
      bottom: 0;
      left: 0;
      width: 285px;
      background: #181a20;
      border-right: 1px solid rgba(255, 255, 255, 0.08);
      z-index: 120;
      display: flex;
      flex-direction: row;
      transform: translateX(-100%);
      transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
      box-shadow: 12px 0 35px rgba(0, 0, 0, 0.55);
    }

    .reader-sidebar.open {
      transform: translateX(0);
    }

    /* DẢI ICON DỌC BÊN TRÁI (LEFT ICON RAIL) */
    .sidebar-rail {
      width: 48px;
      background: #12141a;
      border-right: 1px solid rgba(255, 255, 255, 0.08);
      display: flex;
      flex-direction: column;
      align-items: center;
      padding: 12px 0;
      gap: 8px;
      flex-shrink: 0;
    }

    .rail-btn {
      width: 40px;
      height: 40px;
      border-radius: 6px;
      background: transparent;
      border: none;
      color: #94a3b8;
      display: flex;
      align-items: center;
      justify-content: center;
      cursor: pointer;
      position: relative;
      transition: all 0.15s ease;
    }

    .rail-btn:hover {
      color: #ffffff;
      background: rgba(255, 255, 255, 0.06);
    }

    /* Nút đang kích hoạt: Thanh xanh sáng ở mép trái chuẩn Acrobat */
    .rail-btn.active {
      color: #38bdf8;
      background: rgba(56, 189, 248, 0.12);
    }

    .rail-btn.active::before {
      content: '';
      position: absolute;
      left: 0;
      top: 7px;
      bottom: 7px;
      width: 3.5px;
      background: #38bdf8;
      border-radius: 0 3px 3px 0;
      box-shadow: 0 0 8px rgba(56, 189, 248, 0.8);
    }

    /* KHU VỰC NỘI DUNG PANEL BÊN PHẢI RAIL */
    .sidebar-panel-container {
      flex: 1;
      display: flex;
      flex-direction: column;
      background: #191c23;
      overflow: hidden;
      min-width: 0;
    }

    .sidebar-panel {
      display: none;
      flex: 1;
      flex-direction: column;
      min-height: 0;
      overflow: hidden;
    }

    .sidebar-panel.active {
      display: flex;
    }

    /* -------------------------------------------------------------
       PANEL 1: TRANG THU NHỎ (THUMBNAILS - HÌNH ẢNH TRANG THẬT)
       ------------------------------------------------------------- */
    .sidebar-thumbs-wrap {
      flex: 1;
      overflow-y: auto;
      padding: 16px 12px 70px;
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 18px;
    }

    .thumb-unit {
      display: flex;
      flex-direction: column;
      align-items: center;
      cursor: pointer;
      width: 156px;
      transition: transform 0.15s ease;
    }

    .thumb-unit:hover {
      transform: translateY(-2px);
    }

    .thumb-paper {
      width: 148px;
      height: 209px;
      background: #ffffff;
      border-radius: 3px;
      box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
      display: flex;
      align-items: center;
      justify-content: center;
      overflow: hidden;
      position: relative;
      border: 1px solid rgba(255, 255, 255, 0.1);
      transition: outline 0.15s, box-shadow 0.15s;
    }

    .thumb-unit.active .thumb-paper {
      outline: 2.5px solid #38bdf8;
      outline-offset: 1px;
      box-shadow: 0 0 0 1px #38bdf8, 0 8px 24px rgba(56, 189, 248, 0.35);
    }

    .thumb-paper canvas {
      width: 100% !important;
      height: 100% !important;
      object-fit: contain;
      display: block;
      background: #ffffff;
    }

    .thumb-placeholder-spinner {
      width: 22px;
      height: 22px;
      border: 2px solid rgba(0, 0, 0, 0.1);
      border-top-color: #3b82f6;
      border-radius: 50%;
      animation: spin 0.8s linear infinite;
    }

    .thumb-label {
      font-size: 13px;
      font-weight: 500;
      color: #cbd5e1;
      margin-top: 6px;
      text-align: center;
      transition: color 0.15s;
    }

    .thumb-unit.active .thumb-label {
      color: #38bdf8;
      font-weight: 700;
    }

    .thumb-paper.locked {
      background: #11141c;
      border: 1px dashed rgba(239, 68, 68, 0.4);
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 6px;
    }

    .thumb-unit.locked .thumb-label {
      color: #f87171;
    }

    /* -------------------------------------------------------------
       PANEL 2: MỤC LỤC NỘI DUNG (TABLE OF CONTENTS / OUTLINE)
       ------------------------------------------------------------- */
    .toc-container {
      padding: 12px 14px;
      display: flex;
      flex-direction: column;
      gap: 6px;
      overflow-y: auto;
      flex: 1;
    }

    .toc-search-box {
      margin-bottom: 10px;
      position: relative;
    }

    .toc-search-input {
      width: 100%;
      background: rgba(255, 255, 255, 0.06);
      border: 1px solid rgba(255, 255, 255, 0.12);
      border-radius: 6px;
      padding: 7px 10px 7px 30px;
      color: #ffffff;
      font-size: 12px;
      font-family: inherit;
      outline: none;
      box-sizing: border-box;
      transition: border-color 0.2s, background 0.2s;
    }

    .toc-search-input:focus {
      border-color: #38bdf8;
      background: rgba(255, 255, 255, 0.1);
    }

    .toc-search-icon {
      position: absolute;
      left: 9px;
      top: 50%;
      transform: translateY(-50%);
      color: var(--text-muted);
      pointer-events: none;
    }

    .toc-list {
      display: flex;
      flex-direction: column;
      gap: 4px;
      overflow-y: auto;
      flex: 1;
    }

    .toc-section-header {
      font-size: 10px;
      font-weight: 700;
      color: #94a3b8;
      text-transform: uppercase;
      letter-spacing: 0.8px;
      padding: 8px 6px 4px;
      border-bottom: 1px solid rgba(255, 255, 255, 0.06);
      margin-top: 4px;
    }

    .toc-item {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 8px 10px;
      border-radius: 6px;
      background: rgba(255, 255, 255, 0.02);
      border: 1px solid transparent;
      cursor: pointer;
      transition: all 0.15s ease;
      gap: 8px;
    }

    .toc-item:hover {
      background: rgba(255, 255, 255, 0.07);
      border-color: rgba(255, 255, 255, 0.1);
      transform: translateX(2px);
    }

    .toc-item.active {
      background: rgba(56, 189, 248, 0.15);
      border-color: rgba(56, 189, 248, 0.4);
    }

    .toc-item-left {
      display: flex;
      align-items: center;
      gap: 8px;
      flex: 1;
      min-width: 0;
    }

    .toc-item-icon {
      flex-shrink: 0;
      color: #38bdf8;
    }

    .toc-item.locked .toc-item-icon {
      color: #f87171;
    }

    .toc-item-title {
      font-size: 12px;
      font-weight: 500;
      color: #e2e8f0;
      line-height: 1.35;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .toc-item.locked .toc-item-title {
      color: #94a3b8;
    }

    .toc-item-page {
      flex-shrink: 0;
      font-size: 11px;
      font-weight: 700;
      padding: 2px 6px;
      border-radius: 8px;
      background: rgba(255, 255, 255, 0.08);
      color: #cbd5e1;
    }

    .toc-item.locked .toc-item-page {
      background: rgba(225, 29, 72, 0.14);
      color: #fb7185;
      border: 1px solid rgba(225, 29, 72, 0.28);
    }

    /* THANH CUỘN MẢNH TINH TẾ */
    .sidebar-thumbs-wrap::-webkit-scrollbar,
    .toc-container::-webkit-scrollbar,
    .toc-list::-webkit-scrollbar {
      width: 5px;
    }

    .sidebar-thumbs-wrap::-webkit-scrollbar-track,
    .toc-container::-webkit-scrollbar-track,
    .toc-list::-webkit-scrollbar-track {
      background: transparent;
    }

    .sidebar-thumbs-wrap::-webkit-scrollbar-thumb,
    .toc-container::-webkit-scrollbar-thumb,
    .toc-list::-webkit-scrollbar-thumb {
      background: rgba(255, 255, 255, 0.15);
      border-radius: 4px;
    }

    .sidebar-thumbs-wrap::-webkit-scrollbar-thumb:hover,
    .toc-container::-webkit-scrollbar-thumb:hover,
    .toc-list::-webkit-scrollbar-thumb:hover {
      background: rgba(255, 255, 255, 0.3);
    }

    /* TOAST THÔNG BÁO */
    .reader-toast {
      position: fixed;
      top: 68px;
      left: 50%;
      transform: translateX(-50%) translateY(-20px);
      background: rgba(18, 22, 33, 0.95);
      backdrop-filter: blur(20px);
      -webkit-backdrop-filter: blur(20px);
      border: 1px solid rgba(255, 255, 255, 0.15);
      box-shadow: 0 16px 36px rgba(0, 0, 0, 0.6);
      color: #ffffff;
      font-size: 13px;
      font-weight: 500;
      padding: 10px 18px;
      border-radius: 9999px;
      z-index: 300;
      opacity: 0;
      pointer-events: none;
      transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
      display: flex;
      align-items: center;
      gap: 8px;
    }

    .reader-toast.show {
      opacity: 1;
      transform: translateX(-50%) translateY(0);
      pointer-events: auto;
    }

    /* -------------------------------------------------------------
       PAYWALL RESTRICTION MODAL (SEC-3 PREVIEW LIMIT)
       ------------------------------------------------------------- */
    .paywall-card {
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      background: #ffffff;
      border: none;
      border-top: 4px solid #A31A24;
      border-radius: 24px;
      padding: 40px 36px 34px;
      max-width: 400px;
      width: 90%;
      text-align: center;
      color: #1a1414;
      box-shadow: 0 30px 70px -30px rgba(0, 0, 0, 0.55), 0 1px 3px rgba(0, 0, 0, 0.08);
      display: none;
      z-index: 200;
      animation: popIn 0.35s cubic-bezier(0.22, 1, 0.36, 1);
    }

    /* Trạng thái chặn toàn trang (từ chối / yêu cầu đăng nhập / không tìm thấy) */
    .paywall-card.is-blocking {
      position: fixed;
      z-index: 5000;
      box-shadow: 0 0 0 100vmax #f5eee8, 0 30px 70px -35px rgba(127, 16, 25, 0.45);
    }

    .paywall-card.active {
      display: block;
    }

    @keyframes popIn {
      from {
        opacity: 0;
        transform: translate(-50%, -46%) scale(0.96);
      }

      to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
      }
    }

    .paywall-logo {
      display: block;
      width: 84px;
      height: 84px;
      object-fit: contain;
      margin: 0 auto 22px;
    }

    .paywall-tag {
      display: none !important;
    }

    .paywall-title {
      font-size: 21px;
      font-weight: 700;
      letter-spacing: -0.01em;
      color: #1a1414;
      margin: 0 0 8px;
    }

    .paywall-desc {
      font-size: 14.5px;
      color: #7a6f6a;
      line-height: 1.6;
      margin: 0 0 26px;
    }

    .paywall-desc strong {
      color: #1a1414;
      font-weight: 600;
    }

    .btn-paywall {
      background: #A31A24;
      color: #ffffff;
      border: none;
      padding: 11px 26px;
      border-radius: 999px;
      font-family: inherit;
      font-size: 14px;
      font-weight: 600;
      cursor: pointer;
      transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
    }

    .btn-paywall:hover {
      background: #7F1019;
      transform: translateY(-1px);
      box-shadow: 0 8px 18px -8px rgba(127, 16, 25, 0.6);
    }

    /* -------------------------------------------------------------
       SECURITY BLUR OVERLAY (ANTI SCREENSHOT / FOCUS LOST)
       ------------------------------------------------------------- */
    .blur-curtain {
      position: fixed;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      background: rgba(9, 11, 16, 0.88);
      backdrop-filter: blur(25px);
      -webkit-backdrop-filter: blur(25px);
      z-index: 999;
      display: none;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      text-align: center;
      padding: 24px;
    }

    .blur-curtain.active {
      display: flex;
    }

    .blur-curtain h3 {
      font-size: 18px;
      font-weight: 700;
      margin-bottom: 8px;
      color: #ffffff;
    }

    .blur-curtain p {
      font-size: 13px;
      color: var(--text-muted);
      max-width: 400px;
      line-height: 1.5;
    }

    /* LOADING SPINNER & PROGRESS BAR */
    .spinner-box {
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 16px;
      color: var(--text-muted);
      font-size: 13px;
      z-index: 50;
      padding: 24px 28px;
      background: rgba(18, 18, 22, 0.85);
      border: 1px solid rgba(255, 255, 255, 0.1);
      border-radius: 16px;
      backdrop-filter: blur(20px);
      -webkit-backdrop-filter: blur(20px);
      box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.05);
      min-width: 300px;
      max-width: 420px;
      width: 88vw;
      text-align: center;
      transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .spinner-box.fade-out {
      opacity: 0;
      transform: translate(-50%, -46%) scale(0.95);
      pointer-events: none;
    }

    .ring-spinner {
      width: 42px;
      height: 42px;
      border: 3.5px solid rgba(255, 255, 255, 0.08);
      border-top-color: var(--brand-red, #e11d48);
      border-right-color: rgba(225, 29, 72, 0.4);
      border-radius: 50%;
      animation: spin 0.8s cubic-bezier(0.4, 0, 0.2, 1) infinite;
      box-shadow: 0 0 16px rgba(225, 29, 72, 0.3);
    }

    .spinner-content {
      display: flex;
      flex-direction: column;
      align-items: center;
      width: 100%;
      gap: 12px;
    }

    .spinner-title {
      font-size: 13.5px;
      font-weight: 600;
      color: #f8fafc;
      letter-spacing: 0.1px;
      line-height: 1.4;
      transition: color 0.2s ease;
    }

    .spinner-progress-wrap {
      width: 100%;
      display: flex;
      flex-direction: column;
      gap: 8px;
    }

    .spinner-bar-track {
      width: 100%;
      height: 7px;
      background: rgba(255, 255, 255, 0.08);
      border-radius: 999px;
      overflow: hidden;
      position: relative;
      box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.5);
    }

    .spinner-bar-fill {
      height: 100%;
      width: 0%;
      background: linear-gradient(90deg, #e11d48 0%, #f43f5e 60%, #fb7185 100%);
      border-radius: 999px;
      transition: width 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
      position: relative;
      box-shadow: 0 0 10px rgba(225, 29, 72, 0.5);
    }

    .spinner-bar-fill::after {
      content: '';
      position: absolute;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.4) 50%,
        rgba(255, 255, 255, 0) 100%
      );
      animation: shimmer 1.5s infinite;
    }

    @keyframes shimmer {
      0% { transform: translateX(-100%); }
      100% { transform: translateX(100%); }
    }

    .spinner-stats {
      display: flex;
      justify-content: space-between;
      align-items: center;
      width: 100%;
      font-size: 11.5px;
      color: #94a3b8;
      font-variant-numeric: tabular-nums;
    }

    .spinner-percent {
      font-weight: 700;
      color: #38bdf8;
      font-size: 13px;
      letter-spacing: 0.2px;
    }

    .spinner-detail {
      font-size: 11px;
      color: #94a3b8;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      max-width: 230px;
    }

    /* CHỐNG IN ẤN VÀ XUẤT FILE TRÁI PHÉP KHI CHƯA ĐƯỢC CẤP QUYỀN */
    @media print {

      body:not(.can-print) #viewport,
      body:not(.can-print) #canvasPaper,
      body:not(.can-print) #pdfCanvas,
      body:not(.can-print) .drawer,
      body:not(.can-print) .floating-hud,
      body:not(.can-print) .topbar,
      body:not(.can-print) .reader-sidebar,
      body:not(.can-print) .drm-modal-backdrop {
        display: none !important;
        visibility: hidden !important;
        height: 0 !important;
        width: 0 !important;
        opacity: 0 !important;
      }

      body:not(.can-print)::before {
        content: 'TÀI LIỆU SỐ BẢO VỆ BẢN QUYỀN FTU DRM - TÍNH NĂNG IN ẤN ĐÃ BỊ VÔ HIỆU HÓA HOÀN TOÀN.';
        display: block !important;
        font-size: 22px;
        color: #e11d48;
        text-align: center;
        margin-top: 120px;
        font-weight: bold;
        font-family: sans-serif;
      }
    }

    /* VÔ HIỆU HÓA BÔI ĐEN VĂN BẢN VÀ KÉO THẢ */
    * {
      -webkit-user-select: none !important;
      -moz-user-select: none !important;
      -ms-user-select: none !important;
      user-select: none !important;
      -webkit-user-drag: none !important;
    }
    /* =========================================================================
       FTU DRM READER - MOBILE & TABLET ADAPTIVE DESIGN SYSTEM (<= 768px)
       Tối ưu hóa hiển thị, công thái học ngón tay cái và điều hướng cảm ứng
       ========================================================================= */
    @media (max-width: 768px) {
      /* 1. Header trên cùng thu gọn */
      .topbar {
        height: 50px !important;
        padding: 0 10px !important;
      }

      .topbar-left {
        gap: 8px !important;
        max-width: calc(100vw - 65px) !important;
      }

      .doc-title {
        font-size: 13px !important;
        max-width: calc(100vw - 120px) !important;
        line-height: 1.2 !important;
      }

      .doc-author {
        display: none !important; /* Ẩn tác giả trên mobile để header luôn giữ 1 dòng thanh thoát */
      }

      /* Người dùng trên mobile: thu nhỏ và ẩn badge thừa */
      .topbar-right .user-pill {
        padding: 3px 8px !important;
        font-size: 11px !important;
      }

      #patronRoleBadge,
      .user-pill span:not(.status-dot) {
        display: none !important;
      }

      .btn-icon-subtle {
        width: 32px !important;
        height: 32px !important;
        flex-shrink: 0 !important;
      }

      /* 2. Khung nhìn (Viewport) đệm lót chuẩn safe-area cho điện thoại */
      .viewport {
        padding: 56px 6px calc(68px + env(safe-area-inset-bottom, 0px)) 6px !important;
        align-items: center !important;
      }

      /* 3. Sân khấu sách 3D (3D Flipbook) trên màn hình dọc */
      .book-stage {
        overflow: hidden !important;
        padding: 0 !important;
        margin: 0 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        width: 100% !important;
        height: 100% !important;
      }

      .book-desk-mat {
        display: none !important; /* Bỏ đệm da bàn sách lớn để trang sách chiếm trọn màn hình */
      }

      .book-nav-arrow {
        display: flex !important;
        width: 40px !important;
        height: 40px !important;
        background: rgba(15, 23, 42, 0.78) !important;
        backdrop-filter: blur(12px) !important;
        -webkit-backdrop-filter: blur(12px) !important;
        border: 1px solid rgba(255, 255, 255, 0.22) !important;
        color: #ffffff !important;
        box-shadow: 0 4px 18px rgba(0, 0, 0, 0.65) !important;
        z-index: 80 !important;
        position: absolute !important;
        top: 50% !important;
        transform: translateY(-50%) !important;
        opacity: 0.9 !important;
        pointer-events: auto !important;
        touch-action: manipulation !important;
      }

      .book-nav-arrow:active:not(:disabled) {
        transform: translateY(-50%) scale(0.92) !important;
        background: rgba(225, 29, 72, 0.95) !important;
        border-color: rgba(225, 29, 72, 1) !important;
      }

      .book-nav-arrow.prev {
        left: 8px !important;
      }

      .book-nav-arrow.next {
        right: 8px !important;
      }

      .flip-drag-hint {
        display: none !important;
      }

      .book-stack-depth {
        display: none !important;
      }

      .book-spine-overlay {
        display: none !important;
      }

      .book-wrap {
        width: 100% !important;
        max-width: 100% !important;
        height: 100% !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        transform: none !important;
      }

      #flipBook {
        max-width: 100vw !important;
        margin: 0 auto !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
      }

      .stf__parent {
        margin: 0 auto !important;
      }

      .stf__wrapper {
        margin: 0 auto !important;
      }

      .flip-page {
        border-radius: 6px !important;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.75) !important;
      }

      .flip-page-actions {
        top: 8px !important;
        right: 8px !important;
      }

      .page-action-pill {
        width: 26px !important;
        height: 26px !important;
      }

      /* 4. Chế độ trang đơn 2D (Single Page Canvas) */
      .canvas-paper {
        max-width: 100% !important;
        width: auto !important;
        margin: 0 auto !important;
        box-shadow: 0 8px 30px rgba(0, 0, 0, 0.7) !important;
        display: flex !important;
        justify-content: center !important;
        align-items: center !important;
        position: relative !important;
      }

      #pdfCanvas {
        max-width: calc(100vw - 16px) !important;
        height: auto !important;
        border-radius: 6px !important;
        display: block !important;
        margin: 0 auto !important;
      }

      /* 5. Thanh công cụ nổi dưới đáy (Mobile Floating HUD Dock) */
      .floating-hud {
        position: fixed !important;
        bottom: calc(12px + env(safe-area-inset-bottom, 0px)) !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        width: calc(100vw - 20px) !important;
        max-width: 440px !important;
        height: 46px !important;
        padding: 0 8px !important;
        gap: 4px !important;
        justify-content: space-between !important;
        background: rgba(15, 23, 42, 0.94) !important;
        backdrop-filter: blur(20px) !important;
        -webkit-backdrop-filter: blur(20px) !important;
        border: 1px solid rgba(255, 255, 255, 0.15) !important;
        box-shadow: 0 12px 35px rgba(0, 0, 0, 0.75) !important;
        border-radius: 28px !important;
      }

      /* Ẩn các nút rườm rà trên desktop để thanh HUD vừa khít màn hình điện thoại */
      #btnZoomOut,
      #zoomLabel,
      #btnZoomIn,
      #btnFitWidth,
      #btnFullscreen,
      #btnFlipMode,
      .hud-divider {
        display: none !important;
      }

      .hud-btn {
        width: 34px !important;
        height: 34px !important;
        padding: 0 !important;
        border-radius: 17px !important;
      }

      .hud-page-indicator {
        font-size: 12px !important;
        gap: 3px !important;
      }

      .hud-page-input {
        width: 32px !important;
        height: 26px !important;
        font-size: 12px !important;
        padding: 0 !important;
        text-align: center !important;
      }

      .hud-quota-chip {
        font-size: 10px !important;
        padding: 2px 7px !important;
        border-radius: 12px !important;
      }

      /* Chế độ ẩn mượt mà khi đọc toàn màn hình (Immersive Mode) */
      .floating-hud.auto-hide {
        transform: translateX(-50%) translateY(120%) !important;
        opacity: 0 !important;
        pointer-events: none !important;
      }

      .topbar.auto-hide {
        transform: translateY(-100%) !important;
        opacity: 0 !important;
        pointer-events: none !important;
      }

      /* 6. Thanh ngăn kéo Mục lục & Trang thu nhỏ (Sidebar Drawer) */
      .reader-sidebar {
        width: 88vw !important;
        max-width: 320px !important;
        z-index: 1000 !important;
      }

      .sidebar-backdrop {
        z-index: 999 !important;
      }

      /* 7. Thông báo giới hạn xem trước (Paywall & Locked Sheet) */
      .paywall-card {
        width: 90vw !important;
        max-width: 360px !important;
        padding: 28px 20px 24px !important;
      }

      .paywall-logo {
        width: 68px;
        height: 68px;
        margin-bottom: 16px;
      }

      .paywall-title {
        font-size: 16px !important;
      }

      .paywall-desc {
        font-size: 12px !important;
      }

      .flip-locked-sheet {
        padding: 16px 10px !important;
      }

      .locked-page-heading {
        font-size: 14px !important;
        margin-bottom: 6px !important;
      }

      .locked-page-notice {
        font-size: 11px !important;
        margin-bottom: 12px !important;
      }

      .locked-cta-box {
        padding: 8px 10px !important;
      }

      .locked-cta-title {
        font-size: 10px !important;
      }

      .locked-cta-desc {
        font-size: 9.5px !important;
      }

      .locked-faint-lines {
        display: none !important;
      }
    }

    /* Màn hình siêu nhỏ (<= 390px, iPhone SE, iPhone Mini) */
    @media (max-width: 390px) {
      .topbar-right .user-pill {
        display: none !important; /* Ẩn hẳn pill tên người dùng trên màn hình siêu hẹp để dành chỗ cho tiêu đề */
      }

      .floating-hud {
        width: calc(100vw - 12px) !important;
        padding: 0 4px !important;
      }

      .hud-page-input {
        width: 28px !important;
      }

      .hud-quota-chip {
        display: none !important;
      }
    }

    /* Tối ưu hóa độ nét cao và chống vỡ nét / răng cưa chữ cho Canvas đọc tài liệu */
    .flip-page-canvas,
    #pdfCanvas {
      image-rendering: -webkit-optimize-contrast;
      image-rendering: auto;
    }

    /* =========================================================================
       DRM ACTIONS: TẢI XUỐNG, IN ẤN, SAO CHÉP VĂN BẢN (THEO CHÍNH SÁCH BẢO MẬT)
       ========================================================================= */

    /* Các nút tác vụ phân quyền DRM trên thanh tiêu đề */
    .topbar-btn {
      background: rgba(255, 255, 255, 0.06);
      border: 1px solid rgba(255, 255, 255, 0.14);
      color: #e2e8f0;
      height: 32px;
      padding: 0 11px;
      border-radius: 8px;
      display: inline-flex;
      align-items: center;
      gap: 6px;
      cursor: pointer;
      font-size: 12px;
      font-weight: 500;
      font-family: inherit;
      transition: all 0.18s ease;
      white-space: nowrap;
    }

    .topbar-btn:hover {
      background: rgba(255, 255, 255, 0.13);
      color: #ffffff;
      border-color: rgba(255, 255, 255, 0.28);
      transform: translateY(-1px);
      box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
    }

    .topbar-btn:active {
      transform: translateY(0);
    }

    .topbar-btn.primary-btn {
      background: linear-gradient(135deg, #2563eb, #1d4ed8);
      border: 1px solid rgba(147, 197, 253, 0.35);
      color: #ffffff;
      box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
    }

    .topbar-btn.primary-btn:hover {
      background: linear-gradient(135deg, #3b82f6, #2563eb);
      border-color: rgba(147, 197, 253, 0.6);
      box-shadow: 0 4px 14px rgba(37, 99, 235, 0.45);
      transform: translateY(-1px);
    }

    .topbar-divider {
      width: 1px;
      height: 20px;
      background: rgba(255, 255, 255, 0.12);
      margin: 0 4px;
    }

    /* Khi được cấp quyền sao chép, cho phép bôi đen văn bản */
    body.can-copy-text,
    body.can-copy-text * {
      -webkit-user-select: text;
      -moz-user-select: text;
      -ms-user-select: text;
      user-select: text;
    }

    /* MODAL SAO CHÉP VĂN BẢN (COPY TEXT MODAL) */
    .drm-modal-backdrop {
      position: fixed;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      background: rgba(0, 0, 0, 0.75);
      backdrop-filter: blur(8px);
      -webkit-backdrop-filter: blur(8px);
      z-index: 1050;
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 16px;
      animation: fadeIn 0.2s ease-out;
    }

    .drm-modal-box {
      background: #0f172a;
      border: 1px solid rgba(255, 255, 255, 0.15);
      box-shadow: 0 25px 60px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.05);
      border-radius: 16px;
      width: 100%;
      max-width: 640px;
      max-height: 85vh;
      display: flex;
      flex-direction: column;
      overflow: hidden;
      animation: scaleUp 0.22s cubic-bezier(0.16, 1, 0.3, 1);
    }

    @keyframes fadeIn {
      from { opacity: 0; }
      to { opacity: 1; }
    }

    @keyframes scaleUp {
      from { transform: scale(0.95); opacity: 0; }
      to { transform: scale(1); opacity: 1; }
    }

    .drm-modal-header {
      padding: 16px 20px;
      border-bottom: 1px solid rgba(255, 255, 255, 0.08);
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      background: rgba(255, 255, 255, 0.02);
    }

    .drm-modal-title-wrap {
      display: flex;
      align-items: center;
      gap: 12px;
    }

    .drm-modal-icon {
      width: 38px;
      height: 38px;
      border-radius: 10px;
      background: rgba(37, 99, 235, 0.15);
      border: 1px solid rgba(37, 99, 235, 0.3);
      color: #60a5fa;
      display: flex;
      align-items: center;
      justify-content: center;
      flex-shrink: 0;
    }

    .drm-modal-title {
      font-size: 15px;
      font-weight: 700;
      color: #f8fafc;
      margin: 0;
      line-height: 1.3;
    }

    .drm-modal-subtitle {
      font-size: 11.5px;
      color: #94a3b8;
      display: block;
      margin-top: 2px;
    }

    .drm-modal-body {
      padding: 18px 20px;
      overflow-y: auto;
      display: flex;
      flex-direction: column;
      gap: 12px;
      flex: 1;
    }

    .copy-modal-toolbar {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 8px;
      flex-wrap: wrap;
    }

    .copy-stats-badge {
      font-size: 11px;
      font-weight: 600;
      color: #38bdf8;
      background: rgba(56, 189, 248, 0.1);
      border: 1px solid rgba(56, 189, 248, 0.25);
      padding: 3px 8px;
      border-radius: 6px;
    }

    .copy-mode-tabs {
      display: inline-flex;
      background: rgba(255, 255, 255, 0.05);
      border-radius: 8px;
      padding: 2px;
      border: 1px solid rgba(255, 255, 255, 0.08);
      gap: 2px;
    }

    .copy-tab-btn {
      background: transparent;
      border: none;
      color: #94a3b8;
      font-size: 11px;
      font-weight: 500;
      padding: 4px 10px;
      border-radius: 6px;
      cursor: pointer;
      transition: all 0.15s ease;
      font-family: inherit;
    }

    .copy-tab-btn:hover {
      color: #f8fafc;
    }

    .copy-tab-btn.active {
      background: #2563eb;
      color: #ffffff;
      font-weight: 600;
      box-shadow: 0 2px 6px rgba(37, 99, 235, 0.35);
    }

    .copy-textarea {
      width: 100%;
      height: 220px;
      background: #020617;
      border: 1px solid rgba(255, 255, 255, 0.12);
      border-radius: 10px;
      padding: 12px 14px;
      color: #e2e8f0;
      font-family: 'Consolas', 'Courier New', monospace;
      font-size: 12.5px;
      line-height: 1.6;
      resize: vertical;
      box-sizing: border-box;
      outline: none;
      -webkit-user-select: text !important;
      user-select: text !important;
    }

    .copy-textarea:focus {
      border-color: #3b82f6;
      box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.25);
    }

    .copy-modal-notice {
      font-size: 11px;
      color: #94a3b8;
      line-height: 1.5;
      background: rgba(255, 255, 255, 0.03);
      padding: 8px 12px;
      border-radius: 8px;
      border: 1px solid rgba(255, 255, 255, 0.06);
    }

    .drm-modal-footer {
      padding: 14px 20px;
      border-top: 1px solid rgba(255, 255, 255, 0.08);
      display: flex;
      align-items: center;
      justify-content: flex-end;
      gap: 10px;
      background: rgba(255, 255, 255, 0.02);
    }

    .btn-subtle {
      background: transparent;
      border: 1px solid rgba(255, 255, 255, 0.15);
      color: #cbd5e1;
      font-size: 12px;
      font-weight: 500;
      padding: 7px 14px;
      border-radius: 8px;
      cursor: pointer;
      transition: all 0.15s ease;
      font-family: inherit;
    }

    .btn-subtle:hover {
      background: rgba(255, 255, 255, 0.08);
      color: #ffffff;
      border-color: rgba(255, 255, 255, 0.25);
    }

    .btn-primary {
      background: linear-gradient(135deg, #2563eb, #1d4ed8);
      border: 1px solid rgba(147, 197, 253, 0.4);
      color: #ffffff;
      font-size: 12px;
      font-weight: 600;
      padding: 7px 16px;
      border-radius: 8px;
      cursor: pointer;
      display: inline-flex;
      align-items: center;
      gap: 6px;
      transition: all 0.15s ease;
      font-family: inherit;
      box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
    }

    .btn-primary:hover {
      background: linear-gradient(135deg, #3b82f6, #2563eb);
      box-shadow: 0 4px 12px rgba(37, 99, 235, 0.45);
      transform: translateY(-1px);
    }

    /* Thu gọn text nút trên màn hình nhỏ */
    @media (max-width: 768px) {
      .topbar-btn .topbar-btn-text {
        display: none !important;
      }
      .topbar-btn {
        width: 32px !important;
        padding: 0 !important;
        justify-content: center !important;
      }
      .drm-modal-box {
        max-width: 95vw !important;
      }
    }

    /* =========================================================================
       UX PRO ENHANCEMENTS: RESUME BANNER, SCRUBBER, SEARCH, BOOKMARKS & THEMES
       ========================================================================= */

    /* 1. Resume Reading Banner */
    .resume-reading-banner {
      position: fixed;
      top: 62px;
      left: 50%;
      transform: translateX(-50%);
      background: rgba(15, 23, 42, 0.94);
      backdrop-filter: blur(18px);
      -webkit-backdrop-filter: blur(18px);
      border: 1px solid rgba(56, 189, 248, 0.35);
      box-shadow: 0 14px 35px rgba(0, 0, 0, 0.65), 0 0 18px rgba(56, 189, 248, 0.15);
      padding: 7px 10px 7px 16px;
      border-radius: 999px;
      z-index: 150;
      display: flex;
      align-items: center;
      gap: 10px;
      font-size: 12.5px;
      color: #e2e8f0;
      animation: popInBanner 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    }

    @keyframes popInBanner {
      from { opacity: 0; transform: translateX(-50%) translateY(-10px); }
      to { opacity: 1; transform: translateX(-50%) translateY(0); }
    }

    .resume-banner-text strong {
      color: #38bdf8;
      font-weight: 700;
    }

    .resume-banner-btn {
      background: linear-gradient(135deg, #0284c7, #0369a1);
      border: 1px solid rgba(125, 211, 252, 0.4);
      color: #ffffff;
      font-size: 11.5px;
      font-weight: 600;
      padding: 4px 12px;
      border-radius: 999px;
      cursor: pointer;
      font-family: inherit;
      transition: all 0.15s ease;
    }

    .resume-banner-btn:hover {
      background: linear-gradient(135deg, #0ea5e9, #0284c7);
      transform: scale(1.03);
    }

    .resume-banner-close {
      background: transparent;
      border: none;
      color: #94a3b8;
      cursor: pointer;
      font-size: 13px;
      padding: 2px 6px;
      border-radius: 50%;
      line-height: 1;
    }

    .resume-banner-close:hover {
      color: #ffffff;
      background: rgba(255, 255, 255, 0.1);
    }

    /* 2. Interactive Page Scrubber on Floating HUD */
    .hud-scrubber-bar {
      position: absolute;
      top: -14px;
      left: 18px;
      right: 18px;
      height: 14px;
      display: flex;
      align-items: center;
      z-index: 102;
    }

    .hud-scrubber-input {
      -webkit-appearance: none;
      appearance: none;
      width: 100%;
      height: 4px;
      background: rgba(255, 255, 255, 0.16);
      border-radius: 999px;
      outline: none;
      cursor: pointer;
      transition: height 0.15s ease, background 0.15s ease;
    }

    .hud-scrubber-bar:hover .hud-scrubber-input {
      height: 6px;
      background: rgba(255, 255, 255, 0.25);
    }

    .hud-scrubber-input::-webkit-slider-thumb {
      -webkit-appearance: none;
      appearance: none;
      width: 13px;
      height: 13px;
      border-radius: 50%;
      background: #e11d48;
      border: 2px solid #ffffff;
      box-shadow: 0 0 8px rgba(225, 29, 72, 0.8);
      cursor: grab;
      transition: transform 0.15s ease;
    }

    .hud-scrubber-input::-webkit-slider-thumb:hover {
      transform: scale(1.25);
    }

    .hud-scrubber-tooltip {
      position: absolute;
      bottom: 18px;
      left: 50%;
      transform: translateX(-50%);
      background: rgba(15, 23, 42, 0.96);
      border: 1px solid rgba(255, 255, 255, 0.18);
      color: #f8fafc;
      font-size: 11px;
      font-weight: 600;
      padding: 3px 9px;
      border-radius: 6px;
      pointer-events: none;
      opacity: 0;
      transition: opacity 0.15s ease;
      white-space: nowrap;
      box-shadow: 0 6px 16px rgba(0, 0, 0, 0.5);
    }

    .hud-scrubber-bar:hover .hud-scrubber-tooltip,
    .hud-scrubber-bar.dragging .hud-scrubber-tooltip {
      opacity: 1;
    }

    /* 3. Sidebar Header, Search & Bookmarks */
    .sidebar-panel-header {
      padding: 11px 14px 9px;
      border-bottom: 1px solid rgba(255, 255, 255, 0.07);
      font-size: 12px;
      font-weight: 700;
      color: #e2e8f0;
      display: flex;
      align-items: center;
      justify-content: space-between;
      background: rgba(0, 0, 0, 0.18);
      letter-spacing: 0.2px;
    }

    .sidebar-panel-sub {
      font-size: 10.5px;
      font-weight: 600;
      color: #38bdf8;
      background: rgba(56, 189, 248, 0.12);
      padding: 2px 7px;
      border-radius: 6px;
    }

    .sidebar-header-action {
      background: rgba(56, 189, 248, 0.14);
      border: 1px solid rgba(56, 189, 248, 0.3);
      color: #38bdf8;
      font-size: 10.5px;
      font-weight: 600;
      padding: 3px 8px;
      border-radius: 6px;
      cursor: pointer;
      font-family: inherit;
      transition: all 0.15s ease;
    }

    .sidebar-header-action:hover {
      background: rgba(56, 189, 248, 0.25);
      color: #ffffff;
    }

    .rail-badge {
      position: absolute;
      top: 4px;
      right: 4px;
      background: #f59e0b;
      color: #090b10;
      font-size: 9.5px;
      font-weight: 800;
      min-width: 15px;
      height: 15px;
      border-radius: 999px;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      padding: 0 3px;
    }

    .book-search-btn {
      background: #0284c7;
      border: 1px solid rgba(125, 211, 252, 0.3);
      color: #ffffff;
      font-size: 11.5px;
      font-weight: 600;
      padding: 0 11px;
      border-radius: 6px;
      cursor: pointer;
      font-family: inherit;
      transition: background 0.15s;
    }

    .book-search-btn:hover {
      background: #0ea5e9;
    }

    .sidebar-empty-hint {
      padding: 24px 12px;
      text-align: center;
      font-size: 12px;
      color: #94a3b8;
      line-height: 1.55;
    }

    .search-hit-item {
      display: flex;
      flex-direction: column;
      gap: 4px;
      padding: 9px 10px;
      border-radius: 7px;
      background: rgba(255, 255, 255, 0.03);
      border: 1px solid rgba(255, 255, 255, 0.06);
      cursor: pointer;
      transition: all 0.15s ease;
    }

    .search-hit-item:hover {
      background: rgba(56, 189, 248, 0.1);
      border-color: rgba(56, 189, 248, 0.3);
    }

    .search-hit-top {
      display: flex;
      align-items: center;
      justify-content: space-between;
      font-size: 11px;
      font-weight: 700;
      color: #38bdf8;
    }

    .search-hit-snippet {
      font-size: 11.5px;
      color: #cbd5e1;
      line-height: 1.45;
      display: -webkit-box;
      -webkit-line-clamp: 3;
      -webkit-box-orient: vertical;
      overflow: hidden;
      user-select: none;
    }

    .search-hit-snippet mark {
      background: rgba(245, 158, 11, 0.35);
      color: #fde68a;
      padding: 0 2px;
      border-radius: 3px;
      font-weight: 600;
    }

    .topbar-btn.bookmarked {
      background: rgba(245, 158, 11, 0.18);
      border-color: rgba(245, 158, 11, 0.45);
      color: #fbbf24;
    }

    .bookmark-del-btn {
      background: transparent;
      border: none;
      color: #64748b;
      cursor: pointer;
      padding: 2px 5px;
      border-radius: 4px;
      font-size: 12px;
    }

    .bookmark-del-btn:hover {
      color: #f87171;
      background: rgba(248, 113, 113, 0.12);
    }

    /* 4. Eye-Care Reading Themes (Sepia Warm Paper & Night Dark Mode) */
    body.theme-sepia #pdfCanvas,
    body.theme-sepia .flip-page-canvas {
      filter: sepia(0.32) contrast(0.96) brightness(0.96);
    }

    body.theme-sepia .flip-page-inner,
    body.theme-sepia .canvas-paper {
      background-color: #f4ecd8 !important;
    }

    body.theme-night #pdfCanvas,
    body.theme-night .flip-page-canvas {
      filter: invert(0.88) hue-rotate(180deg) contrast(0.92);
    }

    body.theme-night .flip-page-inner,
    body.theme-night .canvas-paper {
      background-color: #161922 !important;
    }

    /* 5. Responsive Breakpoints for Tablet / Compact Laptop Viewports */
    @media (max-width: 1180px) {
      .topbar-left .doc-title {
        max-width: 240px;
      }

      .topbar-right {
        gap: 6px;
      }
    }

    @media (max-width: 960px) {
      .topbar-left .doc-title {
        max-width: 180px;
      }

      .topbar-btn span,
      .btn-label {
        display: none;
      }

      .topbar-btn {
        padding: 0 9px;
      }

      .floating-hud {
        max-width: calc(100vw - 24px);
      }
    }


