/* #1178 L1 — optional visual shell B; the canonical A DOM remains unchanged. */
.shell-mode-toggle {
  display: none;
}

/* #1254 — keep the viewport-centred destinations separate from utilities.
   R6 already exposes the full account name in its native popover. Reserve
   room for Administration and the A/B switch before expanding that label. */
@media (min-width: 1024px) and (max-width: 1399px) {
  html body.authenticated-shell > header > .bar:has(.primary-nav.has-workspace) .desktop-account-label {
    max-width: 110px;
  }
}

@media (min-width: 1400px) and (max-width: 1599px) {
  html body.authenticated-shell[data-shell-mode="a"] > header > .bar:has(.primary-nav.has-workspace) .desktop-account-label {
    max-width: 110px;
  }
}

@media (min-width: 1400px) {
  body.authenticated-shell.shell-mode-ready .shell-mode-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    max-width: 100%;
    border: 1px solid var(--color-line);
    border-radius: 10px;
    padding: 8px 10px;
    background: var(--color-canvas);
    color: var(--color-ink);
    font-size: .8rem;
    line-height: 1.2;
    text-align: center;
  }

  body.authenticated-shell .shell-mode-toggle:focus-visible {
    outline: 3px solid var(--color-focus);
    outline-offset: 2px;
  }

  html body.authenticated-shell[data-shell-mode="b"] {
    --shell-b-rail: 224px;
    background: #f3f6fc;
  }

  html body.authenticated-shell[data-shell-mode="b"] > header.desktop-shell-header {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 100;
    width: var(--shell-b-rail);
    height: 100vh;
    height: 100dvh;
    border: 0;
    overflow-x: hidden;
    overflow-y: auto;
    background: linear-gradient(160deg, #101e37, #213b62);
    box-shadow: 4px 0 24px rgb(20 38 69 / 14%);
    color: #e4efff;
    scrollbar-width: thin;
  }

  html body.authenticated-shell[data-shell-mode="b"] > header.desktop-shell-header > .bar {
    position: static;
    width: 100%;
    max-width: none;
    min-height: 100%;
    margin: 0;
    padding: 23px 12px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 21px;
  }

  html body.authenticated-shell[data-shell-mode="b"] > header.desktop-shell-header > .bar > .brand {
    flex: none;
    width: 100%;
    max-width: 100%;
    margin: 0;
    border: 0;
    padding: 5px 10px 10px;
    color: #fff;
    font-size: 1.11rem;
    line-height: 1.2;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  html body.authenticated-shell[data-shell-mode="b"] > header.desktop-shell-header > .bar > .primary-nav {
    flex: none;
    width: 100%;
    max-width: none;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 12px;
  }

  html body.authenticated-shell[data-shell-mode="b"] > header.desktop-shell-header .desktop-workspace-switcher {
    flex: none;
    width: 100%;
    min-width: 0;
    max-width: none;
  }

  html body.authenticated-shell[data-shell-mode="b"] > header.desktop-shell-header .desktop-workspace-switcher > summary {
    background: rgb(255 255 255 / 9%);
    border-color: rgb(207 224 255 / 38%);
    color: #f4f8ff;
    overflow-wrap: anywhere;
  }

  html body.authenticated-shell[data-shell-mode="b"] > header.desktop-shell-header .desktop-workspace-switcher__name {
    color: #f4f8ff;
  }

  html body.authenticated-shell[data-shell-mode="b"] > header.desktop-shell-header .desktop-workspace-switcher > summary::after {
    color: #dce9ff;
  }

  /* Override the historic .bar:has(.primary-nav.has-workspace) centering
     selector with a stronger, DOM-specific B composition. No duplicated nav. */
  html body.authenticated-shell[data-shell-mode="b"] > header.desktop-shell-header > .bar > .primary-nav.has-workspace > .scope-navigation,
  html body.authenticated-shell[data-shell-mode="b"] > header.desktop-shell-header > .bar > .primary-nav:not(.has-workspace) > .scope-navigation {
    position: static;
    top: auto;
    left: auto;
    width: 100%;
    max-width: none;
    transform: none;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    z-index: auto;
  }

  html body.authenticated-shell[data-shell-mode="b"] > header.desktop-shell-header .scope-navigation :is(.personal-nav, .daily-nav) {
    flex: none;
    width: 100%;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 5px;
    margin: 0;
    border: 0;
    padding: 0;
  }

  html body.authenticated-shell[data-shell-mode="b"] > header.desktop-shell-header .scope-navigation :is(.personal-nav-link, .daily-nav a) {
    display: flex;
    width: 100%;
    min-height: 43px;
    align-items: center;
    border-radius: 10px;
    padding: 9px 12px;
    color: #dce9ff;
    font-size: .89rem;
    font-weight: 700;
    line-height: 1.25;
    text-decoration: none;
    white-space: normal;
  }

  html body.authenticated-shell[data-shell-mode="b"] > header.desktop-shell-header .scope-navigation :is(.personal-nav-link, .daily-nav a):is(:hover, :focus-visible) {
    background: rgb(255 255 255 / 12%);
    color: #fff;
  }

  html body.authenticated-shell[data-shell-mode="b"] > header.desktop-shell-header .scope-navigation :is(.personal-nav-link, .daily-nav a)[aria-current="page"] {
    background: linear-gradient(90deg, #426cdb, #315dba);
    color: #fff;
    box-shadow: inset 3px 0 #a8c6ff;
  }

  html body.authenticated-shell[data-shell-mode="b"] > header.desktop-shell-header .personal-nav-scope {
    display: none;
  }

  html body.authenticated-shell[data-shell-mode="b"] > header.desktop-shell-header > .bar > .shell-utilities {
    flex: none;
    width: 100%;
    min-width: 0;
    margin: auto 0 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 9px;
  }

  html body.authenticated-shell[data-shell-mode="b"] > header.desktop-shell-header .shell-mode-toggle {
    width: 100%;
    border-color: rgb(207 224 255 / 42%);
    background: rgb(255 255 255 / 11%);
    color: #fff;
  }

  html body.authenticated-shell[data-shell-mode="b"] > header.desktop-shell-header .shell-utilities > details {
    width: 100%;
    min-width: 0;
  }

  html body.authenticated-shell[data-shell-mode="b"] > header.desktop-shell-header .shell-utilities > details > summary {
    width: 100%;
    color: #edf4ff;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  /* The Mission 17 .bar:has(.primary-nav.has-workspace) utility-menu rules
     otherwise set muted ink (and a light hover surface) on the dark B rail.
     Keep this override bound to B and to the canonical utility summaries. */
  html body.authenticated-shell[data-shell-mode="b"] > header.desktop-shell-header > .bar > .shell-utilities > .nav-menu > summary {
    color: #edf4ff;
    background: rgb(255 255 255 / 8%);
  }

  html body.authenticated-shell[data-shell-mode="b"] > header.desktop-shell-header > .bar > .shell-utilities > .nav-menu > summary:is(:hover, :focus-visible, [aria-current="page"]) {
    color: #fff;
    background: rgb(255 255 255 / 16%);
  }

  html body.authenticated-shell[data-shell-mode="b"] > header.desktop-shell-header > .bar > .shell-utilities > .nav-menu > summary:focus-visible {
    outline: 3px solid #a8c6ff;
    outline-offset: 2px;
  }

  html body.authenticated-shell[data-shell-mode="b"] > header.desktop-shell-header :is(.nav-menu, .workspace-switcher) > .nav-popover {
    position: static;
    inset: auto;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    margin-top: 5px;
    box-shadow: none;
  }

  html body.authenticated-shell[data-shell-mode="b"] > header.desktop-shell-header .desktop-breadcrumb {
    display: none;
  }

  html body.authenticated-shell[data-shell-mode="b"] > main {
    width: calc(100% - var(--shell-b-rail) - 48px);
    max-width: none;
    min-width: 0;
    margin-left: calc(var(--shell-b-rail) + 24px);
    margin-right: 24px;
  }

  html body.authenticated-shell[data-shell-mode="b"] > main .desktop-surface[data-desktop-surface] {
    width: 100%;
    max-width: 100%;
    margin-inline: 0;
  }
}

@media (forced-colors: active) and (min-width: 1400px) {
  html body.authenticated-shell[data-shell-mode="b"] > header.desktop-shell-header {
    border-right: 2px solid CanvasText;
  }

  html body.authenticated-shell[data-shell-mode="b"] > header.desktop-shell-header .scope-navigation [aria-current="page"] {
    outline: 2px solid Highlight;
    outline-offset: -2px;
  }
}
