.neo-layout {
  display: flex;
  min-height: 100vh;
  background: var(--bg-subtle);
  color: var(--text-primary);
}

/* RUI modal + form feedback overrides */
.modal-scrim {
  position: fixed;
  inset: 0;
  z-index: 12000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(15, 23, 42, 0.36);
  backdrop-filter: blur(2px);
}

.modal-scrim .modal {
  position: static;
  inset: auto;
  margin: 0;
  width: min(36rem, calc(100vw - 2rem));
  max-width: 100%;
  max-height: calc(100dvh - 2rem);
  overflow: auto;
  border: 1px solid var(--border-light);
  border-radius: 1rem;
  background: var(--surface);
  color: var(--text-primary);
  box-shadow: 0 26px 60px rgba(15, 23, 42, 0.3);
  padding: 1.15rem 1.2rem;
}

.modal-scrim .modal h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.modal-scrim .modal p {
  margin-top: 0.45rem;
  color: var(--text-secondary);
}

.modal-scrim .modal.modal-fullwidth {
  width: min(72rem, calc(100vw - 2rem));
}

.modal-scrim .modal::backdrop {
  background: transparent;
}

.admin-delete-form {
  margin-top: 0.95rem;
  display: grid;
  gap: 0.95rem;
}

.admin-delete-form__actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.55rem;
}

.admin-flash-stack {
  display: grid;
  gap: 0.6rem;
}

.admin-flash {
  border-radius: 0.85rem;
  border: 1px solid transparent;
  padding: 0.7rem 0.9rem;
  font-size: 0.86rem;
  line-height: 1.35;
  font-weight: 500;
}

