/* Navegação móvel compartilhada: uma gaveta, sem barras horizontais extras. */
html,
body {
  overflow-x: hidden;
}

.impersonation-banner {
  position: fixed;
  z-index: 120;
  top: 14px;
  left: 50%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: min(520px, calc(100vw - 28px));
  padding: 10px 12px 10px 15px;
  border: 1px solid color-mix(in srgb, var(--accent, #b7a3ff) 55%, transparent);
  border-radius: 14px;
  background: color-mix(in srgb, var(--panel, #211b28) 92%, transparent);
  box-shadow: 0 14px 34px rgba(18, 12, 26, .28);
  color: var(--ink, var(--text, #fff));
  transform: translateX(-50%);
  backdrop-filter: blur(12px);
}

.impersonation-banner div { min-width: 0; }
.impersonation-banner strong,
.impersonation-banner span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.impersonation-banner strong { font-size: 12px; }
.impersonation-banner span { margin-top: 2px; color: var(--muted, #aaa1b2); font-size: 11px; }
.impersonation-banner button { min-height: 34px; padding: 8px 11px; border: 1px solid var(--accent, #b7a3ff); border-radius: 9px; background: var(--accent, #b7a3ff); color: var(--bg, #17131d); font: 700 11px inherit; cursor: pointer; white-space: nowrap; }

/* Navegação desktop compacta: os recursos secundários ficam agrupados para
   evitar que a barra superior ultrapasse a largura disponível. */
.topbar > .app-nav,
.profile-topbar > .app-nav,
.story-topbar > .app-nav {
  display: flex;
  align-items: center;
  gap: clamp(10px, 1.55vw, 22px);
  min-width: 0;
  margin-right: auto;
}

.app-nav > a,
.app-nav > .nav-group > summary {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  color: var(--muted, #aaa1b2);
  font-size: 13px;
  white-space: nowrap;
  text-decoration: none;
}

.app-nav > a.active,
.app-nav > .nav-group > summary.active {
  color: var(--ink, var(--text, #f7f2ff));
}

.nav-group {
  position: relative;
  flex: 0 0 auto;
}

.nav-group > summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
}

.nav-group > summary::-webkit-details-marker {
  display: none;
}

.nav-group > summary::after {
  content: '⌄';
  margin-left: 5px;
  color: currentColor;
  font-size: 14px;
  line-height: 1;
  transition: transform .18s ease;
}

.nav-group[open] > summary::after {
  transform: rotate(180deg);
}

.nav-group-panel {
  position: absolute;
  z-index: 30;
  top: calc(100% + 8px);
  left: 50%;
  display: grid;
  min-width: 178px;
  padding: 6px;
  border: 1px solid color-mix(in srgb, currentColor 18%, transparent);
  border-radius: 12px;
  background: var(--card, var(--panel, #211b28));
  box-shadow: 0 18px 42px rgba(0, 0, 0, .24);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -5px);
  transition: opacity .18s ease, transform .18s ease;
}

.nav-group[open] > .nav-group-panel,
.nav-group:focus-within > .nav-group-panel {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, 0);
}

.nav-group-panel a {
  display: flex;
  align-items: center;
  min-height: 42px;
  padding: 9px 11px;
  border-radius: 8px;
  color: var(--muted, #aaa1b2);
  font-size: 12px;
  text-decoration: none;
  white-space: nowrap;
}

.nav-group-panel a:hover,
.nav-group-panel a.active {
  background: color-mix(in srgb, var(--accent, var(--violet, #b7a3ff)) 12%, transparent);
  color: var(--ink, var(--text, #fff));
}

.mobile-menu-toggle,
.mobile-menu-backdrop,
.mobile-menu-panel,
.admin-mobile-toggle,
.admin-mobile-backdrop,
.admin-mobile-close {
  display: none;
}

@media (max-width: 820px) {
  .impersonation-banner { top: 8px; }
  .topbar,
  .profile-topbar,
  .story-topbar {
    isolation: isolate;
    max-width: 100%;
  }

  .topbar > .exit,
  .topbar > .back,
  .profile-topbar > .back,
  .story-topbar > .top-actions > a,
  .topbar > .top-actions > a {
    display: none !important;
  }

  .topbar > nav,
  .profile-topbar > nav,
  .story-topbar > nav {
    display: none !important;
  }

  .mobile-menu-toggle {
    display: grid;
    place-items: center;
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    margin-left: auto;
    padding: 0;
    border: 1px solid color-mix(in srgb, currentColor 22%, transparent);
    border-radius: 12px;
    background: var(--lime, var(--accent, #b7a3ff));
    color: var(--ink, var(--bg, #17131d));
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }

  .mobile-menu-toggle:hover {
    transform: none;
    filter: brightness(1.04);
  }

  .mobile-menu-toggle:focus-visible,
  .mobile-menu-close:focus-visible,
  .mobile-menu-panel a:focus-visible,
  .admin-mobile-toggle:focus-visible,
  .admin-mobile-close:focus-visible {
    outline: 3px solid var(--lime, var(--accent, #b7a3ff));
    outline-offset: 3px;
  }

  .mobile-menu-toggle span,
  .mobile-menu-toggle::before,
  .mobile-menu-toggle::after {
    display: block;
    width: 18px;
    height: 2px;
    border-radius: 2px;
    background: currentColor;
    content: "";
    transition: transform .2s ease, opacity .2s ease;
  }

  .mobile-menu-toggle::before {
    margin-bottom: 4px;
  }

  .mobile-menu-toggle::after {
    margin-top: 4px;
  }

  .mobile-menu-backdrop {
    position: fixed;
    z-index: 90;
    inset: 0;
    display: block;
    background: rgba(7, 6, 10, .56);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
  }

  .mobile-menu-panel {
    position: fixed;
    z-index: 100;
    inset: 0 auto 0 0;
    display: flex;
    flex-direction: column;
    width: min(86vw, 340px);
    max-width: 100%;
    padding: calc(16px + env(safe-area-inset-top)) 16px calc(18px + env(safe-area-inset-bottom));
    overflow-y: auto;
    overscroll-behavior: contain;
    border-right: 1px solid color-mix(in srgb, currentColor 18%, transparent);
    background: var(--card, var(--panel, var(--surface, #1b1822)));
    color: var(--ink, var(--text, #f7f2ff));
    box-shadow: 20px 0 55px rgba(0, 0, 0, .28);
    transform: translateX(-105%);
    transition: transform .24s ease;
  }

  .mobile-menu-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 48px;
    padding-bottom: 18px;
    border-bottom: 1px solid color-mix(in srgb, currentColor 14%, transparent);
  }

  .mobile-menu-brand {
    min-width: 0;
  }

  .mobile-menu-brand .brand {
    display: inline-flex;
    color: inherit;
  }

  .mobile-menu-close,
  .admin-mobile-close {
    display: grid;
    place-items: center;
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 1px solid color-mix(in srgb, currentColor 20%, transparent);
    border-radius: 12px;
    background: transparent;
    color: inherit;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    touch-action: manipulation;
  }

  .mobile-menu-panel nav,
  .mobile-menu-links {
    display: grid !important;
    gap: 6px;
    width: 100%;
    margin: 18px 0 0;
  }

  .mobile-menu-panel nav a,
  .mobile-menu-links a {
    display: flex;
    align-items: center;
    min-height: 50px;
    padding: 10px 12px;
    border: 1px solid transparent;
    border-radius: 12px;
    color: var(--muted, #aaa1b2);
    font-size: 14px;
    text-decoration: none;
    touch-action: manipulation;
  }

  .mobile-menu-panel nav a:hover,
  .mobile-menu-panel nav a.active,
  .mobile-menu-panel nav a:focus-visible,
  .mobile-menu-links a:hover,
  .mobile-menu-links a:focus-visible {
    border-color: color-mix(in srgb, var(--accent, var(--violet, #b7a3ff)) 44%, transparent);
    background: color-mix(in srgb, var(--accent, var(--violet, #b7a3ff)) 12%, transparent);
    color: var(--ink, var(--text, #fff));
  }

  .mobile-menu-links {
    padding-top: 14px;
    border-top: 1px solid color-mix(in srgb, currentColor 14%, transparent);
  }

  .mobile-menu-panel .mobile-menu-links a:last-child {
    margin-top: 4px;
    color: var(--ink, var(--text, #fff));
  }

  body.mobile-menu-open,
  body.admin-menu-open {
    overflow: hidden;
  }

  body.mobile-menu-open .mobile-menu-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  body.mobile-menu-open .mobile-menu-panel {
    transform: translateX(0);
  }

  body.mobile-menu-open .mobile-menu-toggle span {
    opacity: 0;
  }

  body.mobile-menu-open .mobile-menu-toggle::before {
    transform: translateY(3px) rotate(45deg);
  }

  body.mobile-menu-open .mobile-menu-toggle::after {
    transform: translateY(-3px) rotate(-45deg);
  }

  /* Admin uses the same drawer behavior while keeping its desktop sidebar. */
  .admin-mobile-toggle {
    position: fixed;
    z-index: 130;
    top: calc(12px + env(safe-area-inset-top));
    left: 14px;
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 1px solid #54476b;
    border-radius: 12px;
    background: var(--violet, #b7a5ff);
    color: #211a2a;
    cursor: pointer;
    touch-action: manipulation;
  }

  .admin-mobile-backdrop {
    position: fixed;
    z-index: 110;
    inset: 0;
    display: block;
    background: rgba(7, 6, 10, .62);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
  }

  .admin-shell .admin-sidebar {
    position: fixed;
    z-index: 120;
    inset: 0 auto 0 0;
    width: min(86vw, 300px);
    max-width: 100%;
    height: 100dvh;
    padding: calc(16px + env(safe-area-inset-top)) 16px calc(18px + env(safe-area-inset-bottom));
    overflow-y: auto;
    overscroll-behavior: contain;
    background: var(--sidebar, #17131f);
    transform: translateX(-105%);
    transition: transform .24s ease;
  }

  .admin-shell .admin-nav {
    display: grid;
    overflow: visible;
    gap: 5px;
    padding-bottom: 0;
  }

  .admin-shell .admin-nav-label {
    display: block;
  }

  .admin-shell .admin-nav-link {
    flex: initial;
    min-height: 46px;
  }

  .admin-shell .admin-nav-icon {
    display: grid;
  }

  .admin-main {
    padding-top: 74px;
  }

  .admin-mobile-close {
    position: absolute;
    top: calc(12px + env(safe-area-inset-top));
    right: 12px;
  }

  body.admin-menu-open .admin-mobile-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  body.admin-menu-open .admin-shell .admin-sidebar {
    transform: translateX(0);
  }

  body.admin-menu-open .admin-mobile-toggle {
    opacity: 0;
    pointer-events: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .mobile-menu-backdrop,
  .mobile-menu-panel,
  .mobile-menu-toggle span,
  .mobile-menu-toggle::before,
  .mobile-menu-toggle::after,
  .admin-mobile-backdrop,
  .admin-shell .admin-sidebar {
    transition: none !important;
  }
}

.global-notification-host {
  position: fixed;
  z-index: 1000;
  top: calc(18px + env(safe-area-inset-top));
  right: 18px;
  width: min(420px, calc(100vw - 36px));
  display: grid;
  gap: 10px;
  pointer-events: none;
}

.global-notification {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) 28px;
  align-items: start;
  gap: 10px;
  min-width: 0;
  padding: 14px 12px;
  border: 1px solid rgba(174, 255, 94, .4);
  border-radius: 14px;
  background: #1d1927;
  color: #f8f4ff;
  box-shadow: 0 18px 48px rgba(5, 3, 12, .34);
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity .2s ease, transform .2s ease;
  pointer-events: auto;
}

.global-notification.is-visible { opacity: 1; transform: translateY(0); }
.global-notification.is-error { border-color: rgba(255, 126, 126, .58); }
.global-notification-icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #c8ff67;
  color: #17200e;
  font-weight: 800;
}
.global-notification.is-error .global-notification-icon { background: #ff8585; color: #351313; }
.global-notification-copy { min-width: 0; }
.global-notification-copy strong,
.global-notification-copy p { display: block; margin: 0; overflow-wrap: anywhere; }
.global-notification-copy strong { font-size: 13px; line-height: 1.25; }
.global-notification-copy p { margin-top: 4px; color: #d6cce7; font-size: 12px; line-height: 1.45; }
.global-notification-copy a { display: inline-block; margin-top: 7px; color: #c8ff67; font-size: 12px; font-weight: 700; }
.global-notification-close { width: 28px; height: 28px; border: 0; border-radius: 7px; background: transparent; color: #bdb2cf; font-size: 21px; line-height: 1; cursor: pointer; }
.global-notification-close:hover, .global-notification-close:focus-visible { background: rgba(255,255,255,.1); color: #fff; }

@media (max-width: 520px) {
  .global-notification-host { top: calc(10px + env(safe-area-inset-top)); right: 10px; width: calc(100vw - 20px); }
}

@media (prefers-reduced-motion: reduce) {
  .global-notification { transition: none; }
}
