:root {
  --bg-color: #0b0f19;
  --card-bg: #111827;
  --card-border: #1f2937;
  --card-border-hover: #374151;
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --text-dim: #6b7280;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-subtle: rgba(59, 130, 246, 0.12);
  --success: #10b981;
  --success-subtle: rgba(16, 185, 129, 0.12);
  --warning: #f59e0b;
  --danger: #ef4444;
  --danger-subtle: rgba(239, 68, 68, 0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
}

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

body {
  background-color: var(--bg-color);
  color: var(--text-main);
  font-family: var(--font-sans);
  line-height: 1.5;
  min-height: 100vh;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.container {
  width: 100%;
  max-width: 900px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Header */
header {
  text-align: center;
  padding-bottom: 8px;
}

.logo-wrap {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.logo-wrap h1 {
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #60a5fa 0%, #3b82f6 50%, #93c5fd 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.tagline {
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* Cards */
.card {
  background-color: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
  transition: border-color 0.2s;
}

/* Mailbox Hero Box */
.mailbox-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.mailbox-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.section-label {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 9999px;
  background-color: var(--success-subtle);
  color: var(--success);
}

.status-badge.live::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--success);
  animation: pulse 2s infinite;
}

.status-badge.expired {
  background-color: var(--danger-subtle);
  color: var(--danger);
}

.status-badge.expired::before {
  background-color: var(--danger);
  animation: none;
}

@keyframes pulse {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

/* Address Box */
.address-box {
  display: flex;
  gap: 10px;
  background-color: rgba(0, 0, 0, 0.3);
  padding: 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--card-border);
}

.address-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 1.15rem;
  font-weight: 600;
  padding: 8px 12px;
  outline: none;
  width: 100%;
}

/* Custom Name & Domain Selector */
.custom-name-box {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.custom-input-group {
  flex: 1;
  display: flex;
  align-items: center;
  background-color: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  min-width: 280px;
}

.custom-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 0.95rem;
  padding: 6px 0;
  outline: none;
  min-width: 120px;
}

.at-sign {
  color: var(--text-dim);
  font-family: var(--font-mono);
  padding: 0 4px;
  user-select: none;
}

.domain-select {
  background-color: #1f2937;
  color: #93c5fd;
  border: 1px solid var(--card-border);
  border-radius: 6px;
  padding: 4px 8px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  outline: none;
  cursor: pointer;
}

.domain-select:focus {
  border-color: var(--accent);
}

.btn-set {
  white-space: nowrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

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

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

.btn-secondary {
  background-color: #1f2937;
  color: var(--text-main);
  border: 1px solid var(--card-border-hover);
}

.btn-secondary:hover {
  background-color: #374151;
}

.mailbox-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding-top: 6px;
}

.timer-box {
  font-size: 0.9rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.timer-value {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--warning);
}

/* Toast Notifications */
#toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background-color: #1e293b;
  color: #fff;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.4);
  border-left: 4px solid var(--accent);
  font-size: 0.9rem;
  display: none;
  z-index: 100;
  animation: slideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

#toast.show {
  display: block;
}

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

/* Main Inbox / Layout */
.inbox-card {
  min-height: 400px;
  display: flex;
  flex-direction: column;
}

.inbox-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--card-border);
  padding-bottom: 16px;
  margin-bottom: 16px;
}

.inbox-count-badge {
  background-color: var(--accent-subtle);
  color: #93c5fd;
  font-size: 0.8rem;
  padding: 2px 8px;
  border-radius: 9999px;
  font-weight: 600;
}

/* Message List */
.message-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.message-item {
  background-color: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  cursor: pointer;
  transition: all 0.15s ease;
  display: grid;
  grid-template-columns: 180px 1fr auto;
  gap: 16px;
  align-items: center;
}

.message-item:hover {
  background-color: rgba(255, 255, 255, 0.05);
  border-color: var(--card-border-hover);
  transform: translateY(-1px);
}

.message-item.unread {
  border-left: 3px solid var(--accent);
  background-color: var(--accent-subtle);
}

.msg-sender {
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-main);
}

.msg-content-preview {
  overflow: hidden;
}

.msg-subject {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-main);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.msg-snippet {
  font-size: 0.85rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.msg-meta {
  text-align: right;
  font-size: 0.8rem;
  color: var(--text-dim);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.attachment-indicator {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.75rem;
  color: var(--accent);
}

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text-dim);
  text-align: center;
  gap: 12px;
}

.empty-state svg {
  width: 48px;
  height: 48px;
  stroke: var(--text-dim);
  opacity: 0.6;
}

.empty-state p {
  font-size: 0.95rem;
  max-width: 320px;
}

/* Modal / Message View */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-container {
  background-color: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 800px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--card-border);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.modal-title-wrap {
  flex: 1;
  overflow: hidden;
}

.modal-subject {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 4px;
}

.modal-meta {
  font-size: 0.85rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.close-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  line-height: 1;
}

.close-btn:hover {
  color: var(--text-main);
  background-color: rgba(255, 255, 255, 0.1);
}

.modal-tabs {
  display: flex;
  gap: 8px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--card-border);
  background-color: rgba(0, 0, 0, 0.2);
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.85rem;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.tab-btn.active {
  background-color: #1f2937;
  color: #fff;
}

.modal-body {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  font-size: 0.95rem;
}

.body-text {
  font-family: var(--font-sans);
  white-space: pre-wrap;
  word-break: break-word;
  color: #d1d5db;
  line-height: 1.6;
}

.body-html-frame {
  width: 100%;
  height: 400px;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  background-color: #ffffff;
}

.attachments-section {
  padding: 16px 20px;
  border-top: 1px solid var(--card-border);
  background-color: rgba(0, 0, 0, 0.2);
}

.attachments-heading {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.attachments-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.attachment-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background-color: #1f2937;
  border: 1px solid var(--card-border-hover);
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text-main);
  font-size: 0.85rem;
  transition: all 0.15s;
}

.attachment-pill:hover {
  background-color: #374151;
  border-color: var(--accent);
  color: #60a5fa;
}

.attachment-size {
  color: var(--text-dim);
  font-size: 0.75rem;
}

/* Footer */
footer {
  margin-top: auto;
  text-align: center;
  color: var(--text-dim);
  font-size: 0.8rem;
  padding-top: 32px;
}

/* Responsive */
@media (max-width: 640px) {
  .message-item {
    grid-template-columns: 1fr;
    gap: 6px;
  }
  .msg-meta {
    align-items: flex-start;
  }
  .address-box {
    flex-direction: column;
  }
}
