/* Orivexa Mail — Premium Design System (Light/Dark Auto) */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* ═══════════════════════════════════════════════════════
   DESIGN TOKENS — Light Mode (default)
   ═══════════════════════════════════════════════════════ */
:root {
  /* Surfaces */
  --bg: #f4f2ff;
  --bg-mesh-1: rgba(129, 140, 248, 0.15);
  --bg-mesh-2: rgba(168, 85, 247, 0.10);
  --bg-mesh-3: rgba(45, 212, 191, 0.08);
  --surface: #ffffff;
  --surface-glass: rgba(255, 255, 255, 0.72);
  --surface-raised: rgba(255, 255, 255, 0.92);
  --surface-hover: rgba(99, 102, 241, 0.04);
  --surface-selected: rgba(99, 102, 241, 0.08);

  /* Borders */
  --border: rgba(99, 102, 241, 0.10);
  --border-strong: rgba(99, 102, 241, 0.18);
  --border-glass: rgba(255, 255, 255, 0.6);
  --border-card: rgba(99, 102, 241, 0.12);

  /* Text */
  --text: #1e1b4b;
  --text-secondary: #6366f1;
  --text-muted: #8b8fa3;
  --text-faint: #a5a8c0;

  /* Accents */
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-soft: rgba(99, 102, 241, 0.10);
  --primary-glow: rgba(99, 102, 241, 0.25);
  --gradient-primary: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a855f7 100%);
  --gradient-primary-hover: linear-gradient(135deg, #4f46e5 0%, #7c3aed 50%, #9333ea 100%);
  --gradient-surface: linear-gradient(135deg, rgba(255,255,255,0.9) 0%, rgba(255,255,255,0.7) 100%);

  /* Semantic */
  --success: #10b981;
  --success-soft: rgba(16, 185, 129, 0.10);
  --warning: #f59e0b;
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.08);
  --danger-border: rgba(239, 68, 68, 0.20);
  --otp-bg: linear-gradient(135deg, #eef2ff 0%, #f3e8ff 100%);
  --otp-text: #4338ca;
  --otp-border: rgba(99, 102, 241, 0.18);

  /* Badge */
  --unread: #6366f1;
  --selected: rgba(99, 102, 241, 0.08);
  --hover: rgba(99, 102, 241, 0.04);

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(30, 27, 75, 0.04);
  --shadow-md: 0 4px 16px rgba(30, 27, 75, 0.06);
  --shadow-lg: 0 12px 40px rgba(30, 27, 75, 0.10);
  --shadow-xl: 0 24px 72px rgba(30, 27, 75, 0.14);
  --shadow-glow: 0 0 30px rgba(99, 102, 241, 0.12);
  --shadow-btn: 0 4px 14px rgba(99, 102, 241, 0.28);
  --shadow-btn-hover: 0 8px 24px rgba(99, 102, 241, 0.36);

  /* Layout */
  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --radius-full: 9999px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;

  /* Typography */
  --font: 'Inter', system-ui, -apple-system, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --fs-hero: 1.75rem;
  --fs-title: 1.25rem;
  --fs-body: 0.9375rem;
  --fs-small: 0.8125rem;
  --fs-caption: 0.75rem;
  --fs-micro: 0.6875rem;
  --fs-otp: 1.5rem;
  --lh: 1.55;
  --header-h: 64px;
  --list-w: 380px;
  --focus: 0 0 0 3px rgba(99, 102, 241, 0.30);

  /* Transitions */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --duration-fast: 0.15s;
  --duration-normal: 0.25s;
  --duration-slow: 0.4s;

  color-scheme: light dark;
}

/* ═══════════════════════════════════════════════════════
   DARK MODE TOKENS
   ═══════════════════════════════════════════════════════ */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f0e17;
    --bg-mesh-1: rgba(99, 102, 241, 0.10);
    --bg-mesh-2: rgba(139, 92, 246, 0.08);
    --bg-mesh-3: rgba(45, 212, 191, 0.05);
    --surface: rgba(30, 28, 50, 0.80);
    --surface-glass: rgba(30, 28, 50, 0.60);
    --surface-raised: rgba(40, 37, 65, 0.85);
    --surface-hover: rgba(99, 102, 241, 0.08);
    --surface-selected: rgba(99, 102, 241, 0.14);

    --border: rgba(99, 102, 241, 0.12);
    --border-strong: rgba(99, 102, 241, 0.22);
    --border-glass: rgba(255, 255, 255, 0.08);
    --border-card: rgba(99, 102, 241, 0.16);

    --text: #e8e6f0;
    --text-secondary: #a5b4fc;
    --text-muted: #8b8fa3;
    --text-faint: #5c5f73;

    --primary: #818cf8;
    --primary-hover: #6366f1;
    --primary-soft: rgba(129, 140, 248, 0.12);
    --primary-glow: rgba(129, 140, 248, 0.20);
    --gradient-primary: linear-gradient(135deg, #818cf8 0%, #a78bfa 50%, #c084fc 100%);
    --gradient-primary-hover: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a855f7 100%);
    --gradient-surface: linear-gradient(135deg, rgba(30,28,50,0.9) 0%, rgba(30,28,50,0.7) 100%);

    --success: #34d399;
    --success-soft: rgba(52, 211, 153, 0.12);
    --warning: #fbbf24;
    --danger: #f87171;
    --danger-bg: rgba(248, 113, 113, 0.10);
    --danger-border: rgba(248, 113, 113, 0.24);
    --otp-bg: linear-gradient(135deg, rgba(99,102,241,0.12) 0%, rgba(139,92,246,0.10) 100%);
    --otp-text: #a5b4fc;
    --otp-border: rgba(129, 140, 248, 0.20);

    --unread: #818cf8;
    --selected: rgba(99, 102, 241, 0.12);
    --hover: rgba(99, 102, 241, 0.06);

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.20);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.25);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.30);
    --shadow-xl: 0 24px 72px rgba(0, 0, 0, 0.40);
    --shadow-glow: 0 0 40px rgba(99, 102, 241, 0.15);
    --shadow-btn: 0 4px 14px rgba(99, 102, 241, 0.22);
    --shadow-btn-hover: 0 8px 24px rgba(99, 102, 241, 0.30);
  }
}

