/* ═══════════════════════════════════════════════════
   Aethink Mail — Floating Minimal UI (Sunlit Teal)
   Palette: #F8F1BD, #FFFFF8, #176A60, #F9DB46, #8ADCD4, #96BDFB, #233C36
   ═══════════════════════════════════════════════════ */

:root {
  color-scheme: light;
  --background: #f8f1bd;
  --page: #f8f1bd;
  --surface: #fffff8;
  --surface-pure: #fffffa;
  --text-primary: #233c36;
  --text: #233c36;
  --muted: #4c6861;
  --primary: #176a60;
  --primary-hover: #11534b;
  --action: #125850;
  --color-pop: #f9db46;
  --accent-1: #8adcd4;
  --accent-2: #96bdfb;
  --accent-soft: #d9f3ef;
  --accent-soft-hover: #c3ebe5;
  --line: #e5e8dc;
  --shadow-floating: 0 20px 48px #176a6026;
  --success: #145c46;
  --success-bg: #d4f3ea;
  --warn: #7c5206;
  --warn-bg: #fce996;
  --error: #b42318;
  --error-bg: #fef2f2;
  --error-border: #fecaca;

  --radius-panel: 26px;
  --radius-control: 12px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);

  --shadow-panel:
    0 2px 8px rgba(23, 106, 96, 0.05),
    0 20px 48px #176a6026;
  --shadow-pill:
    0 3px 10px rgba(23, 106, 96, 0.06),
    0 18px 40px -6px #176a6026;
  --shadow-control:
    0 2px 6px rgba(23, 106, 96, 0.08),
    0 1px 2px rgba(23, 106, 96, 0.04);
  --shadow-dialog:
    0 8px 24px rgba(23, 106, 96, 0.12),
    0 28px 60px -12px rgba(23, 106, 96, 0.24);
  --surface-border: rgba(255, 255, 255, 0.92);
  --input-bg: #ffffff;
  --hover-tint: #e9f2ec;
  --row-hover: #f0f6f2;
  --subtle-bg: #eef5f0;
  --btn-primary-text: #ffffff;
  --inbox-head-bg: rgba(255, 255, 248, 0.96);
  --inbox-btn-ink: #344d41;
  --inbox-btn-icon: #466355;
  --mobile-tool-bg: #eef7f4;
  --skeleton-a: #e7efe9;
  --skeleton-b: #f4f8f5;
  --backdrop: rgba(35, 55, 46, 0.3);
  --soft-inset: inset 0 1px 0 rgba(255, 255, 255, 0.7);
  --toast-bg: #1e332e;
  --toast-text: #fffff8;
  --toast-border: rgba(23, 106, 96, 0.2);
  --toast-success-bg: #176a60;
  --toast-success-text: #ffffff;
  --toast-error-bg: #b42318;
  --toast-error-text: #ffffff;
}

[data-theme="dark"] {
  color-scheme: dark;
  --background: #111d30;
  --page: #111d30;
  --surface: #1c2c42;
  --surface-pure: #223550;
  --text-primary: #edf4ff;
  --text: #edf4ff;
  --muted: #9eb3cf;
  --primary: #72ddd0;
  --primary-hover: #8adcd4;
  --action: #8adcd4;
  --color-pop: #f9db46;
  --accent-1: #8adcd4;
  --accent-2: #96bdfb;
  --accent-soft: rgba(114, 221, 208, 0.14);
  --accent-soft-hover: rgba(114, 221, 208, 0.24);
  --line: rgba(150, 189, 251, 0.14);
  --shadow-floating: 0 20px 48px #00000059;
  --success: #72ddd0;
  --success-bg: rgba(114, 221, 208, 0.16);
  --warn: #f9db46;
  --warn-bg: rgba(249, 219, 70, 0.16);
  --error: #fda4af;
  --error-bg: rgba(225, 29, 72, 0.16);
  --error-border: rgba(251, 113, 133, 0.32);

  --shadow-panel:
    0 2px 10px rgba(0, 0, 0, 0.2),
    0 20px 48px #00000059;
  --shadow-pill:
    0 4px 12px rgba(0, 0, 0, 0.24),
    0 20px 48px #00000059;
  --shadow-control:
    0 3px 10px rgba(0, 0, 0, 0.26);
  --shadow-dialog:
    0 12px 32px rgba(0, 0, 0, 0.42),
    0 24px 60px #00000073;
  --surface-border: rgba(237, 244, 255, 0.08);
  --input-bg: #152338;
  --hover-tint: rgba(150, 189, 251, 0.1);
  --row-hover: rgba(150, 189, 251, 0.07);
  --subtle-bg: #16253a;
  --btn-primary-text: #0f1e2e;
  --inbox-head-bg: rgba(28, 44, 66, 0.96);
  --inbox-btn-ink: #d5e3f7;
  --inbox-btn-icon: #9eb3cf;
  --mobile-tool-bg: rgba(150, 189, 251, 0.09);
  --skeleton-a: #243854;
  --skeleton-b: #2c4363;
  --backdrop: rgba(6, 12, 24, 0.68);
  --soft-inset: inset 0 1px 0 rgba(138, 220, 212, 0.14);
  --toast-bg: #263b58;
  --toast-text: #edf4ff;
  --toast-border: rgba(150, 189, 251, 0.25);
  --toast-success-bg: #155c54;
  --toast-success-text: #edf4ff;
  --toast-error-bg: #9f1239;
  --toast-error-text: #ffe4e6;
}