.admin-flash--success {
  border-color: color-mix(in oklab, #22c55e 42%, var(--border-light));
  background: color-mix(in oklab, #22c55e 12%, var(--surface));
  color: color-mix(in oklab, #15803d 70%, var(--text-primary));
}

.admin-flash--error {
  border-color: color-mix(in oklab, #ef4444 42%, var(--border-light));
  background: color-mix(in oklab, #ef4444 11%, var(--surface));
  color: color-mix(in oklab, #b91c1c 72%, var(--text-primary));
}

.admin-edit-form-shell {
  margin-inline: auto;
}

.admin-edit-form-actions {
  position: static;
  padding-bottom: 0;
  background: transparent;
}

@media (width < 48rem) {
  .admin-edit-form-actions {
    position: sticky;
    bottom: 0;
    padding-bottom: 0.35rem;
    background: linear-gradient(180deg, color-mix(in oklab, var(--surface) 0%, transparent), var(--surface) 28%);
  }
}

.neo-sidebar {
  width: 15rem;
  height: 100vh;
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border-light);
  z-index: 30;
}

.neo-sidebar__brand {
  height: 3.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid var(--border-light);
}

.neo-brand-mark {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 0.7rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), color-mix(in oklab, var(--primary) 65%, #38bdf8));
}

.neo-nav {
  flex: 1;
  overflow-y: auto;
  padding: 0.65rem;
  display: grid;
  gap: 0.25rem;
}

.neo-nav__item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  border-radius: 0.7rem;
  padding: 0.55rem 0.6rem;
  color: var(--text-secondary);
  border: 1px solid transparent;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.neo-nav__item:hover {
  background: var(--hover-bg);
  color: var(--text-primary);
}

.neo-nav__item.is-active {
  background: color-mix(in oklab, var(--primary-subtle) 75%, var(--surface));
  color: var(--text-primary);
  border-color: color-mix(in oklab, var(--primary) 20%, var(--border-light));
}

.neo-nav__icon {
  width: 1.05rem;
  height: 1.05rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.neo-nav__icon>svg {
  width: 1.05rem;
  height: 1.05rem;
}

.neo-nav__label {
  white-space: nowrap;
  font-size: 0.85rem;
  font-weight: 500;
}

.neo-sidebar__footer {
  border-top: 1px solid var(--border-light);
  padding: 0.6rem;
}

.neo-user-chip {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  border-radius: 0.8rem;
  padding: 0.45rem;
  transition: background-color 0.15s ease;
}

.neo-user-chip:hover {
  background: var(--hover-bg);
}

.neo-user-chip__initial {
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-primary);
  background: color-mix(in oklab, var(--primary) 18%, var(--surface));
}

.neo-user-chip__meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.neo-user-chip__name,
.neo-user-chip__email {
  display: block;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.neo-user-chip__name {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--text-primary);
}

.neo-user-chip__email {
  font-size: 0.68rem;
  color: var(--text-muted);
}

.neo-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.neo-topbar {
  position: sticky;
  top: 0;
  z-index: 25;
  height: 3.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 1rem;
  background: color-mix(in oklab, var(--surface) 92%, var(--bg-subtle));
  border-bottom: 1px solid var(--border-light);
}

.neo-topbar__left,
.neo-topbar__right {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
}

.neo-icon-btn {
  width: 2rem;
  height: 2rem;
  border-radius: 0.55rem;
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.neo-icon-btn:hover {
  color: var(--text-primary);
  background: var(--hover-bg);
}

.neo-icon-btn>svg {
  width: 1rem;
  height: 1rem;
}

.neo-workspace {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
  max-width: 10rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.neo-tenant-select-wrap {
  border: 1px solid var(--border-light);
  border-radius: 0.55rem;
  background: var(--surface);
  padding: 0 0.35rem;
}

.neo-tenant-select {
  height: 1.85rem;
  min-width: 7rem;
  font-size: 0.74rem;
  color: var(--text-primary);
}

.neo-env-pill {
  border: 1px solid color-mix(in oklab, #d97706 35%, var(--border-light));
  background: color-mix(in oklab, #f59e0b 16%, var(--surface));
  color: #b45309;
  border-radius: 999px;
  font-size: 0.63rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 0.2rem 0.55rem;
  text-transform: uppercase;
}

:root[data-theme="dark"] .neo-env-pill,
.dark .neo-env-pill {
  color: #fbbf24;
}

.neo-search-chip {
  border: 1px solid var(--border-light);
  border-radius: 999px;
  padding: 0.33rem 0.7rem;
  color: var(--text-secondary);
  font-size: 0.74rem;
}

.neo-user-badge {
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
}

.neo-main__content {
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow: auto;
}

.neo-main__inner {
  padding-top: 1.15rem;
  padding-bottom: 1.15rem;
}

.neo-anon-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: radial-gradient(circle at 16% 12%, color-mix(in oklab, var(--primary) 8%, var(--bg-subtle)) 0%, var(--bg-subtle) 38%) fixed;
}

.neo-anon-main {
  flex: 1;
}

@media (max-width: 1024px) {
  .neo-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    box-shadow: 0 22px 48px color-mix(in oklab, var(--text-primary) 18%, transparent);
  }

  body.neo-sidebar-open .neo-sidebar {
    transform: translateX(0);
  }

  .neo-workspace,
  .neo-env-pill {
    display: none;
  }
}

/* App shell styles moved from templates */
:root {
  --app-shell-blue: var(--primary, #1e2c47);
  --app-shell-blue-hover: var(--primary-light, #2d3c59);
  --app-shell-blue-active: var(--primary-lighter, #3a4a6b);
  --app-sidebar-bg: #111b2d;
  --app-sidebar-panel-bg: #1a2840;
  --app-sidebar-border: rgba(255, 255, 255, 0.14);
  --app-sidebar-muted-border: rgba(255, 255, 255, 0.1);
  --app-shell-fg: #e8eefc;
  --app-shell-muted: rgba(232, 238, 252, 0.7);
  --app-shell-hover-bg: #253753;
  --app-shell-active-bg: #2d4262;
  --app-shell-accent: #93b1ff;
  --app-sidebar-width: 248px;
  --app-sidebar-collapsed-width: 72px;
  --app-thread-visible-count: 5;
  --app-thread-item-height: 2.02rem;
  --app-thread-gap: 0.08rem;
}

.hamburger-line-top,
.hamburger-line-mid,
.hamburger-line-bot {
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
  transform-origin: center;
}

#sidebarToggle[aria-expanded="false"] .hamburger-line-top {
  transform: translateY(6px) rotate(45deg);
}

#sidebarToggle[aria-expanded="false"] .hamburger-line-mid {
  opacity: 0;
  transform: scaleX(0);
}

#sidebarToggle[aria-expanded="false"] .hamburger-line-bot {
  transform: translateY(-6px) rotate(-45deg);
}

#sidebarToggle .toggle-arrow-open {
  display: block;
}

#sidebarToggle .toggle-arrow-closed {
  display: none;
}

/* Icon shows action: collapse when open, expand when closed */
#sidebarToggle[aria-expanded="true"] .toggle-arrow-open {
  display: none;
}

#sidebarToggle[aria-expanded="true"] .toggle-arrow-closed {
  display: block;
}

.theme-button {
  height: 2.25rem;
  width: 2.25rem;
  border-radius: 0.75rem;
  border: 1px solid var(--border-light);
  background: var(--surface);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.theme-button:hover {
  background: var(--hover-bg);
  color: var(--text-primary);
}

.theme-button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px color-mix(in oklab, var(--primary) 30%, transparent);
}

.theme-button svg {
  width: 1.05rem;
  height: 1.05rem;
}

.neo-select {
  position: relative;
  display: inline-block;
}

.neo-select--full {
  display: block;
  width: 100%;
}

.neo-select__btn {
  width: auto;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  border: 1px solid var(--border-light);
  border-radius: 0.85rem;
  background: var(--surface);
  color: var(--text-primary);
  padding: 0.42rem 0.6rem;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.neo-select--full .neo-select__btn {
  width: 100%;
}

.neo-select--compact .neo-select__btn {
  padding: 0.42rem 0.55rem;
}

.neo-select__btn:hover {
  background: var(--hover-bg);
}

.neo-select__btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px color-mix(in oklab, var(--primary) 30%, transparent);
}

.neo-select__left {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
}

.neo-select__right {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

.neo-select__icon {
  width: 1rem;
  height: 1rem;
  opacity: 0.85;
}

.neo-select__label {
  font-size: 0.85rem;
  line-height: 1.1rem;
  color: var(--text-secondary);
}

.neo-select__value {
  font-size: 0.85rem;
  line-height: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.neo-select__chev {
  width: 1rem;
  height: 1rem;
  opacity: 0.7;
}

.neo-select__menu {
  position: absolute;
  right: 0;
  top: calc(100% + 0.45rem);
  min-width: 11.5rem;
  border: 1px solid var(--border-light);
  background: var(--surface);
  border-radius: 0.95rem;
  padding: 0.35rem;
  box-shadow: 0 20px 55px rgba(0, 0, 0, 0.14);
  z-index: 70;
}

.neo-select__option {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.5rem 0.6rem;
  border-radius: 0.75rem;
  font-size: 0.85rem;
  line-height: 1.1rem;
  color: var(--text-primary);
  background: transparent;
  border: 0;
  text-align: left;
}

.neo-select__option:hover {
  background: var(--hover-bg);
}

.neo-select__option[aria-checked="true"] {
  background: color-mix(in oklab, var(--primary) 10%, var(--surface));
  font-weight: 600;
}

.neo-select__check {
  width: 1rem;
  height: 1rem;
  opacity: 0;
}

.neo-select__option[aria-checked="true"] .neo-select__check {
  opacity: 1;
}

.app-header {
  background: var(--primary-dark);
  color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.app-header .app-icon-btn {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.08);
}

.app-header .app-icon-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.15);
}

.app-header .app-header__divider {
  width: 1px;
  height: 20px;
  background: rgba(255, 255, 255, 0.24);
}

.app-header .text-secondary,
.app-header .text-primary {
  color: rgba(255, 255, 255, 0.95);
}

.app-header .app-header__left a {
  color: rgba(255, 255, 255, 0.95);
}

.app-header .app-header__left a:hover {
  color: #fff;
}

.app-user-btn {
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.26);
  color: #fff;
}

.app-user-btn:hover {
  background: rgba(255, 255, 255, 0.22);
}

.app-search {
  height: 2.25rem;
  min-width: 14rem;
  max-width: 18rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.1);
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0 0.7rem;
}

.app-search svg {
  width: 0.95rem;
  height: 0.95rem;
  color: rgba(255, 255, 255, 0.84);
  flex-shrink: 0;
}

.app-search input {
  width: 100%;
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 0.82rem;
  line-height: 1.1rem;
  outline: none;
}

.app-search input::placeholder {
  color: rgba(255, 255, 255, 0.72);
}

#appUserDropdown {
  background: var(--surface);
  border: 1px solid var(--border-light);
  color: var(--text-primary);
}

