/* ==========================================================================
   NovelCraft: Professional Knowledge Graph & Genealogy Design System
   Built according to UI/UX Pro Max standards (Editorial Luxury / Classic Paper)
   WCAG 2.2 AA Compliant | Zero Raw Emojis | Vector SVGs | Responsive
   ========================================================================== */

:root {
  --nc-font-display: 'Literata', 'Noto Serif', Georgia, serif;
  --nc-font-ui: 'Be Vietnam Pro', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  
  /* Semantic Color Tokens (Warm Paper / Editorial Luxury) */
  --nc-bg-canvas: #fcfaf6;
  --nc-bg-card: #ffffff;
  --nc-bg-subtle: #f5f0e9;
  --nc-bg-header: #ece5dc;
  --nc-bg-overlay: rgba(26, 18, 15, 0.72);

  --nc-text-primary: #271c19;
  --nc-text-secondary: #5d463d;
  --nc-text-tertiary: #856f64;
  --nc-text-inverse: #fdfbf7;

  --nc-border-soft: #e5dbd2;
  --nc-border-medium: #d4c5b9;
  --nc-border-strong: #9e8275;

  /* Accent Tokens */
  --nc-primary-amber: #b45309;
  --nc-primary-amber-hover: #92400e;
  --nc-accent-jade: #047857;
  --nc-accent-jade-hover: #065f46;
  --nc-accent-blood: #b91c1c;
  --nc-accent-blue: #0369a1;
  --nc-accent-purple: #7e22ce;

  /* Focus & Elevation */
  --nc-focus-ring: 0 0 0 2px #fcfaf6, 0 0 0 4px #b45309;
  --nc-shadow-sm: 0 1px 3px rgba(39, 28, 25, 0.08);
  --nc-shadow-md: 0 4px 16px rgba(39, 28, 25, 0.12);
  --nc-shadow-lg: 0 20px 48px rgba(20, 14, 12, 0.28);
  --nc-radius-sm: 6px;
  --nc-radius-md: 10px;
  --nc-radius-lg: 14px;
  --nc-radius-full: 9999px;
  
  --nc-transition-fast: 150ms cubic-bezier(0.16, 1, 0.3, 1);
  --nc-transition-smooth: 240ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* Strict SVG Sizing Guard to prevent any vector blowup */
.nc-tree-trigger svg,
.nc-tree-modal svg,
.nc-tree-btn svg,
.nc-tree-tab svg,
.nc-path-node svg,
.nc-header-nav-pill svg,
.nc-badge svg {
  width: 16px !important;
  height: 16px !important;
  min-width: 16px !important;
  min-height: 16px !important;
  max-width: 16px !important;
  max-height: 16px !important;
  display: inline-block !important;
  vertical-align: middle !important;
  flex-shrink: 0 !important;
}

/* Floating Trigger Button */
.nc-tree-trigger {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 999999;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 22px;
  background: #1c1917;
  color: #fdfbf7;
  font-family: var(--nc-font-ui);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.2px;
  border: 1.5px solid #b45309;
  border-radius: var(--nc-radius-full);
  cursor: pointer;
  box-shadow: 0 8px 30px rgba(180, 83, 9, 0.35);
  transition: all var(--nc-transition-smooth);
  animation: ncTriggerPulse 3s infinite ease-in-out;
}

@keyframes ncTriggerPulse {
  0%, 100% {
    box-shadow: 0 8px 30px rgba(180, 83, 9, 0.35), 0 0 0 0 rgba(180, 83, 9, 0.4);
  }
  50% {
    box-shadow: 0 12px 36px rgba(180, 83, 9, 0.5), 0 0 0 8px rgba(180, 83, 9, 0);
  }
}

.nc-tree-trigger:hover {
  transform: translateY(-2px) scale(1.02);
  background: #000000;
  border-color: #d97706;
  box-shadow: 0 12px 36px rgba(180, 83, 9, 0.6);
}

.nc-tree-trigger:focus-visible {
  outline: none;
  box-shadow: var(--nc-focus-ring);
}

.nc-tree-trigger svg {
  width: 19px;
  height: 19px;
  stroke-width: 2.2;
  color: #fbbf24;
}

.nc-tree-badge {
  background: var(--nc-primary-amber);
  color: #ffffff;
  font-size: 11px;
  line-height: 1;
  padding: 3px 8px;
  border-radius: var(--nc-radius-full);
  font-weight: 700;
  min-width: 20px;
  text-align: center;
}

/* Modal Overlay */
.nc-tree-overlay {
  position: fixed;
  inset: 0;
  background: var(--nc-bg-overlay);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity var(--nc-transition-smooth);
  padding: 16px;
}

.nc-tree-overlay.is-open {
  display: flex;
  opacity: 1;
}

.nc-tree-modal {
  width: 100%;
  max-width: 1260px;
  height: 92vh;
  max-height: 900px;
  background: var(--nc-bg-canvas);
  background-image: linear-gradient(rgba(252, 250, 246, 0.94), rgba(252, 250, 246, 0.94)), url('/assets/images/maccanh-ink-backdrop.jpg');
  background-size: cover;
  background-position: center center;
  border: 1px solid var(--nc-border-medium);
  border-radius: var(--nc-radius-lg);
  box-shadow: var(--nc-shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: var(--nc-font-ui);
  color: var(--nc-text-primary);
  animation: ncTreePop var(--nc-transition-smooth);
}

@keyframes ncTreePop {
  from {
    opacity: 0;
    transform: scale(0.97) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* Header */
.nc-tree-header {
  padding: 14px 22px;
  background: var(--nc-bg-header);
  border-bottom: 1px solid var(--nc-border-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.nc-tree-title {
  font-family: var(--nc-font-display);
  font-size: 17.5px;
  font-weight: 700;
  color: var(--nc-text-primary);
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nc-tree-title svg {
  color: var(--nc-primary-amber);
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.nc-tree-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

/* Base Buttons */
.nc-tree-btn {
  padding: 7px 14px;
  font-size: 12.5px;
  font-weight: 600;
  border-radius: var(--nc-radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: all var(--nc-transition-fast);
  border: 1px solid transparent;
  background: var(--nc-bg-card);
  color: var(--nc-text-primary);
  line-height: 1.4;
  user-select: none;
}

.nc-tree-btn:focus-visible {
  outline: none;
  box-shadow: var(--nc-focus-ring);
}

.nc-tree-btn svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.nc-tree-btn-ai {
  background: var(--nc-primary-amber);
  color: #ffffff;
  box-shadow: var(--nc-shadow-sm);
}

.nc-tree-btn-ai:hover {
  background: var(--nc-primary-amber-hover);
}

.nc-tree-btn-recurrent {
  background: var(--nc-accent-jade);
  color: #ffffff;
  box-shadow: var(--nc-shadow-sm);
}

.nc-tree-btn-recurrent:hover {
  background: var(--nc-accent-jade-hover);
}

.nc-tree-btn-close {
  background: transparent;
  color: var(--nc-text-secondary);
  border: 1px solid transparent;
  padding: 6px;
  border-radius: var(--nc-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.nc-tree-btn-close:hover {
  background: var(--nc-border-soft);
  color: var(--nc-text-primary);
}

.nc-tree-btn-close svg {
  width: 18px;
  height: 18px;
}

/* Secondary Navigation & Tabs */
.nc-tree-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 22px;
  background: var(--nc-bg-subtle);
  border-bottom: 1px solid var(--nc-border-soft);
  gap: 12px;
  flex-wrap: wrap;
}

.nc-tree-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.nc-tree-tab {
  padding: 6px 13px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--nc-text-secondary);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--nc-radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: all var(--nc-transition-fast);
}

.nc-tree-tab svg {
  width: 15px;
  height: 15px;
  color: var(--nc-text-tertiary);
}

.nc-tree-tab:hover {
  background: rgba(255, 255, 255, 0.6);
  color: var(--nc-text-primary);
}

.nc-tree-tab.active {
  background: #ffffff;
  color: var(--nc-text-primary);
  border-color: var(--nc-border-medium);
  box-shadow: 0 1px 4px rgba(39, 28, 25, 0.06);
}

.nc-tree-tab.active svg {
  color: var(--nc-primary-amber);
}

.nc-tree-tab:focus-visible {
  outline: none;
  box-shadow: var(--nc-focus-ring);
}

.nc-tree-status-pills {
  display: flex;
  gap: 8px;
  align-items: center;
}

.nc-tree-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  padding: 3px 10px;
  border-radius: var(--nc-radius-full);
  font-weight: 600;
  border: 1px solid transparent;
}

.nc-tree-status-pill svg {
  width: 13px;
  height: 13px;
}

.nc-pill-green {
  color: #047857;
  background: #ecfdf5;
  border-color: #a7f3d0;
}

.nc-pill-blue {
  color: #0369a1;
  background: #f0f9ff;
  border-color: #bae6fd;
}

/* Modal Body */
.nc-tree-body {
  flex: 1;
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
}

/* ==========================================================================
   TAB 1: Interactive Force Graph
   ========================================================================== */
.nc-graph-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  background: var(--nc-bg-canvas);
  overflow: hidden;
}

.nc-graph-canvas {
  width: 100%;
  height: 100%;
  cursor: grab;
  display: block;
}

.nc-graph-canvas:active {
  cursor: grabbing;
}

.nc-graph-toolbar {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  padding: 6px 10px;
  border-radius: var(--nc-radius-md);
  box-shadow: var(--nc-shadow-sm);
  border: 1px solid var(--nc-border-soft);
}

.nc-filter-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--nc-text-secondary);
  margin-right: 4px;
}

.nc-filter-btn {
  padding: 4px 10px;
  font-size: 11.5px;
  font-weight: 600;
  border-radius: var(--nc-radius-sm);
  border: 1px solid var(--nc-border-soft);
  background: var(--nc-bg-card);
  color: var(--nc-text-secondary);
  cursor: pointer;
  transition: all var(--nc-transition-fast);
}

.nc-filter-btn.active {
  background: var(--nc-text-primary);
  color: #ffffff;
  border-color: var(--nc-text-primary);
}

.nc-filter-btn:focus-visible {
  outline: none;
  box-shadow: var(--nc-focus-ring);
}

/* Zoom & Pan Controls */
.nc-graph-controls {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 10;
  display: flex;
  gap: 4px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  padding: 4px;
  border-radius: var(--nc-radius-md);
  box-shadow: var(--nc-shadow-sm);
  border: 1px solid var(--nc-border-soft);
}

.nc-control-btn {
  width: 30px;
  height: 30px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--nc-radius-sm);
  cursor: pointer;
  color: var(--nc-text-secondary);
  font-weight: 700;
  transition: all var(--nc-transition-fast);
}

.nc-control-btn:hover {
  background: var(--nc-bg-subtle);
  color: var(--nc-text-primary);
}

.nc-control-btn:focus-visible {
  outline: none;
  box-shadow: var(--nc-focus-ring);
}

.nc-control-btn svg {
  width: 15px;
  height: 15px;
}

/* Legend */
.nc-graph-legend {
  position: absolute;
  bottom: 16px;
  left: 16px;
  z-index: 10;
  display: flex;
  gap: 12px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  padding: 7px 14px;
  border-radius: var(--nc-radius-md);
  font-size: 11.5px;
  box-shadow: var(--nc-shadow-sm);
  border: 1px solid var(--nc-border-soft);
  flex-wrap: wrap;
}

.nc-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--nc-text-secondary);
  font-weight: 500;
}

.nc-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Selected Character Sidebar */
.nc-graph-sidebar {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 320px;
  max-height: calc(100% - 32px);
  background: #ffffff;
  border: 1px solid var(--nc-border-medium);
  border-radius: var(--nc-radius-md);
  box-shadow: var(--nc-shadow-md);
  padding: 18px;
  overflow-y: auto;
  z-index: 20;
  animation: ncSlideIn 200ms cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes ncSlideIn {
  from {
    opacity: 0;
    transform: translateX(12px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.nc-node-avatar-monogram {
  width: 36px;
  height: 36px;
  border-radius: var(--nc-radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--nc-font-display);
  font-weight: 700;
  font-size: 18px;
  color: #ffffff;
  background: var(--nc-primary-amber);
  border: 2px solid #ffffff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  flex-shrink: 0;
}

.nc-inv-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: var(--nc-radius-sm);
  background: var(--nc-bg-subtle);
  border: 1px solid var(--nc-border-soft);
  color: var(--nc-text-primary);
  font-weight: 500;
}

.nc-inv-tag svg {
  width: 12px;
  height: 12px;
  color: var(--nc-primary-amber);
}

/* ==========================================================================
   TAB 2: 2-Tier Hierarchy (Bloodline Tree & Sect / Faction Hierarchy)
   ========================================================================== */
.nc-hierarchy-container {
  display: flex;
  gap: 20px;
  padding: 22px;
  overflow-y: auto;
  height: 100%;
}

.nc-tier-section {
  flex: 1;
  background: #ffffff;
  border: 1px solid var(--nc-border-soft);
  border-radius: var(--nc-radius-md);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: var(--nc-shadow-sm);
}

.nc-tier-header {
  font-family: var(--nc-font-display);
  font-size: 15px;
  font-weight: 700;
  color: var(--nc-text-primary);
  border-bottom: 2px solid var(--nc-primary-amber);
  padding-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nc-tier-title-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nc-tier-title-left svg {
  width: 18px;
  height: 18px;
  color: var(--nc-primary-amber);
}

.nc-tier-badge-label {
  font-size: 11.5px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--nc-radius-full);
}

.nc-tier-badge-amber {
  background: #fef3c7;
  color: #92400e;
}

.nc-tier-badge-blue {
  background: #e0f2fe;
  color: #0369a1;
}

.nc-rank-group {
  background: var(--nc-bg-canvas);
  border: 1px solid var(--nc-border-soft);
  border-radius: var(--nc-radius-sm);
  padding: 12px;
}

.nc-rank-title {
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.nc-rank-title svg {
  width: 14px;
  height: 14px;
}

.nc-char-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #ffffff;
  border: 1px solid var(--nc-border-soft);
  padding: 8px 12px;
  border-radius: var(--nc-radius-sm);
  margin-bottom: 6px;
  transition: all var(--nc-transition-fast);
}

.nc-char-card:last-child {
  margin-bottom: 0;
}

.nc-char-card:hover {
  border-color: var(--nc-border-medium);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

/* ==========================================================================
   TAB 3: Graph BFS Path Query Engine
   ========================================================================== */
.nc-query-box {
  padding: 24px;
  overflow-y: auto;
  height: 100%;
  max-width: 960px;
  margin: 0 auto;
  width: 100%;
}

.nc-query-controls {
  display: flex;
  gap: 16px;
  align-items: flex-end;
  background: #ffffff;
  padding: 20px 24px;
  border-radius: var(--nc-radius-md);
  border: 1px solid var(--nc-border-medium);
  box-shadow: var(--nc-shadow-sm);
  margin-bottom: 22px;
}

.nc-query-field {
  flex: 1;
}

.nc-query-label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--nc-text-secondary);
  margin-bottom: 6px;
}

.nc-query-select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--nc-border-medium);
  border-radius: var(--nc-radius-sm);
  font-family: inherit;
  font-size: 13px;
  background: var(--nc-bg-canvas);
  color: var(--nc-text-primary);
  cursor: pointer;
  transition: border-color var(--nc-transition-fast);
}

.nc-query-select:focus-visible {
  outline: none;
  box-shadow: var(--nc-focus-ring);
  border-color: var(--nc-primary-amber);
}

.nc-query-separator {
  color: var(--nc-primary-amber);
  display: flex;
  align-items: center;
  justify-content: center;
  padding-bottom: 8px;
}

.nc-query-separator svg {
  width: 22px;
  height: 22px;
}

.nc-query-result {
  background: #ffffff;
  border: 1px solid var(--nc-border-soft);
  border-radius: var(--nc-radius-md);
  padding: 22px;
  box-shadow: var(--nc-shadow-sm);
}

.nc-path-steps {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 16px 0;
  padding: 14px;
  background: var(--nc-bg-canvas);
  border: 1px solid var(--nc-border-soft);
  border-radius: var(--nc-radius-sm);
}

.nc-path-node {
  background: var(--nc-text-primary);
  color: #ffffff;
  padding: 6px 14px;
  border-radius: var(--nc-radius-sm);
  font-weight: 600;
  font-size: 12.5px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.nc-path-node svg {
  width: 14px;
  height: 14px;
}

.nc-path-edge {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 11px;
  color: var(--nc-primary-amber);
  font-weight: 700;
  padding: 0 4px;
}

/* ==========================================================================
   TAB 4: Recurrent State & 3-Line Recap
   ========================================================================== */
.nc-recurrent-view {
  padding: 24px;
  overflow-y: auto;
  height: 100%;
  max-width: 1080px;
  margin: 0 auto;
  width: 100%;
}

.nc-snapshot-card {
  background: #ffffff;
  border: 1px solid var(--nc-border-soft);
  border-radius: var(--nc-radius-md);
  padding: 18px;
  margin-bottom: 22px;
  box-shadow: var(--nc-shadow-sm);
}

.nc-snapshot-title {
  margin: 0 0 12px 0;
  font-family: var(--nc-font-display);
  color: var(--nc-text-primary);
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.nc-snapshot-title svg {
  width: 18px;
  height: 18px;
  color: var(--nc-primary-amber);
}

.nc-char-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
}

.nc-snapshot-char-card {
  border: 1px solid var(--nc-border-soft);
  padding: 12px;
  border-radius: var(--nc-radius-sm);
  background: var(--nc-bg-canvas);
}

.nc-recurrent-timeline {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.nc-chapter-recap-card {
  background: #ffffff;
  border: 1px solid var(--nc-border-soft);
  border-radius: var(--nc-radius-md);
  padding: 18px;
  box-shadow: var(--nc-shadow-sm);
}

.nc-recap-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--nc-border-soft);
}

.nc-recap-title {
  font-family: var(--nc-font-display);
  font-size: 15.5px;
  font-weight: 700;
  color: var(--nc-text-primary);
}

.nc-recap-status {
  font-size: 11px;
  padding: 3px 9px;
  border-radius: var(--nc-radius-full);
  font-weight: 700;
  letter-spacing: 0.3px;
}

.nc-recap-status-completed {
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
}

.nc-recap-status-writing {
  background: #fefce8;
  color: #854d0e;
  border: 1px solid #fef08a;
}

.nc-recap-lines {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nc-recap-line {
  font-size: 13px;
  line-height: 1.6;
  color: var(--nc-text-secondary);
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.nc-recap-bullet {
  color: var(--nc-primary-amber);
  font-weight: 700;
  margin-top: 2px;
  flex-shrink: 0;
}

/* ==========================================================================
   Accessibility & Responsive Optimizations (WCAG 2.2 AA)
   ========================================================================== */
@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;
  }
}

@media (max-width: 900px) {
  .nc-hierarchy-container {
    flex-direction: column;
  }

  .nc-query-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .nc-query-separator {
    transform: rotate(90deg);
    padding: 4px 0;
  }
}

@media (max-width: 640px) {
  .nc-tree-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .nc-tree-header-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .nc-tree-nav {
    flex-direction: column;
    align-items: flex-start;
  }

  .nc-graph-sidebar {
    width: calc(100% - 32px);
  }
}

/* ==========================================================================
   INTEGRATED WORKBENCH DOCK PANEL (B?ng Ph? H? T�ch H?p V�o B�n Vi?t)
   ========================================================================== */
.nc-tree-trigger {
  display: none !important; /* G? b? ho�n to�n n�t bong b�ng n?i g�c m�n h�nh */
}

.nc-workbench-dock {
  position: fixed;
  top: 52px;
  right: 0;
  bottom: 0;
  width: 420px;
  max-width: 90vw;
  background: var(--nf-surface);
  border-left: 1px solid var(--nf-line-strong);
  box-shadow: -8px 0 32px rgba(0, 0, 0, 0.12);
  display: flex;
  flex-direction: column;
  z-index: 99990;
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  font-family: 'Be Vietnam Pro', system-ui, sans-serif;
  color: var(--nf-ink);
}

.nc-workbench-dock.is-open {
  transform: translateX(0);
}

.nc-dock-header {
  padding: 12px 16px;
  background: var(--nf-surface-2);
  border-bottom: 1px solid var(--nf-line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.nc-dock-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nc-dock-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--nf-hover-soft);
  color: var(--nf-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.nc-dock-icon svg {
  width: 17px !important;
  height: 17px !important;
}

.nc-dock-titles {
  display: flex;
  flex-direction: column;
}

.nc-dock-novel-title {
  font-family: 'Literata', serif;
  font-size: 14.5px;
  font-weight: 700;
  color: var(--nf-ink);
}

.nc-dock-novel-sub {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--nf-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.nc-dock-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.nc-dock-btn {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  border: 1px solid var(--nf-line);
  background: var(--nf-surface);
  color: var(--nf-text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.nc-dock-btn:hover {
  background: var(--nf-hover-soft);
  color: var(--nf-primary);
  border-color: var(--nf-primary);
}

.nc-dock-btn svg {
  width: 15px !important;
  height: 15px !important;
}

.nc-dock-btn-close:hover {
  background: #fef2f2 !important;
  color: #ef4444 !important;
  border-color: #fecaca !important;
}

/* Dock Navigation Tabs */
.nc-dock-nav {
  padding: 6px 10px;
  background: var(--nf-surface);
  border-bottom: 1px solid var(--nf-line);
}

.nc-dock-tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}

.nc-dock-tabs::-webkit-scrollbar {
  display: none;
}

.nc-dock-tab {
  white-space: nowrap;
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  font-size: 11px;
  font-weight: 600;
  color: var(--nf-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.nc-dock-tab:hover {
  color: var(--nf-ink);
  background: var(--nf-surface-2);
}

.nc-dock-tab.active {
  background: var(--nf-surface-2);
  color: var(--nf-primary);
  border-color: var(--nf-line);
  font-weight: 700;
}

/* Dock Content Area */
.nc-dock-content {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  background-image: linear-gradient(rgba(255, 255, 255, 0.94), rgba(255, 255, 255, 0.94)), url('/assets/images/maccanh-ink-backdrop.jpg');
  background-size: cover;
  background-position: center center;
}

html[data-theme="dark"] .nc-dock-content {
  background-image: linear-gradient(rgba(24, 24, 27, 0.94), rgba(24, 24, 27, 0.94)), url('/assets/images/maccanh-dark-backdrop.jpg');
}

html[data-theme="paper"] .nc-dock-content {
  background-image: linear-gradient(rgba(250, 247, 242, 0.92), rgba(250, 247, 242, 0.92)), url('/assets/images/maccanh-paper-backdrop.jpg');
}

.nc-dock-hint {
  font-size: 11.5px;
  color: var(--nf-muted);
  line-height: 1.5;
  padding: 9px 12px;
  border-radius: 8px;
  background: var(--nf-surface);
  border: 1px solid var(--nf-line);
  margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}

/* Character & Addressing Cards */
.nc-dock-char-card {
  background: var(--nf-surface);
  border: 1px solid var(--nf-line);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 10px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.nc-dock-char-card:hover {
  border-color: var(--nf-primary);
  transform: translateY(-1px);
}

.nc-dock-char-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.nc-dock-char-info {
  display: flex;
  flex-direction: column;
}

.nc-dock-char-name {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--nf-ink);
}

.nc-dock-char-meta {
  font-size: 11px;
  color: var(--nf-muted);
}

.nc-dock-char-status {
  font-size: 11.5px;
  color: #b45309;
  background: var(--nf-surface-2);
  padding: 4px 8px;
  border-radius: 6px;
  margin-bottom: 8px;
}

.nc-dock-rel-item {
  background: var(--nf-surface-2);
  border-radius: 6px;
  padding: 8px 10px;
  margin-top: 6px;
  font-size: 11.5px;
  border-left: 3px solid var(--nf-primary);
}

.nc-dock-rel-item.nc-aff-hostile {
  border-left-color: #ef4444;
  background: #fef2f2;
  color: #991b1b;
}

html[data-theme="dark"] .nc-dock-rel-item.nc-aff-hostile {
  background: rgba(239, 68, 68, 0.12);
  color: #fca5a5;
}

.nc-dock-rel-item.nc-aff-friendly {
  border-left-color: #10b981;
  background: #ecfdf5;
  color: #065f46;
}

html[data-theme="dark"] .nc-dock-rel-item.nc-aff-friendly {
  background: rgba(16, 185, 129, 0.12);
  color: #6ee7b7;
}

.nc-dock-rel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.nc-dock-rel-target {
  font-weight: 700;
  font-size: 12px;
}

.nc-dock-rel-badge {
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.06);
}

.nc-call-tag {
  color: var(--nf-primary);
  font-weight: 700;
  padding: 1px 4px;
  background: var(--nf-surface);
  border-radius: 4px;
  border: 1px solid var(--nf-line);
}

.nc-attitude-warning {
  margin-top: 5px;
  font-size: 10.5px;
  color: #dc2626;
  font-weight: 600;
}

/* Toolbar Button inside Editor */
.nc-toolbar-dock-btn {
  display: inline-flex !important;
  align-items: center !important;
  gap: 6px !important;
  padding: 5px 12px !important;
  border-radius: 6px !important;
  font-size: 12px !important;
  font-weight: 700 !important;
  background: var(--nf-surface-2) !important;
  border: 1px solid var(--nf-line) !important;
  color: var(--nf-ink) !important;
  cursor: pointer !important;
  transition: all 0.2s ease !important;
}

.nc-toolbar-dock-btn:hover {
  background: var(--nf-hover-soft) !important;
  border-color: var(--nf-primary) !important;
  color: var(--nf-primary) !important;
}

.nc-toolbar-dock-btn.is-active {
  background: var(--nf-primary) !important;
  color: #ffffff !important;
  border-color: var(--nf-primary) !important;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3) !important;
}

.nc-dock-badge {
  background: var(--nf-primary);
  color: #ffffff;
  border-radius: 9999px;
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
}

.nc-toolbar-dock-btn.is-active .nc-dock-badge {
  background: #ffffff;
  color: var(--nf-primary);
}

/* Edge Tab Handle (Pinned to viewport right edge) */
.nc-dock-edge-handle {
  position: fixed;
  right: 0;
  top: 140px;
  z-index: 998;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px 8px 10px;
  background: var(--nf-surface, #ffffff);
  border: 1px solid var(--nf-line-strong, #d4c5b9);
  border-right: none;
  border-radius: 8px 0 0 8px;
  box-shadow: -4px 4px 16px rgba(0, 0, 0, 0.08);
  color: var(--nf-text, #271c19);
  font-family: var(--nc-font-ui, sans-serif);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
}

.nc-dock-edge-handle:hover {
  background: var(--nf-surface-2, #f5f0e9);
  color: var(--nf-primary, #b45309);
  box-shadow: -6px 6px 20px rgba(0, 0, 0, 0.12);
  transform: translateX(-3px);
}

.nc-dock-edge-handle.dock-active {
  right: 420px;
  background: var(--nf-primary, #b45309);
  color: #ffffff;
  border-color: var(--nf-primary, #b45309);
}

.nc-edge-icon svg {
  width: 15px !important;
  height: 15px !important;
}

.nc-edge-kbd {
  font-size: 9.5px;
  font-family: monospace;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.06);
  border: 1px solid rgba(0, 0, 0, 0.1);
  color: var(--nf-muted, #78716c);
}

.nc-dock-edge-handle.dock-active .nc-edge-kbd {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.3);
  color: #ffffff;
}
/* ==========================================================================
   MOBILE & TABLET PRO-MAX RESPONSIVE DESIGN (Tối Ưu Toàn Diện Di Động)
   ========================================================================== */
.nc-rs-mobile-toc-btn {
  display: none !important;
}

@media (max-width: 820px) {
  /* 1. Modal Overlay & Container full screen on mobile */
  .nc-tree-overlay {
    padding: 0 !important;
    align-items: stretch !important;
    justify-content: stretch !important;
    background: rgba(0, 0, 0, 0.82) !important;
  }

  .nc-tree-modal,
  #nc-bulk-modal-inner,
  .nc-reader-studio-modal {
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    border-radius: 0 !important;
    border: none !important;
  }

  /* 2. Modal Headers on Mobile */
  .nc-tree-header {
    padding: 10px 14px !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
  }

  .nc-tree-header-actions {
    width: 100% !important;
    justify-content: space-between !important;
    flex-wrap: wrap !important;
    gap: 6px !important;
  }

  /* 3. Reader Studio (Phòng Đọc & Nghe) Mobile */
  .nc-rs-mobile-toc-btn {
    display: inline-flex !important;
  }

  .nc-rs-body-split {
    grid-template-columns: 1fr !important;
    position: relative !important;
  }

  .nc-rs-toc-aside {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    bottom: 0 !important;
    width: 84% !important;
    max-width: 320px !important;
    z-index: 200 !important;
    background: var(--nf-surface) !important;
    box-shadow: 14px 0 35px rgba(0, 0, 0, 0.35) !important;
    transform: translateX(-105%) !important;
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1) !important;
  }

  .nc-rs-toc-aside.is-open {
    transform: translateX(0) !important;
  }

  .nc-rs-toc-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    z-index: 190;
    display: none;
  }

  .nc-rs-toc-backdrop.is-open {
    display: block !important;
  }

  .nc-rs-audio-bar {
    padding: 8px 12px !important;
    gap: 8px !important;
  }

  .nc-rs-audio-bar > div:first-child {
    flex-wrap: wrap !important;
    gap: 6px !important;
    width: 100% !important;
  }

  .nc-rs-audio-bar > div:first-child button {
    padding: 6px 10px !important;
    font-size: 11.5px !important;
  }

  #nc-rs-audio-status {
    width: 100% !important;
    order: 3 !important;
    font-size: 11px !important;
    text-align: left !important;
    line-height: 1.4 !important;
  }

  .nc-rs-audio-bar > div:last-child {
    width: 100% !important;
    justify-content: space-between !important;
    flex-wrap: wrap !important;
  }

  .nc-rs-audio-bar > div:last-child select {
    max-width: 170px !important;
  }

  #nc-rs-book-scroll {
    padding: 12px 10px 80px !important;
  }

  #nc-rs-book-page {
    padding: 18px 12px 36px !important;
    margin: 0 !important;
    max-width: 100% !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    background: transparent !important;
  }

  #nc-rs-chapter-content {
    font-size: 17.5px !important;
    line-height: 1.85 !important;
  }

  .nc-rs-para {
    padding: 8px 10px !important;
    margin-bottom: 12px !important;
    border-radius: 6px !important;
  }

  /* 4. Bulk Audiobook Studio Modal Mobile */
  #nc-bulk-modal-inner > div:nth-child(2) {
    padding: 14px 10px !important;
    gap: 12px !important;
  }

  #nc-bulk-modal-inner .nc-tree-header {
    padding: 12px 14px !important;
  }

  #nc-bulk-modal-inner .nc-bulk-actions,
  #nc-bulk-modal-inner select {
    width: 100% !important;
  }

  #nc-bulk-btn-start,
  #nc-bulk-btn-download-full {
    width: 100% !important;
    justify-content: center !important;
    padding: 10px 14px !important;
    font-size: 13px !important;
  }

  #nc-bulk-inline-player {
    padding: 12px 14px !important;
  }

  #nc-bulk-inline-player > div:first-child {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 8px !important;
  }

  #nc-bulk-inline-player > div:first-child > div:last-child {
    width: 100% !important;
    justify-content: space-between !important;
  }

  /* Chapter rows in bulk modal */
  [id^="nc-bulk-chap-row-"] {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 10px !important;
    padding: 12px 10px !important;
  }

  [id^="nc-bulk-chap-row-"] > div:last-child {
    width: 100% !important;
    justify-content: flex-end !important;
  }

  /* 5. Touch Friendly Controls (Minimum 38px touch targets) */
  .nc-tree-btn,
  button,
  select,
  input {
    min-height: 38px !important;
    touch-action: manipulation;
  }
}