html[data-theme="dark"],
html[data-theme="dark"] body {
  background:
    radial-gradient(ellipse at 12% 10%, rgba(114, 221, 208, 0.1) 0%, transparent 54%),
    radial-gradient(ellipse at 88% 82%, rgba(150, 189, 251, 0.1) 0%, transparent 56%),
    var(--page);
  background-attachment: fixed;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-width: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background:
    radial-gradient(ellipse at 12% 10%, rgba(138, 220, 212, 0.32) 0%, transparent 56%),
    radial-gradient(ellipse at 88% 82%, rgba(150, 189, 251, 0.28) 0%, transparent 58%),
    var(--page);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.mono {
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

button,
select,
input {
  font: inherit;
}

:where(button, a, select, input, summary):focus-visible {
  outline: 2px solid var(--action);
  outline-offset: 3px;
}

/* ─── App Shell & Header ─── */
.app-shell {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.site-header {
  width: min(100% - 48px, 1180px);
  margin: 24px auto 0;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--text);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.025em;
  text-decoration: none;
}

.brand-logo {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: block;
  flex-shrink: 0;
  box-shadow:
    0 2px 6px rgba(45, 76, 59, 0.08),
    0 8px 18px -4px rgba(87, 124, 102, 0.26);
}

.brand-accent {
  color: var(--primary);
  font-weight: 600;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
}

/* ─── Buttons (Tactile Controls) ─── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  background: transparent;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition:
    transform 180ms var(--ease),
    background-color 180ms var(--ease),
    box-shadow 180ms var(--ease),
    color 180ms var(--ease),
    border-color 180ms var(--ease);
  -webkit-tap-highlight-color: transparent;
}

.btn svg {
  width: 17px;
  height: 17px;
  flex: none;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.btn--icon {
  width: 44px;
  min-height: 44px;
  padding: 0;
  border-radius: 12px;
}

.btn--soft {
  background: var(--accent-soft);
  color: var(--action);
  box-shadow: var(--soft-inset);
}

.btn--raised {
  background: var(--surface-pure);
  border-color: var(--line);
  box-shadow: var(--shadow-control);
  border-radius: 999px;
  padding: 8px 14px;
}

.btn--header-icon {
  width: 40px;
  min-height: 40px;
  padding: 0;
  border-radius: 999px;
}

/* Distinct slightly larger icon-only Sign Out pill so it's never confused with Sound/Theme */
.btn--signout {
  width: 48px;
  min-height: 42px;
  padding: 0;
  border-radius: 14px;
  color: var(--error);
  border-color: var(--error-border);
}

.btn--signout svg {
  width: 18px;
  height: 18px;
}

.btn--primary {
  background: var(--primary);
  color: var(--btn-primary-text);
  font-weight: 600;
  box-shadow: 0 4px 14px -2px rgba(23, 106, 96, 0.34);
}

.btn--ghost-border {
  background: var(--surface-pure);
  border-color: var(--line);
  color: var(--text);
}

@media (hover: hover) and (pointer: fine) {
  .btn:not(:disabled):hover {
    transform: translateY(-1px);
    background-color: var(--hover-tint);
  }
  .btn--raised:not(:disabled):hover {
    background-color: var(--surface-pure);
    box-shadow: 0 6px 16px rgba(23, 106, 96, 0.14);
  }
  .btn--signout:not(:disabled):hover {
    background-color: var(--error-bg);
    border-color: var(--error-border);
  }
  .btn--primary:not(:disabled):hover {
    background-color: var(--primary-hover);
  }
  .btn--soft:not(:disabled):hover {
    background-color: var(--accent-soft-hover);
  }
  .btn--ghost-border:not(:disabled):hover {
    background-color: var(--hover-tint);
  }
}

.btn:not(:disabled):active {
  transform: translateY(1px) scale(0.97);
  box-shadow: none;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn[data-copied="true"],
.btn--soft[data-copied="true"] {
  color: var(--success);
  background: var(--success-bg);
}

/* ─── Floating Surface Base ─── */
.floating-surface {
  background: var(--surface);
  border: 1px solid var(--surface-border);
  box-shadow: var(--shadow-panel);
}

/* ─── Main Container & Compact Hero ─── */
.main-content {
  width: min(100% - 48px, 900px);
  margin: 42px auto 0;
  padding-bottom: 56px;
  flex: 1;
}

.hero {
  text-align: center;
}

.hero h1 {
  margin: 0;
  font-size: clamp(28px, 3.4vw, 40px);
  line-height: 1.18;
  font-weight: 700;
  letter-spacing: -0.035em;
  color: var(--text);
}

.hero-accent {
  color: var(--primary);
}

.hero p {
  margin: 10px auto 0;
  max-width: 580px;
  color: var(--muted);
  font-size: 15px;
}

/* ═══════════════════════════════════════════════════
   TOKEN ACCESS GATE (Floating Minimal)
   ═══════════════════════════════════════════════════ */

.gate-card {
  width: min(100%, 460px);
  margin: 28px auto 0;
  padding: 28px;
  border-radius: var(--radius-panel);
}

.gate-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
}

.text-input,
.select-input {
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  border-radius: var(--radius-control);
  border: 1px solid var(--line);
  background: var(--input-bg);
  color: var(--text);
  font-size: 14.5px;
  transition: border-color 160ms var(--ease), box-shadow 160ms var(--ease);
}

.text-input:focus,
.select-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(70, 124, 99, 0.16);
  outline: none;
}

.token-input {
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-align: center;
  text-transform: uppercase;
  min-height: 48px;
}

.alert-error {
  padding: 10px 14px;
  border-radius: var(--radius-control);
  background: var(--error-bg);
  border: 1px solid var(--error-border);
  color: var(--error);
  font-size: 13.5px;
  font-weight: 500;
}

.gate-note {
  margin: 14px 0 0;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}

/* ═══════════════════════════════════════════════════
   FLOATING EMAIL PILL BAR
   ═══════════════════════════════════════════════════ */

.email-bar {
  width: min(100%, 700px);
  min-height: 68px;
  margin: 28px auto 0;
  padding: 10px 14px 10px 18px;
  border-radius: 999px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-pill);
}

