/* LibGate — shared monochrome design system */
:root {
  --bg: #ffffff;
  --bg-2: #f6f6f5;
  --bg-3: #ececea;
  --ink: #0a0a0a;
  --ink-2: #3d3d3b;
  --ink-3: #75756f;
  --ink-4: #a9a9a3;
  --line: #e2e2df;
  --line-2: #cfcfcb;
  --inv: #ffffff;
  --accent: #0a0a0a;
  --ok: #1d7a46;
  --warn: #9a6400;
  --bad: #b3261e;
  --page: #f4f4f2;
  --surface: #ffffff;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.03), 0 2px 10px rgba(0,0,0,.035);
  --shadow: 0 1px 2px rgba(0,0,0,.03), 0 10px 30px rgba(0,0,0,.06);
  --shadow-lg: 0 30px 80px rgba(0,0,0,.16);
  --r: 22px;
  --r-sm: 12px;
  --ease: cubic-bezier(.2,.8,.2,1);
  --spring: cubic-bezier(.34,1.36,.5,1);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "Cascadia Code", Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0b0b; --bg-2: #141414; --bg-3: #1d1d1d;
    --ink: #f4f4f2; --ink-2: #cacac6; --ink-3: #8e8e88; --ink-4: #5c5c58;
    --line: #262626; --line-2: #343434; --inv: #0b0b0b; --accent: #f4f4f2;
    --ok: #5cc98a; --warn: #e0a740; --bad: #f2776e;
    --page: #0a0a0a; --surface: #151515;
    --shadow-sm: 0 1px 0 rgba(255,255,255,.03) inset, 0 2px 10px rgba(0,0,0,.35);
    --shadow: 0 1px 0 rgba(255,255,255,.04) inset, 0 12px 32px rgba(0,0,0,.45);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b0b0b; --bg-2: #141414; --bg-3: #1d1d1d;
  --ink: #f4f4f2; --ink-2: #cacac6; --ink-3: #8e8e88; --ink-4: #5c5c58;
  --line: #262626; --line-2: #343434; --inv: #0b0b0b; --accent: #f4f4f2;
  --ok: #5cc98a; --warn: #e0a740; --bad: #f2776e;
  --page: #0a0a0a; --surface: #151515;
  --shadow-sm: 0 1px 0 rgba(255,255,255,.03) inset, 0 2px 10px rgba(0,0,0,.35);
  --shadow: 0 1px 0 rgba(255,255,255,.04) inset, 0 12px 32px rgba(0,0,0,.45);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--page);
  color: var(--ink);
  font: 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  transition: background .35s var(--ease), color .35s var(--ease);
}
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: var(--ink); color: var(--inv); }
.mono { font-family: var(--mono); font-feature-settings: "zero"; }
.muted { color: var(--ink-3); }
.hidden { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 16px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  cursor: pointer; font-weight: 500; white-space: nowrap; text-decoration: none;
  transition: transform .3s var(--spring), background .25s, border-color .25s, color .25s, box-shadow .3s;
}
.btn:hover { border-color: var(--ink-4); box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--ink); color: var(--inv); border-color: var(--ink); }
.btn.primary:hover { opacity: .9; box-shadow: 0 8px 20px color-mix(in srgb, var(--ink) 25%, transparent); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--bg-2); box-shadow: none; }
.btn.danger { color: var(--bad); }
.btn.danger:hover { border-color: var(--bad); }
.btn.sm { height: 30px; padding: 0 12px; font-size: 13px; }
.btn.icon { width: 38px; padding: 0; }
.btn.sm.icon { width: 30px; }
.btn svg { width: 16px; height: 16px; flex: none; }
.btn:disabled { opacity: .4; pointer-events: none; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 12px; color: var(--ink-3); font-weight: 500; letter-spacing: .02em; }
.input, select.input, textarea.input {
  height: 40px; padding: 0 14px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--surface); width: 100%;
  transition: border-color .2s, box-shadow .2s;
}
textarea.input { height: auto; padding: 10px 12px; resize: vertical; }
.input:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ink) 12%, transparent); }
.checkbox { display: inline-flex; gap: 8px; align-items: center; cursor: pointer; }
.checkbox input { accent-color: var(--ink); width: 16px; height: 16px; }

/* ---------- Surfaces ---------- */
.card {
  background: var(--surface); border: 1px solid color-mix(in srgb, var(--line) 55%, transparent); border-radius: var(--r);
  box-shadow: var(--shadow-sm);
  transition: box-shadow .4s var(--ease), transform .4s var(--ease), background .35s, border-color .3s;
}
.pill {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px;
  border-radius: 999px; font-size: 12px; font-weight: 500;
  border: 1px solid var(--line-2); color: var(--ink-2); white-space: nowrap;
}
.pill.solid { background: var(--ink); color: var(--inv); border-color: var(--ink); }
.pill.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.pill.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.pill.bad { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, transparent); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.dot.live { animation: pulse 1.8s infinite; }
@keyframes pulse { 0%{ box-shadow: 0 0 0 0 color-mix(in srgb, currentColor 50%, transparent);} 70%{ box-shadow: 0 0 0 7px transparent;} 100%{ box-shadow: 0 0 0 0 transparent;} }

.avatar {
  width: 40px; height: 40px; border-radius: 50%; flex: none; overflow: hidden;
  display: grid; place-items: center; font-weight: 600; font-size: 14px;
  background: var(--bg-3); color: var(--ink); border: 1px solid var(--line);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.t { background: var(--ink); color: var(--inv); border-color: var(--ink); }

/* ---------- Toasts ---------- */
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 1000; }
.toast {
  min-width: 240px; max-width: 380px; padding: 12px 16px; border-radius: 12px;
  background: var(--ink); color: var(--inv); box-shadow: var(--shadow-lg);
  animation: toastIn .35s var(--ease); font-size: 13px;
}
.toast.out { animation: toastOut .3s var(--ease) forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px) scale(.98); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(8px); } }

/* ---------- Modal ---------- */
.modal-bg {
  position: fixed; inset: 0; background: rgba(0,0,0,.32); backdrop-filter: blur(8px) saturate(1.2);
  display: grid; place-items: center; z-index: 900; padding: 16px;
  animation: fade .25s var(--ease);
}
@media (prefers-reduced-motion: no-preference) { .modal { animation-timing-function: var(--spring) !important; } }
.modal {
  background: var(--surface); border-radius: 26px; width: min(640px, 100%); max-height: calc(100vh - 32px);
  overflow: auto; box-shadow: var(--shadow-lg); border: 1px solid var(--line);
  animation: rise .35s var(--ease);
}
.modal header { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); z-index: 1; }
.modal header h3 { margin: 0; font-size: 16px; }
.modal .body { padding: 22px; }
.modal footer { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 22px; border-top: 1px solid var(--line); position: sticky; bottom: 0; background: var(--surface); }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(18px) scale(.97); } }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 640px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 10px; border: 3px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
