.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: 100%;
  height: 100vh;
  height: 100dvh;
  background: var(--bg);
}

.shell-scrim {
  display: none;
}

/* ---------- Sidebar ---------- */
.sidebar {
  grid-column: 1;
  height: 100%;
  overflow-y: auto;
  scrollbar-gutter: stable;
  padding: 0 var(--space-5);
  /* Longhand rather than folded into the shorthand above: this is the sidebar's
     only padding-top/bottom declaration, on both the desktop static column and
     the mobile fixed drawer (see the 900px block), so it has to already include
     --safe-top/--safe-bottom rather than relying on a breakpoint to add it. */
  padding-top: calc(var(--space-6) + var(--safe-top));
  padding-bottom: calc(var(--space-6) + var(--safe-bottom));
  border-inline-end: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: transform var(--dur-slow) var(--ease-out);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0 var(--space-3) var(--space-5);
  margin-bottom: var(--space-4);
  border-bottom: 1px solid var(--border);
}

.sidebar-brand__mark {
  color: var(--accent);
}

.sidebar-brand__name {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: var(--text-lg);
  letter-spacing: -0.01em;
}

.sidebar-section {
  margin-bottom: var(--space-4);
}

.sidebar-section + .sidebar-section {
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
}

.sidebar-label {
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
  text-transform: uppercase;
  padding: 0 var(--space-3);
  margin-bottom: var(--space-2);
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 10px var(--space-3);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-weight: 500;
  font-size: var(--text-base);
  position: relative;
  transition: color var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out);
}

.nav-link svg {
  color: var(--text-tertiary);
  transition: color var(--dur-fast) var(--ease-out);
}

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

.nav-link:hover svg {
  color: var(--text-primary);
}

.nav-link.is-active {
  color: var(--accent);
  background: var(--accent-dim);
}

.nav-link.is-active svg {
  color: var(--accent);
}

.nav-link.is-active::before {
  content: '';
  position: absolute;
  inset-inline-start: -20px;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 60%;
  background: var(--accent);
  border-radius: var(--radius-full);
}

.nav-link .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
}

/* ---------- Content column ---------- */
.content-col {
  grid-column: 2;
  height: 100%;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  flex: 0 0 auto;
  /* min-height, not height: a fixed height combined with the safe-top padding
     below would compress the search input and buttons into whatever room was
     left over instead of growing the bar to fit both. */
  min-height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: var(--space-5);
  padding: var(--safe-top) calc(var(--space-8) + var(--safe-right)) 0 calc(var(--space-8) + var(--safe-left));
  border-bottom: 1px solid var(--border);
  justify-content: space-between;
}

.icon-btn.menu-toggle {
  display: none;
  position: relative;
  z-index: calc(var(--z-overlay) + 1);
}

.search-form {
  flex: 1 1 auto;
  max-width: 640px;
  position: relative;
}

.search-input {
  width: 100%;
  height: 48px;
  border-radius: var(--radius-md);
  background: var(--surface-2);
  border: 1px solid transparent;
  padding-inline-start: 44px;
  padding-inline-end: var(--space-4);
  color: var(--text-primary);
  transition: border-color var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out);
}

.search-input::placeholder {
  color: var(--text-tertiary);
}

.search-input:focus {
  outline: none;
  border-color: var(--border-accent);
  background: var(--surface-3);
}

.search-form__icon {
  position: absolute;
  inset-inline-start: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
  pointer-events: none;
}

.topbar-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.topbar-account {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 8px 14px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: var(--text-sm);
  font-weight: 600;
  flex-shrink: 0;
  max-width: 180px;
  transition: background var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
}

.topbar-account:hover {
  background: var(--surface-2);
  border-color: var(--border-strong);
}

.topbar-account svg {
  flex-shrink: 0;
  color: var(--text-secondary);
}

.topbar-account span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.body-row {
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
}

.main-scroll {
  flex: 1 1 auto;
  min-width: 0;
  overflow-y: auto;
  scrollbar-gutter: stable;
  padding: var(--space-6) var(--space-8) var(--space-10);
}

.right-rail {
  flex: 0 0 var(--rightrail-w);
  width: var(--rightrail-w);
  border-inline-start: 1px solid var(--border);
  overflow-y: auto;
  scrollbar-gutter: stable;
  padding: var(--space-6) var(--space-6) var(--space-10);
}

.right-rail[hidden] {
  display: none;
}

/* padding-bottom is a single value, not additive — this replaces the sidebar's
   base safe-bottom padding entirely, so --player-clearance (which already
   includes --safe-bottom) has to be repeated here rather than assumed to stack
   on top of it. */
body.has-player .main-scroll,
body.has-player .right-rail,
body.has-player .sidebar {
  padding-bottom: var(--player-clearance);
}

/* ---------- Responsive ---------- */
@media (max-width: 1280px) {
  .right-rail {
    display: none !important;
  }
}

@media (max-width: 900px) {
  :root {
    --sidebar-w: 260px;
  }
  .app-shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: fixed;
    inset-block: 0;
    inset-inline-start: 0;
    width: var(--sidebar-w);
    z-index: var(--z-overlay);
    background: var(--surface);
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.is-open {
    transform: translateX(0);
  }
  .shell-scrim {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: calc(var(--z-overlay) - 1);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--dur-base) var(--ease-out);
  }
  .shell-scrim.is-visible {
    opacity: 1;
    pointer-events: auto;
  }
  .icon-btn.menu-toggle {
    display: inline-flex;
  }
  .topbar {
    padding-left: calc(var(--space-4) + var(--safe-left));
    padding-right: calc(var(--space-4) + var(--safe-right));
    gap: var(--space-3);
  }
  .main-scroll {
    padding: var(--space-4) var(--space-4) var(--space-8);
  }

  /*
   * The open drawer's own brand row (logo + "سازورو") sits directly under
   * the topbar's hamburger-turned-X close button — both render at the same
   * fixed top-right corner, so the X visibly overlapped and half-hid the logo
   * mark. The mark is the flex row's first child, which lands at the
   * inline-start edge — physically the RIGHT edge in this app's RTL-only
   * layout — so it's padding-inline-START that needs the clearance, not
   * -end (that was tried first and pushed the wrong, already-empty side).
   */
  .sidebar-brand {
    padding-inline-start: 52px;
  }
}
