.app-shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* ============================= الشريط الجانبي ============================= */
.sidebar {
  background: var(--bg-elevated);
  border-inline-start: 1px solid var(--border-soft);
  padding: var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding-inline: 4px;
}

.brand-mark {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
}

.brand-top-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.brand-text h1 {
  font-size: 1.1rem;
  color: var(--brand-600);
  line-height: 1;
}
[data-theme='dark'] .brand-text h1 { color: var(--brand-700); }

.brand-text span {
  font-size: var(--fs-xs);
  color: var(--ink-500);
}

.version-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  border-radius: var(--radius-pill);
  font-size: 9px;
  font-weight: 800;
  line-height: 1.6;
  background: linear-gradient(135deg, var(--gold-300), var(--gold-500));
  color: var(--brand-900);
  animation: badge-glow 2.4s ease-in-out infinite;
}

.nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 11px var(--sp-3);
  border-radius: var(--radius-md);
  color: var(--ink-700);
  font-size: var(--fs-sm);
  font-weight: 600;
  position: relative;
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}

.nav-item .nav-icon {
  width: 20px; height: 20px; flex-shrink: 0;
  display: grid; place-items: center;
}
.nav-item svg { width: 100%; height: 100%; stroke: currentColor; }

.nav-item:hover { background: var(--nav-color-soft, var(--bg-sunken)); transform: translateX(-2px); }

.nav-item.active {
  background: linear-gradient(90deg, var(--nav-color-soft, var(--brand-50)), transparent);
  color: var(--nav-color, var(--brand-600));
}
[data-theme='dark'] .nav-item.active { color: var(--nav-color, var(--brand-700)); }

.nav-item.active::before {
  content: '';
  position: absolute;
  inset-inline-end: -1px;
  top: 6px; bottom: 6px;
  width: 3px;
  border-radius: var(--radius-pill);
  background: var(--nav-color, var(--gold-500));
}

.sidebar-footer {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding-top: var(--sp-3);
  border-top: 1px solid var(--border-soft);
}

.sidebar-user {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  border-radius: var(--radius-md);
  background: var(--bg-sunken);
}

.sidebar-user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
  color: #fdfdf6;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
}

.sidebar-user-meta {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.sidebar-user-greeting {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-900);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-footer-caption {
  display: block;
  text-align: center;
  font-size: 10px;
  color: var(--ink-300);
  margin-top: 6px;
}

.sidebar-logout-btn {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--ink-500);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.sidebar-logout-btn svg { width: 15px; height: 15px; stroke: currentColor; }
.sidebar-logout-btn:hover { background: rgba(181, 73, 91, .12); color: var(--accent-rose); }

/* ============================= المحتوى ============================= */
.main-col {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-4) var(--sp-6);
  gap: var(--sp-4);
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--bg-glass);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-soft);
}

