.account-menu-shell {
  position: relative;
  display: inline-flex;
}

.user-chip__chevron {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
  transition: transform var(--motion-control) var(--ease);
}

.user-chip[aria-expanded='true'] {
  background: var(--selection-yellow-soft);
}

.user-chip[aria-expanded='true'] .user-chip__chevron {
  transform: rotate(180deg);
}

.account-menu {
  position: absolute;
  z-index: 90;
  top: calc(100% + 10px);
  right: 0;
  width: min(370px, calc(100vw - 28px));
  max-height: calc(100vh - 92px);
  overflow-x: hidden;
  overflow-y: auto;
  color: var(--ink);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--white);
  box-shadow: 0 16px 44px rgba(43, 41, 37, 0.18);
}

.account-menu[hidden] {
  display: none;
}

.account-menu__identity {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 18px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--surface-canvas);
}

.account-menu__identity .avatar {
  width: 42px;
  height: 42px;
  font-size: 15px;
}

.account-menu__identity span:last-child {
  min-width: 0;
}

.account-menu__identity strong,
.account-menu__identity small,
.account-menu__identity em {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-menu__identity strong {
  color: var(--ink-deep);
  font-size: 16px;
  line-height: 1.25;
}

.account-menu__identity small {
  margin-top: 2px;
  color: var(--text-secondary);
  font-size: 13px;
}

.account-menu__identity em {
  margin-top: 1px;
  color: var(--text-tertiary, var(--text-secondary));
  font-size: 12px;
  font-style: normal;
}

.account-menu__assignment {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1px 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--selection-yellow-soft);
}

.account-menu__assignment small {
  grid-column: 1 / -1;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.account-menu__assignment strong {
  overflow: hidden;
  color: var(--ink-deep);
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-menu__assignment span {
  color: var(--text-secondary);
  font-size: 12px;
  white-space: nowrap;
}

.account-emergency-status {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 14px 16px;
  color: var(--orange);
  border: 1px solid var(--warning-rule);
  background: var(--warning-surface);
}

.account-emergency-status--compact {
  margin: 10px 10px 0;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
}

.account-emergency-status > svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.account-emergency-status strong,
.account-emergency-status small {
  display: block;
}

.account-emergency-status strong {
  font-size: 13px;
}

.account-emergency-status small {
  margin-top: 2px;
  font-size: 12px;
  line-height: 1.35;
}

.account-menu__items {
  padding: 8px;
}

.account-menu__group {
  display: grid;
  gap: 1px;
}

.account-menu__item {
  display: grid;
  width: 100%;
  min-height: 52px;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  color: var(--ink);
  border: 0;
  border-radius: var(--radius-xs);
  background: transparent;
  text-align: left;
}

.account-menu__item:hover,
.account-menu__item:focus-visible {
  background: var(--surface-recessed);
}

.account-menu__item > svg:first-child {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.75;
}

.account-menu__item > span {
  min-width: 0;
}

.account-menu__item strong,
.account-menu__item small {
  display: block;
}

.account-menu__item strong {
  color: var(--ink-deep);
  font-size: 14px;
  font-weight: 750;
}

.account-menu__item small {
  margin-top: 2px;
  overflow: hidden;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-menu__item > svg:last-child {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.account-menu__divider {
  height: 1px;
  margin: 6px 10px;
  background: var(--border-subtle);
}

.account-menu__item--signout {
  color: var(--red);
}

.account-menu__item--signout strong {
  color: inherit;
}

.account-menu__item--signout:hover,
.account-menu__item--signout:focus-visible {
  background: var(--danger-surface);
}

@media (max-width: 940px) {
  .user-chip__chevron {
    display: none;
  }
}

@media (max-width: 690px) {
  .account-menu-shell {
    display: none;
  }
}

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

html[data-motion-preference='reduced'] .user-chip__chevron {
  transition: none;
}
