/* Nord SaaS Lite mobile shell v2: desktop >=1025px intentionally untouched.
   This is the final mobile layout authority for the platform and Nexus. */
/* Transient drawer nodes must never appear after switching back to desktop. */
.nord-mobile-quicknav { display:none!important; }
@media (max-width:1024px) {
  :root { --nord-mobile-bar:64px; }
  html, body { max-width:100%; overflow-x:clip!important; }

  /* Full-width content. The former Discord rail becomes drawer quick actions. */
  #appShell.nord-shell, body.nord-nexus-active #appShell.nord-shell {
    display:block!important; grid-template-columns:minmax(0,1fr)!important;
    width:100%!important; max-width:100%!important;
    min-width:0!important; margin:0!important;
  }
  #appShell #workspaceRail.nord-rail,
  body.nord-nexus-active #appShell #workspaceRail.nord-rail {
    display:none!important; visibility:hidden!important;
    width:0!important; min-width:0!important; max-width:0!important;
    pointer-events:none!important;
  }
  #appShell .nord-main, body.nord-nexus-active #appShell .nord-main {
    grid-column:1!important; width:100%!important; min-width:0!important;
    max-width:100%!important; margin:0!important;
  }

  /* Unified menu drawer and full-viewport backdrop. */
  #appShell #sidebar.nord-sidebar,
  body.nord-nexus-active #appShell #nordNexusSidebar.nx-sidebar {
    position:fixed!important; inset:0 auto 0 0!important; left:0!important;
    display:flex!important; flex-direction:column!important;
    width:min(340px,calc(100vw - 46px))!important;
    min-width:0!important; max-width:calc(100vw - 46px)!important;
    height:100dvh!important; min-height:0!important;
    margin:0!important;
    transform:translate3d(calc(-100% - 18px),0,0)!important;
    visibility:hidden!important; pointer-events:none!important;
    overflow:hidden!important; z-index:10010!important;
    transition:transform .2s ease,visibility .2s ease!important;
    box-shadow:16px 0 55px rgba(0,0,0,.4)!important;
  }
  /* Nexus owns its navigation; do not show the platform sidebar underneath. */
  body.nord-nexus-active #appShell #sidebar.nord-sidebar { display:none!important; }
  body:not(.nord-nexus-active) #appShell #nordNexusSidebar.nx-sidebar { display:none!important; }
  body.sidebar-open:not(.nord-nexus-active) #appShell #sidebar.nord-sidebar,
  body.nord-nexus-active.sidebar-open #appShell #nordNexusSidebar.nx-sidebar {
    transform:translate3d(0,0,0)!important;
    visibility:visible!important; pointer-events:auto!important;
  }
  #appShell #sidebarBackdrop.sidebar-backdrop {
    display:block!important; position:fixed!important;
    inset:0!important; left:0!important; top:0!important;
    width:100vw!important; height:100dvh!important;
    z-index:10000!important; border:0!important;
    background:rgba(2,6,13,.72)!important;
  }
  #appShell #sidebarBackdrop.sidebar-backdrop[hidden] { display:none!important; }
  body.sidebar-open { overflow:hidden!important; touch-action:none!important; }
  #appShell #sidebar > .community-sidebar-view,
  #appShell #sidebar > .account-sidebar-view,
  #appShell #sidebar > [class*="sidebar-view"] {
    flex:1 1 auto!important; height:auto!important; min-height:0!important;
    overflow-y:auto!important; overscroll-behavior:contain;
  }

  /* Exactly one topbar row, never the desktop two-row wrap. */
  #appShell .nord-main > .nord-topbar,
  body.nord-nexus-active #appShell .nord-main > .nord-topbar {
    position:sticky!important; top:0!important; left:auto!important;
    inset-inline:auto!important;
    display:grid!important; grid-template-columns:44px minmax(0,1fr) 44px!important;
    grid-template-rows:64px!important; align-items:center!important;
    justify-content:stretch!important; gap:8px!important;
    height:64px!important; min-height:64px!important; max-height:64px!important;
    width:100%!important; min-width:0!important; max-width:100%!important;
    padding:0 12px!important; margin:0!important;
    background:var(--surface)!important; border-bottom:1px solid var(--border)!important;
    overflow:visible!important; z-index:90!important;
  }
  body.nord-nexus-active #appShell .nord-main > .nord-topbar {
    grid-template-columns:44px minmax(0,1fr) 44px 44px!important;
  }
  #appShell .nord-topbar #mobileMenu.mobile-menu,
  body.nord-nexus-active #appShell .nord-topbar #mobileMenu.mobile-menu {
    display:grid!important; place-items:center!important;
    position:static!important; transform:none!important;
    grid-column:1!important; grid-row:1!important;
    width:44px!important; min-width:44px!important; max-width:44px!important;
    height:44px!important; min-height:44px!important;
    margin:0!important; padding:0!important;
    border-radius:12px!important; z-index:auto!important;
  }
  #appShell .nord-topbar #nordMobileTitle.nord-mobile-page-title {
    display:flex!important; grid-column:2!important; grid-row:1!important;
    flex-direction:column!important; align-items:flex-start!important;
    justify-content:center!important; min-width:0!important;
    width:100%!important; max-width:100%!important;
    margin:0!important; padding:0 2px!important;
    overflow:hidden!important;
  }
  #appShell #nordMobileTitle strong {
    display:block!important; width:100%!important; max-width:100%!important;
    font-size:16px!important; line-height:1.3!important; font-weight:800!important;
    white-space:nowrap!important; overflow:hidden!important; text-overflow:ellipsis!important;
  }
  #appShell #nordMobileTitle small {
    display:block!important; max-width:100%!important;
    font-size:11px!important; line-height:1.3!important;
    color:var(--muted)!important; white-space:nowrap!important;
    overflow:hidden!important; text-overflow:ellipsis!important;
  }
  /* Nexus used to inject an extra mobile title, duplicating the page label. */
  body.nord-nexus-active #appShell #nxTopbarTitle { display:none!important; }
  #appShell .nord-topbar #nordAccountMenuWrap {
    display:block!important; grid-column:3!important; grid-row:1!important;
    position:relative!important; justify-self:end!important; align-self:center!important;
    width:44px!important; min-width:44px!important; max-width:44px!important;
    height:44px!important; margin:0!important; z-index:100!important;
  }
  body.nord-nexus-active #appShell .nord-topbar #nordAccountMenuWrap {
    grid-column:4!important;
  }
  #appShell .nord-topbar #nordAccountTrigger {
    display:grid!important; place-items:center!important;
    width:44px!important; max-width:44px!important; min-width:44px!important;
    height:44px!important; min-height:44px!important;
    padding:3px!important; margin:0!important;
    border-radius:12px!important;
  }
  #appShell .nord-topbar #nordAccountTrigger .user-avatar {
    width:36px!important; height:36px!important;
    flex:none!important; margin:0!important;
  }
  #appShell .nord-topbar #nordAccountTrigger .nord-account-trigger-copy,
  #appShell .nord-topbar #nordAccountTrigger > i,
  #appShell .nord-topbar #accountTopbarContext,
  #appShell .nord-topbar .topbar-spacer,
  #appShell .nord-topbar .server-context,
  #appShell .nord-topbar .nord-legacy-topbar-action {
    display:none!important;
  }
  #appShell .nord-topbar #nordAccountDropdown {
    position:absolute!important; top:calc(100% + 10px)!important;
    right:0!important; left:auto!important;
    width:min(310px,calc(100vw - 24px))!important;
    max-width:min(310px,calc(100vw - 24px))!important;
    max-height:calc(100dvh - 86px)!important;
    overflow-y:auto!important; z-index:10050!important;
  }
  body.nord-nexus-active #appShell .nord-topbar #nxTopbarNotifications {
    display:grid!important; place-items:center!important;
    grid-column:3!important; grid-row:1!important;
    position:relative!important; width:44px!important; height:44px!important;
    min-width:44px!important; margin:0!important; padding:0!important;
    border-radius:12px!important;
  }
  body:not(.nord-nexus-active) #appShell .nord-topbar #nxTopbarNotifications { display:none!important; }
  #appShell #nxTopbarRefresh { display:none!important; }

  /* Nexus is the only module with its own fixed-height scroll viewport. */
  body.nord-nexus-active #appShell .nord-main {
    display:grid!important; grid-template-rows:64px minmax(0,1fr)!important;
    height:100dvh!important; min-height:0!important;
    max-height:100dvh!important; overflow:hidden!important;
  }
  body.nord-nexus-active #appShell .nord-main > .nord-topbar {
    position:relative!important; grid-row:1!important;
  }
  body.nord-nexus-active #appShell .nord-page {
    grid-row:2!important; min-height:0!important;
    width:100%!important; height:100%!important; max-height:100%!important;
    padding:0!important; margin:0!important;
    overflow-y:auto!important; overflow-x:hidden!important;
    overscroll-behavior:contain!important;
  }
  body.nord-nexus-active #appShell #page-hub,
  body.nord-nexus-active #appShell #page-hub .nx-shell,
  body.nord-nexus-active #appShell #page-hub .nx-grid,
  body.nord-nexus-active #appShell #page-hub .nx-main {
    width:100%!important; max-width:100%!important; min-width:0!important;
    margin:0!important; padding-left:0!important; padding-right:0!important;
  }
  body.nord-nexus-active #appShell #page-hub .nx-grid {
    display:block!important; grid-template-columns:minmax(0,1fr)!important;
  }
  body.nord-nexus-active #appShell #page-hub .nx-right { display:none!important; }
  body.nord-nexus-active #appShell #page-hub .nx-head { display:none!important; }
  body.nord-nexus-active #appShell #page-hub .nx-tabs {
    position:sticky!important; top:0!important; z-index:20!important;
    height:48px!important; min-height:48px!important;
    width:100%!important; margin:0!important;
    display:flex!important; flex-wrap:nowrap!important;
    background:var(--bg)!important;
  }
  body.nord-nexus-active #appShell #page-hub .nx-tabs > button {
    min-width:0!important; flex:1 1 0!important;
    white-space:nowrap!important; overflow:hidden!important;
    text-overflow:ellipsis!important;
  }

  /* Compact global navigation inside either off-canvas sidebar. */
  #appShell .nord-mobile-quicknav {
    display:block!important; flex:0 0 auto!important;
    width:100%!important; min-width:0!important;
    padding:12px!important; border-bottom:1px solid var(--border)!important;
    background:var(--surface)!important;
  }
  #appShell .nord-mobile-quicknav-top {
    display:flex; align-items:center; justify-content:space-between;
    gap:8px; margin-bottom:9px; min-width:0;
  }
  #appShell .nord-mobile-quicknav-top > strong {
    font-size:13px; font-weight:850; min-width:0;
    overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
  }
  #appShell .nord-mobile-quicknav-close {
    width:34px; height:34px; display:grid; place-items:center;
    border:1px solid var(--border); border-radius:10px;
    color:var(--text); background:var(--surface-2); cursor:pointer;
  }
  #appShell .nord-mobile-quicknav-actions {
    display:grid; grid-template-columns:repeat(4,minmax(0,1fr));
    gap:6px; width:100%;
  }
  #appShell .nord-mobile-quicknav-actions button,
  #appShell .nord-mobile-quicknav-profiles button {
    border:1px solid var(--border); border-radius:10px;
    background:var(--surface-2); color:var(--text-2);
    cursor:pointer; min-width:0;
  }
  #appShell .nord-mobile-quicknav-actions button {
    display:flex; flex-direction:column; gap:5px;
    align-items:center; justify-content:center;
    min-height:54px; padding:7px 3px;
  }
  #appShell .nord-mobile-quicknav-actions i { font-size:15px; }
  #appShell .nord-mobile-quicknav-actions span {
    width:100%; overflow:hidden; text-overflow:ellipsis;
    white-space:nowrap; font-size:10px; text-align:center;
  }
  #appShell .nord-mobile-quicknav button.active {
    background:var(--accent-soft); border-color:var(--accent); color:var(--accent);
  }
  #appShell .nord-mobile-quicknav-profiles {
    display:flex; gap:6px; overflow-x:auto; min-width:0;
    padding:9px 0 1px; scrollbar-width:none;
  }
  #appShell .nord-mobile-quicknav-profiles:empty { display:none; }
  #appShell .nord-mobile-quicknav-profiles::-webkit-scrollbar { display:none; }
  #appShell .nord-mobile-quicknav-profiles button {
    flex:0 0 auto; display:flex; align-items:center; gap:6px;
    max-width:150px; padding:7px 9px;
    font-size:11px; font-weight:700;
  }
  #appShell .nord-mobile-quicknav-profiles button > span {
    overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
  }
  #appShell #nordNexusSidebar .nx-sidebar-inner {
    flex:1 1 auto!important; min-height:0!important;
    overflow-y:auto!important;
  }
  #appShell #nordNexusSidebar .nx-nav { flex:0 0 auto; }
  #appShell .nord-page { min-width:0!important; max-width:100%!important; }
}