#appUserDropdown a,
#appUserDropdown p,
#appUserDropdown .text-primary {
  color: var(--text-primary);
}

#appUserDropdown .text-secondary {
  color: var(--text-secondary);
}

#appUserDropdown a:hover {
  background: var(--hover-bg);
  color: var(--text-primary);
}

.app-shell-main {
  min-height: 100vh;
}

#primary-aside.sidebar-shell {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--app-sidebar-width);
  display: flex;
  flex-direction: column;
  background: var(--app-sidebar-bg);
  color: var(--app-shell-fg);
  border-right: 1px solid var(--app-sidebar-border);
  transform: translateX(-100%);
  transition: width 0.2s ease, transform 0.2s ease;
  z-index: 40;
  box-shadow: none;
}

#primary-aside .sidebar-shell__header {
  padding: 0.7rem 0.65rem;
  border-bottom: 0;
  height: 4rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

#primary-aside .sidebar-brand {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.75rem;
  border-radius: 0.62rem;
  padding: 0.5rem;
  color: inherit;
  text-align: left;
  transition: background-color 0.15s ease;
}

#primary-aside .sidebar-brand__meta {
  opacity: 1;
  max-width: 14rem;
  transform: translateX(0);
  transition: opacity 0.18s ease, transform 0.18s ease, max-width 0.22s ease;
  will-change: opacity, transform, max-width;
  overflow: hidden;
}

