/* AllMCP base — reset, typography, and the shared component vocabulary.
   Import order on every page: fonts.css, tokens.css, base.css, [page].css */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4, p, figure { margin: 0; }
h1, h2, h3 { text-wrap: balance; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
img, svg { display: block; max-width: 100%; }
::selection { background: rgba(94, 106, 210, 0.35); }
/* The hidden attribute must always win over a component's own `display` rule. */
[hidden] { display: none !important; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--text-muted); }
.dim { color: var(--text-dim); }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 18px;
  font-size: 14px; font-weight: 500; line-height: 1;
  border: 1px solid transparent; border-radius: var(--radius);
  cursor: pointer; user-select: none;
  transition: background 0.14s var(--ease), border-color 0.14s var(--ease), opacity 0.14s var(--ease);
  white-space: nowrap;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-sm { height: 34px; padding: 0 12px; font-size: 13px; border-radius: var(--radius); }
.btn-block { width: 100%; }

.btn-primary { background: var(--accent); color: var(--accent-contrast); border-color: var(--accent); }
.btn-primary:not(:disabled):hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-outline { background: transparent; color: var(--text); border-color: var(--border-strong); }
.btn-outline:not(:disabled):hover { background: var(--subtle); border-color: var(--border-hover); }

.btn-ghost { background: transparent; color: var(--text-muted); border-color: transparent; }
.btn-ghost:not(:disabled):hover { background: var(--subtle); color: var(--text); }

.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:not(:disabled):hover { background: var(--danger-hover); border-color: var(--danger-hover); }

.btn-danger-outline { background: transparent; color: var(--danger); border-color: rgba(235, 87, 87, 0.4); }
.btn-danger-outline:not(:disabled):hover { background: rgba(235, 87, 87, 0.1); border-color: var(--danger); }

/* ---------- Cards & panels ---------- */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.card-pad { padding: 24px 28px; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 7px; }
.label { font-size: 13px; font-weight: 500; color: var(--text); }
.help { font-size: 12px; color: var(--text-muted); line-height: 1.5; }
.input, textarea.input, select.input {
  width: 100%; min-height: 44px; padding: 11px 14px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  font-family: inherit; font-size: 14px; line-height: 1.4;
  transition: border-color 0.14s var(--ease), box-shadow 0.14s var(--ease);
}
.input::placeholder { color: var(--text-dim); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(94, 106, 210, 0.18); }
.input.mono { font-family: var(--font-mono); }
textarea.input { min-height: 120px; resize: vertical; }
.input-invalid, .input-invalid:focus { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(235, 87, 87, 0.16); }