/* ═══════════════════════════════════════════════════════
   RESET & BASE
   ═══════════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  font-size: var(--fs-body);
  line-height: var(--lh);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button, input, select { font: inherit; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
.hidden, [hidden] { display: none !important; }
.view { min-height: 100vh; }

/* Smooth scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

/* Screen reader only */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ═══════════════════════════════════════════════════════
   TYPOGRAPHY
   ═══════════════════════════════════════════════════════ */
.page-title {
  margin: 0 0 var(--space-2);
  font-size: var(--fs-hero);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.2;
  background: linear-gradient(135deg, var(--text) 0%, var(--primary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.page-desc {
  margin: 0 0 var(--space-6);
  color: var(--text-muted);
  font-size: var(--fs-body);
  line-height: 1.65;
}

.section-title {
  margin: 0;
  font-size: var(--fs-micro);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.meta-caption {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  background: var(--primary-soft);
  color: var(--primary);
  font-size: var(--fs-micro);
  font-weight: 600;
}

.logo-text {
  font-size: var(--fs-body);
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
}

.logo-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: var(--gradient-primary);
  color: #fff;
  flex-shrink: 0;
  box-shadow: var(--shadow-btn);
  transition: transform var(--duration-normal) var(--ease-spring), box-shadow var(--duration-normal) var(--ease-out);
}

.logo-mark:hover {
  transform: scale(1.05);
  box-shadow: var(--shadow-btn-hover);
}

.logo-mark-sm {
  width: 34px;
  height: 34px;
}

/* ═══════════════════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 40px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  font-weight: 500;
  font-size: 0.875rem;
  cursor: pointer;
  white-space: nowrap;
  transition:
    background var(--duration-fast) var(--ease-out),
    border-color var(--duration-fast) var(--ease-out),
    color var(--duration-fast) var(--ease-out),
    box-shadow var(--duration-fast) var(--ease-out),
    transform var(--duration-fast) var(--ease-spring);
  position: relative;
  overflow: hidden;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(circle at center, rgba(255,255,255,0.2) 0%, transparent 70%);
  opacity: 0;
  transition: opacity var(--duration-fast) var(--ease-out);
}

.btn:hover::after { opacity: 1; }
.btn:active { transform: scale(0.97); }
.btn:focus-visible { outline: none; box-shadow: var(--focus); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn svg { flex-shrink: 0; }

.btn-primary {
  background: var(--gradient-primary);
  color: #fff;
  border-color: transparent;
  box-shadow: var(--shadow-btn);
  font-weight: 600;
}

.btn-primary:hover:not(:disabled) {
  background: var(--gradient-primary-hover);
  box-shadow: var(--shadow-btn-hover);
  transform: translateY(-1px);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0) scale(0.98);
}

.btn-secondary {
  background: var(--surface-glass);
  border-color: var(--border);
  color: var(--text);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--surface-hover);
  border-color: var(--border-strong);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--hover);
  color: var(--text);
}

.btn-danger {
  background: var(--danger-bg);
  border-color: var(--danger-border);
  color: var(--danger);
}

.btn-block {
  width: 100%;
  min-height: 48px;
}

.btn-back { padding-left: 8px; }

@media (max-width: 767px) {
  .app-header-actions .btn-text { display: none; }
  .app-header-actions .btn { min-width: 40px; padding: 0 10px; }
}

/* ═══════════════════════════════════════════════════════
   VIEW — ACCESS (Login page)
   ═══════════════════════════════════════════════════════ */
.view-access {
  display: grid;
  place-items: center;
  padding: var(--space-6);
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 20% 20%, var(--bg-mesh-1), transparent 50%),
    radial-gradient(ellipse at 80% 80%, var(--bg-mesh-2), transparent 50%),
    radial-gradient(ellipse at 50% 50%, var(--bg-mesh-3), transparent 60%),
    var(--bg);
}

/* Animated floating orbs */
.view-access::before,
.view-access::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  filter: blur(80px);
  animation: float-orb 12s ease-in-out infinite alternate;
}

.view-access::before {
  width: 400px;
  height: 400px;
  top: -100px;
  right: -50px;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.18) 0%, transparent 70%);
  animation-delay: 0s;
}

