body.page-shell {
  --shell-sidebar-width: 304px;
  --shell-header-height: 84px;
  --shell-z-header: 9720;
  --shell-z-header-active: 9770;
  --shell-z-backdrop: 9760;
  --shell-z-sidebar: 9790;
  --shell-paper: #f4d978;
  --shell-paper-strong: #faecc0;
  --shell-brown: #333333;
  --shell-brown-soft: rgba(244, 217, 120, 0.78);
  --shell-brown-deep: #333333;
  --shell-orange: #c99a28;
  --shell-mustard: #ebcd75;
  --shell-line: rgba(244, 217, 120, 0.18);
  --shell-shadow: rgba(0, 0, 0, 0.18);
  width: 100%;
}

body.page-shell .app-header,
body.page-shell .app-header[hidden] {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: var(--shell-z-header);
  height: var(--shell-header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 24px;
  background: #333;
  border-bottom: 1px solid var(--shell-line);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(18px);
  transition: left 0.28s ease;
  height: 95px;
}

body.page-shell.sidebar-open .app-header {
  left: var(--shell-sidebar-width);
}

body.page-shell .header-left {
  min-width: 0;
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  grid-template-areas:
    "button page"
    "button brand";
  align-items: center;
  column-gap: 14px;
  row-gap: 2px;
}

body.page-shell .header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 0 1 auto;
  justify-content: flex-end;
  position: relative;
}

body.page-shell .drawer-toggle {
  grid-area: button;
  width: 46px;
  height: 46px;
  min-height: 46px;
  padding: 0;
  border: 0;
  border-radius: 14px;
  background: var(--shell-brown);
  color: var(--shell-paper-strong);
  box-shadow: 0 10px 22px var(--shell-shadow);
  font-size: 0;
  position: relative;
  text-transform: none;
  cursor: pointer;
}

body.page-shell .drawer-toggle::before {
  content: "☰";
  font-size: 22px;
  line-height: 1;
}

body.page-shell .drawer-toggle:hover {
  background: var(--shell-orange);
  transform: translateY(-1px);
}

body.page-shell .header-page {
  grid-area: page;
  display: block;
  min-height: auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: var(--shell-paper-strong);
  font-family: 'Playfair Display', serif;
  font-size: 24px;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

body.page-shell .header-brand {
  grid-area: brand;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(244, 217, 120, 0.72);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

body.page-shell .header-chip {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  max-width: min(42vw, 260px);
  padding: 0 16px;
  border: 1px solid rgba(244, 217, 120, 0.22);
  border-radius: 999px;
  background: rgba(244, 217, 120, 0.14);
  box-shadow: none;
  color: var(--shell-paper-strong);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

body.page-shell .header-chip.role-switchable {
  cursor: pointer;
  user-select: none;
}

body.page-shell .header-chip.role-switchable::after {
  content: "▾";
  margin-left: 10px;
  font-size: 12px;
}

body.page-shell .header-right {
  position: relative;
}

body.page-shell .role-scope-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 220px;
  /* max-height: min(340px, calc(100vh - 140px)); */
  padding: 10px;
  border: 1px solid rgba(244, 217, 120, 0.18);
  border-radius: 20px;
  background: rgba(51, 51, 51, 0.98);
  box-shadow: 0 18px 30px rgba(0, 0, 0, 0.24);
  display: grid;
  gap: 8px;
  overflow-y: auto;
  z-index: 2;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-10px) scale(0.98);
  transform-origin: top right;
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s ease;
  overflow: hidden;
}

body.page-shell .role-scope-menu[hidden] {
  display: none;
}

body.page-shell .role-scope-menu.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

body.page-shell .role-scope-option {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid rgba(244, 217, 120, 0.14);
  border-radius: 14px;
  background: rgba(244, 217, 120, 0.08);
  color: var(--shell-paper-strong);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
  margin-bottom: 7px;
  border: 1px solid rgba(244, 217, 120, 0.22);
  box-shadow: 0px 0px 0 #4b2c20;
}

body.page-shell .role-scope-option.active,
body.page-shell .role-scope-option:hover {
  background: linear-gradient(135deg, rgba(201, 154, 40, 0.94), rgba(235, 205, 117, 0.92));
  color: #333333;
}

body.page-shell .drawer-backdrop,
body.page-shell .drawer-backdrop[hidden] {
  position: fixed;
  inset: 0;
  z-index: var(--shell-z-backdrop);
  display: block;
  opacity: 0;
  pointer-events: none;
  background: rgba(36, 23, 15, 0.42);
  transition: opacity 0.28s ease;
}

body.page-shell.sidebar-open .drawer-backdrop {
  opacity: 1;
  pointer-events: auto;
}

body.page-shell.role-scope-open .drawer-backdrop {
  opacity: 1;
  pointer-events: auto;
  background: rgba(36, 23, 15, 0.24);
}

body.page-shell.role-scope-open {
  overflow: hidden;
}

body.page-shell.role-scope-open .app-header {
  z-index: var(--shell-z-header-active);
}

body.page-shell .notice-stack {
  top: calc(var(--shell-header-height) + 16px);
  z-index: 70;
}

body.page-shell main {
  width: 100%;
  margin: 0;
  padding: calc(var(--shell-header-height) + 24px) 24px 32px 24px;
  transition: padding-left 0.28s ease;
}

body.page-shell.sidebar-open main {
  padding-left: calc(var(--shell-sidebar-width) + 24px);
}

body.page-shell .app-layout {
  display: block;
}

body.page-shell .content-stack {
  display: grid;
  gap: 16px;
  min-width: 0;
}

body.page-shell #nav.shell-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--shell-sidebar-width);
  max-width: 100%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 18px;
  padding: 11px 18px;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent 120px), linear-gradient(180deg, #363636, #282828);
  transform: translateX(calc(-100% - 18px));
  transition: transform 0.28s ease;
  z-index: var(--shell-z-sidebar);
  isolation: isolate;
}

