     1. CSS VARIABLES & THEMES
     ============================================================ */
  *, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
  }

  :root {
    /* Typography */
    --font-arabic: 'Noto Naskh Arabic', 'Amiri', serif;
    --font-ui: 'Tajawal', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    /* Font Sizes - Adjustable */
    --text-scale: 1;
    --font-size-xs: calc(11px * var(--text-scale));
    --font-size-sm: calc(13px * var(--text-scale));
    --font-size-base: calc(15px * var(--text-scale));
    --font-size-lg: calc(17px * var(--text-scale));
    --font-size-xl: calc(20px * var(--text-scale));
    --font-size-2xl: calc(24px * var(--text-scale));
    --font-size-3xl: calc(28px * var(--text-scale));

    /* Layout */
    --header-height: 72px;
    --sidebar-width: 320px;
    --content-max-width: 1400px;

    /* Radii */
    --radius-xs: 4px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
    --transition-slow: 0.4s ease;

    /* Z-Index Layers */
    --z-dropdown: 100;
    --z-sticky: 200;
    --z-modal: 300;
    --z-toast: 400;
  }

  /* Dark Theme (Default) */
  [data-theme="dark"] {
    --bg-base: #06060a;
    --bg-raised: #0d0d14;
    --bg-elevated: #14141e;
    --bg-surface: #1c1c28;
    --bg-overlay: #252532;
    --bg-hover: #2d2d3d;

    --border-dim: rgba(255,255,255,0.04);
    --border-subtle: rgba(255,255,255,0.08);
    --border-default: rgba(255,255,255,0.12);
    --border-strong: rgba(255,255,255,0.20);
    --border-focus: rgba(212, 168, 83, 0.5);

    --text-primary: #fafafa;
    --text-secondary: #c8c8d0;
    --text-tertiary: #909098;
    --text-dim: #606068;
    --text-muted: #48484f;

    --accent: #d4a853;
    --accent-hover: #e6bc6a;
    --accent-dim: rgba(212, 168, 83, 0.12);
    --accent-glow: rgba(212, 168, 83, 0.25);

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.4);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.5);
    --shadow-lg: 0 12px 40px rgba(0,0,0,0.6);
    --shadow-glow: 0 0 40px rgba(212, 168, 83, 0.12);
  }

  /* Light Theme */
  [data-theme="light"] {
    --bg-base: #f8f7f4;
    --bg-raised: #ffffff;
    --bg-elevated: #ffffff;
    --bg-surface: #f0efe8;
    --bg-overlay: #e8e7e0;
    --bg-hover: #e0dfd8;

    --border-dim: rgba(0,0,0,0.04);
    --border-subtle: rgba(0,0,0,0.08);
    --border-default: rgba(0,0,0,0.12);
    --border-strong: rgba(0,0,0,0.20);
    --border-focus: rgba(180, 130, 40, 0.5);

    --text-primary: #1a1a1f;
    --text-secondary: #3d3d45;
    --text-tertiary: #6d6d78;
    --text-dim: #9d9da8;
    --text-muted: #c0c0c8;

    --accent: #b48220;
    --accent-hover: #9a6f1a;
    --accent-dim: rgba(180, 130, 32, 0.10);
    --accent-glow: rgba(180, 130, 32, 0.15);

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.10);
    --shadow-lg: 0 12px 40px rgba(0,0,0,0.12);
    --shadow-glow: 0 0 40px rgba(180, 130, 32, 0.08);
  }

  /* Semantic Colors (Both Themes) */
  :root {
    --green: #22c55e;
    --green-dim: rgba(34, 197, 94, 0.12);
    --cyan: #06b6d4;
    --cyan-dim: rgba(6, 182, 212, 0.12);
    --blue: #3b82f6;
    --blue-dim: rgba(59, 130, 246, 0.12);
    --amber: #f59e0b;
    --amber-dim: rgba(245, 158, 11, 0.12);
    --red: #ef4444;
    --red-dim: rgba(239, 68, 68, 0.12);
    --purple: #a855f7;
    --purple-dim: rgba(168, 85, 247, 0.12);

    /* Graph Node Colors */
    --node-author: #a855f7;
    --node-narrator: #06b6d4;
    --node-sahabi: #f59e0b;
    --node-prophet: #22c55e;
    --edge-line: var(--accent);
  }

  /* ============================================================
     2. BASE & RESET
     ============================================================ */
  html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }

  body {
    font-family: var(--font-ui);
    background: var(--bg-base);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    transition: background var(--transition-normal), color var(--transition-normal);
  }

  /* Scrollbar */
  ::-webkit-scrollbar { width: 8px; height: 8px; }
  ::-webkit-scrollbar-track { background: var(--bg-base); }
  ::-webkit-scrollbar-thumb {
    background: var(--bg-overlay);
    border-radius: 4px;
    border: 2px solid var(--bg-base);
  }
  ::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

  /* Selection */
  ::selection {
    background: var(--accent);
    color: var(--bg-base);
  }

  /* Focus Visible */
  :focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
  }

  /* Links */
  a {
    color: var(--accent);
    text-decoration: none;
    transition: color var(--transition-fast);
  }
  a:hover { color: var(--accent-hover); }

  /* ============================================================
     3. UTILITY CLASSES
     ============================================================ */
  .sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
  }

  .fade-in {
    animation: fadeIn var(--transition-normal) ease forwards;
  }

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

  @keyframes slideDown {
    from { opacity: 0; transform: translateY(-12px); }
    to { opacity: 1; transform: translateY(0); }
  }

  @keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
  }

  @keyframes spin {
    to { transform: rotate(360deg); }
  }

  @keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
  }

  /* ============================================================
     4. LAYOUT STRUCTURE
     ============================================================ */
  .app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
  }

  .main-layout {
    display: flex;
    flex: 1;
    max-width: var(--content-max-width);
    margin: 0 auto;
    width: 100%;
  }

  /* ============================================================
     5. HEADER
     ============================================================ */
  .header {
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
    background: var(--bg-raised);
    border-bottom: 1px solid var(--border-dim);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
  }

  .header-inner {
    max-width: var(--content-max-width);
    margin: 0 auto;
    padding: 12px 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
  }

  /* Logo */
  .logo {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-shrink: 0;
  }

  .logo-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--accent), #8b6914);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-arabic);
    font-size: 24px;
    font-weight: 700;
    color: var(--bg-base);
    box-shadow: var(--shadow-glow);
    transition: transform var(--transition-fast);
  }

  .logo-icon:hover {
    transform: scale(1.05);
  }

  .logo-text h1 {
    font-family: var(--font-arabic);
    font-size: var(--font-size-xl);
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
  }

  .logo-text span {
    font-size: var(--font-size-xs);
    color: var(--text-tertiary);
  }

  /* Header Controls */
  .header-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-right: auto;
    flex-wrap: wrap;
    flex: 1;
    justify-content: flex-end;
  }

  /* Search Box */
  .search-box {
    position: relative;
    flex: 1;
    max-width: 400px;
    min-width: 200px;
  }

  .search-box input {
    width: 100%;
    padding: 12px 48px 12px 40px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-full);
    color: var(--text-primary);
    font-family: var(--font-ui);
    font-size: var(--font-size-sm);
    outline: none;
    transition: all var(--transition-fast);
    direction: rtl;
    text-align: right;
  }

  .search-box input::placeholder {
    color: var(--text-dim);
    text-align: right;
  }

  .search-box input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
    background: var(--bg-surface);
  }

  .search-box .search-icon {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--text-dim);
    pointer-events: none;
  }

  .search-box .clear-btn {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 22px;
    height: 22px;
    background: var(--bg-overlay);
    border: none;
    border-radius: 50%;
    color: var(--text-tertiary);
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: all var(--transition-fast);
  }

  .search-box .clear-btn:hover {
    background: var(--accent);
    color: var(--bg-base);
  }

  .search-box.has-value .clear-btn {
    display: flex;
  }

  /* Buttons */
  .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border: 1px solid transparent;
    border-radius: var(--radius-full);
    font-family: var(--font-ui);
    font-size: var(--font-size-sm);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
  }

  .btn svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
  }

  .btn-primary {
    background: linear-gradient(135deg, var(--accent), #9a7020);
    color: var(--bg-base);
    box-shadow: var(--shadow-md), var(--shadow-glow);
  }

  .btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg), 0 0 50px var(--accent-glow);
  }

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

  .btn-secondary {
    background: var(--bg-elevated);
    border-color: var(--border-subtle);
    color: var(--text-secondary);
  }

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

  .btn-icon {
    padding: 10px;
    border-radius: var(--radius-md);
  }

  .btn-icon.active {
    background: var(--accent-dim);
    border-color: var(--accent);
    color: var(--accent);
  }

  /* Stats Badge */
  .stats-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-dim);
    border-radius: var(--radius-full);
    font-size: var(--font-size-xs);
    color: var(--text-tertiary);
  }

  .stats-dot {
    width: 8px;
    height: 8px;
    background: var(--text-dim);
    border-radius: 50%;
    transition: all var(--transition-fast);
  }

  .stats-dot.active {
    background: var(--green);
    box-shadow: 0 0 12px var(--green);
  }

  .stats-dot.loading {
    background: var(--amber);
    box-shadow: 0 0 12px var(--amber);
    animation: pulse 1.2s infinite;
  }

  /* ============================================================
     6. TOOLBAR
     ============================================================ */
  .toolbar {
    background: var(--bg-raised);
    border-bottom: 1px solid var(--border-dim);
    padding: 10px 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    overflow-x: auto;
  }

  .toolbar-group {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-left: 12px;
    border-left: 1px solid var(--border-dim);
  }

  .toolbar-group:first-child {
    padding-left: 0;
    border-left: none;
  }

  .toolbar-label {
    font-size: var(--font-size-xs);
    color: var(--text-dim);
    white-space: nowrap;
  }

  /* Select Dropdown */
  .select-wrapper {
    position: relative;
  }

  .select-wrapper select {
    appearance: none;
    padding: 8px 32px 8px 12px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-family: var(--font-ui);
    font-size: var(--font-size-xs);
    cursor: pointer;
    outline: none;
    transition: all var(--transition-fast);
  }

  .select-wrapper select:hover {
    border-color: var(--border-default);
  }

  .select-wrapper select:focus {
    border-color: var(--accent);
  }

  .select-wrapper::after {
    content: '';
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    border: 4px solid transparent;
    border-top-color: var(--text-dim);
    pointer-events: none;
  }

  /* Font Size Controls */
  .font-size-controls {
    display: flex;
    align-items: center;
    gap: 4px;
  }

  .font-size-controls button {
    width: 28px;
    height: 28px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    transition: all var(--transition-fast);
  }

  .font-size-controls button:hover {
    background: var(--bg-surface);
    border-color: var(--accent);
    color: var(--accent);
  }

  .font-size-controls span {
    min-width: 40px;
    text-align: center;
    font-size: var(--font-size-xs);
    color: var(--text-tertiary);
  }

  /* ============================================================
     7. SIDEBAR
     ============================================================ */
  .sidebar {
    width: var(--sidebar-width);
    min-width: 280px;
    height: calc(100vh - var(--header-height) - 52px);
    position: sticky;
    top: calc(var(--header-height) + 52px);
    background: var(--bg-raised);
    border-left: 1px solid var(--border-dim);
    display: flex;
    flex-direction: column;
    transition: transform var(--transition-normal);
  }

  .sidebar.collapsed {
    transform: translateX(100%);
    margin-right: calc(-1 * var(--sidebar-width));
  }

  .sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-dim);
    background: var(--bg-elevated);
  }

  .sidebar-header h2 {
    font-family: var(--font-arabic);
    font-size: var(--font-size-base);
    font-weight: 700;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
  }

  .sidebar-header p {
    font-size: var(--font-size-sm);
    color: var(--text-tertiary);
    line-height: 1.6;
  }

  .sidebar-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    list-style: none;
  }

  .sidebar-item {
    margin-bottom: 4px;
  }

  .sidebar-link {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 14px 16px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    text-decoration: none;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
  }

  .sidebar-link:hover {
    background: var(--bg-elevated);
    border-color: var(--border-subtle);
    color: var(--text-primary);
  }

  .sidebar-link.active {
    background: var(--accent-dim);
    border-color: var(--accent);
    color: var(--accent);
  }

  .sidebar-link-num {
    flex-shrink: 0;
    min-width: 32px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-overlay);
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: var(--text-tertiary);
  }

  .sidebar-link.active .sidebar-link-num {
    background: var(--accent);
    color: var(--bg-base);
  }

  .sidebar-link-title {
    font-family: var(--font-arabic);
    font-size: var(--font-size-base);
    font-weight: 600;
    line-height: 1.6;
    color: var(--text-primary);
  }

  .sidebar-link.active .sidebar-link-title {
    color: var(--accent);
  }

  .sidebar-link-count {
    font-family: var(--font-arabic);
    font-size: var(--font-size-sm);
    color: var(--text-tertiary);
  }

  .sidebar-link.active .sidebar-link-count {
    color: var(--accent);
    opacity: 0.8;
  }

  .sidebar-link-grade {
    flex-shrink: 0;
    font-size: 9px;
    font-weight: 700;
    padding: 3px 6px;
    border-radius: var(--radius-xs);
    background: var(--bg-overlay);
    color: var(--text-dim);
  }

  .sidebar-link-grade.grade-sahih {
    background: var(--green-dim);
    color: var(--green);
  }

  .sidebar-link-grade.grade-hasan {
    background: var(--cyan-dim);
    color: var(--cyan);
  }

  .sidebar-link-grade.grade-daeef {
    background: var(--red-dim);
    color: var(--red);
  }

  .sidebar-link-grade.grade-mawdu {
    background: var(--red-dim);
    color: var(--red);
  }

  .sidebar-link-meta {
    font-size: var(--font-size-xs);
    color: var(--text-dim);
  }

  .sidebar-link.active .sidebar-link-meta {
    color: var(--accent);
    opacity: 0.7;
  }

  /* ============================================================
     8. MAIN CONTENT
     ============================================================ */
  .content {
    flex: 1;
    padding: 24px;
    min-width: 0;
    overflow-x: hidden;
  }

  /* Empty State */
  .empty-state {
    max-width: 480px;
    margin: 80px auto;
    text-align: center;
    animation: fadeIn var(--transition-slow) ease;
  }

  .empty-icon {
    width: 100px;
    height: 100px;
    margin: 0 auto 28px;
    background: var(--accent-dim);
    border-radius: var(--radius-xl);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
  }

  .empty-icon svg {
    width: 44px;
    height: 44px;
  }

  .empty-state h2 {
    font-family: var(--font-arabic);
    font-size: var(--font-size-2xl);
    margin-bottom: 12px;
    color: var(--text-primary);
  }

  .empty-state p {
    color: var(--text-tertiary);
    font-size: var(--font-size-base);
    margin-bottom: 24px;
  }

  /* Loading State */
  .loading-state {
    max-width: 480px;
    margin: 120px auto;
    text-align: center;
    animation: fadeIn var(--transition-slow) ease;
  }

  .loading-state h2 {
    font-family: var(--font-arabic);
    font-size: var(--font-size-xl);
    color: var(--text-primary);
    margin-bottom: 12px;
  }

  .loading-state p {
    color: var(--text-tertiary);
    font-size: var(--font-size-base);
  }

  .loading-spinner {
    width: 80px;
    height: 80px;
    margin: 0 auto 32px;
  }

  .loading-spinner svg {
    width: 100%;
    height: 100%;
    animation: spin 1.2s linear infinite;
  }

  .loading-spinner svg circle {
    stroke: var(--accent);
    stroke-dasharray: 90, 150;
    stroke-dashoffset: 0;
    animation: dash 1.5s ease-in-out infinite;
  }

  @keyframes spin {
    100% { transform: rotate(360deg); }
  }

  @keyframes dash {
    0% {
      stroke-dasharray: 1, 150;
      stroke-dashoffset: 0;
    }
    50% {
      stroke-dasharray: 90, 150;
      stroke-dashoffset: -35;
    }
    100% {
      stroke-dasharray: 90, 150;
      stroke-dashoffset: -124;
    }
  }

  /* Embedded Instructions */
  .embedded-instructions {
    margin-top: 24px;
    padding: 20px 30px;
    background: var(--accent-dim);
    border: 1px solid var(--accent);
    border-radius: var(--radius-lg);
    text-align: center;
  }

  .embedded-instructions p {
    margin: 0;
    color: var(--accent);
    font-size: var(--font-size-base);
    font-weight: 500;
  }

  /* ============================================================
     9. PAGE CARD
     ============================================================ */
  .page-card {
    background: var(--bg-raised);
    border: 1px solid var(--border-dim);
    border-radius: var(--radius-xl);
    margin-bottom: 32px;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    animation: fadeIn var(--transition-normal) ease;
  }

  .page-header {
    padding: 20px 24px;
    background: linear-gradient(135deg, var(--bg-elevated), var(--bg-raised));
    border-bottom: 1px solid var(--border-dim);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
  }

  .page-header h2 {
    font-family: var(--font-arabic);
    font-size: var(--font-size-xl);
    display: flex;
    align-items: center;
    gap: 10px;
  }

  .page-header span {
    font-size: var(--font-size-sm);
    color: var(--text-tertiary);
  }

  .page-body {
    padding: 24px;
  }

  /* ============================================================
     10. HADITH CARD
     ============================================================ */
  .hadith {
    background: var(--bg-elevated);
    border: 1px solid var(--border-dim);
    border-radius: var(--radius-lg);
    margin-bottom: 24px;
    overflow: hidden;
    transition: all var(--transition-fast);
  }

  .hadith:hover {
    border-color: var(--border-subtle);
    box-shadow: var(--shadow-md);
  }

  .hadith:last-child {
    margin-bottom: 0;
  }

  /* Hadith Header */
  .hadith-header {
    padding: 16px 20px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-dim);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 14px;
  }

  .hadith-titles {
    flex: 1;
    min-width: 200px;
  }

  .hadith-kitab {
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .hadith-kitab::before {
    content: '';
    width: 4px;
    height: 4px;
    background: var(--accent);
    border-radius: 50%;
  }

  .hadith-bab {
    font-family: var(--font-arabic);
    font-size: var(--font-size-lg);
    font-weight: 700;
    color: var(--accent);
    line-height: 1.6;
  }

  .hadith-bab-secondary {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    margin-top: 4px;
  }

  .hadith-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: flex-start;
  }

  /* Badges */
  .badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--bg-overlay);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-full);
    font-size: var(--font-size-xs);
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
  }

  .badge-number {
    font-family: var(--font-mono);
    font-size: 11px;
  }

  .badge-sahih {
    background: var(--green-dim);
    border-color: var(--green);
    color: var(--green);
  }

  .badge-hasan {
    background: var(--cyan-dim);
    border-color: var(--cyan);
    color: var(--cyan);
  }

  .badge-daeef {
    background: var(--amber-dim);
    border-color: var(--amber);
    color: var(--amber);
  }

  .badge-mawdu {
    background: var(--red-dim);
    border-color: var(--red);
    color: var(--red);
  }

  .badge-munkar {
    background: var(--red-dim);
    border-color: var(--red);
    color: var(--red);
  }

  /* Hadith Actions */
  .hadith-actions {
    display: flex;
    gap: 4px;
    margin-right: 8px;
  }

  .hadith-action-btn {
    width: 32px;
    height: 32px;
    background: transparent;
    border: 1px solid var(--border-dim);
    border-radius: var(--radius-sm);
    color: var(--text-dim);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
  }

  .hadith-action-btn:hover {
    background: var(--bg-overlay);
    border-color: var(--accent);
    color: var(--accent);
  }

  .hadith-action-btn svg {
    width: 14px;
    height: 14px;
  }

  /* Hadith Body */
  .hadith-body {
    padding: 24px;
  }

  .hadith-isnad {
    font-family: var(--font-arabic);
    font-size: var(--font-size-lg);
    line-height: 2.4;
    color: var(--text-secondary);
    padding-bottom: 20px;
    margin-bottom: 20px;
    border-bottom: 1px dashed var(--border-subtle);
    white-space: pre-wrap;
  }

  .hadith-matn {
    position: relative;
    font-family: var(--font-arabic);
    font-size: var(--font-size-2xl);
    line-height: 2.4;
    font-weight: 500;
    color: var(--text-primary);
    padding-right: 24px;
    white-space: pre-wrap;
  }

  .hadith-matn::before {
    content: '';
    position: absolute;
    right: 0;
    top: 10px;
    bottom: 10px;
    width: 4px;
    background: linear-gradient(180deg, var(--accent), var(--node-author));
    border-radius: 2px;
  }

  /* ============================================================
     11. ISNAD GRAPH
     ============================================================ */
  .isnad-section {
    margin-top: 28px;
    padding-top: 24px;
    border-top: 1px solid var(--border-dim);
  }

  .isnad-toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 12px 24px;
    background: var(--accent-dim);
    border: 1px solid var(--accent);
    border-radius: var(--radius-full);
    color: var(--accent);
    font-family: var(--font-ui);
    font-size: var(--font-size-sm);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
  }

  .isnad-toggle:hover {
    background: var(--accent);
    color: var(--bg-base);
  }

  .isnad-toggle svg {
    width: 18px;
    height: 18px;
    transition: transform var(--transition-normal);
  }

  .isnad-toggle.open svg:last-child {
    transform: rotate(180deg);
  }

  .isnad-graph-wrap {
    display: none;
    margin-top: 20px;
    padding: 40px;
    background: var(--bg-base);
    border: 1px solid var(--border-dim);
    border-radius: var(--radius-lg);
    overflow-x: auto;
    position: relative;
  }

  .isnad-graph-wrap.show {
    display: block;
    animation: slideDown var(--transition-normal) ease;
    text-align: center;
  }

  /* Graph Container */
  .graph-container {
    position: relative;
    min-width: fit-content;
    padding: 20px;
    display: inline-block;
    text-align: center;
  }

  .graph-svg {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
    overflow: visible;
    z-index: 1;
  }

  .graph-svg path {
    fill: none;
    stroke: var(--accent);
    stroke-width: 2.5;
    stroke-linecap: round;
    opacity: 0.7;
    transition: all var(--transition-fast);
  }

  .graph-svg path:hover {
    stroke-width: 3.5;
    opacity: 1;
  }

  .graph-nodes {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 70px;
    z-index: 2;
    padding: 10px;
    text-align: center;
  }

  /* Graph Row */
  .graph-row {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 28px;
    flex-wrap: wrap;
  }

  /* Tahwil Marker */
  .tahwil-marker {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 8px 0;
    margin: -30px auto;
    z-index: 5;
    position: relative;
    width: 100%;
  }

  .tahwil-line {
    width: 100px;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
  }

  .tahwil-badge {
    padding: 8px 20px;
    background: var(--bg-base);
    border: 2px solid var(--accent);
    border-radius: var(--radius-full);
    font-family: var(--font-arabic);
    font-size: var(--font-size-sm);
    font-weight: 700;
    color: var(--accent);
    white-space: nowrap;
    box-shadow: var(--shadow-glow);
  }

  /* Node */
  .node {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 240px;
    flex-shrink: 0;
    text-align: center;
  }

  .node-card {
    width: 100%;
    background: var(--bg-raised);
    border: 2px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 20px 18px;
    position: relative;
    transition: all var(--transition-fast);
    cursor: default;
  }

  .node-card:hover {
    border-color: var(--accent);
    box-shadow: 0 0 30px var(--accent-dim);
    transform: translateY(-3px);
  }

  .node-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
  }

  .node-card.author::before { background: var(--node-author); }
  .node-card.narrator::before { background: var(--node-narrator); }
  .node-card.sahabi::before { background: var(--node-sahabi); }
  .node-card.prophet::before {
    background: var(--node-prophet);
  }
  .node-card.prophet {
    background: rgba(34, 197, 94, 0.08);
  }

  .node-idx {
    position: absolute;
    top: -12px;
    left: -12px;
    width: 26px;
    height: 26px;
    background: var(--bg-base);
    border: 2px solid var(--border-default);
    border-radius: 50%;
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 600;
    color: var(--text-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .node-name {
    font-family: var(--font-arabic);
    font-size: var(--font-size-lg);
    font-weight: 700;
    color: var(--text-primary);
    text-align: center;
    margin-bottom: 8px;
    line-height: 1.8;
  }

  .node-bio {
    font-size: var(--font-size-base);
    color: var(--text-tertiary);
    text-align: center;
    margin-bottom: 10px;
    line-height: 1.8;
  }

  .node-jarh {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px dashed var(--border-subtle);
    text-align: center;
  }

  .jarh-item {
    font-family: var(--font-arabic);
    font-size: var(--font-size-sm);
    color: var(--amber);
    background: var(--amber-dim);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    margin-bottom: 6px;
    line-height: 1.8;
    text-align: center;
  }

  .jarh-item:last-child {
    margin-bottom: 0;
  }

  /* Method Badge */
  .node-method {
    margin-top: 14px;
    padding: 8px 18px;
    background: var(--bg-surface);
    border: 1px solid var(--border-dim);
    border-radius: var(--radius-full);
    font-family: var(--font-arabic);
    font-size: var(--font-size-base);
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
    text-align: center;
  }

  /* ============================================================
     11.5. SIMPLE ISNAD TREE (without SVG)
     ============================================================ */
  .simple-isnad-tree-container {
    display: none;
    margin-top: 16px;
    padding: 16px;
    background: var(--bg-base);
    border: 1px solid var(--border-dim);
    border-radius: var(--radius-lg);
  }

  .simple-isnad-tree-container.show {
    display: block;
    animation: slideDown var(--transition-normal) ease;
  }

  .simple-isnad-tree {
    list-style: none;
    padding: 0;
    margin: 0 auto;
    position: relative;
    max-width: 500px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
  }

  .simple-narrator-node {
    position: relative;
    padding: 0;
    width: 100%;
    display: flex;
    justify-content: center;
  }

  .simple-narrator-node:not(:last-child)::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 2px;
    height: 8px;
    background: var(--accent);
  }

  .simple-narrator-node::before {
    display: none;
  }

  .simple-narrator-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 18px 26px;
    transition: all var(--transition-fast);
    text-align: center;
    min-width: 260px;
    max-width: 450px;
    position: relative;
    z-index: 3;
  }

  .simple-narrator-card:hover {
    border-color: var(--accent);
    box-shadow: 0 4px 16px var(--accent-dim);
  }

  .simple-narrator-name {
    font-family: var(--font-arabic);
    font-size: var(--font-size-xl);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
    line-height: 1.9;
  }

  .simple-narrator-bio {
    font-size: var(--font-size-lg);
    line-height: 1.9;
    color: var(--text-tertiary);
  }

  /* ============================================================
     12. INFO SECTIONS
     ============================================================ */
  .info-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 28px;
    padding-top: 24px;
    border-top: 1px solid var(--border-dim);
  }

  .info-box {
    background: var(--bg-base);
    border: 1px solid var(--border-dim);
    border-radius: var(--radius-md);
    padding: 18px;
    transition: all var(--transition-fast);
  }

  .info-box:hover {
    border-color: var(--border-subtle);
  }

  .info-head {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: var(--font-size-sm);
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 14px;
  }

  .info-icon {
    width: 32px;
    height: 32px;
    background: var(--accent-dim);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
  }

  .info-icon svg {
    width: 16px;
    height: 16px;
  }

  .info-content {
    font-family: var(--font-arabic);
    font-size: var(--font-size-lg);
    line-height: 2.2;
    color: var(--text-secondary);
    white-space: pre-wrap;
  }

  /* Info List */
  .info-list {
    list-style: none;
    margin: 0;
    padding: 0;
  }

  .info-list li {
    position: relative;
    padding: 14px 28px 14px 0;
    font-family: var(--font-arabic);
    font-size: var(--font-size-lg);
    color: var(--text-secondary);
    line-height: 2.2;
  }

  .info-list li:not(:last-child) {
    border-bottom: 1px dashed var(--border-dim);
  }

  .info-list li::before {
    content: '';
    position: absolute;
    right: 0;
    top: 26px;
    width: 8px;
    height: 8px;
    background: var(--accent);
    border-radius: 50%;
  }

  /* Tags */
  .tags-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }

  .tag-item {
    padding: 6px 14px;
    background: var(--bg-surface);
    border: 1px solid var(--border-dim);
    border-radius: var(--radius-full);
    font-size: var(--font-size-xs);
    color: var(--text-tertiary);
    transition: all var(--transition-fast);
    cursor: pointer;
  }

  .tag-item:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-dim);
  }

  /* ============================================================
     13. COLLAPSIBLE / JSON VIEWER
     ============================================================ */
  .collapsible {
    margin-top: 20px;
    border: 1px solid var(--border-dim);
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--bg-elevated);
  }

  .collapsible-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    background: var(--bg-surface);
    font-size: var(--font-size-sm);
    font-weight: 500;
    font-family: var(--font-mono);
    color: var(--text-dim);
    cursor: pointer;
    transition: all var(--transition-fast);
    list-style: none;
    border: none;
  }

  .collapsible-header::-webkit-details-marker {
    display: none;
  }

  .collapsible-header::before {
    content: '▶';
    font-size: 9px;
    color: var(--accent);
    transition: transform var(--transition-fast);
    flex-shrink: 0;
  }

  details[open] .collapsible-header::before {
    transform: rotate(90deg);
  }

  .collapsible-header:hover {
    background: var(--bg-overlay);
    color: var(--text-tertiary);
  }

  .collapsible-body {
    padding: 16px 18px;
    background: var(--bg-base);
    border-top: 1px solid var(--border-dim);
  }

  .code-block {
    font-family: var(--font-mono);
    font-size: 11px;
    line-height: 1.8;
    color: var(--green);
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 400px;
    overflow-y: auto;
    direction: ltr;
    text-align: left;
  }

  /* Footnotes specific styles */
  .footnotes-collapsible {
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    margin-top: 20px;
    overflow: hidden;
  }

  .footnotes-collapsible .collapsible-header {
    color: var(--accent);
    font-family: var(--font-arabic);
    font-size: var(--font-size-base);
    background: var(--bg-surface);
    font-weight: 600;
    padding: 14px 18px;
    border: none;
    border-radius: 0;
  }

  .footnotes-collapsible .collapsible-header svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
  }

  .footnotes-collapsible .collapsible-body {
    padding: 16px 18px;
    background: var(--bg-base);
    border-top: 1px solid var(--border-dim);
    margin-top: 0;
    border-radius: 0;
  }

  .footnotes-content {
    font-family: var(--font-arabic);
    font-size: var(--font-size-lg);
    line-height: 2.2;
    color: var(--text-secondary);
    white-space: pre-wrap;
  }

  /* Grade box specific styles */
  .grade-box {
    background: linear-gradient(135deg, var(--accent-dim), transparent) !important;
    border-color: var(--accent) !important;
  }

  .grade-box .info-head {
    color: var(--accent);
  }

  .grade-box .info-content {
    font-size: var(--font-size-xl);
    font-weight: 700;
    color: var(--accent);
  }

  /* Badge grade in header */
  .badge-grade {
    font-size: var(--font-size-base) !important;
    padding: 6px 16px !important;
    font-weight: 700 !important;
  }

  /* Tags at bottom of hadith */
  .hadith-tags-bottom {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-top: 20px;
    padding: 16px;
    background: var(--bg-surface);
    border: 1px solid var(--border-dim);
    border-radius: var(--radius-md);
  }

  .hadith-tags-bottom .tags-label {
    font-family: var(--font-ui);
    font-size: var(--font-size-sm);
    color: var(--text-tertiary);
    font-weight: 500;
  }

  .hadith-tags-bottom .badge {
    font-size: var(--font-size-sm);
    padding: 5px 12px;
  }

  /* ============================================================
     14. TOAST NOTIFICATIONS
     ============================================================ */
  .toast-container {
    position: fixed;
    bottom: 24px;
    left: 24px;
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  .toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    animation: slideIn var(--transition-normal) ease;
    max-width: 360px;
  }

  @keyframes slideIn {
    from { opacity: 0; transform: translateX(-20px); }
    to { opacity: 1; transform: translateX(0); }
  }

  .toast.success { border-color: var(--green); }
  .toast.error { border-color: var(--red); }
  .toast.warning { border-color: var(--amber); }

  .toast-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
  }

  .toast.success .toast-icon { color: var(--green); }
  .toast.error .toast-icon { color: var(--red); }
  .toast.warning .toast-icon { color: var(--amber); }

  .toast-message {
    flex: 1;
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
  }

  .toast-close {
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    padding: 4px;
    display: flex;
    transition: color var(--transition-fast);
  }

  .toast-close:hover {
    color: var(--text-primary);
  }

  /* ============================================================
     15. KEYBOARD SHORTCUTS MODAL
     ============================================================ */
  .modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(4px);
    z-index: var(--z-modal);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
  }

  .modal-overlay.show {
    display: flex;
    animation: fadeIn var(--transition-fast) ease;
  }

  .modal {
    background: var(--bg-raised);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    max-width: 500px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
  }

  .modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-dim);
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  .modal-header h3 {
    font-size: var(--font-size-lg);
    font-weight: 700;
  }

  .modal-close {
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
  }

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

  .modal-body {
    padding: 24px;
  }

  .shortcut-list {
    list-style: none;
  }

  .shortcut-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-dim);
  }

  .shortcut-item:last-child {
    border-bottom: none;
  }

  .shortcut-desc {
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
  }

  .shortcut-keys {
    display: flex;
    gap: 6px;
  }

  .key {
    padding: 4px 10px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-tertiary);
  }

  /* ============================================================
     16. STATISTICS PANEL
     ============================================================ */
  .stats-panel {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
    padding: 20px;
    background: var(--bg-raised);
    border: 1px solid var(--border-dim);
    border-radius: var(--radius-lg);
  }

  .stat-card {
    text-align: center;
    padding: 16px;
    background: var(--bg-elevated);
    border-radius: var(--radius-md);
  }

  .stat-value {
    font-family: var(--font-mono);
    font-size: var(--font-size-2xl);
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 4px;
  }

  .stat-label {
    font-size: var(--font-size-xs);
    color: var(--text-tertiary);
  }

  .stat-sahih .stat-value {
    color: var(--green);
  }

  .stat-hasan .stat-value {
    color: var(--cyan);
  }

  .stat-daeef .stat-value {
    color: var(--red);
  }

  /* ============================================================
     17. RESPONSIVE
     ============================================================ */
  @media (max-width: 1200px) {
    .sidebar {
      width: 280px;
      min-width: 260px;
    }
  }

  @media (max-width: 1024px) {
    .main-layout {
      flex-direction: column;
    }

    .sidebar {
      width: 100%;
      height: auto;
      max-height: 300px;
      position: static;
      border-left: none;
      border-bottom: 1px solid var(--border-dim);
    }

    .content {
      padding: 16px;
    }
  }

  @media (max-width: 768px) {
    .header-inner {
      padding: 12px 16px;
    }

    .logo {
      flex: 1;
    }

    .logo-text span {
      display: none;
    }

    .header-controls {
      width: 100%;
      justify-content: stretch;
    }

    .search-box {
      order: 3;
      flex: 1 1 100%;
      max-width: none;
      margin-top: 8px;
    }

    .toolbar {
      padding: 10px 16px;
      justify-content: center;
    }

    .toolbar-group {
      flex-wrap: wrap;
      justify-content: center;
    }

    .hadith-body {
      padding: 16px;
    }

    .hadith-matn {
      font-size: var(--font-size-xl);
    }

    .isnad-graph-wrap {
      padding: 20px;
    }

    .node {
      width: 160px;
    }

    .graph-row {
      gap: 16px;
    }
  }

  @media (max-width: 480px) {
    .btn span {
      display: none;
    }

    .btn {
      padding: 10px;
    }

    .stats-badge span:last-child {
      display: none;
    }

    .page-header {
      flex-direction: column;
      text-align: center;
    }

    .node {
      width: 140px;
    }
  }

  /* Print Styles */
  @media print {
    .header, .toolbar, .sidebar,
    .isnad-toggle, .collapsible,
    .hadith-actions, .toast-container {
      display: none !important;
    }

    body {
      background: white;
      color: black;
    }

    .content {
      padding: 0;
    }

    .hadith {
      break-inside: avoid;
      border: 1px solid #ddd;
      margin-bottom: 20px;
    }

    .hadith-matn {
      font-size: 18px;
      color: black;
    }

    .hadith-matn::before {
      background: #333;
    }
  }

  /* ============================================================
     18. PAGINATION CONTROLS
     ============================================================ */
  .pagination-container {
    background: var(--bg-raised);
    border-bottom: 1px solid var(--border-dim);
    padding: 12px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
  }

  .pagination-info {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
  }

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

  .pagination-pages {
    display: flex;
    gap: 4px;
  }

  .pagination-page {
    min-width: 36px;
    padding: 6px 12px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-size: var(--font-size-sm);
    text-align: center;
  }

  .pagination-page:hover {
    background: var(--bg-surface);
    border-color: var(--accent);
    color: var(--accent);
  }

  .pagination-page.active {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--bg-base);
    font-weight: 600;
  }

  .pagination-ellipsis {
    padding: 6px 12px;
    color: var(--text-dim);
    font-size: var(--font-size-sm);
  }

  .pagination-controls .btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
  }