/* Tab labels responsive */
.nc-tab-short {
  display: none !important;
}
.nc-tab-full {
  display: inline !important;
}

@media (max-width: 820px) {
  .nc-tab-full {
    display: none !important;
  }
  .nc-tab-short {
    display: inline !important;
  }

  /* 1. TOP BAR PRO-MAX MOBILE */
  .nc-top-control-bar {
    padding: 6px 10px !important;
    gap: 8px !important;
    flex-wrap: nowrap !important;
    overflow-x: hidden !important;
    width: 100vw !important;
    max-width: 100vw !important;
    box-sizing: border-box !important;
  }

  .nc-top-left {
    gap: 6px !important;
    min-width: 0 !important;
    flex: 1 1 auto !important;
    overflow: hidden !important;
  }

  .nc-brand-sub {
    display: none !important;
  }

  .nc-brand-title {
    font-size: 13px !important;
    white-space: nowrap !important;
  }

  .nc-brand-emblem-img {
    width: 22px !important;
    height: 22px !important;
  }

  .nc-top-breadcrumb-sep {
    display: none !important;
  }

  .nc-project-selector-wrapper {
    min-width: 0 !important;
    flex: 1 1 auto !important;
  }

  .nc-btn-project-dropdown {
    padding: 4px 8px !important;
    font-size: 12px !important;
    max-width: 140px !important;
    gap: 5px !important;
  }

  .nc-active-project-title {
    max-width: 105px !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    font-size: 12px !important;
  }

  /* Hide redundant quick buttons in topbar on mobile */
  .nc-btn-quick-new-novel,
  .nc-btn-quick-reader {
    display: none !important;
  }

  .nc-project-dropdown-menu {
    min-width: unset !important;
    width: calc(100vw - 20px) !important;
    max-width: 380px !important;
    left: -40px !important;
    right: auto !important;
  }

  .nc-top-actions {
    gap: 5px !important;
    flex-shrink: 0 !important;
  }

  #nc-editor-only-cluster,
  #nc-editor-only-divider {
    display: none !important;
  }

  .nc-theme-switch-group {
    padding: 2px !important;
    gap: 2px !important;
  }

  .nc-theme-btn {
    padding: 3px 5px !important;
  }

  .nc-ai-model-label {
    display: none !important;
  }

  .nc-btn-ai-status {
    padding: 4px 7px !important;
  }

  /* 2. PROJECT TABS SLEEK SCROLLABLE PILL BAR ON MOBILE */
  .nc-project-page-tabs {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    scrollbar-width: none !important;
    padding: 6px 10px !important;
    margin: 6px 0 12px !important;
    gap: 6px !important;
    width: 100vw !important;
    max-width: 100vw !important;
    box-sizing: border-box !important;
    border-radius: 0 !important;
  }

  .nc-project-page-tabs::-webkit-scrollbar {
    display: none !important;
  }

  .nc-proj-tab-btn {
    padding: 7px 12px !important;
    font-size: 12px !important;
    white-space: nowrap !important;
    flex-shrink: 0 !important;
    border-radius: 999px !important;
    gap: 5px !important;
  }

  #nc-proj-open-reader {
    margin-left: 0 !important;
  }

  /* 3. MASTER ARCHITECT PANEL ON MOBILE */
  .nc-master-architect-panel {
    padding: 10px 8px !important;
  }

  .nc-master-architect-panel > div:first-child {
    padding: 14px 12px !important;
    border-radius: 10px !important;
  }

  .nc-arch-synopsis-grid {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  .nc-arch-sub-grid {
    grid-template-columns: 1fr !important;
    gap: 8px !important;
  }

  .nc-arch-beats-grid {
    grid-template-columns: 1fr !important;
    gap: 8px !important;
  }

  .nc-arch-chap-row__header {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 6px !important;
  }
}


