    /* ===== ROOT ===== */
    * {
      margin: 0;
      padding: 0;
      box-sizing: border-box;
    }

    :root {

      --white: #fff;
      --primary: #0a1e3d;
      --secondary: #1d5b85;
      --orange: #e67e22;
      --dark: #1a252f;
      --light: #ecf0f1;
      --success: #2ecc71;
      --danger: #e74c3c;
      --gray: #7f8c8d;
      --white: #fff;
      --shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
      --primary-light: #1e4a7a;
      --primary-gradient: linear-gradient(145deg, #0a1e3d, #2a6a9a);
      --accent: #f5b342;
      --bg-body: #f0f4fa;
      --bg-card: #ffffff;
      --text-primary: #0a1e3d;
      --text-secondary: #3a4e6b;
      --text-muted: #6a7e9a;
      --border-light: rgba(10, 30, 61, 0.06);
      --shadow-sm: 0 4px 20px rgba(10, 30, 61, 0.04);
      --shadow-md: 0 12px 40px rgba(10, 30, 61, 0.06);
      --shadow-lg: 0 24px 60px rgba(10, 30, 61, 0.08);
      --shadow-xl: 0 32px 80px rgba(10, 30, 61, 0.12);
      --radius: 20px;
      --radius-sm: 12px;
      --transition: all 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94);
      --font: 'Cairo', sans-serif;
    }

    body {
      font-family: var(--font);
      background: var(--bg-body);
      color: var(--text-primary);
      line-height: 1.7;
      transition: background 0.4s, color 0.4s;
    }

    body.night-mode {
      --bg-body: #0d1421;
      --bg-card: #162035;
      --text-primary: #e8edf5;
      --text-secondary: #a0b3cc;
      --text-muted: #6a7e9a;
      --border-light: rgba(255, 255, 255, 0.06);
    }

    /* الوضع الليلي للقارئ فقط */
    .reader-night-mode {
      --bg-body: #0d1421;
      --bg-card: #162035;
      --text-primary: #e8edf5;
      --text-secondary: #a0b3cc;
      --text-muted: #6a7e9a;
      --border-light: rgba(255, 255, 255, 0.04);
    }

    .reader-night-mode .reader-content,
    .reader-night-mode .reader-toolbar,
    .reader-night-mode .reader-nav button,
    .reader-night-mode .reader-progress {
      background: #162035;
      color: #e8edf5;
      border-color: rgba(255, 255, 255, 0.05);
    }

    .reader-night-mode .reader-toolbar button {
      background: #1a2332;
      color: #a0b3cc;
      border-color: rgba(255, 255, 255, 0.05);
    }

    .reader-night-mode .reader-toolbar button:hover {
      background: var(--primary-gradient);
      color: white;
    }

    .reader-night-mode .reader-content {
      background: #162035;
      color: #e8edf5;
    }

    ::-webkit-scrollbar {
      width: 5px;
    }

    ::-webkit-scrollbar-track {
      background: transparent;
    }

    ::-webkit-scrollbar-thumb {
      background: var(--primary-light);
      border-radius: 10px;
    }


    .btn-outline {
      background: transparent;
      border: 1.5px solid var(--accent);
      padding: 0.3rem 1.2rem;
      border-radius: 50px;
      font-weight: 600;
      color: var(--accent);
      transition: var(--transition);
      cursor: pointer;
      font-size: 0.82rem;
    }

    .btn-outline:hover {
      background: var(--accent);
      color: var(--primary);
      box-shadow: 0 6px 20px rgba(245, 179, 66, 0.25);
    }

    .btn-primary {
      background: var(--primary-gradient);
      border: none;
      padding: 0.45rem 1.8rem;
      border-radius: 50px;
      color: white;
      font-weight: 600;
      font-size: 0.88rem;
      transition: var(--transition);
      cursor: pointer;
      box-shadow: 0 4px 16px rgba(10, 30, 61, 0.15);
    }

    .btn-primary:hover {
      transform: translateY(-2px);
      box-shadow: 0 8px 28px rgba(10, 30, 61, 0.25);
    }

    .btn-primary-sm {
      padding: 0.25rem 1.2rem;
      font-size: 0.75rem;
    }

    .container {
      max-width: 1440px;
      margin: 0 auto;
      padding: 0 2.5rem;
    }

    /* ===== HERO SEARCH ===== */
    .hero-search {
      background: var(--primary-gradient);
      padding: 3rem 3rem;
      border-radius: var(--radius);
      margin: 2rem 0 3rem;
      box-shadow: var(--shadow-xl);
      color: white;
      position: relative;
      overflow: hidden;
    }

    .hero-search::before {
      content: '';
      position: absolute;
      top: -40%;
      right: -10%;
      width: 60%;
      height: 200%;
      background: radial-gradient(circle at 30% 50%, rgba(255, 255, 255, 0.06) 0%, transparent 70%);
      pointer-events: none;
    }

    .hero-search h1 {
      font-size: 2rem;
      font-weight: 800;
      margin-bottom: 0.8rem;
    }

    .hero-search h1 i {
      margin-left: 10px;
      opacity: 0.8;
    }

    .search-wrapper {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      background: white;
      border-radius: 60px;
      padding: 0.2rem 0.2rem 0.2rem 1.8rem;
      box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
      position: relative;
      z-index: 2;
    }

    .search-wrapper input {
      flex: 1;
      border: none;
      outline: none;
      padding: 0.9rem 0.5rem;
      font-size: 1rem;
      background: transparent;
      min-width: 160px;
      font-family: var(--font);
      color: #000000 !important;
    }

    .search-wrapper input::placeholder {
      color: #666;
    }

    .search-wrapper .search-actions {
      display: flex;
      align-items: center;
      gap: 0.5rem;
    }

    .search-wrapper .mini-search-input {
      display: none;
      padding: 0.4rem 0.8rem;
      border: 1px solid var(--border-light);
      border-radius: 30px;
      font-family: var(--font);
      font-size: 0.85rem;
      background: var(--bg-body);
      color: var(--text-primary);
      width: 150px;
    }

    .search-wrapper .mini-search-input.active {
      display: block;
    }

    .search-wrapper button {
      background: var(--primary-gradient);
      border: none;
      color: white;
      padding: 0.65rem 2.2rem;
      border-radius: 60px;
      font-weight: 600;
      display: flex;
      align-items: center;
      gap: 10px;
      transition: var(--transition);
      cursor: pointer;
      font-family: var(--font);
    }

    .search-wrapper button:hover {
      transform: scale(1.02);
      box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    }

    .search-suggestions {
      display: flex;
      gap: 0.5rem;
      flex-wrap: wrap;
      padding: 0.6rem 0.2rem 0;
      position: relative;
      z-index: 2;
    }

    .search-suggestions span {
      background: rgba(255, 255, 255, 0.12);
      padding: 0.15rem 1.2rem;
      border-radius: 50px;
      font-size: 0.78rem;
      backdrop-filter: blur(4px);
      cursor: pointer;
      transition: var(--transition);
      border: 1px solid rgba(255, 255, 255, 0.05);
    }

    .search-suggestions span:hover {
      background: rgba(255, 255, 255, 0.25);
      transform: translateY(-1px);
    }

    .search-suggestions span i {
      margin-left: 5px;
    }

    .container {
      width: 90%;
      max-width: 1200px;
      margin: 0 auto;
      padding: 0 15px;
    }

    /* ===== SECTION ===== */
    .section-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin: 2.8rem 0 1.5rem;
      flex-wrap: wrap;
      gap: 0.5rem;
    }

    .section-title {
      font-size: 1.6rem;
      font-weight: 700;
      display: flex;
      align-items: center;
      gap: 12px;
      color: var(--text-primary);
    }

    .section-title i {
      color: var(--primary-light);
      font-size: 1.4rem;
    }

    .section-more {
      color: var(--primary-light);
      font-weight: 500;
      cursor: pointer;
      transition: var(--transition);
      display: flex;
      align-items: center;
      gap: 4px;
      font-size: 0.88rem;
      padding: 0.3rem 0.8rem;
      border-radius: 50px;
      background: rgba(26, 74, 122, 0.04);
    }

    .section-more:hover {
      background: rgba(26, 74, 122, 0.08);
      transform: translateX(-4px);
      color: var(--primary);
    }

    /* ===== HORIZONTAL SCROLL (بديل السلايدر) ===== */
    .section-scroll-wrapper {
      position: relative;
      overflow: hidden;
      padding: 0.5rem 0 1.5rem;
    }

    .section-scroll-track {
      display: flex;
      gap: 1.8rem;
      overflow-x: auto;
      padding: 0.5rem 0.2rem 1.2rem;
      scroll-behavior: smooth;
      -webkit-overflow-scrolling: touch;
      scrollbar-width: thin;
      scrollbar-color: var(--primary-light) transparent;
    }

    .section-scroll-track::-webkit-scrollbar {
      height: 4px;
    }

    .section-scroll-track::-webkit-scrollbar-thumb {
      background: var(--primary-light);
      border-radius: 10px;
    }

    .section-scroll-track .card {
      min-width: 220px;
      flex: 0 0 220px;
      transition: var(--transition);
      cursor: pointer;
      border: 2px solid transparent;
      position: relative;
      box-shadow: var(--shadow-sm);
      background: var(--bg-card);
      border-radius: var(--radius);
      padding: 1.2rem 1.2rem 1rem;
      display: flex;
      flex-direction: column;
      align-items: flex-start;
      gap: 0.4rem;
    }

    .section-scroll-track .card:hover {
      transform: translateY(-4px);
      box-shadow: var(--shadow-md);
      border-color: var(--accent);
    }

    .section-scroll-track .card .card-icon {
      font-size: 2.8rem;
      color: var(--primary-light);
      width: 100%;
      text-align: center;
      padding: 0.4rem 0;
      background: var(--bg-body);
      border-radius: var(--radius-sm);
      margin-bottom: 0.3rem;
      transition: var(--transition);
    }

    .section-scroll-track .card:hover .card-icon {
      transform: scale(1.05);
      color: var(--accent);
    }

    .section-scroll-track .card .badge {
      background: var(--bg-body);
      padding: 0.05rem 0.8rem;
      border-radius: 50px;
      font-size: 0.6rem;
      color: var(--primary-light);
      font-weight: 700;
      text-transform: uppercase;
    }

    .section-scroll-track .card h4 {
      font-size: 1rem;
      font-weight: 700;
      margin: 0.2rem 0;
      color: var(--text-primary);
      line-height: 1.3;
    }

    .section-scroll-track .card p {
      font-size: 0.78rem;
      color: var(--text-secondary);
      margin: 0.1rem 0;
    }

    .section-scroll-track .card .meta {
      display: flex;
      flex-wrap: wrap;
      gap: 0.3rem 0.8rem;
      font-size: 0.7rem;
      color: var(--text-muted);
      width: 100%;
    }

    .section-scroll-track .card .actions {
      display: flex;
      justify-content: space-between;
      width: 100%;
      margin-top: 0.4rem;
      border-top: 1px solid var(--border-light);
      padding-top: 0.5rem;
    }

    .section-scroll-track .card .actions i {
      color: var(--text-muted);
      transition: var(--transition);
      cursor: pointer;
      font-size: 0.9rem;
    }

    .section-scroll-track .card .actions i:hover {
      color: var(--primary);
      transform: scale(1.15);
    }

    .menu-toggle {
      display: none;
      background: none;
      border: none;
      font-size: 2rem;
      cursor: pointer;
      color: var(--bg-body);
      padding: 0.5rem;
      line-height: 1;
      z-index: 1001;
    }

    .menu-toggle:hover {
      color: var(--bg-body);
    }

    .nav-controls {
      display: flex;
      gap: 1.5rem;
      align-items: center;
      flex-wrap: wrap;
    }

    .nav-link {
      display: flex;
      align-items: center;
      gap: 5px;
      color: var(--bg-body);
      text-decoration: none;
      font-weight: 500;
      padding: 0.5rem 0.8rem;
      border-radius: 6px;
      transition: var(--transition);
    }

    .nav-title {
      color: var(--bg-body);
    }

    .nav-link:hover {
      background: var(--light);
      color: var(--bg-body);
    }

    .dropdown {
      position: relative;
    }

    .dropdown-content {
      display: none;
      position: absolute;
      background: var(--bg-body);
      min-width: 220px;
      box-shadow: var(--shadow);
      border-radius: 8px;
      top: 100%;
      right: 0;
      padding: 1rem 0;
    }

    .dropdown-content a:hover {
      background: var(--light);
      color: var(--bg-body);
    }


    .dropdown:hover .dropdown-content {
      display: block;
    }

    .dropdown-section {
      padding: 0.5rem 1rem;
    }

    .dropdown-section h4 {
      color: var(--primary);
      margin-bottom: 0.5rem;
      font-size: 0.9rem;
      border-bottom: 1px solid var(--light);
      padding-bottom: 0.5rem;
    }

    .dropdown-content a {
      color: var(--dark);
      padding: 0.5rem 1rem;
      display: flex;
      align-items: center;
      gap: 10px;
      transition: var(--transition);
    }

    .top-nav {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 1rem 0;
      flex-wrap: wrap;
      gap: 1rem;
      position: relative;
    }

    /* ===== الرأس ===== */
    header {
      background: var(--primary);
      box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
      position: sticky;
      top: 0;
      z-index: 1000;
    }

    .logo {
      display: flex;
      align-items: center;
      gap: 10px;
      color: var(--primary);
    }

    .logo-img {
      width: 70px;
      height: 40px;
      background: rgba(255, 255, 255, 0);
    }

    .dropdown-content a:hover {
      background: var(--light);
      color: var(--bg-body);
    }

    /* ===== CARDS GRID ===== */
    .card-grid {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
      gap: 2rem;
      margin-bottom: 1rem;
    }

    .card-grid .card {
      background: var(--bg-card);
      border-radius: var(--radius);
      padding: 1.2rem 1.2rem 1rem;
      box-shadow: var(--shadow-sm);
      transition: var(--transition);
      border: 1px solid var(--border-light);
      display: flex;
      flex-direction: column;
      align-items: flex-start;
      gap: 0.4rem;
      cursor: pointer;
      position: relative;
    }

    .card-grid .card:hover {
      transform: translateY(-6px);
      box-shadow: var(--shadow-lg);
      border-color: rgba(26, 74, 122, 0.08);
    }

    .card-grid .card .card-icon {
      font-size: 3rem;
      color: var(--primary-light);
      width: 100%;
      text-align: center;
      padding: 0.8rem 0;
      background: var(--bg-body);
      border-radius: var(--radius-sm);
      margin-bottom: 0.3rem;
      transition: var(--transition);
    }

    .card-grid .card:hover .card-icon {
      transform: scale(1.05);
      color: var(--accent);
    }

    .card-grid .card .badge {
      background: var(--bg-body);
      padding: 0.05rem 0.8rem;
      border-radius: 50px;
      font-size: 0.6rem;
      color: var(--primary-light);
      font-weight: 700;
      letter-spacing: 0.5px;
      text-transform: uppercase;
    }

    .card-grid .card h4 {
      font-size: 1.05rem;
      font-weight: 700;
      margin: 0.2rem 0;
      color: var(--text-primary);
      line-height: 1.3;
    }

    .card-grid .card p {
      font-size: 0.82rem;
      color: var(--text-secondary);
      margin: 0.1rem 0;
    }

    .card-grid .card .meta {
      display: flex;
      flex-wrap: wrap;
      gap: 0.3rem 0.8rem;
      font-size: 0.72rem;
      color: var(--text-muted);
      width: 100%;
    }

    .card-grid .card .actions {
      display: flex;
      justify-content: space-between;
      width: 100%;
      margin-top: 0.5rem;
      border-top: 1px solid var(--border-light);
      padding-top: 0.6rem;
    }

    .card-grid .card .actions i {
      color: var(--text-muted);
      transition: var(--transition);
      cursor: pointer;
      font-size: 0.95rem;
    }

    .card-grid .card .actions i:hover {
      color: var(--primary);
      transform: scale(1.15);
    }

    .rating-stars {
      color: var(--accent);
      letter-spacing: 0.5px;
      font-size: 0.85rem;
    }

    /* ===== CHAT ===== */
    .chat-float {
      position: fixed;
      bottom: 2rem;
      left: 2rem;
      z-index: 999;
      background: var(--primary-gradient);
      color: white;
      width: 62px;
      height: 62px;
      border-radius: 50%;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 1.8rem;
      box-shadow: 0 8px 32px rgba(10, 30, 61, 0.3);
      transition: var(--transition);
      cursor: pointer;
      border: none;
    }

    .chat-float:hover {
      transform: scale(1.06) rotate(-4deg);
    }

    .chat-widget {
      position: fixed;
      bottom: 90px;
      left: 20px;
      width: 400px;
      max-height: 520px;
      background: var(--bg-card);
      border-radius: var(--radius);
      box-shadow: var(--shadow-xl);
      display: none;
      flex-direction: column;
      overflow: hidden;
      z-index: 1000;
      border: 1px solid var(--border-light);
    }

    .chat-widget.active {
      display: flex;
      animation: fadeUp 0.3s ease;
    }

    .chat-header {
      background: var(--primary-gradient);
      color: white;
      padding: 0.9rem 1.5rem;
      font-weight: 600;
      display: flex;
      justify-content: space-between;
      align-items: center;
    }

    .chat-body {
      padding: 1rem 1.2rem;
      overflow-y: auto;
      flex: 1;
      max-height: 300px;
      background: var(--bg-card);
      display: flex;
      flex-direction: column;
    }

    .chat-body .msg {
      background: var(--bg-body);
      padding: 0.6rem 1rem;
      border-radius: 16px;
      margin: 0.3rem 0;
      max-width: 85%;
      color: var(--text-primary);
      font-size: 0.9rem;
      word-wrap: break-word;
      position: relative;
      align-self: flex-start;
      width: fit-content;
      min-width: 40px;
      transition: all 0.2s ease;
    }

    .chat-body .msg.user {
      background: var(--primary-gradient);
      color: white;
      align-self: flex-end;
    }

    .chat-body .msg .msg-actions {
      display: flex;
      gap: 0.5rem;
      margin-top: 0.3rem;
      font-size: 0.7rem;
      opacity: 0.6;
    }

    .chat-body .msg .msg-actions i {
      cursor: pointer;
      transition: var(--transition);
    }

    .chat-body .msg .msg-actions i:hover {
      opacity: 1;
      transform: scale(1.1);
    }

    .chat-input {
      display: flex;
      border-top: 1px solid var(--border-light);
      background: var(--bg-card);
    }

    .chat-input input {
      flex: 1;
      border: none;
      padding: 0.8rem 1.2rem;
      outline: none;
      font-family: var(--font);
      background: transparent;
      color: var(--text-primary);
      font-size: 0.9rem;
    }

    .chat-input button {
      background: var(--primary-gradient);
      border: none;
      color: white;
      padding: 0.8rem 1.4rem;
      cursor: pointer;
      font-size: 1.1rem;
    }

    /* ===== PAGES ===== */
    .page {
      display: none;
      animation: fadeUp 0.45s ease;
    }

    .page.active {
      display: block;
    }

    @keyframes fadeUp {
      from {
        opacity: 0;
        transform: translateY(24px);
      }

      to {
        opacity: 1;
        transform: translateY(0);
      }
    }

    /* ===== DETAIL ===== */
    .detail-hero {
      display: flex;
      flex-wrap: wrap;
      gap: 2.5rem;
      align-items: flex-start;
    }

    .detail-hero .detail-icon {
      font-size: 5rem;
      color: var(--primary-light);
      width: 180px;
      height: 180px;
      background: var(--bg-body);
      border-radius: var(--radius);
      display: flex;
      align-items: center;
      justify-content: center;
      box-shadow: var(--shadow-md);
      flex-shrink: 0;
    }

    .detail-info {
      flex: 1;
    }

    .detail-info h2 {
      font-size: 2.2rem;
      font-weight: 800;
      margin-bottom: 0.2rem;
      color: var(--text-primary);
    }

    .detail-info .meta-line {
      color: var(--text-secondary);
      margin-bottom: 0.5rem;
      font-size: 0.95rem;
    }

    .detail-actions {
      display: flex;
      flex-wrap: wrap;
      gap: 0.8rem;
      margin: 1.2rem 0;
    }

    .detail-section {
      margin-top: 2rem;
    }

    .detail-section h4 {
      font-size: 1.1rem;
      font-weight: 700;
      margin-bottom: 0.5rem;
      color: var(--primary-light);
      display: flex;
      align-items: center;
      gap: 8px;
    }

    .similar-grid {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
      gap: 1.2rem;
      margin-top: 0.5rem;
    }

    .similar-grid .card {
      padding: 0.8rem;
      cursor: pointer;
    }

    .similar-grid .card .card-icon {
      font-size: 2rem;
      padding: 0.4rem 0;
    }

    /* ===== READER ===== */
    .reader-toolbar {
      display: flex;
      flex-wrap: wrap;
      gap: 0.5rem;
      margin: 1rem 0;
      padding: 0.6rem 1.2rem;
      background: var(--bg-body);
      border-radius: var(--radius-sm);
      align-items: center;
    }

    .reader-toolbar button {
      background: var(--bg-card);
      border: 1px solid var(--border-light);
      padding: 0.25rem 1rem;
      border-radius: 50px;
      cursor: pointer;
      transition: var(--transition);
      font-family: var(--font);
      color: var(--text-secondary);
      font-size: 0.8rem;
    }

    .reader-toolbar button:hover {
      background: var(--primary-gradient);
      color: white;
      border-color: transparent;
    }

    .reader-content {
      padding: 2rem;
      border-radius: var(--radius-sm);
      background: var(--bg-card);
      border: 1px solid var(--border-light);
      min-height: 350px;
      transition: all 0.3s;
      color: var(--text-primary);
      font-size: 1.05rem;
      line-height: 1.9;
      position: relative;
    }

    .reader-content .page-number {
      text-align: center;
      color: var(--text-muted);
      font-size: 0.85rem;
      margin-top: 1.5rem;
      padding-top: 1rem;
      border-top: 1px solid var(--border-light);
    }

    .reader-content .highlighted {
      background: #f5b342;
      color: #0a1e3d;
      padding: 0.1rem 0.2rem;
      border-radius: 4px;
    }

    .reader-nav {
      display: flex;
      justify-content: center;
      gap: 1rem;
      margin-top: 1rem;
    }

    .reader-nav button {
      background: var(--bg-card);
      border: 1px solid var(--border-light);
      padding: 0.3rem 1.5rem;
      border-radius: 50px;
      cursor: pointer;
      transition: var(--transition);
      font-family: var(--font);
      color: var(--text-secondary);
    }

    .reader-nav button:hover {
      background: var(--primary-gradient);
      color: white;
      border-color: transparent;
    }

    .reader-progress {
      margin-top: 1.2rem;
    }

    .reader-progress progress {
      width: 100%;
      height: 6px;
      border-radius: 10px;
      background: var(--bg-body);
      -webkit-appearance: none;
      appearance: none;
    }

    .reader-progress progress::-webkit-progress-bar {
      background: var(--bg-body);
      border-radius: 10px;
    }

    .reader-progress progress::-webkit-progress-value {
      background: var(--primary-gradient);
      border-radius: 10px;
    }

    /* ===== NOTES ===== */
    .note-marker {
      display: inline-block;
      color: #f5b342;
      font-weight: 700;
      cursor: pointer;
      margin: 0 2px;
      font-size: 1.1rem;
      position: relative;
    }

    .note-marker:hover {
      color: #1e4a7a;
    }

    .note-marker .note-preview {
      display: none;
      position: absolute;
      bottom: 100%;
      right: -10px;
      background: var(--bg-card);
      border: 1px solid var(--border-light);
      border-radius: var(--radius-sm);
      padding: 0.5rem 0.8rem;
      box-shadow: var(--shadow-lg);
      min-width: 150px;
      max-width: 250px;
      font-size: 0.75rem;
      color: var(--text-primary);
      z-index: 100;
    }

    .note-marker:hover .note-preview {
      display: block;
    }

    .note-tooltip {
      position: fixed;
      background: var(--bg-card);
      border: 1px solid var(--border-light);
      border-radius: var(--radius-sm);
      padding: 0.8rem 1rem;
      box-shadow: var(--shadow-xl);
      z-index: 2000;
      max-width: 300px;
      font-size: 0.85rem;
      color: var(--text-primary);
      display: none;
    }

    .note-tooltip.active {
      display: block;
      animation: fadeUp 0.2s ease;
    }

    .note-input-popup {
      position: fixed;
      background: var(--bg-card);
      border-radius: var(--radius-sm);
      padding: 1.2rem;
      box-shadow: var(--shadow-xl);
      z-index: 2001;
      border: 1px solid var(--border-light);
      min-width: 300px;
      display: none;
    }

    .note-input-popup.active {
      display: block;
      animation: fadeUp 0.2s ease;
    }

    .note-input-popup textarea {
      width: 100%;
      padding: 0.5rem;
      border: 1px solid var(--border-light);
      border-radius: var(--radius-sm);
      font-family: var(--font);
      background: var(--bg-body);
      color: var(--text-primary);
      min-height: 80px;
      resize: vertical;
    }

    .note-input-popup .note-actions {
      display: flex;
      gap: 0.5rem;
      margin-top: 0.5rem;
      justify-content: flex-end;
      flex-wrap: wrap;
    }

    .note-input-popup .note-actions button {
      padding: 0.2rem 1rem;
      border-radius: 50px;
      border: none;
      cursor: pointer;
      font-family: var(--font);
    }

    .note-input-popup .note-actions .save-note {
      background: var(--primary-gradient);
      color: white;
    }

    .note-input-popup .note-actions .delete-note {
      background: #e74c3c;
      color: white;
    }

    .note-input-popup .note-actions .cancel-note {
      background: var(--bg-body);
      color: var(--text-secondary);
    }

    /* ===== CONTEXT MENU ===== */
    .context-menu {
      position: fixed;
      background: var(--bg-card);
      border-radius: var(--radius-sm);
      box-shadow: var(--shadow-xl);
      border: 1px solid var(--border-light);
      padding: 0.4rem 0;
      min-width: 180px;
      z-index: 2002;
      display: none;
    }

    .context-menu.active {
      display: block;
      animation: fadeUp 0.15s ease;
    }

    .context-menu .menu-item {
      padding: 0.4rem 1.5rem;
      cursor: pointer;
      transition: var(--transition);
      color: var(--text-secondary);
      font-size: 0.85rem;
      display: flex;
      align-items: center;
      gap: 8px;
    }

    .context-menu .menu-item:hover {
      background: var(--bg-body);
      color: var(--text-primary);
    }

    .context-menu .menu-item i {
      width: 18px;
      font-size: 0.9rem;
    }

    /* ===== MODAL – بحث متقدم ===== */
    .modal-overlay {
      display: none;
      position: fixed;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      background: rgba(10, 30, 61, 0.5);
      backdrop-filter: blur(8px);
      z-index: 1200;
      align-items: center;
      justify-content: center;
    }

    .modal-overlay.active {
      display: flex;
      animation: fadeUp 0.3s ease;
    }

    .modal-box {
      background: var(--bg-card);
      border-radius: var(--radius);
      padding: 0;
      max-width: 620px;
      width: 92%;
      max-height: 90vh;
      box-shadow: var(--shadow-xl);
      border: 1px solid var(--border-light);
      display: flex;
      flex-direction: column;
      overflow: hidden;
    }

    .modal-header {
      background: var(--primary-gradient);
      padding: 1.2rem 2rem;
      display: flex;
      justify-content: space-between;
      align-items: center;
      color: white;
      flex-shrink: 0;
    }

    .modal-header h2 {
      font-weight: 700;
      font-size: 1.4rem;
      margin: 0;
    }

    .modal-header .close-modal {
      cursor: pointer;
      font-size: 1.5rem;
      transition: var(--transition);
      background: none;
      border: none;
      color: white;
    }

    .modal-header .close-modal:hover {
      transform: scale(1.1);
      opacity: 0.8;
    }

    .modal-body {
      padding: 1.8rem 2rem;
      overflow-y: auto;
      flex: 1;
    }

    .modal-body .form-group {
      margin-bottom: 1rem;
    }

    .modal-body label {
      display: block;
      font-weight: 600;
      margin-bottom: 0.2rem;
      color: var(--text-secondary);
      font-size: 0.85rem;
    }

    .modal-body input,
    .modal-body select {
      width: 100%;
      padding: 0.5rem 1rem;
      border: 1.5px solid var(--border-light);
      border-radius: var(--radius-sm);
      font-family: var(--font);
      background: var(--bg-body);
      color: var(--text-primary);
      transition: var(--transition);
      font-size: 0.9rem;
    }

    .modal-body input:focus,
    .modal-body select:focus {
      border-color: var(--primary-light);
      outline: none;
      box-shadow: 0 0 0 3px rgba(26, 74, 122, 0.08);
    }

    .modal-body .range-group {
      display: flex;
      gap: 1rem;
      align-items: center;
    }

    .modal-body .range-group input {
      flex: 1;
    }

    .modal-body .range-group span {
      color: var(--text-muted);
      font-size: 0.85rem;
    }

    /* تصنيفات قابلة للاختيار مع زر إظهار/إخفاء */
    .category-selector-wrapper {
      margin-top: 0.3rem;
    }

    .category-selector-toggle {
      background: var(--bg-body);
      border: 1px solid var(--border-light);
      border-radius: 50px;
      padding: 0.2rem 1rem;
      cursor: pointer;
      font-family: var(--font);
      font-size: 0.8rem;
      color: var(--text-secondary);
      transition: var(--transition);
      margin-bottom: 0.5rem;
    }

    .category-selector-toggle:hover {
      border-color: var(--primary-light);
      color: var(--primary);
    }

    .category-selector {
      display: none;
      flex-wrap: wrap;
      gap: 0.5rem;
      margin-top: 0.3rem;
    }

    .category-selector.active {
      display: flex;
    }

    .category-selector .cat-chip {
      background: var(--bg-body);
      padding: 0.2rem 1rem;
      border-radius: 50px;
      font-size: 0.8rem;
      border: 1.5px solid var(--border-light);
      cursor: pointer;
      transition: var(--transition);
      color: var(--text-secondary);
    }

    .category-selector .cat-chip:hover {
      border-color: var(--primary-light);
    }

    .category-selector .cat-chip.selected {
      background: var(--primary-gradient);
      color: white;
      border-color: transparent;
    }

    .selected-categories-display {
      display: flex;
      flex-wrap: wrap;
      gap: 0.4rem;
      margin-top: 0.3rem;
    }

    .selected-categories-display .sel-chip {
      background: var(--primary-gradient);
      color: white;
      padding: 0.15rem 0.8rem;
      border-radius: 50px;
      font-size: 0.75rem;
      display: flex;
      align-items: center;
      gap: 4px;
    }

    .selected-categories-display .sel-chip .remove-sel {
      cursor: pointer;
      font-weight: 700;
      opacity: 0.7;
    }

    .selected-categories-display .sel-chip .remove-sel:hover {
      opacity: 1;
    }

    .modal-footer {
      padding: 1rem 2rem;
      border-top: 1px solid var(--border-light);
      display: flex;
      gap: 0.8rem;
      justify-content: flex-end;
      flex-shrink: 0;
      background: var(--bg-card);
      flex-wrap: wrap;
    }

    /* ===== RESULTS ===== */
    .results-container {
      display: none;
      padding: 1.5rem 0;
      background: var(--bg-card);
      border-radius: var(--radius);
      margin: 1rem 0;
      box-shadow: var(--shadow-sm);
      border: 1px solid var(--border-light);
    }

    .results-container.active {
      display: block;
    }

    .results-container .results-header {
      padding: 0 1.5rem 1rem;
      border-bottom: 1px solid var(--border-light);
      display: flex;
      justify-content: space-between;
      align-items: center;
      flex-wrap: wrap;
    }

    .results-container .results-header h3 {
      color: var(--text-primary);
      font-weight: 700;
    }

    .results-container .results-header .close-results {
      cursor: pointer;
      color: var(--text-muted);
      transition: var(--transition);
    }

    .results-container .results-header .close-results:hover {
      color: var(--primary);
    }

    .results-container .result-section {
      padding: 1rem 1.5rem;
      border-bottom: 1px solid var(--border-light);
    }

    .results-container .result-section:last-child {
      border-bottom: none;
    }

    .results-container .result-section h4 {
      color: var(--primary-light);
      font-size: 0.95rem;
      margin-bottom: 0.5rem;
    }

    .results-container .result-section .mini-grid {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
      gap: 0.8rem;
    }

    .results-container .result-section .mini-grid .mini-card {
      background: var(--bg-body);
      border-radius: var(--radius-sm);
      padding: 0.5rem;
      cursor: pointer;
      transition: var(--transition);
      border: 1px solid transparent;
      text-align: center;
    }

    .results-container .result-section .mini-grid .mini-card:hover {
      border-color: var(--primary-light);
      transform: translateY(-2px);
    }

    .results-container .result-section .mini-grid .mini-card .mini-icon {
      font-size: 2.5rem;
      color: var(--primary-light);
      display: block;
      margin-bottom: 0.3rem;
    }

    .results-container .result-section .mini-grid .mini-card h5 {
      font-size: 0.8rem;
      color: var(--text-primary);
      margin: 0.2rem 0;
    }

    .results-container .result-section .mini-grid .mini-card p {
      font-size: 0.65rem;
      color: var(--text-muted);
    }

    /* ===== FOOTER ===== */
    .footer-full {
      background: var(--bg-card);
      padding: 2.5rem 2rem 1.5rem;
      margin-top: 3.5rem;
      border-radius: var(--radius) var(--radius) 0 0;
      border-top: 1px solid var(--border-light);
    }

    .footer-full .footer-grid {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
      gap: 2rem;
      margin-bottom: 2rem;
    }

    .footer-full .footer-grid h4 {
      color: var(--text-primary);
      font-weight: 700;
      margin-bottom: 0.6rem;
    }

    .footer-full .footer-grid ul {
      list-style: none;
      padding: 0;
    }

    .footer-full .footer-grid ul li {
      padding: 0.2rem 0;
      color: var(--text-secondary);
      font-size: 0.9rem;
      cursor: pointer;
      transition: var(--transition);
    }

    .footer-full .footer-grid ul li:hover {
      color: var(--primary-light);
      padding-right: 0.3rem;
    }

    .footer-full .footer-bottom {
      border-top: 1px solid var(--border-light);
      padding-top: 1.5rem;
      text-align: center;
      color: var(--text-muted);
      font-size: 0.8rem;
    }

    /* إخفاء الفوتر في صفحة المساعد */
    .page-assistant.active~.footer-full {
      display: none;
    }

    /* ===== COLOR PICKER ===== */
    .color-picker-circle {
      display: flex;
      gap: 0.4rem;
      flex-wrap: wrap;
      margin: 0.3rem 0;
    }

    .color-picker-circle .color-option {
      width: 28px;
      height: 28px;
      border-radius: 50%;
      cursor: pointer;
      border: 2px solid transparent;
      transition: var(--transition);
    }

    .color-picker-circle .color-option:hover {
      transform: scale(1.1);
    }

    .color-picker-circle .color-option.active {
      border-color: var(--primary);
      box-shadow: 0 0 0 2px white, 0 0 0 4px var(--primary);
    }

    /* ===== LOGIN / REGISTER / FORGOT MODALS ===== */
    .auth-modal .modal-box {
      max-width: 420px;
    }

    .auth-modal .form-group {
      margin-bottom: 1.2rem;
    }

    .auth-modal .form-group label {
      display: block;
      font-weight: 600;
      margin-bottom: 0.2rem;
      color: var(--text-secondary);
    }

    .auth-modal .form-group input {
      width: 100%;
      padding: 0.6rem 1rem;
      border: 1.5px solid var(--border-light);
      border-radius: var(--radius-sm);
      font-family: var(--font);
      background: var(--bg-body);
      color: var(--text-primary);
    }

    .auth-modal .form-group input:focus {
      border-color: var(--primary-light);
      outline: none;
      box-shadow: 0 0 0 3px rgba(26, 74, 122, 0.08);
    }

    .auth-modal .modal-footer {
      flex-direction: column;
      gap: 0.6rem;
    }

    .auth-modal .modal-footer .btn-primary {
      width: 100%;
    }

    .auth-modal .modal-footer .btn-outline {
      width: 100%;
    }

    .auth-modal .auth-link {
      text-align: center;
      margin-top: 0.8rem;
      color: var(--text-secondary);
      font-size: 0.85rem;
    }

    .auth-modal .auth-link a {
      color: var(--primary-light);
      cursor: pointer;
      font-weight: 600;
      text-decoration: none;
    }

    .auth-modal .auth-link a:hover {
      text-decoration: underline;
    }

    /* ===== SECTION NAVIGATION SCROLLBAR ===== */
    .section-nav-scroll {
      display: flex;
      gap: 0.5rem;
      overflow-x: auto;
      padding: 0.5rem 0 1rem;
      scrollbar-width: thin;
      scrollbar-color: var(--primary-light) transparent;
      -webkit-overflow-scrolling: touch;
      margin-top: -0.5rem;
    }

    .section-nav-scroll::-webkit-scrollbar {
      height: 4px;
    }

    .section-nav-scroll::-webkit-scrollbar-thumb {
      background: var(--primary-light);
      border-radius: 10px;
    }

    .section-nav-scroll .nav-item {
      background: var(--bg-card);
      padding: 0.3rem 1.2rem;
      border-radius: 50px;
      white-space: nowrap;
      border: 1px solid var(--border-light);
      font-size: 0.8rem;
      color: var(--text-secondary);
      cursor: pointer;
      transition: var(--transition);
      flex-shrink: 0;
    }

    .section-nav-scroll .nav-item:hover {
      border-color: var(--primary-light);
      color: var(--primary);
      transform: translateY(-2px);
    }

    .section-nav-scroll .nav-item.active {
      background: var(--primary-gradient);
      color: white;
      border-color: transparent;
    }


    /* ===== RESPONSIVE ===== */
    @media (max-width: 768px) {
      .nav-controls.active {
        display: flex;
      }

      .user-dropdown {
        position: static;
        margin-top: 0.5rem;
      }

      .user-menu {
        width: 100%;
      }

      .menu-toggle {
        display: block;
      }

      .nav-controls {
        display: none;
        flex-direction: column;
        width: 100%;
        background: var(--bg-body);
        padding: 1.5rem;
        border-radius: 16px;
        position: absolute;
        top: 100%;
        right: 0;
        z-index: 999;
        gap: 1rem;
        box-shadow: 0 15px 35px rgba(0, 0, 0, 0.15);
      }

      .dropdown-content {
        position: static;
        box-shadow: none;
        margin-top: 0.5rem;
      }

      .nav-link {
        width: 100%;
        justify-content: flex-start;
        color: #0a1e3d;
      }

      .container {
        padding: 0 1.2rem;
      }

      .hero-search {
        padding: 2rem 1.5rem;
      }

      .hero-search h1 {
        font-size: 1.4rem;
      }

      .card-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 1.2rem;
      }

      .section-title {
        font-size: 1.3rem;
      }

      .detail-hero .detail-icon {
        width: 120px;
        height: 120px;
        font-size: 3.5rem;
      }

      .chat-widget {
        width: 320px;
        left: 10px;
        bottom: 80px;
        max-height: 440px;
      }

      .section-scroll-track .card {
        min-width: 180px;
        flex: 0 0 180px;
      }

      .modal-body {
        padding: 1.2rem 1.2rem;
      }

      .modal-footer {
        padding: 0.8rem 1.2rem;
      }

      .search-wrapper .mini-search-input {
        width: 100px;
      }
    }

    @media (max-width: 480px) {
      .card-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.8rem;
      }

      .card-grid .card {
        padding: 0.8rem;
      }

      .card-grid .card .card-icon {
        font-size: 2.2rem;
        padding: 0.4rem 0;
      }

      .card-grid .card h4 {
        font-size: 0.9rem;
      }

      .section-scroll-track .card {
        min-width: 150px;
        flex: 0 0 150px;
      }

      .section-scroll-track .card .card-icon {
        font-size: 2rem;
      }

      .chat-widget {
        width: 280px;
        max-height: 400px;
      }
    }

    .user-menu {
      position: relative;
    }

    .user-area {
      display: flex;
      align-items: center;
      gap: 10px;
      padding: 0.5rem 1rem;
      background: linear-gradient(135deg, #f8f9fa, #e9ecef);
      border-radius: 30px;
      cursor: pointer;
      transition: var(--transition);
      border: 1px solid #dee2e6;
    }

    .user-area:hover {
      background: linear-gradient(135deg, #e9ecef, #dee2e6);
      box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    }

    .user-greeting {
      font-weight: 600;
      color: var(--primary);
      font-size: 0.95rem;
    }

    .user-avatar {
      width: 38px;
      height: 38px;
      background: linear-gradient(135deg, #3498db, var(--primary));
      border-radius: 50%;
      display: flex;
      align-items: center;
      justify-content: center;
      color: white;
      font-size: 1rem;
      box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    }

    .user-dropdown {
      position: absolute;
      top: 55px;
      left: 0;
      background: white;
      border-radius: 12px;
      box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
      min-width: 220px;
      display: none;
      flex-direction: column;
      padding: 0.5rem 0;
      z-index: 200;
      border: 1px solid #eee;
      overflow: hidden;
    }

    .user-dropdown.active {
      display: flex;
    }

    .dropdown-item {
      padding: 0.8rem 1.5rem;
      text-decoration: none;
      color: #1a252f;
      font-weight: 500;
      transition: all 0.3s ease;
      display: flex;
      align-items: center;
      gap: 10px;
      font-size: 0.95rem;
    }

    .dropdown-item:hover {
      background: #f8f9fa;
      color: #3498db;
      padding-right: 1.8rem;
    }

    .dropdown-divider {
      border: none;
      border-top: 1px solid #eee;
      margin: 0.3rem 0;
    }

    .logout-item {
      color: #e74c3c;
    }

    .logout-item:hover {
      background: #fff5f5;
      color: #c0392b;
    }

    .auth-buttons {
      display: flex;
      gap: 0.5rem;
    }

    .btn-outline {
      background: transparent;
      border: 2px solid var(--secondary);
      color: var(--secondary);
      padding: 0.5rem 1.5rem;
      border-radius: 30px;
      font-weight: bold;
      cursor: pointer;
      transition: var(--transition);
    }

    .btn-outline:hover {
      background: var(--secondary);
      color: white;
    }

    /* ===== نافذة تسجيل الدخول (مودال) ===== */
    .modal {
      display: none;
      position: fixed;
      inset: 0;
      background: rgba(0, 0, 0, 0.5);
      backdrop-filter: blur(5px);
      justify-content: center;
      align-items: center;
      z-index: 3000;
    }

    .modal.active {
      display: flex;
    }

    .modal-content {
      background: white;
      padding: 2rem 1.8rem;
      border-radius: 16px;
      width: 90%;
      max-width: 420px;
      box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
      position: relative;
      animation: slideDown 0.3s ease;
    }

/* ============================================================
   RESPONSIVE POLISH — إضافات للشاشات الصغيرة
   ============================================================ */
@media (max-width: 768px) {
  html {
    overflow-x: hidden;
  }

  body {
    min-width: 0;
    overflow-x: hidden;
  }

  header {
    position: sticky;
  }

  .top-nav {
    padding: 0.75rem 0;
    gap: 0.75rem;
  }

  .logo {
    min-width: 0;
    gap: 0.5rem;
  }

  .logo-img {
    width: 52px;
    height: 32px;
    object-fit: contain;
  }

  .nav-title {
    font-size: 1rem;
    white-space: nowrap;
  }

  .menu-toggle {
    flex-shrink: 0;
    font-size: 1.75rem;
  }

  .nav-controls {
    max-height: calc(100vh - 80px);
    overflow-y: auto;
  }

  .auth-buttons {
    width: 100%;
    flex-direction: column;
  }

  .auth-buttons .btn {
    width: 100%;
  }

  .container {
    width: 100%;
    max-width: 100%;
    padding-right: 1rem;
    padding-left: 1rem;
  }

  .hero-search {
    margin-top: 1rem;
    margin-bottom: 1.5rem;
    padding: 1.5rem 1rem;
    border-radius: 14px;
  }

  .search-wrapper {
    align-items: stretch;
    border-radius: 18px;
    padding: 0.35rem;
  }

  .search-wrapper input {
    min-width: 0;
    width: 100%;
    padding: 0.7rem;
  }

  .search-wrapper .search-actions {
    width: 100%;
  }

  .search-wrapper .search-actions button {
    flex: 0 0 auto;
    padding-right: 1rem;
    padding-left: 1rem;
  }

  .section-header {
    align-items: flex-start;
    margin-top: 1.8rem;
  }

  .section-title {
    font-size: 1.15rem;
  }

  .card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
  }

  .card-grid .card {
    min-width: 0;
    padding: 0.8rem;
  }

  .card-grid .card h4 {
    overflow-wrap: anywhere;
  }

  .detail-hero {
    gap: 1rem;
  }

  .detail-info h2 {
    font-size: 1.5rem;
  }

  .detail-actions > * {
    flex: 1 1 calc(50% - 0.8rem);
  }

  .reader-content {
    padding: 1rem;
    font-size: 1rem;
  }

  .reader-toolbar {
    padding: 0.5rem;
  }

  .reader-toolbar button {
    flex: 1 1 auto;
  }

  .modal-box {
    width: calc(100% - 1.5rem);
    max-height: calc(100vh - 1.5rem);
  }

  .footer-full {
    padding-right: 1rem;
    padding-left: 1rem;
  }
}

@media (max-width: 480px) {
  .nav-title {
    font-size: 0.9rem;
  }

  .hero-search h1 {
    font-size: 1.2rem;
  }

  .card-grid {
    gap: 0.6rem;
  }

  .card-grid .card .meta {
    gap: 0.2rem 0.45rem;
    font-size: 0.65rem;
  }

  .detail-actions > * {
    flex-basis: 100%;
  }

  .chat-widget {
    right: 0.75rem;
    left: 0.75rem;
    width: auto;
  }
}

/* ===== READER EMBED ===== */
.reader-content.reader-embedded {
  padding: 0;
  overflow: hidden;
}

.reader-frame {
  display: block;
  width: 100%;
  min-height: 70vh;
  border: 0;
  background: #fff;
}

.reader-source-note {
  padding: 0.6rem 1rem;
  color: var(--text-muted);
  font-size: 0.75rem;
  text-align: center;
  border-top: 1px solid var(--border-light);
}

@media (max-width: 768px) {
  .reader-frame {
    min-height: 65vh;
  }
}

/* ===== ملء شاشة الكتاب داخل القارئ ===== */

.reader-frame:fullscreen {
  width: 100vw;
  height: 100vh;
  min-height: 100vh;
  border: 0;
  background: #fff;
}

.reader-frame:-webkit-full-screen {
  width: 100vw;
  height: 100vh;
  min-height: 100vh;
  border: 0;
  background: #fff;
}
