/* xac.lol relay portal — shared design system */
:root {
  --ink: #09090d;
  --ink-2: #0f1016;
  --surface: #14151d;
  --raised: #1b1d27;
  --raised-2: #232633;
  --line: rgba(255, 255, 255, 0.07);
  --line-strong: rgba(255, 255, 255, 0.14);
  --text: #f1efe9;
  --muted: #9a98a3;
  --faint: #66646f;
  --ember: #ff6a3d;
  --ember-2: #ff9a5c;
  --ember-glow: rgba(255, 106, 61, 0.35);
  --mint: #4fe0a5;
  --amber: #ffc25c;
  --rose: #ff5577;
  --violet: #a594ff;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: none;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --font: "Instrument Sans", system-ui, -apple-system, sans-serif;
  --display: "Bricolage Grotesque", "Instrument Sans", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--ink);
  color: var(--text);
  font: 15px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: inherit; }
::selection { background: var(--ember); color: #160803; }
:focus-visible { outline: 2px solid var(--ember); outline-offset: 3px; border-radius: 8px; }

h1, h2, h3 { font-family: var(--display); letter-spacing: -0.02em; margin: 0; font-weight: 650; }
h1 { font-size: clamp(30px, 5vw, 44px); line-height: 1.05; }
h2 { font-size: 21px; }
h3 { font-size: 16px; }
p { margin: 0; }
code, .mono { font-family: var(--mono); font-size: 0.88em; }

/* ---- layout ---------------------------------------------------------- */
.shell { position: relative; z-index: 1; max-width: 1120px; margin: 0 auto; padding: 0 20px 80px; }
.shell.narrow { max-width: 820px; }
.stack { display: grid; gap: 16px; }
.row { display: flex; align-items: center; gap: 12px; }
.row.wrap { flex-wrap: wrap; }
.spread { justify-content: space-between; }
.grid-2 { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); }
.grid-2 > *, .stack > *, .card { min-width: 0; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 13px; }
.eyebrow { font: 600 11px/1 var(--mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--faint); }

/* ---- top bar --------------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 18px;
  max-width: 1120px; margin: 0 auto; padding: 18px 20px;
  backdrop-filter: blur(14px) saturate(1.4);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
}
.topbar::after {
  content: ""; position: absolute; left: 20px; right: 20px; bottom: 0; height: 1px;
  background: var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font: 650 17px var(--display); letter-spacing: -0.02em; }
.brand .mark { width: 30px; height: 30px; color: var(--ember); }
.brand small { font: 500 11px var(--mono); color: var(--faint); letter-spacing: 0.06em; }
.nav { display: flex; gap: 4px; margin-left: auto; }
.nav a {
  text-decoration: none; color: var(--muted); padding: 7px 12px; border-radius: 999px; font-weight: 550; font-size: 14px;
  transition: color .2s, background .2s;
}
.nav a:hover { color: var(--text); background: var(--raised); }
.nav a[aria-current="page"] { color: var(--text); background: var(--raised-2); }
@media (max-width: 560px) {
  .brand small { display: none; }
  .nav { gap: 0; }
  .nav a { padding: 7px 8px; font-size: 13px; white-space: nowrap; }
  .nav a .g { width: 18px; height: 18px; }
  /* admins get 4 links; the mark alone carries the brand on phones */
  .topbar.crowded .brand span { display: none; }
}

