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

:root {
  --bg: #000000;
  --surface: #0d0d0d;
  --surface2: #171717;
  --border: #252525;
  --border-hover: #3a3a3a;
  --text: #f4f4f4;
  --text-muted: #b5b5b5;
  --text-dim: #878787;
  --primary: #f5c03d;
  --primary-light: #ffd76c;
  --primary-glow: rgba(245, 192, 61, 0.2);
  --accent: #e6a700;
  --success: #22c55e;
  --danger: #ef4444;
  --danger-surface: rgba(239,68,68,0.12);
  --radius: 18px;
  --radius-sm: 8px;
  --shadow: 0 12px 36px rgba(0, 0, 0, 0.6);
}

html[data-theme='dark'] {
  --bg: #070b1a;
  --surface: #0f172a;
  --surface2: #172036;
  --border: rgba(148, 163, 184, 0.22);
  --border-hover: rgba(148, 163, 184, 0.42);
  --text: #e5ecff;
  --text-muted: #a1b0d8;
  --text-dim: #7283ad;
  --primary: #2563eb;
  --primary-light: #60a5fa;
  --primary-glow: rgba(37, 99, 235, 0.35);
  --accent: #14b8a6;
  --shadow: 0 20px 60px rgba(2, 8, 23, 0.5);
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #eef4ff;
    --surface: #ffffff;
    --surface2: #edf3ff;
    --border: rgba(37, 99, 235, 0.16);
    --border-hover: rgba(37, 99, 235, 0.34);
    --text: #0f172a;
    --text-muted: #42567e;
    --text-dim: #6b7da3;
    --primary: #2563eb;
    --primary-light: #1d4ed8;
    --primary-glow: rgba(37, 99, 235, 0.22);
    --accent: #0d9488;
    --shadow: 0 18px 44px rgba(15, 23, 42, 0.12);
  }
}

html[data-theme='light'] {
  --bg: #eef4ff;
  --surface: #ffffff;
  --surface2: #edf3ff;
  --border: rgba(37, 99, 235, 0.16);
  --border-hover: rgba(37, 99, 235, 0.34);
  --text: #0f172a;
  --text-muted: #42567e;
  --text-dim: #6b7da3;
  --primary: #2563eb;
  --primary-light: #1d4ed8;
  --primary-glow: rgba(37, 99, 235, 0.22);
  --accent: #0d9488;
  --shadow: 0 18px 44px rgba(15, 23, 42, 0.12);
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  font-size: 14px;
  line-height: 1.6;
}

/* ─────────────────────────────────────────────
   BACKGROUND ORBS
───────────────────────────────────────────── */
.bg-orbs,
.orb { display: none; }

@keyframes float {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-30px) scale(1.05); }
}
.orb-3 { animation: float3 10s ease-in-out infinite; }
@keyframes float3 {
  0%, 100% { transform: translate(-50%,-50%) scale(1); }
  50% { transform: translate(-50%,-55%) scale(1.08); }
}

/* ─────────────────────────────────────────────
   HEADER
───────────────────────────────────────────── */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: transparent;
  border-bottom: none;
  padding: 14px 32px;
}
.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.header-moon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.2s, border-color 0.2s;
}
.header-moon:hover {
  background: var(--surface2);
  border-color: var(--border-hover);
}
.header-moon:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
#headerLeadIcon svg {
  display: block;
}
.header-right { display: flex; align-items: center; gap: 10px; }
.lang-select {
  background: #f5f5f5;
  color: #1a1a1a;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 9px 34px 9px 12px;
  font-size: 14px;
}

.theme-toggle, .stats-badge { display: none; }

/* ─────────────────────────────────────────────
   SCREENS
───────────────────────────────────────────── */
.screen { position: relative; z-index: 1; }
.screen.hidden { display: none; }
.screen.active { display: block; }

/* ─────────────────────────────────────────────
   SETUP SCREEN
───────────────────────────────────────────── */
.hero {
  text-align: center;
  padding: 26px 24px 20px;
}
.brand-mark {
  width: 180px;
  height: 96px;
  margin: 0 auto 12px;
  border: 2px solid #bdbdbd;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
}
.brand-logo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: grayscale(1) contrast(1.12) brightness(0.95);
}
.hero-title {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 0;
  margin-bottom: 6px;
  animation: none;
}
.hero-sub { color: var(--text-muted); font-size: 1.1rem; max-width: 480px; margin: 0 auto; }
.hero-sub {
  font-size: 14px;
  animation: none;
}

/* Setup Card */
.card {
  background: #0a0a0a;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  backdrop-filter: none;
}
.setup-card {
  max-width: 500px;
  margin: 0 auto 16px;
  padding: 24px;
  position: relative;
  overflow: hidden;
  animation: none;
}
.setup-card::before {
  display: none;
}