/* ========================================================
   PHASE 3: CHAPTER EDITOR MOBILE OPTIMIZATION (<=720px)
   ======================================================== */
@media (max-width: 720px) {
  /* 1. CHAPTER COMPASS BAR â€” Compact on mobile */
  #nc-chapter-compass-bar {
    margin: 0 0 6px 0 !important;
  }
  #nc-chapter-compass-bar > div {
    padding: 8px 10px !important;
    border-radius: 8px !important;
  }
  /* Title row: shrink */
  #nc-chapter-compass-bar > div > div:first-child {
    gap: 6px !important;
    flex-wrap: wrap !important;
  }
  #nc-chapter-compass-bar > div > div:first-child > div:first-child {
    min-width: 0 !important;
    gap: 4px !important;
  }
  /* Shrink badge font */
  #nc-chapter-compass-bar > div > div:first-child > div:first-child > span:first-child {
    font-size: 10px !important;
    padding: 1px 6px !important;
  }
  /* Shrink chapter title */
  #nc-chapter-compass-bar > div > div:first-child > div:first-child > strong {
    font-size: 11.5px !important;
    max-width: 200px !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }
  /* Hide value shift label on mobile to save space */
  #nc-chapter-compass-bar > div > div:first-child > div:first-child > span:nth-child(3) {
    display: none !important;
  }
  /* Compass action buttons: shrink */
  #nc-compass-toggle-btn {
    font-size: 10px !important;
    height: 26px !important;
    padding: 0 7px !important;
  }
  #nc-compass-write-all {
    font-size: 10px !important;
    height: 26px !important;
    padding: 0 7px !important;
  }
  /* Goal text: smaller + clamp to 2 lines */
  #nc-chapter-compass-bar > div > div:nth-child(2) {
    font-size: 11px !important;
    margin-top: 3px !important;
    line-height: 1.35 !important;
    display: -webkit-box !important;
    -webkit-line-clamp: 2 !important;
    -webkit-box-orient: vertical !important;
    overflow: hidden !important;
  }
  /* Beats drawer: 1 column on mobile */
  #nc-compass-beats-drawer {
    grid-template-columns: 1fr !important;
    gap: 6px !important;
    margin-top: 6px !important;
    padding-top: 6px !important;
  }
}



