:root {
  color-scheme: light;
  --bg: #f5f8ff;
  --panel: #ffffff;
  --ink: #141e32;
  --muted: #60708f;
  --line: rgba(30, 120, 230, 0.14);
  --brand: #1e78e6;
  --brand-2: #50b4ff;
  --dark-brand: #0f46a0;
  --danger: #dc2626;
  --shadow: 0 24px 70px rgba(15, 70, 160, 0.16);
  --radius: 28px;
  --logo-size: 102px;
  --mobile-logo-size: 64px;
  --topbar-offset: 160px;
}

html.dark {
  color-scheme: dark;
  --bg: #08111f;
  --panel: #0e1b2e;
  --ink: #edf4ff;
  --muted: #9fb0c8;
  --line: rgba(159, 176, 200, 0.18);
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.30);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: var(--topbar-offset);
}

section[id] {
  scroll-margin-top: var(--topbar-offset);
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(30, 120, 230, 0.16), transparent 34rem),
    radial-gradient(circle at top right, rgba(80, 180, 255, 0.12), transparent 30rem),
    var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

html.dark body {
  background:
    radial-gradient(circle at top left, rgba(30, 120, 230, 0.20), transparent 34rem),
    radial-gradient(circle at top right, rgba(80, 180, 255, 0.18), transparent 30rem),
    linear-gradient(180deg, #07101d 0%, var(--bg) 55%, #050a12 100%);
}

button,
input {
  font: inherit;
}

.app {
  width: min(1120px, calc(100% - 28px));
  margin: 0 auto;
  padding: var(--topbar-offset) 0 42px;
}

.site-footer {
  width: min(1120px, calc(100% - 28px));
  margin: 0 auto;
  padding: 0 0 34px;
  display: flex;
  justify-content: center;
}

.footer-logo {
  display: inline-flex;
  width: var(--logo-size);
  height: auto;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  text-decoration: none;
}

.footer-logo img {
  width: var(--logo-size);
  height: auto;
  object-fit: contain;
}

.topbar {
  position: fixed;
  top: 14px;
  left: 50%;
  width: min(1120px, calc(100% - 28px));
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 16px 44px rgba(16, 32, 51, 0.08);
}

.brand {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  text-decoration: none;
  font-weight: 800;
  letter-spacing: -0.03em;
  font-size: 1.25rem;
  flex: 0 0 auto;
}

.brand-logo,
.footer-logo img {
  width: var(--logo-size);
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 12px 22px rgba(30, 120, 230, 0.18));
}

.menu-bar {
  position: relative;
  z-index: 101;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px;
  border-radius: 999px;
  background: rgba(245, 248, 255, 0.88);
}

.menu-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 9px 14px;
  border-radius: 999px;
  color: var(--muted);
  font-weight: 800;
  font-size: 0.92rem;
  text-decoration: none;
  transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}

.menu-link:hover,
.menu-link[aria-current="page"] {
  color: var(--ink);
  background: #fff;
}

.menu-link:active {
  transform: translateY(1px);
}

.theme-toggle {
  border: 0;
  border-radius: 999px;
  padding: 9px 13px;
  font-weight: 800;
  cursor: pointer;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.10);
  transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}

html:not(.dark) .theme-toggle {
  background: #eef4ff;
}

.theme-toggle:active {
  transform: translateY(1px);
}

.menu-toggle {
  display: none;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 999px;
  background: #eef4ff;
  cursor: pointer;
  padding: 0;
}

html.dark .menu-toggle {
  background: rgba(255, 255, 255, 0.08);
}

.menu-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  margin: 5px auto;
  border-radius: 99px;
  background: var(--ink);
  transition: transform 160ms ease, opacity 160ms ease;
}

.menu-toggle.open span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.menu-toggle.open span:nth-child(2) {
  opacity: 0;
}

.menu-toggle.open span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

.verify-link {
  color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: 0 10px 22px rgba(30, 120, 230, 0.18);
}

.verify-link:hover,
.verify-link[aria-current="page"] {
  color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
}

.hero {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 20px;
  align-items: stretch;
  margin-bottom: 18px;
}