/* Tabs */
.card-tabs {
  display: flex;
  gap: 8px;
  background: transparent;
  border-radius: 0;
  padding: 0;
  margin-bottom: 16px;
}
.tab-btn {
  flex: 1;
  padding: 9px;
  border: 1px solid #3a3a3a;
  border-radius: 8px;
  background: #151515;
  color: #c9c9c9;
  font-size: 13px;
  cursor: pointer;
}
.tab-btn.active {
  background: #1f1f1f;
  color: #fff;
  border-color: #4d4d4d;
}

.tab-content.hidden { display: none; }
.tab-content.fade-in { animation: fadeSlideIn 0.28s ease; }
@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Input Row */
.input-row {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 10px;
  margin-bottom: 16px;
}
.input-row .input-group:first-child,
.input-row .input-group:last-child {
  flex: 0 1 220px;
  max-width: 220px;
}

.input-group { display: flex; flex-direction: column; gap: 6px; flex: 1; }
.input-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  text-align: center;
}

.input-field {
  background: #171717;
  border: 1px solid #2d2d2d;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit; font-size: 14px;
  padding: 10px 14px;
  width: 100%;
  text-align: center;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}
.input-field:focus {
  border-color: #555;
  box-shadow: none;
}
.input-field::placeholder { color: var(--text-dim); }
.select-field { cursor: pointer; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238888aa' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px;
}

.at-symbol {
  color: var(--text-muted); font-size: 18px; font-weight: 700;
  padding-bottom: 10px;
  flex-shrink: 0;
  text-align: center;
}

/* Address preview */
.address-preview {
  display: flex; align-items: center; gap: 8px;
  background: #101010;
  border: 1px solid #242424;
  border-radius: var(--radius-sm); padding: 10px 14px; margin-bottom: 20px;
}
.preview-label { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; flex-shrink: 0; }
.preview-addr { font-family: 'Courier New', monospace; color: var(--primary-light); font-size: 14px; font-weight: 600; word-break: break-all; }

/* Random desc */
.random-desc { color: var(--text-muted); margin-bottom: 20px; font-size: 13px; line-height: 1.6; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 20px; border: none; border-radius: var(--radius-sm);
  font-family: inherit; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s, color 0.2s, background 0.2s; text-decoration: none;
  user-select: none;
}
.btn-primary {
  background: var(--primary);
  color: #101010;
  width: 100%;
  box-shadow: none;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: none; }
.btn-primary:active { transform: translateY(0); }

.btn-sm { padding: 8px 14px; font-size: 13px; gap: 6px; }
.btn-outline {
  background: #1a1a1a;
  color: #efefef;
  border: 1px solid #2a2a2a;
}
.btn-outline:hover { border-color: var(--border-hover); color: var(--text); }
.btn-danger { background: #1a1a1a; color: #efefef; border: 1px solid #2a2a2a; }
.btn-danger:hover { background: #242424; }
.btn-icon { font-size: 16px; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface2); color: var(--text-muted);
  cursor: pointer; transition: all 0.2s; flex-shrink: 0;
}
.icon-btn:hover { border-color: var(--border-hover); color: var(--text); }
.icon-btn-danger:hover { border-color: rgba(239,68,68,0.4); color: var(--danger); background: var(--danger-surface); }

/* Features */
.features {
  display: none;
}
.feature {
  display: flex; align-items: center; gap: 12px;
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
}
.feature-icon { font-size: 22px; }
.feature-text { display: flex; flex-direction: column; }
.feature-text strong { font-size: 13px; color: var(--text); }
.feature-text span { font-size: 12px; color: var(--text-muted); }

/* ─────────────────────────────────────────────
   INBOX SCREEN
───────────────────────────────────────────── */
#inboxScreen { padding: 18px; max-width: 760px; margin: 0 auto; }

.inbox-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.inbox-address-block { flex: 1; min-width: 200px; }
.inbox-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.8px; color: var(--text-dim); margin-bottom: 8px; }
.inbox-address-row { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.inbox-address {
  font-family: 'Courier New', monospace;
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
}
.inbox-ttl { font-size: 12px; color: var(--text-muted); }

.inbox-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Inbox body */
.inbox-body { display: grid; grid-template-columns: 1fr; gap: 14px; min-height: 300px; }

/* Email list panel */
.email-list-panel {
  background: #090909;
  border: 1px solid #1f1f1f;
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.panel-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.8px;
  color: var(--text-muted); font-weight: 600;
}
.email-count {
  background: var(--surface2); border: 1px solid var(--border);
  padding: 2px 10px; border-radius: 20px; font-size: 11px;
}
.email-list { flex: 1; overflow-y: auto; }

/* Email item */
.email-item {
  padding: 14px 16px; border-bottom: 1px solid var(--border);
  cursor: pointer; transition: background 0.2s, transform 0.2s;
  position: relative;
}
.email-item:hover { background: var(--surface2); transform: translateX(2px); }
.email-item.active { background: rgba(99,102,241,0.1); border-left: 3px solid var(--primary); }
.email-item.unread .email-item-subject::before {
  content: ''; display: inline-block; width: 7px; height: 7px;
  background: var(--primary); border-radius: 50%; margin-right: 8px; vertical-align: middle;
}
.email-item-from { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.email-item-subject { font-size: 13px; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 4px; }
.email-item-time { font-size: 11px; color: var(--text-dim); }
.attach-badge {
  position: absolute; right: 16px; top: 50%; transform: translateY(-50%);
  font-size: 12px; opacity: 0.6;
}

/* Empty state */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 60px 24px; text-align: center; gap: 12px;
}
.empty-icon { font-size: 48px; opacity: 0.5; animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 0.4; } 50% { opacity: 0.7; } }
.empty-state p { color: var(--text-muted); font-weight: 500; }
.empty-state span { font-size: 12px; color: var(--text-dim); }

