/* quack system — the one dark instrument language for /hub, /account and /admin.
   elevation is lightness (canvas → panel → raised → pop), borders are white at low
   alpha, motion is .22,1,.36,1 with exits faster. served at /auth/ui/system.css. */

:root {
  --bg: #0b0c0e;
  --panel: #121417;
  --raised: #191c20;
  --pop: #212429;
  --inset: #08090b;
  --line: rgba(255, 255, 255, .06);
  --line-2: rgba(255, 255, 255, .10);
  --line-3: rgba(255, 255, 255, .16);
  --ring: 0 0 0 1px rgba(255, 255, 255, .08);
  --shadow-float: 0 25px 50px -12px rgba(0, 0, 0, .6);
  --ink: #eceef1;
  --ink-2: #b3b8c2;
  --ink-3: #858b98;
  --ink-4: #565c68;
  --ink-5: #3a3f49;
  --accent: #ffd23f;
  --accent-soft: rgba(255, 210, 63, .12);
  --accent-line: rgba(255, 210, 63, .32);
  --accent-ink: #221b00;
  --ok: #4ade80;
  --ok-soft: rgba(74, 222, 128, .10);
  --ok-line: rgba(74, 222, 128, .30);
  --warn: #facc15;
  --err: #f87171;
  --err-soft: rgba(248, 113, 113, .10);
  --err-line: rgba(248, 113, 113, .30);
  --info: #6ea8fe;
  --info-soft: rgba(110, 168, 254, .10);
  --info-line: rgba(110, 168, 254, .30);
  --sel: rgba(110, 168, 254, .28);
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Spline Sans Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --r-ctl: 7px;
  --r-card: 12px;
  --r-shell: 16px;
  --ease: cubic-bezier(.22, 1, .36, 1);
  --d-in: 250ms;
  --d-quick: 140ms;
  --d-out: 150ms;
}

