.sidebar {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-3);
  background: var(--c-surface);
  border-right: 1px solid var(--c-border);
  z-index: var(--z-sidebar);
  overflow: hidden;
}
/* Desktop: cap the sidebar at the viewport and pin it, so the footer (Settings +
   Logout) is always at the bottom and the nav scrolls inside if it's tall.
   Scoped to desktop so it can't override the mobile off-canvas drawer
   (position: fixed) defined in layout.css, which loads earlier. */
@media (min-width: 769px) {
  .sidebar { position: sticky; top: 0; height: 100dvh; }
}

/* Header: brand mark + label + collapse toggle */
.sidebar__head {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2);
}
.sidebar__brand {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-width: 0;
  font-family: var(--font-display);
  font-weight: var(--fw-bold);
  font-size: var(--fs-lg);
  letter-spacing: -0.01em;
  color: var(--c-ink);
}
.sidebar__mark {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: var(--r-md);
  background: var(--c-ink);
  color: #fff;
  font-weight: var(--fw-bold);
  overflow: hidden;
}
.sidebar__mark:has(img) { background: transparent; }
.sidebar__mark img { width: 100%; height: 100%; object-fit: contain; display: block; }
.sidebar__mark svg { width: 1.45rem; height: 1.45rem; display: block; } /* inline Orbo glyph — inherits the mark's #fff */
.sidebar__mark--photo img { object-fit: contain; } /* show the whole photo, never crop it */
.sidebar__brand-text { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sidebar__toggle {
  flex: 0 0 auto;
  margin-left: auto;
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: var(--r-md);
  color: var(--c-ink-soft);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.sidebar__toggle:hover { background: var(--c-surface-2); color: var(--c-ink); }

/* Navigation */
.sidebar__nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar__section-label {
  padding: var(--sp-3) var(--sp-2) var(--sp-1);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--c-ink-faint);
  white-space: nowrap;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3);
  border-radius: var(--r-md);
  color: var(--c-ink-soft);
  font-weight: var(--fw-medium);
  white-space: nowrap;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.nav-item:hover { background: var(--c-surface-2); color: var(--c-ink); text-decoration: none; }
.nav-item__icon { flex: 0 0 auto; width: 1.375rem; height: 1.375rem; }
.nav-item__icon svg { width: 100%; height: 100%; stroke: currentColor; }
.nav-item__label { min-width: 0; overflow: hidden; }

/* Active state: colour + a solid left marker so it never relies on hue alone */
.nav-item[aria-current="page"] {
  background: var(--c-accent-wash);
  color: var(--c-accent-ink);
  font-weight: var(--fw-semibold);
  box-shadow: inset 3px 0 0 var(--c-accent-ink);
}

/* Live timer badge (Work item): a pulsing dot + running clock. Meaning is
   carried by the motion, the ticking time and the marker itself — not by hue. */
.nav-timer { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-xs); font-weight: var(--fw-semibold); font-variant-numeric: tabular-nums; color: var(--c-accent-ink); }
.nav-timer__dot { flex: 0 0 auto; width: 7px; height: 7px; border-radius: var(--r-full); background: var(--c-accent-ink); animation: navTimerPulse 1.4s ease-in-out infinite; }
.nav-item.has-timer[aria-current="page"] .nav-timer,
.nav-item.has-timer[aria-current="page"] .nav-timer__dot { color: var(--c-accent-ink); }
@keyframes navTimerPulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.3; transform: scale(0.6); } }
@media (prefers-reduced-motion: reduce) { .nav-timer__dot { animation: none; } }

/* Collapsed rail: hide the clock, keep the pulsing dot pinned to the icon. */
.app[data-sidebar="collapsed"] .nav-item.has-timer { position: relative; }
.app[data-sidebar="collapsed"] .nav-timer { position: absolute; top: 5px; right: 5px; margin: 0; }
.app[data-sidebar="collapsed"] .nav-timer__time { display: none; }
@media (max-width: 768px) {
  .app[data-sidebar="collapsed"] .nav-timer { position: static; margin-left: auto; }
  .app[data-sidebar="collapsed"] .nav-timer__time { display: revert; }
}

.sidebar__foot { flex: 0 0 auto; margin-top: auto; padding-top: var(--sp-2); border-top: 1px solid var(--c-border); }

/* Footer action rail: 4 icon-only controls (toggle · theme · settings · logout).
   Wraps on the collapsed rail so the icons stack instead of overflowing. */
.sidebar__actions { display: flex; flex-wrap: wrap; justify-content: space-evenly; align-items: center; gap: var(--sp-1); }
.sidebar__act { flex: 0 0 auto; display: grid; place-items: center; width: 2.25rem; height: 2.25rem; border-radius: var(--r-md); color: var(--c-ink-soft); transition: background var(--dur) var(--ease), color var(--dur) var(--ease); }
.sidebar__act:hover { background: var(--c-surface-2); color: var(--c-ink); text-decoration: none; }
.sidebar__act svg { width: 1.2rem; height: 1.2rem; stroke: currentColor; }
.sidebar__act[aria-current="page"] { color: var(--c-accent-ink); background: var(--c-accent-wash); }

