:root {
  --bg: #0b0d12;
  --bg-elev: #12151c;
  --bg-elev-2: #1a1f2a;
  --border: #232936;
  --text: #e6eaf2;
  --text-dim: #8a93a6;
  --text-muted: #5a6478;
  --accent: #6366f1;
  --accent-hover: #7c7fff;
  --accent-soft: rgba(99, 102, 241, 0.15);
  --danger: #ef4444;
  --success: #22c55e;
  --warning: #f59e0b;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family:
    -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu,
    Cantarell, 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
  background: radial-gradient(ellipse at top, #151824 0%, var(--bg) 60%);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

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

#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(11, 13, 18, 0.85);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
}
.logo {
  font-size: 22px;
}
.brand-name {
  font-size: 16px;
  letter-spacing: 0.2px;
}
.domain-badge {
  background: var(--accent-soft);
  color: var(--accent-hover);
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  margin-left: 6px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

main {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.footer {
  text-align: center;
  padding: 20px;
  color: var(--text-muted);
  font-size: 12px;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-elev-2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: border-color 0.15s, background 0.15s, transform 0.05s;
  font-family: inherit;
}
.btn:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--bg-elev);
}
.btn:active:not(:disabled) {
  transform: translateY(1px);
}
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}
.btn-ghost {
  background: transparent;
  border-color: transparent;
}
.btn-ghost:hover:not(:disabled) {
  border-color: var(--border);
  background: var(--bg-elev);
}
.btn-danger {
  background: transparent;
  border-color: transparent;
  color: var(--danger);
}
.btn-danger:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.35);
}
.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

/* ===== Inputs ===== */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}
.field label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-dim);
}
.input,
.input-group input {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  width: 100%;
  transition: border-color 0.15s;
}
.input:focus,
.input-group input:focus {
  border-color: var(--accent);
}
.input-group {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  overflow: hidden;
  transition: border-color 0.15s;
}
.input-group:focus-within {
  border-color: var(--accent);
}
.input-group input {
  border: 0;
  flex: 1;
  min-width: 0;
}
.input-group .suffix {
  display: flex;
  align-items: center;
  padding: 0 12px;
  color: var(--text-dim);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  border-left: 1px solid var(--border);
  background: var(--bg-elev);
  white-space: nowrap;
}

/* ===== Landing page ===== */
.landing {
  max-width: 920px;
  margin: 0 auto;
  padding: 60px 24px 40px;
  width: 100%;
}
.landing h1 {
  font-size: 36px;
  margin: 0 0 10px;
  letter-spacing: -0.5px;
}
.landing .lead {
  color: var(--text-dim);
  font-size: 16px;
  margin-bottom: 36px;
  max-width: 640px;
}

.card-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
@media (max-width: 780px) {
  .card-grid {
    grid-template-columns: 1fr;
  }
}

.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}
.card h2 {
  margin: 0 0 6px;
  font-size: 18px;
}
.card .card-desc {
  color: var(--text-dim);
  font-size: 13px;
  margin-bottom: 16px;
}

.tabs {
  display: flex;
  gap: 2px;
  background: var(--bg-elev-2);
  padding: 3px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
}
.tab {
  flex: 1;
  background: transparent;
  border: 0;
  color: var(--text-dim);
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, color 0.15s;
}
.tab.active {
  background: var(--bg);
  color: var(--text);
}

.form-error {
  color: var(--danger);
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.3);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 12px;
}

/* ===== Inbox ===== */
.inbox {
  flex: 1;
  display: grid;
  grid-template-columns: 340px 1fr;
  min-height: calc(100vh - 100px);
}
@media (max-width: 820px) {
  .inbox {
    grid-template-columns: 1fr;
  }
  .inbox .detail-pane.empty {
    display: none;
  }
}