.card {
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(220, 228, 238, 0.86);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

html.dark .topbar,
html.dark .card,
html.dark .menu-bar,
html.dark .email-box,
html.dark .message-detail,
html.dark .loading-card {
  background: rgba(14, 27, 46, 0.82);
  border-color: var(--line);
}

html.dark .menu-link:hover,
html.dark .menu-link[aria-current='page'] {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.08);
}

html.dark .btn.secondary {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--line);
}

html.dark .spinner.dark {
  border-color: rgba(159, 176, 200, 0.22);
  border-top-color: var(--brand);
}

.hero-copy {
  padding: clamp(22px, 4vw, 38px);
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  color: var(--brand);
  font-weight: 800;
  font-size: 0.86rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

h1 {
  margin: 0;
  max-width: 11ch;
  font-size: clamp(2.25rem, 7vw, 4.7rem);
  line-height: 0.94;
  letter-spacing: -0.075em;
}

.hero-copy p {
  max-width: 58ch;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: clamp(1rem, 2.4vw, 1.12rem);
}

.email-card {
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 280px;
}

.email-card h2 {
  margin: 0;
  font-size: 1.1rem;
  letter-spacing: -0.02em;
}

.email-box {
  margin: 18px 0;
  padding: 16px;
  border-radius: 18px;
  border: 1px dashed #b9c7dc;
  background: #f8fbff;
  overflow-wrap: anywhere;
}

.email-address {
  display: block;
  font-size: clamp(1.05rem, 3.4vw, 1.45rem);
  font-weight: 800;
  letter-spacing: -0.035em;
  word-break: break-word;
}

.email-meta {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.92rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.btn {
  border: 0;
  border-radius: 999px;
  padding: 12px 16px;
  cursor: pointer;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--dark-brand));
  box-shadow: 0 12px 24px rgba(30, 120, 230, 0.22);
  transition: transform 160ms ease, box-shadow 160ms ease, opacity 160ms ease;
}

.btn.secondary {
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: none;
}

.btn.danger {
  background: var(--danger);
  box-shadow: none;
}

.btn:active {
  transform: translateY(1px) scale(0.99);
}

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

.btn.danger:disabled {
  color: #98a2b3;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: none;
}

.inbox {
  padding: 20px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.section-head h2 {
  margin: 0;
  font-size: 1.2rem;
  letter-spacing: -0.03em;
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.empty {
  border: 1px dashed #c7d3e3;
  border-radius: 18px;
  padding: 24px;
  text-align: center;
  color: var(--muted);
  background: #f8fbff;
}

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

.message-item {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  padding: 14px;
  text-align: left;
  cursor: pointer;
  transition: border-color 160ms ease, transform 160ms ease;
}

.message-item:hover {
  border-color: #a9b9d0;
  transform: translateY(-1px);
}

.message-title {
  margin: 0;
  font-weight: 850;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}

.message-from {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  overflow-wrap: anywhere;
}

.message-preview {
  margin: 8px 0 0;
  color: #334155;
  font-size: 0.92rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.message-item {
  overflow: hidden;
}

.message-detail {
  margin-top: 14px;
  padding: 16px;
  border-radius: 18px;
  background: #f8fbff;
  border: 1px solid var(--line);
}

.message-detail h3 {
  margin: 0 0 8px;
  font-size: 1.08rem;
  letter-spacing: -0.02em;
}

.message-detail .meta {
  color: var(--muted);
  font-size: 0.88rem;
  margin-bottom: 12px;
}

.message-body {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 0.95rem;
  max-height: 60vh;
  overflow-y: auto;
  padding-right: 8px;
  line-height: 1.6;
}

.message-detail {
  position: relative;
  max-height: 70vh;
  overflow: hidden;
}

.message-detail .close-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 999px;
  background: rgba(16, 32, 51, 0.06);
  color: var(--muted);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}

.message-detail .close-btn:hover {
  background: rgba(16, 32, 51, 0.12);
  color: var(--ink);
}

.message-detail .close-btn:active {
  transform: scale(0.95);
}

html.dark .message-detail .close-btn {
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
}

html.dark .message-detail .close-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--ink);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%) translateY(20px);
  opacity: 0;
  pointer-events: none;
  background: #102033;
  color: #fff;
  border-radius: 999px;
  padding: 11px 15px;
  box-shadow: 0 16px 32px rgba(16, 32, 51, 0.2);
  transition: opacity 180ms ease, transform 180ms ease;
  font-size: 0.92rem;
  z-index: 10;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: #fff;
  border-radius: 999px;
  animation: spin 800ms linear infinite;
  display: inline-block;
  vertical-align: -3px;
  margin-right: 8px;
}