/* Collapsed rail: hide text, centre the icons */
.app[data-sidebar="collapsed"] .sidebar__brand-text,
.app[data-sidebar="collapsed"] .sidebar__section-label,
.app[data-sidebar="collapsed"] .nav-item__label { display: none; }

.app[data-sidebar="collapsed"] .sidebar__head { justify-content: center; }
.app[data-sidebar="collapsed"] .sidebar__toggle { margin-left: 0; }
.app[data-sidebar="collapsed"] .nav-item { justify-content: center; padding-inline: var(--sp-2); }

/* On mobile the drawer is always full-width when open, never a rail. */
@media (max-width: 768px) {
  .app[data-sidebar="collapsed"] .sidebar__brand-text,
  .app[data-sidebar="collapsed"] .sidebar__section-label,
  .app[data-sidebar="collapsed"] .nav-item__label { display: revert; }
  .app[data-sidebar="collapsed"] .nav-item { justify-content: flex-start; padding-inline: var(--sp-3); }
}

/* Collapsed rail: drop the brand so only the (expand) toggle sits in the head. */
.app[data-sidebar="collapsed"] .sidebar__brand { display: none; }

/* Scrollable middle region so a long menu never pushes the footer off-screen. */
.sidebar__scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

/* Subtle, rounded scrollbar — invisible until the sidebar is hovered.
   Firefox uses scrollbar-color; WebKit uses the pseudo-elements below. The
   transparent border + content-box clip makes the thumb read as a thin pill. */
.sidebar__scroll { scrollbar-width: thin; scrollbar-color: transparent transparent; }
.sidebar:hover .sidebar__scroll { scrollbar-color: var(--c-border-strong) transparent; }
.sidebar__scroll::-webkit-scrollbar { width: 8px; }
.sidebar__scroll::-webkit-scrollbar-track { background: transparent; }
.sidebar__scroll::-webkit-scrollbar-thumb { background: transparent; border: 2px solid transparent; border-radius: var(--r-full); background-clip: content-box; transition: background var(--dur) var(--ease); }
.sidebar:hover .sidebar__scroll::-webkit-scrollbar-thumb { background: var(--c-border-strong); background-clip: content-box; }
.sidebar__scroll::-webkit-scrollbar-thumb:hover { background: var(--c-ink-faint); background-clip: content-box; }

/* ---- Flyout submenus (open to the side on hover, WordPress-style) ---- */
.nav-item-wrap { position: relative; }
.nav-item__caret { margin-left: auto; display: inline-grid; place-items: center; color: var(--c-ink-faint); opacity: 0.7; }
.nav-item__caret svg { width: 0.8rem; height: 0.8rem; }
.app[data-sidebar="collapsed"] .nav-item__caret { display: none; }

.nav-flyout {
  position: fixed; z-index: 60; min-width: 12.5rem; max-height: 80vh; overflow-y: auto;
  padding: var(--sp-2); background: var(--c-surface);
  border: 1px solid var(--c-border); border-radius: var(--r-md);
  box-shadow: 0 14px 34px -14px rgba(20,21,26,0.4);
  opacity: 0; visibility: hidden; transform: translateX(-6px);
  transition: opacity 0.12s var(--ease), transform 0.12s var(--ease), visibility 0.12s var(--ease);
}
.nav-flyout::before { content: ""; position: absolute; top: 0; left: -12px; width: 12px; height: 100%; } /* hover bridge across the gap */
.nav-item-wrap.has-sub:hover .nav-flyout, .nav-flyout:hover { opacity: 1; visibility: visible; transform: none; }
.nav-flyout__title { padding: var(--sp-1) var(--sp-2) var(--sp-2); font-size: var(--fs-xs); font-weight: var(--fw-semibold); text-transform: uppercase; letter-spacing: var(--tracking-label); color: var(--c-ink-faint); }
.nav-flyout__link { display: block; padding: var(--sp-2); border-radius: var(--r-sm); font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--c-ink-soft); white-space: nowrap; }
.nav-flyout__link:hover { background: var(--c-surface-2); color: var(--c-ink); text-decoration: none; }
.nav-flyout__link[aria-current="page"] { color: var(--c-accent-ink); background: var(--c-accent-wash); }

/* When the timer badge is present, it takes the flexible space (sits mid-right)
   and the caret follows it at the very end. */
.nav-item.has-timer .nav-item__caret { margin-left: var(--sp-2); }

/* Theme toggle (sun/moon) in the header, sits just left of the collapse toggle */
.sidebar__theme { flex: 0 0 auto; margin-left: auto; display: grid; place-items: center; width: 2.25rem; height: 2.25rem; border-radius: var(--r-md); color: var(--c-ink-soft); transition: background var(--dur) var(--ease), color var(--dur) var(--ease); }
.sidebar__theme:hover { background: var(--c-surface-2); color: var(--c-ink); }
.sidebar__theme svg { width: 1.15rem; height: 1.15rem; }
.sidebar__toggle { margin-left: 4px; }
/* On the collapsed desktop rail there's only room for the expand toggle. */
.app[data-sidebar="collapsed"] .sidebar__theme { display: none; }
@media (max-width: 768px) { .app[data-sidebar="collapsed"] .sidebar__theme { display: grid; margin-left: auto; } }
