/**
 * IuVe Sidebar v2 — desktop architecture (persistent rail / expanded panel).
 * Mobile rail + overlay expand lives in iuve-sidebar-drawer-v2.css (@media max-width 767px).
 */

:root {
  --sidebar-v2-expanded: 260px;
  --sidebar-v2-collapsed: 56px;
  --sidebar-v2-header: 56px;
  --sidebar-v2-item-height: 40px;
  --sidebar-v2-icon: 20px;
  --sidebar-v2-rail-logo: 28px;
  --sidebar-v2-transition: 200ms ease;
  --sidebar-v2-bg: #ffffff;
  --app-shell-content-bg: #ffffff;
  /* Full-height seam between white sidebar and white main column (soft on white). */
  --sidebar-v2-border: #e8eaed;
  --sidebar-v2-text: #0f172a;
  --sidebar-v2-muted: #64748b;
  --sidebar-v2-hover: transparent;
  --sidebar-active-bg: transparent;
  --sidebar-v2-active: transparent;
  --sidebar-v2-active-text: #0f172a;
  --sidebar-active-fg: #0f172a;
}

/* ── App shell grid (desktop only) ─────────────────────────────────────── */
/* Viewport-locked shell: left nav stays put; only .app-content scrolls.
   Mobile (≤767) keeps document scroll + drawer — do not apply here. */

@media (min-width: 769px) {
  html:has(.app-shell.app-shell-v2),
  body:has(.app-shell.app-shell-v2) {
    height: 100%;
    max-height: 100dvh;
    overflow: hidden !important;
  }

  .app-shell.app-shell-v2 {
    display: grid !important;
    grid-template-columns: var(--sidebar-v2-expanded) minmax(0, 1fr) !important;
    grid-template-rows: minmax(0, 1fr);
    align-items: stretch;
    min-height: 100dvh;
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
    transition: grid-template-columns var(--sidebar-v2-transition);
  }

  .app-shell.app-shell-v2.nav-collapsed {
    grid-template-columns: var(--sidebar-v2-collapsed) minmax(0, 1fr) !important;
  }

  .app-shell.app-shell-v2 .main-layout,
  .app-shell.app-shell-v2 .app-content {
    min-width: 0;
    width: auto;
    margin: 0;
    min-height: 0;
    height: 100%;
    max-height: 100dvh;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    pointer-events: auto;
    position: relative;
    z-index: 1;
    background: var(--app-shell-content-bg, #ffffff) !important;
    background-image: none !important;
  }

  html:has(.app-shell.app-shell-v2),
  body:has(.app-shell.app-shell-v2),
  .app-shell.app-shell-v2 {
    background: var(--app-shell-content-bg, #ffffff) !important;
  }

  .app-shell.app-shell-v2 .sidebar-v2__overlay {
    display: none !important;
    pointer-events: none !important;
  }

  .app-shell.app-shell-v2 .sidebar-v2.side-nav {
    position: sticky !important;
    transform: none !important;
    inset: auto !important;
    width: 100% !important;
    max-width: none !important;
    height: 100dvh !important;
    z-index: 40;
  }
}

/* Legacy dashboard backdrop must never capture clicks on Sidebar v2 pages. */
.app-shell.app-shell-v2::after,
.app-shell.app-shell-v2.mobile-nav-open::after,
.app-shell.app-shell-v2[data-sidebar-mobile="open"]::after {
  content: none !important;
  display: none !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

/* Closed overlay: hard-disable hit testing (beats drawer display:block+[hidden]). */
.sidebar-v2__overlay[hidden],
.app-shell.app-shell-v2:not(.mobile-nav-open):not([data-sidebar-mobile="open"]) > .sidebar-v2__overlay {
  display: none !important;
  pointer-events: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
}

/* ── Sidebar root ────────────────────────────────────────────────────────── */

/* Root border token — keep in sync with --sidebar-v2-border (#e8eaed). */
.sidebar-v2.side-nav {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  height: 100dvh;
  background: var(--sidebar-v2-bg);
  border-right: 0;
  overflow: hidden;
  box-sizing: border-box;
  padding: 0;
  margin: 0;
  z-index: 40;
}

@media (min-width: 769px) {
  .sidebar-v2.side-nav {
    position: sticky;
    top: 0;
    align-self: stretch;
    width: 100%;
    min-width: 0;
    max-width: none;
    transform: none;
    box-shadow: none;
    transition: none;
  }
}

/* ── Header ──────────────────────────────────────────────────────────────── */

.sidebar-v2__header {
  flex: 0 0 var(--sidebar-v2-header);
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--sidebar-v2-item-height);
  align-items: center;
  gap: 8px;
  height: var(--sidebar-v2-header);
  min-height: var(--sidebar-v2-header);
  padding: 8px 12px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
  background: var(--sidebar-v2-bg);
  box-sizing: border-box;
}

.sidebar-v2__brand {
  grid-column: 1;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--sidebar-v2-text);
  text-decoration: none;
}

.sidebar-v2__brand-mark {
  display: none;
}

.sidebar-v2__toggle--collapse,
.sidebar-v2__toggle--expand {
  grid-column: 2;
  justify-self: end;
}

.sidebar-v2__logo {
  width: 24px;
  height: 24px;
  display: block;
}

.sidebar-v2__brand-text {
  font-family: var(--iuve-font-family, inherit);
  font-size: var(--iuve-font-size-sidebar, 14px);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: opacity 120ms ease, max-width var(--sidebar-v2-transition);
}

.sidebar-v2__toggle {
  width: var(--sidebar-v2-item-height);
  height: var(--sidebar-v2-item-height);
  min-width: var(--sidebar-v2-item-height);
  min-height: var(--sidebar-v2-item-height);
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #334155;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}

.sidebar-v2__toggle:hover {
  background: var(--sidebar-v2-hover);
}

.sidebar-v2__toggle svg {
  width: 18px;
  height: 18px;
}

.sidebar-v2__toggle--expand {
  display: none;
}

.sidebar-v2__toggle-logo--rail {
  display: none;
  width: var(--sidebar-v2-rail-logo, 28px);
  height: var(--sidebar-v2-rail-logo, 28px);
  object-fit: contain;
  object-position: center;
  pointer-events: none;
}

.sidebar-v2__toggle--close-mobile {
  display: none;
}

/* ── Scroll region ───────────────────────────────────────────────────────── */

.sidebar-v2__scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-v2__section {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0;
  padding: 0;
}

.sidebar-v2__section + .sidebar-v2__section {
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px solid rgba(148, 163, 184, 0.14);
}

.sidebar-v2__section-label {
  margin: 0 0 4px;
  padding: 0 10px;
  font-size: var(--iuve-font-size-sidebar-section, 11px);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--sidebar-v2-muted);
  line-height: 1.2;
  transition: opacity 120ms ease;
}

.sidebar-v2__primary-actions {
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--sidebar-v2-bg);
  padding-bottom: 2px;
}

