/* ==========================================================================
   DESIGN SYSTEM & THEME TOKENS
   Vanilla CSS - Modern, Rich, High-End Aesthetic
   ========================================================================== */

:root {
  /* Color Palette - Light Mode */
  --bg-primary: #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #ffffff;
  --bg-surface-hover: #f1f5f9;
  --bg-sidebar: #0f172a;
  --bg-sidebar-hover: #1e293b;
  --bg-sidebar-active: #2563eb;
  
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --text-inverse: #ffffff;
  
  --border-light: #e2e8f0;
  --border-subtle: #cbd5e1;
  --border-focus: #3b82f6;
  
  /* Brand Accents */
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --primary-border: #bfdbfe;
  
  --accent-cyan: #06b6d4;
  --accent-indigo: #4f46e5;
  --accent-emerald: #10b981;
  --accent-emerald-light: #ecfdf5;
  --accent-emerald-border: #a7f3d0;
  
  --accent-amber: #f59e0b;
  --accent-amber-light: #fffbeb;
  --accent-amber-border: #fde68a;
  
  --accent-rose: #ef4444;
  --accent-rose-light: #fef2f2;
  --accent-rose-border: #fecaca;

  /* Elevation Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.06);

  /* Layout */
  --header-height: 72px;
  --sidebar-width: 380px;
  --content-max-width: 1300px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  
  /* Typography Scale */
  --font-base: 'Be Vietnam Pro', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-ja: 'Noto Sans JP', 'Hiragino Kaku Gothic ProN', Meiryo, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', Menlo, monospace;

  --content-font-size: 16px;
  --content-line-height: 1.8;
}

/* Dark Mode Theme Tokens */
[data-theme="dark"] {
  --bg-primary: #090d16;
  --bg-surface: #111827;
  --bg-surface-elevated: #1f2937;
  --bg-surface-hover: #263346;
  --bg-sidebar: #050811;
  --bg-sidebar-hover: #111827;
  --bg-sidebar-active: #2563eb;

  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #64748b;
  --text-inverse: #0f172a;

  --border-light: #1f2937;
  --border-subtle: #334155;
  --border-focus: #60a5fa;

  --primary: #3b82f6;
  --primary-hover: #60a5fa;
  --primary-light: rgba(59, 130, 246, 0.15);
  --primary-border: #1e3a8a;

  --accent-emerald-light: rgba(16, 185, 129, 0.15);
  --accent-emerald-border: #065f46;

  --accent-amber-light: rgba(245, 158, 11, 0.15);
  --accent-amber-border: #78350f;

  --accent-rose-light: rgba(239, 68, 68, 0.15);
  --accent-rose-border: #7f1d1d;

  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 8px -1px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 10px 20px -3px rgba(0, 0, 0, 0.6);
  --shadow-xl: 0 20px 30px -5px rgba(0, 0, 0, 0.8);
}

/* Warm Paper / Sepia Mode (Vàng Nhạt - Dịu Mắt Khi Đọc Sách Lâu) */
[data-theme="sepia"] {
  --bg-primary: #fbf7ee; /* Nền giấy ngà ấm áp */
  --bg-surface: #f4ede0; /* Mặt thẻ đọc sách tone giấy ngà cao cấp */
  --bg-surface-elevated: #ede2d1;
  --bg-surface-hover: #e6d9c4;
  --bg-sidebar: #2b231b; /* Thanh bên tone gỗ sồi sẫm ấm cúng */
  --bg-sidebar-hover: #3d3328;
  --bg-sidebar-active: #c27803;

  --text-primary: #382b1d; /* Chữ nâu đen ấm, êm dịu triệt tiêu mỏi mắt */
  --text-secondary: #5e4c36;
  --text-muted: #8e7a62;
  --text-inverse: #fbf7ee;

  --border-light: #e6d7c1;
  --border-subtle: #d3c0a6;
  --border-focus: #b45309;

  --primary: #b45309; /* Hổ phách hoàng gia */
  --primary-hover: #92400e;
  --primary-light: #fef3c7;
  --primary-border: #fcd34d;

  --accent-cyan: #0e7490;
  --accent-indigo: #4338ca;
  --accent-emerald: #059669;
  --accent-emerald-light: #ecfdf5;
  --accent-emerald-border: #a7f3d0;

  --accent-amber: #d97706;
  --accent-amber-light: #fef3c7;
  --accent-amber-border: #fde68a;

  --accent-rose: #dc2626;
  --accent-rose-light: #fee2e2;
  --accent-rose-border: #fca5a5;

  --shadow-sm: 0 1px 2px 0 rgba(70, 50, 20, 0.06);
  --shadow-md: 0 4px 6px -1px rgba(70, 50, 20, 0.08), 0 2px 4px -2px rgba(70, 50, 20, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(70, 50, 20, 0.09), 0 4px 6px -4px rgba(70, 50, 20, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(70, 50, 20, 0.12), 0 8px 10px -6px rgba(70, 50, 20, 0.06);
}

/* ==========================================================================
   RESET & BASE STYLES
   ========================================================================== */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-base);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  overflow-x: hidden;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border-subtle);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ==========================================================================
   HEADER & TOP PROGRESS BAR
   ========================================================================== */