/* ---------- Banners / inline notices ---------- */
.banner {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px; border-radius: var(--radius);
  font-size: 13px; line-height: 1.5;
  border: 1px solid var(--border);
}
.banner-error { background: rgba(235, 87, 87, 0.1); border-color: rgba(235, 87, 87, 0.32); color: #f2b0b0; }
.banner-success { background: rgba(76, 195, 138, 0.1); border-color: rgba(76, 195, 138, 0.3); color: #9fe0c1; }
.banner-warning { background: rgba(242, 201, 76, 0.08); border-color: rgba(242, 201, 76, 0.3); color: #e8d194; }
.banner-info { background: var(--subtle); border-color: var(--border); color: var(--text-muted); }

/* ---------- Status badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px; border-radius: var(--radius-pill);
  font-size: 11px; font-weight: 500; letter-spacing: 0.01em;
  border: 1px solid var(--border);
}
.badge-dot { width: 6px; height: 6px; border-radius: 50%; flex: none; }
.badge-active { color: var(--success); border-color: rgba(76, 195, 138, 0.35); }
.badge-active .badge-dot { background: var(--success); }
.badge-warn { color: var(--warning); border-color: rgba(242, 201, 76, 0.35); }
.badge-warn .badge-dot { background: var(--warning); }
.badge-danger { color: var(--danger); border-color: rgba(235, 87, 87, 0.35); }
.badge-danger .badge-dot { background: var(--danger); }
.badge-neutral { color: var(--text-muted); }
.badge-neutral .badge-dot { background: var(--text-dim); }

/* ---------- Code / key display ---------- */
.code-line {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  font-family: var(--font-mono); font-size: 13px; color: var(--text);
  overflow-x: auto;
}
.copy-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; flex: none;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: transparent; color: var(--text-muted); cursor: pointer;
  transition: background 0.14s var(--ease), color 0.14s var(--ease);
}
.copy-btn:hover { background: var(--subtle); color: var(--text); }
.copy-btn.copied { color: var(--success); border-color: rgba(76, 195, 138, 0.4); }

/* ---------- Spinner ---------- */
.spinner {
  width: 16px; height: 16px; flex: none;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--text);
  border-radius: 50%;
  animation: allmcp-spin 0.7s linear infinite;
}
@keyframes allmcp-spin { to { transform: rotate(360deg); } }
@keyframes allmcp-shimmer { 0% { opacity: 0.5; } 50% { opacity: 1; } 100% { opacity: 0.5; } }
.skeleton { background: var(--subtle); border-radius: var(--radius); animation: allmcp-shimmer 1.4s ease-in-out infinite; }

/* ---------- Toast (via ui.js) — design 3d: bottom-center pill with
   optional divider + action slot (Undo w/ 18px countdown ring) ---------- */
.toast-host {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  z-index: 1000; display: flex; flex-direction: column; gap: 10px; align-items: center;
}
.toast {
  display: flex; align-items: center; gap: 14px;
  max-width: 520px; padding: 10px 16px;
  background: var(--subtle); border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  font-size: 13px; color: var(--text); white-space: nowrap;
  animation: toast-in 0.2s var(--ease);
}
.toast .toast-divider { width: 1px; height: 16px; background: rgba(255, 255, 255, 0.12); flex: none; }
.toast .toast-action {
  display: flex; align-items: center; gap: 7px; flex: none;
  background: none; border: none; padding: 0; font: inherit; font-size: 13px;
  color: var(--text); font-weight: 500; cursor: pointer;
}
.toast .toast-action:hover { color: #fff; }
.toast .toast-ring { transform: rotate(-90deg); flex: none; }
.toast .toast-ring .ring-track { stroke: rgba(255, 255, 255, 0.15); }
.toast .toast-ring .ring-fill { stroke: currentColor; stroke-linecap: round; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Error strip (design 6c — canonical shape everywhere) ---------- */
.err-strip {
  display: flex; align-items: center; gap: 10px; padding: 11px 16px;
  border: 1px solid rgba(235, 87, 87, 0.3); border-radius: var(--radius);
  background: rgba(235, 87, 87, 0.05);
  font-size: 13px; color: var(--text);
}
.err-strip .msg { line-height: 1.45; }
.err-strip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--danger); flex: none; }
.err-strip .code { font-family: var(--font-mono); font-size: 10px; color: var(--text-dim); margin-left: auto; flex: none; }

/* ---------- Modal / drawer (via ui.js) ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 900;
  background: rgba(0, 0, 0, 0.55);
  display: flex; align-items: center; justify-content: center;
  padding: 20px; animation: fade-in 0.15s var(--ease);
}
.modal {
  width: 100%; max-width: 460px; background: var(--panel);
  border: 1px solid var(--border-strong); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop); animation: modal-in 0.16s var(--ease);
}
.modal-pad { padding: 26px 28px; }
.modal-title { font-size: 17px; font-weight: 600; margin-bottom: 8px; }
.modal-body { font-size: 13.5px; color: var(--text-muted); line-height: 1.6; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(0.99); } to { opacity: 1; transform: none; } }

/* ---------- Wordmark ---------- */
.wordmark { display: inline-flex; align-items: center; gap: 9px; font-weight: 600; letter-spacing: -0.01em; color: var(--text); }
.wordmark svg { flex: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
