:root {
  color-scheme: dark;
  --canvas: #0c0e12;
  --surface: #12151b;
  --surface-2: #171a21;
  --surface-3: #1d212a;
  --sidebar: #090b0e;
  --text: #f1f3f7;
  --text-2: #c5cad3;
  --muted: #858d9b;
  --border: #282d37;
  --border-strong: #383f4c;
  --accent: #4f7cff;
  --accent-hover: #638bff;
  --accent-soft: #192440;
  --accent-text: #ffffff;
  --danger: #ff6b78;
  --danger-soft: #30171c;
  --unread: #151c2a;
  --focus: rgba(79, 124, 255, 0.32);
  --overlay: rgba(0, 0, 0, 0.72);
  --radius: 11px;
  --radius-lg: 16px;
}

:root[data-theme="light"] {
  color-scheme: light;
  --canvas: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --surface-3: #eceff3;
  --sidebar: #151922;
  --text: #171a21;
  --text-2: #3e4551;
  --muted: #707887;
  --border: #dfe3e8;
  --border-strong: #cbd1d9;
  --accent: #315fdd;
  --accent-hover: #254fc3;
  --accent-soft: #e9efff;
  --accent-text: #ffffff;
  --danger: #c93445;
  --danger-soft: #fff0f2;
  --unread: #f2f6ff;
  --focus: rgba(49, 95, 221, 0.22);
  --overlay: rgba(12, 15, 21, 0.62);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background: var(--canvas);
  color: var(--text);
  font-family: "Nunito", "Trebuchet MS", ui-rounded, system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: var(--accent);
  color: #fff;
}

button,
input,
textarea {
  font: inherit;
}

button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 650;
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

button:hover:not(:disabled) {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

button:active:not(:disabled) {
  transform: translateY(0) scale(0.98);
}

button:disabled {
  opacity: 0.55;
  cursor: wait;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

input,
textarea {
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--canvas);
  color: var(--text);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

input {
  min-height: 44px;
}

textarea {
  min-height: 190px;
  line-height: 1.6;
  resize: vertical;
}

input::placeholder,
textarea::placeholder {
  color: var(--muted);
  opacity: 0.72;
}

input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus);
  outline: none;
}

label {
  display: block;
  margin-bottom: 16px;
  color: var(--text-2);
  font-size: 0.875rem;
  font-weight: 620;
}

a {
  color: var(--accent);
  text-underline-offset: 3px;
}

svg,
img {
  display: block;
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--muted);
  font-size: 0.875rem;
}

.error {
  margin: 12px 0 0;
  padding: 10px 12px;
  border: 1px solid #63303a;
  border-radius: var(--radius);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 0.875rem;
}

.eyebrow,
.section-label,
.account-label {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  line-height: 1.2;
  text-transform: uppercase;
}

.icon {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-button,
.theme-toggle {
  width: 38px;
  height: 38px;
  min-height: 38px;
  padding: 0;
  border-color: var(--border);
  background: transparent;
  color: var(--muted);
}

.icon-button:hover:not(:disabled),
.theme-toggle:hover:not(:disabled) {
  border-color: var(--border-strong);
  background: var(--surface-3);
  color: var(--text);
}

#refresh-btn .refresh-icon {
  width: 19px;
  height: 19px;
  stroke-width: 1.9;
  transform-origin: center;
}

#refresh-btn:hover:not(:disabled) .refresh-icon {
  transform: rotate(24deg);
  transition: transform 180ms ease;
}

#refresh-btn.is-refreshing .refresh-icon {
  animation: refresh-spin 700ms linear infinite;
}

.icon-moon,
:root[data-theme="light"] .icon-sun {
  display: none;
}

:root[data-theme="light"] .icon-moon {
  display: block;
}

.brand,
.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-size: 0.94rem;
  font-weight: 700;
  letter-spacing: -0.015em;
}

.brand {
  color: #f4f6fa;
}

.brand-mark {
  display: block;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  overflow: hidden;
  border-radius: 9px;
}

.brand-mark img {
  width: 100%;
  height: 100%;
}

/* Authentication screens */

.login {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 32px 20px;
  background: var(--canvas);
}

.login-shell {
  width: min(100%, 420px);
}

.login-card {
  position: relative;
  width: min(100%, 440px);
  margin: auto;
  padding: 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
  animation: rise-in 420ms cubic-bezier(.2,.75,.25,1) both;
}