.email-lead-icon {
  width: 38px;
  height: 38px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--action);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  pointer-events: none;
}

.email-lead-icon svg {
  width: 19px;
  height: 19px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.email-address {
  min-width: 0;
  padding-inline: 12px;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
  overflow-wrap: anywhere;
  user-select: all;
  transition: opacity 180ms var(--ease);
}

.email-address[data-switching="true"] {
  opacity: 0.35;
}

.copy-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.copy-tooltip {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: var(--toast-bg);
  color: var(--toast-text);
  border: 1px solid var(--toast-border);
  font-size: 12px;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: 8px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms var(--ease), transform 160ms var(--ease);
}

.copy-tooltip[data-visible="true"] {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.expiry {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 14px;
  border-radius: 999px;
  background: var(--color-pop);
  color: #162724;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.expiry svg {
  width: 15px;
  height: 15px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.85;
  flex-shrink: 0;
}

.expiry[data-urgent="true"] {
  background: var(--warn-bg);
  color: var(--warn);
}

.expiry[data-critical="true"] {
  background: var(--error-bg);
  color: var(--error);
}

/* Header History Dropdown Popover */
.header-dropdown {
  position: relative;
}

.history-count-dot {
  font-size: 12px;
  font-weight: 600;
  color: var(--action);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 1px 7px;
  font-variant-numeric: tabular-nums;
}

#historyTrigger[aria-expanded="true"] .domain-chevron {
  transform: rotate(180deg);
}

.header-popover {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 280px;
  max-width: calc(100vw - 32px);
  padding: 8px;
  border-radius: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-dialog);
  z-index: 40;
  transform-origin: top right;
  animation: dropdown-open 170ms var(--ease) both;
}