/* ---- cards ----------------------------------------------------------- */
.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}
.card.tight { padding: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.card-head .title { display: flex; align-items: center; gap: 10px; }
.card-head .title .g { width: 22px; height: 22px; color: var(--ember); }
.divider { height: 1px; background: var(--line); margin: 18px 0; border: 0; }

/* ---- buttons --------------------------------------------------------- */
.btn {
  --bg: var(--raised-2); --fg: var(--text); --bd: var(--line-strong);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 16px; border-radius: 999px;
  background: var(--bg); color: var(--fg); border: 1px solid var(--bd);
  font: 600 14px var(--font); text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: transform .18s var(--spring), background .2s, border-color .2s, box-shadow .25s, opacity .2s;
  -webkit-tap-highlight-color: transparent; user-select: none;
}
.btn:hover { border-color: rgba(255, 255, 255, 0.24); }
.btn:active { transform: scale(0.96); }
.btn .g { width: 17px; height: 17px; }
.btn.primary {
  --bg: var(--ember); --fg: #1a0904; --bd: transparent;
}
.btn.primary:hover { --bg: var(--ember-2); }
.btn.ghost { --bg: transparent; --bd: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--raised); }
.btn.danger { --bg: rgba(255, 85, 119, 0.12); --fg: #ff8fa5; --bd: rgba(255, 85, 119, 0.28); }
.btn.sm { min-height: 32px; padding: 0 12px; font-size: 13px; }
.btn.icon { width: 36px; min-height: 36px; padding: 0; }
.btn.block { width: 100%; }
.btn[disabled], .btn.busy { opacity: 0.6; pointer-events: none; }
.btn.busy::after {
  content: ""; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite;
}
.btn.done { --bg: rgba(79, 224, 165, 0.14); --bd: rgba(79, 224, 165, 0.35); --fg: var(--mint); }

/* ---- forms ----------------------------------------------------------- */
label.field { display: grid; gap: 7px; font-weight: 550; font-size: 13px; color: var(--muted); }
.input {
  width: 100%; min-height: 46px; padding: 0 14px; border-radius: var(--radius-sm);
  background: var(--ink-2); color: var(--text); border: 1px solid var(--line-strong);
  font: 500 15px var(--font); transition: border-color .2s, box-shadow .2s;
}
.input:focus { outline: none; border-color: var(--ember); box-shadow: 0 0 0 4px rgba(255, 106, 61, 0.15); }
.input.mono { font-family: var(--mono); font-size: 14px; }
.input-wrap { position: relative; }
.input-wrap .btn { position: absolute; right: 5px; top: 5px; }
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 550; }
.switch input { appearance: none; width: 40px; height: 24px; border-radius: 999px; background: var(--raised-2); border: 1px solid var(--line-strong); position: relative; cursor: pointer; transition: background .2s; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--muted); transition: transform .25s var(--spring), background .2s; }
.switch input:checked { background: rgba(255, 106, 61, 0.25); border-color: var(--ember); }
.switch input:checked::after { transform: translateX(16px); background: var(--ember); }

/* segmented control */
.seg { display: inline-flex; padding: 4px; gap: 2px; border-radius: 999px; background: var(--ink-2); border: 1px solid var(--line); flex-wrap: wrap; }
.seg button {
  border: 0; background: transparent; color: var(--muted); font: 600 13px var(--font);
  padding: 7px 14px; border-radius: 999px; cursor: pointer; display: inline-flex; align-items: center; gap: 7px;
  transition: color .2s, background .25s var(--ease);
}
.seg button .g { width: 16px; height: 16px; }
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--raised-2); color: var(--text); }

/* ---- copy field ------------------------------------------------------ */
.copy {
  display: flex; align-items: stretch; gap: 0; border-radius: var(--radius-sm);
  background: var(--ink-2); border: 1px solid var(--line-strong); overflow: hidden;
}
.copy .val {
  flex: 1; min-width: 0; padding: 12px 14px; font: 500 13px/1.5 var(--mono); color: var(--text);
  word-break: break-all; user-select: all;
}
.copy .val.masked { color: var(--faint); letter-spacing: 0.12em; user-select: none; }
.copy .acts { display: flex; align-items: center; gap: 4px; padding: 0 6px; border-left: 1px solid var(--line); }
.copy-label { display: flex; justify-content: space-between; align-items: baseline; margin: 0 0 7px; font-size: 13px; color: var(--muted); font-weight: 550; }

pre.code {
  margin: 0; padding: 16px; border-radius: var(--radius-sm); background: var(--ink-2); border: 1px solid var(--line);
  font: 500 12.5px/1.65 var(--mono); color: #e6e2d8; overflow-x: auto; white-space: pre;
}
pre.code .k { color: var(--ember-2); }
pre.code .s { color: var(--mint); }