/* ========================================================
   SYSTEMIC MOBILE IA: BOTTOM NAVIGATION & BOTTOM SHEET
   ======================================================== */
@media (max-width: 820px) {
  /* 1. PROJECT OVERVIEW: NATIVE BOTTOM NAVIGATION BAR */
  #nc-project-page-tabs {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100vw !important;
    max-width: 100vw !important;
    height: 56px !important;
    z-index: 9999 !important;
    background: var(--nf-surface) !important;
    border-top: 1px solid var(--nf-line-strong) !important;
    border-radius: 0 !important;
    padding: 3px 6px calc(3px + env(safe-area-inset-bottom, 0px)) !important;
    margin: 0 !important;
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    justify-content: space-around !important;
    align-items: center !important;
    box-shadow: 0 -3px 12px rgba(15, 23, 42, 0.08) !important;
    box-sizing: border-box !important;
  }

  .nc-proj-tab-btn {
    flex: 1 1 0 !important;
    min-width: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 2px !important;
    height: 48px !important;
    padding: 4px 2px !important;
    background: transparent !important;
    border: none !important;
    border-radius: 8px !important;
    color: var(--nf-muted) !important;
    font-size: 10px !important;
    font-weight: 600 !important;
    white-space: nowrap !important;
  }

  .nc-proj-tab-btn.is-active {
    color: var(--nf-primary) !important;
    background: var(--nf-active-soft) !important;
    font-weight: 700 !important;
  }

  .nc-proj-tab-btn svg {
    width: 18px !important;
    height: 18px !important;
    flex-shrink: 0 !important;
  }

  /* Padding at bottom of #story-frame so fixed bottom nav never blocks content */
  #story-frame {
    padding-bottom: 72px !important;
  }

  /* 2. CHAPTER EDITOR: LA BÃ€N CHÆ¯Æ NG AS NATIVE BOTTOM SHEET */
  #nc-chapter-compass-bar {
    position: fixed !important;
    bottom: -120% !important;
    left: 0 !important;
    right: 0 !important;
    width: 100vw !important;
    max-width: 100vw !important;
    max-height: 82vh !important;
    z-index: 100000 !important;
    margin: 0 !important;
    padding: 14px 14px calc(14px + env(safe-area-inset-bottom, 0px)) !important;
    transition: bottom 0.28s cubic-bezier(0.16, 1, 0.3, 1) !important;
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.35) !important;
    border-radius: 18px 18px 0 0 !important;
    overflow-y: auto !important;
    background: var(--nf-surface) !important;
    box-sizing: border-box !important;
    border-top: 2px solid var(--nf-primary) !important;
  }

  #nc-chapter-compass-bar.is-sheet-open {
    bottom: 0 !important;
  }

  .nc-compass-mobile-header {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    width: 100% !important;
  }

  .nc-compass-drag-pill {
    width: 36px !important;
    height: 4px !important;
    background: var(--nf-line-strong) !important;
    border-radius: 999px !important;
    margin-bottom: 8px !important;
  }

  /* Backdrop for Chapter Compass */
  .nc-compass-backdrop {
    display: none;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    background: rgba(15, 23, 42, 0.5) !important;
    backdrop-filter: blur(2px) !important;
    z-index: 99990 !important;
  }

  .nc-compass-backdrop.is-sheet-open {
    display: block !important;
  }

  /* Floating Action Button for Chapter Compass */
  .nc-compass-fab {
    display: inline-flex !important;
    align-items: center !important;
    gap: 6px !important;
    position: fixed !important;
    bottom: 18px !important;
    right: 16px !important;
    z-index: 9990 !important;
    background: linear-gradient(135deg, #181512 0%, #292524 100%) !important;
    color: #f59e0b !important;
    border: 1px solid rgba(245, 158, 11, 0.45) !important;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35) !important;
    border-radius: 999px !important;
    padding: 8px 14px !important;
    font-size: 12px !important;
    font-weight: 700 !important;
    cursor: pointer !important;
    font-family: var(--nf-font-ui, sans-serif) !important;
    transition: transform 0.15s ease !important;
  }

  .nc-compass-fab:active {
    transform: scale(0.96) !important;
  }

  .nc-compass-fab.is-sheet-open {
    display: none !important;
  }
}

