:root {
  --bg: #070a12;
  --panel: rgba(15, 20, 34, 0.86);
  --panel-solid: #111727;
  --line: rgba(148, 163, 184, 0.15);
  --text: #eef2ff;
  --muted: #8994aa;
  --purple: #8b5cf6;
  --purple-light: #c4b5fd;
  --cyan: #22d3ee;
  --green: #34d399;
  --orange: #fb923c;
  --red: #fb7185;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--bg); }

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--text);
  background:
    radial-gradient(circle at 20% -10%, rgba(124, 58, 237, 0.16), transparent 38%),
    radial-gradient(circle at 100% 30%, rgba(6, 182, 212, 0.1), transparent 32%),
    var(--bg);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input, select { font: inherit; }
button { color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; margin: -1px; padding: 0; border: 0; clip: rect(0, 0, 0, 0); white-space: nowrap; }

.ambient {
  position: fixed;
  z-index: -1;
  width: 340px;
  height: 340px;
  border-radius: 999px;
  filter: blur(110px);
  opacity: 0.12;
  pointer-events: none;
}
.ambient-a { top: 18%; left: -160px; background: var(--purple); }
.ambient-b { right: -150px; bottom: 10%; background: var(--cyan); }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px max(22px, calc((100vw - 1240px) / 2));
  border-bottom: 1px solid var(--line);
  background: rgba(7, 10, 18, 0.78);
  backdrop-filter: blur(24px);
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark, .login-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 13px;
  color: white;
  background: linear-gradient(135deg, var(--purple), #4f46e5 55%, #0891b2);
  box-shadow: 0 12px 30px rgba(124, 58, 237, 0.32);
  font: 800 1.1rem "JetBrains Mono", monospace;
}
.brand h1 { margin: 0; font-size: 1rem; letter-spacing: -0.02em; }
.brand p { margin: 3px 0 0; color: var(--muted); font-size: 0.72rem; }

.top-actions { display: flex; align-items: center; gap: 9px; }
.live-state {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-right: 4px;
  color: var(--muted);
  font-size: 0.76rem;
}
.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 5px rgba(52, 211, 153, 0.08);
}

.shell { width: min(1240px, calc(100% - 36px)); margin: 0 auto; padding: 44px 0 64px; }
.hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
  margin-bottom: 26px;
}
.eyebrow {
  display: block;
  margin-bottom: 9px;
  color: var(--purple-light);
  font: 700 0.66rem "JetBrains Mono", monospace;
  letter-spacing: 0.17em;
}
.hero h2 {
  max-width: 760px;
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 3.4rem);
  line-height: 1.04;
  letter-spacing: -0.055em;
}
.hero p { max-width: 680px; margin: 16px 0 0; color: var(--muted); line-height: 1.7; font-size: 0.94rem; }

.auto-refresh {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.78rem;
  cursor: pointer;
}
.auto-refresh input { position: absolute; width: 1px; height: 1px; min-height: 0; overflow: hidden; opacity: 0; }
.auto-refresh span {
  position: relative;
  width: 38px;
  height: 22px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #151b2a;
  transition: 0.2s ease;
}
.auto-refresh span::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--muted);
  transition: 0.2s ease;
}
.auto-refresh input:checked + span { background: rgba(139, 92, 246, 0.28); border-color: rgba(139, 92, 246, 0.55); }
.auto-refresh input:checked + span::after { transform: translateX(16px); background: var(--purple-light); }