.view-access::after {
  width: 350px;
  height: 350px;
  bottom: -80px;
  left: -60px;
  background: radial-gradient(circle, rgba(168, 85, 247, 0.14) 0%, transparent 70%);
  animation-delay: -6s;
}

@keyframes float-orb {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(20px, -15px) scale(1.05); }
  100% { transform: translate(-10px, 10px) scale(0.95); }
}

.access-shell {
  width: min(100%, 460px);
  position: relative;
  z-index: 1;
  animation: fade-slide-up 0.6s var(--ease-out) both;
}

@keyframes fade-slide-up {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.access-card {
  position: relative;
  overflow: hidden;
  background: var(--surface-glass);
  backdrop-filter: blur(24px) saturate(1.4);
  -webkit-backdrop-filter: blur(24px) saturate(1.4);
  border: 1px solid var(--border-glass);
  border-radius: 24px;
  padding: 36px 32px;
  box-shadow: var(--shadow-xl), var(--shadow-glow);
  transition: box-shadow var(--duration-slow) var(--ease-out);
}

.access-card:hover {
  box-shadow: var(--shadow-xl), 0 0 50px rgba(99, 102, 241, 0.18);
}

.access-card-glow {
  position: absolute;
  top: -120px;
  right: -100px;
  width: 280px;
  height: 280px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--primary-glow) 0%, transparent 70%);
  pointer-events: none;
  animation: pulse-glow 4s ease-in-out infinite alternate;
}

@keyframes pulse-glow {
  0% { opacity: 0.6; transform: scale(1); }
  100% { opacity: 1; transform: scale(1.1); }
}

.access-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: 28px;
  position: relative;
  z-index: 1;
}

.brand-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  padding: 5px 10px;
  border: 1px solid rgba(16, 185, 129, 0.20);
  border-radius: var(--radius-full);
  background: var(--success-soft);
  color: var(--success);
  font-size: var(--fs-micro);
  font-weight: 700;
  letter-spacing: 0.02em;
}

.brand-status span,
.access-foot-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.40);
  animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 4px rgba(16, 185, 129, 0.3); }
  50% { box-shadow: 0 0 12px rgba(16, 185, 129, 0.6); }
}

.access-intro {
  position: relative;
  z-index: 1;
  margin-bottom: 26px;
}

.eyebrow {
  display: block;
  margin-bottom: 8px;
  color: var(--primary);
  font-size: var(--fs-micro);
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.access-intro .page-title {
  font-size: 1.75rem;
  line-height: 1.18;
}

.access-intro .page-desc {
  max-width: 360px;
  margin-bottom: 0;
  line-height: 1.65;
}

/* Access Form */
.access-form {
  display: grid;
  gap: 12px;
  position: relative;
  z-index: 1;
}

.field-label {
  display: block;
  font-size: var(--fs-small);
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.input-combo {
  display: flex;
  align-items: center;
  min-height: 52px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-glass);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding-right: 8px;
  transition:
    border-color var(--duration-fast) var(--ease-out),
    box-shadow var(--duration-fast) var(--ease-out),
    background var(--duration-fast) var(--ease-out);
}

.input-combo:hover {
  border-color: var(--border-strong);
}

.input-combo:focus-within {
  border-color: var(--primary);
  box-shadow: var(--focus);
  background: var(--surface);
}

.input-combo input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  padding: 14px;
  color: var(--text);
  outline: none;
  font-weight: 500;
}

.input-combo input::placeholder { color: var(--text-faint); }

.input-suffix {
  font-size: var(--fs-small);
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
}

.input-suffix.is-hidden { display: none; }

.domain-picker {
  display: flex;
  align-self: stretch;
  align-items: center;
  margin: 6px 0;
  border-left: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--surface-hover);
  padding-left: 10px;
  transition: background var(--duration-fast) var(--ease-out);
}

.domain-picker:hover {
  background: var(--primary-soft);
}

.domain-picker select {
  max-width: 172px;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font: inherit;
  font-size: var(--fs-caption);
  font-weight: 600;
  outline: none;
  padding: 8px 22px 8px 0;
}

.domain-picker select:focus-visible {
  outline: none;
  color: var(--text);
}

.domain-helper {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 2px 4px;
  color: var(--text-faint);
  font-size: var(--fs-caption);
}

.domain-helper::before {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--primary);
  content: '';
  opacity: 0.6;
}

@media (max-width: 420px) {
  .input-combo {
    align-items: stretch;
    flex-wrap: wrap;
    padding-right: 0;
  }
  .input-combo input { min-width: 100%; }
  .domain-picker {
    width: 100%;
    border-top: 1px solid var(--border);
    border-left: 0;
    padding: 0 12px;
    margin: 0;
    border-radius: 0;
  }
  .domain-picker select {
    max-width: none;
    width: 100%;
    padding: 10px 22px 10px 0;
  }
}