@media (min-width: 821px) {
  .nc-compass-mobile-header,
  .nc-compass-fab,
  .nc-compass-backdrop {
    display: none !important;
  }
}



/* ========================================================
   PREMIUM MOBILE READING TYPOGRAPHY (KINDLE / APPLE BOOKS STANDARD)
   ======================================================== */
@media (max-width: 820px) {
  /* 1. MANUSCRIPT & PROSE TEXT: BÃ€N Äá»ŒC & VIáº¾T TRÃŠN MOBILE */
  .wb-editor .nf-rich-editor,
  .manuscript-surface,
  .manuscript-surface [contenteditable],
  .manuscript-surface textarea,
  .manuscript-surface p,
  .paper-editor-main,
  #nc-rs-chapter-content,
  .nc-rs-para {
    font-size: 19px !important;
    line-height: 1.82 !important;
    font-family: 'Literata', 'Noto Serif', Georgia, serif !important;
    letter-spacing: 0.012em !important;
    color: var(--nf-ink) !important;
    text-rendering: optimizeLegibility !important;
    -webkit-font-smoothing: antialiased !important;
  }

  /* 2. HIDE LINE NUMBERS GUTTER ON MOBILE TO RECLAIM FULL SCREEN WIDTH */
  .wb-editor .nf-rich-editor {
    --nf-line-number-gutter: 0px !important;
    padding-left: 16px !important;
    padding-right: 16px !important;
  }

  /* Hide code line numbers on mobile novel reading */
  .nf-line-number,
  .cm-gutter-lint,
  .cm-lineNumbers,
  [class*="line-number"] {
    display: none !important;
  }

  /* 3. PARAGRAPH BREATHING & SPACING */
  .manuscript-surface p,
  .nf-rich-editor p,
  .nc-rs-para {
    margin-bottom: 1.25em !important;
    margin-top: 0 !important;
  }

  /* 4. CHAPTER HEADING STYLING */
  .manuscript-surface h1,
  .manuscript-surface h2,
  .wb-editor h1,
  .wb-editor h2,
  #nc-rs-chapter-title {
    font-size: 23px !important;
    font-weight: 800 !important;
    font-family: 'Literata', 'Noto Serif', serif !important;
    line-height: 1.4 !important;
    text-align: center !important;
    margin: 20px 0 16px !important;
    color: var(--nf-ink) !important;
  }

  /* 5. NOVEL READER STUDIO (PHÃ’NG Äá»ŒC & AUDIOBOOK) */
  #nc-rs-overlay .nc-rs-page {
    padding: 24px 18px 60px !important;
    max-width: 100% !important;
    box-shadow: none !important;
    border: none !important;
  }

  #nc-rs-chapter-content {
    font-size: 19.5px !important;
    line-height: 1.88 !important;
  }

  .nc-rs-para {
    padding: 10px 12px !important;
    margin-bottom: 14px !important;
    border-radius: 8px !important;
    transition: background 0.2s ease !important;
  }

  .nc-rs-para.is-playing {
    background: rgba(180, 83, 9, 0.12) !important;
    border-left: 3px solid #b45309 !important;
  }

  /* 6. WORD COUNT BADGE: SUBTLE & CLEAN */
  .manuscript-surface .qc-chapter-badge,
  .manuscript-surface [class*="target-badge"],
  .manuscript-surface [class*="word-count-badge"] {
    font-size: 12px !important;
    padding: 3px 10px !important;
    margin: 8px auto 18px !important;
    display: inline-block !important;
  }
}