.sidebar-v2__primary-actions .sidebar-v2__item,
.sidebar-v2__primary-actions .side-nav-new-chat,
.sidebar-v2__primary-actions .side-nav-action {
  justify-content: flex-start;
  text-align: left;
}

.sidebar-v2__primary-actions .sidebar-v2__item-label,
.sidebar-v2__primary-actions .side-nav-link-text {
  flex: 0 1 auto;
  text-align: left;
}

.sidebar-v2__navigation {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* ── Unified nav item ────────────────────────────────────────────────────── */

.sidebar-v2__item,
.sidebar-v2 .side-nav-new-chat,
.sidebar-v2 .side-nav-action,
.sidebar-v2 .side-nav-links a,
.sidebar-v2 .side-nav-logout-btn {
  min-height: var(--sidebar-v2-item-height);
  height: var(--sidebar-v2-item-height);
  width: 100%;
  border: 0;
  border-radius: 10px;
  padding: 8px 12px;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  color: #0f172a;
  background: transparent;
  text-decoration: none;
  font: inherit;
  text-align: left;
  cursor: pointer;
  box-sizing: border-box;
}

.sidebar-v2__item:hover,
.sidebar-v2 .side-nav-new-chat:hover,
.sidebar-v2 .side-nav-action:hover,
.sidebar-v2 .side-nav-links a:hover,
.sidebar-v2 .side-nav-logout-btn:hover,
.sidebar-v2__item:focus-visible,
.sidebar-v2 .side-nav-new-chat:focus-visible,
.sidebar-v2 .side-nav-action:focus-visible,
.sidebar-v2 .side-nav-links a:focus-visible,
.sidebar-v2 .side-nav-logout-btn:focus-visible {
  background: transparent;
  color: #0f172a;
}

.sidebar-v2__item.is-active,
.sidebar-v2 .side-nav-links a.active,
.sidebar-v2 .side-nav-action.active {
  background: transparent;
  color: #0f172a;
  font-weight: 600;
  box-shadow: inset 2px 0 0 #0f172a;
}

.sidebar-v2__item.is-active .sidebar-v2__item-icon,
.sidebar-v2 .side-nav-links a.active .side-nav-link-icon,
.sidebar-v2 .side-nav-action.active .side-nav-link-icon {
  color: #334155;
}

.sidebar-v2__item-icon,
.sidebar-v2 .side-nav-link-icon {
  width: var(--sidebar-v2-icon);
  height: var(--sidebar-v2-icon);
  flex: 0 0 var(--sidebar-v2-icon);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #334155;
}

.sidebar-v2__item-icon svg,
.sidebar-v2 .side-nav-link-icon svg {
  width: var(--sidebar-v2-icon);
  height: var(--sidebar-v2-icon);
  display: block;
}

.sidebar-v2__item-label,
.sidebar-v2 .side-nav-link-text,
.sidebar-v2 .side-nav-logout-text {
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: opacity 120ms ease, max-width var(--sidebar-v2-transition);
}

/* ── Project / chat subcontrols ──────────────────────────────────────────── */

.sidebar-v2 .side-nav-subcontrols {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-v2 .side-nav-subcontrol-label {
  font-size: var(--iuve-font-size-sidebar-section, 11px);
  color: var(--sidebar-v2-muted);
  margin: 0;
}

.sidebar-v2 .side-nav-subcontrol-row--project-main,
.sidebar-v2 .side-nav-subcontrol-row--chat-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--sidebar-v2-item-height);
  gap: 6px;
}

.sidebar-v2 .side-nav-subcontrol-chip--hook {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  min-width: 0 !important;
  min-height: 0 !important;
  margin: -1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
  pointer-events: none !important;
}

.sidebar-v2 #side-nav-chat-create.sidebar-v2__section-add,
.sidebar-v2 #side-nav-project-create.sidebar-v2__section-add {
  position: static !important;
  width: 24px !important;
  height: 24px !important;
  min-width: 24px !important;
  min-height: 24px !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: visible !important;
  clip: auto !important;
  white-space: normal !important;
  border: 0 !important;
  pointer-events: auto !important;
}

.sidebar-v2 .side-nav-subcontrol-select {
  min-height: 36px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
  color: var(--sidebar-v2-text);
  font: inherit;
}

.sidebar-v2 .side-nav-subcontrol-chip {
  width: 32px;
  min-width: 32px;
  height: 32px;
  min-height: 32px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
  color: var(--sidebar-v2-text);
  cursor: pointer;
}

.sidebar-v2 .side-nav-subcontrol-status {
  margin: 0;
  font-size: var(--iuve-font-size-sidebar-section, 11px);
  color: var(--sidebar-v2-muted);
}

/* Action menus are real popovers.
   Closed menus must never participate in sidebar layout.
   Applies to BOTH chat and project menus. */
.sidebar-v2 :is(.side-nav-chat-actions-menu, .side-nav-project-actions-menu):not(.sidebar-v2__action-popover--open),
:is(.side-nav-chat-actions-menu, .side-nav-project-actions-menu):not(.sidebar-v2__action-popover--open),
.sidebar-v2 :is(.side-nav-chat-actions-menu, .side-nav-project-actions-menu)[hidden],
:is(.side-nav-chat-actions-menu, .side-nav-project-actions-menu)[hidden] {
  display: none !important;
}

.sidebar-v2 :is(.side-nav-project-action, .side-nav-chat-action),
.sidebar-v2 :is(.side-nav-chat-actions-menu, .side-nav-project-actions-menu) button {
  border: 0;
  background: transparent;
  text-align: left;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  color: var(--sidebar-v2-text);
}

.sidebar-v2 :is(.side-nav-project-action, .side-nav-chat-action):hover,
.sidebar-v2 :is(.side-nav-chat-actions-menu, .side-nav-project-actions-menu) button:hover {
  background: var(--sidebar-v2-hover);
}

.sidebar-v2 :is(.side-nav-project-action--danger, .side-nav-chat-action--danger),
.sidebar-v2 :is(.side-nav-chat-actions-menu, .side-nav-project-actions-menu) button[id$="delete"] {
  color: #b91c1c;
}

/* ── Footer ──────────────────────────────────────────────────────────────── */

.sidebar-v2__footer {
  flex: 0 0 auto;
  position: sticky;
  bottom: 0;
  z-index: 3;
  padding: 8px;
  border-top: 1px solid rgba(148, 163, 184, 0.22);
  background: var(--sidebar-v2-bg);
}

.sidebar-v2 .side-nav-logout-form {
  margin: 0;
}

