/* Topbar owns session copy and right-side action controls.
   Keep this file as the single control point for the top session/theme row. */
.app-topbar {
  --shell-topbar-row-bg: transparent;
  --shell-topbar-row-border: transparent;
  --shell-topbar-row-shadow: none;
  --shell-topbar-switcher-bg: transparent;
  --shell-topbar-switcher-border: transparent;

  box-sizing: border-box;
  max-width: var(--shell-page-max-width);
  width: 100%;
  margin: var(--shell-page-gutter) auto 0 0;
  padding-inline: var(--shell-page-gutter);
  border: 1px solid var(--shell-topbar-row-border) !important;
  background: var(--shell-topbar-row-bg) !important;
  box-shadow: var(--shell-topbar-row-shadow) !important;
}

.app-topbar-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.app-account-menu {
  position: relative;
  min-width: 0;
}

.app-account-menu summary {
  list-style: none;
}

.app-account-menu summary::-webkit-details-marker {
  display: none;
}

.console-account-trigger {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  max-width: min(420px, 44vw);
  min-height: 48px;
  padding: 5px 15px 5px 6px;
  border-radius: 999px;
  border: 1px solid var(--theme-border-soft, var(--line));
  background: var(--theme-surface-high, var(--surface-soft));
  color: var(--theme-text, var(--text));
  cursor: pointer;
}

.console-account-avatar {
  display: inline-grid;
  place-items: center;
  text-align: center;
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  border-radius: 50%;
  border: 1px solid var(--theme-border, var(--line));
  background: var(--theme-primary-soft, var(--surface-soft));
  color: var(--theme-primary, var(--brand));
  font-size: 14px;
  font-weight: 900;
  line-height: 30px;
}

.console-account-main {
  display: grid;
  min-width: 0;
  gap: 1px;
}

.console-account-label {
  color: var(--theme-muted, var(--muted));
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
}

.console-account-name {
  display: block;
  max-width: 18em;
  overflow: hidden;
  color: var(--theme-text, var(--text));
  font-size: 14px;
  font-weight: 860;
  line-height: 1.08;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.console-account-email {
  display: block;
  max-width: 24em;
  overflow: hidden;
  color: var(--theme-muted, var(--muted));
  font-size: 11px;
  font-weight: 650;
  line-height: 1.08;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.console-account-email-primary {
  color: var(--theme-text, var(--text));
  font-size: 13px;
  font-weight: 820;
  line-height: 1.1;
}

.console-account-popover {
  position: absolute;
  top: 4px;
  left: calc(100% + 10px);
  z-index: 80;
  display: grid;
  gap: 8px;
  width: min(292px, calc(100vw - 44px));
  padding: 10px;
  border-radius: 28px;
  border: 1px solid var(--theme-primary-border, var(--theme-primary, var(--line)));
  background: var(--theme-primary, var(--ink));
  box-shadow: var(--theme-shadow-card, var(--shadow));
  transform: translateX(-6px);
  opacity: 0;
  pointer-events: none;
  transition: transform 160ms ease, opacity 160ms ease;
}

details[open] > .console-account-popover {
  transform: translateX(0);
  opacity: 1;
  pointer-events: auto;
}

.console-account-detail strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.console-account-detail {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  min-height: 38px;
  padding: 8px 12px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--theme-surface, #fff) 94%, transparent);
  border: 1px solid color-mix(in srgb, var(--theme-surface, #fff) 82%, transparent);
  transition: transform 150ms ease, background-color 150ms ease, border-color 150ms ease;
}

.console-account-detail:hover {
  transform: translateY(-2px);
  background: color-mix(in srgb, var(--theme-surface, #fff) 98%, transparent);
  border-color: color-mix(in srgb, var(--theme-surface, #fff) 94%, transparent);
}

.console-account-detail span {
  color: var(--theme-muted, var(--muted));
  font-size: 12px;
  font-weight: 800;
}

.console-account-detail strong {
  color: var(--theme-text, var(--text));
  font-size: 13px;
  font-weight: 820;
}

.console-account-link {
  color: var(--theme-primary, var(--brand));
  font-weight: 900;
  letter-spacing: .04em;
  text-decoration: none;
}

.console-account-link:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.console-account-logout {
  width: 100%;
  min-height: 38px;
  margin: 0;
  border-radius: 999px !important;
  border-color: color-mix(in srgb, var(--theme-surface, #fff) 82%, transparent) !important;
  background: color-mix(in srgb, var(--theme-surface, #fff) 94%, transparent) !important;
  color: var(--theme-text, var(--text)) !important;
  transition: transform 150ms ease, background-color 150ms ease, border-color 150ms ease;
}

.console-account-logout:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--theme-surface, #fff) 94%, transparent) !important;
  background: color-mix(in srgb, var(--theme-surface, #fff) 98%, transparent) !important;
}

.app-topbar .preference-switcher {
  border-radius: 0 !important;
  border-color: var(--shell-topbar-switcher-border) !important;
  background: var(--shell-topbar-switcher-bg) !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
}

.app-topbar .preference-button {
  border-radius: 0 !important;
  border-color: var(--theme-border, var(--line)) !important;
  background: var(--theme-surface, var(--surface)) !important;
  color: var(--theme-text, var(--text)) !important;
}

body.theme-lux .app-topbar {
  border-color: transparent !important;
  margin-right: auto;
}

body.theme-lux .app-topbar .preference-button.active {
  background: var(--theme-primary) !important;
  color: var(--theme-on-primary) !important;
}

body.theme-lux-light .console-account-popover {
  border-color: #2a2a29;
  background: #2a2a29;
}

body.theme-lux-dark .console-account-popover {
  border-color: #2b2924;
  background: #111111;
}

body.theme-lux-dark .console-account-popover .console-account-detail,
body.theme-lux-dark .console-account-popover .console-account-logout {
  border-color: rgba(218, 177, 102, .42) !important;
  background: linear-gradient(90deg, rgba(248, 223, 161, .24), rgba(180, 124, 47, .13)) !important;
  color: #f7dfaa !important;
}

body.theme-lux-dark .console-account-popover .console-account-detail:hover,
body.theme-lux-dark .console-account-popover .console-account-logout:hover {
  border-color: rgba(248, 223, 161, .72) !important;
  background: linear-gradient(90deg, rgba(248, 223, 161, .32), rgba(180, 124, 47, .2)) !important;
}

body.theme-lux-dark .console-account-popover .console-account-detail span {
  color: rgba(247, 223, 170, .72) !important;
}

body.theme-lux-dark .console-account-popover .console-account-detail strong,
body.theme-lux-dark .console-account-popover .console-account-logout {
  color: #ffe8b6 !important;
}

@media (max-width: 860px) {
  .app-topbar {
    width: 100%;
    max-width: 100%;
    margin: 18px auto 0 0;
    padding-inline: 18px;
  }

  .console-account-trigger {
    max-width: 58vw;
  }

  .console-account-popover {
    top: calc(100% + 10px);
    left: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .console-account-detail,
  .console-account-logout {
    transition: none;
  }

  .console-account-detail:hover,
  .console-account-logout:hover {
    transform: none;
  }
}
