:root {
  --bg: #fffaf0;
  --text: #1f1f1f;
  --muted: #5f5a52;
  --panel: rgba(255, 255, 255, 0.78);
  --line: rgba(31, 31, 31, 0.12);
  --brand: #ca3f1e;
  --brand-2: #f2b63f;
  --danger: #9c1f12;
  --ok: #1e845f;
  --radius: 18px;
  --shadow: 0 16px 40px rgba(15, 15, 15, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: 'Space Grotesk', sans-serif;
  background: radial-gradient(circle at 15% 20%, #ffe4b3 0%, transparent 40%),
    radial-gradient(circle at 80% 10%, #ffd6c2 0%, transparent 42%),
    linear-gradient(130deg, #fff9ef, #fff6d6 45%, #f8f3e8);
  position: relative;
}

h1,
h2,
h3 {
  font-family: 'Fraunces', serif;
  letter-spacing: 0.01em;
  margin: 0 0 12px;
}

a {
  color: inherit;
}

.bg-orb {
  position: fixed;
  border-radius: 999px;
  z-index: -3;
  filter: blur(8px);
  opacity: 0.35;
  animation: drift 8s ease-in-out infinite alternate;
}

.orb-a {
  width: 320px;
  height: 320px;
  right: -80px;
  top: 80px;
  background: #ff6a3d;
}

.orb-b {
  width: 260px;
  height: 260px;
  left: -70px;
  bottom: 60px;
  background: #f2d33f;
}

.bg-noise {
  position: fixed;
  inset: 0;
  z-index: -2;
  background-image: radial-gradient(rgba(20, 20, 20, 0.06) 1px, transparent 1px);
  background-size: 4px 4px;
  opacity: 0.12;
  pointer-events: none;
}

@keyframes drift {
  from {
    transform: translateY(0px) translateX(0px);
  }

  to {
    transform: translateY(-14px) translateX(10px);
  }
}

.topbar {
  max-width: 1180px;
  margin: 18px auto;
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  font-weight: 700;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.brand-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
}

.menu {
  display: flex;
  align-items: center;
  gap: 12px;
}

.menu a {
  text-decoration: none;
}

.menu-user {
  color: var(--muted);
}

.page {
  max-width: 1180px;
  margin: 24px auto 60px;
  padding: 0 18px;
  display: grid;
  gap: 18px;
}

.panel {
  border: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(10px);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.hero h1 {
  font-size: clamp(1.55rem, 1.9vw, 2.1rem);
}

.hero-meta {
  margin-top: 14px;
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  color: var(--muted);
}

.sample-box {
  margin-top: 16px;
  border: 1px dashed rgba(31, 31, 31, 0.25);
  border-radius: 14px;
  padding: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  background: rgba(255, 255, 255, 0.75);
}

.sample-address {
  display: inline-flex;
  align-items: center;
  font-size: 1.05rem;
  font-weight: 700;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.06);
}

.hero-actions {
  margin-top: 16px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.grid-2 {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.count {
  display: inline-flex;
  min-width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.06);
  font-weight: 700;
}

.create-form {
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

.create-form label {
  flex: 1;
  display: grid;
  gap: 8px;
  font-size: 0.9rem;
  color: var(--muted);
}

.create-feedback {
  min-height: 1.4rem;
  margin: 10px 2px 0;
  font-size: 0.92rem;
}

.create-feedback-success {
  color: #1e6f51;
}

.create-feedback-error {
  color: #7a170f;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 12px;
  padding: 11px 13px;
  font: inherit;
}

.stack-form {
  display: grid;
  gap: 12px;
}

.stack-form label {
  display: grid;
  gap: 8px;
}

.btn {
  border: none;
  border-radius: 12px;
  padding: 10px 14px;
  font: inherit;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 120ms ease, opacity 120ms ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, #bb3215, #e67a20);
}

.btn-ghost {
  background: rgba(20, 20, 20, 0.06);
  color: var(--text);
}

.btn-danger {
  background: rgba(156, 31, 18, 0.1);
  color: var(--danger);
}

.mailbox-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 10px;
  background: rgba(255, 255, 255, 0.74);
}

.mailbox-card-archived {
  background: rgba(255, 255, 255, 0.45);
}

.mailbox-address {
  font-weight: 700;
  text-decoration: none;
}

.mailbox-meta {
  margin: 8px 0 0;
  color: var(--muted);
}

.mailbox-actions {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.flash {
  border-radius: 12px;
  padding: 11px 13px;
  border: 1px solid;
}

.flash-success {
  background: rgba(30, 132, 95, 0.1);
  border-color: rgba(30, 132, 95, 0.24);
  color: #1e6f51;
}

.flash-error {
  background: rgba(156, 31, 18, 0.08);
  border-color: rgba(156, 31, 18, 0.25);
  color: #7a170f;
}

.badge {
  display: inline-flex;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 0.82rem;
  background: rgba(20, 20, 20, 0.08);
}

.badge-keep {
  background: rgba(30, 132, 95, 0.16);
  color: #16563d;
}

.badge-archived {
  background: rgba(0, 0, 0, 0.12);
}

.empty {
  color: var(--muted);
}

.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.auth-card {
  width: min(520px, 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 24px;
  animation: rise 340ms ease;
}

.auth-link {
  margin-top: 14px;
  color: var(--muted);
}

@keyframes rise {
  from {
    transform: translateY(8px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.mailbox-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.4fr);
}

.list-stack {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

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

.live-state {
  margin: 0;
  font-size: 0.93rem;
  color: var(--muted);
}

.live-state-ok {
  color: #1e6f51;
}

.live-state-warn {
  color: #7a170f;
}

.inbox-list {
  max-height: 72vh;
  overflow: auto;
}

.mail-row {
  display: block;
  text-decoration: none;
  color: inherit;
  padding: 11px;
  border-radius: 12px;
  border: 1px solid var(--line);
  margin-bottom: 9px;
  background: rgba(255, 255, 255, 0.76);
}

.mail-row strong {
  display: block;
}

.mail-row span,
.mail-row small,
.mail-row p {
  color: var(--muted);
}

.mail-row p {
  margin: 5px 0 0;
}

.mail-unread {
  border-color: rgba(202, 63, 30, 0.35);
}

.mail-detail {
  max-height: 72vh;
  overflow: auto;
}

.detail-meta {
  margin: 6px 0;
  color: var(--muted);
}

.mail-body {
  margin-top: 14px;
  white-space: pre-wrap;
  line-height: 1.45;
  background: rgba(0, 0, 0, 0.04);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
}

.stats-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.stat-card {
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.7);
  display: grid;
  gap: 6px;
}

.stat-card span {
  color: var(--muted);
}

.stat-card strong {
  font-size: 1.35rem;
}

.admin-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 0 0 14px;
}

.admin-form {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: end;
}

.admin-form label {
  display: grid;
  gap: 7px;
}

.user-table-wrap {
  overflow: auto;
}

.user-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

.user-table th,
.user-table td {
  text-align: left;
  border-bottom: 1px solid var(--line);
  padding: 10px 8px;
  vertical-align: top;
}

.inline-form {
  display: inline-flex;
  gap: 8px;
  margin-right: 8px;
  margin-bottom: 8px;
}

.wiki-panel {
  overflow: hidden;
}

.wiki-content {
  line-height: 1.55;
}

.wiki-content h1,
.wiki-content h2,
.wiki-content h3 {
  margin-top: 22px;
}

.wiki-content code {
  background: rgba(0, 0, 0, 0.07);
  padding: 2px 6px;
  border-radius: 8px;
}

.wiki-content pre {
  background: rgba(0, 0, 0, 0.06);
  padding: 12px;
  border-radius: 12px;
  overflow: auto;
}

.debug-meta-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 14px;
}

.debug-list {
  display: grid;
  gap: 10px;
}

.debug-event {
  border: 1px solid var(--line);
  border-left-width: 5px;
  border-radius: 14px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.72);
}

.debug-event-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 8px;
}

.debug-event-head small {
  color: var(--muted);
}

.debug-event-connect,
.debug-event-disconnect,
.debug-event-tls_ready,
.debug-event-mail_from {
  border-left-color: rgba(20, 20, 20, 0.24);
}

.debug-event-rcpt_accept,
.debug-event-stored {
  border-left-color: rgba(30, 132, 95, 0.5);
}

.debug-event-rcpt_reject,
.debug-event-data_error {
  border-left-color: rgba(156, 31, 18, 0.55);
}

.debug-table-wrap {
  overflow: auto;
}

.debug-badge-connect,
.debug-badge-disconnect,
.debug-badge-tls_ready,
.debug-badge-mail_from {
  background: rgba(20, 20, 20, 0.1);
}

.debug-badge-rcpt_accept,
.debug-badge-stored {
  background: rgba(30, 132, 95, 0.14);
  color: #16563d;
}

.debug-badge-rcpt_reject,
.debug-badge-data_error {
  background: rgba(156, 31, 18, 0.12);
  color: #7a170f;
}

@media (max-width: 980px) {
  .grid-2,
  .mailbox-grid,
  .stats-grid,
  .debug-meta-grid {
    grid-template-columns: 1fr;
  }

  .create-form,
  .admin-form {
    grid-template-columns: 1fr;
  }

  .menu {
    flex-wrap: wrap;
    justify-content: flex-end;
  }
}