.sidebar-v2 .side-nav-logout-icon {
  width: var(--sidebar-v2-icon);
  height: var(--sidebar-v2-icon);
  flex: 0 0 var(--sidebar-v2-icon);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ── Collapsed rail (desktop + mobile compact default) ───────────────────── */

.app-shell.app-shell-v2.nav-collapsed .sidebar-v2__header.side-nav-rail-head {
  display: flex !important;
  flex-direction: column;
  justify-content: center !important;
  align-items: center !important;
  padding: 4px 0 !important;
  grid-template-columns: none;
}

.app-shell.app-shell-v2.nav-collapsed .sidebar-v2__brand,
.app-shell.app-shell-v2.nav-collapsed .sidebar-v2__brand-mark,
.app-shell.app-shell-v2.nav-collapsed .sidebar-v2__brand-text,
.app-shell.app-shell-v2.nav-collapsed .sidebar-v2__section-label,
.app-shell.app-shell-v2.nav-collapsed .sidebar-v2 .sidebar-v2__item-label,
.app-shell.app-shell-v2.nav-collapsed .sidebar-v2 .side-nav-link-text,
.app-shell.app-shell-v2.nav-collapsed .sidebar-v2 .side-nav-logout-text,
.app-shell.app-shell-v2.nav-collapsed .sidebar-v2 .side-nav-subcontrols {
  display: none !important;
  opacity: 0 !important;
  visibility: hidden !important;
  max-width: 0 !important;
  width: 0 !important;
  overflow: hidden !important;
  pointer-events: none !important;
}

.app-shell.app-shell-v2.nav-collapsed .sidebar-v2__scroll {
  gap: 2px;
  padding: 4px 0;
  align-items: center;
}

.app-shell.app-shell-v2.nav-collapsed .sidebar-v2__section {
  gap: 2px;
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
  align-items: center;
  width: 100%;
}

.app-shell.app-shell-v2.nav-collapsed .sidebar-v2__section + .sidebar-v2__section {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.app-shell.app-shell-v2.nav-collapsed .sidebar-v2__header {
  justify-content: center !important;
  align-items: center !important;
  padding: 4px 0 !important;
}

.app-shell.app-shell-v2.nav-collapsed .sidebar-v2__brand {
  flex: 0 0 auto;
  justify-content: center;
  width: 0;
  min-width: 0;
  padding: 0;
}

.app-shell.app-shell-v2.nav-collapsed .sidebar-v2 :is(
  .sidebar-v2__brand,
  .side-nav-item-rail,
  .side-nav-logout-btn,
  .sidebar-v2__item,
  .side-nav-action,
  .side-nav-links a
) {
  justify-content: center !important;
  align-items: center !important;
  width: var(--sidebar-v2-item-height) !important;
  min-width: var(--sidebar-v2-item-height) !important;
  max-width: var(--sidebar-v2-item-height) !important;
  margin: 0 auto !important;
  padding: 0 !important;
  gap: 0 !important;
}

.app-shell.app-shell-v2.nav-collapsed .sidebar-v2__primary-actions :is(
  .sidebar-v2__item,
  .side-nav-new-chat,
  .side-nav-action
) {
  justify-content: center !important;
  text-align: center !important;
}

.app-shell.app-shell-v2.nav-collapsed .sidebar-v2__footer {
  display: flex;
  justify-content: center;
  padding: 4px 0;
}

.app-shell.app-shell-v2.nav-collapsed .sidebar-v2 .side-nav-links a:not(.side-nav-item-rail),
.app-shell.app-shell-v2.nav-collapsed .sidebar-v2 .side-nav-action:not(.side-nav-item-rail),
.app-shell.app-shell-v2.nav-collapsed .sidebar-v2 .sidebar-v2__item:not(.side-nav-item-rail):not(.side-nav-new-chat):not(#btn-search-chats) {
  display: none !important;
}

/* ── Desktop collapsed rail toggles + label fade ─────────────────────────── */

@media (min-width: 769px) {
  .app-shell.app-shell-v2.nav-expanded .sidebar-v2__toggle--expand {
    display: none !important;
  }

  .app-shell.app-shell-v2.nav-expanded .sidebar-v2__toggle--collapse {
    display: inline-flex !important;
  }

  .app-shell.app-shell-v2.nav-collapsed .sidebar-v2__toggle--collapse {
    display: none !important;
  }

  .app-shell.app-shell-v2.nav-collapsed .sidebar-v2__toggle--expand,
  .app-shell.app-shell-v2.nav-collapsed .side-nav-rail-open {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    grid-column: auto !important;
    justify-self: stretch !important;
    margin: 0 !important;
    position: relative;
  }

  /* Collapsed rail: logo by default, panel-open icon on hover */
  .app-shell.app-shell-v2.nav-collapsed .sidebar-v2__toggle--expand > *,
  .app-shell.app-shell-v2.nav-collapsed .side-nav-rail-open > * {
    position: absolute;
    inset: 0;
    margin: auto;
    width: var(--sidebar-v2-icon);
    height: var(--sidebar-v2-icon);
  }

  .app-shell.app-shell-v2.nav-collapsed .sidebar-v2__toggle--expand .sidebar-v2__toggle-logo--rail,
  .app-shell.app-shell-v2.nav-collapsed .side-nav-rail-open .sidebar-v2__toggle-logo--rail {
    display: block;
    width: var(--sidebar-v2-rail-logo, 28px);
    height: var(--sidebar-v2-rail-logo, 28px);
    object-fit: contain;
    object-position: center;
    opacity: 1;
    transition: opacity 120ms ease;
  }

  .app-shell.app-shell-v2.nav-collapsed .sidebar-v2__toggle--expand svg,
  .app-shell.app-shell-v2.nav-collapsed .side-nav-rail-open svg {
    opacity: 0;
    transition: opacity 120ms ease;
  }

  .app-shell.app-shell-v2.nav-collapsed .sidebar-v2__toggle--expand:hover .sidebar-v2__toggle-logo--rail {
    opacity: 0;
  }

  .app-shell.app-shell-v2.nav-collapsed .sidebar-v2__toggle--expand:hover svg {
    opacity: 1;
  }

  .app-shell.app-shell-v2.sidebar-v2--labels-out .sidebar-v2 :is(
    .sidebar-v2__brand-text,
    .sidebar-v2__section-label,
    .side-nav-link-text,
    .side-nav-logout-text
  ) {
    opacity: 0;
  }

  .app-shell.app-shell-v2.sidebar-v2--labels-in .sidebar-v2 :is(
    .sidebar-v2__brand-text,
    .sidebar-v2__section-label,
    .side-nav-link-text,
    .side-nav-logout-text
  ) {
    opacity: 1;
  }
}

/* ── Overlay (hidden on desktop) ─────────────────────────────────────────── */

.sidebar-v2__overlay {
  display: none;
}

/* ── TopBar (desktop: hide mobile trigger) ───────────────────────────────── */

@media (min-width: 769px) {
  .main-layout .workspace-mobile-nav,
  .app-content .workspace-mobile-nav {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .app-shell.app-shell-v2,
  .sidebar-v2.side-nav,
  .sidebar-v2__brand-text,
  .sidebar-v2__item-label,
  .sidebar-v2 .side-nav-link-text {
    transition: none !important;
  }
}

/* ── Sidebar action popovers: fixed overlays, never inline layout cards ───── */
.sidebar-v2 :is(.side-nav-chat-actions-menu, .side-nav-project-actions-menu),
:is(.side-nav-chat-actions-menu, .side-nav-project-actions-menu) {
  display: none !important;
}

:is(.side-nav-chat-actions-menu, .side-nav-project-actions-menu).sidebar-v2__action-popover--open:not([hidden]) {
  position: fixed !important;
  display: flex !important;
  flex-direction: column;
  gap: 2px;
  padding: 6px;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.14);
  box-sizing: border-box;
  pointer-events: auto;
  z-index: 10020;
}

:is(.side-nav-chat-actions-menu, .side-nav-project-actions-menu).sidebar-v2__action-popover--open :is(button, .side-nav-project-action, .side-nav-chat-action) {
  min-height: 36px;
  height: 36px;
  width: 100%;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--sidebar-v2-text, #0f172a);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  text-align: left;
  cursor: pointer;
  font: inherit;
  box-sizing: border-box;
}

:is(.side-nav-chat-actions-menu, .side-nav-project-actions-menu).sidebar-v2__action-popover--open :is(button, .side-nav-project-action, .side-nav-chat-action):hover,
:is(.side-nav-chat-actions-menu, .side-nav-project-actions-menu).sidebar-v2__action-popover--open :is(button, .side-nav-project-action, .side-nav-chat-action):focus-visible {
  background: var(--sidebar-v2-hover, #f3f4f6);
  outline: none;
}

:is(.side-nav-chat-actions-menu, .side-nav-project-actions-menu).sidebar-v2__action-popover--open :is(.side-nav-project-action--danger, .side-nav-chat-action--danger, button[id$="delete"]) {
  color: #b91c1c;
}

:is(.side-nav-chat-actions-menu, .side-nav-project-actions-menu).sidebar-v2__action-popover--open :is(.side-nav-project-action--danger, .side-nav-chat-action--danger, button[id$="delete"]):hover,
:is(.side-nav-chat-actions-menu, .side-nav-project-actions-menu).sidebar-v2__action-popover--open :is(.side-nav-project-action--danger, .side-nav-chat-action--danger, button[id$="delete"]):focus-visible {
  background: #fef2f2;
}

:is(.side-nav-project-action-icon, .side-nav-chat-action-icon) {
  width: 16px;
  min-width: 16px;
  display: inline-flex;
  justify-content: center;
}

/* ── shell-open-fab: constrain logo, hide when sidebar is visible ────────── */
/* iuve-infinity-v.svg is 1536×1024 (embedded PNG); without size rules it overlays main content. */

.shell-open-fab {
  border: 0;
  background: transparent;
  padding: 0;
  margin: 0;
  font: inherit;
  cursor: pointer;
  color: #0f172a;
}

.shell-fab-logo {
  display: none;
}

.shell-fab-brand-text {
  font-size: var(--iuve-font-size-sidebar, 14px);
  font-weight: 600;
  color: #0f172a;
  white-space: nowrap;
}

@media (min-width: 768px) {
  .app-shell:not(.nav-hidden) .shell-open-fab,
  .app-shell:has(.workspace-mobile-nav) .shell-open-fab {
    display: none !important;
  }

  .app-shell.nav-hidden .shell-open-fab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    position: fixed;
    top: max(10px, env(safe-area-inset-top, 0px));
    left: max(6px, env(safe-area-inset-left, 0px));
    z-index: 40;
    padding: 6px 10px;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }
}

@media (max-width: 767px) {
  body[data-page="iuve-chat"] .shell-open-fab,
  body[data-page="iuve-chat"] .workspace-app-mobile-header {
    display: none !important;
  }

  /* Fixed top bar for /app/* workspace pages (Billing, Connect, API keys, …) */
  body:not([data-page="iuve-chat"]) .app-shell.app-shell-v2 .workspace-app-mobile-header {
    display: flex;
    align-items: center;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 120;
    box-sizing: border-box;
    height: calc(var(--workspace-mobile-header-height, 50px) + env(safe-area-inset-top, 0px));
    padding: env(safe-area-inset-top, 0px) max(14px, env(safe-area-inset-right, 0px)) 0 max(14px, env(safe-area-inset-left, 0px));
    background: #ffffff;
    border-bottom: 1px solid rgba(148, 163, 184, 0.22);
  }

  body:not([data-page="iuve-chat"]) .app-shell.app-shell-v2 .workspace-app-mobile-header .shell-open-fab {
    display: inline-flex !important;
    align-items: center;
    position: static;
    top: auto;
    left: auto;
    z-index: auto;
    min-height: 44px;
    padding: 8px 0;
    margin: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    pointer-events: auto;
  }

  body:not([data-page="iuve-chat"]) .app-shell.app-shell-v2 .workspace-app-mobile-header .shell-fab-brand-text {
    color: #0f172a;
    font-weight: 600;
  }

  body:not([data-page="iuve-chat"]) .app-shell.app-shell-v2.mobile-nav-open .workspace-app-mobile-header,
  body:not([data-page="iuve-chat"]) .app-shell.app-shell-v2[data-sidebar-mobile="open"] .workspace-app-mobile-header {
    display: none !important;
  }
}

@media (min-width: 768px) {
  .workspace-app-mobile-header {
    display: none !important;
  }
}

/* ── Expanded desktop: labels must stay visible ──────────────────────────── */

@media (min-width: 769px) {
  .app-shell.app-shell-v2.nav-expanded .sidebar-v2 :is(
    .sidebar-v2__brand-text,
    .sidebar-v2__section-label,
    .sidebar-v2__item-label,
    .side-nav-link-text,
    .side-nav-logout-text
  ) {
    display: inline-block !important;
    opacity: 1 !important;
    visibility: visible !important;
    max-width: none !important;
    width: auto !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    pointer-events: auto !important;
  }
}

/* ── SSOT cascade: beats dashboard.css / workspace-shell.css legacy sidebar rules ── */

body .sidebar-v2.side-nav,
.app-shell-v2 .sidebar-v2.side-nav,
body[data-active-mode] .sidebar-v2.side-nav {
  background: var(--sidebar-v2-bg) !important;
  background-image: none !important;
  border: 0 !important;
  border-right: 0 !important;
  box-shadow: none !important;
  outline: none !important;
  backdrop-filter: none !important;
  border-radius: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  top: 0 !important;
  height: 100dvh !important;
  overflow: hidden !important;
  position: relative !important;
  isolation: isolate;
}

/* Central column: white (divider seam separates sidebar). */
body .app-shell.app-shell-v2 .app-content,
body .app-shell.app-shell-v2 .main-layout,
body[data-active-mode] .app-shell.app-shell-v2 .app-content,
body[data-active-mode] .app-shell.app-shell-v2 .main-layout,
body[data-active-mode] .app-shell.app-shell-v2 .dashboard-layout {
  background: var(--app-shell-content-bg, #ffffff) !important;
  background-image: none !important;
}

/* Chat card must not paint white over the central column. */
body[data-page="iuve-chat"] .app-shell.app-shell-v2 #unified-card.unified-card,
body[data-page="iuve-chat"] .app-shell.app-shell-v2 .unified-wrap,
body[data-page="iuve-chat"] .app-shell.app-shell-v2 #unified-main.dashboard-layout {
  background: transparent !important;
  background-image: none !important;
}

/* Single full-height seam: pinned to rail edge, independent of СИСТЕМА / active rows. */
body .sidebar-v2.side-nav::after,
.app-shell-v2 .sidebar-v2.side-nav::after {
  content: "" !important;
  position: absolute !important;
  top: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 1px !important;
  height: 100% !important;
  min-height: 100dvh !important;
  margin: 0 !important;
  padding: 0 !important;
  background: var(--sidebar-v2-border) !important;
  pointer-events: none !important;
  z-index: 80 !important;
}

.app-shell.app-shell-v2.nav-collapsed .sidebar-v2.side-nav::after {
  content: "" !important;
  display: block !important;
}

@media (min-width: 769px) {
  body .app-shell.app-shell-v2 .sidebar-v2.side-nav,
  .app-shell.app-shell-v2 .sidebar-v2.side-nav {
    position: sticky !important;
  }
}

.sidebar-v2.side-nav .sidebar-v2__scroll,
.sidebar-v2.side-nav.side-nav-scroll {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  -webkit-overflow-scrolling: touch !important;
}

.sidebar-v2.side-nav :is(
  .sidebar-v2__navigation,
  .side-nav-links,
  .sidebar-v2__section,
  .sidebar-v2__primary-actions
) {
  border: 0 !important;
  box-shadow: none !important;
  outline: none !important;
  background: transparent !important;
  background-image: none !important;
}

.iuve-shell .sidebar-v2.side-nav .sidebar-v2__section,
.iuve-shell .sidebar-v2.side-nav .side-nav-section {
  border-bottom: 0 !important;
}

.sidebar-v2.side-nav :is(
  .sidebar-v2__item,
  .side-nav-new-chat,
  .side-nav-action,
  .side-nav-links a,
  .side-nav-logout-btn
) {
  background: transparent !important;
  background-image: none !important;
  border: 0 !important;
  box-shadow: none !important;
  outline: none !important;
  color: #0f172a !important;
  -webkit-text-fill-color: #0f172a !important;
}

.sidebar-v2.side-nav :is(
  .sidebar-v2__item:hover,
  .side-nav-new-chat:hover,
  .side-nav-action:hover,
  .side-nav-links a:hover,
  .side-nav-logout-btn:hover,
  .sidebar-v2__item:focus,
  .side-nav-new-chat:focus,
  .side-nav-action:focus,
  .side-nav-links a:focus,
  .side-nav-logout-btn:focus,
  .sidebar-v2__item:focus-visible,
  .side-nav-new-chat:focus-visible,
  .side-nav-action:focus-visible,
  .side-nav-links a:focus-visible,
  .side-nav-logout-btn:focus-visible
) {
  background: transparent !important;
  color: #0f172a !important;
  -webkit-text-fill-color: #0f172a !important;
  border: 0 !important;
  box-shadow: none !important;
}

.sidebar-v2.side-nav :is(
  .sidebar-v2__item :is(.sidebar-v2__item-icon, .side-nav-link-icon),
  .side-nav-links a :is(.sidebar-v2__item-icon, .side-nav-link-icon),
  .side-nav-action :is(.sidebar-v2__item-icon, .side-nav-link-icon),
  .side-nav-new-chat :is(.sidebar-v2__item-icon, .side-nav-link-icon),
  .side-nav-logout-btn .side-nav-logout-icon
) {
  color: #334155 !important;
}

.sidebar-v2 .side-nav-subcontrol-select {
  background: #ffffff !important;
  border: 1px solid #cbd5e1 !important;
  color: var(--sidebar-v2-text) !important;
  box-shadow: none !important;
}

.sidebar-v2 .side-nav-subcontrol-chip,
.sidebar-v2 .mode-chip.side-nav-subcontrol-chip {
  background: #ffffff !important;
  border: 1px solid #cbd5e1 !important;
  color: var(--sidebar-v2-text) !important;
  box-shadow: none !important;
}

.sidebar-v2 .side-nav-subcontrol-chip:hover,
.sidebar-v2 .mode-chip.side-nav-subcontrol-chip:hover {
  background: #f8fafc !important;
  border-color: #cbd5e1 !important;
  color: var(--sidebar-v2-text) !important;
}

.sidebar-v2.side-nav :is(
  .sidebar-v2__item.is-active,
  .sidebar-v2__item.active,
  .side-nav-links a.active,
  .side-nav-action.active
),
body[data-page="iuve-chat"] #app-shell .sidebar-v2.side-nav :is(
  .sidebar-v2__item.is-active,
  .sidebar-v2__item.active,
  .side-nav-links a.active,
  .side-nav-action.active
) {
  background: transparent !important;
  color: #0f172a !important;
  -webkit-text-fill-color: #0f172a !important;
  font-weight: 600 !important;
  box-shadow: inset 2px 0 0 #0f172a !important;
  border: 0 !important;
  outline: none !important;
}

.sidebar-v2.side-nav :is(
  .sidebar-v2__item.is-active,
  .sidebar-v2__item.active,
  .side-nav-links a.active,
  .side-nav-action.active
) :is(.sidebar-v2__item-label, .side-nav-link-text, .side-nav-logout-text),
body[data-page="iuve-chat"] #app-shell .sidebar-v2.side-nav :is(
  .sidebar-v2__item.is-active,
  .sidebar-v2__item.active,
  .side-nav-links a.active,
  .side-nav-action.active
) :is(.sidebar-v2__item-label, .side-nav-link-text, .side-nav-logout-text) {
  color: #0f172a !important;
  -webkit-text-fill-color: #0f172a !important;
}