.auth-brand {
  margin-bottom: 42px;
}

.login-theme {
  position: absolute;
  top: 25px;
  right: 25px;
}

.form-heading {
  margin-bottom: 28px;
}

.form-heading h1,
.form-heading h2 {
  margin: 4px 0 7px;
  color: var(--text);
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.25;
}

.form-heading p {
  margin: 0;
  line-height: 1.55;
}

.login-card > button[type="submit"] {
  width: 100%;
  min-height: 44px;
  margin-top: 2px;
}

.signup-link-wrap {
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
  text-align: center;
}

.signup-link-wrap a {
  font-weight: 650;
  text-decoration: none;
}

.signup-link-wrap a:hover {
  text-decoration: underline;
}

.gate-card {
  max-width: 420px;
}

.signup-card {
  max-width: 480px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
}

.signup-card .auth-brand {
  margin-bottom: 32px;
}

.signup-card > .muted:last-child {
  margin: 18px 0 0;
  text-align: center;
}

.addr-inline {
  display: flex;
  align-items: center;
  margin-top: 6px;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--canvas);
}

.addr-inline:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus);
}

.addr-inline input {
  min-width: 80px;
  margin: 0;
  border: 0;
  box-shadow: none;
}

.addr-inline input:focus {
  box-shadow: none;
}

/* Mail application */

.app {
  display: grid;
  grid-template-columns: 248px minmax(340px, 400px) minmax(420px, 1fr);
  width: 100vw;
  height: 100vh;
  min-height: 0;
  overflow: hidden;
  background: var(--canvas);
}

.sidebar {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 18px;
  padding: 18px 16px 14px;
  background: var(--sidebar);
  color: #f4f6fa;
  animation: panel-left 360ms cubic-bezier(.2,.75,.25,1) both;
}

.sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 3px;
}

.sidebar .theme-toggle,
.sidebar .icon-button {
  border-color: #252a33;
  color: #929aaa;
}

.sidebar .theme-toggle:hover:not(:disabled),
.sidebar .icon-button:hover:not(:disabled) {
  background: #1a1e26;
  color: #fff;
}

.compose {
  width: 100%;
  border-color: #5b84ff;
  background: var(--accent);
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(79, 124, 255, 0.2);
}

.compose:hover:not(:disabled) {
  background: var(--accent-hover);
}

.sidebar-section {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
}

.section-label {
  margin: 4px 10px 9px;
  color: #6f7888;
}

.folders {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.folders button,
.secondary {
  justify-content: flex-start;
  width: 100%;
  min-height: 38px;
  padding: 7px 10px;
  border-color: transparent;
  background: transparent;
  color: #969eac;
  font-size: 0.875rem;
  font-weight: 560;
  text-align: left;
  transition: transform 150ms ease, background 150ms ease, color 150ms ease;
}

.folders button {
  justify-content: space-between;
}

.folders button:hover:not(:disabled),
.secondary:hover:not(:disabled) {
  background: #171b22;
  color: #f5f6f8;
  transform: translateX(3px);
}

.folders button.active {
  background: #1e2532;
  color: #ffffff;
}

.folder-count {
  min-width: 20px;
  color: #829be5;
  font-size: 0.72rem;
  font-weight: 700;
  text-align: right;
}

.sidebar-actions {
  padding-top: 10px;
  border-top: 1px solid #22262e;
}

.sidebar-foot {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 32px 32px;
  align-items: center;
  gap: 6px;
  padding: 12px 0 0;
  border-top: 1px solid #22262e;
}

.account-switch {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) 16px;
  min-width: 0;
  min-height: 44px;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-color: transparent;
  background: transparent;
  color: #dfe3ea;
  text-align: left;
}

.account-switch:hover:not(:disabled) {
  border-color: #252a33;
  background: #171b22;
}

.account-switch > .icon {
  width: 15px;
  color: #70798a;
}

.avatar {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 7px;
  background: #1e2532;
}

.avatar::after {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  content: "";
}

.account-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
  text-align: left;
}

.account-label {
  color: #6f7888;
  font-size: 0.58rem;
}

#who {
  overflow: hidden;
  color: #dfe3ea;
  font-size: 0.74rem;
  font-weight: 600;
  line-height: 1.5;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-foot .icon-button {
  width: 32px;
  height: 32px;
  min-height: 32px;
}

