/* Builder UI tokens and primitives shared by the dashboard and the editor. */
:root {
  --bg: #0e0e12; --bg-1: #15151b; --bg-2: #1c1c24; --bg-3: #24242e;
  --line: #2a2a36; --line-2: #34344280;
  --fg: #ececf1; --fg-1: #b4b4c2; --fg-2: #7c7c8e; --fg-3: #55556a;
  --accent: #6366f1; --accent-2: #818cf8; --accent-soft: rgba(99,102,241,.16);
  --ok: #34d399; --warn: #fbbf24; --danger: #f87171;
  --r: 8px; --r-lg: 12px;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --shadow: 0 10px 40px rgba(0,0,0,.45), 0 1px 0 rgba(255,255,255,.04) inset;
  color-scheme: dark;
}
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
::selection { background: var(--accent-soft); }
[hidden] { display: none !important; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: var(--r); border: 1px solid var(--line); background: var(--bg-2); color: var(--fg); font-weight: 500; white-space: nowrap; transition: background .12s, border-color .12s, transform .06s; user-select: none; }
.btn:hover { background: var(--bg-3); border-color: #3a3a4a; text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #575af0; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--fg-1); }
.btn.ghost:hover { background: var(--bg-2); color: var(--fg); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: rgba(248,113,113,.12); border-color: rgba(248,113,113,.3); }
.btn.sm { height: 26px; padding: 0 8px; font-size: 12.5px; border-radius: 6px; }
.btn.icon { width: 32px; padding: 0; }
.btn.icon.sm { width: 26px; }
.btn svg { width: 16px; height: 16px; flex: none; }

.input, .select, .textarea { width: 100%; height: 32px; padding: 0 10px; border-radius: var(--r); border: 1px solid var(--line); background: var(--bg-1); color: var(--fg); outline: none; transition: border-color .12s, box-shadow .12s; }
.textarea { height: auto; padding: 8px 10px; resize: vertical; min-height: 72px; line-height: 1.45; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input::placeholder { color: var(--fg-3); }
.select { appearance: none; padding-right: 26px; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237c7c8e' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>"); background-repeat: no-repeat; background-position: right 8px center; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: 12px; font-weight: 500; color: var(--fg-1); }
.hint { font-size: 12px; color: var(--fg-2); }
.kbd { display: inline-block; padding: 1px 5px; border-radius: 4px; border: 1px solid var(--line); background: var(--bg-2); font: 11px/1.4 var(--mono); color: var(--fg-1); }

.card { background: var(--bg-1); border: 1px solid var(--line); border-radius: var(--r-lg); }
.muted { color: var(--fg-2); }
.row { display: flex; align-items: center; gap: 8px; }
.grow { flex: 1; min-width: 0; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: grid; place-items: center; z-index: 100; padding: 16px; backdrop-filter: blur(4px); }
.modal { width: 100%; max-width: 520px; background: var(--bg-1); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.modal h2 { margin: 0; font-size: 16px; font-weight: 600; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; }

/* toast */
.toasts { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 200; pointer-events: none; }
.toast { background: var(--bg-2); border: 1px solid var(--line); color: var(--fg); padding: 9px 14px; border-radius: 10px; box-shadow: var(--shadow); font-size: 13px; animation: toast-in .18s ease-out; pointer-events: auto; display: flex; gap: 10px; align-items: center; }
.toast.ok { border-color: rgba(52,211,153,.4); } .toast.err { border-color: rgba(248,113,113,.5); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

.spinner { width: 14px; height: 14px; border: 2px solid var(--line); border-top-color: var(--accent-2); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