@media (min-width: 769px) {
  .app-shell.app-shell-v2.nav-expanded .sidebar-v2.side-nav :is(
    .sidebar-v2__item.is-active,
    .sidebar-v2__item.active,
    .side-nav-links a.active,
    .side-nav-action.active
  ) :is(.sidebar-v2__item-label, .side-nav-link-text, .side-nav-logout-text),
  body[data-page="iuve-chat"] #app-shell.app-shell-v2.nav-expanded .sidebar-v2.side-nav :is(
    .sidebar-v2__item.is-active,
    .sidebar-v2__item.active,
    .side-nav-links a.active,
    .side-nav-action.active
  ) :is(.sidebar-v2__item-label, .side-nav-link-text, .side-nav-logout-text) {
    opacity: 1 !important;
    visibility: visible !important;
    max-width: none !important;
    width: auto !important;
    display: inline-block !important;
  }
}

/* Collapsed rail: active labels must stay hidden (beats SSOT active rules above) */
.app-shell.app-shell-v2.nav-collapsed .sidebar-v2.side-nav :is(
  .sidebar-v2__item.is-active,
  .sidebar-v2__item.active,
  .side-nav-links a.active,
  .side-nav-action.active
) :is(.sidebar-v2__item-label, .side-nav-link-text, .side-nav-logout-text),
body[data-page="iuve-chat"] #app-shell.app-shell-v2.nav-collapsed .sidebar-v2.side-nav :is(
  .sidebar-v2__item.is-active,
  .sidebar-v2__item.active,
  .side-nav-links a.active,
  .side-nav-action.active
) :is(.sidebar-v2__item-label, .side-nav-link-text, .side-nav-logout-text) {
  display: none !important;
  opacity: 0 !important;
  visibility: hidden !important;
  max-width: 0 !important;
  width: 0 !important;
  overflow: hidden !important;
  pointer-events: none !important;
}