.field-error {
  margin: 0;
  padding: 10px 14px;
  font-size: var(--fs-small);
  color: var(--danger);
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  border-radius: var(--radius-sm);
  animation: shake 0.3s var(--ease-out);
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

.btn-primary .btn-label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.btn-primary .btn-label span {
  font-size: 1.15rem;
  line-height: 0;
  transition: transform var(--duration-fast) var(--ease-spring);
}

.btn-primary:hover:not(:disabled) .btn-label span {
  transform: translateX(4px);
}

.access-features {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  margin-top: 20px;
  color: var(--text-muted);
  font-size: var(--fs-caption);
  position: relative;
  z-index: 1;
}

.access-features span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.access-features i {
  display: inline-grid;
  width: 16px;
  height: 16px;
  place-items: center;
  border-radius: 50%;
  background: var(--success-soft);
  color: var(--success);
  font-size: 0.6rem;
  font-style: normal;
  font-weight: 800;
}

.access-foot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 22px;
  font-size: var(--fs-caption);
  color: var(--text-faint);
}

.access-foot strong {
  color: var(--text-muted);
  font-weight: 600;
}

.access-foot-dot { width: 5px; height: 5px; }

@media (max-width: 420px) {
  .access-card {
    padding: 26px 22px;
    border-radius: 20px;
  }
  .brand-status { font-size: 0.6rem; }
  .access-features { display: grid; gap: 8px; }
}

/* ═══════════════════════════════════════════════════════
   APP HEADER
   ═══════════════════════════════════════════════════════ */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  height: var(--header-h);
  padding: 0 24px;
  background: var(--surface-glass);
  backdrop-filter: blur(20px) saturate(1.3);
  -webkit-backdrop-filter: blur(20px) saturate(1.3);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
  transition: background var(--duration-normal) var(--ease-out);
}

.app-header-left {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
}

.app-header-titles {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.inbox-addr {
  font-size: var(--fs-caption);
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: min(52vw, 360px);
}

.app-header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════
   INBOX LAYOUT
   ═══════════════════════════════════════════════════════ */
.inbox-layout {
  display: grid;
  grid-template-columns: var(--list-w) 1fr;
  height: calc(100vh - var(--header-h));
  min-height: 0;
  background: var(--bg);
}

.msg-list-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--surface-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-right: 1px solid var(--border);
}

.pane-toolbar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 17px 18px 13px;
  border-bottom: 1px solid var(--border);
}

.msg-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  flex: 1;
}

/* Message Rows */
.msg-row {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  gap: var(--space-3);
  width: 100%;
  text-align: left;
  padding: 14px 18px;
  border: none;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: inherit;
  cursor: pointer;
  align-items: start;
  transition:
    background var(--duration-fast) var(--ease-out),
    box-shadow var(--duration-fast) var(--ease-out);
  animation: fade-in 0.2s var(--ease-out) both;
}

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

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

.msg-row:focus-visible {
  outline: none;
  box-shadow: inset var(--focus);
}

.msg-row.is-selected {
  background: var(--surface-selected);
  box-shadow: inset 3px 0 0 var(--primary);
}

.msg-row.is-unread .msg-from,
.msg-row.is-unread .msg-subject {
  font-weight: 700;
}

.msg-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--gradient-primary);
  color: #fff;
  font-size: var(--fs-small);
  font-weight: 700;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
  transition: transform var(--duration-fast) var(--ease-spring);
}

.msg-row:hover .msg-avatar {
  transform: scale(1.05);
}