.sidebar-foot .icon-button .icon {
  width: 16px;
  height: 16px;
}

.list-pane,
.read-pane {
  min-width: 0;
  min-height: 0;
  background: var(--surface);
}

.list-pane {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  animation: panel-in 360ms 55ms cubic-bezier(.2,.75,.25,1) both;
}

.list-head {
  display: flex;
  min-height: 76px;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 15px 17px;
  border-bottom: 1px solid var(--border);
}

.list-head h1 {
  margin: 0;
  font-size: 1.22rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.15;
}

.list-head .eyebrow,
.modal-heading .eyebrow {
  display: none;
}

.list-head-right {
  display: flex;
  align-items: center;
  gap: 7px;
}

.status-pill {
  max-width: 120px;
  overflow: hidden;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-form {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) 30px;
  align-items: center;
  gap: 7px;
  margin: 10px 14px;
  padding: 0 6px 0 11px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--canvas);
  color: var(--muted);
}

.search-form:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus);
}

.search-form input {
  min-height: 39px;
  margin: 0;
  padding: 6px 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  font-size: 0.84rem;
}

.search-form input:focus {
  box-shadow: none;
}

.search-form input::-webkit-search-cancel-button {
  display: none;
}

.search-clear {
  width: 28px;
  height: 28px;
  min-height: 28px;
  padding: 0;
  background: transparent;
  color: var(--muted);
}

.search-clear:hover:not(:disabled) {
  background: var(--surface-3);
  color: var(--text);
}

.search-clear .icon {
  width: 15px;
  height: 15px;
}

.list {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: var(--border-strong) transparent;
  scrollbar-width: thin;
}

.item {
  position: relative;
  padding: 14px 17px 15px;
  border-top: 1px solid var(--border);
  cursor: pointer;
  transition: transform 150ms ease, background 150ms ease, box-shadow 150ms ease;
}

.item:first-child {
  border-top: 0;
}

.item:hover {
  background: var(--surface-2);
  transform: translateX(3px);
}

.item.active {
  background: var(--accent-soft);
  box-shadow: inset 3px 0 0 var(--accent);
}

.item.unread {
  background: var(--unread);
}

.item.unread.active {
  background: var(--accent-soft);
}