.header-popover-title {
  padding: 6px 10px 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  margin-bottom: 6px;
}

.header-popover-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 260px;
  overflow-y: auto;
}

.history-item-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  min-height: 38px;
  padding: 7px 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background-color 140ms var(--ease), color 140ms var(--ease);
}

.history-item-btn span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-item-btn:hover {
  background: var(--hover-tint);
}

.history-item-btn[aria-current="true"] {
  background: var(--accent-soft);
  color: var(--action);
  font-weight: 600;
}

.history-item-btn svg {
  width: 15px;
  height: 15px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

.history-empty-note {
  padding: 14px 10px;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}

/* ═══════════════════════════════════════════════════
   FLOATING INBOX PANEL
   ═══════════════════════════════════════════════════ */

.inbox {
  margin-top: 28px;
  min-height: 360px;
  border-radius: var(--radius-panel);
  overflow: hidden;
}

.inbox-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 24px;
  min-height: 64px;
  border-bottom: 1px solid var(--line);
  background: var(--inbox-head-bg);
}

.inbox-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.inbox-title-icon {
  width: 20px;
  height: 20px;
  color: var(--text);
  stroke: currentColor;
  fill: none;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.inbox-title h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.message-count {
  font-size: 13px;
  font-weight: 600;
  color: var(--action);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 2px 9px;
  font-variant-numeric: tabular-nums;
}

.inbox-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-wrap: wrap;
}

.inbox-divider {
  width: 1px;
  height: 18px;
  background: var(--line);
  margin: 0 6px;
}

.inbox-actions .btn {
  min-height: 36px;
  padding: 6px 10px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--inbox-btn-ink);
  background: transparent;
  border-color: transparent;
  gap: 6px;
}

.inbox-actions .btn svg {
  width: 16px;
  height: 16px;
  color: var(--inbox-btn-icon);
}

.inbox-actions .btn:hover:not(:disabled) {
  color: var(--text);
}

.inbox-actions .btn:hover:not(:disabled) svg {
  color: var(--text);
}

/* Empty State */
.empty-state {
  min-height: 300px;
  padding: 40px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.empty-envelope {
  width: 96px;
  height: 96px;
  margin-bottom: 14px;
}

.empty-state h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 650;
  color: var(--text);
  letter-spacing: -0.015em;
}

.empty-state p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
  max-width: 360px;
}

.connection {
  margin-top: 14px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--muted);
}

.connection-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #2f9e66;
}

.connection-dot[data-paused="true"] {
  background: #94a3b8;
}

/* Error State inside Inbox */
.inbox-error {
  min-height: 260px;
  padding: 36px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 10px;
}

.inbox-error h3 {
  margin: 0;
  font-size: 17px;
  color: var(--error);
}

.inbox-error p {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
  max-width: 380px;
}

/* Loading Skeleton */
.skeleton-list {
  padding: 20px 24px;
  display: grid;
  gap: 16px;
}

.skeleton-row {
  display: grid;
  gap: 8px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.skeleton {
  border-radius: 8px;
  height: 14px;
  background: linear-gradient(90deg, var(--skeleton-a) 25%, var(--skeleton-b) 50%, var(--skeleton-a) 75%);
  background-size: 200% 100%;
  animation: shimmer 1200ms linear infinite;
}

/* Message List */
.message-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.message-row {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px 16px;
  padding: 16px 24px;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  text-align: left;
  color: var(--text);
  cursor: pointer;
  transition: background-color 140ms var(--ease);
}

.message-list li:last-child .message-row {
  border-bottom: 0;
}

.message-row:hover {
  background: var(--row-hover);
}

.message-row-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.message-row .sender {
  font-size: 14.5px;
  font-weight: 650;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-row .subject {
  font-size: 14px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.message-row-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  flex-shrink: 0;
}

.message-row time {
  color: var(--muted);
  font-size: 12.5px;
  white-space: nowrap;
}

.otp-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--success-bg);
  color: var(--success);
  font-size: 12px;
  font-weight: 700;
  font-family: "JetBrains Mono", ui-monospace, monospace;
}

/* Message Detail View */
.message-detail {
  padding: 20px 24px 28px;
  overflow-wrap: anywhere;
}