#reading-progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 3.5px;
  background: linear-gradient(90deg, #2563eb, #06b6d4, #10b981);
  width: 0%;
  z-index: 1000;
  transition: width 0.1s linear;
}

.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background-color: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 900;
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

[data-theme="dark"] .site-header {
  background-color: rgba(17, 24, 39, 0.88);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  user-select: none;
}

.brand-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 50%, #06b6d4 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-size: 20px;
  font-weight: 800;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

.brand-info {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 800;
  line-height: 1.25;
  background: linear-gradient(120deg, var(--text-primary) 0%, var(--primary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-subtitle {
  font-size: 0.76rem;
  color: var(--text-secondary);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
}

.brand-subtitle-badge {
  background: var(--accent-rose-light);
  color: var(--accent-rose);
  border: 1px solid var(--accent-rose-border);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.68rem;
  font-weight: 700;
}

/* Header Middle: Global Search */
.header-search {
  flex: 1;
  max-width: 480px;
  margin: 0 24px;
  position: relative;
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 14px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  height: 42px;
  padding: 0 40px 0 42px;
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-light);
  background: var(--bg-surface-hover);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
  transition: all 0.2s ease;
}

.search-input:focus {
  background: var(--bg-surface);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.search-clear-btn {
  position: absolute;
  right: 12px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  display: none;
}
.search-clear-btn.active {
  display: flex;
}

/* Header Right: Controls */
.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Control Pills & Buttons */
.ctrl-btn {
  height: 38px;
  padding: 0 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.ctrl-btn:hover {
  background: var(--bg-surface-hover);
  border-color: var(--border-subtle);
  transform: translateY(-1px);
}

.ctrl-btn.active {
  background: var(--primary-light);
  border-color: var(--primary-border);
  color: var(--primary);
}

.ctrl-btn-icon {
  width: 38px;
  padding: 0;
  justify-content: center;
}

.btn-accent {
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent-indigo) 100%);
  color: #ffffff;
  border: none;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}
.btn-accent:hover {
  background: linear-gradient(135deg, var(--primary-hover) 0%, var(--accent-indigo) 100%);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

/* Translation Mode Selector Group (Verbatim vs Explanatory vs Both) */
.trans-mode-group {
  display: flex;
  background: var(--bg-surface-hover);
  padding: 3px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  gap: 2px;
}

.trans-mode-btn {
  padding: 6px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.trans-mode-btn:hover {
  color: var(--text-primary);
}

.trans-mode-btn.active {
  background: var(--bg-surface);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
  font-weight: 700;
}

/* In-column Translation Segmented Switch */
.trans-switch-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.trans-switch-group {
  display: inline-flex;
  background: var(--bg-surface-hover);
  padding: 3px;
  border-radius: 8px;
  border: 1px solid var(--border-light);
  gap: 2px;
}

.trans-switch-btn {
  padding: 4px 10px;
  font-size: 0.76rem;
  font-weight: 600;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.trans-switch-btn:hover {
  color: var(--text-primary);
}

.trans-switch-btn.active {
  background: var(--bg-surface);
  color: var(--primary);
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* Dual Mode Combined Display */
.translation-section-divider {
  margin: 32px 0 24px 0;
  padding-top: 20px;
  border-top: 2px dashed var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.translation-section-badge {
  font-size: 0.78rem;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 20px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.badge-verbatim {
  background: rgba(37, 99, 235, 0.1);
  color: #2563eb;
  border: 1px solid rgba(37, 99, 235, 0.25);
}

.badge-explanatory {
  background: rgba(16, 185, 129, 0.1);
  color: #059669;
  border: 1px solid rgba(16, 185, 129, 0.25);
}

/* View Mode Selector Group */
.view-mode-group {
  display: flex;
  background: var(--bg-surface-hover);
  padding: 3px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
}

.mode-btn {
  padding: 6px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
}

.mode-btn.active {
  background: var(--bg-surface);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

/* Theme Selector Group (Sáng / Vàng Nhạt Sepia / Tối) */
.theme-selector-group {
  display: flex;
  background: var(--bg-surface-hover);
  padding: 3px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  gap: 2px;
}

.theme-btn {
  padding: 6px 11px;
  font-size: 0.8rem;
  font-weight: 600;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 4px;
}

.theme-btn:hover {
  color: var(--text-primary);
}

.theme-btn.active {
  background: var(--bg-surface);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
  font-weight: 700;
}

/* Mobile Sidebar Toggle */
.mobile-sidebar-toggle {
  display: none;
}

/* ==========================================================================
   APP CONTAINER & LAYOUT
   ========================================================================== */

.app-container {
  display: flex;
  margin-top: var(--header-height);
  min-height: calc(100vh - var(--header-height));
  position: relative;
}

/* ==========================================================================
   SIDEBAR & TABLE OF CONTENTS
   ========================================================================== */

.sidebar {
  width: var(--sidebar-width);
  height: calc(100vh - var(--header-height));
  position: sticky;
  top: var(--header-height);
  background: var(--bg-surface);
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 800;
}

.sidebar-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sidebar-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-title {
  font-size: 0.95rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-stats {
  font-size: 0.78rem;
  font-weight: 600;
  background: var(--bg-surface-hover);
  padding: 3px 8px;
  border-radius: 20px;
  color: var(--text-muted);
}

/* Tag filter pills */
.sidebar-filters {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.sidebar-filters::-webkit-scrollbar {
  height: 4px;
}

.filter-pill {
  white-space: nowrap;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 12px;
  border: 1px solid var(--border-light);
  background: var(--bg-surface);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.filter-pill:hover {
  background: var(--bg-surface-hover);
  border-color: var(--border-subtle);
}

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

/* Sidebar Navigation Items List */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Part Group Accordion */
.part-group {
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  overflow: hidden;
  margin-bottom: 4px;
  transition: border-color 0.2s ease;
}

.part-header {
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  background: var(--bg-surface-hover);
  user-select: none;
  transition: background 0.2s ease;
}

.part-header:hover {
  background: var(--bg-surface-elevated);
}

.part-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.part-icon {
  font-size: 1.1rem;
  color: var(--primary);
}

.part-title-wrapper {
  display: flex;
  flex-direction: column;
}

.part-title-vi {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.25;
}

.part-title-ja {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-family: var(--font-ja);
}

.part-badge-count {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
  background: var(--border-light);
  color: var(--text-secondary);
}

.part-toggle-arrow {
  color: var(--text-muted);
  font-size: 0.8rem;
  transition: transform 0.25s ease;
}

.part-group.collapsed .part-toggle-arrow {
  transform: rotate(-90deg);
}

.part-items-list {
  display: flex;
  flex-direction: column;
  padding: 6px;
  gap: 4px;
  max-height: 1200px;
  transition: max-height 0.35s ease, opacity 0.25s ease;
}

.part-group.collapsed .part-items-list {
  max-height: 0;
  opacity: 0;
  padding: 0;
  overflow: hidden;
}

/* Nav Section Item */
.nav-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 0.85rem;
  line-height: 1.4;
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
  border-left: 3px solid transparent;
}

.nav-item:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 700;
  border-left-color: var(--primary);
}

.nav-item-num {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--border-light);
  color: var(--text-primary);
  flex-shrink: 0;
  margin-top: 1px;
}

.nav-item.active .nav-item-num {
  background: var(--primary);
  color: #ffffff;
}

.nav-item-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item-title-vi {
  font-weight: 600;
  color: inherit;
}

.nav-item-title-ja {
  font-size: 0.73rem;
  color: var(--text-muted);
  font-family: var(--font-ja);
}

.nav-item-indicators {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.indicator-read {
  color: var(--accent-emerald);
  font-size: 0.85rem;
  display: none;
}
.nav-item.is-read .indicator-read {
  display: inline-block;
}

.indicator-bookmark {
  color: var(--accent-amber);
  font-size: 0.85rem;
  display: none;
}
.nav-item.is-bookmarked .indicator-bookmark {
  display: inline-block;
}

/* ==========================================================================
   MAIN CONTENT AREA & READING PANE
   ========================================================================== */

.main-content {
  flex: 1;
  padding: 36px 48px;
  max-width: var(--content-max-width);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* Breadcrumb & Navigation Pill Bar */
.module-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-light);
}

.module-breadcrumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.breadcrumb-part {
  font-weight: 700;
  color: var(--primary);
}

.breadcrumb-separator {
  color: var(--text-muted);
}

.breadcrumb-page {
  background: var(--bg-surface-hover);
  border: 1px solid var(--border-light);
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-muted);
}

.module-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.action-btn {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.action-btn:hover {
  background: var(--bg-surface-hover);
  border-color: var(--border-subtle);
  color: var(--text-primary);
}

.action-btn.active {
  background: var(--accent-amber-light);
  border-color: var(--accent-amber-border);
  color: var(--accent-amber);
}

.action-btn.read-active {
  background: var(--accent-emerald-light);
  border-color: var(--accent-emerald-border);
  color: var(--accent-emerald);
}

/* Module Header Hero Card */
.module-hero-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 32px 36px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.module-hero-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 6px;
  height: 100%;
  background: linear-gradient(180deg, var(--primary) 0%, var(--accent-cyan) 100%);
}

.hero-meta-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.badge-num {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 800;
  background: var(--primary);
  color: #ffffff;
  padding: 3px 10px;
  border-radius: 6px;
  letter-spacing: 0.5px;
}

.badge-category {
  font-size: 0.78rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 6px;
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid var(--primary-border);
}

.badge-tag {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--bg-surface-hover);
  color: var(--text-secondary);
}

.hero-title-vi {
  font-size: 1.85rem;
  font-weight: 800;
  line-height: 1.35;
  color: var(--text-primary);
  margin-bottom: 10px;
}

.hero-title-ja {
  font-family: var(--font-ja);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-secondary);
  line-height: 1.45;
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px dashed var(--border-light);
}

.hero-subtitle-vi {
  font-size: 1.05rem;
  color: var(--text-secondary);
  font-weight: 500;
  line-height: 1.6;
}

/* Callout Highlights (Takeaways & Legal Notes) */
.callout-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.callout-box {
  border-radius: var(--radius-md);
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.callout-takeaway {
  background: var(--accent-emerald-light);
  border: 1px solid var(--accent-emerald-border);
  color: var(--text-primary);
}

.callout-legal {
  background: var(--accent-amber-light);
  border: 1px solid var(--accent-amber-border);
  color: var(--text-primary);
}

.callout-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.callout-takeaway .callout-header {
  color: var(--accent-emerald);
}

.callout-legal .callout-header {
  color: #b45309;
}

.callout-body {
  font-size: 0.95rem;
  line-height: 1.65;
  font-weight: 500;
}

/* ==========================================================================
   BILINGUAL CONTENT LAYOUT (DUAL-VIEW & INDEPENDENT)
   ========================================================================== */

.content-reader-container {
  display: grid;
  gap: 32px;
  transition: all 0.3s ease;
}

/* Mode: Bilingual Side-by-Side */
.view-mode-bilingual .content-reader-container {
  grid-template-columns: 1.15fr 0.85fr;
}

/* Mode: Vietnamese Only */
.view-mode-vi .content-reader-container {
  grid-template-columns: 1fr;
}
.view-mode-vi .content-column-ja {
  display: none;
}

/* Mode: Japanese Only */
.view-mode-ja .content-reader-container {
  grid-template-columns: 1fr;
}
.view-mode-ja .content-column-vi {
  display: none;
}

/* Content Columns Styling */
.content-column {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 36px 40px;
  box-shadow: var(--shadow-sm);
}

.column-header-tab {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 16px;
  margin-bottom: 24px;
  border-bottom: 2px solid var(--border-light);
}

.column-label {
  font-size: 0.85rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.75px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.column-label-vi {
  color: var(--primary);
}

.column-label-ja {
  color: #0d9488;
  font-family: var(--font-ja);
}

.column-badge {
  font-size: 0.74rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--bg-surface-hover);
  color: var(--text-muted);
}

/* Typography Inside Articles */
.article-body {
  font-size: var(--content-font-size);
  line-height: var(--content-line-height);
  color: var(--text-primary);
}

.article-body h3 {
  font-size: 1.35rem;
  font-weight: 800;
  margin: 28px 0 14px 0;
  color: var(--text-primary);
  line-height: 1.4;
  border-left: 4px solid var(--primary);
  padding-left: 14px;
}

.article-body h4 {
  font-size: 1.12rem;
  font-weight: 700;
  margin: 22px 0 10px 0;
  color: var(--text-primary);
}

.article-body p {
  margin-bottom: 16px;
  text-align: justify;
}

.article-body ul, .article-body ol {
  margin: 14px 0 20px 24px;
}

.article-body li {
  margin-bottom: 8px;
}

.article-body strong {
  color: var(--text-primary);
  font-weight: 700;
}

.article-body hr {
  border: none;
  height: 1px;
  background: var(--border-light);
  margin: 28px 0;
}

/* Article Table Styles */
.article-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 20px 0;
  font-size: 0.92rem;
}

.article-body th {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
  font-weight: 700;
  padding: 12px 14px;
  border: 1px solid var(--border-light);
  text-align: left;
}

.article-body td {
  padding: 12px 14px;
  border: 1px solid var(--border-light);
  vertical-align: top;
}

.article-body tr:nth-child(even) td {
  background: var(--bg-surface-hover);
}

/* Code Blocks & ASCII Schematics */
.article-body pre {
  background: #0f172a;
  color: #e2e8f0;
  padding: 18px 20px;
  border-radius: var(--radius-md);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.5;
  margin: 20px 0;
}

[data-theme="dark"] .article-body pre {
  background: #030712;
  border: 1px solid #1f2937;
}

/* Japanese Article Specific */
.content-column-ja .article-body {
  font-family: var(--font-ja);
  font-size: calc(var(--content-font-size) * 0.96);
  line-height: 1.95;
  letter-spacing: 0.3px;
}

/* ==========================================================================
   ORIGINAL DIAGRAM VIEWER & LIGHTBOX
   ========================================================================== */

.diagrams-section {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 28px 36px;
  box-shadow: var(--shadow-sm);
}

.diagrams-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.diagrams-title {
  font-size: 1.15rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}

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

.diagram-card {
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-surface-hover);
  cursor: pointer;
  transition: all 0.25s ease;
  position: relative;
  group: true;
}

.diagram-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary-border);
}

.diagram-img-wrapper {
  height: 280px;
  overflow: hidden;
  position: relative;
  background: #f1f5f9;
}

.diagram-thumbnail {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  transition: transform 0.3s ease;
}

.diagram-card:hover .diagram-thumbnail {
  transform: scale(1.03);
}

.diagram-zoom-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s ease;
  color: #ffffff;
  font-weight: 700;
  gap: 8px;
}

.diagram-card:hover .diagram-zoom-overlay {
  opacity: 1;
}

.diagram-caption {
  padding: 12px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Lightbox Modal */
.lightbox-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.92);
  backdrop-filter: blur(10px);
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 30px;
  animation: fadeIn 0.2s ease;
}

.lightbox-modal.active {
  display: flex;
}

.lightbox-container {
  max-width: 95vw;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--border-light);
}

