/* V3.6: a fixed icon spine with independently revealed text.
   All desktop/tablet rows retain the same coordinates while the shell widens. */
.rail-toggle {
  display: grid; place-items: center; flex: 0 0 auto;
  width: 28px; height: 32px; padding: 5px; border: 0;
  color: var(--glass-ink); background: transparent;
}
.rail-toggle:hover { background: var(--glass-hover); }
.rail-toggle svg,
.rail-compact-actions svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.rail-compact-actions { display: none; }
.sidebar-scrim { position: fixed; inset: 0; z-index: 40; padding: 0; border: 0; border-radius: 0; background: rgba(8, 20, 13, .22); }

@media (min-width: 651px) {
  .side-rail { --rail-width: var(--sidebar); padding: 20px 14px 14px; }
  html[data-sidebar-mode="collapsed"] { --sidebar: 72px; }
  .side-rail .rail-brand-row { position: relative; display: block; height: 76px; flex: 0 0 76px; }
  .rail-brand-row .rail-brand {
    position: absolute; left: 5px; top: 0; display: flex;
    justify-content: flex-start; align-items: center;
    width: calc(100% - 33px); min-width: 32px; height: 32px;
    gap: 8px; margin: 0; padding: 0;
  }
  .rail-brand-row .rail-brand img { width: 32px; height: 32px; flex-shrink: 0; }
  .side-rail .rail-brand > span { position: absolute; left: 40px; top: 0; display: block; width: 110px; pointer-events: none; }
  .rail-brand-row .rail-brand b { font-size: 15px; line-height: 20px; white-space: nowrap; }
  .rail-brand-row .rail-brand small { font-size: 9px; line-height: 12px; margin-top: 1px; white-space: nowrap; }
  /* Keep the control on the icon spine in every sidebar state. */
  .rail-toggle { position: absolute; left: 0; top: 0; z-index: 3; transform: translate(7px, 40px); }
  html[data-sidebar-mode="collapsed"] .rail-toggle svg { transform: rotate(180deg); }

  .side-rail .rail-caption {
    display: block; flex: 0 0 20px; height: 20px; line-height: 20px;
    padding: 0 8px; white-space: nowrap;
  }
  .side-rail .rail-nav {
    display: flex; flex-direction: column; gap: 6px; margin-top: 0;
    min-height: 0; overflow-x: hidden; overflow-y: auto; scrollbar-width: thin;
  }
  .side-rail .nav-item {
    position: relative; display: block; flex: 0 0 44px;
    width: 100%; min-width: 0; min-height: 44px; height: 44px;
    padding: 0; text-align: left; font-size: 13px;
  }
  .side-rail .nav-item svg {
    position: absolute; left: 11px; top: 50%;
    width: 19px; height: 19px; transform: translateY(-50%);
  }
  .side-rail .nav-item:focus-visible { outline-offset: -3px; }
  .side-rail .nav-item > span {
    position: absolute; left: 40px; top: 0; display: block;
    width: max-content; max-width: 124px; height: 42px; line-height: 42px;
    white-space: nowrap; pointer-events: none;
  }

  /* A reserved footer slot prevents utility groups from shifting the nav. */
  .side-rail .rail-footer { position: relative; flex: 0 0 174px; height: 174px; min-height: 174px; margin-top: auto; }
  .side-rail .rail-bottom {
    position: absolute; left: 0; right: 0; bottom: 0;
    display: block; min-width: 144px; margin: 0; padding: 18px 8px 0;
    white-space: nowrap;
  }
  .side-rail .rail-compact-actions {
    position: absolute; left: 0; bottom: 0; display: flex;
    flex-direction: column; align-items: center; gap: 4px;
    width: 42px; margin: 0; padding-top: 18px;
    opacity: 0; visibility: hidden; pointer-events: none; transform: translateY(4px);
  }
  .rail-compact-actions > * {
    display: grid; place-items: center; width: 42px; height: 44px;
    padding: 0; border: 0; border-radius: 7px; background: transparent;
    color: var(--glass-muted); text-decoration: none;
  }
  .rail-compact-actions > *:hover { color: var(--glass-ink); background: var(--glass-hover); }

  .side-rail .rail-brand > span,
  .side-rail .rail-caption,
  .side-rail .nav-item > span,
  .side-rail .rail-bottom { opacity: 1; visibility: visible; transform: translateX(0); }
  html[data-sidebar-mode="collapsed"] .rail-brand > span,
  html[data-sidebar-mode="collapsed"] .rail-caption,
  html[data-sidebar-mode="collapsed"] .nav-item > span,
  html[data-sidebar-mode="collapsed"] .rail-bottom {
    opacity: 0; visibility: hidden; pointer-events: none; transform: translateX(-6px);
  }
  html[data-sidebar-mode="collapsed"] .rail-compact-actions { opacity: 1; visibility: visible; pointer-events: auto; transform: translateY(0); }

  /* Enter after the shell has made room; exit quickly with no waiting.
     These are transitions, not queued keyframes, so a reversal is continuous. */
  html[data-sidebar-motion="ready"] .rail-brand > span,
  html[data-sidebar-motion="ready"] .rail-caption,
  html[data-sidebar-motion="ready"] .nav-item > span,
  html[data-sidebar-motion="ready"] .rail-bottom {
    transition: opacity 180ms ease 110ms, transform 220ms var(--rail-motion-ease) 80ms, visibility 0s linear 0s;
  }
  html[data-sidebar-motion="ready"][data-sidebar-mode="collapsed"] .rail-brand > span,
  html[data-sidebar-motion="ready"][data-sidebar-mode="collapsed"] .rail-caption,
  html[data-sidebar-motion="ready"][data-sidebar-mode="collapsed"] .nav-item > span,
  html[data-sidebar-motion="ready"][data-sidebar-mode="collapsed"] .rail-bottom {
    transition: opacity 90ms ease, transform 150ms var(--rail-motion-ease), visibility 0s linear 100ms;
  }
  html[data-sidebar-motion="ready"] .rail-compact-actions {
    transition: opacity 100ms ease, transform 150ms var(--rail-motion-ease), visibility 0s linear 100ms;
  }
  html[data-sidebar-motion="ready"][data-sidebar-mode="collapsed"] .rail-compact-actions {
    transition: opacity 150ms ease 110ms, transform 200ms var(--rail-motion-ease) 80ms, visibility 0s linear;
  }
  .side-rail .rail-bottom:focus-within,
  .side-rail .rail-compact-actions:focus-within { opacity: 1; visibility: visible; transform: none; transition: none !important; }
}