#primary-aside .sidebar-brand:hover {
  background: var(--app-shell-hover-bg);
}

#primary-aside .sidebar-brand__mark {
  width: 2.45rem;
  height: 2.45rem;
  border-radius: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: transparent;
  border: 0;
  flex-shrink: 0;
}

#primary-aside .sidebar-brand__logo {
  width: 1.72rem;
  height: 1.72rem;
  display: block;
  filter: none;
  animation: none;
  margin-right: auto;
}

#primary-aside .sidebar-brand__meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

#primary-aside .sidebar-brand__title {
  font-size: 0.875rem;
  line-height: 1.1rem;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#primary-aside .sidebar-brand__sub {
  font-size: 0.75rem;
  line-height: 1rem;
  color: var(--app-shell-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#primary-aside .sidebar-shell__scroll {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.62rem 0.62rem 0.54rem;
}

#primary-aside .sidebar-shell__scroll::-webkit-scrollbar {
  width: 6px;
}

#primary-aside .sidebar-shell__scroll::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.22);
  border-radius: 999px;
}

#primary-aside .sidebar-section {
  margin-bottom: 0.94rem;
}

#primary-aside .sidebar-section+.sidebar-section {
  margin-top: 0;
}

#primary-aside .sidebar-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin: 0 0 0.3rem;
  padding: 0 0.5rem;
  min-height: 1rem;
}

#primary-aside .sidebar-section-title {
  display: block;
  font-size: 0.68rem;
  line-height: 1rem;
  letter-spacing: 0.09em;
  font-weight: 700;
  text-transform: uppercase;
  color: rgba(232, 238, 252, 0.64);
  margin: 0;
  padding: 0;
}

#primary-aside .sidebar-section-pill {
  min-width: auto;
  height: auto;
  border-radius: 999px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.69rem;
  line-height: 1rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: rgba(232, 238, 252, 0.56);
  background: transparent;
  border: 0;
}

#primary-aside .sidebar-section-caption {
  margin: 0 0 0.35rem;
  padding: 0 0.48rem;
  display: block;
  font-size: 0.74rem;
  line-height: 1rem;
  color: rgba(232, 238, 252, 0.48);
}

#primary-aside .sidebar-section--top {
  margin-bottom: 0.98rem;
  padding-bottom: 0;
  border-bottom: 0;
}

#primary-aside .sidebar-section--threads {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin-bottom: 0;
}

#primary-aside .sidebar-section--admin {
  margin-top: auto;
  margin-bottom: 0;
  padding-top: 0.75rem !important;
}

#primary-aside .sidebar-section--admin .sidebar-section-head {
  margin-bottom: 0.14rem;
  padding-top: 0.08rem;
}

#primary-aside .sidebar-section--admin .sidebar-section-title {
  letter-spacing: 0.06em;
  line-height: 0.9rem;
}

#primary-aside .sidebar-section--admin .sidebar-list {
  gap: 0.08rem !important;
}

#primary-aside .sidebar-section--admin .sidebar-link {
  padding: 0.3rem 0.2rem !important;
  margin-left: 0.2rem !important;
}

#primary-aside.sidebar-shell:not(.is-collapsed) .sidebar-section--agents,
#primary-aside.sidebar-shell:not(.is-collapsed) .sidebar-section--threads,
#primary-aside.sidebar-shell:not(.is-collapsed) .sidebar-section--admin,
#primary-aside.sidebar-shell.hover-expanded .sidebar-section--agents,
#primary-aside.sidebar-shell.hover-expanded .sidebar-section--threads,
#primary-aside.sidebar-shell.hover-expanded .sidebar-section--admin {
  border-radius: 0;
  border: 0;
  background: transparent;
  padding: 0;
}