.msg-main {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.msg-from {
  font-size: 0.875rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}

.msg-subject {
  font-size: 0.875rem;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.msg-snippet {
  font-size: var(--fs-caption);
  color: var(--text-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-top: 1px;
}

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

.msg-time {
  font-size: var(--fs-caption);
  color: var(--text-faint);
  white-space: nowrap;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 8px;
  border-radius: var(--radius-full);
  font-size: var(--fs-micro);
  font-weight: 700;
  line-height: 1;
}

.badge-new {
  background: var(--primary-soft);
  color: var(--primary);
  animation: badge-pop 0.3s var(--ease-spring) both;
}

@keyframes badge-pop {
  from { transform: scale(0.7); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.badge-otp {
  background: var(--primary-soft);
  color: var(--primary);
  font-variant-numeric: tabular-nums;
  font-family: var(--mono);
  letter-spacing: 0.03em;
}

/* ═══════════════════════════════════════════════════════
   DETAIL PANE
   ═══════════════════════════════════════════════════════ */
.msg-detail-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  overflow: auto;
  background:
    radial-gradient(ellipse at 80% 10%, var(--bg-mesh-1), transparent 40%),
    var(--bg);
}

.detail-content {
  max-width: 800px;
  width: 100%;
  margin: 28px auto;
  padding: 28px 36px 42px;
  background: var(--surface-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-top: 3px solid var(--primary);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: detail-enter 0.35s var(--ease-out) both;
}

@keyframes detail-enter {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.detail-toolbar {
  display: flex;
  align-items: center;
  min-height: 28px;
  margin: -3px 0 20px;
}

.detail-subject {
  margin: 0 0 var(--space-4);
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.3;
  word-break: break-word;
  color: var(--text);
}

.detail-meta {
  margin: 0 0 var(--space-5);
  display: grid;
  gap: 8px;
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--border);
}

.detail-meta > div {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: var(--space-2);
  font-size: var(--fs-small);
}

.detail-meta dt { margin: 0; color: var(--text-faint); font-weight: 600; }
.detail-meta dd { margin: 0; color: var(--text); word-break: break-word; }

/* Email heading */
.email-heading {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 22px;
}

.detail-sender-avatar {
  display: inline-grid;
  flex: 0 0 auto;
  width: 50px;
  height: 50px;
  place-items: center;
  border-radius: var(--radius-sm);
  background: var(--gradient-primary);
  box-shadow: var(--shadow-btn);
  color: #fff;
  font-size: 1.1rem;
  font-weight: 700;
  transition: transform var(--duration-fast) var(--ease-spring);
}

.detail-sender-avatar:hover {
  transform: scale(1.05);
}

.email-heading-content {
  min-width: 0;
  padding-top: 2px;
}

.email-heading-label {
  display: block;
  margin-bottom: 5px;
  color: var(--primary);
  font-size: var(--fs-micro);
  font-weight: 800;
  letter-spacing: 0.10em;
  text-transform: uppercase;
}

.email-heading .detail-subject {
  margin: 0;
  font-size: 1.5rem;
  line-height: 1.25;
}

/* Sender Card */
.sender-card {
  display: grid;
  grid-template-columns: minmax(150px, 0.78fr) minmax(0, 1.8fr);
  gap: 20px;
  margin-bottom: 22px;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-glass);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.sender-identity {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  min-width: 0;
  padding-right: 16px;
  border-right: 1px solid var(--border);
}

.sender-name {
  overflow: hidden;
  color: var(--text);
  font-size: 0.875rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sender-caption {
  color: var(--text-faint);
  font-size: var(--fs-micro);
  font-weight: 500;
}

.sender-card .detail-meta {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
  padding: 0;
  border: 0;
}

.sender-card .detail-meta > div { display: block; min-width: 0; }

.sender-card .detail-meta dt {
  margin-bottom: 3px;
  color: var(--text-faint);
  font-size: var(--fs-micro);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.sender-card .detail-meta dd {
  overflow: hidden;
  color: var(--text-muted);
  font-size: var(--fs-caption);
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* OTP Block */
.otp-block {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-4);
  margin-bottom: 22px;
  background: var(--otp-bg);
  border: 1px solid var(--otp-border);
  border-radius: var(--radius);
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.otp-block::after {
  content: '';
  position: absolute;
  top: -40px;
  right: -30px;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: var(--primary-glow);
  pointer-events: none;
  animation: pulse-glow 3s ease-in-out infinite alternate;
}

.otp-block-text, .otp-block .btn {
  position: relative;
  z-index: 1;
}

.otp-label {
  display: block;
  font-size: var(--fs-caption);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--otp-text);
  opacity: 0.8;
  margin-bottom: 4px;
}

.otp-code {
  font-family: var(--mono);
  font-size: var(--fs-otp);
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--otp-text);
}

.otp-block .btn {
  min-height: 38px;
  box-shadow: none;
}

/* Body Toggle */
.body-toggle {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
}

.chip-btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface-glass);
  color: var(--text-muted);
  border-radius: var(--radius-full);
  padding: 7px 14px;
  font-size: var(--fs-caption);
  font-weight: 600;
  cursor: pointer;
  transition:
    background var(--duration-fast) var(--ease-out),
    border-color var(--duration-fast) var(--ease-out),
    color var(--duration-fast) var(--ease-out);
}

.chip-btn:hover {
  border-color: var(--border-strong);
  color: var(--primary);
}

.chip-btn.is-active {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary);
}

.chip-btn:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

/* Email Body */
.email-body-shell {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.email-body-topline {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  padding: 0 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-hover);
  color: var(--text-faint);
  font-size: var(--fs-micro);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.email-body-topline > span:not(:nth-child(2)) {
  height: 1px;
  background: var(--border);
}

.email-body-shell .body-html {
  min-height: 170px;
  padding: 26px 28px 32px;
  color: var(--text);
  font-size: 0.9375rem;
  line-height: 1.72;
}

.body-html { font-size: var(--fs-body); line-height: 1.72; color: var(--text); overflow-wrap: anywhere; }
.body-html a { color: var(--primary); }
.body-html img { display: none; }

.email-body-shell .body-html > :first-child { margin-top: 0; }
.email-body-shell .body-html > :last-child { margin-bottom: 0; }

.email-body-shell .body-html h1,
.email-body-shell .body-html h2,
.email-body-shell .body-html h3 { color: var(--text); }

.email-body-shell .body-html blockquote {
  margin: 18px 0;
  padding: 12px 16px;
  border-left: 3px solid var(--primary);
  background: var(--surface-hover);
  color: var(--text-muted);
  border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
}

.body-text {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--mono);
  font-size: var(--fs-small);
  line-height: 1.6;
  padding: var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.email-body-shell .body-text {
  margin: 18px;
  border-color: var(--border);
  background: var(--surface-hover);
}

/* ═══════════════════════════════════════════════════════
   STATES (empty, loading, error, placeholder)
   ═══════════════════════════════════════════════════════ */
.state-box {
  display: grid;
  justify-items: center;
  text-align: center;
  gap: var(--space-2);
  padding: var(--space-8) var(--space-4);
  color: var(--text-muted);
}

.state-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  border-radius: var(--radius-sm);
  background: var(--primary-soft);
  color: var(--primary);
  margin-bottom: var(--space-2);
  transition: transform var(--duration-normal) var(--ease-spring);
}

.state-icon:hover {
  transform: scale(1.08);
}

.state-title {
  margin: 0;
  font-size: var(--fs-body);
  font-weight: 600;
  color: var(--text);
}

.state-desc {
  margin: 0;
  font-size: var(--fs-small);
  color: var(--text-muted);
  max-width: 280px;
}

.state-email {
  margin: var(--space-2) 0 0;
  font-size: var(--fs-small);
  word-break: break-all;
}

.state-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  justify-content: center;
  margin-top: var(--space-3);
}

.detail-placeholder {
  margin: auto;
  padding-top: 20vh;
}

.empty-state {
  margin-top: 12vh;
}

/* Skeleton Loading */
.skeleton-list {
  padding: var(--space-3) var(--space-4);
  display: grid;
  gap: var(--space-3);
}

.skeleton-row {
  height: 68px;
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg, var(--surface-hover) 25%, var(--border) 50%, var(--surface-hover) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}

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

/* ═══════════════════════════════════════════════════════
   TOAST
   ═══════════════════════════════════════════════════════ */
.toast-root {
  position: fixed;
  z-index: 100;
  top: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  max-width: min(380px, calc(100vw - 40px));
}

.toast {
  pointer-events: auto;
  padding: 12px 16px;
  background: var(--surface-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: var(--fs-small);
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.3s var(--ease-spring) both;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(24px) scale(0.95); }
  to { opacity: 1; transform: translateX(0) scale(1); }
}

.toast.is-error {
  border-color: var(--danger-border);
  color: var(--danger);
}

@media (max-width: 767px) {
  .toast-root {
    top: auto;
    bottom: 20px;
    right: 16px;
    left: 16px;
    max-width: none;
  }
}

/* ═══════════════════════════════════════════════════════
   AUTO-REFRESH INDICATOR
   ═══════════════════════════════════════════════════════ */
.refresh-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  background: var(--success-soft);
  color: var(--success);
  font-size: var(--fs-micro);
  font-weight: 600;
  animation: fade-in 0.3s var(--ease-out);
}

.refresh-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  animation: pulse-dot 2s ease-in-out infinite;
}

