/* Desktop homepage navigation only. Mobile rules and the workbench stay independent. */
.nav-label-short, .desktop-nav-menu { display: none; }
@media screen and (min-width: 721px) {
  .navbar .nav-inner { gap: 14px; }
  .navbar .brand { flex: 1 1 260px; min-width: 135px; max-width: 290px; overflow: hidden; }
  .navbar .brand-mark { flex-shrink: 0; }
  .navbar .brand-text { min-width: 0; overflow: hidden; }
  .navbar .brand-text b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .navbar .brand-text small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .navbar .nav-links { display: flex; flex: 0 0 auto; gap: 18px; white-space: nowrap; }
  .navbar .nav-links > a { flex-shrink: 0; }
  .navbar .nav-actions { flex: 0 0 auto; gap: 7px; white-space: nowrap; }
  .navbar .nav-actions .btn { padding: 0 11px; flex-shrink: 0; }
  .navbar .token-pill { flex-shrink: 0; flex-wrap: nowrap; white-space: nowrap; height: 36px; font-family: inherit; padding: 0 11px; }
  .navbar .token-pill > * { flex-shrink: 0; }
  .navbar .nav-user { max-width: 140px; }
  .navbar .nav-username { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
  .navbar[data-nav-layout="compact"] .nav-links { gap: 12px; }
  .navbar[data-nav-layout="compact"] .nav-label-full,
  .navbar[data-nav-layout="compact"] .nav-secondary { display: none; }
  .navbar[data-nav-layout="compact"] .nav-label-short { display: inline; }
  .navbar[data-nav-layout="compact"] .desktop-nav-menu,
  .navbar[data-nav-layout="menu"] .desktop-nav-menu { display: block; }
  .navbar[data-nav-layout="menu"] .nav-links > a { display: none; }
  .navbar[data-nav-layout="compact"] .nav-overflow-primary,
  .navbar[data-nav-layout="menu"] .nav-more-label { display: none; }
  .navbar[data-nav-layout="menu"] .brand-text small { display: none; }
  .navbar[data-nav-account="compact"] .nav-promo,
  .navbar[data-nav-account="compact"] .nav-logout { display: none; }
  .navbar[data-nav-account="compact"] .brand { min-width: 90px; }
  .navbar[data-nav-account="compact"] .nav-user { max-width: 85px; }
  html[data-nav-account="compact"] .mobile-account-tools { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
  .desktop-nav-menu { position: relative; align-self: center; }
  .desktop-nav-menu summary { cursor: pointer; list-style: none; border: 1px solid #334155; border-radius: 8px; padding: 8px 10px; color: #e2e8f0; font-size: 13px; }
  .desktop-nav-menu summary::-webkit-details-marker { display: none; }
  .desktop-nav-menu summary:focus-visible { outline: 2px solid #60a5fa; outline-offset: 3px; }
  .nav-menu-label { display: none; }
  .navbar[data-nav-layout="menu"] .nav-menu-label { display: inline; }
  .desktop-nav-panel { position: fixed; top: 76px; left: clamp(12px, var(--nav-menu-left, 12px), calc(100vw - 282px)); width: 270px; max-width: calc(100vw - 32px); max-height: 70vh; overflow-y: auto; padding: 8px; border: 1px solid #334155; border-radius: 12px; background: #0f172a; box-shadow: 0 16px 35px #0006; }
  .desktop-nav-panel a { display: block; padding: 11px; white-space: normal; overflow-wrap: anywhere; border-radius: 7px; }
  .desktop-nav-panel a:hover, .desktop-nav-panel a:focus-visible { background: #1e293b; }
}
/* Coarse-pointer landscape uses the existing phone UI, even above 720px. */
@media screen and (max-width: 1024px) and (max-height: 600px) and (pointer: coarse) {
  .navbar .nav-links { display: none; }
  .navbar .brand { flex: 1; min-width: 0; max-width: none; }
  .navbar .nav-actions .btn { padding: 8px; }
  .navbar .nav-user { max-width: 100px; }
}

/* Preserve desktop flex geometry; the same live links/account nodes fold on phones. */
.portal-nav-content { display: contents; }
.mobile-nav-toggle { display: none; }
@media screen and (max-width: 720px), screen and (max-width: 1024px) and (max-height: 600px) and (pointer: coarse) {
  .navbar[data-mobile-nav-ready] .mobile-nav-toggle {
    display: inline-flex; flex: 0 0 auto; align-items: center; justify-content: center; gap: 8px;
    min-height: 40px; padding: 8px 11px; border: 1px solid #475569; border-radius: 9px;
    background: #17243b; color: #f8fafc; cursor: pointer; font: inherit; font-size: 13px;
  }
  .mobile-nav-bars { display: flex; flex-direction: column; gap: 4px; width: 18px; }
  .mobile-nav-bars i { display: block; width: 18px; height: 2px; border-radius: 2px; background: currentColor; }
  .navbar[data-mobile-nav-ready] .mobile-nav-toggle[aria-expanded=true] { background: #1e40af; border-color: #60a5fa; }
  .mobile-nav-toggle:focus-visible { outline: 2px solid #93c5fd; outline-offset: 3px; }
  .navbar[data-mobile-nav-ready] .portal-nav-content {
    display: none; position: absolute; top: 100%; left: 0; right: 0; padding: 12px;
    max-height: calc(100dvh - 68px); max-height: min(78dvh, calc(100dvh - 68px)); overflow-y: auto;
    overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
    background: #0f172a; border-bottom: 1px solid #334155; box-shadow: 0 16px 28px #02061755;
  }
  .navbar[data-mobile-nav-ready][data-mobile-open=true] .portal-nav-content { display: flex; flex-direction: column; gap: 14px; }
  .navbar[data-mobile-nav-ready] .portal-nav-content .nav-links { display: flex; flex-direction: column; align-items: stretch; gap: 3px; white-space: normal; }
  .navbar[data-mobile-nav-ready] .portal-nav-content .nav-links > a { display: block; padding: 11px 12px; min-height: 44px; border-radius: 8px; overflow-wrap: anywhere; }
  .navbar[data-mobile-nav-ready] .portal-nav-content .nav-links > a:hover,
  .navbar[data-mobile-nav-ready] .portal-nav-content .nav-links > a:focus-visible { background: #1e293b; color: #fff; }
  .navbar[data-mobile-nav-ready] .portal-nav-content .desktop-nav-menu,
  .navbar[data-mobile-nav-ready] .portal-nav-content .nav-label-short { display: none; }
  .navbar[data-mobile-nav-ready] .portal-nav-content .nav-label-full { display: inline; }
  .navbar[data-mobile-nav-ready] #navAuthArea { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 14px 0 max(4px,env(safe-area-inset-bottom)); border-top: 1px solid #334155; white-space: normal; min-width: 0; }
  .navbar[data-mobile-nav-ready] #navAuthArea > button { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; max-width: 100%; padding: 9px 12px; white-space: normal; overflow-wrap: anywhere; }
  .navbar[data-mobile-nav-ready] #navAuthArea .token-pill { display: inline-flex; flex-wrap: wrap; height: auto; max-width: 100%; min-height: 40px; padding: 8px 12px; font-family: inherit; white-space: normal; overflow-wrap: anywhere; }
  .navbar[data-mobile-nav-ready] #navAuthArea .nav-user { max-width: 100%; min-width: 0; }
  .navbar[data-mobile-nav-ready] #navAuthArea .nav-username { min-width: 0; overflow-wrap: anywhere; white-space: normal; }
}