/* V9.2.5: give the expanded rail a clearer brand block and more legible nav.
   The floating control keeps its existing geometry and remains untouched. */
@media (min-width: 651px) {
  .rail-brand-row .rail-brand {
    width: calc(100% - 12px);
    gap: 10px;
  }
  .rail-brand-row .rail-brand img {
    width: 40px;
    height: 40px;
  }
  .side-rail .rail-brand > span {
    left: 52px;
    width: 116px;
  }
  .rail-brand-row .rail-brand b {
    font-size: 18px;
    line-height: 23px;
    letter-spacing: .01em;
  }
  .rail-brand-row .rail-brand small {
    font-size: 11px;
    line-height: 15px;
    margin-top: 2px;
  }
  .side-rail .rail-caption {
    flex-basis: 30px;
    height: 30px;
    padding: 0 10px;
    line-height: 30px;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: .02em;
    color: var(--glass-ink);
  }
  .side-rail .rail-nav { gap: 8px; }
  .side-rail .nav-item {
    flex-basis: 48px;
    min-height: 48px;
    height: 48px;
    font-size: 15px;
  }
  .side-rail .nav-item > span { height: 46px; line-height: 46px; }
}

@media (min-width: 651px) and (max-width: 1250px) {
  .side-rail .rail-brand > span { width: 104px; }
  .rail-brand-row .rail-brand b { font-size: 17px; }
  .rail-brand-row .rail-brand small { font-size: 10px; }
}

@media (min-width: 981px) {
  html[data-sidebar-mode="collapsed"] .main-content { margin-left: calc(var(--sidebar) + 40px); }
}
@media (min-width: 981px) and (max-width: 1250px) {
  html[data-sidebar-mode="collapsed"] .main-content { margin-left: calc(var(--sidebar) + 36px); }
}
@media (min-width: 1900px) {
  html[data-sidebar-mode="collapsed"] .main-content { margin-left: calc(var(--sidebar) + 56px); }
}
@media (min-width: 651px) and (max-width: 980px) {
  .rail-toggle { width: 44px; height: 44px; transform: translate(-1px, 40px); }
  .side-rail .rail-brand-row { height: 88px; flex-basis: 88px; }
  html[data-sidebar-mode="overlay"] .side-rail { --rail-width: 204px; z-index: 50; width: 204px; }
  html[data-sidebar-mode="overlay"] .main-content { margin-left: 108px; }
}
@media (max-width: 650px) {
  .rail-brand-row,
  .rail-footer,
  .rail-compact-actions,
  .sidebar-scrim { display: none; }
}
/* On a short landscape screen, let the whole fixed shell scroll instead of
   letting fixed header/footer slots squeeze the navigation down to zero. */
@media (min-width: 651px) and (max-height: 560px) {
  .side-rail { overflow-y: auto; scrollbar-width: thin; }
  .side-rail .rail-nav { flex: 0 0 auto; min-height: 244px; overflow: visible; }
}
@media (prefers-reduced-motion: reduce) {
  .side-rail .rail-brand > span,
  .side-rail .rail-caption,
  .side-rail .nav-item > span,
  .side-rail .rail-bottom,
  .side-rail .rail-compact-actions { transition: none !important; }
}