.lightbox-toolbar {
  height: 52px;
  padding: 0 20px;
  background: var(--bg-surface-hover);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.lightbox-title {
  font-weight: 700;
  font-size: 0.95rem;
}

.lightbox-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.lightbox-img-area {
  flex: 1;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: #0b0f19;
}

.lightbox-img {
  max-width: 100%;
  max-height: 80vh;
  object-fit: contain;
  transition: transform 0.2s ease;
}

/* ==========================================================================
   FOOTER NAVIGATION BAR
   ========================================================================== */

.module-nav-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  padding-top: 24px;
  border-top: 1px solid var(--border-light);
}

.nav-arrow-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 22px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  background: var(--bg-surface);
  color: var(--text-primary);
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.nav-arrow-btn:hover {
  background: var(--bg-surface-hover);
  border-color: var(--primary-border);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.nav-arrow-info {
  display: flex;
  flex-direction: column;
}

.nav-arrow-hint {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
}

.nav-arrow-title {
  font-size: 0.92rem;
  font-weight: 700;
}

/* ==========================================================================
   INTERACTIVE TOOLS MODALS
   (Compliance Checker, Glossary, Template Generator, Bookmarks)
   ========================================================================== */

.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(8px);
  z-index: 1500;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeIn 0.2s ease;
}

