:root {
      --green-dark:  #1a4731;
      --green:       #2d6a4f;
      --green-mid:   #40916c;
      --green-light: #74c69d;
      --gold:        #c9a84c;
      --gold-light:  #e9c46a;
      --cream:       #faf7f0;
      --cream-dark:  #f0ead8;
      --text-dark:   #1c1c1c;
      --text-mid:    #3d3d3d;
      --text-muted:  #7a7a7a;
      --white:       #ffffff;
      --shadow-sm:   0 1px 4px rgba(0,0,0,0.08);
      --shadow-md:   0 4px 16px rgba(0,0,0,0.10);
      --shadow-lg:   0 8px 32px rgba(0,0,0,0.13);
      --radius:      12px;
      --radius-sm:   8px;
    }

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

    body {
      font-family: 'Inter', 'Noto Serif Bengali', sans-serif;
      background: var(--cream);
      color: var(--text-dark);
      min-height: 100vh;
      display: flex;
      flex-direction: column;
    }

    /* ──────────────── TOPBAR ──────────────── */
    #topbar {
      background: var(--green-dark);
      color: var(--cream);
      padding: 0 1.5rem;
      height: 56px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      position: sticky;
      top: 0;
      z-index: 1000;
      box-shadow: var(--shadow-md);
    }
    #topbar .brand {
      display: flex;
      align-items: center;
      gap: 10px;
      cursor: pointer;
      text-decoration: none;
    }
    #topbar .brand-icon {
      font-size: 1.5rem;
      font-family: 'Amiri', serif;
      color: var(--gold-light);
    }
    #topbar .brand-name {
      font-family: 'Noto Serif Bengali', serif;
      font-size: 1.05rem;
      font-weight: 700;
      color: var(--cream);
      letter-spacing: 0.01em;
    }
    #topbar .brand-sub {
      font-size: 0.68rem;
      color: var(--green-light);
      letter-spacing: 0.05em;
      text-transform: uppercase;
    }
    #topbar nav {
      display: flex;
      align-items: center;
      gap: 0.3rem;
    }
    #topbar nav a, #topbar nav button {
      color: var(--cream);
      text-decoration: none;
      font-size: 0.82rem;
      padding: 6px 12px;
      border-radius: var(--radius-sm);
      border: none;
      background: transparent;
      cursor: pointer;
      transition: background 0.2s;
      font-family: inherit;
    }
    #topbar nav a:hover, #topbar nav button:hover {
      background: rgba(255,255,255,0.12);
    }
    #topbar nav a.active {
      background: var(--green-mid);
      color: var(--gold-light);
      font-weight: 600;
    }
    #search-bar {
      display: flex;
      align-items: center;
      gap: 6px;
      background: rgba(255,255,255,0.10);
      border: 1px solid rgba(255,255,255,0.18);
      border-radius: 99px;
      padding: 4px 12px;
    }
    #search-bar input {
      background: transparent;
      border: none;
      outline: none;
      color: var(--cream);
      font-size: 0.82rem;
      width: 160px;
      font-family: inherit;
    }
    #search-bar input::placeholder { color: var(--green-light); }
    #search-bar .icon { color: var(--green-light); font-size: 0.85rem; }

    /* ──────────────── LAYOUT ──────────────── */
    #layout {
      display: grid;
      grid-template-columns: 260px 1fr;
      flex: 1;
      min-height: calc(100vh - 56px);
    }

    /* ──────────────── SIDEBAR ──────────────── */
    #sidebar {
      background: var(--white);
      border-right: 1px solid #e8e0d0;
      overflow-y: auto;
      height: calc(100vh - 56px);
      position: sticky;
      top: 56px;
    }
    .sidebar-section-title {
      font-size: 0.68rem;
      text-transform: uppercase;
      letter-spacing: 0.08em;
      color: var(--text-muted);
      padding: 1.2rem 1.2rem 0.4rem;
      font-weight: 600;
    }
    .sidebar-item {
      display: flex;
      align-items: center;
      gap: 8px;
      padding: 9px 1.2rem;
      font-size: 0.84rem;
      color: var(--text-mid);
      cursor: pointer;
      border-radius: 0;
      transition: background 0.15s, color 0.15s;
      text-decoration: none;
      font-family: 'Noto Serif Bengali', serif;
    }
    .sidebar-item:hover {
      background: var(--cream-dark);
      color: var(--green-dark);
    }
    .sidebar-item.active {
      background: linear-gradient(90deg, #e8f5ee 0%, transparent 100%);
      color: var(--green-dark);
      font-weight: 600;
      border-left: 3px solid var(--green-mid);
      padding-left: calc(1.2rem - 3px);
    }
    .sidebar-item .dot {
      width: 6px; height: 6px;
      border-radius: 50%;
      background: var(--green-light);
      flex-shrink: 0;
    }
    .sidebar-item.active .dot { background: var(--green-mid); }
    .sidebar-divider {
      height: 1px;
      background: #ede8dd;
      margin: 0.5rem 0;
    }

    /* ──────────────── MAIN CONTENT ──────────────── */
    #main {
      overflow-y: auto;
    }
    #content-area {
      padding: 2rem;
      min-height: 100%;
    }

    /* HTMX loading indicator */
    #htmx-indicator {
      display: none;
      position: fixed;
      top: 56px;
      left: 0; right: 0;
      height: 3px;
      background: linear-gradient(90deg, var(--gold), var(--green-light), var(--gold));
      background-size: 200% 100%;
      animation: shimmer 1.2s linear infinite;
      z-index: 999;
    }
    @keyframes shimmer { 0%{background-position:200% 0} 100%{background-position:-200% 0} }
    .htmx-request #htmx-indicator { display: block; }

    /* ──────────────── HOMEPAGE ──────────────── */
    .hero {
      text-align: center;
      padding: 3rem 1rem 2rem;
      background: linear-gradient(160deg, var(--green-dark) 0%, var(--green) 55%, var(--green-mid) 100%);
      border-radius: var(--radius);
      color: var(--white);
      margin-bottom: 2.5rem;
      position: relative;
      overflow: hidden;
    }
    .hero::before {
      content: "﷽";
      font-family: 'Amiri', serif;
      font-size: 3rem;
      opacity: 0.08;
      position: absolute;
      top: -10px; right: 20px;
    }
    .hero-bismillah {
      font-family: 'Amiri', serif;
      font-size: 1.8rem;
      color: var(--gold-light);
      margin-bottom: 0.8rem;
      letter-spacing: 0.05em;
    }
    .hero h1 {
      font-family: 'Noto Serif Bengali', serif;
      font-size: 1.9rem;
      font-weight: 700;
      margin-bottom: 0.5rem;
    }
    .hero p {
      font-size: 0.92rem;
      color: rgba(255,255,255,0.78);
      max-width: 480px;
      margin: 0 auto 1.5rem;
      line-height: 1.6;
    }
    .hero-stats {
      display: flex;
      justify-content: center;
      gap: 2rem;
      flex-wrap: wrap;
    }
    .hero-stat {
      text-align: center;
    }
    .hero-stat .num {
      font-size: 1.6rem;
      font-weight: 700;
      color: var(--gold-light);
    }
    .hero-stat .lbl {
      font-size: 0.72rem;
      color: rgba(255,255,255,0.65);
      text-transform: uppercase;
      letter-spacing: 0.06em;
    }

    /* Cards */
    .section-title {
      font-family: 'Noto Serif Bengali', serif;
      font-size: 1.1rem;
      font-weight: 700;
      color: var(--green-dark);
      margin-bottom: 1rem;
      display: flex;
      align-items: center;
      gap: 8px;
    }
    .section-title::after {
      content: '';
      flex: 1;
      height: 1px;
      background: linear-gradient(90deg, var(--gold) 0%, transparent 100%);
    }
    .cards-grid {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
      gap: 1rem;
      margin-bottom: 2.5rem;
    }
    .card {
      background: var(--white);
      border: 1px solid #e8e0d0;
      border-radius: var(--radius);
      padding: 1.1rem 1rem;
      cursor: pointer;
      transition: transform 0.18s, box-shadow 0.18s, border-color 0.18s;
      display: flex;
      align-items: flex-start;
      gap: 10px;
      text-decoration: none;
      color: inherit;
    }
    .card:hover {
      transform: translateY(-2px);
      box-shadow: var(--shadow-md);
      border-color: var(--green-light);
    }
    .card-icon {
      width: 36px; height: 36px;
      border-radius: 8px;
      background: linear-gradient(135deg, var(--green) 0%, var(--green-mid) 100%);
      display: flex; align-items: center; justify-content: center;
      color: var(--white);
      font-size: 1rem;
      flex-shrink: 0;
    }
    .card-body .card-title {
      font-family: 'Noto Serif Bengali', serif;
      font-size: 0.88rem;
      font-weight: 600;
      color: var(--green-dark);
      line-height: 1.4;
    }
    .card-body .card-meta {
      font-size: 0.72rem;
      color: var(--text-muted);
      margin-top: 3px;
    }

    /* Featured topics */
    .topics-grid {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
      gap: 0.6rem;
      margin-bottom: 2.5rem;
    }
    .topic-pill {
      background: var(--white);
      border: 1px solid #e0d8c8;
      border-radius: 99px;
      padding: 7px 14px;
      font-family: 'Noto Serif Bengali', serif;
      font-size: 0.8rem;
      color: var(--text-mid);
      cursor: pointer;
      transition: all 0.15s;
      text-align: center;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .topic-pill:hover {
      background: var(--green-dark);
      color: var(--white);
      border-color: var(--green-dark);
    }

    /* Recent files section */
    .file-list { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 2.5rem; }
    .file-item {
      background: var(--white);
      border: 1px solid #e8e0d0;
      border-radius: var(--radius-sm);
      padding: 0.85rem 1rem;
      display: flex;
      align-items: center;
      gap: 12px;
      cursor: pointer;
      transition: background 0.15s, border-color 0.15s;
      text-decoration: none;
      color: inherit;
    }
    .file-item:hover {
      background: var(--cream-dark);
      border-color: var(--green-light);
    }
    .file-icon {
      width: 38px; height: 38px;
      border-radius: 8px;
      background: linear-gradient(135deg, #c9a84c 0%, #e9c46a 100%);
      display: flex; align-items: center; justify-content: center;
      font-size: 1.1rem;
      flex-shrink: 0;
    }
    .file-info .file-name {
      font-family: 'Noto Serif Bengali', serif;
      font-size: 0.88rem;
      font-weight: 600;
      color: var(--text-dark);
    }
    .file-info .file-date {
      font-size: 0.72rem;
      color: var(--text-muted);
    }
    .file-arrow { margin-left: auto; color: var(--text-muted); font-size: 0.8rem; }

    /* ──────────────── FOOTER ──────────────── */
    footer {
      background: var(--green-dark);
      color: rgba(255,255,255,0.55);
      text-align: center;
      padding: 1rem;
      font-size: 0.75rem;
      border-top: 1px solid rgba(255,255,255,0.08);
    }
    footer span { color: var(--gold-light); }

    /* ──────────────── RESPONSIVE ──────────────── */
    #menu-btn { display: none; background: none; border: none; color: var(--cream); font-size: 1.6rem; cursor: pointer; padding: 0 5px 0 0; }
    #sidebar-overlay {
      display: none;
      position: fixed;
      top: 56px; left: 0; right: 0; bottom: 0;
      background: rgba(0,0,0,0.5);
      z-index: 999;
      backdrop-filter: blur(2px);
    }
    #sidebar-overlay.open { display: block; }

    @media (max-width: 768px) {
      #menu-btn { display: block; }
      #layout { grid-template-columns: 1fr; }
      #sidebar {
        position: fixed;
        left: -280px;
        top: 56px;
        width: 280px;
        height: calc(100vh - 56px);
        z-index: 1000;
        transition: left 0.3s ease;
        box-shadow: 4px 0 16px rgba(0,0,0,0.1);
        display: block; /* override display: none */
      }
      #sidebar.open { left: 0; }
      #home-view { padding: 1.2rem; }
      .hero h1 { font-size: 1.4rem; }
      .cards-grid { grid-template-columns: repeat(2, 1fr); }
    }