.sidebar-v2.side-nav :is(
  .sidebar-v2__item.is-active,
  .sidebar-v2__item.active,
  .side-nav-links a.active,
  .side-nav-action.active
) :is(.sidebar-v2__item-icon, .side-nav-link-icon),
body[data-page="iuve-chat"] #app-shell .sidebar-v2.side-nav :is(
  .sidebar-v2__item.is-active,
  .sidebar-v2__item.active,
  .side-nav-links a.active,
  .side-nav-action.active
) :is(.sidebar-v2__item-icon, .side-nav-link-icon) {
  color: #334155 !important;
}

.sidebar-v2.side-nav :is(
  .sidebar-v2__item.is-active,
  .sidebar-v2__item.active,
  .side-nav-links a.active,
  .side-nav-action.active
) :is(.sidebar-v2__item-icon svg, .side-nav-link-icon svg) {
  stroke: currentColor;
}

.sidebar-v2.side-nav :is(
  .side-nav-links a.active .side-nav-link-icon::after,
  .side-nav-action.active .side-nav-link-icon::after
) {
  content: none !important;
  display: none !important;
}

/* ── Monochrome text: beat dashboard.css gradient brand + link colors ─────── */

.sidebar-v2.side-nav :is(
  .sidebar-v2__brand,
  .sidebar-v2__brand-text,
  .side-nav-brand,
  .side-nav-brand-text,
  .sidebar-v2__item-label,
  .side-nav-link-text,
  .side-nav-logout-text
) {
  background: none !important;
  background-image: none !important;
  -webkit-background-clip: border-box !important;
  background-clip: border-box !important;
  -webkit-text-fill-color: #0f172a !important;
  color: #0f172a !important;
  text-shadow: none !important;
}