.modal-backdrop.active {
  display: flex;
}

.modal-card {
  width: 100%;
  max-width: 820px;
  max-height: 88vh;
  background: var(--bg-surface);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-xl);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-header {
  padding: 22px 28px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-surface-hover);
}

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

.modal-icon-badge {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-primary);
}

.modal-desc {
  font-size: 0.84rem;
  color: var(--text-secondary);
}

.modal-close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.4rem;
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}
.modal-close-btn:hover {
  background: var(--border-light);
  color: var(--text-primary);
}

.modal-body {
  padding: 28px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 16px 28px;
  border-top: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  background: var(--bg-surface-hover);
}

/* Compliance Checker Interactive Elements */
.checker-question-card {
  background: var(--bg-surface-hover);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 20px;
  margin-bottom: 16px;
}

.question-text {
  font-size: 0.98rem;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--text-primary);
}

.options-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.option-label {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.15s ease;
}

.option-label:hover {
  border-color: var(--primary-border);
}

.option-label input[type="radio"],
.option-label input[type="checkbox"] {
  accent-color: var(--primary);
  width: 18px;
  height: 18px;
}

.checker-result-box {
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-top: 20px;
  display: none;
}
.checker-result-box.active {
  display: block;
}

/* Glossary Search & Grid */
.glossary-search-bar {
  margin-bottom: 20px;
  position: relative;
}