body.page-shell.sidebar-open #nav.shell-sidebar {
  transform: translateX(0);
}

body.page-shell #nav.shell-sidebar {
  z-index: var(--shell-z-sidebar);
}

body.page-shell #navBackdrop.drawer-backdrop,
body.page-shell #navBackdrop.drawer-backdrop[hidden] {
  z-index: var(--shell-z-backdrop);
}

body.page-shell .sidebar-brand {
  display: flex;
  margin: 0px;
  align-items: center;
  gap: 14px;
  min-height: var(--shell-header-height);
  padding-bottom: 16px;
  border-bottom: 1px dashed rgba(255, 246, 223, 0.34);
}

body.page-shell .sidebar-logo {
  display: block;
  min-width: 86px;
  /* height: 86px; */
  background: transparent;
  padding: 4px;
  border-radius: 16px;
  object-fit: contain;
  /* box-shadow: inset 0 0 0 2px rgba(74, 47, 34, 0.22); */
  flex: 0 0 56px;
}

body.page-shell .sidebar-copy {
  min-width: 0;
}

body.page-shell .sidebar-copy strong {
  display: block;
  font-family: 'Playfair Display', serif;
  font-size: 19px;
  line-height: 1;
  letter-spacing: 0.04em;
  color: var(--shell-paper);
  text-transform: uppercase;
}

body.page-shell .sidebar-copy span {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(255, 246, 223, 0.78);
}


body.page-shell .sidebar-sections {
  display: grid;
  gap: 18px;
  align-content: start;
}

body.page-shell .sidebar-scroll {
  min-height: 0;
  padding-right: 6px;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(244, 217, 120, 0.08) rgba(255, 246, 223, 0.01);
}

body.page-shell .sidebar-scroll::-webkit-scrollbar {
  width: 10px;
}

body.page-shell .sidebar-scroll::-webkit-scrollbar-track {
  border-radius: 999px;
  background: rgba(255, 246, 223, 0.01);
}

body.page-shell .sidebar-scroll::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(244, 217, 120, 0.08);
  border: 2px solid rgba(51, 51, 51, 0.08);
}

body.page-shell .sidebar-scroll::-webkit-scrollbar-thumb:hover {
  background: rgba(244, 217, 120, 0.12);
}

body.page-shell .sidebar-section {
  display: grid;
  gap: 10px;
}

body.page-shell .sidebar-section-title {
  margin: 0;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(255, 246, 223, 0.62);
}

body.page-shell .sidebar-links {
  display: grid;
  gap: 8px;
}

body.page-shell .sidebar-link {
  display: grid;
  gap: 4px;
  padding: 13px 14px;
  border-radius: 18px;
  border: 1px solid rgba(255, 246, 223, 0.1);
  background: rgba(255, 246, 223, 0.05);
  color: var(--shell-paper);
  box-shadow: none;
  text-decoration: none;
  transition: transform 0.18s ease, background-color 0.18s ease, border-color 0.18s ease;
}

body.page-shell .sidebar-link:hover,
body.page-shell .sidebar-link.active {
  background: linear-gradient(135deg, rgba(201, 111, 53, 0.96), rgba(168, 74, 30, 0.96));
  border-color: rgba(255, 232, 208, 0.18);
  transform: translateX(4px);
}

body.page-shell .sidebar-link-label {
  font-size: 14px;
  font-weight: 800;
  color: inherit;
}

body.page-shell .sidebar-link-caption {
  font-size: 12px;
  line-height: 1.45;
  color: rgba(255, 246, 223, 0.72);
}

body.page-shell .sidebar-link.active .sidebar-link-caption,
body.page-shell .sidebar-link:hover .sidebar-link-caption {
  color: rgba(255, 248, 233, 0.94);
}