.item-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.item-from {
  overflow: hidden;
  color: var(--text-2);
  font-size: 0.82rem;
  font-weight: 580;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-date {
  flex-shrink: 0;
  color: var(--muted);
  font-size: 0.72rem;
}

.item-subject {
  margin-top: 4px;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.9rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-snippet {
  margin-top: 3px;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.77rem;
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item.unread .item-from,
.item.unread .item-subject {
  color: var(--text);
  font-weight: 700;
}

.item.unread::after {
  position: absolute;
  top: 19px;
  right: 8px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  content: "";
}

.more {
  width: calc(100% - 28px);
  margin: 10px 14px;
  border-color: var(--border);
  background: var(--surface-2);
  color: var(--text-2);
}

.more:hover:not(:disabled) {
  background: var(--surface-3);
}

.read-pane {
  overflow-y: auto;
  background: var(--canvas);
  scrollbar-color: var(--border-strong) transparent;
  scrollbar-width: thin;
  animation: panel-in 360ms 110ms cubic-bezier(.2,.75,.25,1) both;
}

.reader {
  width: min(100%, 980px);
  min-height: 100%;
  margin: 0 auto;
  padding: clamp(28px, 4.5vw, 58px);
}

.reader.empty {
  display: grid;
  width: 100%;
  place-items: center;
}

.empty-state {
  max-width: 290px;
  text-align: center;
}

.empty-icon {
  display: grid;
  width: 46px;
  height: 46px;
  margin: 0 auto 15px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  color: var(--muted);
  animation: gentle-float 4s ease-in-out infinite;
}

.empty-icon svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.empty-state h2 {
  margin: 0 0 5px;
  font-size: 1.05rem;
  font-weight: 800;
}

.empty-state p {
  margin: 0;
}

.message-card {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: 0 22px 55px rgba(0, 0, 0, 0.16);
  animation: message-in 260ms cubic-bezier(.2,.75,.25,1) both;
}

.message-header {
  padding: clamp(22px, 3.4vw, 34px) clamp(20px, 4vw, 38px) 0;
}

.message-header h2 {
  max-width: 780px;
  margin: 0 0 24px;
  font-size: clamp(1.45rem, 3vw, 2rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.22;
  overflow-wrap: anywhere;
}

.meta {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  color: var(--muted);
  font-size: 0.82rem;
  overflow-wrap: anywhere;
}

.sender-avatar {
  position: relative;
  display: grid;
  width: 42px;
  height: 42px;
  overflow: hidden;
  place-items: center;
  border-radius: 13px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 1rem;
  font-weight: 850;
}

.sender-avatar img {
  position: absolute;
  inset: 0;
  display: none;
  width: 26px;
  height: 26px;
  margin: auto;
  object-fit: contain;
}

.sender-avatar.has-image {
  background: #fff;
  color: transparent;
  font-size: 0;
}

.sender-avatar.has-image img {
  display: block;
}

.sender-copy {
  display: grid;
  min-width: 0;
  line-height: 1.28;
}

.sender-copy strong {
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 750;
}

.sender-copy span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recipient-line {
  margin-top: 3px;
}

.message-date {
  align-self: start;
  padding-top: 2px;
  white-space: nowrap;
}

.reader-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 20px clamp(20px, 4vw, 38px) 0;
  padding: 16px 0;
  border-top: 1px solid var(--border);
}

.link,
.text-button {
  min-height: 34px;
  padding: 5px 9px;
  border-color: var(--border);
  background: transparent;
  color: var(--text-2);
  font-size: 0.8rem;
  font-weight: 600;
}

.link:hover:not(:disabled),
.text-button:hover:not(:disabled) {
  background: var(--surface-3);
  color: var(--text);
}

.reader-actions .link:last-child {
  margin-left: auto;
  color: var(--danger);
}

.message-content {
  margin: 0 clamp(12px, 2vw, 20px) clamp(12px, 2vw, 20px);
  border: 1px solid var(--border);
  border-radius: 14px;
}

.message-content.html-message {
  overflow: hidden;
  padding: clamp(14px, 2.5vw, 22px);
  border-color: rgba(255, 255, 255, 0.12);
  background: #fff;
}

.message-content.plain-message {
  padding: clamp(20px, 3vw, 30px);
  background: var(--surface-2);
}

.body-text {
  color: var(--text-2);
  font-size: 1rem;
  line-height: 1.75;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.body-frame {
  display: block;
  width: 100%;
  min-height: 220px;
  border: 0;
  background: #fff;
}

.attachments {
  margin: 0 clamp(20px, 4vw, 38px);
  padding: 4px 0 24px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.82rem;
}

.attachment-link {
  display: inline-flex;
  margin: 9px 7px 0 0;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-2);
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
}

.attachment-link:hover {
  border-color: var(--border-strong);
  color: var(--accent);
}

/* Dialogs */

.modal {
  position: fixed;
  z-index: 20;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: var(--overlay);
  backdrop-filter: blur(5px);
  animation: fade-in 160ms ease both;
}

.modal-card {
  width: min(100%, 580px);
  max-height: min(90vh, 800px);
  overflow-y: auto;
  padding: 24px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.34);
  animation: rise-in 230ms cubic-bezier(.2,.75,.25,1) both;
}

.compose-card {
  width: min(100%, 640px);
}

.modal-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.modal-heading h2 {
  margin: 0;
  font-size: 1.28rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.modal-actions {
  display: flex;
  min-height: 42px;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 6px;
}

.modal-actions p {
  margin: 0;
}

#c-send {
  flex: 0 0 auto;
}

.addr-form {
  display: flex;
  align-items: stretch;
  gap: 9px;
  margin: 20px 0 9px;
}

.address-input {
  display: flex;
  min-width: 0;
  flex: 1;
  align-items: center;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--canvas);
}

.address-input:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus);
}

.address-input input {
  min-width: 80px;
  margin: 0;
  border: 0;
  box-shadow: none;
}

.address-input input:focus {
  box-shadow: none;
}

.addr-domain {
  padding-right: 12px;
  color: var(--muted);
  font-size: 0.84rem;
  white-space: nowrap;
}

.addr-list {
  max-height: 42vh;
  margin-top: 16px;
  overflow-y: auto;
}

.addr-row {
  display: flex;
  min-height: 50px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 2px;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
}