.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 13px; margin-bottom: 14px; }
.stat-card, .panel {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
}
.stat-card { position: relative; overflow: hidden; min-height: 145px; padding: 21px; border-radius: 17px; }
.stat-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--accent);
}
.stat-card::after {
  content: "";
  position: absolute;
  top: -50px;
  right: -40px;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: var(--accent);
  filter: blur(55px);
  opacity: 0.13;
}
.accent-purple { --accent: var(--purple); }
.accent-green { --accent: var(--green); }
.accent-cyan { --accent: var(--cyan); }
.accent-orange { --accent: var(--orange); }
.stat-card span { color: var(--muted); font-size: 0.75rem; font-weight: 600; }
.stat-card strong { display: block; margin: 16px 0 9px; font: 700 2rem "JetBrains Mono", monospace; letter-spacing: -0.06em; }
.stat-card small { color: #657086; font-size: 0.7rem; }

.panel { margin-top: 14px; border-radius: 19px; }
.address-panel { margin: 0 0 14px; padding: 26px; border-color: rgba(124, 58, 237, 0.25); background: rgba(13, 14, 34, 0.9); }
.address-heading { align-items: center; margin-bottom: 18px; }
.saved-address-count { padding: 6px 10px; border-radius: 999px; color: var(--muted); background: rgba(139, 92, 246, 0.09); font-size: 0.68rem; }
.address-builder { display: grid; grid-template-columns: minmax(0, 1fr) minmax(190px, 0.34fr); gap: 10px; }
.address-builder input, .address-builder select { min-height: 48px; border-color: rgba(139, 92, 246, 0.2); background: rgba(27, 28, 51, 0.88); font-size: 0.82rem; font-weight: 600; }
.generated-address { display: flex; align-items: center; min-height: 58px; margin-top: 14px; padding: 0 20px; border: 2px dashed rgba(139, 92, 246, 0.45); border-radius: 13px; color: #8b95ab; background: rgba(76, 29, 149, 0.09); word-break: break-all; font-size: clamp(0.88rem, 2vw, 1.12rem); font-weight: 700; font-style: italic; transition: all .3s ease; }
.generated-address.ready { color: #e9d5ff; font-style: normal; letter-spacing: 0.02em; border-color: rgba(139, 92, 246, 0.7); background: rgba(76, 29, 149, 0.18); box-shadow: 0 0 20px rgba(139, 92, 246, 0.12), inset 0 0 12px rgba(139, 92, 246, 0.06); }
.address-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; margin-top: 16px; }
.address-button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 42px; padding: 0 13px; border: 0; border-radius: 11px; color: white; cursor: pointer; font-size: 0.76rem; font-weight: 700; transition: transform .18s ease, filter .18s ease; }
.address-button:hover { transform: translateY(-1px); filter: brightness(1.1); }
.address-button svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.address-button.generate { background: linear-gradient(135deg, #7c3aed, #a855f7); }
.address-button.copy { background: linear-gradient(135deg, #059669, #10b981); }
.address-button.refresh { background: linear-gradient(135deg, #0891b2, #06b6d4); }
.address-button.save { background: linear-gradient(135deg, #d97706, #f59e0b); }
.address-status { display: flex; align-items: center; gap: 8px; margin-top: 12px; color: #6f7a91; font-size: 0.7rem; }
.address-status > span:first-child { width: 7px; height: 7px; border-radius: 50%; background: #10b981; box-shadow: 0 0 0 4px rgba(16, 185, 129, .08); }
.filters-panel { padding: 21px; }
.panel-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 19px; }
.panel-heading .eyebrow { margin-bottom: 5px; }
.panel-heading h3 { margin: 0; font-size: 1rem; }
.text-button { padding: 0; border: 0; color: var(--purple-light); background: transparent; font-size: 0.75rem; cursor: pointer; }
.text-button:hover { color: white; }

.filter-grid { display: grid; grid-template-columns: 1.35fr 1.05fr 0.85fr 0.8fr; gap: 12px; }
.filter-grid label > span:first-child, .login-card label > span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 600;
}
input, select {
  width: 100%;
  min-height: 42px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  color: var(--text);
  background: rgba(5, 9, 17, 0.7);
  transition: border-color 0.2s, box-shadow 0.2s;
  font-size: 0.78rem;
}
input:focus, select:focus { border-color: rgba(139, 92, 246, 0.7); box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.11); }
input::placeholder { color: #4e596d; }
select option { background: #111727; }
.check-row {
  display: flex !important;
  align-items: center;
  min-height: 42px;
  gap: 9px;
  margin: 0 !important;
  color: var(--text) !important;
  font-size: 0.75rem !important;
  font-weight: 500 !important;
}
.check-row input { width: 16px; min-height: 16px; accent-color: var(--purple); }

.inbox-panel { min-height: 380px; padding: 21px; }
.inbox-heading { align-items: center; }
.inbox-heading-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.result-count { padding: 6px 10px; border-radius: 999px; color: var(--muted); background: rgba(148, 163, 184, 0.08); font-size: 0.7rem; }
.message-list { display: grid; gap: 8px; }
.message-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(100px, 0.28fr) auto auto;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px 15px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.025);
  transition: 0.18s ease;
}
.message-item:hover, .message-item.expanded { border-color: rgba(139, 92, 246, 0.3); background: rgba(139, 92, 246, 0.055); }
.message-click-zone { display: grid; grid-template-columns: minmax(180px, .9fr) minmax(250px, 1.5fr); align-items: center; gap: 18px; min-width: 0; border-radius: 9px; outline: none; cursor: pointer; }
.message-click-zone:focus-visible { box-shadow: 0 0 0 3px rgba(139, 92, 246, .18); }
.recipient { min-width: 0; }
.recipient strong, .message-main strong { display: block; overflow: hidden; color: #e6eafe; text-overflow: ellipsis; white-space: nowrap; font-size: 0.78rem; }
.recipient span, .message-main span { display: block; overflow: hidden; margin-top: 4px; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; font-size: 0.67rem; }
.domain-tag { color: var(--cyan) !important; }
.otp-code {
  justify-self: start;
  padding: 7px 10px;
  border: 1px solid rgba(52, 211, 153, 0.25);
  border-radius: 9px;
  color: #a7f3d0;
  background: rgba(52, 211, 153, 0.08);
  font: 700 0.82rem "JetBrains Mono", monospace;
  letter-spacing: 0.08em;
}
.no-otp { color: #4d586c; font-size: 0.68rem; }
.message-time { color: #626d82; font-size: 0.67rem; white-space: nowrap; }
.delete-message-button { min-height: 34px; padding: 0 11px; border: 1px solid rgba(251, 113, 133, .22); border-radius: 9px; color: #fda4af; background: rgba(127, 29, 29, .13); cursor: pointer; font-size: .68rem; font-weight: 700; }
.delete-message-button:hover { border-color: rgba(251, 113, 133, .5); background: rgba(127, 29, 29, .28); }
.inline-detail-loading, .inline-message-detail { grid-column: 1 / -1; }
.inline-detail-loading { padding: 18px 4px 5px; border-top: 1px solid var(--line); color: var(--muted); font-size: .72rem; }
.inline-message-detail { min-width: 0; padding: 18px 3px 3px; border-top: 1px solid rgba(139, 92, 246, .2); }
.inline-detail-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 15px; }
.inline-detail-header strong { display: block; color: #eef2ff; font-size: .88rem; }
.inline-detail-header div > span { display: block; margin-top: 5px; color: var(--muted); font-size: .69rem; }
.inline-message-body { min-height: 130px; max-height: 460px; }

.button {
  min-height: 37px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: 0.18s ease;
}
.button:hover { transform: translateY(-1px); filter: brightness(1.1); }
.button.ghost { border-color: var(--line); background: rgba(148, 163, 184, 0.05); }
.button.primary { color: white; background: linear-gradient(135deg, #7c3aed, #4f46e5); box-shadow: 0 10px 25px rgba(79, 70, 229, 0.2); }
.button.full { width: 100%; min-height: 44px; }
.danger-text { color: var(--red); }

.empty-state, .loading-state { padding: 68px 20px; text-align: center; color: var(--muted); }
.empty-icon { display: grid; place-items: center; width: 52px; height: 52px; margin: 0 auto 14px; border: 1px solid var(--line); border-radius: 15px; color: var(--purple-light); font: 700 1rem "JetBrains Mono", monospace; }
.empty-state h4 { margin: 0 0 7px; color: var(--text); }
.empty-state p { margin: 0; font-size: 0.78rem; }
.spinner { display: inline-block; width: 16px; height: 16px; margin-right: 9px; vertical-align: -3px; border: 2px solid rgba(255,255,255,.15); border-top-color: var(--purple-light); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.login-layer, .modal-layer {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(3, 5, 10, 0.78);
  backdrop-filter: blur(18px);
}
.login-layer[hidden], .modal-layer[hidden] { display: none; }
.login-card, .modal-card {
  width: min(100%, 440px);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 21px;
  background: #101625;
  box-shadow: 0 35px 100px rgba(0,0,0,.55);
}
.login-mark { margin-bottom: 24px; }
.login-card h2 { margin: 0; font-size: 1.5rem; letter-spacing: -0.04em; }
.login-card p { margin: 10px 0 22px; color: var(--muted); line-height: 1.6; font-size: 0.78rem; }
.login-card code { color: var(--purple-light); }
.login-card label { display: block; margin-bottom: 14px; }
.login-card input { min-height: 45px; }
.form-error { min-height: 18px; margin-top: 12px; color: var(--red); text-align: center; font-size: 0.72rem; }

.modal-card { position: relative; width: min(100%, 760px); max-height: min(88vh, 840px); overflow: auto; }
.modal-close { position: absolute; top: 15px; right: 16px; width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 9px; color: var(--muted); background: rgba(255,255,255,.04); cursor: pointer; font-size: 1.2rem; }
.detail-meta { display: flex; align-items: center; gap: 10px; padding-right: 45px; }
.recipient-pill { max-width: 70%; overflow: hidden; padding: 6px 9px; border-radius: 8px; color: var(--cyan); background: rgba(34,211,238,.08); text-overflow: ellipsis; white-space: nowrap; font-size: .68rem; }
.detail-meta time { color: var(--muted); font-size: .68rem; }
.modal-card h2 { margin: 18px 0 8px; font-size: 1.35rem; letter-spacing: -.035em; }
.detail-from { margin: 0 0 20px; color: var(--muted); font-size: .75rem; }
.detail-otp { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 16px; padding: 14px 16px; border: 1px solid rgba(52,211,153,.22); border-radius: 12px; background: rgba(52,211,153,.065); }
.detail-otp span { color: #8ca49e; font-size: .72rem; }
.detail-otp button { border: 0; color: #a7f3d0; background: transparent; cursor: pointer; font: 700 1.15rem "JetBrains Mono", monospace; letter-spacing: .12em; }
.message-body { min-height: 190px; max-height: 400px; overflow: auto; margin: 0; padding: 17px; border: 1px solid var(--line); border-radius: 12px; color: #cbd3e6; background: rgba(4,7,13,.65); white-space: pre-wrap; word-break: break-word; font: 400 .78rem/1.72 Inter, sans-serif; }
.modal-actions { display: flex; justify-content: space-between; gap: 10px; margin-top: 18px; }

.toast { position: fixed; z-index: 200; right: 20px; bottom: 20px; max-width: 330px; padding: 12px 15px; border: 1px solid rgba(52,211,153,.25); border-radius: 11px; color: #d1fae5; background: rgba(6,78,59,.9); box-shadow: var(--shadow); transform: translateY(140%); opacity: 0; transition: .25s ease; font-size: .75rem; }
.toast.show { transform: translateY(0); opacity: 1; }
.toast.error { border-color: rgba(251,113,133,.3); color: #ffe4e6; background: rgba(127,29,29,.92); }

@media (max-width: 960px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .filter-grid { grid-template-columns: repeat(2, 1fr); }
  .message-item { grid-template-columns: minmax(0, 1fr) auto auto; }
  .message-click-zone { grid-template-columns: minmax(150px, .8fr) minmax(210px, 1.4fr); }
  .message-time { display: none; }
}

@media (max-width: 680px) {
  .topbar { padding: 12px 14px; }
  .brand p, .live-state, .top-actions .danger-text { display: none; }
  .shell { width: min(100% - 22px, 1240px); padding-top: 28px; }
  .stats-grid, .filter-grid { grid-template-columns: 1fr; }
  .address-panel { padding: 17px; }
  .address-builder { grid-template-columns: 1fr; }
  .address-actions { grid-template-columns: repeat(2, 1fr); }
  .stat-card { min-height: 126px; }
  .message-item { grid-template-columns: minmax(0, 1fr) auto; gap: 10px; }
  .message-click-zone { grid-column: 1 / -1; grid-template-columns: 1fr; gap: 8px; }
  .otp-code, .no-otp { grid-column: 1; grid-row: 2; }
  .delete-message-button { grid-column: 2; grid-row: 2; }
  .inbox-heading { align-items: flex-start; flex-direction: column; }
  .inbox-heading-actions { width: 100%; justify-content: flex-start; }
  .inbox-heading-actions .auto-refresh { width: 100%; }
  .inline-detail-header { flex-direction: column-reverse; gap: 10px; }
  .inline-detail-header .recipient-pill { max-width: 100%; }
  .filters-panel, .inbox-panel { padding: 16px; }
  .login-card, .modal-card { padding: 21px; }
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions .button { width: 100%; }
}