#primary-aside .sidebar-section--threads::before,
#primary-aside .sidebar-section--threads::after {
  content: none;
  position: absolute;
  left: 0.48rem;
  right: 0.48rem;
  height: 0.9rem;
  pointer-events: none;
  opacity: 0;
}

#primary-aside .sidebar-section--threads::before {
  top: 2.2rem;
  background: linear-gradient(to bottom, var(--app-sidebar-panel-bg), rgba(26, 40, 64, 0));
}

#primary-aside .sidebar-section--threads::after {
  bottom: 1.42rem;
  background: linear-gradient(to top, var(--app-sidebar-panel-bg), rgba(26, 40, 64, 0));
}

#primary-aside .sidebar-section--threads.is-scrollable:not(.is-at-top)::before {
  opacity: 1;
}

#primary-aside .sidebar-section--threads.is-scrollable:not(.is-at-bottom)::after {
  opacity: 1;
}

#primary-aside .sidebar-list {
  display: grid;
  gap: 0.16rem;
  min-width: 0;
}

#primary-aside .sidebar-list--top {
  gap: 0.1rem;
}

#primary-aside .sidebar-list--threads {
  gap: 0;
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 0.08rem;
  scroll-padding-top: 0.2rem;
  scrollbar-gutter: stable;
  overscroll-behavior: contain;
}

#primary-aside .sidebar-inline-group {
  display: grid;
  gap: 0.2rem;
}

#primary-aside .sidebar-inline-group+.sidebar-inline-group {
  margin-top: 0.68rem;
  padding-top: 0.64rem;
  border-top: 1px solid var(--app-sidebar-muted-border);
}

#primary-aside .sidebar-inline-group__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin: 0 0 0.16rem;
  padding: 0 0.48rem;
  min-height: 1rem;
}

#primary-aside .sidebar-inline-group__list {
  display: grid;
  gap: var(--app-thread-gap);
}

#primary-aside .sidebar-list--threads::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}

#primary-aside .sidebar-list--threads::-webkit-scrollbar-track {
  background: transparent;
}

#primary-aside .sidebar-list--threads::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.28);
  border-radius: 999px;
}

#primary-aside .sidebar-link {
  display: flex;
  align-items: center;
  position: relative;
  gap: 0.62rem;
  border-radius: 0.58rem;
  padding: 0.43rem 0.56rem;
  border: 0 !important;
  border-left: 0 !important;
  color: rgba(232, 238, 252, 0.94) !important;
  background: transparent !important;
  font-size: 0.88rem;
  line-height: 1.2rem;
  transition: background-color 0.15s ease, color 0.15s ease;
  min-height: 2rem;
}

#primary-aside .sidebar-link:hover {
  background: var(--app-shell-hover-bg) !important;
  color: #fff !important;
}

#primary-aside .sidebar-link--action {
  min-height: 2.12rem;
  font-size: 0.93rem;
}

#primary-aside .sidebar-link--action .sidebar-icon-wrap {
  width: 1.2rem;
  height: 1.2rem;
}

#primary-aside .sidebar-link--text {
  min-height: 1.72rem;
  height: auto;
  padding: 0.24rem 0.42rem;
  border-radius: 0.46rem;
}

#primary-aside .sidebar-link--text .sidebar-label-wrap {
  justify-content: flex-start;
}

#primary-aside .sidebar-link--text .sidebar-link-label {
  font-size: 0.86rem;
  line-height: 1.08rem;
  font-weight: 400;
}

#primary-aside .sidebar-link--text[aria-current="page"] {
  background: rgba(255, 255, 255, 0.09) !important;
  box-shadow: none;
}

#primary-aside .sidebar-link--text[aria-current="page"]::before {
  content: none;
}

#primary-aside .sidebar-thread-more {
  display: inline-flex;
  align-items: center;
  margin: 0.36rem 0 0 0.42rem;
  font-size: 0.76rem;
  line-height: 1rem;
  color: rgba(232, 238, 252, 0.8);
  border-radius: 0.4rem;
  padding: 0.28rem 0.4rem;
  transition: background-color 0.14s ease, color 0.14s ease;
}

#primary-aside .sidebar-thread-more:hover,
#primary-aside .sidebar-thread-more:focus-visible {
  color: #fff;
  background: var(--app-shell-hover-bg);
}