.addr-name {
  overflow: hidden;
  color: var(--text-2);
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.addr-tag {
  flex-shrink: 0;
  padding: 2px 7px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.67rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.addr-note {
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.6;
}

.accounts-actions {
  justify-content: flex-start;
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.toast-region {
  position: fixed;
  z-index: 100;
  top: 18px;
  right: 18px;
  display: flex;
  width: min(360px, calc(100vw - 36px));
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  min-height: 50px;
  align-items: center;
  gap: 11px;
  padding: 12px 15px;
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  background: var(--surface-2);
  color: var(--text);
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.34);
  font-size: 0.9rem;
  font-weight: 700;
  animation: toast-in 260ms cubic-bezier(.2,.8,.25,1) both;
}

.toast.leaving {
  animation: toast-out 220ms ease both;
}

.toast-dot {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(79, 124, 255, 0.14);
}

.toast.success .toast-dot {
  background: #45c991;
  box-shadow: 0 0 0 4px rgba(69, 201, 145, 0.14);
}

.toast.new-mail .toast-dot {
  animation: toast-pulse 1.4s ease-in-out infinite;
}

.app,
.sidebar,
.list-pane,
.read-pane,
.modal-card,
.login-card,
input,
textarea {
  transition: background-color 220ms ease, border-color 220ms ease, color 220ms ease;
}

@keyframes panel-left {
  from { opacity: 0; transform: translateX(-12px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes panel-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes rise-in {
  from { opacity: 0; transform: translateY(14px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes gentle-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

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

@keyframes toast-out {
  to { opacity: 0; transform: translateX(18px) scale(0.98); }
}

@keyframes toast-pulse {
  50% { transform: scale(1.2); box-shadow: 0 0 0 6px rgba(79, 124, 255, 0.08); }
}

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

@keyframes refresh-spin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  #refresh-btn.is-refreshing .refresh-icon {
    animation: none;
  }
}

@media (max-width: 1020px) {
  .app {
    grid-template-columns: 220px minmax(300px, 350px) minmax(350px, 1fr);
  }

  .reader {
    padding: 32px;
  }
}

@media (max-width: 820px) {
  body {
    overflow: auto;
  }

  .app {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(380px, 52vh) minmax(420px, auto);
    width: 100%;
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 9px;
    padding: 11px 13px;
  }

  .sidebar-top {
    padding: 0;
  }

  .sidebar-top .theme-toggle {
    display: none;
  }

  .compose {
    width: 40px;
    padding: 0;
  }

  .compose span {
    display: none;
  }

  .sidebar-section {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .section-label {
    display: none;
  }

  .folders {
    flex-direction: row;
    gap: 4px;
    overflow-x: auto;
  }

  .folders button {
    width: auto;
    flex: 0 0 auto;
    gap: 8px;
  }

  .sidebar-actions {
    padding: 0;
    border: 0;
  }

  .secondary {
    width: 40px;
    padding: 0;
    justify-content: center;
  }

  .secondary span,
  .sidebar-foot {
    display: none;
  }

  .list-pane {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .read-pane,
  .reader {
    min-height: 420px;
  }
}

@media (max-width: 540px) {
  .login {
    align-items: start;
    padding: 0;
    background: var(--surface);
  }

  .login-shell {
    width: 100%;
  }

  .login-card,
  .gate-card,
  .signup-card {
    width: 100%;
    max-width: none;
    min-height: 100vh;
    max-height: none;
    padding: 28px 22px;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .auth-brand {
    margin-bottom: 48px;
  }

  .brand > span:last-child {
    display: none;
  }

  .list-head {
    min-height: 70px;
  }

  .reader {
    padding: 26px 19px;
  }

  .message-card {
    border-radius: 16px;
  }

  .meta {
    grid-template-columns: 38px minmax(0, 1fr);
  }

  .sender-avatar {
    width: 38px;
    height: 38px;
    border-radius: 12px;
  }

  .message-date {
    grid-column: 2;
    padding: 0;
  }

  .modal {
    align-items: end;
    padding: 0;
  }

  .toast-region {
    top: 12px;
    right: 12px;
    width: calc(100vw - 24px);
  }

  .modal-card,
  .compose-card {
    width: 100%;
    max-height: 94vh;
    padding: 21px 18px calc(21px + env(safe-area-inset-bottom));
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 12px 12px 0 0;
  }

  .addr-form,
  .modal-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .addr-form button,
  #c-send {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

/* Copy-address feedback */
.icon-button.copied { color: var(--accent); }

/* Height is set from the content once it loads; block removes the inline gap. */
.body-frame { display: block; }