/* ── Unified left alignment for all sections (ПРОЕКТЫ / ЧАТЫ / СИСТЕМА) ───── */

.sidebar-v2.side-nav {
  --sidebar-v2-item-padding-x: 12px;
  --sidebar-v2-item-padding-y: 8px;
}

.sidebar-v2.side-nav .sidebar-v2__scroll,
.iuve-shell .sidebar-v2.side-nav .sidebar-v2__scroll {
  padding: 8px !important;
}

.sidebar-v2.side-nav .sidebar-v2__section-label,
.iuve-shell .sidebar-v2.side-nav .sidebar-v2__section-label {
  padding: 0 var(--sidebar-v2-item-padding-x) !important;
  margin: 0 0 4px !important;
}

.sidebar-v2.side-nav :is(
  .sidebar-v2__navigation,
  .side-nav-links,
  .sidebar-v2__primary-actions,
  .sidebar-v2__section
) {
  padding: 0 !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
}

.sidebar-v2.side-nav :is(
  .sidebar-v2__item,
  .side-nav-new-chat,
  .side-nav-action,
  .side-nav-links a,
  .side-nav-logout-btn
),
.iuve-shell .sidebar-v2.side-nav :is(
  .sidebar-v2__item,
  .side-nav-new-chat,
  .side-nav-action,
  .side-nav-logout-btn
) {
  padding: var(--sidebar-v2-item-padding-y) var(--sidebar-v2-item-padding-x) !important;
  gap: 10px !important;
  margin: 0 !important;
  border-radius: 10px !important;
  justify-content: flex-start !important;
  text-align: left !important;
}

/* Collapsed rail: hide every text label (incl. active «Б…» leak + legacy ::after) */

.app-shell.app-shell-v2.nav-collapsed .sidebar-v2.side-nav :is(
  .sidebar-v2__brand-text,
  .side-nav-brand-text,
  .sidebar-v2__section-label,
  .sidebar-v2__item-label,
  .side-nav-link-text,
  .side-nav-logout-text
) {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  width: 0 !important;
  max-width: 0 !important;
  height: 0 !important;
  overflow: hidden !important;
  font-size: 0 !important;
  line-height: 0 !important;
  letter-spacing: 0 !important;
  clip-path: inset(50%) !important;
  position: absolute !important;
  pointer-events: none !important;
}

.app-shell.app-shell-v2.nav-collapsed .sidebar-v2.side-nav :is(
  .side-nav-links a,
  .side-nav-action,
  .sidebar-v2__item
)::after {
  content: none !important;
  display: none !important;
}

/* Collapsed rail tooltips from title/data-label (do not affect 56/260 geometry) */
@media (min-width: 769px) {
  .app-shell.app-shell-v2.nav-collapsed .sidebar-v2.side-nav :is(
    .sidebar-v2__item,
    .side-nav-action,
    .side-nav-links a,
    .side-nav-new-chat,
    .side-nav-logout-btn
  ) {
    position: relative;
  }

  .app-shell.app-shell-v2.nav-collapsed .sidebar-v2.side-nav :is(
    .sidebar-v2__item[data-label],
    .side-nav-action[data-label],
    .side-nav-links a[data-label],
    .side-nav-new-chat[data-label],
    .side-nav-logout-btn[data-label]
  ):hover::before,
  .app-shell.app-shell-v2.nav-collapsed .sidebar-v2.side-nav :is(
    .sidebar-v2__item[title],
    .side-nav-action[title],
    .side-nav-links a[title],
    .side-nav-new-chat[title],
    .side-nav-logout-btn[title]
  ):focus-visible::before {
    content: attr(data-label);
    position: absolute;
    left: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%);
    z-index: 80;
    white-space: nowrap;
    padding: 6px 10px;
    border-radius: 8px;
    background: #0f172a;
    color: #f8fafc;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.2;
    pointer-events: none;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.18);
  }

  .app-shell.app-shell-v2.nav-collapsed .sidebar-v2.side-nav :is(
    .sidebar-v2__item[title]:not([data-label]),
    .side-nav-action[title]:not([data-label]),
    .side-nav-links a[title]:not([data-label]),
    .side-nav-new-chat[title]:not([data-label]),
    .side-nav-logout-btn[title]:not([data-label])
  ):hover::before {
    content: attr(title);
  }
}

