:root {
  color-scheme: dark;
  --bg: #0f1012;
  --surface: #17181b;
  --surface-2: #202126;
  --surface-3: #292b31;
  --line: #34363d;
  --line-soft: #27292e;
  --text: #f3f3f5;
  --muted: #9a9da6;
  --accent: #d9293b;
  --accent-hover: #ed3b4d;
  --accent-soft: rgba(217, 41, 59, 0.14);
  --button-frame: rgba(255, 255, 255, 0.11);
  --success: #45c878;
  --warning: #f2b84b;
  --radius: 8px;
  --header-height: 68px;
  --app-font-size: 15px;
  --app-font-weight: 500;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  font-size: var(--app-font-size);
  font-weight: var(--app-font-weight);
  letter-spacing: 0;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  width: 100%;
  min-width: 320px;
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

html {
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-gutter: stable;
}

body {
  overflow-x: hidden;
  overflow-y: visible;
}

button,
input,
textarea,
select {
  font: inherit;
  letter-spacing: 0;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.55;
}

input,
textarea,
select {
  outline: 0;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--surface);
}

::-webkit-scrollbar-thumb {
  border: 2px solid var(--surface);
  border-radius: 6px;
  background: var(--accent);
}

.auth-view {
  position: relative;
  display: grid;
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  grid-template-rows: 1fr;
  align-items: center;
  overflow: visible;
  background: var(--bg);
}

.auth-shell {
  width: min(480px, calc(100% - 36px));
  margin: 84px auto 28px;
  padding: 34px;
  border: 1px solid var(--button-frame);
  border-radius: calc(var(--radius) + 10px);
  background: linear-gradient(145deg, var(--surface), var(--bg));
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.38);
}

.auth-back-button {
  display: inline-flex;
  width: 100%;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 24px;
  border-color: var(--button-frame);
  background: var(--surface);
}

.auth-brand {
  position: absolute;
  top: 24px;
  left: 24px;
  margin: 0;
}

.auth-brand,
.mail-brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--text);
  font-size: 18px;
  font-weight: 800;
  text-decoration: none;
}

.auth-brand img,
.mail-brand img {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  object-fit: cover;
}

.auth-brand strong,
.mail-brand strong {
  color: var(--accent);
}

.auth-heading {
  margin: 0 0 26px;
}

.auth-heading p,
.modal-header p {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 900;
}

.auth-heading h1 {
  margin: 0;
  font-size: 31px;
  line-height: 1.15;
}

.auth-heading .auth-description {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.6;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 24px;
}

.auth-tab {
  height: 44px;
  border: 1px solid var(--button-frame);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--muted);
  font-weight: 750;
}

.auth-tab:hover {
  border-color: var(--line);
  background: var(--surface-3);
  color: var(--text);
}

.auth-tab.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--accent-soft);
}

.auth-form,
.settings-form {
  display: grid;
  gap: 17px;
}

.auth-form label,
.settings-form label {
  display: grid;
  gap: 7px;
}