.topbar-dates {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.topbar-dates .hijri {
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  color: var(--ink-900);
}

.topbar-dates .gregorian {
  font-size: var(--fs-xs);
  color: var(--ink-500);
}

.topbar-actions { display: flex; align-items: center; gap: var(--sp-3); }

.screen {
  flex: 1;
  padding: var(--sp-6);
  max-width: 1180px;
  width: 100%;
  margin-inline: auto;
}

.screen-entering { animation: screen-in var(--dur-med) var(--ease-out); }
.screen-leaving { animation: screen-out var(--dur-fast) var(--ease-out) forwards; }

@keyframes screen-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes screen-out {
  to { opacity: 0; transform: translateY(-6px); }
}

.mobile-nav { display: none; }

body.no-scroll { overflow: hidden; }

/* ============================= استجابة ============================= */
@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .screen { padding: var(--sp-4); padding-bottom: calc(104px + env(safe-area-inset-bottom)); }
  .topbar { padding: var(--sp-3) var(--sp-4); }
  .topbar-dates .hijri { font-size: var(--fs-md); }

  /* ===== الشريط السفلي: اختصاران يمين + اختصاران يسار حول زر مركزي بارز "المزيد" ===== */
  .mobile-nav {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    position: fixed;
    bottom: 0; inset-inline: 0;
    z-index: 30;
    background: var(--bg-glass);
    backdrop-filter: blur(18px);
    border-top: 1px solid var(--border-soft);
    padding: 6px var(--sp-2) calc(6px + env(safe-area-inset-bottom));
    box-shadow: 0 -8px 24px -12px rgba(20, 40, 25, 0.16);
  }

  .mobile-nav-side {
    display: flex;
    justify-content: space-around;
  }

  .mobile-nav .nav-item {
    flex-direction: column;
    gap: 3px;
    font-size: 10px;
    font-weight: 700;
    padding: 6px 10px;
    min-width: 56px;
    text-align: center;
    border-radius: var(--radius-md);
    color: var(--ink-500);
  }
  .mobile-nav .nav-item.active { background: var(--nav-color-soft, var(--brand-50)); color: var(--nav-color, var(--brand-600)); }
  .mobile-nav .nav-item.active::before { display: none; }
  .mobile-nav .nav-icon { width: 21px; height: 21px; margin-inline: auto; color: inherit !important; }
  .mobile-nav .nav-item.active .nav-icon { color: var(--nav-color, var(--brand-600)) !important; }

  /* الزر المركزي: دائرة بارزة فوق الشريط بتدرّج ذهبي/زمردي مميّز، يفتح
     مربّع "المزيد" بكل الأقسام — بديل عملي عن حشر كل الأقسام في شريط ضيق */
  .mobile-nav-fab {
    width: 54px; height: 54px;
    border-radius: 50%;
    border: 4px solid var(--bg-base);
    background: linear-gradient(135deg, var(--gold-300), var(--brand-500) 68%);
    color: #fdfdf6;
    display: grid; place-items: center;
    box-shadow: var(--shadow-gold-glow), var(--shadow-lg);
    transform: translateY(-16px);
    transition: transform var(--dur-fast) var(--ease-spring), box-shadow var(--dur-fast) var(--ease-out);
    justify-self: center;
  }
  .mobile-nav-fab:active { transform: translateY(-16px) scale(0.92); }
  .mobile-nav-fab-icon { width: 24px; height: 24px; display: grid; place-items: center; }
  .mobile-nav-fab-icon svg { width: 100%; height: 100%; stroke: currentColor; }

  /* ===== مربّع "المزيد": كل الأقسام بأيقونات ملوّنة، ينزلق من الأسفل ===== */
  .more-sheet-backdrop {
    position: fixed; inset: 0; z-index: 70;
    background: rgba(0, 0, 0, 0.42);
    backdrop-filter: blur(2px);
    display: flex; align-items: flex-end;
    animation: fade-in var(--dur-fast) var(--ease-out);
  }
  .more-sheet-backdrop.closing { animation: fade-in var(--dur-fast) var(--ease-out) reverse; }

  .more-sheet {
    width: 100%;
    max-height: 78vh;
    overflow-y: auto;
    background: var(--bg-elevated);
    border-radius: 26px 26px 0 0;
    padding: 10px var(--sp-5) calc(var(--sp-6) + env(safe-area-inset-bottom));
    box-shadow: var(--shadow-lg);
    animation: sheet-up var(--dur-med) var(--ease-spring);
  }
  .more-sheet-backdrop.closing .more-sheet { animation: sheet-up var(--dur-fast) var(--ease-out) reverse; }
  @keyframes sheet-up { from { transform: translateY(100%); } to { transform: translateY(0); } }

  .more-sheet-handle {
    width: 40px; height: 4px; border-radius: var(--radius-pill);
    background: var(--border-strong);
    margin: 4px auto var(--sp-4);
  }

  .more-sheet-title {
    font-family: var(--font-display);
    font-size: var(--fs-md);
    color: var(--ink-700);
    margin-bottom: var(--sp-4);
    text-align: center;
  }

  .more-sheet-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--sp-4) var(--sp-2);
  }

  .more-tile {
    display: flex; flex-direction: column; align-items: center; gap: 8px;
    text-align: center;
    padding: 4px;
    border-radius: var(--radius-md);
    transition: transform var(--dur-fast) var(--ease-spring), background var(--dur-fast);
  }
  .more-tile:active { transform: scale(0.94); background: var(--bg-sunken); }

  .more-tile-icon {
    width: 52px; height: 52px;
    border-radius: 18px;
    display: grid; place-items: center;
    font-size: 22px;
  }
  .more-tile-icon svg { width: 24px; height: 24px; stroke: currentColor; }

  .more-tile-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--ink-700);
    line-height: 1.4;
  }
}

@media (max-width: 400px) {
  .more-sheet-grid { grid-template-columns: repeat(3, 1fr); }
}
