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

:root {
  --bg: #0a0a0a;
  --surface-1: #111111;
  --surface-2: #141414;
  --surface-3: #1c1c1c;
  --border: #1e1e1e;
  --border-2: #2a2a2a;
  --text-1: #e5e5e5;
  --text-2: #888888;
  --text-3: #555555;
  --accent: #7c3aed;
  --accent-hover: #6d28d9;
  --unread-dot: #7c3aed;
  --read-dot: #333333;
  --danger: #ef4444;
}

html, body {
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text-1);
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ─── AUTH PAGES ─── */

.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 16px;
}

@media (max-width: 640px) {
  .auth-page {
    align-items: flex-start;
    padding-top: 40px;
  }
}

.auth-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: 12px;
  padding: 28px 28px;
}

.auth-logo {
  text-align: center;
  margin-bottom: 20px;
}

.auth-logo-img {
  width: 120px;
  display: block;
  margin: 0 auto 8px;
  object-fit: contain;
}

.auth-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-1);
  letter-spacing: -0.3px;
}

.auth-subtitle {
  font-size: 13px;
  color: var(--text-3);
  margin-top: 4px;
}

.error-banner {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 16px;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  letter-spacing: 0.3px;
}

.label-hint {
  font-weight: 400;
  color: var(--text-3);
}

.form-input {
  background: var(--surface-3);
  border: 1px solid var(--border-2);
  border-radius: 6px;
  padding: 9px 12px;
  font-size: 14px;
  color: var(--text-1);
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
  font-family: inherit;
}

.form-input:focus {
  border-color: var(--accent);
}

.form-input::placeholder {
  color: var(--text-3);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  font-family: inherit;
  margin-top: 4px;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.auth-link {
  text-align: center;
  margin-top: 20px;
  font-size: 13px;
  color: var(--text-3);
}

.auth-link a {
  color: var(--accent);
  text-decoration: none;
}

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

/* ─── INBOX LAYOUT ─── */

.inbox-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 52px;
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 12px;
}

.header-logo-img {
  height: 24px;
  object-fit: contain;
  flex-shrink: 0;
}

.header-center {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  justify-content: center;
}

.email-badge {
  font-size: 13px;
  color: #c4b5fd;
  background: rgba(124, 58, 237, 0.15);
  border: 1px solid rgba(124, 58, 237, 0.4);
  padding: 5px 14px;
  border-radius: 20px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  letter-spacing: 0.3px;
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

.btn-header-action {
  display: flex;
  align-items: center;
  gap: 5px;
  border: none;
  border-radius: 6px;
  padding: 5px 11px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.15s, transform 0.1s;
  line-height: 1;
}

.btn-header-action:hover {
  opacity: 0.85;
}

.btn-header-action:active {
  transform: scale(0.97);
}

.btn-copy-action {
  background: rgba(124, 58, 237, 0.2);
  color: #c4b5fd;
  border: 1px solid rgba(124, 58, 237, 0.35);
}

.btn-change-action {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-2);
  border: 1px solid var(--border-2);
}

.btn-history-action {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-2);
  border: 1px solid var(--border-2);
}

/* ─── HISTORY LIST ─── */

.history-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
  max-height: 240px;
  overflow-y: auto;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface-3);
  border: 1px solid var(--border-2);
  border-radius: 6px;
  padding: 8px 12px;
  gap: 10px;
}

.history-item-address {
  font-size: 12px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  color: var(--text-2);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-item-date {
  font-size: 11px;
  color: var(--text-3);
  white-space: nowrap;
}

.btn-reactivate {
  background: rgba(124, 58, 237, 0.2);
  color: #c4b5fd;
  border: 1px solid rgba(124, 58, 237, 0.35);
  border-radius: 4px;
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  transition: opacity 0.15s;
}

.btn-reactivate:hover {
  opacity: 0.8;
}

.history-empty {
  text-align: center;
  color: var(--text-3);
  font-size: 13px;
  padding: 16px 0;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  white-space: nowrap;
}

.header-username {
  font-size: 13px;
  color: var(--text-3);
}

.btn-logout {
  background: none;
  border: 1px solid var(--border-2);
  color: var(--text-3);
  border-radius: 5px;
  padding: 5px 12px;
  font-size: 12px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  font-family: inherit;
}

.btn-logout:hover {
  color: var(--text-1);
  border-color: var(--text-3);
}

.inbox-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ─── PANEL LEFT ─── */

.panel-left {
  width: 300px;
  min-width: 240px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
  flex-shrink: 0;
}

.panel-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.unread-count {
  font-size: 11px;
  background: var(--accent);
  color: #fff;
  padding: 1px 7px;
  border-radius: 10px;
  font-weight: 600;
}

.email-list {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border-2) transparent;
}

.email-list::-webkit-scrollbar {
  width: 4px;
}