* { box-sizing: border-box; }
html { color-scheme: dark; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 14px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
::selection { background: var(--sel); }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
a { color: var(--info); text-decoration: none; }
a:hover { text-decoration: underline; }
svg { flex: none; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
input:focus-visible, textarea:focus-visible, [contenteditable]:focus-visible { outline: none; }

.scroll { scrollbar-width: thin; scrollbar-color: var(--ink-5) transparent; }
.scroll::-webkit-scrollbar { width: 9px; height: 9px; }
.scroll::-webkit-scrollbar-thumb {
  background: var(--ink-5); border-radius: 9px;
  border: 3px solid transparent; background-clip: content-box;
}
.scroll::-webkit-scrollbar-thumb:hover { background: var(--ink-4); border: 3px solid transparent; background-clip: content-box; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 30px; padding: 0 12px; border-radius: var(--r-ctl);
  font-size: 12.5px; font-weight: 550; white-space: nowrap;
  background: var(--raised); border: 1px solid var(--line-2); color: var(--ink-2);
  transition: background var(--d-quick) var(--ease), color var(--d-quick) var(--ease),
    border-color var(--d-quick) var(--ease);
}
.btn:hover { background: var(--pop); color: var(--ink); border-color: var(--line-3); }
.btn:active { transform: scale(.97); }
.btn.ghost { background: none; border-color: transparent; }
.btn.ghost:hover { background: var(--raised); }
.btn.icon { width: 30px; padding: 0; }
.btn.acc { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 620; }
.btn.acc:hover { background: #ffdc66; color: var(--accent-ink); }
.btn.danger { color: var(--err); }
.btn.danger:hover { background: var(--err-soft); border-color: var(--err-line); color: var(--err); }
.btn.quiet { height: 26px; padding: 0 9px; font-size: 12px; }
.btn[disabled] { opacity: .45; pointer-events: none; }

/* ---------- fields ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label {
  font-size: 11px; letter-spacing: .06em; text-transform: uppercase;
  color: var(--ink-4); font-weight: 600;
}
.field .hint { font-size: 11.5px; color: var(--ink-4); line-height: 1.45; }
.inp {
  width: 100%; padding: 8px 11px; background: var(--inset); color: var(--ink);
  border: 1px solid var(--line-2); border-radius: var(--r-ctl); font: inherit;
  font-size: 13.5px; transition: border-color var(--d-quick) var(--ease), box-shadow var(--d-quick) var(--ease);
}
.inp::placeholder { color: var(--ink-4); }
.inp:focus { border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea.inp { resize: vertical; min-height: 64px; line-height: 1.5; }
.row { display: flex; gap: 8px; align-items: center; min-width: 0; }

/* a select that is actually a button — the menu it opens is a .menu */
.selbtn {
  display: inline-flex; align-items: center; gap: 8px; height: 30px; padding: 0 10px;
  background: var(--inset); border: 1px solid var(--line-2); border-radius: var(--r-ctl);
  font-size: 12.5px; color: var(--ink-2); min-width: 0;
  transition: border-color var(--d-quick) var(--ease), color var(--d-quick) var(--ease);
}
.selbtn:hover { border-color: var(--line-3); color: var(--ink); }
.selbtn .sel-v { flex: 1; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.selbtn svg { color: var(--ink-4); }

/* ---------- switch ---------- */
.sw {
  flex: none; width: 34px; height: 20px; border-radius: 999px; background: var(--inset);
  border: 1px solid var(--line-2); padding: 2px; display: flex;
  transition: background var(--d-quick) var(--ease), border-color var(--d-quick) var(--ease);
}
.sw i {
  width: 14px; height: 14px; border-radius: 50%; background: var(--ink-4);
  transition: transform var(--d-in) var(--ease), background var(--d-quick) var(--ease);
}
.sw.on { background: var(--accent); border-color: transparent; }
.sw.on i { transform: translateX(14px); background: var(--accent-ink); }

/* ---------- avatar ---------- */
.avatar {
  width: 24px; height: 24px; border-radius: 50%; flex: none; object-fit: cover;
  background: var(--raised); border: 1px solid var(--line-2);
  display: grid; place-items: center; font-size: 10.5px; font-weight: 640; color: var(--ink-2);
  overflow: hidden; user-select: none;
}
.avatar.lg { width: 64px; height: 64px; font-size: 24px; }
.avatar.xl { width: 88px; height: 88px; font-size: 32px; }

/* ---------- pills (the three-alpha formula) ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px;
  border-radius: 999px; font-size: 11.5px; font-weight: 550;
  background: rgba(255, 255, 255, .06); border: 1px solid var(--line-2); color: var(--ink-3);
}
.pill.ok { background: var(--ok-soft); border-color: var(--ok-line); color: var(--ok); }
.pill.err { background: var(--err-soft); border-color: var(--err-line); color: var(--err); }
.pill.acc { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); }
.pill.info { background: var(--info-soft); border-color: var(--info-line); color: var(--info); }

.kbd {
  font: 500 10px/1 var(--mono); color: var(--ink-4);
  border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 4px; padding: 3px 5px;
  background: var(--raised);
}

/* ---------- menus & layers ---------- */
.menu {
  position: fixed; z-index: 130; min-width: 180px; max-width: 320px;
  background: var(--pop); border: 1px solid var(--line-2); border-radius: 10px;
  box-shadow: var(--shadow-float), var(--ring); padding: 5px;
  animation: menu-in var(--d-in) var(--ease);
}
.menu.closing { animation: menu-out var(--d-out) var(--ease) forwards; }
@keyframes menu-in { from { opacity: 0; transform: scale(.97); } }
@keyframes menu-out { to { opacity: 0; transform: scale(.99); } }
.menu .mi {
  display: flex; align-items: center; gap: 9px; width: 100%; padding: 7px 9px;
  border-radius: 6px; font-size: 13px; color: var(--ink-2); cursor: pointer;
  text-align: left; min-width: 0; transition: background 60ms linear, color 60ms linear;
}
.menu .mi > svg { color: var(--ink-3); }
.menu .mi .mi-t { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu .mi .mi-sub { display: block; font-size: 11px; color: var(--ink-4); }
.menu .mi .mi-k { margin-left: auto; }
.menu .mi.hl { background: var(--raised); color: var(--ink); }
.menu .mi.hl > svg { color: var(--ink-2); }
.menu .mi.on { color: var(--ink); }
.menu .mi.on .mi-check { color: var(--accent); }
.menu .mi.danger { color: var(--err); }
.menu .mi.danger > svg { color: var(--err); }
.menu .mi.danger.hl { background: var(--err-soft); }
.menu .msep { height: 1px; background: var(--line); margin: 5px 4px; }
.menu .mhead {
  padding: 6px 9px 4px; font-size: 10.5px; letter-spacing: .07em;
  text-transform: uppercase; color: var(--ink-4); font-weight: 620;
}

.scrim { position: fixed; inset: 0; background: rgba(3, 4, 6, .6); animation: fade var(--d-in) var(--ease); }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px) scale(.97); } }

.modal-wrap { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 20px; }
.modal {
  /* positioned + lifted on purpose: .scrim is a fixed sibling, so a static .modal paints
     UNDER it the moment the rise animation's transform stops making a stacking context.
     that was the dim sheet over every confirm dialog. */
  position: relative; z-index: 1;
  width: min(540px, 94vw); max-height: 86vh; display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--line-2); border-radius: var(--r-shell);
  box-shadow: var(--shadow-float); animation: rise var(--d-in) var(--ease); overflow: hidden;
}
.m-head {
  padding: 14px 18px; border-bottom: 1px solid var(--line); flex: none;
  display: flex; align-items: center; gap: 10px;
  font-size: 14px; font-weight: 620; letter-spacing: -.01em;
}
.m-head .m-x { margin-left: auto; }
.m-body { padding: 16px 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.m-foot {
  padding: 12px 18px; border-top: 1px solid var(--line); flex: none;
  display: flex; gap: 8px; justify-content: flex-end; align-items: center;
}
.m-foot .foot-note { margin-right: auto; font-size: 11.5px; color: var(--ink-4); }

#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 140; }
.toast {
  display: flex; align-items: center; gap: 9px;
  background: var(--pop); border: 1px solid var(--line-2); border-radius: 9px;
  padding: 10px 14px; font-size: 13px; box-shadow: var(--shadow-float);
  animation: toast-in 350ms var(--ease);
}
.toast svg { color: var(--ok); }
.toast.err svg { color: var(--err); }
@keyframes toast-in { from { opacity: 0; transform: translateY(14px); filter: blur(2px); } }

/* ---------- cards (account / admin surfaces) ---------- */
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-card);
  padding: 18px; min-width: 0;
}
.card .card-h {
  display: flex; align-items: center; gap: 9px; margin: 0 0 4px;
  font-size: 13.5px; font-weight: 620; letter-spacing: -.01em; color: var(--ink);
}
.card .card-h svg { color: var(--ink-3); }
.card .card-sub { font-size: 12px; color: var(--ink-4); margin: 0 0 14px; line-height: 1.5; }

.stat .stat-l {
  font-size: 11px; font-weight: 550; letter-spacing: .06em; text-transform: uppercase;
  color: var(--ink-4);
}
.stat .stat-v {
  font-size: 26px; font-weight: 650; letter-spacing: -.02em;
  font-variant-numeric: tabular-nums; margin-top: 2px;
}
.mono { font-family: var(--mono); }
.num { font-variant-numeric: tabular-nums; }

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