.auth-form label > span:first-child,
.settings-form label > span:first-child {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.auth-form input,
.settings-form input,
.settings-form select,
.logout-options select {
  width: 100%;
  height: 46px;
  padding: 0 13px;
  border: 1px solid var(--button-frame);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  transition:
    border-color 140ms ease,
    background-color 140ms ease;
}

.auth-form input:focus,
.settings-form input:focus,
.settings-form select:focus,
.logout-options select:focus {
  border-color: var(--accent);
  background: var(--surface-2);
}

.address-input {
  display: grid !important;
  grid-template-columns: minmax(90px, 1fr) auto;
  align-items: center;
  border: 1px solid var(--button-frame);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.address-input:focus-within {
  border-color: var(--accent);
}

.address-input input {
  border: 0;
  background: transparent;
}

.address-input b {
  min-width: 0;
  padding-right: 12px;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.primary-button,
.outline-button,
.danger-button {
  min-height: 42px;
  padding: 9px 17px;
  border-radius: var(--radius);
  font-weight: 800;
  transition:
    background-color 140ms ease,
    border-color 140ms ease,
    transform 140ms ease;
}

.primary-button {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
}

.primary-button:hover {
  background: var(--accent-hover);
}

.outline-button {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
}

.outline-button:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.danger-button {
  background: var(--accent);
  color: #fff;
}

.auth-form .primary-button {
  width: 100%;
  margin-top: 5px;
}

.mail-app {
  display: grid;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  grid-template-columns: 244px minmax(0, 1fr);
  grid-template-rows: var(--header-height) minmax(0, 1fr);
  background: var(--bg);
  overflow: hidden;
}

.mail-header {
  position: relative;
  z-index: 40;
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: 244px minmax(260px, 720px) 1fr auto;
  align-items: center;
  gap: 18px;
  height: var(--header-height);
  padding: 0 22px 0 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.header-brand-block {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 8px;
}

.mobile-menu {
  display: none !important;
}

.mail-search {
  display: grid;
  width: 100%;
  height: 44px;
  grid-template-columns: 36px minmax(0, 1fr) 36px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  transition:
    border-color 140ms ease,
    background-color 140ms ease;
}

.mail-search:focus-within {
  border-color: var(--accent);
  background: var(--surface-3);
}

.mail-search > span {
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  color: var(--muted);
}

.mail-search > span .lucide {
  width: 18px;
  height: 18px;
}

.mail-search input {
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  line-height: 1.2;
}

.mail-search input::placeholder {
  color: var(--muted);
}

.mail-search button {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 21px;
}

.mail-search button:hover {
  background: var(--surface-3);
  color: var(--text);
}

.avatar-button,
.large-avatar,
.small-avatar,
.sender-avatar {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-weight: 900;
}

.avatar-button {
  width: auto;
  min-width: 40px;
  height: 40px;
  padding: 0;
  border: 2px solid transparent;
  overflow: hidden;
}

.avatar-button {
  gap: 7px;
  padding: 0 12px 0 4px;
  border: 1px solid var(--button-frame);
  border-radius: var(--radius);
  background: transparent;
}

#avatar-initial {
  display: flex;
  width: 32px;
  height: 32px;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  overflow: hidden;
}

#avatar-initial img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.avatar-button:hover,
.avatar-button[aria-expanded="true"] {
  border-color: transparent;
  box-shadow: none;
  transform: translateY(-1px) scale(1.03);
}

.avatar-button:focus-visible {
  border-color: transparent;
  box-shadow: 0 0 0 3px var(--accent-soft);
  transform: translateY(-1px) scale(1.03);
}

.avatar-button,
.avatar-button:focus,
.avatar-button:focus-visible {
  outline: 0;
  border-color: transparent;
}

.account-dialog {
  width: min(560px, calc(100% - 30px));
  max-height: calc(100vh - 36px);
  max-height: calc(100dvh - 36px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 4px);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.68);
  overflow: hidden;
}

.account-dialog[open] {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.account-dialog::backdrop {
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(5px);
}

.account-dialog-header {
  display: flex;
  min-height: 76px;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 15px 22px;
  border-bottom: 1px solid var(--line);
}

.account-dialog-header p,
.account-section-title {
  margin: 0;
  color: var(--accent);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.account-dialog-header h2 {
  margin: 4px 0 0;
  font-size: 21px;
}

.account-dialog-content {
  display: grid;
  min-height: 0;
  gap: 18px;
  padding: 20px 22px 22px;
  overflow-y: auto;
  scrollbar-width: none;
}

.account-dialog-content::-webkit-scrollbar,
.account-list::-webkit-scrollbar {
  display: none;
}

.current-account {
  display: grid;
  min-width: 0;
  grid-template-columns: 64px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 18px;
  border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--line));
  border-radius: calc(var(--radius) + 2px);
  background:
    radial-gradient(circle at 100% 0, var(--accent-soft), transparent 42%),
    var(--surface-2);
}

.large-avatar {
  width: 58px;
  height: 58px;
  margin-bottom: 11px;
  font-size: 23px;
}

.current-account .large-avatar {
  width: 64px;
  height: 64px;
  margin: 0;
}

.current-account strong {
  overflow: hidden;
  font-size: 16px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.current-account-copy {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.current-account-copy small {
  color: var(--accent);
  font-size: 9px;
  font-weight: 850;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.current-account-copy > span {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-status {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  gap: 5px;
  padding: 0 9px;
  border: 1px solid color-mix(in srgb, var(--success) 35%, var(--line));
  border-radius: 999px;
  background: color-mix(in srgb, var(--success) 9%, transparent);
  color: var(--success);
  font-size: 10px;
  font-weight: 800;
}

.account-status .lucide {
  width: 13px;
  height: 13px;
  stroke-width: 2.5;
}

.account-list-section,
.account-actions {
  display: grid;
  gap: 9px;
}

.account-section-title {
  padding-left: 2px;
  color: var(--muted);
}

.account-list {
  display: grid;
  max-height: 156px;
  gap: 6px;
  overflow-y: auto;
  scrollbar-width: none;
}

.account-switch,
.popover-action {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  text-align: left;
  transition:
    border-color 160ms ease,
    background-color 160ms ease,
    transform 180ms ease;
}

.account-switch:hover,
.popover-action:hover {
  border-color: color-mix(in srgb, var(--accent) 42%, var(--line));
  background: var(--surface-3);
  transform: translateY(-1px);
}

.small-avatar {
  width: 36px;
  height: 36px;
}

.account-switch > span:last-child {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.account-switch strong,
.account-switch small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-switch small {
  color: var(--muted);
}

.popover-action > span {
  color: var(--muted);
}

.popover-action > .action-sticker {
  display: inline-flex;
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  background: var(--accent-soft);
  color: var(--accent);
}

.account-action-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
}

.account-dialog .popover-action {
  display: grid;
  min-height: 56px;
  grid-template-columns: 34px minmax(0, 1fr);
  align-content: center;
  gap: 10px;
  padding: 8px 12px;
  border-color: var(--button-frame);
}

.account-dialog .popover-action > span:last-child {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.account-dialog .popover-action strong {
  color: var(--text);
  font-size: 12px;
}

.account-dialog .popover-action small {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.35;
}

.account-dialog .danger-action strong,
.account-dialog .danger-action:hover strong {
  color: #ff8791;
}

@media (max-width: 520px) {
  .account-dialog {
    width: calc(100% - 20px);
    max-height: calc(100dvh - 20px);
  }

  .account-dialog-header {
    min-height: 68px;
    padding: 12px 14px 11px 16px;
  }

  .account-dialog-content {
    gap: 15px;
    padding: 14px;
  }

  .current-account {
    grid-template-columns: 54px minmax(0, 1fr);
    gap: 12px;
    padding: 15px;
  }

  .current-account .large-avatar {
    width: 54px;
    height: 54px;
    margin: 0;
  }

  .account-status {
    grid-column: 2;
    justify-self: start;
  }

  .account-dialog .popover-action {
    min-height: 56px;
  }
}

.danger-action > .action-sticker {
  background: rgba(255, 92, 105, 0.12);
  color: #ff8791;
}

.danger-action {
  color: #ff8791;
}

.sidebar {
  display: flex;
  min-height: 0;
  flex-direction: column;
  padding: 18px 12px 12px;
  border-right: 1px solid var(--line);
  background: var(--surface);
  overflow-y: auto;
  scrollbar-gutter: stable;
}

.compose-button {
  display: grid;
  width: 100%;
  height: 48px;
  grid-template-columns: 35px minmax(0, 1fr) auto;
  align-items: center;
  gap: 0;
  margin: 0 0 20px;
  padding: 0 12px;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font-weight: 850;
  text-align: left;
}

.compose-button:hover {
  background: var(--accent-hover);
}

.compose-button span {
  display: inline-flex;
  width: 28px;
  height: 28px;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}

.folder-nav {
  display: grid;
  gap: 3px;
}

.folder-button {
  display: grid;
  width: 100%;
  height: 42px;
  grid-template-columns: 35px minmax(0, 1fr) auto;
  align-items: center;
  padding: 0 12px;
  border: 1px solid var(--button-frame);
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  text-align: left;
}

.folder-button:hover {
  background: var(--surface-2);
  color: var(--text);
}

.folder-button.active {
  background: var(--accent-soft);
  color: #fff;
}

.folder-button.active span {
  color: var(--accent-hover);
}

.folder-button span {
  font-size: 18px;
}

.folder-button > .nav-sticker {
  display: inline-flex;
  width: 28px;
  height: 28px;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  background: rgba(217, 41, 59, 0.12);
  color: #f05a68;
}

.folder-button:nth-child(2) > .nav-sticker {
  background: rgba(244, 183, 64, 0.12);
  color: #f4b740;
}

.folder-button:nth-child(3) > .nav-sticker {
  background: rgba(79, 141, 255, 0.12);
  color: #6b9cff;
}

.folder-button:nth-child(4) > .nav-sticker {
  background: rgba(55, 184, 125, 0.12);
  color: #45c98d;
}

.folder-button:nth-child(5) > .nav-sticker {
  background: rgba(171, 112, 255, 0.12);
  color: #b383ff;
}

.folder-button:nth-child(6) > .nav-sticker {
  background: rgba(140, 145, 158, 0.12);
  color: #a3a8b4;
}

.folder-button b {
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.folder-button em {
  color: inherit;
  font-size: 12px;
  font-style: normal;
  font-weight: 800;
}

.sidebar-account {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 9px;
  margin-top: auto;
  padding: 14px 10px 2px;
  border-top: 1px solid var(--line-soft);
  color: var(--muted);
  font-size: 11px;
}

.sidebar-account span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--success);
}

.mail-content {
  min-width: 0;
  min-height: 0;
  background: var(--bg);
  overflow: hidden;
}

.message-panel,
.reader {
  display: flex;
  width: 100%;
  height: 100%;
  min-height: 0;
  flex-direction: column;
}

.list-toolbar,
.reader-toolbar {
  display: flex;
  min-height: 72px;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}

.list-toolbar h1 {
  margin: 0 0 3px;
  font-size: 20px;
}

.list-toolbar > div > span {
  color: var(--muted);
  font-size: 12px;
}

.icon-button {
  display: inline-flex;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 20px;
}

.icon-button span,
.settings-button span,
.avatar-button b {
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
}

.lucide {
  display: block;
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.icon-button .lucide,
.settings-button .lucide,
.dialog-close .lucide {
  width: 19px;
  height: 19px;
}

.icon-button:hover {
  border-color: var(--line);
  background: var(--surface-2);
  color: var(--text);
}

.icon-button.active {
  color: var(--warning);
}

.message-list {
  min-height: 0;
  overflow-y: auto;
  scrollbar-gutter: stable;
}

.message-row {
  display: grid;
  min-height: 54px;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: stretch;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(32, 33, 38, 0.52);
}

.message-row.unread {
  background: var(--surface-2);
}

.message-row:hover {
  position: relative;
  z-index: 1;
  background: var(--surface-3);
  box-shadow: inset 3px 0 0 var(--accent);
}

.star-button {
  width: 42px;
  background: transparent;
  color: #6e717a;
  font-size: 20px;
}

.star-button:hover,
.star-button.active {
  color: var(--warning);
}

.star-button.active .lucide,
.icon-button.active .lucide {
  fill: currentColor;
}

.message-open {
  display: grid;
  min-width: 0;
  grid-template-columns:
    minmax(150px, 0.34fr) minmax(150px, 0.42fr) minmax(120px, 1fr)
    62px;
  align-items: center;
  gap: 13px;
  padding: 0 19px 0 4px;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.message-open strong,
.message-open span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-open strong,
.row-subject {
  font-size: 13px;
}

.message-row:not(.unread) .message-open strong,
.message-row:not(.unread) .row-subject {
  font-weight: 500;
}

.row-snippet {
  color: var(--muted);
  font-size: 12px;
}

.thread-count {
  display: inline-flex;
  min-width: 20px;
  height: 20px;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent-hover);
  font-size: 10px;
  font-weight: 900;
  vertical-align: middle;
}

.message-open time {
  color: var(--muted);
  font-size: 11px;
  text-align: right;
}

.empty-state {
  display: flex;
  min-height: 0;
  flex: 1;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 30px;
  color: var(--muted);
  text-align: center;
}

.empty-state > span {
  display: inline-flex;
  width: 54px;
  height: 54px;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--accent);
  font-size: 23px;
  font-weight: 900;
}

.empty-state strong {
  color: var(--text);
  font-size: 17px;
}

.empty-state p {
  margin: 7px 0 0;
  font-size: 13px;
}

.reader-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.reader-toolbar .icon-button {
  width: auto;
  min-width: 38px;
  gap: 7px;
  padding: 0 11px;
  border-color: var(--button-frame);
  border-radius: var(--radius);
  font-size: 13px;
}

.reader-content {
  width: min(980px, 100%);
  margin: 0 auto;
  padding: 35px 38px 60px;
  overflow-y: auto;
  scrollbar-gutter: stable;
}

.reader-content h1 {
  margin: 0 0 28px;
  font-size: 25px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.reader-sender-row {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line-soft);
}

.sender-avatar {
  width: 42px;
  height: 42px;
  background: var(--surface-3);
  color: var(--accent-hover);
}

.reader-sender-row > div {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.reader-sender-row strong,
.reader-sender-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reader-sender-row span,
.reader-sender-row time {
  color: var(--muted);
  font-size: 12px;
}

.reader-content pre {
  min-height: 200px;
  margin: 28px 0 0;
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  line-height: 1.65;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.conversation-thread {
  display: grid;
  gap: 16px;
  margin-top: 28px;
}

.thread-message {
  display: grid;
  width: min(760px, 92%);
  gap: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  overflow: hidden;
}

.thread-message.incoming {
  justify-self: start;
  border-top-left-radius: 4px;
}

.thread-message.outgoing {
  justify-self: end;
  border-color: color-mix(in srgb, var(--accent) 42%, var(--line));
  border-top-right-radius: 4px;
  background: color-mix(in srgb, var(--accent-soft) 55%, var(--surface));
}

.thread-message.selected {
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.thread-message header {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface-2) 72%, transparent);
}

.thread-avatar {
  width: 36px;
  height: 36px;
  font-size: 13px;
}

.thread-message header > div {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.thread-message header strong,
.thread-message header span,
.thread-message header time {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.thread-message header span,
.thread-message header time {
  color: var(--muted);
  font-size: 11px;
}

.thread-message pre {
  min-height: 0;
  margin: 0;
  font-size: 14px;
  line-height: 1.65;
}

.thread-html-body {
  display: block;
  width: 100%;
  height: 520px;
  min-height: 240px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.thread-clean-email {
  display: grid;
  gap: 13px;
  padding: clamp(18px, 4vw, 34px);
  border: 1px solid var(--line);
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface-2) 74%, var(--surface));
  line-height: 1.6;
}

.thread-clean-email p {
  margin: 0;
}

.thread-clean-email .email-emphasis {
  color: var(--text);
  font-size: 16px;
  font-weight: 800;
}

.thread-clean-email .email-verification-code {
  width: fit-content;
  margin: 5px 0;
  padding: 12px 18px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent-soft);
  color: var(--text);
  font:
    900 26px/1.1 "Cascadia Mono",
    Consolas,
    monospace;
  letter-spacing: 5px;
}

.thread-message-content {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.thread-attachment {
  display: block;
  width: min(460px, 100%);
  max-width: 460px;
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  cursor: zoom-in;
  overflow: hidden;
}

.thread-attachment img {
  display: block;
  width: 100%;
  max-height: 340px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  object-fit: contain;
}

.thread-attachment:hover img {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.image-preview-dialog {
  width: min(980px, calc(100% - 28px));
  max-height: calc(100vh - 28px);
  max-height: calc(100dvh - 28px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.72);
  overflow: hidden;
}

.image-preview-dialog::backdrop {
  background: rgba(0, 0, 0, 0.84);
  backdrop-filter: blur(5px);
}

.image-preview-header,
.image-preview-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

.image-preview-stage {
  display: grid;
  min-height: 280px;
  max-height: calc(100vh - 170px);
  max-height: calc(100dvh - 170px);
  place-items: center;
  padding: 18px;
  background: #090a0c;
  overflow: auto;
}

.image-preview-stage img {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 210px);
  max-height: calc(100dvh - 210px);
  object-fit: contain;
}

.image-preview-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
  border-top: 1px solid var(--line);
  border-bottom: 0;
}

.image-preview-actions button {
  display: inline-flex;
  width: auto;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
}

.image-preview-actions button:disabled {
  cursor: progress;
  opacity: 0.78;
}

.share-image-dialog {
  width: min(520px, calc(100% - 28px));
}

.share-image-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 20px;
}

.share-image-options button {
  display: flex;
  min-height: 58px;
  align-items: center;
  gap: 10px;
  padding: 0 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  font-weight: 750;
}

.share-image-options button:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.share-image-options button .lucide {
  color: var(--accent);
}

.copy-success-dialog {
  width: min(390px, calc(100% - 28px));
}

.copy-success-content {
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 28px 24px 24px;
  text-align: center;
}

.copy-success-content h2,
.copy-success-content p {
  margin: 0;
}

.copy-success-content p {
  color: var(--muted);
  line-height: 1.5;
}

.copy-success-sticker {
  display: inline-flex;
  width: 58px;
  height: 58px;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(80, 200, 120, 0.35);
  border-radius: 50%;
  background: rgba(80, 200, 120, 0.13);
  color: #64d98b;
}

.copy-success-sticker .lucide {
  width: 29px;
  height: 29px;
  stroke-width: 2.5;
}

.copy-success-content .dialog-close {
  width: auto;
  height: auto;
  min-width: 130px;
  margin-top: 6px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: transparent;
  color: var(--accent);
  font-size: 14px;
}

.copy-success-content .dialog-close:hover {
  border-color: var(--accent-hover);
  background: var(--accent-soft);
  color: var(--accent-hover);
}

.reader-reply-bar {
  display: flex;
  justify-content: flex-end;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--line-soft);
}

.reader-reply-bar .primary-button {
  display: inline-flex;
  min-width: 140px;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.compose-recipient-field input:read-only {
  color: var(--muted);
  cursor: default;
}

.compose-window {
  position: fixed;
  z-index: 60;
  right: 24px;
  bottom: 0;
  display: grid;
  width: min(560px, calc(100vw - 32px));
  height: min(600px, calc(100vh - 95px));
  grid-template-rows: 44px minmax(0, 1fr);
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: var(--radius) var(--radius) 0 0;
  background: var(--surface);
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.5);
  transition:
    border-color 180ms ease,
    box-shadow 180ms ease,
    transform 220ms ease,
    opacity 180ms ease;
}

.compose-window:focus-within {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  box-shadow:
    0 18px 58px rgba(0, 0, 0, 0.56),
    0 0 0 1px var(--accent-soft);
}

.compose-window.collapsed {
  height: 44px;
}

.compose-window.collapsed form {
  display: none;
}

.compose-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px 0 16px;
  border-radius: var(--radius) var(--radius) 0 0;
  background: var(--surface-3);
  color: var(--text);
  font-size: 13px;
}

.compose-header button {
  width: 30px;
  height: 30px;
  background: transparent;
  color: var(--muted);
  font-size: 20px;
}

.compose-header button:hover {
  color: var(--text);
}

.compose-window form {
  display: grid;
  min-height: 0;
  grid-template-rows: 43px 43px minmax(120px, 1fr) 58px;
}

.compose-window input,
.compose-window textarea {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  background: transparent;
  color: var(--text);
  transition:
    border-color 150ms ease,
    background-color 150ms ease,
    box-shadow 150ms ease;
}

.compose-window input::selection,
.compose-window textarea::selection {
  background: var(--accent-soft);
  color: var(--text);
}

.compose-window input {
  padding: 0 15px;
}

.compose-window textarea {
  padding: 16px;
  line-height: 1.5;
  resize: none;
}

.compose-window input:focus,
.compose-window textarea:focus {
  border-bottom-color: var(--accent);
  background: rgba(255, 255, 255, 0.025);
  box-shadow: inset 3px 0 0 var(--accent);
}

.compose-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px 8px 14px;
}

.compose-footer .primary-button {
  min-width: 112px;
}

.compose-footer .outline-button {
  min-height: 40px;
  gap: 8px;
  border-color: var(--button-frame);
}

.draft-sticker {
  display: inline-flex;
  width: 48px;
  height: 48px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--button-frame);
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 22px;
}

.modal {
  width: min(500px, calc(100% - 30px));
  max-height: calc(100vh - 40px);
  max-height: calc(100dvh - 40px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.65);
  overflow-y: auto;
  scrollbar-gutter: stable;
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0.72);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 22px;
  border-bottom: 1px solid var(--line);
}

.modal-header p {
  margin-bottom: 5px;
}

.modal-header h2 {
  margin: 0;
  font-size: 20px;
}

.dialog-close {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 23px;
}

.dialog-close:hover {
  background: var(--surface-3);
  color: var(--text);
}

.profile-summary {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 20px 22px;
  border-bottom: 1px solid var(--line-soft);
}

.profile-summary .large-avatar {
  width: 48px;
  height: 48px;
  margin: 0;
  font-size: 19px;
}

.profile-summary > div {
  display: grid;
  min-width: 0;
  gap: 5px;
}

.profile-summary strong,
.profile-summary span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-summary span {
  color: var(--muted);
  font-size: 12px;
}

.settings-form {
  padding: 20px 22px 22px;
  border-bottom: 1px solid var(--line-soft);
}

.settings-form:last-child {
  border-bottom: 0;
}

.settings-form h3 {
  margin: 0 0 2px;
  font-size: 14px;
}

.settings-form .outline-button {
  justify-self: start;
}

.small-modal {
  width: min(460px, calc(100% - 30px));
}

.logout-options {
  display: grid;
  gap: 7px;
  padding: 18px 22px 22px;
}

.logout-options > label {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  align-items: start;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  cursor: pointer;
}

.logout-options > label:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.logout-options input[type="radio"] {
  margin: 4px 0 0;
  accent-color: var(--accent);
}

.logout-options label > span {
  display: grid;
  gap: 4px;
}

.logout-options small {
  color: var(--muted);
}

.logout-options select {
  height: 36px;
  margin-top: 5px;
}

.logout-options .danger-button {
  margin-top: 8px;
}

.sidebar-scrim {
  position: fixed;
  z-index: 44;
  inset: var(--header-height) 0 0;
  background: rgba(0, 0, 0, 0.6);
}

.toast {
  position: fixed;
  z-index: 100;
  right: max(20px, env(safe-area-inset-right));
  bottom: max(20px, env(safe-area-inset-bottom));
  left: auto;
  max-width: min(430px, calc(100vw - 32px));
  padding: 12px 16px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--surface-3);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 920px) {
  .mail-app {
    grid-template-columns: 210px minmax(0, 1fr);
  }

  .mail-header {
    grid-template-columns: 210px minmax(220px, 1fr) auto;
  }

  .mail-search + * {
    justify-self: end;
  }

  .message-open {
    grid-template-columns: minmax(130px, 0.4fr) minmax(160px, 1fr) 58px;
  }

  .row-snippet {
    display: none;
  }
}