.email-list::-webkit-scrollbar-thumb {
  background: var(--border-2);
  border-radius: 2px;
}

.email-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
}

.email-item:hover {
  background: var(--surface-2);
}

.email-item.active {
  background: #12091f;
  border-left: 2px solid var(--accent);
  padding-left: 14px;
}

.email-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--read-dot);
  flex-shrink: 0;
  margin-top: 5px;
  border: 1px solid var(--border-2);
}

.email-item.unread .email-dot {
  background: var(--unread-dot);
  border-color: var(--unread-dot);
}

.email-content {
  flex: 1;
  min-width: 0;
}

.email-from {
  font-size: 13px;
  color: var(--text-2);
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}

.email-item.unread .email-from {
  color: var(--text-1);
  font-weight: 600;
}

.email-subject {
  font-size: 12px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 3px;
}

.email-item.unread .email-subject {
  color: var(--text-2);
}

.email-time {
  font-size: 11px;
  color: var(--text-3);
}

.empty-state {
  padding: 40px 16px;
  text-align: center;
  font-size: 13px;
  color: var(--text-3);
}

/* ─── PANEL RIGHT ─── */

.panel-right {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.reading-pane {
  flex: 1;
  overflow-y: auto;
  padding: 28px 36px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-2) transparent;
}

.reading-pane::-webkit-scrollbar {
  width: 4px;
}

.reading-pane::-webkit-scrollbar-thumb {
  background: var(--border-2);
  border-radius: 2px;
}

.reading-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 12px;
  color: var(--text-3);
  font-size: 14px;
  min-height: 300px;
}

.reading-empty-icon {
  font-size: 32px;
  opacity: 0.3;
}

.email-header {
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.email-subject-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-1);
  line-height: 1.3;
  margin-bottom: 12px;
}

.email-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.email-meta-row {
  display: flex;
  gap: 8px;
  font-size: 13px;
}

.email-meta-label {
  color: var(--text-3);
  width: 32px;
  flex-shrink: 0;
}

.email-meta-value {
  color: var(--text-2);
}

.email-body-text {
  font-size: 14px;
  color: var(--text-2);
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
}

.email-html-frame {
  width: 100%;
  min-height: 400px;
  border: none;
  background: var(--surface-2);
  border-radius: 8px;
  padding: 0;
}

/* ─── COPY TOAST ─── */

.copy-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface-3);
  border: 1px solid var(--border-2);
  color: var(--text-1);
  padding: 8px 18px;
  border-radius: 20px;
  font-size: 13px;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  z-index: 100;
}

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


/* ─── MODAL ─── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.modal {
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: 12px;
  padding: 28px 28px 24px;
  max-width: 360px;
  width: 100%;
  margin: 20px;
}

.modal-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-1);
  margin-bottom: 10px;
}

.modal-text {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.6;
  margin-bottom: 22px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.btn-modal-cancel {
  background: none;
  border: 1px solid var(--border-2);
  color: var(--text-2);
  border-radius: 6px;
  padding: 8px 16px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.15s, color 0.15s;
}

.btn-modal-cancel:hover {
  border-color: var(--text-3);
  color: var(--text-1);
}

.btn-modal-confirm {
  background: var(--accent);
  border: none;
  color: #fff;
  border-radius: 6px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
}

.btn-modal-confirm:hover {
  background: var(--accent-hover);
}

/* ─── MOBILE BACK BUTTON ─── */

.btn-back-mobile {
  display: none;
}

/* ─── MOBILE RESPONSIVE ─── */

@media (max-width: 640px) {
  .header {
    height: auto;
    flex-wrap: wrap;
    padding: 10px 14px;
    gap: 8px;
  }

  .header-logo-img {
    height: 26px;
  }

  .header-center {
    order: 3;
    width: 100%;
    justify-content: flex-start;
    gap: 6px;
    padding-bottom: 2px;
  }

  .email-badge {
    max-width: 160px;
    font-size: 11px;
    padding: 4px 10px;
  }

  .btn-header-action span.btn-label {
    display: none;
  }

  .header-username {
    display: none;
  }

  .inbox-layout {
    flex-direction: column;
  }

  .panel-left {
    width: 100%;
    min-width: unset;
    border-right: none;
    border-bottom: 1px solid var(--border);
    flex: 1;
  }

  .panel-right {
    display: none;
    flex: 1;
    flex-direction: column;
  }

  .panel-right.mobile-active {
    display: flex;
  }

  .panel-left.mobile-hidden {
    display: none;
  }

  .btn-back-mobile {
    display: flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    border-bottom: 1px solid var(--border);
    color: var(--accent);
    font-size: 13px;
    font-weight: 600;
    padding: 12px 16px;
    cursor: pointer;
    font-family: inherit;
    flex-shrink: 0;
  }

  .reading-pane {
    padding: 16px;
  }

  .email-subject-title {
    font-size: 15px;
  }
}
