/* Phantom desktop shell layout. ASCII-only. Loaded after app.css. */
#app-shell.phantom-desktop-shell {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  position: relative;
  width: 100%;
  max-width: 100vw;
  height: 100dvh;
  max-height: 100dvh;
  min-height: 0;
  margin: 0;
  padding: 0;
  background: #050509;
  overflow: hidden;
  box-sizing: border-box;
}

#app-shell.phantom-desktop-shell.hidden {
  display: none !important;
}

#app-sidebar.app-sidebar {
  box-sizing: border-box;
  width: 188px;
  min-width: 188px;
  max-width: 188px;
  flex: 0 0 188px;
  display: flex;
  flex-direction: column;
  align-self: stretch;
  background: #090910;
  border-right: 1px solid #29283A;
  overflow: hidden;
}

#app-sidebar.app-sidebar[data-collapsed="true"] {
  width: 64px;
  min-width: 64px;
  max-width: 64px;
  flex-basis: 64px;
}

#app-sidebar.app-sidebar[data-collapsed="true"] .nav-label,
#app-sidebar.app-sidebar[data-collapsed="true"] .sidebar-brand,
#app-sidebar.app-sidebar[data-collapsed="true"] .nav-section,
#app-sidebar.app-sidebar[data-collapsed="true"] .nav-soon-tag {
  display: none !important;
}

#app-sidebar .sidebar-header {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 52px;
  min-height: 52px;
  padding: 0 10px;
  border-bottom: 1px solid #29283A;
  flex-shrink: 0;
}

/* Desktop: the close control must not add a box. Logo and wordmark stay in the row. */
#btn-mobile-nav-brand-close.mobile-nav-brand-close {
  display: contents;
}

#app-sidebar .sidebar-toggle {
  appearance: none;
  -webkit-appearance: none;
  background: #12121C;
  border: 1px solid #29283A;
  color: #F6F4FF;
  border-radius: 8px;
  width: 36px;
  height: 36px;
  min-width: 36px;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
  font: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
#app-sidebar .sidebar-toggle svg { display: block; }

#app-sidebar .sidebar-brand {
  font-weight: 700;
  color: #B59BFF;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#app-sidebar .sidebar-nav {
  flex: 1 1 auto;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 4px 6px 2px;
  display: block;
  min-height: 0;
}

#app-sidebar .sidebar-utility {
  border-top: 1px solid #29283A;
  padding: 6px 6px 8px;
  display: block;
  flex-shrink: 0;
}

#app-sidebar .sidebar-user-badge {
  display: block;
  margin: 0 4px 6px;
  padding: 4px 8px;
  background: #12121C;
  border: 1px solid #29283A;
  border-radius: 8px;
  font-size: 0.68rem;
  line-height: 1.25;
  color: #8F8C9B;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#app-sidebar.app-sidebar[data-collapsed="true"] .sidebar-user-badge {
  display: none !important;
}

#app-sidebar .nav-section {
  display: block;
  margin: 8px 8px 2px;
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #8F8C9B;
}

#app-sidebar button.nav-item {
  appearance: none;
  -webkit-appearance: none;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  box-sizing: border-box;
  background: transparent;
  border: 1px solid transparent;
  color: #C8C5D2;
  border-radius: 8px;
  padding: 8px 10px;
  margin: 0 0 2px;
  cursor: pointer;
  text-align: left;
  min-height: 40px;
  height: auto;
  font: inherit;
  font-size: 0.9rem;
  line-height: 1.25;
}

#app-sidebar button.nav-item:hover:not(:disabled) {
  background: #181824;
  color: #F6F4FF;
}

#app-sidebar button.nav-item.active,
#app-sidebar button.nav-item[aria-current="page"] {
  background: #19152A;
  border-color: #4A347A;
  color: #F6F4FF;
}

#app-sidebar button.nav-item:disabled,
#app-sidebar button.nav-item.nav-soon {
  opacity: 0.55;
  cursor: not-allowed;
}

#app-sidebar .nav-icon {
  width: 1.35rem;
  height: 1.35rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #C8C5D2;
  font-style: normal;
}

#app-sidebar .nav-icon svg {
  width: 1.15rem;
  height: 1.15rem;
  fill: currentColor;
  display: block;
}

#app-sidebar .nav-icon-img img {
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 5px;
  object-fit: cover;
  display: block;
  border: 1px solid rgba(118, 82, 214, 0.45);
}

#app-sidebar button.nav-item.active .nav-icon,
#app-sidebar button.nav-item[aria-current="page"] .nav-icon {
  color: #B59BFF;
}

#app-sidebar button.nav-item.active .nav-icon-img img,
#app-sidebar button.nav-item[aria-current="page"] .nav-icon-img img {
  border-color: rgba(181, 155, 255, 0.85);
  box-shadow: 0 0 0 1px rgba(139, 92, 246, 0.35);
}

