/* Mail Service design system: dark surfaces with a violet accent. Shared by the site, docs and admin. */

:root {
  color-scheme: dark;

  --bg: #0b0a12;
  --bg-elev: #100e19;
  --surface: #15121f;
  --surface-2: #1b1828;
  --surface-3: #242035;
  --border: #29233c;
  --border-strong: #3a3253;

  --text: #eeebf7;
  --text-2: #bdb6d3;
  --muted: #8d86a6;

  --primary: #8b5cf6;
  --primary-hover: #9d74f8;
  --primary-press: #7c3aed;
  --primary-soft: rgba(139, 92, 246, 0.14);
  --primary-line: rgba(139, 92, 246, 0.38);
  --primary-text: #c4b5fd;
  --magenta: #d946ef;

  --success: #34d399;
  --success-soft: rgba(52, 211, 153, 0.12);
  --warning: #fbbf24;
  --warning-soft: rgba(251, 191, 36, 0.12);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.12);
  --info: #7dd3fc;
  --info-soft: rgba(125, 211, 252, 0.12);

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 12px 32px -12px rgba(0, 0, 0, 0.6);
  --ring: 0 0 0 3px rgba(139, 92, 246, 0.35);

  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: "JetBrains Mono", "Cascadia Code", ui-monospace, "SFMono-Regular", Consolas, monospace;
}

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

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

::selection { background: rgba(139, 92, 246, 0.45); color: #fff; }

a { color: var(--primary-text); text-decoration: none; }
a:hover { color: #ddd6fe; text-decoration: underline; text-underline-offset: 3px; }

h1, h2, h3, h4 { color: var(--text); line-height: 1.2; letter-spacing: -0.02em; margin: 0; }
p { margin: 0; }

:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--radius-sm); }

.hidden { display: none !important; }
.muted { color: var(--muted); }
.text-2 { color: var(--text-2); }
.mono { font-family: var(--mono); }
.nowrap { white-space: nowrap; }
.spacer { flex: 1; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.container { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 24px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.stack { display: grid; gap: 16px; }

/* Brand */
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); font-weight: 650; letter-spacing: -0.01em; }
.brand:hover { color: var(--text); text-decoration: none; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--primary), var(--magenta));
  box-shadow: 0 6px 18px -6px rgba(139, 92, 246, 0.7);
}
.brand-mark svg { width: 17px; height: 17px; }
.brand small { color: var(--muted); font-weight: 500; font-size: 12px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: 600 14px/1 var(--font); letter-spacing: -0.005em;
  padding: 10px 16px; border-radius: 10px; border: 1px solid transparent;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background-color .15s, border-color .15s, color .15s, transform .05s, box-shadow .15s;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; transform: none; }
.btn svg { width: 16px; height: 16px; flex: none; }

.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 8px 20px -10px rgba(139, 92, 246, .9); }
.btn-primary:hover { background: var(--primary-hover); color: #fff; }
.btn-primary:active { background: var(--primary-press); }

.btn-secondary { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-3); color: var(--text); }

.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

