:root {
  --bg: #0b0f14;
  --bg-elev: #121820;
  --bg-soft: #18212c;
  --line: #2a3544;
  --line-soft: #1e2834;
  --text: #e8eef6;
  --muted: #8b9aab;
  --faint: #5c6b7c;
  --amber: #e8a13a;
  --amber-dim: rgba(232, 161, 58, 0.16);
  --teal: #3ecfbf;
  --teal-dim: rgba(62, 207, 191, 0.14);
  --danger: #e86a5a;
  --radius: 12px;
  --font: "Outfit", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

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

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

body {
  background-image:
    radial-gradient(1200px 600px at 10% -10%, rgba(62, 207, 191, 0.08), transparent 55%),
    radial-gradient(900px 500px at 90% 0%, rgba(232, 161, 58, 0.07), transparent 50%),
    linear-gradient(180deg, #0d131a 0%, var(--bg) 40%);
}

.noise {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 50;
  opacity: 0.04;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.view[hidden],
.panel:not(.is-active) {
  display: none;
}

.view-login.is-active {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 32px 20px;
  animation: fadeUp 0.45s ease both;
}

.login-shell {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  width: min(980px, 100%);
  gap: 0;
  background: linear-gradient(145deg, var(--bg-elev), #0e141c);
  border: 1px solid var(--line);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.login-brand {
  padding: 48px 44px;
  border-right: 1px solid var(--line-soft);
  background:
    linear-gradient(160deg, rgba(62, 207, 191, 0.06), transparent 40%),
    repeating-linear-gradient(
      -12deg,
      transparent,
      transparent 18px,
      rgba(255, 255, 255, 0.015) 18px,
      rgba(255, 255, 255, 0.015) 19px
    );
}

.brand-mark,
.brand-compact {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.brand-name {
  font-size: 1.05rem;
}

.brand-pulse {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 0 0 0 rgba(62, 207, 191, 0.55);
  animation: pulse 2s ease infinite;
}

.brand-pulse.sm {
  width: 8px;
  height: 8px;
}

.login-brand h1 {
  margin: 28px 0 14px;
  font-size: clamp(1.7rem, 3vw, 2.35rem);
  line-height: 1.15;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.login-lede {
  margin: 0 0 28px;
  color: var(--muted);
  line-height: 1.55;
  max-width: 36ch;
}

.login-points {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.login-points li {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 0.95rem;
}

.login-points span {
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--amber);
  background: var(--amber-dim);
  border: 1px solid rgba(232, 161, 58, 0.28);
  border-radius: 6px;
  padding: 4px 8px;
  min-width: 42px;
  text-align: center;
}

.login-card {
  padding: 48px 40px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.login-card h2 {
  margin: 6px 0 24px;
  font-size: 1.45rem;
}

.eyebrow {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--teal);
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.field span {
  font-size: 0.85rem;
  color: var(--muted);
}

.field input,
.address-bar input {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  border-radius: 10px;
  padding: 12px 14px;
  font: 500 0.95rem/1.2 var(--mono);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field input:focus,
.address-bar input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px var(--teal-dim);
}

.hint {
  margin: 14px 0 0;
  font-size: 0.8rem;
  color: var(--faint);
}

.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 14px;
  font: 600 0.9rem/1 var(--font);
  cursor: pointer;
  transition: transform 0.12s, background 0.15s, border-color 0.15s, color 0.15s;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn-block {
  width: 100%;
}

.btn-primary {
  background: linear-gradient(180deg, #f0b04e, var(--amber));
  color: #1a1206;
  border-color: #c9892a;
}

.btn-primary:hover {
  filter: brightness(1.05);
}

.btn-secondary {
  background: var(--teal-dim);
  color: var(--teal);
  border-color: rgba(62, 207, 191, 0.35);
}

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

.btn-ghost:hover {
  color: var(--text);
  border-color: #3d4d61;
}

.btn-ghost.danger:hover {
  color: var(--danger);
  border-color: rgba(232, 106, 90, 0.45);
}

/* APP */
.view-app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  animation: fadeUp 0.35s ease both;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(12, 17, 24, 0.85);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-compact {
  background: none;
  border: 0;
  color: var(--text);
  cursor: pointer;
  padding: 0;
  font: 600 0.95rem var(--font);
}

.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--bg-soft);
  border-radius: 12px;
  border: 1px solid var(--line-soft);
}

.tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: 600 0.85rem var(--font);
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
}

.tab.is-active {
  background: var(--bg-elev);
  color: var(--text);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04);
}

.chip {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.chip-live i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--teal);
  display: inline-block;
  box-shadow: 0 0 8px var(--teal);
}

.panel.is-active {
  display: block;
  flex: 1;
}

.toolbar {
  padding: 18px 20px 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  align-items: center;
  justify-content: space-between;
}

.address-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: min(100%, 420px);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 6px 6px 6px 14px;
}

.address-prefix {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--faint);
}

.address-bar input {
  border: 0;
  background: transparent;
  padding: 8px 4px;
  box-shadow: none;
}

.domain-select {
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 10px;
  font: 500 0.78rem/1.2 var(--mono);
  max-width: 180px;
  cursor: pointer;
}

.address-bar input:focus {
  box-shadow: none;
}

.toolbar-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--muted);
  font-size: 0.88rem;
}