.glossary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.glossary-item-card {
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 18px;
  background: var(--bg-surface);
  transition: all 0.2s ease;
}

.glossary-item-card:hover {
  border-color: var(--primary-border);
  box-shadow: var(--shadow-sm);
}

.glossary-term-ja {
  font-family: var(--font-ja);
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 2px;
}

.glossary-term-romaji {
  font-size: 0.76rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  margin-bottom: 6px;
}

.glossary-term-vi {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-light);
}

.glossary-definition {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.55;
}

/* Template Copy Area */
.template-input-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

.template-field-label {
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 6px;
  display: block;
}

.template-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
}

.template-preview-box {
  background: var(--bg-surface-hover);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 20px;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.6;
  max-height: 380px;
  overflow-y: auto;
  white-space: pre-wrap;
}

/* ==========================================================================
   ANIMATIONS & KEYFRAMES
   ========================================================================== */

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

@keyframes slideUp {
  from { transform: translateY(24px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ==========================================================================
   RESPONSIVE DESIGN (TABLET & MOBILE)
   ========================================================================== */

@media (max-width: 1024px) {
  :root {
    --sidebar-width: 320px;
  }
  .main-content {
    padding: 24px;
  }
  .callout-grid {
    grid-template-columns: 1fr;
  }
  .view-mode-bilingual .content-reader-container {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .site-header {
    padding: 0 16px;
  }
  .brand-subtitle {
    display: none;
  }
  .header-search {
    display: none;
  }
  .mobile-sidebar-toggle {
    display: flex;
  }
  .sidebar {
    position: fixed;
    top: var(--header-height);
    left: -100%;
    width: 85%;
    max-width: 340px;
    height: calc(100vh - var(--header-height));
    box-shadow: var(--shadow-xl);
  }
  .sidebar.mobile-open {
    left: 0;
  }
  .main-content {
    padding: 20px 16px;
  }
  .hero-title-vi {
    font-size: 1.45rem;
  }
  .content-column {
    padding: 24px 20px;
  }
  .module-nav-footer {
    flex-direction: column;
    gap: 12px;
  }
  .nav-arrow-btn {
    width: 100%;
  }
}