.sidebar {
  border-right: 1px solid var(--border);
  background: var(--bg-elev);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.sidebar-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.sidebar-header .address {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
  word-break: break-all;
}
.copy-btn {
  background: transparent;
  border: 0;
  color: var(--text-dim);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  font-size: 12px;
}
.copy-btn:hover {
  background: var(--bg-elev-2);
  color: var(--text);
}
.sidebar-meta {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  gap: 10px;
}
.sidebar-actions {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.last-refresh {
  color: var(--text-muted);
  font-size: 11px;
}
.connection-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--warning);
  margin-right: 4px;
  vertical-align: middle;
}
.connection-dot.connected {
  background: var(--success);
}
.connection-dot.disconnected {
  background: var(--danger);
}

.messages-list {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}
.message-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.12s;
}
.message-item:hover {
  background: var(--bg-elev-2);
}
.message-item.active {
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
  padding-left: 13px;
}
.message-item .msg-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.message-item .msg-from {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.message-item.unread .msg-from::before {
  content: '•';
  color: var(--accent);
  margin-right: 4px;
  font-size: 16px;
  line-height: 0;
  vertical-align: middle;
}
.message-item .msg-time {
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
}
.message-item .msg-subject {
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.message-item.unread .msg-subject {
  color: var(--text);
}

.list-empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

.detail-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.detail-pane.empty {
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 14px;
  padding: 40px;
  text-align: center;
}

.detail-header {
  border-bottom: 1px solid var(--border);
  padding: 20px 26px;
  background: var(--bg-elev);
}
.detail-header h2 {
  margin: 0 0 8px;
  font-size: 18px;
}
.detail-header .meta {
  font-size: 13px;
  color: var(--text-dim);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.detail-header .meta b {
  color: var(--text);
  font-weight: 500;
  margin-right: 4px;
}
.detail-actions {
  margin-top: 12px;
  display: flex;
  gap: 8px;
}

.detail-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px 26px;
  min-height: 0;
}
.detail-body pre.text-body {
  white-space: pre-wrap;
  word-break: break-word;
  font-family: inherit;
  margin: 0;
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}
.html-frame {
  width: 100%;
  min-height: 500px;
  border: 0;
  background: #fff;
  border-radius: var(--radius-sm);
}

.attachments {
  margin-top: 20px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}
.attachments h3 {
  font-size: 13px;
  margin: 0 0 8px;
  color: var(--text-dim);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.attachments ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.attachments a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.attachments a:hover {
  border-color: var(--accent);
}

.format-toggle {
  display: inline-flex;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.format-toggle button {
  background: transparent;
  border: 0;
  padding: 5px 10px;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
}
.format-toggle button.active {
  background: var(--accent);
  color: #fff;
}

/* ===== Toasts ===== */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 100;
  max-width: 360px;
}
.toast {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  animation: slide-in 0.25s ease-out;
  font-size: 13px;
}
.toast.success {
  border-color: rgba(34, 197, 94, 0.4);
}
.toast.error {
  border-color: rgba(239, 68, 68, 0.4);
  color: #fca5a5;
}
@keyframes slide-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== Copy hint / password box ===== */
.generated-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  color: var(--text);
  margin-bottom: 10px;
}

.hint {
  color: var(--text-muted);
  font-size: 12px;
  margin-top: -6px;
  margin-bottom: 14px;
}

.policy-page {
  min-height: 100%;
  padding: 32px 16px;
}
.policy-card {
  width: min(840px, 100%);
  margin: 0 auto;
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(18, 21, 28, 0.92);
  box-shadow: var(--shadow);
}
.policy-card h1 {
  margin: 16px 0 12px;
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.05;
}
.policy-card h2 {
  margin-top: 24px;
  color: var(--text);
}
.policy-card p,
.policy-card li {
  color: var(--text-dim);
  font-size: 15px;
}
.policy-card strong {
  color: var(--text);
}
.policy-back {
  display: inline-flex;
  margin-bottom: 8px;
}
.muted {
  color: var(--text-muted) !important;
}