.detail-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.detail-subject {
  margin: 0 0 12px;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.detail-meta {
  display: grid;
  gap: 4px;
  font-size: 13.5px;
  color: var(--muted);
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.detail-meta-row {
  display: flex;
  gap: 10px;
}

.detail-meta-key {
  width: 48px;
  flex-shrink: 0;
  color: var(--muted);
}

.detail-meta-val {
  color: var(--text);
  word-break: break-word;
}

.otp-banner {
  margin: 16px 0;
  padding: 14px 18px;
  border-radius: 16px;
  background: var(--success-bg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.otp-banner-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--success);
}

.otp-banner-code {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--text);
}

.remote-img-bar {
  margin: 14px 0 10px;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--subtle-bg);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12.5px;
  color: var(--muted);
  flex-wrap: wrap;
}

.detail-body {
  margin-top: 16px;
}

.detail-iframe {
  display: block;
  border: 1px solid var(--line);
  border-radius: 14px;
  width: 100%;
  min-height: 360px;
  background: #ffffff;
}

.detail-plain {
  margin: 0;
  padding: 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--subtle-bg);
  white-space: pre-wrap;
  word-break: break-word;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 13px;
  line-height: 1.65;
  color: var(--text);
}

/* ═══════════════════════════════════════════════════
   CUSTOM ADDRESS DIALOG (Modal)
   ═══════════════════════════════════════════════════ */

.dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: var(--backdrop);
  display: grid;
  place-items: center;
  padding: 16px;
}

.dialog-card {
  width: min(100%, 460px);
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: 24px;
  padding: 24px;
  box-shadow: var(--shadow-dialog);
  animation: enter-soft 180ms var(--ease) both;
}

.dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.dialog-head h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.dialog-head p {
  margin: 4px 0 0;
  font-size: 13.5px;
  color: var(--muted);
}

.dialog-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.address-input-group {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--input-bg);
  padding: 4px;
  transition: border-color 160ms var(--ease), box-shadow 160ms var(--ease);
}

.address-input-group:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(70, 124, 99, 0.16);
}

.address-input-group input {
  border: 0;
  padding: 8px 6px 8px 12px;
  min-height: 38px;
  min-width: 0;
  outline: none;
  background: transparent;
  color: var(--text);
  font-size: 14.5px;
  font-weight: 500;
}

.address-input-at {
  padding: 0 6px 0 2px;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--muted);
  user-select: none;
}

.domain-dropdown {
  position: relative;
}

.domain-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 38px;
  padding: 6px 12px 6px 13px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--action);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 160ms var(--ease), transform 160ms var(--ease);
}

.domain-trigger:hover {
  background: var(--accent-soft-hover);
}

.domain-trigger:active {
  transform: scale(0.98);
}

.domain-chevron {
  width: 15px;
  height: 15px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 180ms var(--ease);
}

.domain-trigger[aria-expanded="true"] .domain-chevron {
  transform: rotate(180deg);
}

.domain-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 196px;
  padding: 6px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-dialog);
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 2px;
  transform-origin: top right;
  animation: dropdown-open 170ms var(--ease) both;
}

