/* Access icons stay under the profile; the full friends panel opens on demand. */
.account-tools{width:100%;min-width:0}
/* The old floating widget was hidden while the drawer was open. This instance
   now belongs to the drawer itself and must remain visible inside it. */
body:has(.mobile-drawer[open]) .account-tools .friends-presence-widget{visibility:visible}
.account-tools .friends-presence-widget{position:static;inset:auto;display:grid;grid-template-columns:repeat(3,minmax(44px,1fr));gap:0 4px;justify-content:stretch;align-items:center;width:100%;max-width:none;pointer-events:auto}
body .account-tools .account-tool{position:relative;grid-row:2;display:grid;place-items:center;justify-self:center;width:44px;height:44px;min-height:44px;margin:0;padding:8px;border:0;border-radius:9px;color:var(--theme-muted);background:transparent;box-shadow:none;cursor:pointer;text-decoration:none}
.account-tools .friends-presence-toggle{grid-column:1}
.account-tools .friend-request-bell{grid-column:2}
.account-tools .account-settings{grid-column:3}
.account-tools .account-tool>svg{width:23px;height:23px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
body .account-tools .account-tool:hover,body .account-tools .account-tool:focus-visible{color:var(--theme-title);background:var(--theme-surface-hover)}
.account-tools .account-tool:focus-visible{outline:3px solid var(--theme-accent);outline-offset:-2px}
body .account-tools .friend-request-bell.has-pending{color:#d63848}
body .account-tools .friends-presence-toggle__badge,body .account-tools .friend-request-bell__count{position:absolute;top:0;right:0;min-width:18px;height:18px;margin:0;padding:0 4px;display:grid;place-items:center;border:1px solid var(--theme-sidebar,var(--theme-surface));border-radius:12px;color:var(--theme-title);background:var(--theme-surface-hover);font-size:10px;line-height:1;transform:none}
body .account-tools .friend-request-bell__count{color:#fff;background:#c22e3d}
.account-tools [data-empty="true"],.account-tools [hidden]{display:none!important}
body .account-tools .friends-presence-panel{position:fixed;inset:max(12px,env(safe-area-inset-top)) max(12px,env(safe-area-inset-right)) auto auto;z-index:1200;display:flex;flex-direction:column;width:min(23rem,calc(100vw - 24px));max-width:none;max-height:calc(100dvh - 24px - env(safe-area-inset-top));margin:0;border-radius:14px;box-shadow:0 16px 40px rgba(3,14,24,.28)}
.account-tools .friends-presence-panel__head{flex:none;gap:8px;padding:10px 12px}
.account-tools .friends-presence-panel__head strong{font-size:16px}
.account-tools .friends-presence-panel__head small{font-size:12px}
.account-tools .friends-presence-panel__head button{min-width:44px;min-height:44px}
.account-tools .friends-presence-panel__body{flex:1 1 auto;min-height:0;max-height:min(32rem,calc(100dvh - 170px));overflow-y:auto;overscroll-behavior:contain;padding:8px}
.account-tools .friends-presence-panel__link{flex:none;padding:12px;font-size:12px;min-height:44px}
.account-tools .friends-presence-row{grid-template-columns:36px minmax(0,1fr);gap:8px;padding:8px}
.account-tools .friends-presence-row__avatar{width:36px;height:36px}
.account-tools .friends-presence-row__actions{grid-template-columns:1fr 1fr}
.account-tools .friends-presence-row__actions :is(a,button),.account-tools .friend-challenge-config :is(select,button){min-height:44px;line-height:1.25;font-size:12px}
.account-tools__notices{min-width:0;max-height:min(11rem,26dvh);overflow-y:auto;overscroll-behavior:contain}
.account-tools .notification-rail{position:static;inset:auto;z-index:auto;width:100%;gap:5px;pointer-events:none}
.account-social-notices{display:grid;gap:6px;min-width:0;max-height:min(20rem,46dvh);overflow-y:auto;overscroll-behavior:contain}
.account-social-notices:not(:has(.friend-event-toast,.friend-online-toast,.friend-request-notice:not([hidden]))){display:none}
body>.account-social-notices{position:fixed;inset:max(12px,env(safe-area-inset-top)) max(12px,env(safe-area-inset-right)) auto auto;z-index:1201;width:min(23rem,calc(100vw - 24px));filter:drop-shadow(0 6px 12px rgba(3,14,24,.24));border-radius:14px}
.friends-presence-panel>.account-social-notices{flex:0 0 auto;padding:8px;border-bottom:1px solid var(--theme-border)}
.account-social-notices :is([data-presence-notifications],[data-simul-notifications]){display:flex;flex-direction:column;gap:6px}
.account-social-notices [data-simul-notifications]:empty{display:none}
.account-social-notices [data-presence-notifications]:not(:has(.friend-event-toast,.friend-online-toast)){display:none}
.account-social-notices .friend-event-toast--challenge{order:-1}
.account-social-notices :is(.friend-online-toast,.friend-event-toast,.friend-request-notice){margin:0;width:100%;min-height:44px;padding:8px 10px;gap:8px;border-radius:12px;background:var(--theme-surface);box-shadow:none;animation:none}
.account-social-notices .friend-event-toast__actions button{min-height:44px}
.account-tools .king-check-alert{grid-template-columns:1fr;padding:8px;animation:none;box-shadow:none}
.account-tools .king-check-alert__piece{display:none}
.account-tools .king-check-alert>a{grid-column:1}
.account-menu-indicator{position:absolute;top:4px;right:4px;width:10px;height:10px;background:#c22e3d;border:2px solid var(--theme-surface);border-radius:50%}
.account-menu-indicator[hidden]{display:none}
body:has(.account-tools) .analysis-intro-actions{padding-right:0}
body:has(.account-tools) .play-room .play-panel-setup .play-panel-head{padding-top:1rem}
body:has(.account-tools) .bot-picker-heading{min-height:52px;justify-content:center;padding-inline:12px}
/* Problems already uses a 76px icon rail on small desktop/tablet widths.
   Keep full touch targets without widening that workspace or covering it. */
@media(min-width:901px) and (max-width:1100px){
    body:has(.puzzle-journey-room) .account-tools .friends-presence-widget{grid-template-columns:minmax(0,1fr)}
    body:has(.puzzle-journey-room) .account-tools .account-tool{grid-column:1}
    body:has(.puzzle-journey-room) .account-tools .friend-request-bell{grid-row:3}
    body:has(.puzzle-journey-room) .account-tools .account-settings{grid-row:4}
}
@media(max-width:900px){
    /* Leave the menu trigger and the drawer header usable on phones. */
    body>.account-social-notices{width:min(23rem,calc(100vw - 76px - env(safe-area-inset-left) - env(safe-area-inset-right)))}
    body:has(.mobile-drawer[open])>.account-social-notices{top:calc(72px + env(safe-area-inset-top))}
    .mobile-drawer__panel>.mobile-drawer__links{flex:1 1 auto;min-height:0}
    .mobile-drawer__foot{flex:0 0 auto;min-height:0;max-height:65dvh;overflow-y:auto;overscroll-behavior:contain}
    /* An identity transform makes fixed descendants relative to the drawer.
       Remove it only while Friends is open: the panel then uses the viewport,
       without moving nodes or changing the existing challenge handlers. */
    .mobile-drawer[open] .mobile-drawer__panel:has(.friends-presence-panel:not([hidden])){transform:none;transition:none}
}