.btn-danger { background: transparent; color: var(--danger); border-color: rgba(248, 113, 113, .35); }
.btn-danger:hover { background: var(--danger-soft); color: #fca5a5; }
.btn-danger-solid { background: #dc2626; color: #fff; }
.btn-danger-solid:hover { background: #ef4444; color: #fff; }

.btn-sm { padding: 7px 11px; font-size: 13px; border-radius: 8px; }
.btn-lg { padding: 13px 22px; font-size: 15px; border-radius: 12px; }
.btn-icon { padding: 8px; }

/* Forms */
.field { display: grid; gap: 6px; align-content: start; }
.field > span, .label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.field .hint { font-size: 12px; color: var(--muted); font-weight: 400; }
.req { color: var(--primary-text); }

.input, .select, .textarea {
  width: 100%; font: 14px/1.4 var(--font); color: var(--text);
  background: var(--bg-elev); border: 1px solid var(--border-strong); border-radius: 10px;
  padding: 10px 12px; transition: border-color .15s, box-shadow .15s, background-color .15s;
}
.input::placeholder, .textarea::placeholder { color: #6f6889; }
.input:hover, .select:hover, .textarea:hover { border-color: #4a4068; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
.textarea { resize: vertical; min-height: 110px; }
.select { appearance: none; padding-right: 36px; cursor: pointer;
  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='%238d86a6' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; }
.input[type=number] { font-variant-numeric: tabular-nums; }

.checkbox { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; padding: 12px 14px;
  border: 1px solid var(--border-strong); border-radius: 10px; background: var(--bg-elev); }
.checkbox:hover { border-color: #4a4068; }
.checkbox input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--primary); flex: none; }
.checkbox strong { display: block; font-size: 14px; }
.checkbox span { font-size: 13px; color: var(--muted); }

.form-error {
  display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 10px;
  background: var(--danger-soft); border: 1px solid rgba(248, 113, 113, .3); color: #fecaca; font-size: 13px;
}

/* Surfaces */
.card {
  background: linear-gradient(180deg, rgba(255, 255, 255, .015), transparent 40%), var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow);
}
.card-pad { padding: 24px; }
.card-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.card-head h2, .card-head h3 { font-size: 16px; }

.divider { height: 1px; background: var(--border); border: 0; margin: 0; }

/* Badges */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; line-height: 1.5; white-space: nowrap; border: 1px solid transparent;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.plain::before { display: none; }
.badge-success { color: var(--success); background: var(--success-soft); border-color: rgba(52, 211, 153, .25); }
.badge-warning { color: var(--warning); background: var(--warning-soft); border-color: rgba(251, 191, 36, .25); }
.badge-danger { color: var(--danger); background: var(--danger-soft); border-color: rgba(248, 113, 113, .25); }
.badge-info { color: var(--info); background: var(--info-soft); border-color: rgba(125, 211, 252, .25); }
.badge-primary { color: var(--primary-text); background: var(--primary-soft); border-color: var(--primary-line); }
.badge-neutral { color: var(--text-2); background: var(--surface-3); border-color: var(--border-strong); }

.pill { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px;
  background: var(--primary-soft); border: 1px solid var(--primary-line); color: var(--primary-text); font-size: 13px; font-weight: 600; }

.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); display: inline-block; flex: none; }
.dot-live { background: var(--success); box-shadow: 0 0 0 4px rgba(52, 211, 153, .15); animation: pulse 2.4s ease-in-out infinite; }
.dot-warn { background: var(--warning); box-shadow: 0 0 0 4px rgba(251, 191, 36, .15); }
@keyframes pulse { 50% { box-shadow: 0 0 0 7px rgba(52, 211, 153, 0); } }

/* Tables */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left; font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  color: var(--muted); padding: 12px 16px; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--bg-elev);
}
.table td { padding: 14px 16px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tbody tr { transition: background-color .12s; }
.table tbody tr:hover { background: rgba(139, 92, 246, .04); }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { font-variant-numeric: tabular-nums; }
.table .sub { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }

/* Code */
code, kbd, pre { font-family: var(--mono); }
:not(pre) > code {
  font-size: .86em; padding: 2px 6px; border-radius: 6px; background: var(--surface-3);
  border: 1px solid var(--border); color: #e9d5ff; word-break: break-word;
}
.codeblock { position: relative; border: 1px solid var(--border); border-radius: var(--radius); background: #0d0b16; overflow: hidden; }
.codeblock-head { display: flex; align-items: center; gap: 8px; padding: 8px 10px 8px 14px; border-bottom: 1px solid var(--border);
  background: var(--bg-elev); font-size: 12px; color: var(--muted); font-weight: 600; }
.codeblock pre { margin: 0; padding: 16px; overflow-x: auto; font-size: 13px; line-height: 1.65; color: #e4e0f2; tab-size: 2; }
.tok-c { color: #6f6889; font-style: italic; }
.tok-k { color: #c4b5fd; }
.tok-s { color: #86efac; }
.tok-n { color: #fda4af; }
.tok-h { color: #7dd3fc; }

/* Toasts */
.toasts { position: fixed; right: 20px; bottom: 20px; display: grid; gap: 10px; z-index: 100; width: min(380px, calc(100vw - 40px)); }
.toast {
  display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 12px;
  background: var(--surface-2); border: 1px solid var(--border-strong); box-shadow: 0 18px 40px -12px rgba(0, 0, 0, .7);
  font-size: 14px; animation: toast-in .2s ease-out;
}
.toast .dot { margin-top: 7px; }
.toast-success .dot { background: var(--success); }
.toast-error .dot { background: var(--danger); }
.toast-info .dot { background: var(--primary); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* Dialogs */
dialog.modal {
  width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-lg);
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .8);
}
dialog.modal[open] { animation: modal-in .18s ease-out; }
dialog.modal::backdrop { background: rgba(6, 5, 12, .72); backdrop-filter: blur(4px); }
dialog.modal.modal-sm { width: min(440px, calc(100vw - 32px)); }
.modal-head { display: flex; align-items: flex-start; gap: 12px; padding: 20px 22px 14px; }
.modal-head h2 { font-size: 18px; }
.modal-head p { font-size: 14px; color: var(--muted); margin-top: 4px; }
.modal-body { padding: 4px 22px 20px; display: grid; gap: 16px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--border); background: var(--bg-elev);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg); flex-wrap: wrap; }
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(.98); } }

.secret {
  display: flex; align-items: center; gap: 10px; padding: 12px 12px 12px 14px; border-radius: 12px;
  background: #0d0b16; border: 1px dashed var(--primary-line);
}
.secret code { flex: 1; background: none; border: 0; padding: 0; font-size: 13px; word-break: break-all; color: #e9d5ff; }

.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty svg { width: 36px; height: 36px; color: var(--border-strong); margin-bottom: 10px; }
.empty strong { display: block; color: var(--text-2); font-size: 15px; margin-bottom: 4px; }

.grid-2 { display: grid; gap: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-4 { display: grid; gap: 12px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 720px) {
  .grid-2 { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .container { padding: 0 16px; }
}

.input[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--danger); }
.danger-hover:hover { color: var(--danger); background: var(--danger-soft); }