#primary-aside.is-collapsed:not(.hover-expanded) .sidebar-section--top .sidebar-link--action::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(100% + 0.52rem);
  top: 50%;
  transform: translateY(-50%) translateX(-4px);
  max-width: 11.5rem;
  border-radius: 0.45rem;
  padding: 0.28rem 0.5rem;
  background: #0f172a;
  border: 1px solid var(--app-sidebar-border);
  color: #fff;
  font-size: 0.72rem;
  line-height: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.14s ease, transform 0.14s ease;
  z-index: 120;
}

#primary-aside.is-collapsed:not(.hover-expanded) .sidebar-section--top .sidebar-link--action:hover::after,
#primary-aside.is-collapsed:not(.hover-expanded) .sidebar-section--top .sidebar-link--action:focus-visible::after {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
}

#primary-aside .sidebar-link[aria-current="page"] {
  background: var(--app-shell-active-bg) !important;
  color: #fff !important;
  font-weight: 600;
  border-left: 0 !important;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

#primary-aside .sidebar-link[aria-current="page"]::before {
  content: "";
  position: absolute;
  left: 0.2rem;
  top: 0.34rem;
  bottom: 0.34rem;
  width: 2px;
  border-radius: 999px;
  background: var(--app-shell-accent);
}

#primary-aside .sidebar-link[aria-current="page"]:hover {
  background: var(--app-shell-active-bg) !important;
}

/* Theme switcher active-state classes used by themeScript */
.bg-accent-subtle {
  background: var(--hover-bg) !important;
  background: color-mix(in oklab, var(--primary, #1e2c47) 12%, var(--surface, #ffffff)) !important;
}

.text-accent {
  color: var(--text-primary, #172b4d) !important;
  color: color-mix(in oklab, var(--primary, #1e2c47) 45%, var(--text-primary, #172b4d)) !important;
  font-weight: 600;
}

#primary-aside .sidebar-link:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 2px color-mix(in oklab, #ffffff 35%, transparent);
}

#primary-aside .sidebar-icon-wrap {
  width: 1.35rem;
  height: 1.35rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border-radius: 0;
  background: transparent;
  transition: none;
  opacity: 1;
}

#primary-aside .sidebar-icon-wrap svg {
  width: 1rem;
  height: 1rem;
}

#primary-aside .sidebar-label-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  min-width: 0;
  width: 100%;
}

#primary-aside .sidebar-label-stack {
  min-width: 0;
  display: grid;
  gap: 0.06rem;
}

#primary-aside .sidebar-link-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#primary-aside .sidebar-link-meta {
  font-size: 0.67rem;
  line-height: 0.88rem;
  color: rgba(232, 238, 252, 0.58);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#primary-aside .sidebar-link[aria-current="page"] .sidebar-link-meta {
  color: rgba(255, 255, 255, 0.9);
}

#primary-aside .sidebar-badge {
  min-width: 1.1rem;
  height: 1.1rem;
  border-radius: 999px;
  padding: 0 0.3rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.68rem;
  line-height: 0.9rem;
  font-weight: 700;
  background: #ef4444;
  color: #fff;
  flex-shrink: 0;
}

#primary-aside .sidebar-sublinks {
  margin: 0.22rem 0 0.5rem 2.35rem;
  display: none;
  border-left: 0;
  padding-left: 0.5rem;
}

#primary-aside .sidebar-sublinks.is-open {
  display: grid;
  gap: 0.12rem;
}

#primary-aside .sidebar-sublink {
  display: block;
  border-radius: 0.4rem;
  padding: 0.35rem 0.45rem;
  font-size: 0.8rem;
  line-height: 1.1rem;
  color: rgba(232, 238, 252, 0.78);
  transition: color 0.15s ease, background-color 0.15s ease;
}

#primary-aside .sidebar-sublink:hover {
  background: var(--app-shell-hover-bg);
  color: #fff;
}

#primary-aside .sidebar-sublink[aria-current="page"] {
  color: #fff;
  background: var(--app-shell-active-bg);
}

#primary-aside .sidebar-shell__footer {
  border-top: 0;
  padding: 0.4rem 0.62rem 0.56rem;
  display: grid;
  gap: 0.35rem;
}

#primary-aside .sidebar-shell__footer--simple {
  padding-top: 0.48rem;
}

#primary-aside .sidebar-settings-stack {
  display: grid;
  gap: 0.28rem;
}