@keyframes dropdown-open {
  from {
    opacity: 0;
    transform: translateY(-4px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.domain-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: 38px;
  padding: 7px 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  font-size: 13.5px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background-color 140ms var(--ease), color 140ms var(--ease);
}

.domain-option:hover {
  background: var(--hover-tint);
}

.domain-option[aria-selected="true"] {
  background: var(--accent-soft);
  color: var(--action);
  font-weight: 600;
}

.domain-option svg {
  width: 15px;
  height: 15px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

.dialog-preview {
  padding: 10px 14px;
  border-radius: var(--radius-control);
  background: var(--subtle-bg);
  font-size: 13.5px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.dialog-preview strong {
  color: var(--text);
}

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

/* ─── Footer ─── */
.site-footer {
  margin-top: auto;
  padding: 36px 16px 26px;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 18px;
  color: var(--muted);
  font-size: 13px;
}

.footer-dot {
  opacity: 0.45;
}

/* ─── Toast ─── */
.toast {
  position: fixed;
  bottom: 22px;
  right: 22px;
  z-index: 80;
  padding: 10px 16px;
  border-radius: 12px;
  background: var(--toast-bg);
  color: var(--toast-text);
  border: 1px solid var(--toast-border);
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: var(--shadow-pill);
  animation: enter-soft 180ms var(--ease) both;
}

.toast.success {
  background: var(--toast-success-bg);
  color: var(--toast-success-text);
}

.toast.error {
  background: var(--toast-error-bg);
  color: var(--toast-error-text);
}

/* ─── Motion ─── */
@keyframes enter-soft {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}

.message-row.is-new,
.message-detail.is-entering {
  animation: enter-soft 240ms var(--ease) both;
}

.btn[data-loading="true"] .refresh-icon {
  animation: spin 600ms linear infinite;
}

/* ─── Responsive Mobile Reflow (360–680px Native Polish) ─── */
@media (max-width: 680px) {
  .site-header,
  .main-content {
    width: calc(100% - 28px);
  }

  .site-header {
    margin-top: 14px;
    gap: 10px;
  }

  .brand {
    font-size: 17px;
    gap: 8px;
    min-width: 0;
  }

  .brand-logo {
    width: 34px;
    height: 34px;
    border-radius: 10px;
  }

  .header-actions {
    gap: 6px;
    flex-shrink: 0;
  }

  .header-actions .btn--raised {
    min-height: 36px;
    padding: 6px 10px;
    font-size: 13px;
  }

  .header-actions .btn--header-icon {
    width: 36px;
    min-height: 36px;
    padding: 0;
  }

  .header-actions .btn--signout {
    width: 44px;
    min-height: 38px;
    padding: 0;
  }

  .header-actions .history-btn-label,
  .header-actions #historyTrigger .domain-chevron {
    display: none;
  }

  /* Native viewport-aligned History popover (never clips off left/right edge) */
  .header-popover {
    position: fixed;
    top: 62px;
    left: 14px;
    right: 14px;
    width: auto;
    max-width: none;
    transform-origin: top center;
  }

  .main-content {
    margin-top: 24px;
    padding-bottom: 36px;
  }

  .hero h1 {
    font-size: 26px;
  }

  .hero p {
    font-size: 13.5px;
    margin-top: 6px;
  }

  /* Clean 2-row email card: full-width email + copy on row 1, expiry pill on row 2 */
  .email-bar {
    margin-top: 20px;
    border-radius: 20px;
    padding: 12px 14px;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px 8px;
  }

  .email-lead-icon {
    display: none;
  }

  .email-address {
    grid-row: 1;
    grid-column: 1;
    padding: 2px 0;
    font-size: clamp(13.5px, 3.85vw, 15.5px);
    letter-spacing: -0.025em;
  }

  .copy-wrap {
    grid-row: 1;
    grid-column: 2;
    justify-self: end;
  }

  .expiry {
    grid-row: 2;
    grid-column: 1 / 3;
    justify-self: start;
    font-size: 12.5px;
    padding: 6px 12px;
  }

  .inbox {
    margin-top: 18px;
    border-radius: 20px;
  }

  .inbox-header {
    padding: 12px 14px 10px;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  /* Symmetric 3-column native mobile toolbar */
  .inbox-actions {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    padding-top: 8px;
    border-top: 1px solid var(--line);
  }

  .inbox-divider {
    display: none;
  }

  .inbox-actions .btn {
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    min-height: 50px;
    padding: 7px 4px;
    font-size: 11.5px;
    font-weight: 600;
    line-height: 1.15;
    border-radius: 12px;
    background: var(--mobile-tool-bg);
    white-space: nowrap;
  }

  .inbox-actions .btn svg {
    width: 17px;
    height: 17px;
  }

  .empty-state {
    min-height: 240px;
    padding: 28px 16px;
  }

  .message-row,
  .message-detail {
    padding: 14px;
  }

  .detail-meta-val.mono {
    font-size: 12.5px;
  }

  /* Spacious mobile Custom Address dialog */
  .dialog-card {
    padding: 20px;
    border-radius: 22px;
  }

  .address-input-group {
    grid-template-columns: 1fr;
    padding: 6px;
    gap: 6px;
  }

  .address-input-group input {
    width: 100%;
    padding: 8px 10px;
    min-height: 42px;
    font-size: 15px;
  }

  .address-input-at {
    display: none;
  }

  .domain-dropdown,
  .domain-trigger {
    width: 100%;
    min-height: 42px;
  }

  #customDomainLabel::before {
    content: "@";
    opacity: 0.72;
    margin-right: 1px;
  }

  .domain-menu {
    left: 0;
    right: 0;
    min-width: 0;
    width: 100%;
  }

  .toast {
    left: 14px;
    right: 14px;
    bottom: 16px;
    text-align: center;
  }
}

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