/* Account disclosure replaces the second mobile header row. */
.topbar-account { display: block; }
.topbar-account__panel { display: flex; align-items: center; gap: 10px; }
.topbar-account > summary, .topbar-account__preview { display: none; }
@media (max-width: 760px) {
  .main-panel { padding-inline: 12px; }
  .topbar { height: 52px; min-height: 52px; flex-wrap: nowrap; gap: 6px; padding: 4px 0; }
  .topbar .mobile-nav { flex: 0 0 52px; margin-right: auto; }
  .topbar .mobile-nav > summary { width: 52px; min-width: 0; min-height: 44px; padding: 0 4px; gap: 3px; font-size: 14px; }
  .topbar .store-preview-switcher { flex: 1 1 0; min-width: 0; max-width: 240px; }
  .topbar .store-preview-switcher select { min-height: 44px; max-width: 100%; font-size: 14px; padding-inline: 6px 20px; }
  .topbar .notification-bell { flex: 0 0 auto; min-width: 44px; min-height: 44px; justify-content: center; gap: 3px; padding: 0 4px; font-size: 13px; }
  .topbar .notification-bell > span:first-child { display: inline; }
  .topbar .notification-badge { font-size: 11px; min-width: 18px; height: 18px; }
  .topbar-account { display: block; position: relative; flex: 0 0 44px; font-size: 13px; }
  .topbar-account > summary { display: flex; align-items: center; justify-content: center; min-height: 44px; color: var(--primary); cursor: pointer; list-style: none; }
  .topbar-account > summary::-webkit-details-marker { display: none; }
  .topbar-account:not([open]) > .topbar-account__panel { display: none; }
  .topbar-account[open] > .topbar-account__panel { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; position: absolute; top: calc(100% + 4px); right: 0; width: min(260px, calc(100vw - 24px)); padding: 12px; border: 1px solid var(--border); background: var(--panel); }
  .topbar-account__panel .account { flex: 1; }
  /* Page-specific compact headers must not hide controls inside this menu. */
  .main-panel .topbar .topbar-account .topbar-account__panel :is(.env-label, .account, .store-preview-clear) { display: inline-block; }
  .topbar-account__preview { display: grid; width: 100%; gap: 4px; border-top: 1px solid var(--border); padding-top: 8px; color: var(--muted); }
  .topbar-account__preview button { min-height: 44px; padding: 0; }
  .topbar-account > summary:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
}