#primary-aside .sidebar-link--footer {
  margin-bottom: 0.1rem;
}

#primary-aside .sidebar-locale {
  position: relative;
}

#primary-aside .sidebar-locale form {
  width: 100%;
  display: block;
}

#primary-aside .sidebar-locale .btn-link {
  width: 100%;
  justify-content: space-between;
  border: 0;
  border-radius: 0.62rem;
  padding: 0.52rem 0.58rem;
  color: var(--app-shell-fg);
  background: transparent;
  font-size: 0.84rem;
  line-height: 1.2rem;
}

#primary-aside .sidebar-locale .btn-link:hover,
#primary-aside .sidebar-locale .btn-link:focus-visible {
  background: var(--app-shell-hover-bg);
  color: #fff;
}

#primary-aside .sidebar-locale [role="menu"] {
  min-width: 10.5rem;
  border-color: var(--app-sidebar-border);
  background: var(--app-sidebar-panel-bg);
}

#primary-aside .sidebar-locale [role="menu"] .absolute {
  display: none;
}

#primary-aside .sidebar-locale [role="menu"] .btn-link {
  padding: 0.44rem 0.58rem;
  border-radius: 0.5rem;
  font-size: 0.8rem;
  color: var(--app-shell-fg);
}

#primary-aside .sidebar-locale [role="menu"] .btn-link:hover {
  background: var(--app-shell-hover-bg);
}

#primary-aside .sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  border-radius: 0.5rem;
  padding: 0.45rem 0.58rem;
  background: transparent;
  transition: background-color 0.15s ease;
}

#primary-aside .sidebar-user:hover {
  background: var(--app-shell-hover-bg);
}

#primary-aside .sidebar-user__badge {
  width: 1.65rem;
  height: 1.65rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  background: var(--app-shell-active-bg);
  color: #fff;
  flex-shrink: 0;
}

#primary-aside .sidebar-user__name {
  font-size: 0.8rem;
  line-height: 1.05rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#primary-aside.is-collapsed .nav-label,
#primary-aside.is-collapsed .sidebar-sublinks {
  display: none !important;
}

#primary-aside.is-collapsed .sidebar-section--agents,
#primary-aside.is-collapsed .sidebar-section--threads,
#primary-aside.is-collapsed .sidebar-section--admin {
  display: none;
}

#primary-aside.is-collapsed .sidebar-section--top {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: 0;
}

#primary-aside.is-collapsed .sidebar-brand__meta {
  opacity: 0;
  max-width: 0;
  transform: translateX(-10px);
  pointer-events: none;
}

#primary-aside.is-collapsed .sidebar-shell__footer {
  display: grid;
  border-top: 0;
  padding: 0.45rem 0.62rem 0.58rem;
}

#primary-aside.is-collapsed .sidebar-user {
  justify-content: center;
  padding: 0.2rem;
  background: transparent;
}

#primary-aside.is-collapsed .sidebar-user__badge {
  width: 1.9rem;
  height: 1.9rem;
}

#primary-aside.is-collapsed .sidebar-link {
  justify-content: flex-start;
}

#primary-aside.is-collapsed .sidebar-link[aria-current="page"]::before {
  left: 0.08rem;
}

#primary-aside.is-collapsed .sidebar-section--top .sidebar-link--action {
  justify-content: center;
  gap: 0;
  padding-left: 0.48rem;
  padding-right: 0.48rem;
}

#primary-aside.is-collapsed .sidebar-section--top .sidebar-link--action.sidebar-link--unpinned {
  display: none;
}

/* Keep collapsed padding consistent so icons don't "jump" */
#primary-aside.is-collapsed .sidebar-link {
  padding-left: 0.58rem;
  padding-right: 0.58rem;
}

#primary-aside.is-collapsed .sidebar-shell__scroll {
  padding-left: 0.62rem;
  padding-right: 0.62rem;
}

#primary-aside.is-collapsed {
  width: var(--app-sidebar-collapsed-width);
}

#sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.42);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 35;
}

#sidebar-backdrop.is-active {
  opacity: 1;
  pointer-events: auto;
}

body.sidebar-open-lock {
  overflow: hidden;
}

@media (min-width: 1024px) {
  body.with-sidebar #primary-aside.sidebar-shell {
    transform: translateX(0);
  }

  body.with-sidebar main.flex-grow {
    margin-left: var(--app-sidebar-width);
    padding-left: 0;
    transition: margin-left 0.2s ease;
  }

  body.with-sidebar.sidebar-collapsed main.flex-grow {
    margin-left: var(--app-sidebar-collapsed-width);
  }

  #sidebar-backdrop {
    display: none;
  }
}