/* ========================================================
   CRITICAL FIX: READER STUDIO & DASHBOARD FOR MOBILE (<=900px)
   ======================================================== */

/* Desktop Base for Reader Split */
.nc-reader-studio-modal {
  width: 94vw;
  max-width: 1180px;
  height: 90vh;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 12px;
}

.nc-rs-body-split {
  display: grid;
  grid-template-columns: 280px 1fr;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

#nc-rs-toc-aside {
  border-right: 1px solid var(--nf-line);
  background: var(--nf-surface-2);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* ========================================================
   MOBILE OVERRIDES (<=900px)
   ======================================================== */
@media (max-width: 900px) {
  /* 1. NOVEL READER STUDIO MODAL: 100% FULLSCREEN */
  #nc-reader-studio-overlay {
    padding: 0 !important;
  }

  .nc-tree-modal.nc-reader-studio-modal {
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    border-radius: 0 !important;
    border: none !important;
    margin: 0 !important;
  }

  /* 2. READER BODY SPLIT: 100% FULL WIDTH FOR READING (NO 2-COLUMN CRAMMING!) */
  .nc-rs-body-split {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    flex: 1 !important;
    min-height: 0 !important;
    position: relative !important;
  }

  /* Book scroll & page: full width edge-to-edge reading */
  #nc-rs-book-scroll {
    width: 100% !important;
    max-width: 100% !important;
    flex: 1 !important;
    padding: 14px 12px 70px !important;
    box-sizing: border-box !important;
  }

  #nc-rs-book-page {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 16px 10px 40px !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    background: transparent !important;
    box-sizing: border-box !important;
  }

  #nc-rs-chapter-content {
    font-size: 20px !important;
    line-height: 1.88 !important;
    font-family: 'Literata', 'Noto Serif', serif !important;
    width: 100% !important;
    word-break: break-word !important;
    overflow-wrap: break-word !important;
  }

  .nc-rs-para {
    width: 100% !important;
    box-sizing: border-box !important;
    padding: 10px 12px !important;
    margin-bottom: 16px !important;
    font-size: 20px !important;
    line-height: 1.88 !important;
  }

  /* TOC ASIDE: OFF-CANVAS DRAWER (SLIDES IN ON DEMAND) */
  #nc-rs-toc-aside {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    bottom: 0 !important;
    width: 84% !important;
    max-width: 320px !important;
    z-index: 9999 !important;
    background: var(--nf-surface) !important;
    box-shadow: 12px 0 40px rgba(0, 0, 0, 0.45) !important;
    transform: translateX(-105%) !important;
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1) !important;
    display: flex !important;
    flex-direction: column !important;
  }

  #nc-rs-toc-aside.is-open {
    transform: translateX(0) !important;
  }

  #nc-rs-toc-backdrop {
    display: none;
    position: absolute !important;
    inset: 0 !important;
    background: rgba(0, 0, 0, 0.55) !important;
    backdrop-filter: blur(3px) !important;
    z-index: 9990 !important;
  }

  #nc-rs-toc-backdrop.is-open {
    display: block !important;
  }

  /* 3. READER AUDIO CONTROL BAR ON MOBILE */
  .nc-rs-audio-bar {
    padding: 8px 10px !important;
    gap: 8px !important;
    flex-direction: column !important;
    align-items: stretch !important;
  }

  .nc-rs-audio-bar > div:first-child {
    width: 100% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 6px !important;
  }

  #nc-rs-audio-play {
    flex: 1 !important;
    height: 40px !important;
    font-size: 13.5px !important;
    justify-content: center !important;
  }

  #nc-rs-audio-prev-para,
  #nc-rs-audio-next-para,
  #nc-rs-audio-stop {
    height: 38px !important;
    padding: 0 10px !important;
    flex-shrink: 0 !important;
  }

  #nc-rs-audio-preload,
  #nc-rs-bulk-studio-btn,
  #nc-rs-audio-status {
    display: none !important;
  }

  .nc-rs-audio-bar > div:last-child {
    width: 100% !important;
    display: flex !important;
    justify-content: space-between !important;
    gap: 8px !important;
  }

  .nc-rs-audio-bar > div:last-child label {
    flex: 1 !important;
  }

  .nc-rs-audio-bar > div:last-child select {
    width: 100% !important;
    height: 34px !important;
    font-size: 11.5px !important;
  }

  /* 4. READER HEADER ON MOBILE */
  .nc-tree-header {
    padding: 8px 12px !important;
  }

  #nc-rs-novel-meta,
  #nc-rs-btn-toggle-complete,
  #nc-rs-btn-export {
    display: none !important;
  }

  #nc-rs-btn-toc-toggle {
    display: inline-flex !important;
    height: 32px !important;
    padding: 0 10px !important;
    font-size: 11.5px !important;
    font-weight: 700 !important;
  }

  /* 5. DASHBOARD PROJECT CARDS ON MOBILE */
  .app-core-dashboard {
    padding: 10px 10px 80px !important;
    max-width: 100vw !important;
    box-sizing: border-box !important;
  }

  .app-core-story-row {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 12px !important;
    padding: 16px 14px !important;
    border-radius: 12px !important;
    margin-bottom: 12px !important;
    background: var(--nf-surface) !important;
    border: 1px solid var(--nf-line) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04) !important;
  }

  .app-core-story-row__main {
    width: 100% !important;
  }

  .app-core-story-row__title {
    font-size: 17px !important;
    margin-bottom: 4px !important;
  }

  .app-core-story-row__title > span {
    white-space: normal !important;
    word-break: break-word !important;
  }

  .app-core-story-row__tasks {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 6px !important;
  }

  .app-core-story-row__action {
    width: 100% !important;
    margin-top: 6px !important;
  }

  .app-core-story-row__action button,
  .app-core-story-row__action a {
    width: 100% !important;
    height: 40px !important;
    justify-content: center !important;
    font-size: 13.5px !important;
    font-weight: 700 !important;
    border-radius: 8px !important;
  }
}