#app-sidebar .nav-soon-tag {
  margin-left: auto;
  font-size: 0.65rem;
  color: #8F8C9B;
  border: 1px solid #29283A;
  border-radius: 999px;
  padding: 1px 6px;
}

#app-shell .app-main-column {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  max-width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #050509;
}

#app-shell .app-header {
  display: none !important;
}

#app-shell .app-header-titles {
  display: none;
}

#app-shell .app-header h1 {
  margin: 0;
  font-size: 1.15rem;
  color: #B59BFF;
  flex-shrink: 0;
}

#app-shell #user-badge.badge {
  /* legacy header badge styles kept for safety; live badge is sidebar-user-badge */
  background: #12121C;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  color: #8F8C9B;
  border: 1px solid #29283A;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#app-shell #btn-logout.hidden {
  display: none !important;
}

#app-shell main#main {
  padding: 8px 12px 12px;
  max-width: none;
  width: 100%;
  margin: 0;
  flex: 1 1 auto;
  box-sizing: border-box;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#app-sidebar.app-sidebar[data-collapsed="true"] button.nav-item {
  justify-content: center;
  align-items: center;
  padding: 4px;
  width: calc(100% - 8px);
  margin-left: 4px;
  margin-right: 4px;
  min-height: 48px;
}

#app-sidebar.app-sidebar[data-collapsed="true"] .nav-icon {
  width: 2.65rem;
  height: 2.65rem;
}

#app-sidebar.app-sidebar[data-collapsed="true"] .nav-icon svg {
  width: 2.2rem;
  height: 2.2rem;
}

#app-sidebar.app-sidebar[data-collapsed="true"] .nav-icon-img img {
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 8px;
}

#app-sidebar.app-sidebar[data-collapsed="true"] .sidebar-header {
  justify-content: center;
}

#app-shell [data-view].view-page {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
}

#app-shell [data-view].hidden {
  display: none !important;
}


/* Mobile opener and backdrop stay out of the desktop flex row. */
#btn-mobile-nav.mobile-nav-toggle {
  display: none;
}

#app-nav-backdrop {
  display: none;
}