body.page-shell .sidebar-empty {
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(255, 246, 223, 0.08);
  color: rgba(255, 246, 223, 0.82);
  font-size: 14px;
  line-height: 1.6;
}

body.page-shell .sidebar-footer {
  margin: 9px;
  padding-top: 18px;
  border-top: 1px dashed rgba(255, 246, 223, 0.34);
  /* background: linear-gradient(180deg, rgba(51, 51, 51, 0), rgba(51, 51, 51, 0.32)); */
}

body.page-shell .sidebar-user-label {
  display: block;
  margin-bottom: 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(255, 246, 223, 0.66);
}

body.page-shell .sidebar-user-card {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid rgba(255, 246, 223, 0.12);
  border-radius: 18px;
  background: rgba(255, 246, 223, 0.08);
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease;
}

body.page-shell .sidebar-user-card:hover,
body.page-shell .sidebar-user-card[aria-expanded="true"] {
  background: rgba(255, 246, 223, 0.14);
  border-color: rgba(255, 246, 223, 0.22);
}

body.page-shell .sidebar-user-menu,
#sidebarUserMenu {
  position: fixed;
  left: 51px;
  width: 265px;
  bottom: 155px;
  top: auto;
  z-index: 9999;
  padding: 8px;
  border-radius: 18px;
  background: #2e2e2e;
  border: 1px solid rgba(255, 246, 223, 0.14);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.38);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: none;
}

body.page-shell .sidebar-user-menu.is-open,
#sidebarUserMenu.is-open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

body.page-shell .sidebar-user-avatar {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: linear-gradient(180deg, #f0c773, #dfa64e);
  color: var(--shell-brown-deep);
  box-shadow: inset 0 0 0 2px rgba(74, 47, 34, 0.2);
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  overflow: hidden;
}

body.page-shell .sidebar-user-avatar.has-photo {
  padding: 0;
  background: rgba(255, 246, 223, 0.14);
}

body.page-shell .sidebar-user-avatar img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

body.page-shell .sidebar-user-meta {
  min-width: 0;
}

body.page-shell .sidebar-user-name {
  display: block;
  font-family: 'Playfair Display', serif;
  font-size: 20px;
  line-height: 1.2;
  color: var(--shell-paper);
  word-break: break-word;
}

body.page-shell .sidebar-role-pill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  margin-top: 10px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(255, 246, 223, 0.12);
  color: var(--shell-paper);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.role-scope-options {
  height: 89vh;
  overflow-y: auto;
  padding: 0px;
  margin: 0px;
  border-radius: 15px;

}

@media (min-width: 961px) {
  body.page-shell.sidebar-open .drawer-backdrop {
    opacity: 0;
    pointer-events: none;
  }
}

@media (max-width: 960px) {
  body.page-shell .drawer-backdrop,
  body.page-shell .drawer-backdrop[hidden] {
    z-index: var(--shell-z-backdrop);
  }

  body.page-shell #nav.shell-sidebar {
    z-index: var(--shell-z-sidebar);
  }

  body.page-shell .app-header,
  body.page-shell .app-header[hidden] {
    left: 0;
    padding: 0 16px;
  }

  body.page-shell.sidebar-open {
    overflow: hidden;
  }

  body.page-shell.sidebar-open main {
    padding-left: 16px;
  }

  body.page-shell main {
    padding: calc(var(--shell-header-height) + 20px) 16px 24px 16px;
  }

  body.page-shell .sidebar-scroll {
    padding-right: 2px;
  }

  body.page-shell .header-chip {
    display: inline-flex;
    max-width: min(52vw, 210px);
    min-height: 40px;
    padding: 0 12px;
    font-size: 11px;
    letter-spacing: 0.05em;
    flex: 0 1 auto;
  }

  body.page-shell .header-chip.role-switchable::after {
    margin-left: 8px;
    font-size: 11px;
  }

  body.page-shell .header-left {
    grid-template-columns: 42px minmax(0, 1fr);
    column-gap: 10px;
  }

  body.page-shell .header-page {
    font-size: 18px;
  }

  body.page-shell .header-brand {
    font-size: 10px;
    letter-spacing: 0.14em;
  }

  body.page-shell .role-scope-menu {
    position: fixed;
    left: 50%;
    right: auto;
    top: 50%;
    bottom: auto;
    width: min(420px, calc(151vw - 32px));
    min-width: 0;
    max-height: fit-content;
    border-radius: 24px;
    z-index: 84;
    transform: translate(-50%, calc(-50% + 20px)) scale(0.98);
    transform-origin: center center;
    overflow: hidden;
  }

  body.page-shell .role-scope-menu.is-open {
    transform: translate(-50%, 15%) scale(0.9)
  }
}