.meta-stat strong {
  color: var(--text);
  font-weight: 600;
}

.poll-hint {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--teal);
  letter-spacing: 0.04em;
}

a.btn-ghost {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.text-link {
  color: var(--teal);
  text-decoration: none;
}

.text-link:hover {
  text-decoration: underline;
}

.modal[hidden] {
  display: none !important;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(5, 8, 12, 0.72);
  backdrop-filter: blur(6px);
}

.modal-card {
  width: min(420px, 100%);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 22px;
  box-shadow: var(--shadow);
}

.modal-card-wide {
  width: min(520px, 100%);
}

.modal-card h3 {
  margin: 0 0 16px;
  font-size: 1.15rem;
}

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

.domain-add-row {
  display: flex;
  gap: 8px;
  margin: 12px 0 4px;
}

.domain-add-row input {
  flex: 1;
  min-width: 0;
  font-family: var(--mono);
  font-size: 0.92rem;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
}

.domain-manage-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  max-height: 240px;
  overflow: auto;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
}

.domain-manage-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line-soft);
  font-family: var(--mono);
  font-size: 0.9rem;
}

.domain-manage-list li:last-child {
  border-bottom: 0;
}

.domain-manage-list .dom-primary {
  font-size: 0.72rem;
  opacity: 0.65;
  margin-left: 6px;
}

.inbox-layout {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 0;
  padding: 8px 20px 28px;
  min-height: calc(100vh - 140px);
}

.filters {
  padding: 12px 12px 12px 0;
  border-right: 1px solid var(--line-soft);
  margin-right: 16px;
}

.filters-title {
  margin: 16px 0 8px;
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--faint);
}

.filters-title:first-child {
  margin-top: 0;
}

.filter {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 0;
  background: transparent;
  color: var(--muted);
  text-align: left;
  padding: 9px 10px;
  border-radius: 8px;
  font: 500 0.9rem var(--font);
  cursor: pointer;
}

.filter em {
  font-style: normal;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--faint);
}

.filter:hover,
.filter.is-active {
  background: var(--bg-soft);
  color: var(--text);
}

.filter.muted {
  color: var(--faint);
}

.mailbox-filters {
  display: grid;
  gap: 4px;
  max-height: 220px;
  overflow: auto;
  padding-right: 4px;
}