@media (max-width:380px) {
  #appShell .nord-main > .nord-topbar,
  body.nord-nexus-active #appShell .nord-main > .nord-topbar {
    padding:0 8px!important; gap:5px!important;
    grid-template-columns:42px minmax(0,1fr) 42px!important;
  }
  body.nord-nexus-active #appShell .nord-main > .nord-topbar {
    grid-template-columns:42px minmax(0,1fr) 42px 42px!important;
  }
  #appShell #nordMobileTitle strong { font-size:15px!important; }
}

/* nord-mobile-server-column-v3: Discord-style server icons inside the drawer.
   Entire layout is mobile-scoped; PC structure/styles remain unchanged. */
.nord-mobile-server-rail { display:none!important; }
@media (max-width:1024px) {
  #appShell #sidebar.nord-sidebar,
  body.nord-nexus-active #appShell #nordNexusSidebar.nx-sidebar {
    display:grid!important;
    grid-template-columns:68px minmax(0,1fr)!important;
    grid-template-rows:minmax(0,1fr)!important;
    align-items:stretch!important;
    padding:0!important;
    gap:0!important;
  }
  #appShell #sidebar.nord-sidebar > .nord-mobile-server-rail,
  body.nord-nexus-active #appShell #nordNexusSidebar.nx-sidebar > .nord-mobile-server-rail {
    display:flex!important;
    grid-column:1!important;
    grid-row:1!important;
    flex-direction:column!important;
    align-items:center!important;
    gap:0!important;
    width:68px!important;
    min-width:0!important;
    max-width:68px!important;
    min-height:0!important;
    height:100%!important;
    padding:calc(12px + env(safe-area-inset-top,0px)) 7px calc(12px + env(safe-area-inset-bottom,0px))!important;
    margin:0!important;
    background:var(--surface-2)!important;
    border-right:1px solid var(--border)!important;
    overflow:hidden!important;
    overscroll-behavior:contain;
    z-index:1!important;
  }
  #appShell #sidebar.nord-sidebar > :not(.nord-mobile-server-rail),
  body.nord-nexus-active #appShell #nordNexusSidebar.nx-sidebar > .nx-sidebar-inner {
    grid-column:2!important;
    grid-row:1!important;
    width:100%!important;
    max-width:100%!important;
    min-width:0!important;
    min-height:0!important;
    height:100%!important;
    margin:0!important;
    box-sizing:border-box!important;
    overflow-y:auto!important;
    overflow-x:hidden!important;
    overscroll-behavior-y:contain;
    -webkit-overflow-scrolling:touch;
  }
  body.nord-nexus-active #appShell #nordNexusSidebar.nx-sidebar > .nx-sidebar-inner {
    display:flex!important;
    flex-direction:column!important;
    padding:calc(14px + env(safe-area-inset-top,0px)) 10px calc(12px + env(safe-area-inset-bottom,0px))!important;
  }
  /* Platform side panel has separate quick-actions and view rows;
     Nexus has a single .nx-sidebar-inner that owns both. */
  #appShell #sidebar.nord-sidebar {
    grid-template-rows:auto minmax(0,1fr)!important;
  }
  #appShell #sidebar.nord-sidebar > .nord-mobile-server-rail {
    grid-row:1 / 3!important;
  }
  #appShell #sidebar.nord-sidebar > .nord-mobile-quicknav {
    grid-column:2!important;
    grid-row:1!important;
    width:100%!important;
    min-width:0!important;
    height:auto!important;
    max-height:none!important;
    overflow:visible!important;
  }
  #appShell #sidebar.nord-sidebar > :not(.nord-mobile-server-rail):not(.nord-mobile-quicknav) {
    grid-column:2!important;
    grid-row:2!important;
    width:100%!important;
    min-width:0!important;
    height:100%!important;
    min-height:0!important;
  }
  #appShell #sidebar.nord-sidebar > [class*="sidebar-view"] {
    padding:calc(12px + env(safe-area-inset-top,0px)) 10px calc(12px + env(safe-area-inset-bottom,0px))!important;
  }
  #appShell .nord-mobile-server-top,
  #appShell .nord-mobile-server-bottom {
    flex:0 0 auto!important;
    display:flex!important;
    align-items:center!important;
    justify-content:center!important;
    width:100%!important;
    padding:2px 0 10px!important;
  }
  #appShell .nord-mobile-server-top {
    border-bottom:1px solid var(--border)!important;
    margin-bottom:9px!important;
  }
  #appShell .nord-mobile-server-bottom {
    border-top:1px solid var(--border)!important;
    margin-top:9px!important;
    padding:11px 0 0!important;
  }
  #appShell .nord-mobile-server-list {
    display:flex!important;
    flex:1 1 auto!important;
    flex-direction:column!important;
    align-items:center!important;
    justify-content:flex-start!important;
    gap:11px!important;
    min-width:0!important;
    width:100%!important;
    min-height:0!important;
    padding:4px 0!important;
    overflow-y:auto!important;
    overflow-x:hidden!important;
    overscroll-behavior:contain!important;
    scrollbar-width:none!important;
    -webkit-overflow-scrolling:touch!important;
  }
  #appShell .nord-mobile-server-list::-webkit-scrollbar { display:none!important; }
  #appShell .nord-mobile-server-icon {
    flex:0 0 49px!important;
    position:relative!important;
    width:49px!important; min-width:49px!important; max-width:49px!important;
    height:49px!important; min-height:49px!important; max-height:49px!important;
    margin:0!important; padding:0!important;
    display:grid!important; place-items:center!important;
    border:1px solid var(--border)!important;
    border-radius:17px!important;
    background:var(--surface)!important;
    color:var(--text-2)!important;
    cursor:pointer!important;
    transition:background .15s ease,border-color .15s ease,border-radius .15s ease!important;
    box-shadow:none!important;
    outline-offset:3px;
  }
  #appShell .nord-mobile-server-icon > i {
    font-size:19px!important;
    pointer-events:none!important;
  }
  #appShell .nord-mobile-server-icon:hover {
    border-color:var(--accent)!important;
    background:var(--accent-soft)!important;
    border-radius:14px!important;
    color:var(--accent)!important;
  }
  #appShell .nord-mobile-server-icon:focus-visible {
    outline:2px solid var(--accent)!important;
  }
  #appShell .nord-mobile-server-icon.active {
    border-color:var(--accent)!important;
    background:var(--accent-soft)!important;
    border-radius:14px!important;
    color:var(--accent)!important;
  }
  #appShell .nord-mobile-server-icon.active::before {
    content:''!important;
    position:absolute!important;
    left:-9px!important;
    top:50%!important;
    transform:translateY(-50%)!important;
    width:4px!important;
    height:28px!important;
    border-radius:0 5px 5px 0!important;
    background:var(--accent)!important;
    pointer-events:none!important;
  }
  #appShell .nord-mobile-server-icon .rail-profile-avatar {
    display:grid!important;
    place-items:center!important;
    width:100%!important;
    height:100%!important;
    min-height:0!important;
    overflow:hidden!important;
    border-radius:inherit!important;
    background:var(--accent-soft)!important;
    color:var(--text)!important;
    font-size:13px!important;
    font-weight:850!important;
    line-height:1!important;
    pointer-events:none!important;
  }
  #appShell .nord-mobile-server-icon .rail-profile-avatar img {
    display:block!important;
    width:100%!important;
    height:100%!important;
    object-fit:cover!important;
    border-radius:inherit!important;
  }
  #appShell .nord-mobile-server-icon.needs-setup::after {
    content:'!'!important;
    position:absolute!important;
    right:-3px!important;
    bottom:-3px!important;
    display:grid!important;place-items:center!important;
    width:16px!important;height:16px!important;
    border-radius:50%!important;
    border:2px solid var(--surface-2)!important;
    background:var(--warning,#f59e0b)!important;
    color:#111!important;
    font-size:10px!important;font-weight:900!important;
    pointer-events:none!important;
  }
  #appShell .nord-mobile-server-add {
    color:var(--success,#4ade80)!important;
    border-style:dashed!important;
    background:transparent!important;
  }
  #appShell .nord-mobile-server-add:hover { color:var(--accent)!important; }
  #appShell .nord-mobile-quicknav-profiles {display:none!important;}
  #appShell .nord-mobile-quicknav {
    min-width:0!important;
    max-width:100%!important;
    padding:8px 3px 12px!important;
    flex:0 0 auto!important;
  }
  #appShell .nord-mobile-quicknav-top { padding:0 3px!important; }
  #appShell .nord-mobile-quicknav-actions {
    display:grid!important;
    grid-template-columns:repeat(3,minmax(0,1fr))!important;
    gap:5px!important;
  }
  #appShell .nord-mobile-quicknav-actions button {
    min-width:0!important;
    min-height:51px!important;
    padding:6px 2px!important;
  }
  #appShell .nord-mobile-quicknav-actions span {
    font-size:9px!important;
    line-height:1.2!important;
    max-width:100%!important;
  }
  #appShell #nordNexusSidebar .nx-brand {
    min-width:0!important;
    gap:7px!important;
    padding:3px 2px 12px!important;
  }
  #appShell #nordNexusSidebar .nx-brand .nx-logo {
    width:37px!important;height:37px!important;min-width:37px!important;
    font-size:15px!important;
  }
  #appShell #nordNexusSidebar .nx-nav {
    width:100%!important;
    min-width:0!important;
    max-width:100%!important;
    padding:0!important;
  }
  #appShell #nordNexusSidebar .nx-nav button {
    width:100%!important;min-width:0!important;
    max-width:100%!important;
    gap:8px!important;
    padding:10px 7px!important;
    overflow:hidden!important;
  }
  #appShell #nordNexusSidebar .nx-nav button span {
    min-width:0!important;
    white-space:nowrap!important;
    text-overflow:ellipsis!important;
    overflow:hidden!important;
  }
}
@media(max-width:360px) {
  #appShell #sidebar.nord-sidebar,
  body.nord-nexus-active #appShell #nordNexusSidebar.nx-sidebar {
    grid-template-columns:60px minmax(0,1fr)!important;
  }
  #appShell #sidebar.nord-sidebar > .nord-mobile-server-rail,
  body.nord-nexus-active #appShell #nordNexusSidebar.nx-sidebar > .nord-mobile-server-rail {
    width:60px!important;
    max-width:60px!important;
    padding-left:4px!important;
    padding-right:4px!important;
  }
}

/* Nexus identity header is mobile-only; the desktop sidebar keeps its navigation. */
@media(min-width:1025px){body.nord-nexus-active #nordNexusSidebar .nx-brand{display:flex!important}}
@media(max-width:1024px){body.nord-nexus-active #nordNexusSidebar .nx-brand{display:flex!important}}

/* Nexus page heading (not the sidebar brand): show on mobile only. */
@media(min-width:1025px){body.nord-nexus-active #page-hub .nx-head h1{display:none!important}}
@media(max-width:1024px){body.nord-nexus-active #page-hub .nx-head h1{display:block}}

/* Prevent stale/cached mobile or Nexus scripts from showing obsolete global titles. */
#appShell .nord-main > .nord-topbar #nordMobileTitle.nord-mobile-page-title,
#appShell .nord-main > .nord-topbar #nxTopbarTitle.nx-topbar-title{
  display:none!important;
}