/* ── Shell white + width SSOT (divider seam kept above) ─────────────────── */
body .sidebar-v2.side-nav,
body[data-active-mode] .sidebar-v2.side-nav,
body[data-page="iuve-chat"] #app-shell .sidebar-v2.side-nav,
body[data-page="iuve-chat"] #app-shell .sidebar-v2.side-nav :is(
  .sidebar-v2__header,
  .sidebar-v2__scroll,
  .sidebar-v2__footer,
  .side-nav-header,
  .side-nav-scroll,
  .side-nav-footer,
  .side-nav-subcontrols,
  .side-nav-subcontrol,
  .side-nav-subcontrol-row,
  .side-nav-recent,
  .side-nav-recent-link,
  .side-nav-recent-link.active,
  .side-nav-subitem,
  .side-nav-subitem.active,
  .side-nav-links a,
  .side-nav-links a.active,
  .side-nav-action,
  .side-nav-action.active,
  .side-nav-new-chat,
  .sidebar-v2__item,
  .sidebar-v2__item.is-active,
  .sidebar-v2__item.active
) {
  background: #ffffff !important;
  background-image: none !important;
}

body .sidebar-v2.side-nav :is(
  .side-nav-subcontrol-select,
  .side-nav-subcontrol-chip,
  .mode-chip.side-nav-subcontrol-chip
),
body[data-page="iuve-chat"] #app-shell .sidebar-v2.side-nav :is(
  .side-nav-subcontrol-select,
  .side-nav-subcontrol-chip,
  .mode-chip.side-nav-subcontrol-chip
) {
  background: #ffffff !important;
}

body .app-shell.app-shell-v2 .app-content,
body .app-shell.app-shell-v2 .main-layout,
body[data-active-mode] .app-shell.app-shell-v2 .app-content,
body[data-page="iuve-chat"] #app-shell,
body[data-page="iuve-chat"] #app-shell > .app-content,
body[data-page="iuve-chat"] #app-shell .dashboard-layout,
body[data-page="iuve-chat"] .unified-wrap,
body[data-page="iuve-chat"] #unified-card,
body[data-page="iuve-chat"] .unified-card,
body[data-page="iuve-chat"] .unified-chat,
body[data-page="iuve-chat"] #unified-messages,
body[data-page="iuve-chat"] .unified-messages,
body[data-page="iuve-chat"] .unified-input {
  background: #ffffff !important;
  background-image: none !important;
}

/* Same expanded/collapsed rail width in every app section. */
@media (min-width: 769px) {
  .app-shell.app-shell-v2,
  body.app-shell.app-shell-v2,
  #app-shell.app-shell-v2,
  body[data-page] .app-shell.app-shell-v2,
  body[data-page="iuve-chat"] #app-shell.app-shell-v2 {
    grid-template-columns: var(--sidebar-v2-expanded, 260px) minmax(0, 1fr) !important;
  }

  .app-shell.app-shell-v2.nav-collapsed,
  body.app-shell.app-shell-v2.nav-collapsed,
  #app-shell.app-shell-v2.nav-collapsed,
  body[data-active-mode] .app-shell.app-shell-v2.nav-collapsed,
  body[data-page] .app-shell.app-shell-v2.nav-collapsed,
  body[data-page="iuve-chat"] #app-shell.app-shell-v2.nav-collapsed {
    grid-template-columns: var(--sidebar-v2-collapsed, 56px) minmax(0, 1fr) !important;
  }

  .app-shell.app-shell-v2 .sidebar-v2.side-nav,
  body.app-shell.app-shell-v2 .sidebar-v2.side-nav,
  #app-shell.app-shell-v2 .sidebar-v2.side-nav,
  body[data-page] .app-shell.app-shell-v2 .sidebar-v2.side-nav,
  body[data-page="iuve-chat"] #app-shell.app-shell-v2 > .side-nav,
  body[data-page="iuve-chat"] #app-shell.app-shell-v2 .sidebar-v2.side-nav {
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    box-sizing: border-box !important;
  }
}

/* ── Projects / Chats picker polish (ChatGPT-like) ───────────────────────── */

.sidebar-v2 .side-nav-sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.sidebar-v2 .sidebar-v2__section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 8px 2px 10px;
  min-height: 28px;
}

.sidebar-v2 .sidebar-v2__section-head .sidebar-v2__section-label {
  margin: 0 !important;
  flex: 1 1 auto;
}

.sidebar-v2 .sidebar-v2__section-add {
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #6b7280;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.sidebar-v2 .sidebar-v2__section-add:hover {
  background: #f0f2f5;
  color: #0f172a;
}

.sidebar-v2 :is(.sidebar-v2__section--projects, .sidebar-v2__section--chats) {
  gap: 4px;
  margin-top: 6px;
  padding-top: 10px;
  border-top: 1px solid #eceff3;
}

.sidebar-v2 .sidebar-v2__section--primary + .sidebar-v2__section--projects {
  margin-top: 10px;
}

.sidebar-v2 :is(.sidebar-v2__section--projects, .sidebar-v2__section--chats) .sidebar-v2__section-label {
  letter-spacing: 0.04em;
  font-weight: 600;
  color: #8b95a5 !important;
  -webkit-text-fill-color: #8b95a5 !important;
}

.sidebar-v2 .side-nav-subcontrols {
  gap: 2px;
  padding: 0 4px;
}

.sidebar-v2 .side-nav-picker {
  position: relative;
}

.sidebar-v2 .side-nav-picker-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  max-height: 240px;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0 2px;
  scrollbar-width: thin;
}

.sidebar-v2 .sidebar-v2__section--projects .side-nav-picker-list {
  max-height: 160px;
}

.sidebar-v2 .side-nav-picker-empty {
  padding: 8px 10px;
  font-size: 13px;
  color: #8b95a5;
}

.sidebar-v2 .side-nav-pinned-block {
  margin: 0 0 8px;
  padding: 0 0 8px;
  border-bottom: 1px solid #eef1f5;
}

.sidebar-v2 .side-nav-pinned-label {
  padding: 4px 10px 6px;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: #8b95a5;
}

.sidebar-v2 .side-nav-pinned-list {
  max-height: 280px;
  overflow: auto;
}

.sidebar-v2 .side-nav-picker-item.is-pinned .side-nav-picker-item-icon {
  color: #2563eb;
}

.sidebar-v2 .side-nav-actions-sep {
  height: 1px;
  margin: 6px 8px;
  background: #e8ecf2;
}

.sidebar-v2 .side-nav-action-chevron {
  margin-left: auto;
  color: #94a3b8;
}