.refresh-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ═══════════════════════════════════════════════════════
   ADMIN STYLES (preserved as-is)
   ═══════════════════════════════════════════════════════ */
.admin-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: calc(100vh - var(--header-h));
}

.admin-sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: var(--space-4);
}

.admin-sidebar h2 { margin: 0 0 var(--space-3); }

.admin-main { padding: var(--space-4); min-width: 0; }

.admin-foot { margin-top: var(--space-5); font-size: var(--fs-small); }
.admin-foot a { color: var(--primary); text-decoration: none; }
.admin-foot a:hover { text-decoration: underline; }

.admin-hint {
  margin-top: var(--space-5);
  font-size: var(--fs-caption);
  color: var(--text-faint);
  line-height: 1.45;
}

.inbox-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }

.inbox-item {
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  cursor: pointer;
  font: inherit;
  color: inherit;
}

.inbox-item:hover { background: var(--hover); }
.inbox-item.active { background: var(--selected); border-color: var(--border); }
.inbox-item .addr { font-size: var(--fs-small); font-weight: 500; word-break: break-all; }

.user-label { font-size: var(--fs-caption); color: var(--text-muted); }

.admin-panel-head { margin-bottom: var(--space-4); }
.admin-panel-head .page-title { font-size: 1.1rem; margin-bottom: 4px; }

.admin-msg-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  max-height: 50vh;
  overflow: auto;
}

.admin-detail { margin-top: var(--space-5); }
.admin-detail .detail-content { padding: var(--space-4) 0; max-width: none; }

.admin-shell { padding: var(--space-4) var(--space-5); max-width: 1280px; margin: 0 auto; }
.admin-panel { min-width: 0; }
.admin-page-title { font-size: 1.15rem; margin-bottom: 4px; }

.admin-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}

.admin-toolbar-left {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  min-width: 0;
}

.admin-search { display: flex; gap: var(--space-2); flex: 1; max-width: 420px; }

.admin-search input {
  flex: 1;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
}

.admin-search input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--focus);
}

.admin-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: auto;
}

.data-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }

.data-table th {
  text-align: left;
  font-size: var(--fs-caption);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--hover);
  white-space: nowrap;
}

.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.table-row-click { cursor: pointer; }
.table-row-click:hover { background: var(--hover); }
.table-row-click:focus-visible { outline: none; box-shadow: inset var(--focus); }

.mono-cell { font-family: var(--mono); font-size: var(--fs-small); word-break: break-all; }

.status-pill {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: var(--radius-full);
  font-size: var(--fs-micro);
  font-weight: 700;
}

.status-pill.is-on { background: var(--success-soft); color: var(--success); }
.status-pill.is-off { background: var(--danger-bg); color: var(--danger); }