/* ==========================================================================
   COMPREHENSIVE MOBILE TOUCH & ACCESSIBILITY SCALE (<=900px)
   Eliminates all microscopic 9px-11px text and cramped touch targets.
   Standards: Apple Human Interface Guidelines & Google Material Design 3.
   ========================================================================== */

@media (max-width: 1024px) {
  /* 1. ROOT & BODY BASE SCALING (NO HORIZONTAL OVERFLOW, NO IOS AUTO-ZOOM) */
  html {
    -webkit-text-size-adjust: 100% !important;
    text-size-adjust: 100% !important;
    overflow-x: hidden !important;
    max-width: 100vw !important;
  }

  body {
    font-size: 16px !important;
    line-height: 1.55 !important;
    overflow-x: hidden !important;
    max-width: 100vw !important;
  }

  input,
  textarea,
  select {
    font-size: 16px !important;
  }

  /* 2. UNIVERSAL TOUCH TARGETS */
  button,
  .nc-tree-btn,
  .qc-toolbar-button,
  .nc-proj-tab-btn,
  select,
  input[type="text"],
  input[type="button"],
  input[type="submit"] {
    min-height: 44px !important;
    touch-action: manipulation;
  }

  /* 3. TOP CONTROL BAR (HEADER) ON MOBILE - CLEAN & NO HORIZONTAL OVERFLOW */
  .nc-top-control-bar {
    height: 52px !important;
    padding: 6px 12px !important;
    max-width: 100vw !important;
    overflow: hidden !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 8px !important;
    box-sizing: border-box !important;
  }

  .nc-top-left {
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    min-width: 0 !important;
    flex: 1 1 auto !important;
    overflow: hidden !important;
  }

  .nc-brand-lockup {
    flex-shrink: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 6px !important;
  }

  .nc-brand-emblem-img {
    width: 24px !important;
    height: 24px !important;
  }

  .nc-brand-title {
    font-size: 14.5px !important;
    font-weight: 800 !important;
    white-space: nowrap !important;
  }

  .nc-brand-sub {
    display: none !important;
  }

  .nc-top-breadcrumb-sep {
    margin: 0 2px !important;
    font-size: 12px !important;
    color: var(--nf-muted) !important;
  }

  .nc-btn-project-dropdown {
    height: 36px !important;
    padding: 4px 8px !important;
    font-size: 13px !important;
    font-weight: 700 !important;
    max-width: 125px !important;
    flex-shrink: 1 !important;
    border-radius: 8px !important;
  }

  .nc-active-project-title {
    font-size: 13px !important;
    max-width: 85px !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }

  .nc-btn-quick-reader,
  .nc-btn-quick-new-novel {
    display: none !important; /* Hide secondary top buttons on mobile to avoid overcrowding */
  }

  .nc-top-actions {
    flex-shrink: 0 !important;
    display: flex !important;
    align-items: center !important;
    gap: 4px !important;
  }

  .nc-theme-switch-group {
    display: inline-flex !important;
    gap: 2px !important;
    padding: 2px !important;
  }

  .nc-theme-btn {
    width: 32px !important;
    height: 32px !important;
    min-height: 32px !important;
    padding: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 6px !important;
  }

  .nc-theme-btn svg {
    width: 14px !important;
    height: 14px !important;
  }

  .nc-btn-ai-status {
    height: 32px !important;
    min-height: 32px !important;
    padding: 0 8px !important;
    font-size: 12px !important;
    border-radius: 6px !important;
  }

  /* 4. DASHBOARD / TỦ SÁCH ON MOBILE */
  .app-core-dashboard {
    padding: 12px 14px 100px !important;
    max-width: 100vw !important;
    overflow-x: hidden !important;
    box-sizing: border-box !important;
  }

  .app-core-section-heading h2 {
    font-size: 20px !important;
    font-weight: 800 !important;
    margin-bottom: 12px !important;
  }

  /* HERO NEXT-TASK CARD ON MOBILE */
  .app-core-next-task {
    padding: 18px 16px !important;
    border-radius: 16px !important;
    margin-bottom: 18px !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 14px !important;
    background: var(--nf-surface) !important;
    border: 1.5px solid var(--nf-line-strong) !important;
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.05) !important;
  }

  .app-core-next-task__primary h1,
  .app-core-next-task__primary h1 a {
    font-size: 21px !important;
    font-weight: 800 !important;
    line-height: 1.35 !important;
  }

  .app-core-next-task__stage {
    font-size: 14.5px !important;
    margin-top: 4px !important;
  }

  .app-core-next-task__actions {
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
    width: 100% !important;
    margin-top: 14px !important;
  }

  .app-core-next-task__actions .app-core-button--primary {
    width: 100% !important;
    min-height: 48px !important;
    justify-content: center !important;
    font-size: 15.5px !important;
    font-weight: 700 !important;
    border-radius: 10px !important;
  }

  .app-core-next-task__actions .app-core-text-link {
    width: 100% !important;
    min-height: 44px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    border-radius: 10px !important;
    background: var(--nf-surface-2) !important;
    border: 1px solid var(--nf-line) !important;
    color: var(--nf-ink) !important;
    text-decoration: none !important;
  }

  .app-core-next-task__note {
    padding: 14px 16px !important;
    border-radius: 12px !important;
    background: var(--nf-surface-2) !important;
    border: 1px solid var(--nf-line) !important;
  }

  .app-core-next-task__excerpt {
    font-size: 14.5px !important;
    line-height: 1.6 !important;
    color: var(--nf-text) !important;
  }


  .app-core-story-row {
    padding: 18px 16px !important;
    border-radius: 16px !important;
    gap: 12px !important;
    background: var(--nf-surface) !important;
    border: 1.5px solid var(--nf-line-strong) !important;
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.05) !important;
    margin-bottom: 16px !important;
    display: flex !important;
    flex-direction: column !important;
  }

  .app-core-story-row__title {
    font-size: 20px !important;
    font-weight: 800 !important;
    line-height: 1.4 !important;
  }

  .app-core-story-row__meta {
    font-size: 13.5px !important;
    line-height: 1.6 !important;
    margin-top: 4px !important;
  }

  .app-core-story-row__tasks {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
    margin-top: 6px !important;
  }

  .app-core-story-row__tasks a,
  .app-core-story-row__tasks button {
    min-height: 38px !important;
    padding: 6px 14px !important;
    font-size: 13px !important;
    font-weight: 700 !important;
    border-radius: 8px !important;
  }

  .app-core-story-row__action {
    display: flex !important;
    gap: 8px !important;
    width: 100% !important;
    margin-top: 8px !important;
  }

  .app-core-story-row__action a,
  .app-core-story-row__action button {
    flex: 1 !important;
    min-height: 44px !important;
    font-size: 14px !important;
    font-weight: 700 !important;
    border-radius: 10px !important;
    text-align: center !important;
    justify-content: center !important;
    display: inline-flex !important;
    align-items: center !important;
  }

  /* 5. CHAPTER EDITOR: TOP TOOLBAR & TITLE */
  .wb-toolbar {
    min-height: 52px !important;
    padding: 6px 10px !important;
    gap: 8px !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    justify-content: space-between !important;
    background: var(--nf-surface) !important;
    border-bottom: 1px solid var(--nf-line-strong) !important;
    box-sizing: border-box !important;
  }

  .wb-title {
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    min-width: 0 !important;
    flex: 1 1 auto !important;
    overflow: hidden !important;
  }

  .wb-title a,
  .wb-title .wb-icon-button {
    flex-shrink: 0 !important;
    width: 38px !important;
    height: 38px !important;
    min-height: 38px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 8px !important;
  }

  .wb-title input {
    font-size: 16px !important;
    font-weight: 800 !important;
    min-height: 38px !important;
    height: 38px !important;
    padding: 0 8px !important;
    border-radius: 8px !important;
    width: 100% !important;
    min-width: 0 !important;
    border: 1px solid transparent !important;
    background: transparent !important;
    text-overflow: ellipsis !important;
  }

  .wb-title input:focus {
    background: var(--nf-surface-2) !important;
    border-color: var(--nf-line-strong) !important;
  }

  /* HIDE DESKTOP-ONLY ACTION BUTTONS & STICKY BARS ON MOBILE */
  .wb-actions .wb-icon-button,
  .wb-actions select,
  .wb-actions button,
  .wb-editor-status {
    display: none !important;
  }

  .wb-actions {
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    flex: 0 0 auto !important;
    flex-wrap: nowrap !important;
    min-width: 0 !important;
  }

  .wb-save-state {
    white-space: nowrap !important;
    font-size: 12px !important;
    font-weight: 700 !important;
    padding: 4px 10px !important;
    height: 32px !important;
    min-height: 32px !important;
    border-radius: 999px !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 4px !important;
    background: var(--nf-surface-2) !important;
    border: 1px solid var(--nf-line) !important;
    color: var(--nf-muted) !important;
  }

  .wb-word-count {
    white-space: nowrap !important;
    font-size: 12px !important;
    font-weight: 700 !important;
    padding: 4px 10px !important;
    height: 32px !important;
    min-height: 32px !important;
    border-radius: 999px !important;
    display: inline-flex !important;
    align-items: center !important;
    background: var(--nf-surface-2) !important;
    border: 1px solid var(--nf-line) !important;
    color: var(--nf-muted) !important;
  }

  /* Formatting Toolbar (B, I, H2, quotes) */
  .nf-manuscript-format-toolbar {
    padding: 6px 10px !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    flex-wrap: nowrap !important;
    gap: 4px !important;
    background: var(--nf-surface-2) !important;
    border-bottom: 1px solid var(--nf-line) !important;
  }

  .nf-manuscript-format-toolbar button {
    min-height: 36px !important;
    min-width: 36px !important;
    padding: 0 8px !important;
    font-size: 14px !important;
    border-radius: 6px !important;
    flex-shrink: 0 !important;
  }

  /* 6. MANUSCRIPT PROSE SURFACE - EDGE-TO-EDGE & NO LINE NUMBERS */
  .wb-editor {
    padding: 0 !important;
  }

  .wb-editor .manuscript-surface {
    border: none !important;
    box-shadow: none !important;
    background: transparent !important;
    padding: 16px 16px 140px !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  .nf-rich-editor {
    --nf-line-number-gutter: 0px !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    max-width: 100% !important;
  }

  .nf-rich-editor [data-line-number] {
    padding-left: 0 !important;
  }

  .nf-rich-editor [data-line-number]:before {
    display: none !important;
    content: none !important;
    width: 0 !important;
  }

  .wb-editor .nf-rich-editor,
  .manuscript-surface p,
  .paper-editor-main p {
    font-size: 20px !important;
    line-height: 1.9 !important;
    font-family: 'Literata', 'Noto Serif', Georgia, serif !important;
    margin-bottom: 20px !important;
  }

  /* 7. BOTTOM NAVIGATION & SUBTABS */
  .wb-mobile-tabs {
    height: 54px !important;
    background: var(--nf-surface) !important;
    border-top: 1px solid var(--nf-line-strong) !important;
    z-index: 1000 !important;
  }

  .wb-mobile-tabs button {
    min-height: 50px !important;
    font-size: 12.5px !important;
    font-weight: 700 !important;
  }

  #nc-project-page-tabs {
    height: 60px !important;
    padding: 4px 6px calc(4px + env(safe-area-inset-bottom, 0px)) !important;
    z-index: 1000 !important;
  }

  .nc-proj-tab-btn {
    height: 52px !important;
    font-size: 12.5px !important;
    font-weight: 700 !important;
    gap: 3px !important;
  }

  .nc-proj-tab-btn svg {
    width: 20px !important;
    height: 20px !important;
  }

  /* 8. CHAPTER COMPASS FAB & NATIVE BOTTOM SHEET */
  .nc-compass-fab {
    position: fixed !important;
    bottom: 72px !important;
    right: 16px !important;
    z-index: 9999 !important;
    min-height: 44px !important;
    padding: 0 16px !important;
    font-size: 13.5px !important;
    font-weight: 800 !important;
    border-radius: 999px !important;
    background: linear-gradient(135deg, #b45309, #d97706) !important;
    color: #fff !important;
    border: none !important;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25) !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 6px !important;
    white-space: nowrap !important;
  }

  #nc-chapter-compass-bar {
    padding: 20px 18px calc(20px + env(safe-area-inset-bottom, 0px)) !important;
  }

  #nc-compass-beats-drawer,
  .nc-compass-beats-grid {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  .nc-compass-beat-card {
    padding: 14px 16px !important;
  }

  .nc-compass-beat-title {
    font-size: 15px !important;
  }

  .nc-compass-beat-desc {
    font-size: 14.5px !important;
    line-height: 1.6 !important;
    margin: 6px 0 10px !important;
  }

  .nc-compass-beat-btn {
    width: 100% !important;
    min-height: 44px !important;
    font-size: 14px !important;
    font-weight: 700 !important;
    border-radius: 8px !important;
  }

  /* 9. NOVEL READER STUDIO FULLSCREEN */
  #nc-rs-chapter-title {
    font-size: 24px !important;
    font-weight: 800 !important;
    line-height: 1.4 !important;
    margin: 20px 0 16px !important;
  }

  #nc-rs-chapter-content,
  .nc-rs-para {
    font-size: 21px !important;
    line-height: 1.95 !important;
    font-family: 'Literata', 'Noto Serif', Georgia, serif !important;
    margin-bottom: 20px !important;
  }

  #nc-rs-audio-play {
    min-height: 50px !important;
    font-size: 16px !important;
    font-weight: 800 !important;
    padding: 0 22px !important;
  }

  #nc-rs-audio-prev-para,
  #nc-rs-audio-next-para,
  #nc-rs-audio-stop {
    min-height: 44px !important;
    font-size: 13.5px !important;
    padding: 0 12px !important;
  }

  .nc-rs-audio-bar select {
    min-height: 42px !important;
    font-size: 13.5px !important;
    padding: 4px 10px !important;
  }

  /* 10. PEDIGREE & CHARACTER DOCK (THƯ VIỆN PHẢ HỆ TRÊN MOBILE) */
  #nc-workbench-dock {
    width: 100vw !important;
    max-width: 100vw !important;
    left: 0 !important;
    right: 0 !important;
    font-size: 15px !important;
  }

  #nc-workbench-dock button,
  #nc-workbench-dock .nc-btn-action,
  #nc-workbench-dock .nc-tree-btn {
    min-height: 44px !important;
    font-size: 14px !important;
    padding: 8px 14px !important;
  }

  .nc-dock-card,
  .nc-char-card,
  .nc-fact-item,
  .nc-clan-card {
    padding: 14px 16px !important;
    font-size: 14.5px !important;
    line-height: 1.55 !important;
  }

  /* 11. HIDE FLOATING WORD GOAL ON MOBILE (Already shown in topbar .wb-word-count) */
  .nc-word-goal-container,
  .nc-word-goal-badge {
    display: none !important;
  }
}