.sidebar-v2 .side-nav-chat-move-menu {
  position: absolute;
  left: calc(100% + 6px);
  top: 0;
  min-width: 200px;
  max-height: 280px;
  overflow: auto;
  z-index: 10030;
}

.unified-share-toast {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10040;
  display: none;
  align-items: center;
  gap: 10px;
  max-width: min(560px, calc(100vw - 32px));
  padding: 12px 14px;
  border-radius: 12px;
  background: #111;
  color: #fff;
  box-shadow: 0 12px 32px rgba(0,0,0,0.22);
}

.unified-share-toast.is-visible { display: inline-flex; }
.unified-share-toast-check {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  border: 1.6px solid #fff;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
}
.unified-share-toast-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.unified-share-toast-title { font-size: 13px; font-weight: 650; line-height: 1.25; }
.unified-share-toast-sub { font-size: 12px; opacity: 0.88; line-height: 1.3; }

.sidebar-v2 .side-nav-picker-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 28px;
  align-items: center;
  gap: 2px;
  border-radius: 10px;
  min-height: 36px;
}

.sidebar-v2 .side-nav-picker-item:hover,
.sidebar-v2 .side-nav-picker-item.is-active {
  background: #f4f5f7;
}

.sidebar-v2 .side-nav-picker-item-main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  width: 100%;
  border: 0;
  background: transparent;
  color: #0f172a;
  text-align: left;
  cursor: pointer;
  padding: 7px 4px 7px 8px;
  border-radius: 10px;
  font: inherit;
}

.sidebar-v2 .side-nav-picker-item-icon {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  color: #5b6573;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.sidebar-v2 .side-nav-picker-item-icon svg {
  width: 18px;
  height: 18px;
}

.sidebar-v2 .side-nav-picker-item-label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 500;
  color: #0f172a;
  -webkit-text-fill-color: #0f172a;
}

.sidebar-v2 .side-nav-picker-item.is-active .side-nav-picker-item-label {
  font-weight: 600;
}

.sidebar-v2 .side-nav-picker-item-more {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #6b7280;
  cursor: pointer;
  opacity: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  line-height: 1;
}

.sidebar-v2 .side-nav-picker-item:hover .side-nav-picker-item-more,
.sidebar-v2 .side-nav-picker-item.is-active .side-nav-picker-item-more,
.sidebar-v2 .side-nav-picker-item-more[aria-expanded="true"] {
  opacity: 1;
}

.sidebar-v2 .side-nav-picker-item-more:hover {
  background: #e8eaed;
  color: #0f172a;
}

.sidebar-v2 .side-nav-subcontrol-status {
  margin: 0 !important;
  padding: 4px 10px !important;
  font-size: 11px !important;
  line-height: 1.3 !important;
  color: #8b95a5 !important;
}

.sidebar-v2 .side-nav-subcontrol-status[hidden],
.sidebar-v2 .side-nav-subcontrol-status.is-idle:not(.is-error) {
  display: none !important;
}

.sidebar-v2 .side-nav-subcontrol-status.is-error {
  display: block !important;
  color: #b91c1c !important;
}

@media (hover: none) {
  .sidebar-v2 .side-nav-picker-item-more {
    opacity: 1;
  }
}

/* Keep section-add visible even if old hook-hide rules exist */
.sidebar-v2 .sidebar-v2__section-add {
  position: static !important;
  width: 24px !important;
  height: 24px !important;
  min-width: 24px !important;
  min-height: 24px !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: visible !important;
  clip: auto !important;
  pointer-events: auto !important;
}

/* ── ChatGPT-style user account menu (footer) ─────────────────────────────── */

.sidebar-v2__user-menu {
  position: relative;
}

.sidebar-v2__user-trigger-row {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border-radius: 14px;
  background: #f4f5f7;
}

.sidebar-v2__user-trigger {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 0;
  background: transparent;
  padding: 6px 8px;
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: inherit;
}

.sidebar-v2__user-trigger:hover,
.sidebar-v2__user-trigger[aria-expanded="true"] {
  background: #eceef1;
}

.sidebar-v2__user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.sidebar-v2__user-avatar--sm {
  width: 28px;
  height: 28px;
  font-size: 11px;
}

.sidebar-v2__user-meta {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.sidebar-v2__user-name {
  font-size: 14px;
  font-weight: 600;
  color: #0f172a;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-v2__user-plan {
  font-size: 12px;
  color: #6b7280;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-v2__user-pwa, .sidebar-v2__user-market {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  color: #6b7280;
  text-decoration: none;
}

.sidebar-v2__user-pwa svg, .sidebar-v2__user-market svg {
  width: 18px;
  height: 18px;
}

.sidebar-v2__user-pwa:hover, .sidebar-v2__user-market:hover {
  background: #eceef1;
  color: #0f172a;
}

.sidebar-v2__user-popover {
  position: fixed;
  z-index: 1200;
  min-width: 240px;
  max-width: 280px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.14);
  padding: 6px;
  overflow: hidden;
}

.sidebar-v2__user-popover[hidden] {
  display: none !important;
}

.sidebar-v2__user-popover-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  text-decoration: none;
  color: inherit;
}

.sidebar-v2__user-popover-head:hover {
  background: #f4f5f7;
}

.sidebar-v2__user-popover-chevron {
  width: 16px;
  height: 16px;
  margin-left: auto;
  color: #9ca3af;
  flex: 0 0 auto;
}

.sidebar-v2__user-popover-divider {
  height: 1px;
  background: #eceff3;
  margin: 4px 8px;
}

.sidebar-v2__user-popover-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-v2__user-popover-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: 0;
  background: transparent;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  color: #0f172a;
  text-decoration: none;
  cursor: pointer;
  text-align: left;
  font: inherit;
}

.sidebar-v2__user-popover-item svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  color: #5b6573;
}

.sidebar-v2__user-popover-item:hover,
.sidebar-v2__user-popover-item.is-active {
  background: #f4f5f7;
}

.sidebar-v2__user-logout-form {
  margin: 0;
}

.sidebar-v2__user-popover-item--logout {
  color: #0f172a;
}

.app-shell.app-shell-v2.nav-collapsed .sidebar-v2__user-trigger-row {
  flex-direction: column;
  background: transparent;
  padding: 0;
  gap: 6px;
}

.app-shell.app-shell-v2.nav-collapsed .sidebar-v2__user-trigger {
  justify-content: center;
  padding: 4px;
}

.app-shell.app-shell-v2.nav-collapsed .sidebar-v2__user-meta,
.app-shell.app-shell-v2.nav-collapsed .sidebar-v2__user-pwa, .sidebar-v2__user-market {
  display: none !important;
}
.sidebar-v2__user-pwa {
  border: 0;
  background: transparent;
  cursor: pointer;
  font: inherit;
}

.sidebar-v2__user-pwa:disabled {
  opacity: 0.45;
  cursor: default;
}

.sidebar-v2__user-pwa[hidden] {
  display: none !important;
}