@media (max-width: 1023.98px) {
  body.sidebar-open #primary-aside.sidebar-shell {
    transform: translateX(0);
  }

  #primary-aside.sidebar-shell {
    width: min(var(--app-sidebar-width), 88vw);
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  }
}

/* Desktop hover-expand: when collapsed, expand on hover without "opening" */
@media (min-width: 1024px) {
  body.with-sidebar.sidebar-collapsed #primary-aside.sidebar-shell.hover-expanded {
    width: var(--app-sidebar-width);
    z-index: 9999;
    box-shadow: 0 18px 55px rgba(0, 0, 0, 0.35);
  }

  body.with-sidebar.sidebar-collapsed #primary-aside.sidebar-shell.hover-closing {
    z-index: 9999;
    box-shadow: 0 18px 55px rgba(0, 0, 0, 0.35);
  }

  body.with-sidebar.sidebar-collapsed #primary-aside.sidebar-shell.hover-expanded .nav-label {
    opacity: 1;
    max-width: 20rem;
    transform: translateX(0);
    pointer-events: auto;
  }

  body.with-sidebar.sidebar-collapsed #primary-aside.sidebar-shell.hover-expanded .sidebar-brand,
  body.with-sidebar.sidebar-collapsed #primary-aside.sidebar-shell.hover-expanded .sidebar-link {
    justify-content: flex-start;
  }

  body.with-sidebar.sidebar-collapsed #primary-aside.sidebar-shell.hover-expanded .sidebar-shell__scroll {
    padding-left: 0.62rem;
    padding-right: 0.62rem;
    overflow: hidden;
  }

  body.with-sidebar.sidebar-collapsed #primary-aside.sidebar-shell.hover-expanded .sidebar-link {
    padding-left: 0.58rem;
    padding-right: 0.58rem;
  }

  body.with-sidebar.sidebar-collapsed #primary-aside.sidebar-shell.hover-expanded .sidebar-icon-wrap {
    width: 1.35rem;
    height: 1.35rem;
  }

  body.with-sidebar.sidebar-collapsed #primary-aside.sidebar-shell.hover-expanded .sidebar-user {
    justify-content: flex-start;
    padding: 0.45rem 0.58rem;
    background: transparent;
  }

  body.with-sidebar.sidebar-collapsed #primary-aside.sidebar-shell.hover-expanded .sidebar-section--agents,
  body.with-sidebar.sidebar-collapsed #primary-aside.sidebar-shell.hover-expanded .sidebar-section--admin {
    display: block;
  }

  body.with-sidebar.sidebar-collapsed #primary-aside.sidebar-shell.hover-expanded .sidebar-section--threads {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
  }

  body.with-sidebar.sidebar-collapsed #primary-aside.sidebar-shell.hover-expanded .sidebar-shell__footer {
    display: grid;
  }

  body.with-sidebar.sidebar-collapsed #primary-aside.sidebar-shell.hover-expanded .sidebar-section--top .sidebar-link--action.sidebar-link--unpinned {
    display: flex;
  }

  body.with-sidebar.sidebar-collapsed #primary-aside.sidebar-shell.hover-expanded .sidebar-brand__meta {
    opacity: 1;
    max-width: 14rem;
    transform: translateX(0);
    pointer-events: auto;
  }

  body.with-sidebar.sidebar-collapsed #primary-aside.sidebar-shell.hover-expanded .sidebar-label-wrap.nav-label {
    display: flex !important;
  }

  body.with-sidebar.sidebar-collapsed #primary-aside.sidebar-shell.hover-expanded .sidebar-section-head.nav-label {
    display: flex !important;
  }

  body.with-sidebar.sidebar-collapsed #primary-aside.sidebar-shell.hover-expanded .sidebar-user__name.nav-label {
    display: block !important;
  }

  body.with-sidebar.sidebar-collapsed #primary-aside.sidebar-shell.hover-expanded .sidebar-sublinks.is-open {
    display: grid !important;
  }

  /* Desktop-only scrim (visual overlay, no click-to-close) */
  body.with-sidebar.sidebar-collapsed #sidebar-backdrop {
    display: block;
    pointer-events: none;
    z-index: 9998;
  }

  body.with-sidebar.sidebar-collapsed #sidebar-backdrop.is-hover {
    opacity: 1;
  }
}