.filter-mailbox {
  font-family: var(--mono);
  font-size: 0.72rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.filter-empty {
  margin: 0;
  font-size: 0.8rem;
  color: var(--faint);
  padding: 6px 8px;
}

.mail-to-line {
  display: block !important;
  margin-top: 2px;
  font-family: var(--mono);
  font-size: 0.72rem !important;
  color: var(--teal) !important;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mail-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.mail-row {
  display: grid;
  grid-template-columns: 12px 180px 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 14px 16px;
  border: 1px solid var(--line-soft);
  background: rgba(18, 24, 32, 0.72);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.12s;
  animation: fadeUp 0.4s ease both;
}

.mail-row:nth-child(1) { animation-delay: 0.02s; }
.mail-row:nth-child(2) { animation-delay: 0.05s; }
.mail-row:nth-child(3) { animation-delay: 0.08s; }
.mail-row:nth-child(4) { animation-delay: 0.11s; }
.mail-row:nth-child(5) { animation-delay: 0.14s; }
.mail-row:nth-child(6) { animation-delay: 0.17s; }

.mail-row:hover,
.mail-row:focus-visible {
  outline: none;
  border-color: rgba(62, 207, 191, 0.35);
  background: var(--bg-elev);
  transform: translateX(2px);
}

.mail-row.unread {
  border-color: rgba(232, 161, 58, 0.28);
  background: linear-gradient(90deg, var(--amber-dim), rgba(18, 24, 32, 0.85) 28%);
}

.mail-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: transparent;
}

.mail-row.unread .mail-dot {
  background: var(--amber);
  box-shadow: 0 0 10px rgba(232, 161, 58, 0.55);
}

.mail-from {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.from-name {
  font-weight: 600;
  font-size: 0.92rem;
}

.from-addr {
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mail-body-preview {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.mail-body-preview strong {
  font-size: 0.92rem;
  font-weight: 600;
}

.mail-body-preview span {
  color: var(--muted);
  font-size: 0.85rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mail-row time {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--faint);
  white-space: nowrap;
}

/* READER */
.reader {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: calc(100vh - 64px);
}

.reader-side {
  padding: 20px;
  border-right: 1px solid var(--line-soft);
  background: rgba(14, 19, 26, 0.7);
}

.reader-side .back {
  margin-bottom: 18px;
}

.otp-card {
  background: linear-gradient(160deg, rgba(232, 161, 58, 0.14), rgba(18, 24, 32, 0.9));
  border: 1px solid rgba(232, 161, 58, 0.3);
  border-radius: 14px;
  padding: 18px;
  margin-bottom: 20px;
}

.otp-code {
  margin: 10px 0 16px;
  font-family: var(--mono);
  font-size: 2rem;
  font-weight: 600;
  letter-spacing: 0.28em;
  color: var(--amber);
}

.meta-dl {
  margin: 0;
  display: grid;
  gap: 14px;
}

.meta-dl div {
  display: grid;
  gap: 4px;
}

.meta-dl dt {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint);
}

.meta-dl dd {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
  word-break: break-all;
  font-family: var(--mono);
}

.reader-main {
  padding: 24px 28px 40px;
}

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

.reader-head h2 {
  margin: 0;
  font-size: 1.35rem;
  letter-spacing: -0.02em;
}

.reader-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mail-frame {
  background: #f4f1ea;
  color: #1c1915;
  border-radius: 14px;
  padding: 8px;
  border: 1px solid #d9d2c4;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.5);
  min-height: 420px;
}

.mail-sandbox {
  display: block;
  width: 100%;
  min-height: 420px;
  border: 0;
  border-radius: 10px;
  background: #fff;
}

.mail-plain {
  margin: 0;
  padding: 24px;
  white-space: pre-wrap;
  font-family: var(--mono);
  font-size: 0.85rem;
  color: #1c1915;
  background: #fff;
  border-radius: 10px;
  min-height: 360px;
}

.fake-email {
  background: #fff;
  border-radius: 10px;
  padding: 36px 32px;
  max-width: 560px;
  margin: 0 auto;
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1.55;
}

.fe-logo {
  font-family: Helvetica, Arial, sans-serif;
  font-weight: 700;
  font-size: 1.35rem;
  color: #0866ff;
  margin-bottom: 22px;
}

.fake-email h3 {
  margin: 0 0 16px;
  font-size: 1.25rem;
}

.fe-code {
  font-family: var(--mono);
  font-size: 1.8rem;
  font-weight: 600;
  letter-spacing: 0.25em;
  text-align: center;
  background: #f0f2f5;
  border-radius: 10px;
  padding: 16px;
  color: #1c1e21;
}

.fe-muted,
.fe-foot {
  color: #65676b;
  font-size: 0.92rem;
}

.fe-foot .mono {
  font-family: var(--mono);
  font-size: 0.8rem;
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 12px 18px;
  border-radius: 999px;
  font-size: 0.88rem;
  z-index: 60;
  box-shadow: var(--shadow);
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
}

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

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(62, 207, 191, 0.5); }
  70% { box-shadow: 0 0 0 10px rgba(62, 207, 191, 0); }
  100% { box-shadow: 0 0 0 0 rgba(62, 207, 191, 0); }
}

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

@media (max-width: 900px) {
  .login-shell {
    grid-template-columns: 1fr;
  }

  .login-brand {
    border-right: 0;
    border-bottom: 1px solid var(--line-soft);
    padding: 32px 28px;
  }

  .login-card {
    padding: 32px 28px;
  }

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

  .filters {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    border-right: 0;
    margin-right: 0;
    padding: 0 0 12px;
    border-bottom: 1px solid var(--line-soft);
    margin-bottom: 12px;
  }

  .filters-title {
    width: 100%;
    margin: 8px 0 4px;
  }

  .filter {
    width: auto;
    min-width: 110px;
  }

  .mail-row {
    grid-template-columns: 12px 1fr auto;
    grid-template-rows: auto auto;
  }

  .mail-from {
    grid-column: 2;
  }

  .mail-body-preview {
    grid-column: 2 / -1;
  }

  .mail-row time {
    grid-column: 3;
    grid-row: 1;
  }

  .reader {
    grid-template-columns: 1fr;
  }

  .reader-side {
    border-right: 0;
    border-bottom: 1px solid var(--line-soft);
  }

  .chip-live {
    display: none;
  }
}