/* Skeleton Loading */
.skeleton-item {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.skeleton-line {
  height: 10px;
  border-radius: 999px;
  margin-bottom: 10px;
  background: linear-gradient(90deg, rgba(148, 163, 184, 0.14), rgba(148, 163, 184, 0.32), rgba(148, 163, 184, 0.14));
  background-size: 220% 100%;
  animation: skeletonShimmer 1.25s linear infinite;
}
.skeleton-line-sm { width: 46%; }
.skeleton-line-xs { width: 28%; margin-bottom: 0; }
@keyframes skeletonShimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

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

/* Email detail panel */
.email-detail-panel {
  background: #090909;
  border: 1px solid #1f1f1f;
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.detail-placeholder {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 100%; gap: 12px; color: var(--text-dim);
}
.placeholder-icon { font-size: 48px; opacity: 0.3; }

.email-detail { display: flex; flex-direction: column; height: 100%; }
.email-detail.hidden { display: none; }

.detail-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
}
.back-btn {
  display: flex; align-items: center; gap: 6px;
  background: none; border: none; color: var(--text-muted);
  font-family: inherit; font-size: 13px; cursor: pointer;
  padding: 4px 8px; border-radius: 6px; transition: all 0.15s;
}
.back-btn:hover { background: var(--surface2); color: var(--text); }

.detail-subject { font-size: 17px; font-weight: 700; padding: 16px 16px 8px; line-height: 1.3; }

.detail-meta { padding: 0 16px 16px; border-bottom: 1px solid var(--border); }
.meta-row { display: flex; gap: 12px; padding: 4px 0; }
.meta-key { font-size: 12px; color: var(--text-dim); width: 44px; flex-shrink: 0; padding-top: 1px; }
.meta-val { font-size: 13px; color: var(--text-muted); word-break: break-all; }

.detail-body { flex: 1; overflow: hidden; }
.email-iframe { width: 100%; height: 100%; min-height: 400px; border: none; background: white; border-radius: 0 0 var(--radius) var(--radius); }
.email-text { padding: 20px; font-size: 13px; line-height: 1.8; color: var(--text-muted); white-space: pre-wrap; overflow-y: auto; height: 100%; }

/* ─────────────────────────────────────────────
   TOAST
───────────────────────────────────────────── */
.toast {
  position: fixed; top: 24px; left: 50%; transform: translateX(-50%) translateY(-80px);
  background: rgba(23, 32, 54, 0.95); border: 1px solid var(--border);
  color: var(--text); padding: 12px 24px; border-radius: 100px;
  font-size: 13px; font-weight: 500;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  transition: transform 0.3s cubic-bezier(0.34,1.56,0.64,1);
  z-index: 9999; white-space: nowrap;
  pointer-events: none;
}
.toast.show { transform: translateX(-50%) translateY(0); }

.toast.success { border-color: rgba(34,197,94,0.4); color: var(--success); }
.toast.error { border-color: rgba(239,68,68,0.4); color: var(--danger); }

/* ─────────────────────────────────────────────
   SCROLLBAR
───────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.15); }

/* ─────────────────────────────────────────────
   LOADING SPINNER
───────────────────────────────────────────── */
.spinner {
  display: inline-block; width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: white; border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─────────────────────────────────────────────
   RESPONSIVE
───────────────────────────────────────────── */
@media (max-width: 600px) {
  .header { padding: 12px 14px; }
  .hero { padding: 18px 14px 12px; }
  .setup-card { margin: 0 16px 24px; padding: 20px; }
  .input-row { flex-direction: column; align-items: center; }
  .input-row .input-group:first-child,
  .input-row .input-group:last-child {
    width: 100%;
    max-width: 320px;
    flex: 1 1 auto;
  }
  .at-symbol { display: none; }
  .features { gap: 20px; padding-bottom: 40px; }
  .feature { width: 100%; justify-content: flex-start; }
  #inboxScreen { padding: 16px; }
  .inbox-header { flex-direction: column; }
  .inbox-address { font-size: 14px; }
  .inbox-actions { width: 100%; }
  .inbox-actions .btn { flex: 1; min-width: 90px; }
  .email-item:hover { transform: none; }
  .lang-select { padding: 8px 26px 8px 10px; font-size: 13px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
