/* ── Reset & Base ────────────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #FAFAFA;
  --surface: #FFFFFF;
  --border: #E8E8E8;
  --border-hover: #D0D0D0;
  --text: #1A1A1A;
  --text-secondary: #666666;
  --text-tertiary: #999999;
  --accent: #FF6B35;
  --accent-light: #FFF3ED;
  --accent-hover: #E85A24;
  --success: #10B981;
  --success-light: #ECFDF5;
  --tag-bg: #F3F4F6;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.08);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* ── Layout ──────────────────────────────────────────────────── */
.container { max-width: 720px; margin: 0 auto; padding: 0 24px; }
.container-wide { max-width: 960px; margin: 0 auto; padding: 0 24px; }

/* ── Nav ─────────────────────────────────────────────────────── */
nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.logo {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.3px;
}

.logo span { color: var(--accent); }

nav a {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 500;
}

nav a:hover { color: var(--text); }

/* ── Hero ────────────────────────────────────────────────────── */
.hero {
  text-align: center;
  padding: 80px 0 60px;
}

.hero h1 {
  font-size: 44px;
  font-weight: 800;
  letter-spacing: -1.5px;
  line-height: 1.1;
  margin-bottom: 20px;
}

.hero h1 em {
  font-style: normal;
  color: var(--accent);
}

.hero p {
  font-size: 18px;
  color: var(--text-secondary);
  max-width: 480px;
  margin: 0 auto 40px;
  line-height: 1.7;
}

/* ── Steps ───────────────────────────────────────────────────── */
.steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-bottom: 60px;
}

.step {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
  text-align: center;
}

.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 14px;
}

.step h3 {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 8px;
}

.step p {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ── Register Card ───────────────────────────────────────────── */
.register-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
  max-width: 480px;
  margin: 0 auto 80px;
  box-shadow: var(--shadow);
}

.register-card h2 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 6px;
}

.register-card .subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.input-group {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.input-group input {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-family: var(--font);
  outline: none;
  transition: border-color 0.15s;
  background: var(--bg);
}

.input-group input:focus {
  border-color: var(--accent);
  background: var(--surface);
}

.input-group input::placeholder { color: var(--text-tertiary); }

.btn {
  padding: 12px 24px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  white-space: nowrap;
}

.btn:hover { background: var(--accent-hover); }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.result {
  display: none;
  margin-top: 20px;
  padding: 20px;
  background: var(--success-light);
  border-radius: var(--radius-sm);
  border: 1px solid #D1FAE5;
}

.result.show { display: block; }

.result h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--success);
  margin-bottom: 10px;
}

.result .vault-email {
  font-family: var(--mono);
  font-size: 13px;
  background: white;
  padding: 10px 14px;
  border-radius: 6px;
  border: 1px solid #D1FAE5;
  word-break: break-all;
  margin-bottom: 10px;
  user-select: all;
}

.result .vault-link {
  font-size: 13px;
  color: var(--text-secondary);
}

.result .vault-link a { font-weight: 600; }

/* ── Footer ──────────────────────────────────────────────────── */
footer {
  text-align: center;
  padding: 40px 0;
  font-size: 13px;
  color: var(--text-tertiary);
  border-top: 1px solid var(--border);
}

/* ── Vault Page ──────────────────────────────────────────────── */
.vault-header {
  padding: 40px 0 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

.vault-header h1 {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 6px;
}

.vault-header .vault-addr {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-tertiary);
  background: var(--tag-bg);
  display: inline-block;
  padding: 4px 10px;
  border-radius: 6px;
}

/* ── Toolbar ─────────────────────────────────────────────────── */
.toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  align-items: center;
}

.search-input {
  flex: 1;
  min-width: 200px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: var(--font);
  outline: none;
  background: var(--surface);
  transition: border-color 0.15s;
}

.search-input:focus { border-color: var(--accent); }
.search-input::placeholder { color: var(--text-tertiary); }

.filter-tabs {
  display: flex;
  gap: 4px;
  background: var(--tag-bg);
  padding: 4px;
  border-radius: var(--radius-sm);
}

.filter-tab {
  padding: 6px 14px;
  border: none;
  background: transparent;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}

.filter-tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.filter-tab:hover:not(.active) { color: var(--text); }

/* ── Email List ──────────────────────────────────────────────── */
.email-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.email-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 22px;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.email-card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow);
}

.email-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 6px;
  gap: 12px;
}

.email-subject {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.4;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.email-date {
  font-size: 12px;
  color: var(--text-tertiary);
  white-space: nowrap;
  flex-shrink: 0;
}

.email-from {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.email-preview {
  font-size: 13px;
  color: var(--text-tertiary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.email-tags {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.tag {
  font-size: 11px;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: 4px;
  background: var(--tag-bg);
  color: var(--text-secondary);
}

.tag.attachment {
  background: var(--accent-light);
  color: var(--accent);
}

.tag.arweave {
  background: #EDE9FE;
  color: #7C3AED;
}

/* ── Email Detail Modal ──────────────────────────────────────── */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 100;
  backdrop-filter: blur(2px);
}

.modal-backdrop.show { display: flex; align-items: center; justify-content: center; }

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  width: 90vw;
  max-width: 680px;
  max-height: 85vh;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
  display: flex;
  flex-direction: column;
}

.modal-header {
  padding: 24px 28px 16px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 8px;
}

.modal-meta {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--text-secondary);
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  border: none;
  background: var(--tag-bg);
  border-radius: 6px;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: background 0.15s;
}

.modal-close:hover { background: var(--border); }

.modal-body {
  padding: 24px 28px;
  overflow-y: auto;
  flex: 1;
  font-size: 14px;
  line-height: 1.7;
}

.modal-body .email-html-content img { max-width: 100%; height: auto; border-radius: 6px; }

.modal-attachments {
  padding: 16px 28px 24px;
  border-top: 1px solid var(--border);
}

.modal-attachments h3 {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-tertiary);
  margin-bottom: 10px;
}

.attachment-list {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.attachment-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: var(--tag-bg);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text);
  text-decoration: none;
  transition: background 0.15s;
}

.attachment-item:hover { background: var(--border); color: var(--text); }

.attachment-icon {
  width: 16px;
  height: 16px;
  opacity: 0.5;
}

/* ── Empty State ─────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-tertiary);
}

.empty-state .icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.3;
}

.empty-state h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.empty-state p { font-size: 14px; }

.empty-state .vault-email-hint {
  font-family: var(--mono);
  font-size: 13px;
  background: var(--tag-bg);
  display: inline-block;
  padding: 8px 14px;
  border-radius: 6px;
  margin-top: 16px;
  user-select: all;
}

/* ── Stats Bar ───────────────────────────────────────────────── */
.stats-bar {
  display: flex;
  gap: 24px;
  margin-bottom: 24px;
}

.stat {
  display: flex;
  flex-direction: column;
}

.stat-value {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.stat-label {
  font-size: 12px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ── Loading ─────────────────────────────────────────────────── */
.loading {
  text-align: center;
  padding: 60px 0;
  color: var(--text-tertiary);
}

.spinner {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-bottom: 12px;
}

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

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 640px) {
  .hero h1 { font-size: 32px; }
  .hero p { font-size: 16px; }
  .steps { grid-template-columns: 1fr; }
  .input-group { flex-direction: column; }
  .register-card { padding: 28px; }
  .container-wide { padding: 0 16px; }
  .toolbar { flex-direction: column; }
  .stats-bar { gap: 16px; }
  .modal { width: 96vw; max-height: 90vh; }
}