/* Phone navigation uses a modal drawer; the original permission form moves intact. */
.mobile-shell-icon { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.notification-bell__icon, .mobile-page-title, .mobile-scope-toggle { display: none; }
@media (max-width: 760px) {
  html.mobile-nav-open, html.mobile-nav-open body { overflow: hidden !important; }
  .topbar .mobile-nav { flex-basis: 44px; margin-right: 0; }
  .topbar .mobile-nav > summary { width: 44px; padding: 0; justify-content: center; color: var(--text); }
  .mobile-page-title { display: block; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 18px; font-weight: 700; color: var(--text); }
  .topbar .notification-bell { position: relative; width: 44px; padding: 0; }
  .topbar .notification-bell > .notification-bell__label:first-child { display: none; }
  .notification-bell__icon { display: block; }
  .topbar .notification-bell > .notification-badge { position: absolute; top: 0; right: -2px; min-width: 17px; height: 17px; font-size: 10px; }
  .mobile-nav__dialog { position: fixed; inset: 0; width: 100vw; max-width: none; height: 100dvh; max-height: none; margin: 0; padding: 0; border: 0; background: transparent; overflow: hidden; }
  .mobile-nav__dialog::backdrop, .mobile-scope-dialog::backdrop { background: rgb(23 32 42 / 40%); }
  .mobile-nav__dialog .mobile-nav__panel { position: static; display: flex; flex-direction: column; width: min(320px, calc(100vw - 56px)); height: 100%; max-height: none; border: 0; border-radius: 0 16px 16px 0; box-shadow: none; padding: 8px 12px 0; overflow: hidden; animation: mobile-nav-enter 180ms cubic-bezier(.2,0,0,1); }
  .mobile-nav__brand { min-height: 56px; flex: none; justify-content: space-between; }
  .mobile-nav__list { flex: 1; min-height: 0; display: block; overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; padding: 8px 0 max(108px, env(safe-area-inset-bottom)); scroll-padding-block: 8px 108px; }
  .mobile-nav__close { width: 44px; min-height: 44px; flex: none; display: grid; place-items: center; border: 0; background: transparent; color: var(--muted); padding: 0; }
  .mobile-nav .nav-item, .mobile-nav .nav-subitem, .mobile-nav .nav-subitem-group { border-left: 0; border-radius: 8px; font-size: 15px; min-height: 46px; }
  .mobile-nav .nav-subitem, .mobile-nav .nav-subitem-group { padding-left: 24px; }
  .mobile-nav .is-active { background: #edf1ff; }
  .mobile-scope-toggle { position: fixed; right: 14px; bottom: calc(100px + env(safe-area-inset-bottom)); z-index: 25; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; width: 52px; min-height: 52px; padding: 3px; border: 1px solid rgb(0 47 167 / 24%); border-radius: 50%; background: rgb(225 233 255 / 78%); color: var(--primary); font-size: 10px; font-weight: 700; }
  .mobile-scope-toggle:hover, .mobile-scope-toggle:focus-visible { background: #e1e9ff; }
  .mobile-scope-toggle .mobile-shell-icon { width: 20px; height: 20px; }
  .mobile-scope-dialog { position: fixed; inset: auto 12px calc(162px + env(safe-area-inset-bottom)) auto; width: min(360px, calc(100vw - 24px)); max-width: none; max-height: calc(100dvh - 180px); margin: 0; padding: 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--panel); color: var(--text); }
  .mobile-scope-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
  .mobile-scope-heading h2 { margin: 0; font-size: 16px; }
  .mobile-scope-close { min-height: 44px; min-width: 44px; border: 0; background: transparent; color: var(--primary); padding: 0; }
  .topbar .mobile-scope-dialog .store-preview-switcher { display: flex; flex-wrap: wrap; width: 100%; max-width: none; }
  .topbar .mobile-scope-dialog .store-preview-switcher select { width: 100%; font-size: 16px; }
  .mobile-scope-dialog .store-preview-actor { display: block; width: 100%; font-size: 12px; color: var(--muted); white-space: normal; }
}
@keyframes mobile-nav-enter { from { transform: translateX(-100%); } to { transform: translateX(0); } }
@media (prefers-reduced-motion: reduce) { .mobile-nav__dialog .mobile-nav__panel { animation: none; } }
@media (max-width: 760px) {
  .mobile-scope-dialog .store-preview-clear-form { display: block; margin-top: 8px; }
  .mobile-scope-dialog .store-preview-clear { min-height: 44px; }
}

@media (max-width: 760px) { html.mobile-preview-scope-entry .mobile-scope-toggle { display: none; } }

@media (max-width: 760px) {
  .mobile-nav__brand { gap: 4px; }
  .mobile-nav__brand .brand-identity { flex: 1; min-width: 0; }
  .mobile-nav__brand .brand-identity__name { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  .mobile-nav__brand .brand-identity__mark { flex: none; min-width: 36px; min-height: 36px; }
  .mobile-nav__brand a.brand-identity__mark:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
  [data-mobile-account-slot] { flex: none; }
  .mobile-nav__brand .topbar-account { margin: 0; }
  .mobile-nav__brand .topbar-account__panel { z-index: 2; border-radius: 8px; box-shadow: 0 6px 20px rgb(23 32 42 / 12%); }
}

/* Phones: the closed drawer's button carries the rolled-up 同步异常通知 count. */
@media (max-width: 760px) {
  .topbar .mobile-nav > summary { position: relative; }
  .topbar .mobile-nav > summary > .mobile-nav__badge { position: absolute; top: 1px; right: -4px; min-width: 17px; height: 17px; padding: 0 4px; background: #dc2626; color: #fff; font-size: 10px; font-weight: 600; line-height: 1; }
}