@media (max-width: 760px) {
  .mail-app {
    grid-template-columns: minmax(0, 1fr);
  }

  .mail-header {
    grid-template-columns: auto minmax(120px, 1fr) auto;
    gap: 10px;
    padding: 0 12px;
  }

  .header-brand-block {
    gap: 3px;
  }

  .mobile-menu {
    display: inline-flex !important;
  }

  .mail-brand span {
    display: none;
  }

  .mail-brand img {
    width: 34px;
    height: 34px;
  }

  .mail-search {
    height: 40px;
  }

  .mail-search > span {
    font-size: 20px;
  }

  .sidebar {
    position: fixed;
    z-index: 45;
    top: var(--header-height);
    bottom: 0;
    left: 0;
    width: 260px;
    transform: translateX(-100%);
    transition: transform 180ms ease;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .mail-content {
    grid-column: 1;
  }

  .list-toolbar,
  .reader-toolbar {
    min-height: 64px;
    padding: 0 15px;
  }

  .message-row {
    min-height: 66px;
  }

  .message-open {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto;
    gap: 5px 10px;
    padding: 10px 13px 10px 0;
  }

  .message-open .row-subject {
    grid-column: 1;
    grid-row: 2;
  }

  .message-open time {
    grid-column: 2;
    grid-row: 1;
  }

  .reader-content {
    padding: 26px 20px 50px;
  }

  .reader-content h1 {
    font-size: 21px;
  }

  .reader-sender-row {
    grid-template-columns: 40px minmax(0, 1fr);
  }

  .reader-sender-row time {
    grid-column: 2;
  }

  .compose-window {
    right: 10px;
    width: calc(100vw - 20px);
  }
}

@media (max-width: 480px) {
  .auth-view {
    align-items: start;
  }

  .auth-shell {
    width: min(100% - 28px, 420px);
    margin: 78px auto 14px;
    padding: 24px;
  }

  .auth-heading {
    margin-top: 0;
  }

  .auth-brand {
    top: 18px;
    left: 16px;
  }

  .auth-heading h1 {
    font-size: 27px;
  }

  .mail-header {
    grid-template-columns: auto minmax(92px, 1fr) 38px;
    padding: 0 8px;
  }

  .mail-brand {
    display: none;
  }

  .mail-search {
    grid-template-columns: 30px minmax(0, 1fr) 30px;
  }

  .mail-search input::placeholder {
    font-size: 12px;
  }

  .compose-window {
    height: calc(100vh - 82px);
  }

  .modal-header,
  .profile-summary,
  .settings-form,
  .logout-options {
    padding-left: 16px;
    padding-right: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 1ms !important;
    transition-duration: 1ms !important;
  }
}

/* Account security and settings */
html[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #eceef2;
  --surface-3: #e2e5ea;
  --line: #cfd3da;
  --line-soft: #e1e4e9;
  --text: #17181b;
  --muted: #666b75;
  --button-frame: rgba(15, 18, 24, 0.13);
}

.mail-header {
  grid-template-columns: 244px minmax(260px, 720px) minmax(80px, 1fr);
}

.header-actions {
  display: flex;
  justify-self: end;
  align-items: center;
  gap: 8px;
}

.settings-button {
  display: inline-flex;
  width: auto;
  min-width: 40px;
  height: 40px;
  gap: 7px;
  padding: 0 12px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--button-frame);
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  font-size: 22px;
  transition:
    color 150ms ease,
    background-color 150ms ease,
    transform 220ms ease;
}