.spinner.dark {
  border-color: rgba(30, 120, 230, 0.18);
  border-top-color: var(--brand);
}

.loading-card {
  display: grid;
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
}

.loading-line {
  height: 12px;
  border-radius: 999px;
  background: linear-gradient(90deg, #edf2f8, #f8fbff, #edf2f8);
  background-size: 200% 100%;
  animation: shimmer 1.1s linear infinite;
}

.loading-line.short {
  width: 58%;
}

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

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

@media (max-width: 820px) {
  :root {
    --topbar-offset: 108px;
  }
  .app {
    width: min(100% - 20px, 480px);
    padding-top: var(--topbar-offset);
  }

  .topbar {
    position: fixed;
    top: 10px;
    left: 50%;
    width: calc(100% - 20px);
    transform: translateX(-50%);
    margin: 0;
    gap: 12px;
    padding: 12px;
    border-radius: 24px;
  }

  .menu-toggle {
    display: block;
  }

  .menu-bar {
    display: none;
    position: absolute;
    left: 12px;
    right: 12px;
    top: 66px;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 10px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 16px 36px rgba(16, 32, 51, 0.12);
    opacity: 0;
    transform: translateY(-8px);
    pointer-events: none;
    transition: opacity 1.5s ease, transform 1.5s ease, visibility 0ms linear 1.5s;
    visibility: hidden;
  }

  html.dark .menu-bar {
    background: rgba(14, 27, 46, 0.96);
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.28);
  }

  .menu-bar.open {
    display: flex;
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
    visibility: visible;
    transition: opacity 1.5s ease, transform 1.5s ease;
  }

  .menu-link {
    justify-content: flex-start;
    min-height: 42px;
    padding: 10px 12px;
    border-radius: 16px;
  }

  .menu-link.verify-link {
    color: var(--ink);
    background: rgba(30, 120, 230, 0.10);
    box-shadow: none;
  }

  .menu-bar.open .theme-toggle {
    justify-content: flex-start;
    width: 100%;
    border-radius: 16px;
    padding: 10px 12px;
    background: transparent;
    text-align: left;
  }

  .menu-bar.open .theme-toggle:hover {
    background: rgba(30, 120, 230, 0.10);
    transform: none;
  }

  .brand-logo,
  .footer-logo img {
    width: var(--mobile-logo-size);
  }

  .menu-bar:not(.open) {
    margin-left: auto;
    gap: 6px;
    padding: 5px;
  }

  .menu-link {
    min-height: 38px;
    padding: 8px 11px;
    font-size: 0.86rem;
  }

  .status-pill {
    display: none;
  }

  .hero {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .hero-copy {
    padding: 24px;
  }

  h1 {
    max-width: 9ch;
  }

  .email-card {
    min-height: auto;
  }

  .inbox {
    padding: 16px;
  }

  .btn {
    width: 100%;
    padding: 10px 14px;
    font-size: 0.95rem;
  }

  .actions {
    display: grid;
    gap: 8px;
  }

  /* Email address - prevent horizontal overflow */
  .email-address {
    max-width: 100%;
    overflow-wrap: anywhere;
    word-break: break-all;
    font-size: clamp(1rem, 5vw, 1.2rem);
  }

  /* Message detail - fit in remaining viewport */
  .message-body {
    max-height: 40vh;
  }

  /* Close button - larger touch target */
  .message-detail .close-btn {
    width: 40px;
    height: 40px;
    font-size: 1.4rem;
  }

  /* Message detail - fit in remaining viewport on mobile */
  .message-body {
    max-height: 40vh;
  }

  .message-detail {
    max-height: 55vh;
  }

  /* Message list items - better tap target */
  .message-item {
    padding: 16px;
  }

  /* Collapse hero copy after inbox created */
  .hero-copy.collapsed {
    display: none;
  }

  .hero-copy.collapsed + .email-card {
    margin-top: 0;
  }
}