.admin-split {
  display: grid;
  grid-template-columns: minmax(280px, 380px) 1fr;
  gap: var(--space-4);
  min-height: calc(100vh - 180px);
}

.admin-msg-col {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: calc(100vh - 180px);
}

.admin-msg-list { overflow-y: auto; flex: 1; }

.admin-read-col {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: 320px;
  overflow: auto;
}

.admin-read-col .detail-content { padding: var(--space-4); max-width: none; }

.admin-msg-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

@media (max-width: 900px) {
  .admin-split { grid-template-columns: 1fr; }
  .admin-msg-col { max-height: 40vh; }
  .admin-read-col:not(.is-open) .detail-placeholder { display: grid; }
  .admin-actions { width: 100%; }
}

/* ═══════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════ */
/* ═══════════════════════════════════════════════════════
   RESPONSIVE DESIGN (TABLET & MOBILE)
   ═══════════════════════════════════════════════════════ */

/* Tablet & Small Desktop (768px – 1024px) */
@media (max-width: 1023px) {
  :root {
    --list-w: 320px;
  }
  .inbox-layout {
    grid-template-columns: var(--list-w) 1fr;
  }
  .detail-content {
    margin: 20px;
    padding: 24px;
  }
}

/* Mobile Devices (< 768px) */
@media (max-width: 767px) {
  :root {
    --header-h: 56px;
    --fs-body: 0.9rem;
  }

  /* Safe Area Support */
  body {
    padding-bottom: env(safe-area-inset-bottom, 0);
  }

  /* View: Access (Login Page) */
  .view-access {
    padding: 16px 14px calc(16px + env(safe-area-inset-bottom, 0));
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    justify-content: center;
  }

  .access-shell {
    width: 100%;
    max-width: 440px;
    margin: 0 auto;
  }

  .access-card {
    padding: 26px 20px 24px;
    border-radius: 20px;
  }

  .access-brand {
    margin-bottom: 20px;
  }

  .access-intro {
    margin-bottom: 20px;
  }

  .access-intro .page-title {
    font-size: 1.45rem;
    line-height: 1.25;
  }

  .access-intro .page-desc {
    font-size: 0.85rem;
  }

  .field-label {
    font-size: 0.8rem;
  }

  /* Input Combo on Mobile */
  .input-combo {
    min-height: 50px;
    border-radius: var(--radius-sm);
  }

  .input-combo input {
    font-size: 16px !important; /* Critical: prevents iOS auto-zoom */
    padding: 12px 10px 12px 14px;
  }

  .domain-picker {
    padding-left: 6px;
  }

  .domain-picker select {
    max-width: 135px;
    font-size: 0.78rem;
    padding: 8px 14px 8px 0;
  }

  .domain-helper {
    font-size: 0.72rem;
  }

  .btn-block {
    min-height: 50px;
    font-size: 0.95rem;
  }

  .access-features {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 18px;
    padding-top: 16px;
  }

  .access-foot {
    font-size: 0.72rem;
    line-height: 1.55;
    padding: 0 10px;
    text-align: center;
    word-break: break-word;
  }

  /* App Header on Mobile */
  .app-header {
    height: var(--header-h);
    padding: 0 12px;
    padding-left: calc(12px + env(safe-area-inset-left, 0));
    padding-right: calc(12px + env(safe-area-inset-right, 0));
  }

  .app-header-left {
    gap: 8px;
  }

  .logo-mark-sm {
    width: 32px;
    height: 32px;
    border-radius: 8px;
  }

  .logo-text {
    font-size: 0.92rem;
  }

  .inbox-addr {
    font-size: 0.72rem;
    max-width: min(38vw, 150px);
  }

  /* Header Actions on Mobile */
  .app-header-actions {
    gap: 6px;
  }

  .app-header-actions .btn-text {
    display: none;
  }

  .app-header-actions .btn {
    min-width: 36px;
    height: 36px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
  }

  .app-header-actions .btn svg {
    width: 18px;
    height: 18px;
  }

  /* Compact Live indicator */
  #auto-refresh-status {
    padding: 4px 8px;
    font-size: 0.68rem;
  }
  #auto-refresh-status span:not(.refresh-dot):not(.refresh-spinner) {
    display: none; /* Only show the dot on narrow mobile screens */
  }

  /* Mobile: Split View Toggle */
  .inbox-layout {
    grid-template-columns: 1fr;
    height: calc(100vh - var(--header-h));
    height: calc(100dvh - var(--header-h));
  }

  .msg-list-pane,
  .msg-detail-pane {
    min-height: calc(100vh - var(--header-h));
    min-height: calc(100dvh - var(--header-h));
    height: calc(100dvh - var(--header-h));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* When reading an email: hide list, show detail */
  .inbox-layout.is-reading .msg-list-pane {
    display: none !important;
  }
  .inbox-layout:not(.is-reading) .msg-detail-pane {
    display: none !important;
  }

  /* Message List Pane */
  .pane-toolbar {
    padding: 12px 14px;
    position: sticky;
    top: 0;
    z-index: 4;
    background: var(--surface-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
  }

  .msg-row {
    padding: 12px 14px;
    grid-template-columns: 36px 1fr auto;
    gap: 10px;
    min-height: 64px;
  }

  .msg-row:active {
    background: var(--surface-selected);
  }

  .msg-avatar {
    width: 36px;
    height: 36px;
    font-size: 0.82rem;
    border-radius: 8px;
  }

  .msg-from {
    font-size: 0.85rem;
  }

  .msg-subject {
    font-size: 0.82rem;
  }

  .msg-snippet {
    font-size: 0.74rem;
  }

  .msg-time {
    font-size: 0.7rem;
  }

  /* Detail Pane on Mobile */
  .detail-content {
    margin: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    padding: 12px 14px calc(36px + env(safe-area-inset-bottom, 0));
    min-height: 100%;
    background: var(--surface-glass);
  }

  .detail-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 0 0 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
  }

  .btn-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px 7px 10px;
    border-radius: var(--radius-full);
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 0.85rem;
    font-weight: 600;
    border: 1px solid rgba(99, 102, 241, 0.15);
  }

  .btn-back:active {
    transform: scale(0.96);
  }

  .btn-back .btn-text {
    display: inline-block;
  }

  .email-heading {
    gap: 10px;
    margin-bottom: 14px;
  }

  .detail-sender-avatar {
    width: 42px;
    height: 42px;
    font-size: 1rem;
    border-radius: 10px;
  }

  .detail-subject {
    font-size: 1.2rem;
    margin-bottom: 12px;
  }

  /* Sender Card */
  .sender-card {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 12px;
    border-radius: var(--radius-sm);
  }

  .sender-identity {
    padding: 0 0 8px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .sender-name {
    font-size: 0.88rem;
  }

  .sender-email {
    font-size: 0.74rem;
    word-break: break-all;
  }

  .sender-card .detail-meta {
    gap: 8px;
    margin: 0;
    padding: 0;
    border: 0;
  }

  .sender-card .detail-meta > div {
    grid-template-columns: 60px 1fr;
    font-size: 0.76rem;
  }

  /* OTP Banner on Mobile */
  .otp-block {
    flex-direction: column;
    align-items: stretch;
    padding: 14px;
    gap: 12px;
    margin: 14px 0;
  }

  .otp-block-text {
    text-align: center;
  }

  .otp-label {
    font-size: 0.72rem;
  }

  .otp-code {
    font-size: 1.7rem;
    letter-spacing: 0.15em;
    padding: 8px 12px;
    text-align: center;
    width: 100%;
    box-sizing: border-box;
  }

  .otp-block .btn {
    width: 100%;
    min-height: 44px;
  }

  /* Email Body on Mobile */
  .email-body-shell {
    margin-top: 14px;
    border-radius: var(--radius-sm);
  }

  .email-body-topline {
    padding: 0 10px;
    font-size: 0.65rem;
  }

  .body-toggle {
    gap: 4px;
  }

  .body-toggle-btn {
    padding: 3px 8px;
    font-size: 0.7rem;
  }

  .email-body-shell .body-html {
    min-height: 120px;
    padding: 16px 12px 24px;
    font-size: 0.88rem;
    line-height: 1.6;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    word-break: break-word;
    overflow-wrap: anywhere;
  }

  .email-body-shell .body-html img {
    max-width: 100% !important;
    height: auto !important;
  }

  .email-body-shell .body-html table {
    max-width: 100% !important;
  }

  .email-body-shell .body-text {
    margin: 12px;
    padding: 12px;
    font-size: 0.8rem;
  }

  /* Empty state on Mobile */
  .empty-state {
    margin-top: 6vh;
    padding: 24px 16px;
  }

  .empty-state .state-title {
    font-size: 1.1rem;
  }

  .empty-state .state-desc {
    font-size: 0.82rem;
  }

  .empty-state .state-actions {
    flex-direction: column;
    width: 100%;
    max-width: 260px;
    gap: 10px;
  }

  .empty-state .state-actions .btn {
    width: 100%;
    min-height: 44px;
  }

  /* Toast on Mobile */
  .toast-root {
    left: 12px;
    right: 12px;
    bottom: calc(14px + env(safe-area-inset-bottom, 0));
    max-width: none;
  }

  .toast {
    font-size: 0.84rem;
    padding: 10px 14px;
  }

  .admin-layout {
    grid-template-columns: 1fr;
  }
}

/* Very Small Mobile (< 360px) */
@media (max-width: 359px) {
  .access-card {
    padding: 20px 14px;
  }
  .domain-picker select {
    max-width: 110px;
  }
  .inbox-addr {
    max-width: 28vw;
  }
  .app-header {
    padding: 0 8px;
  }
  .app-header-actions .btn {
    min-width: 32px;
    height: 32px;
  }
}

@media (min-width: 768px) {
  .detail-toolbar {
    display: none;
  }
}

/* ═══════════════════════════════════════════════════════
   VIEW TRANSITIONS
   ═══════════════════════════════════════════════════════ */
.view-transition-enter {
  animation: view-enter 0.4s var(--ease-out) both;
}

.view-transition-exit {
  animation: view-exit 0.25s var(--ease-out) both;
}

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

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