.settings-button:hover {
  border-color: var(--line);
  background: var(--surface-3);
  color: var(--text);
  transform: translateY(-1px);
}

.avatar-button,
.large-avatar,
.small-avatar,
.sender-avatar,
.avatar-preview {
  overflow: hidden;
}

.avatar-button img,
.large-avatar img,
.small-avatar img,
.sender-avatar img,
.avatar-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-picker input[type="file"],
.profile-avatar-editor input[type="file"] {
  display: none;
}

.avatar-picker-row {
  display: flex;
  align-items: center;
  gap: 13px;
}

.avatar-preview {
  display: inline-flex;
  width: 52px;
  height: 52px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 20px;
  font-weight: 900;
}

.avatar-picker-row .outline-button {
  display: inline-flex;
  width: auto;
  min-height: 38px;
  align-items: center;
  color: var(--text) !important;
  cursor: pointer;
}

.compose-window {
  top: 50%;
  right: auto;
  bottom: auto;
  left: 50%;
  width: min(640px, calc(100vw - 32px));
  height: min(560px, calc(100vh - 90px));
  grid-template-rows: 50px minmax(0, 1fr);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -47%) scale(0.97);
  transition:
    opacity 170ms ease,
    transform 190ms ease;
}

.compose-window.open {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
}

