/* ---- menus ---- */

.menu {
  position: absolute;
  z-index: 50;
  top: calc(100% + 6px);
  left: 0;
  min-width: 300px;
  max-width: min(380px, calc(100vw - 16px));
  max-height: calc(100dvh - var(--topbar-h) - 16px);
  overflow-y: auto;
  padding: 6px;
  background: var(--bg-raised);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  box-shadow: var(--shadow-md);
}

.account-menu {
  left: auto;
  right: 0;
  min-width: 260px;
}

.menu-heading {
  padding: 8px 10px 4px;
  color: var(--fg-muted);
  font-size: var(--text-xs);
  font-weight: 650;
  letter-spacing: 0.02em;
}

.menu-group + .menu-group {
  margin-top: 4px;
}

.menu-separator {
  height: 1px;
  margin: 6px 4px;
  background: var(--line);
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 40px;
  padding: 6px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--fg);
  text-align: left;
  text-decoration: none;
}

.menu-item:hover,
.menu-item:focus {
  background: var(--bg-hover);
  outline: none;
}

.menu-item:focus-visible {
  box-shadow: inset 0 0 0 2px var(--focus);
}

.menu-item > .icon {
  color: var(--fg-muted);
}

.mailbox-item[aria-checked="true"] {
  background: var(--accent-soft);
}

.mailbox-item-text {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-width: 0;
  line-height: 1.25;
}

.mailbox-item-address {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.mailbox-item-name {
  color: var(--fg-muted);
  font-size: var(--text-xs);
}

.menu-check {
  display: inline-flex;
  width: 18px;
  color: var(--accent-text);
}

.account-summary {
  padding: 2px 10px 8px;
}

.account-summary .menu-heading {
  padding: 6px 0 4px;
}

.account-name {
  font-weight: 650;
}

.account-email {
  color: var(--fg-muted);
  font-size: var(--text-sm);
}

/* ---- dialogs ---- */

.dialog {
  width: calc(100vw - 32px);
  max-width: 500px;
  padding: 20px 22px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  background: var(--bg-raised);
  color: var(--fg);
  box-shadow: var(--shadow-lg);
}

.dialog::backdrop {
  background: rgb(0 0 0 / 38%);
}

.dialog-title {
  font-size: var(--text-lg);
  font-weight: 650;
}

.dialog-message {
  margin-top: 8px;
  color: var(--fg-muted);
}

.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: -6px -8px 8px 0;
}

.shortcuts {
  max-width: 520px;
}

.shortcut-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 20px;
  margin: 0;
}

.shortcut {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: var(--text-sm);
}

.shortcut dt {
  flex: 0 0 96px;
}

.shortcut dd {
  margin: 0;
  color: var(--fg-muted);
}

@media (max-width: 560px) {
  .shortcut-list {
    grid-template-columns: 1fr;
  }
}

/* ---- toasts ---- */

.toasts {
  position: fixed;
  z-index: 60;
  left: 16px;
  bottom: 16px;
  pointer-events: none;
}

.toast-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(440px, calc(100vw - 32px));
  min-height: 44px;
  padding: 6px 6px 6px 14px;
  border-radius: var(--radius);
  background: var(--toast-bg);
  color: var(--toast-fg);
  box-shadow: var(--shadow-md);
  font-size: var(--text-sm);
  pointer-events: auto;
}

.toast.is-error .icon {
  color: #f97066;
}

@media (prefers-color-scheme: dark) {
  .toast.is-error .icon {
    color: #b42318;
  }
}

.toast-text {
  flex: 1 1 auto;
}

.toast-action {
  padding: 6px 8px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--toast-action);
  font-weight: 700;
}

.toast-action:hover {
  background: rgb(127 127 127 / 18%);
}

.toast-close {
  width: 30px;
  height: 30px;
  color: inherit;
  opacity: 0.75;
}

.toast-close:hover:not(:disabled) {
  background: rgb(127 127 127 / 18%);
  color: inherit;
  opacity: 1;
}

.toast :focus-visible {
  outline-color: var(--toast-action);
}

@media (max-width: 760px) {
  .toasts {
    left: 8px;
    right: 8px;
    bottom: 8px;
  }

  .toast {
    max-width: none;
  }
}