@media (max-width: 980px) {
  /* Keep a row shell. The drawer is fixed, so it has no document-flow size. */
  #app-shell.phantom-desktop-shell {
    flex-direction: row;
  }

  #btn-mobile-nav.mobile-nav-toggle {
    display: inline-flex;
    position: fixed;
    z-index: 40;
    top: calc(8px + env(safe-area-inset-top, 0px));
    left: calc(8px + env(safe-area-inset-left, 0px));
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    align-items: center;
    justify-content: center;
    appearance: none;
    -webkit-appearance: none;
    background: #12121C;
    color: #F6F4FF;
    border: 1px solid #29283A;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
  }

  #btn-mobile-nav.mobile-nav-toggle svg {
    display: block;
    width: 18px;
    height: 18px;
  }

  #app-nav-backdrop:not([hidden]) {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 70;
    margin: 0;
    padding: 0;
    border: 0;
    background: rgba(5, 5, 9, 0.62);
  }

  #app-sidebar.app-sidebar,
  #app-sidebar.app-sidebar[data-collapsed="true"] {
    position: fixed;
    top: 0;
    right: auto;
    bottom: 0;
    left: 0;
    z-index: 80;
    width: min(86vw, 320px);
    min-width: 0;
    max-width: min(86vw, 320px);
    height: 100dvh;
    max-height: 100dvh;
    flex: 0 0 0px;
    margin: 0;
    border-right: 1px solid #29283A;
    border-bottom: 0;
    box-sizing: border-box;
    padding-top: env(safe-area-inset-top, 0px);
    padding-right: 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    padding-left: env(safe-area-inset-left, 0px);
    transform: translateX(-100%);
    visibility: hidden;
    pointer-events: none;
    overflow: hidden;
    transition: transform 160ms ease;
  }

  #app-sidebar.app-sidebar[data-mobile-open="true"],
  #app-sidebar.app-sidebar[data-collapsed="true"][data-mobile-open="true"] {
    transform: translateX(0);
    visibility: visible;
    pointer-events: auto;
  }

  /* Stored desktop collapse must not hide labels or enlarge icons here. */
  #app-sidebar.app-sidebar[data-collapsed="true"] .nav-label,
  #app-sidebar.app-sidebar[data-collapsed="true"] .sidebar-brand,
  #app-sidebar.app-sidebar[data-collapsed="true"] .nav-soon-tag,
  #app-sidebar.app-sidebar[data-collapsed="true"] .nav-restricted-label {
    display: inline !important;
  }

  #app-sidebar.app-sidebar[data-collapsed="true"] .nav-section,
  #app-sidebar.app-sidebar[data-collapsed="true"] .sidebar-user-badge,
  #app-sidebar.app-sidebar[data-collapsed="true"] .sidebar-logo {
    display: block !important;
  }

  #app-sidebar .sidebar-toggle {
    display: none !important;
  }

  #app-sidebar .sidebar-header {
    justify-content: flex-start;
    min-height: 48px;
    height: auto;
  }

  /* Brand row is the drawer close control. It must not navigate. */
  #btn-mobile-nav-brand-close.mobile-nav-brand-close {
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    flex: 1 1 auto;
    align-self: stretch;
    box-sizing: border-box;
    width: 100%;
    min-width: 48px;
    min-height: 48px;
    margin: 0;
    padding: 4px 8px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #B59BFF;
    font: inherit;
    font-weight: 700;
    text-align: left;
    cursor: pointer;
    touch-action: manipulation;
  }

  #btn-mobile-nav-brand-close.mobile-nav-brand-close:focus-visible {
    outline: 3px solid #B59BFF;
    outline-offset: 2px;
  }

  #app-sidebar.app-sidebar[data-collapsed="true"] button.nav-item,
  #app-sidebar button.nav-item {
    flex-direction: row;
    justify-content: flex-start;
    align-items: center;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    min-height: 48px;
    height: auto;
    margin-left: 0;
    margin-right: 0;
    padding: 10px 12px;
  }

  #app-sidebar.app-sidebar[data-collapsed="true"] .nav-icon,
  #app-sidebar .nav-icon {
    width: 1.35rem;
    height: 1.35rem;
  }

  #app-sidebar.app-sidebar[data-collapsed="true"] .nav-icon svg,
  #app-sidebar .nav-icon svg {
    width: 1.15rem;
    height: 1.15rem;
  }

  #app-sidebar.app-sidebar[data-collapsed="true"] .nav-icon-img img,
  #app-sidebar .nav-icon-img img {
    width: 1.25rem;
    height: 1.25rem;
    border-radius: 5px;
  }

  #app-sidebar .sidebar-nav {
    display: block;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  #app-sidebar .nav-section {
    display: block;
  }

  #app-sidebar .sidebar-utility {
    display: block;
    border-top: 1px solid #29283A;
  }

  #app-sidebar .profile-menu-panel button {
    min-height: 48px;
    box-sizing: border-box;
  }

  /* Collapsed header is the menu trigger plus banner content. Do not float
     Library or Sign in beside the hamburger, even if a reach host appears. */
  #main > .mobile-primary-reach,
  #app-shell > .mobile-primary-reach {
    display: none !important;
    height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    visibility: hidden !important;
    pointer-events: none !important;
  }

  /* Banners stay first in the column. A left gutter keeps the fixed control
     off banner text: a phone banner is only about 46px tall. */
  #app-shell main#main {
    padding-top: calc(8px + env(safe-area-inset-top, 0px));
    padding-right: calc(12px + env(safe-area-inset-right, 0px));
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    padding-left: calc(56px + env(safe-area-inset-left, 0px));
  }

  html.phantom-mobile-nav-open,
  html.phantom-mobile-nav-open body,
  html.phantom-mobile-nav-open #app-shell,
  html.phantom-mobile-nav-open #app-shell .app-main-column,
  html.phantom-mobile-nav-open #app-shell main#main {
    overflow: hidden;
    overscroll-behavior: none;
  }
}

@media (max-width: 980px) and (prefers-reduced-motion: reduce) {
  #app-sidebar.app-sidebar,
  #app-sidebar.app-sidebar[data-collapsed="true"] {
    transition: none;
  }
}

.notification-trigger-r2 {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  position: relative;
  min-height: 42px;
}

.notification-trigger-r2 img {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
}

.notification-unread-dot-r2 {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #c9a75b;
  box-shadow: 0 0 0 2px #0d0d14;
}

.notification-centre-r2 {
  position: fixed;
  z-index: 10020;
  top: calc(64px + env(safe-area-inset-top, 0px));
  right: max(16px, env(safe-area-inset-right, 0px));
  width: min(420px, calc(100vw - 32px));
  max-height: min(70vh, 620px);
  overflow: auto;
  padding: 18px;
  border: 1px solid #8b5cf6;
  border-radius: 14px;
  background: #0d0d14;
  color: #f6f4ff;
  box-shadow: 0 18px 52px #000b;
}

.notification-centre-r2.hidden,
.notification-centre-r2[hidden] {
  display: none !important;
}

.notification-centre-r2 h2 {
  margin: 0 0 8px;
  color: #f6f4ff;
}

.notification-centre-r2 ul {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.notification-centre-r2 li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border: 1px solid #3b3150;
  border-radius: 10px;
}

.notification-centre-r2 li a {
  color: #f6f4ff;
  text-decoration-color: #c9a75b;
  overflow-wrap: anywhere;
}

.notification-centre-r2 li button {
  min-height: 36px;
}

@media (max-width: 640px) {
  .notification-centre-r2 {
    top: auto;
    right: max(12px, env(safe-area-inset-right, 0px));
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    left: max(12px, env(safe-area-inset-left, 0px));
    width: auto;
    max-height: min(72vh, 620px);
  }

  .notification-centre-r2 li {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .notification-centre-r2 li a {
    grid-column: 1 / -1;
  }
}