.compose-header {
  border-radius: var(--radius) var(--radius) 0 0;
}

.compose-header > button {
  width: 34px;
  height: 34px;
  border-radius: 50%;
}

.compose-header > button:hover {
  background: var(--surface-2);
}

.compose-window form {
  grid-template-rows: 58px minmax(160px, 1fr) 62px;
}

.compose-window input {
  padding: 0 18px;
  font-size: 13px;
}

.compose-window textarea {
  padding: 20px 18px;
}

.settings-modal {
  width: min(1080px, calc(100% - 34px));
  height: min(760px, calc(100vh - 34px));
  height: min(760px, calc(100dvh - 34px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 25px 80px rgba(0, 0, 0, 0.62);
  overflow: hidden;
}

.settings-modal::backdrop,
.modal::backdrop {
  background: rgba(0, 0, 0, 0.74);
  backdrop-filter: blur(3px);
}

.settings-header {
  display: flex;
  height: 76px;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
}

.settings-header p,
.panel-heading p {
  margin: 0 0 5px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 900;
}

.settings-header h2,
.panel-heading h3 {
  margin: 0;
}

.settings-header h2 {
  font-size: 21px;
}

.settings-layout {
  display: grid;
  height: calc(100% - 76px);
  grid-template-columns: 240px minmax(0, 1fr);
}

.settings-nav {
  display: grid;
  align-content: start;
  gap: 5px;
  padding: 18px 12px;
  border-right: 1px solid var(--line);
  background: var(--surface-2);
}

.settings-nav-button {
  display: grid;
  min-height: 46px;
  grid-template-columns: 34px minmax(0, 1fr);
  column-gap: 8px;
  align-items: center;
  padding: 0 12px;
  border: 1px solid var(--button-frame);
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
  text-align: left;
  transition:
    color 140ms ease,
    background-color 140ms ease,
    transform 140ms ease;
}

.settings-nav-button:hover {
  background: var(--surface-3);
  color: var(--text);
  transform: translateY(-1px);
}

.settings-nav-button.active {
  border-color: color-mix(in srgb, var(--accent) 48%, var(--line));
  background: var(--accent-soft);
  color: var(--text);
}

.settings-nav-button.active span {
  color: var(--accent);
}

.settings-nav-button > .settings-sticker {
  display: inline-flex;
  width: 28px;
  height: 28px;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  background: rgba(217, 41, 59, 0.12);
  color: #f05a68;
}

.settings-nav-button:nth-child(2) > .settings-sticker {
  background: rgba(55, 184, 125, 0.12);
  color: #45c98d;
}

.settings-nav-button:nth-child(3) > .settings-sticker {
  background: rgba(171, 112, 255, 0.12);
  color: #b383ff;
}

.settings-nav-button:nth-child(4) > .settings-sticker {
  background: rgba(79, 141, 255, 0.12);
  color: #6b9cff;
}

.settings-content {
  min-width: 0;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-gutter: stable;
}

.settings-panel {
  display: none;
  min-width: 0;
  max-width: 100%;
  width: min(720px, calc(100% - 54px));
  margin: 0 auto;
  padding: 34px 0 54px;
}

.settings-panel.active {
  display: block;
  animation: panel-enter 190ms ease both;
}

.panel-heading {
  margin-bottom: 28px;
}

.panel-heading h3 {
  font-size: 24px;
}

.settings-panel .settings-form {
  gap: 18px;
  padding: 0;
  border: 0;
}

.settings-panel .settings-form input {
  background: var(--surface-2);
}

.settings-panel .settings-form select {
  width: 100%;
  height: 46px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
}

.profile-avatar-editor {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 5px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line-soft);
}

.profile-avatar-editor .large-avatar {
  width: 72px;
  height: 72px;
  margin: 0 8px 0 0;
}

.profile-avatar-editor label {
  display: inline-flex;
  width: auto;
  min-height: 40px;
  align-items: center;
  cursor: pointer;
}

.text-button {
  min-height: 36px;
  padding: 6px 8px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.text-button:hover {
  color: var(--accent);
}

.settings-subheading {
  display: grid;
  gap: 5px;
  margin-top: 12px;
  padding-top: 22px;
  border-top: 1px solid var(--line-soft);
}

.settings-subheading h4,
.security-block h4 {
  margin: 0;
  font-size: 15px;
}

.settings-subheading span,
.security-block span,
.devices-toolbar > span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.form-submit {
  justify-self: start;
  margin-top: 8px;
}

.security-block {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 78px;
  padding: 15px 0;
  border-bottom: 1px solid var(--line-soft);
}

.security-block > div {
  display: grid;
  gap: 6px;
}

#two-factor-status.enabled {
  color: var(--success);
  font-weight: 800;
}

.security-form {
  margin-top: 10px;
}

.devices-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
}

.device-list {
  display: grid;
  gap: 10px;
}