/* ---- pills & status -------------------------------------------------- */
.pill {
  display: inline-flex; align-items: center; gap: 7px; height: 26px; padding: 0 11px; border-radius: 999px;
  font: 600 12px var(--font); background: var(--raised-2); color: var(--muted); border: 1px solid var(--line); white-space: nowrap;
}
.pill.live { background: rgba(255, 106, 61, 0.14); color: var(--ember-2); border-color: rgba(255, 106, 61, 0.35); }
.pill.ok { background: rgba(79, 224, 165, 0.1); color: var(--mint); border-color: rgba(79, 224, 165, 0.28); }
.pill.warn { background: rgba(255, 194, 92, 0.1); color: var(--amber); border-color: rgba(255, 194, 92, 0.28); }
.pill.bad { background: rgba(255, 85, 119, 0.1); color: #ff8fa5; border-color: rgba(255, 85, 119, 0.28); }
.pill.admin { background: rgba(165, 148, 255, 0.12); color: var(--violet); border-color: rgba(165, 148, 255, 0.3); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }
.pill.live .dot, .dot.live { background: var(--ember); box-shadow: 0 0 0 0 var(--ember-glow); animation: pulse 1.6s var(--ease) infinite; }

/* ---- stats ----------------------------------------------------------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); background: var(--ink-2); border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--line); }
/* hairlines between cells; the -1px margins tuck the outer edges under the border */
.stat { padding: 12px 14px; min-width: 0; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); margin: 0 -1px -1px 0; }
.stat .k { font: 600 10.5px var(--mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--faint); }
.stat .v { font: 600 17px/1.3 var(--display); margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.stat .v small { font: 500 12px var(--font); color: var(--muted); margin-left: 3px; }
.stat .v.good { color: var(--mint); } .stat .v.warn { color: var(--amber); } .stat .v.bad { color: #ff8fa5; }

/* ---- glyphs ---------------------------------------------------------- */
.g { display: inline-block; flex: none; width: 20px; height: 20px; vertical-align: middle; }
.g path, .g circle, .g rect, .g line, .g polyline { vector-effect: non-scaling-stroke; }
.g.draw path, .g.draw circle, .g.draw polyline { stroke-dasharray: 120; stroke-dashoffset: 120; animation: draw 1.1s var(--ease) forwards; }
.g.draw :nth-child(2) { animation-delay: .12s; } .g.draw :nth-child(3) { animation-delay: .24s; } .g.draw :nth-child(4) { animation-delay: .36s; }

/* ---- toast ----------------------------------------------------------- */
.toasts { position: fixed; z-index: 100; left: 50%; bottom: 24px; transform: translateX(-50%); display: grid; gap: 8px; width: min(420px, calc(100vw - 32px)); pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 14px;
  background: rgba(35, 38, 51, 0.92); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--line-strong); font-weight: 550; font-size: 14px;
  animation: toast-in .45s var(--spring); pointer-events: auto;
}
.toast.out { animation: toast-out .3s var(--ease) forwards; }
.toast .g { width: 18px; height: 18px; }
.toast.ok .g { color: var(--mint); } .toast.err .g { color: var(--rose); } .toast.info .g { color: var(--ember); }

/* ---- modal ----------------------------------------------------------- */
.scrim { position: fixed; inset: 0; z-index: 50; background: rgba(5, 5, 8, 0.66); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); display: grid; place-items: center; padding: 16px; animation: fade .25s var(--ease); }
.modal { width: min(520px, 100%); max-height: calc(100vh - 32px); overflow: auto; animation: rise .4s var(--spring); }
.modal.wide { width: min(760px, 100%); }
.scrim.out { animation: fade .2s var(--ease) reverse forwards; }

/* ---- misc ------------------------------------------------------------ */
.empty { display: grid; place-items: center; gap: 10px; padding: 34px 16px; text-align: center; color: var(--muted); }
.empty .g { width: 44px; height: 44px; color: var(--faint); }
.skeleton { background: var(--raised); animation: blink-soft 1.4s ease-in-out infinite; border-radius: 10px; }
.fade-in { animation: rise .5s var(--ease) both; }
.shake { animation: shake .45s var(--ease); }
.kbd { font: 600 11px var(--mono); padding: 2px 6px; border-radius: 6px; background: var(--raised-2); border: 1px solid var(--line-strong); }
.hide { display: none !important; }
.callout { display: flex; gap: 12px; padding: 14px 16px; border-radius: var(--radius-sm); background: rgba(255, 194, 92, 0.06); border: 1px solid rgba(255, 194, 92, 0.2); color: #f0dcb4; font-size: 14px; }
.callout .g { color: var(--amber); width: 20px; height: 20px; margin-top: 1px; }
.callout.tip { background: rgba(255, 106, 61, 0.06); border-color: rgba(255, 106, 61, 0.2); color: #f3d6cb; }
.callout.tip .g { color: var(--ember); }

video.preview { width: 100%; aspect-ratio: 16 / 9; background: #000 center / 56px no-repeat; border-radius: var(--radius-sm); border: 1px solid var(--line); display: block; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 var(--ember-glow); } 70% { box-shadow: 0 0 0 9px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(14px) scale(.96); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px) scale(.98); } }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(12px) scale(.985); } }
@keyframes blink-soft { 50% { opacity: .55; } }
@keyframes shake { 20%, 60% { transform: translateX(-7px); } 40%, 80% { transform: translateX(7px); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .g.draw path, .g.draw circle, .g.draw polyline { stroke-dashoffset: 0; }
}