.device-item {
  display: grid;
  min-height: 92px;
  grid-template-columns: 46px minmax(0, 1fr) auto;
  align-items: start;
  gap: 13px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.device-icon {
  display: inline-flex;
  width: 42px;
  height: 42px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--accent);
  font-size: 19px;
}

.device-item > div {
  display: grid;
  min-width: 0;
  gap: 6px;
}

.device-item span,
.device-item em {
  color: var(--text);
  font-size: 11px;
  font-style: normal;
}

.device-item em {
  color: var(--success);
  font-weight: 800;
}

.device-item .device-location {
  color: var(--text);
  font-weight: 700;
}

.device-item > div > strong {
  font-size: 14px;
}

.device-meta-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.device-meta-grid span {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  gap: 6px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}

.device-meta-grid b {
  color: var(--text);
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
}

.settings-form fieldset {
  margin: 0;
  padding: 0;
  border: 0;
}

.settings-form legend {
  margin-bottom: 9px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.segmented-control {
  display: grid;
  width: min(360px, 100%);
  grid-template-columns: 1fr 1fr;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.segmented-control label {
  cursor: pointer;
}

.segmented-control input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented-control span {
  display: flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  border-radius: 5px;
  color: var(--muted);
  font-weight: 750;
}

.segmented-control input:checked + span {
  background: var(--accent);
  color: #fff;
}

.color-control {
  display: flex;
  width: min(360px, 100%);
  height: 48px;
  align-items: center;
  gap: 12px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.color-control input[type="color"] {
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  background: transparent;
}

.color-control b {
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 13px;
}

.theme-preview {
  display: grid;
  min-height: 74px;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 13px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.theme-preview > span {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--preview-accent, var(--accent));
}

.theme-preview > div {
  display: grid;
  gap: 4px;
}

.theme-preview small {
  color: var(--muted);
}

.theme-preview button {
  min-height: 36px;
  padding: 7px 12px;
  border-radius: var(--radius);
  background: var(--preview-accent, var(--accent));
  color: #fff;
  font-weight: 750;
}

.sound-volume-control input[type="range"] {
  height: 8px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  accent-color: var(--accent);
}

.sound-volume-control b {
  color: var(--text);
}

.sound-preview-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.settings-form .sound-toggle {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  cursor: pointer;
}

.settings-form .sound-toggle input {
  position: relative;
  width: 44px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  appearance: none;
  background: var(--surface-3);
  cursor: pointer;
}

.settings-form .sound-toggle input::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  content: "";
  transition: transform 150ms ease;
}

.settings-form .sound-toggle input:checked {
  background: var(--accent);
}

.settings-form .sound-toggle input:checked::after {
  transform: translateX(20px);
}

.settings-form .sound-toggle > span {
  display: grid;
  gap: 4px;
  color: var(--text);
}

.settings-form .sound-toggle small {
  color: var(--muted);
  font-size: 11px;
}

.two-factor-setup {
  display: grid;
  justify-items: center;
  gap: 16px;
  padding: 24px;
  text-align: center;
}

.two-factor-setup > img {
  width: 210px;
  height: 210px;
  padding: 8px;
  border-radius: var(--radius);
  background: #fff;
}

.two-factor-setup > p,
.form-note,
.recovery-codes-content > p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.secret-row {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.secret-row code {
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  overflow-wrap: anywhere;
}

.two-factor-setup .auth-form {
  width: 100%;
}

.recovery-codes-content {
  display: grid;
  gap: 16px;
  padding: 22px;
}

.recovery-codes-content pre {
  margin: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  font:
    700 14px/1.8 "Cascadia Mono",
    Consolas,
    monospace;
  text-align: center;
}

dialog[open] {
  animation: dialog-enter 180ms ease both;
}

dialog[open]::backdrop {
  animation: backdrop-enter 180ms ease both;
}

@keyframes panel-enter {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes dialog-enter {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes backdrop-enter {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes popover-enter {
  from {
    opacity: 0;
    transform: translateY(-7px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 920px) {
  .mail-header {
    grid-template-columns: 210px minmax(220px, 1fr) auto;
  }

  .settings-layout {
    grid-template-columns: 210px minmax(0, 1fr);
  }
}

@media (max-width: 760px) {
  .mail-header {
    grid-template-columns: auto minmax(120px, 1fr) auto;
  }

  .settings-modal {
    width: calc(100% - 18px);
    height: calc(100vh - 18px);
    height: calc(100dvh - 18px);
  }

  .settings-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .settings-nav {
    display: flex;
    padding: 8px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    overflow-x: auto;
  }

  .settings-nav-button {
    min-width: 180px;
  }

  .settings-panel {
    width: calc(100% - 30px);
    padding-top: 24px;
  }

  .compose-window {
    right: auto;
    width: calc(100vw - 20px);
    height: min(560px, calc(100vh - 32px));
  }
}

@media (max-width: 480px) {
  .mail-header {
    grid-template-columns: auto minmax(80px, 1fr) auto;
  }

  .settings-button,
  .avatar-button {
    width: 36px;
    height: 36px;
  }

  .profile-avatar-editor,
  .devices-toolbar,
  .security-block {
    align-items: flex-start;
    flex-direction: column;
  }

  .device-item {
    grid-template-columns: 42px minmax(0, 1fr);
  }

  .device-item .outline-button {
    grid-column: 2;
    justify-self: start;
  }

  .secret-row {
    align-items: stretch;
    flex-direction: column;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 1ms !important;
    transition-duration: 1ms !important;
  }
}

/* Settings navigation, deferred saves, attachments, and localization. */
button,
a,
label,
input,
textarea {
  transition:
    color 140ms ease,
    background-color 140ms ease,
    border-color 140ms ease,
    box-shadow 140ms ease,
    opacity 140ms ease,
    transform 140ms ease;
}

button:active,
.outline-button:active,
.compose-button:active,
.avatar-button:active,
.settings-button:active {
  transform: scale(0.97);
}

#register-form .avatar-picker {
  padding: 15px;
  border: 1px solid var(--button-frame);
  border-radius: var(--radius);
  background: var(--surface-2);
  align-items: center;
  text-align: center;
}

#register-form .avatar-picker-row {
  justify-content: center;
}

.compose-window form {
  grid-template-rows: auto 44px minmax(160px, 1fr) auto auto;
}

.compose-recipient-field {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  min-height: 58px;
  padding-left: 18px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.compose-primary-actions {
  display: flex;
  align-items: center;
  gap: 9px;
}

.list-toolbar-primary,
.bulk-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.list-toolbar-primary > div {
  min-width: 0;
}

.bulk-actions {
  margin-left: auto;
  animation: panel-enter 150ms ease both;
}

.bulk-actions > span {
  min-width: 72px;
  color: var(--muted);
  font-size: 11px;
  text-align: right;
}

.bulk-action-button {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  gap: 6px;
  padding: 0 9px;
  border: 1px solid var(--button-frame);
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
}

.bulk-action-button b {
  color: var(--text);
  font-size: 15px;
}

.bulk-action-button:hover {
  border-color: var(--accent);
  background: var(--surface-2);
  color: var(--text);
}

.refresh-action-button {
  margin-left: auto;
}

.mail-checkbox {
  display: inline-flex;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.mail-checkbox input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.mail-checkbox span {
  display: inline-flex;
  width: 16px;
  height: 16px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--muted);
  border-radius: 4px;
  background: var(--surface-2);
}

.mail-checkbox input:checked + span,
.mail-checkbox input:indeterminate + span {
  border-color: var(--accent);
  background: var(--accent);
}

.mail-checkbox input:checked + span::after {
  content: "✓";
  color: #fff;
  font-size: 11px;
  font-weight: 900;
}

.mail-checkbox input:indeterminate + span::after {
  content: "−";
  color: #fff;
  font-size: 12px;
  font-weight: 900;
}

.row-checkbox {
  align-self: center;
  justify-self: center;
}

.message-row {
  grid-template-columns: 36px 42px minmax(0, 1fr);
}

.message-row.selected {
  background: var(--accent-soft);
  box-shadow: inset 3px 0 0 var(--accent);
}

.compose-recipient-field input {
  min-width: 0;
  border: 0;
  background: transparent;
}

.sender-avatar img,
.large-avatar img,
.small-avatar img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  object-fit: cover;
}

.reader-content {
  width: min(900px, 100%);
  padding-top: 24px;
}

.reader-content h1 {
  margin-bottom: 18px;
  font-size: 22px;
}

.reader-sender-row {
  grid-template-columns: 38px minmax(0, 1fr) auto;
  gap: 10px;
  padding-bottom: 14px;
}

.reader-sender-row .sender-avatar {
  width: 38px;
  height: 38px;
}

.conversation-thread {
  gap: 12px;
  margin-top: 18px;
}

.thread-message {
  width: min(720px, 96%);
  border-radius: var(--radius);
}

.thread-message header {
  grid-template-columns: 32px minmax(0, 1fr) auto;
  padding: 11px 14px;
}

.thread-avatar {
  width: 32px;
  height: 32px;
}

.thread-message-content {
  padding: 14px;
}

.thread-message pre {
  font-size: 13px;
  line-height: 1.55;
}

.thread-html-body {
  height: 320px;
  min-height: 160px;
}

#compose-subject:read-only {
  color: var(--muted);
  cursor: default;
}

.attachment-button {
  display: inline-flex;
  width: auto;
  min-height: 38px;
  align-items: center;
  cursor: pointer;
}

.attachment-button input,
.profile-avatar-editor input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.attachment-preview {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 32px;
  align-items: center;
  gap: 10px;
  margin: 0 18px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  animation: panel-enter 170ms ease both;
}

.attachment-preview img {
  width: 48px;
  height: 48px;
  border-radius: calc(var(--radius) - 2px);
  object-fit: cover;
}

.attachment-preview span {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 12px;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-preview button {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
}

.attachment-preview button:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.reader-attachment {
  display: grid;
  width: min(520px, 100%);
  gap: 8px;
  margin-top: 24px;
  color: var(--text);
  text-decoration: none;
}

.reader-attachment img {
  display: block;
  width: 100%;
  max-height: 420px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  object-fit: contain;
}

.reader-attachment span {
  color: var(--muted);
  font-size: 12px;
}

.settings-modal {
  position: relative;
}

.settings-panel {
  padding-bottom: 118px;
}

.function-index {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: -12px 0 28px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line-soft);
}

.function-index button {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.function-index button:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
}

.function-index button.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.settings-function {
  display: none;
}

.settings-function.active {
  display: grid;
  gap: 18px;
  animation: panel-enter 180ms ease both;
}

.settings-function > .settings-subheading:first-child,
.settings-function > form > .settings-subheading:first-child,
.settings-function
  > .embedded-settings-section
  > .settings-subheading:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.language-settings-panel {
  width: min(620px, 100%);
}

.embedded-settings-section {
  margin-top: 0;
  scroll-margin-top: 24px;
}

#profile-details,
#recovery-contacts,
#two-factor-section,
#recovery-codes-section,
#password-section,
#theme-section,
#accent-section,
#language-section {
  scroll-margin-top: 22px;
}

.inline-input-action {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 9px;
}

.inline-input-action .outline-button {
  min-width: 120px;
}

.recovery-email-field small {
  color: var(--success);
  font-size: 11px;
}

.language-select-button {
  display: flex;
  width: min(360px, 100%);
  min-height: 46px;
  align-items: center;
  justify-content: space-between;
}

.settings-savebar {
  position: absolute;
  z-index: 5;
  right: 0;
  bottom: 0;
  left: 240px;
  display: flex;
  min-height: 76px;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 12px 24px;
  border-top: 1px solid var(--accent);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  box-shadow: 0 -14px 35px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(12px);
  animation: savebar-enter 190ms ease both;
}

.settings-savebar > span {
  display: grid;
  gap: 3px;
}

.settings-savebar small {
  color: var(--muted);
  font-size: 11px;
}

.settings-savebar > div {
  display: flex;
  align-items: center;
  gap: 9px;
}

.settings-savebar .primary-button {
  min-height: 40px;
  padding: 0 18px;
}

.language-dialog {
  width: min(560px, calc(100% - 28px));
  max-height: min(680px, calc(100vh - 32px));
}

.language-search {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: center;
  margin: 18px 20px 12px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--muted);
}

.language-search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.language-search input {
  min-height: 44px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

.language-list {
  display: grid;
  max-height: 430px;
  gap: 5px;
  padding: 0 20px 20px;
  overflow-y: auto;
}

.language-option {
  display: grid;
  min-height: 50px;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  text-align: left;
}

.language-option-number {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  line-height: 1;
}

.language-option-name {
  min-width: 0;
  overflow-wrap: anywhere;
  font-weight: 650;
  line-height: 1.25;
  unicode-bidi: plaintext;
}

.language-option:hover,
.language-option.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.modal-copy {
  margin: 18px 24px 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.permanent-delete-content {
  display: grid;
  justify-items: center;
  gap: 16px;
  padding: 24px;
  text-align: center;
}

.destructive-sticker {
  display: inline-flex;
  width: 54px;
  height: 54px;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 92, 105, 0.28);
  border-radius: 50%;
  background: rgba(255, 92, 105, 0.12);
  color: #ff6876;
}

.destructive-sticker .lucide {
  width: 24px;
  height: 24px;
}

.permanent-delete-content p {
  max-width: 360px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.permanent-delete-content > div {
  display: flex;
  justify-content: center;
  gap: 9px;
  width: 100%;
}

.permanent-delete-content .outline-button,
.permanent-delete-content .danger-button {
  width: auto;
  min-height: 40px;
  padding: 0 16px;
}

@keyframes savebar-enter {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 920px) {
  .settings-savebar {
    left: 210px;
  }

  .bulk-action-button span {
    display: none;
  }

  .bulk-action-button {
    width: 34px;
    justify-content: center;
    padding: 0;
  }
}

@media (max-width: 760px) {
  .settings-savebar {
    left: 0;
  }
}

@media (max-width: 480px) {
  .thread-message {
    width: 100%;
    padding: 0;
  }

  .thread-message header {
    grid-template-columns: 34px minmax(0, 1fr);
  }

  .thread-message header time {
    grid-column: 2;
  }

  .thread-message-content {
    padding: 14px;
  }

  .image-preview-actions button {
    flex: 1;
  }

  .share-image-options {
    grid-template-columns: 1fr;
  }

  .reader-reply-bar .primary-button {
    width: 100%;
  }

  .compose-recipient-field {
    grid-template-columns: 1fr;
    gap: 2px;
    padding: 9px 12px 0;
  }

  .compose-recipient-field input {
    padding: 0;
  }

  .inline-input-action {
    grid-template-columns: 1fr;
  }

  .settings-savebar {
    align-items: stretch;
    flex-direction: column;
    padding: 10px 14px;
  }

  .settings-savebar > div {
    justify-content: flex-end;
  }

  .list-toolbar {
    gap: 5px;
  }

  .list-toolbar-primary > div,
  .bulk-actions > span {
    display: none;
  }

  .bulk-actions {
    gap: 2px;
  }

  .bulk-action-button {
    width: 34px;
    height: 34px;
    justify-content: center;
    padding: 0;
  }

  .bulk-action-button span {
    display: none;
  }

  .compose-primary-actions {
    min-width: 0;
  }

  .attachment-button {
    padding: 0 10px;
  }
}

/* Unified motion and subtle frames for every interactive control. */
button {
  border: 1px solid var(--button-frame);
  border-radius: var(--radius);
  transition:
    color 160ms ease,
    background-color 160ms ease,
    border-color 160ms ease,
    box-shadow 180ms ease,
    opacity 160ms ease,
    filter 160ms ease,
    transform 180ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

button:hover:not(:disabled) {
  filter: brightness(1.06);
  transform: translateY(-1px) scale(1.01);
}

button:active:not(:disabled) {
  filter: brightness(0.96);
  transform: translateY(0) scale(0.965);
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button .lucide,
a .lucide,
label .lucide {
  transition:
    color 160ms ease,
    stroke 160ms ease,
    transform 200ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

button:hover:not(:disabled) .lucide,
a:hover .lucide,
label:hover .lucide {
  transform: scale(1.12) rotate(-4deg);
}

input,
textarea,
select,
.address-input,
.color-control {
  transition:
    border-color 170ms ease,
    background-color 170ms ease,
    box-shadow 180ms ease,
    transform 180ms ease;
}

input:focus,
textarea:focus,
select:focus,
.address-input:focus-within {
  box-shadow: 0 0 0 3px var(--accent-soft);
  transform: translateY(-1px);
}

.auth-shell {
  animation: ui-pop-in 420ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.mail-header {
  animation: ui-slide-down 360ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.mail-content,
.reader:not([hidden]),
.empty-state:not([hidden]),
.settings-panel.active,
.language-list,
.device-list {
  animation: ui-fade-rise 300ms cubic-bezier(0.16, 1, 0.3, 1) backwards;
}

.thread-message,
.account-switch,
.device-item,
.share-image-options button,
.language-option,
.security-block,
.theme-preview,
.sound-toggle {
  animation: ui-item-in 260ms cubic-bezier(0.16, 1, 0.3, 1) backwards;
}

.thread-message:nth-child(2),
.share-image-options button:nth-child(2) {
  animation-delay: 35ms;
}

.thread-message:nth-child(3),
.share-image-options button:nth-child(3) {
  animation-delay: 70ms;
}

.thread-message:nth-child(4),
.share-image-options button:nth-child(4) {
  animation-delay: 105ms;
}

.thread-message:nth-child(n + 5),
.share-image-options button:nth-child(n + 5) {
  animation-delay: 135ms;
}

.message-row,
.thread-message,
.device-item,
.security-block,
.theme-preview,
.sound-toggle,
.thread-attachment img,
.image-preview-stage img,
.avatar-button img,
.large-avatar img,
.small-avatar img,
.sender-avatar img {
  transition:
    border-color 180ms ease,
    background-color 180ms ease,
    box-shadow 200ms ease,
    filter 180ms ease,
    transform 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.device-item:hover,
.security-block:hover,
.theme-preview:hover,
.sound-toggle:hover {
  transform: translateY(-2px);
}

.thread-message:hover,
.thread-attachment:hover img,
.image-preview-stage:hover img {
  transform: scale(1.008);
}

.avatar-button:hover img,
.large-avatar:hover img,
.small-avatar:hover img,
.sender-avatar:hover img,
.mail-brand:hover img,
.auth-brand:hover img {
  transform: scale(1.08) rotate(2deg);
}

.message-row .star-button,
.message-row .message-open {
  border: 0;
  outline: 0;
}

.message-row .star-button:hover,
.message-row .star-button:active,
.message-row .message-open:hover,
.message-row .message-open:active {
  filter: none;
  transform: none;
}

.mail-checkbox input:focus,
.mail-checkbox input:focus-visible {
  outline: 0;
  box-shadow: none;
  transform: none;
}

.mail-search input:focus,
.mail-search input:focus-visible,
.language-search input:focus,
.language-search input:focus-visible,
.address-input input:focus,
.address-input input:focus-visible,
.compose-recipient-field input:focus,
.compose-recipient-field input:focus-visible {
  outline: 0;
  box-shadow: none;
  transform: none;
}

.language-search {
  border-color: var(--line);
  border-radius: var(--radius);
  box-shadow: none;
  transition:
    border-color 170ms ease,
    background-color 170ms ease,
    box-shadow 180ms ease;
}

.language-search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.language-option {
  border-color: var(--line-soft);
}

.mail-checkbox span {
  transition:
    border-color 170ms ease,
    background-color 170ms ease,
    box-shadow 170ms ease,
    transform 170ms ease;
}

.mail-checkbox:hover span,
.mail-checkbox input:focus-visible + span {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  transform: scale(1.06);
}

.mail-brand img,
.auth-brand img,
.mail-brand span,
.auth-brand span {
  transition:
    color 260ms ease,
    filter 300ms ease,
    letter-spacing 300ms ease,
    text-shadow 300ms ease,
    transform 360ms cubic-bezier(0.16, 1, 0.3, 1);
}

.mail-brand:hover img,
.auth-brand:hover img {
  filter: drop-shadow(0 7px 12px var(--accent-soft));
  transform: translateY(-2px) scale(1.1) rotate(4deg);
}

.mail-brand:hover span,
.auth-brand:hover span {
  letter-spacing: 0.15px;
  text-shadow: 0 4px 16px var(--accent-soft);
  transform: translateX(2px);
}

.copy-success-sticker {
  animation: success-sticker-in 480ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.copy-success-content h2,
.copy-success-content .dialog-close {
  animation: ui-fade-rise 320ms 90ms cubic-bezier(0.16, 1, 0.3, 1) backwards;
}

.toast.visible {
  animation: toast-bounce-in 300ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes ui-pop-in {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.975);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes ui-slide-down {
  from {
    opacity: 0;
    transform: translateY(-12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes ui-slide-right {
  from {
    opacity: 0;
    transform: translateX(-14px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes ui-fade-rise {
  from {
    opacity: 0;
    transform: translateY(9px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes ui-item-in {
  from {
    opacity: 0;
    transform: translateY(7px) scale(0.992);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes success-sticker-in {
  0% {
    opacity: 0;
    transform: scale(0.45) rotate(-18deg);
  }
  68% {
    transform: scale(1.1) rotate(3deg);
  }
  100% {
    opacity: 1;
    transform: scale(1) rotate(0);
  }
}

@keyframes toast-bounce-in {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (max-width: 480px) {
  .toast {
    right: max(14px, env(safe-area-inset-right));
    bottom: max(14px, env(safe-area-inset-bottom));
    max-width: calc(100vw - 28px);
  }
}

@media (min-width: 761px) {
  .sidebar {
    animation: ui-slide-right 380ms 60ms cubic-bezier(0.16, 1, 0.3, 1) backwards;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 1ms !important;
    animation-delay: 0ms !important;
    transition-duration: 1ms !important;
  }
}
