/* CodeGate (Altherix) — follows the altherix.in design system.
   Palette: #020D34 #121160 #331683 #5D1EA6 #9A22B9 #DF3AD2 #FA70A5 #F6B595 #F6F4F4
   One signature gradient, hairlines over boxes, two radii (8px controls, 12px containers). */

@font-face { font-family: "Inter"; font-style: normal; font-weight: 100 900; font-display: swap; src: url(/assets/fonts/inter-var.woff2) format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-style: normal; font-weight: 500; font-display: swap; src: url(/assets/fonts/jbmono-500.woff2) format("woff2"); }

:root {
  --bg: #020D34; --bg-raise: #06123f; --bg-deep: #010924; --bg-hover: #0a1850;
  --line: rgba(246,244,244,.10); --line-strong: rgba(246,244,244,.18);
  --ink: #F6F4F4; --ink-2: #C3C6D6; --ink-3: #9A9EB8;
  --accent: #FA70A5; --violet: #B69CFF; --magenta: #DF3AD2;
  --ok: #3ccf95; --ok-ink: #8fe3bd; --bad: #ff6b81; --warn: #F6B595;
  --grad: linear-gradient(90deg, #121160 0%, #5D1EA6 35%, #DF3AD2 75%, #FA70A5 100%);
  --grad-text: linear-gradient(92deg, #B69CFF 0%, #DF3AD2 50%, #FA70A5 100%);
  --grad-btn: linear-gradient(92deg, #5D1EA6 0%, #9A22B9 45%, #DF3AD2 100%);
  --sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --r-sm: 8px; --r: 12px; --top-h: 60px;
  --ease: cubic-bezier(.2,.7,.2,1);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--ink); font-family: var(--sans); font-size: 15px; line-height: 1.6; -webkit-font-smoothing: antialiased; font-feature-settings: "cv11", "ss01"; }
body::before { content: ""; position: fixed; z-index: -1; right: -20%; top: -20%; width: 80vw; height: 90vh; background: radial-gradient(closest-side, rgba(93,30,166,.22), transparent); pointer-events: none; }
h1, h2, h3, p, ul, ol { margin: 0; }
a { color: inherit; }
img, svg { display: block; max-width: 100%; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
::selection { background: #5D1EA6; color: #fff; }
.hidden { display: none !important; }

/* type */
.label { font-family: var(--mono); font-size: .72rem; font-weight: 500; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); }
.h1 { font-size: clamp(2rem, 4.4vw, 3.25rem); font-weight: 700; line-height: 1.05; letter-spacing: -.035em; }
.h2 { font-size: 1.375rem; font-weight: 600; line-height: 1.2; letter-spacing: -.02em; }
.h3 { font-size: 1rem; font-weight: 600; letter-spacing: -.01em; }
.sig { background: var(--grad-text); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lede { font-size: 1.0625rem; color: var(--ink-2); max-width: 58ch; }
.muted { color: var(--ink-3); }
.small { font-size: .8125rem; }
.mono { font-family: var(--mono); }
.err { color: var(--bad); font-size: .875rem; }
.err:empty { display: none; }

/* top bar */
.top { position: sticky; top: 0; z-index: 50; height: var(--top-h); display: flex; align-items: center; gap: 14px; padding: 0 clamp(16px, 3vw, 28px); background: rgba(2,13,52,.85); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); }
.top::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 1px; background: var(--grad); opacity: .9; }
.brand { display: flex; align-items: center; gap: .6rem; text-decoration: none; font-weight: 700; letter-spacing: .14em; font-size: .875rem; }
.brand img { width: 28px; height: 28px; }
.top .sep { width: 1px; height: 20px; background: var(--line-strong); }
.top .spacer { flex: 1; }

/* layout */
.wrap { max-width: 1160px; margin: 0 auto; padding: clamp(28px, 5vw, 56px) clamp(16px, 3vw, 28px) 64px; }
.wrap.narrow { max-width: 760px; }
.card { background: var(--bg-raise); border: 1px solid var(--line-strong); border-radius: var(--r); padding: clamp(18px, 2.4vw, 28px); }
.card + .card { margin-top: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.stack > * + * { margin-top: 16px; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .5rem; min-height: 40px; padding: .5rem 1rem; border-radius: var(--r-sm); font: inherit; font-weight: 600; font-size: .875rem; text-decoration: none; border: 1px solid var(--line-strong); background: transparent; color: var(--ink); cursor: pointer; white-space: nowrap; transition: background .2s, border-color .2s, transform .1s, opacity .2s; }
.btn:hover { border-color: rgba(246,244,244,.45); background: rgba(246,244,244,.04); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.btn.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn.primary:hover { background: #fff; }
.btn.grad { background: var(--grad-btn); border-color: transparent; color: #fff; box-shadow: 0 6px 24px -8px rgba(223,58,210,.55); }
.btn.grad:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); border-color: rgba(255,107,129,.35); }
.btn.danger:hover { background: rgba(255,107,129,.08); border-color: var(--bad); }
.btn.ghost { border-color: transparent; color: var(--ink-2); }
.btn.ghost:hover { color: var(--ink); background: rgba(246,244,244,.06); }
.btn.lg { min-height: 52px; padding: .8rem 1.5rem; font-size: 1rem; }
.btn.sm { min-height: 32px; padding: .3rem .7rem; font-size: .8125rem; }
.arr { display: inline-block; transition: transform .2s var(--ease); }
.btn:hover .arr { transform: translateX(3px); }
kbd { font-family: var(--mono); font-size: .7rem; padding: 1px 5px; border-radius: 4px; border: 1px solid currentColor; opacity: .6; }
.spin { width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* forms */
.field label { display: block; font-size: .8125rem; font-weight: 500; color: var(--ink-2); margin-bottom: .35rem; }
.field .opt { color: var(--ink-3); font-weight: 400; }
input, select, textarea { width: 100%; font: inherit; font-size: .9375rem; color: var(--ink); background: var(--bg); border: 1px solid var(--line-strong); border-radius: var(--r-sm); padding: .6rem .8rem; min-height: 42px; transition: border-color .2s; }
input:hover, select:hover, textarea:hover { border-color: rgba(246,244,244,.32); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ink); }
textarea { resize: vertical; min-height: 110px; }
select { appearance: none; -webkit-appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%), linear-gradient(135deg, var(--ink-3) 50%, transparent 50%); background-position: calc(100% - 18px) 55%, calc(100% - 13px) 55%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 2.2rem; }
select option { background: var(--bg); }

/* pills */
.pill { display: inline-flex; align-items: center; gap: .4rem; padding: 2px 10px; border-radius: 99px; font-size: .75rem; font-weight: 500; border: 1px solid var(--line-strong); color: var(--ink-2); white-space: nowrap; }
.pill.dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.ok { color: var(--ok-ink); border-color: rgba(60,207,149,.35); background: rgba(60,207,149,.08); }
.pill.warn { color: var(--warn); border-color: rgba(246,181,149,.35); background: rgba(246,181,149,.08); }
.pill.bad { color: var(--bad); border-color: rgba(255,107,129,.35); background: rgba(255,107,129,.08); }
.pill.live { color: var(--accent); border-color: rgba(250,112,165,.4); background: rgba(250,112,165,.08); }
.pill.live::before { animation: pulse 1.6s var(--ease) infinite; }
@keyframes pulse { 50% { opacity: .25; } }

/* code */
pre, code { font-family: var(--mono); font-variant-ligatures: none; font-feature-settings: "calt" 0; }
pre { margin: 0; background: var(--bg-deep); border: 1px solid var(--line); color: #e6e8f2; padding: 14px 16px; border-radius: var(--r-sm); overflow: auto; font-size: .8125rem; line-height: 1.65; }
code.inline { font-size: .85em; padding: 1px 6px; border-radius: 5px; background: rgba(182,156,255,.12); color: #d9ccff; }

/* error box */
.errbox { border: 1px solid rgba(255,107,129,.35); background: rgba(255,107,129,.06); color: #ffb3bf; border-radius: var(--r-sm); padding: .6rem .75rem; font-family: var(--mono); font-size: .78rem; margin-bottom: 8px; white-space: pre-wrap; }

/* tables */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 14px 12px; border-bottom: 1px solid var(--line); font-size: .875rem; vertical-align: middle; }
th { font-family: var(--mono); font-size: .68rem; font-weight: 500; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); padding-top: 4px; }
tbody tr { transition: background .15s; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover { background: rgba(246,244,244,.03); }
tbody tr:last-child td { border-bottom: 0; }

/* modal */
dialog { border: 1px solid var(--line-strong); border-radius: var(--r); background: var(--bg-raise); color: var(--ink); padding: 0; width: min(460px, calc(100vw - 32px)); box-shadow: 0 30px 80px -20px rgba(0,0,0,.6); }
dialog::backdrop { background: rgba(1,9,36,.7); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
dialog[open] { animation: pop .18s var(--ease); }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.modal-body { padding: 24px 24px 8px; }
.modal-body p { color: var(--ink-2); margin-top: .5rem; font-size: .9375rem; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 18px 24px 22px; }

/* toast */
#toasts { position: fixed; z-index: 200; bottom: 20px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; justify-items: center; pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-radius: 99px; background: var(--ink); color: var(--bg); font-size: .875rem; font-weight: 500; box-shadow: 0 12px 40px -10px rgba(0,0,0,.6); animation: toast-in .25s var(--ease); }
.toast.warn { background: var(--warn); }
.toast.bad { background: var(--bad); color: #fff; }
.toast.out { opacity: 0; transform: translateY(6px); transition: .25s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }

/* empty / state screens */
.state { text-align: center; padding: clamp(40px, 8vw, 80px) 24px; }
.state .icon { width: 64px; height: 64px; margin: 0 auto 22px; border-radius: 50%; display: grid; place-items: center; border: 1px solid var(--line-strong); background: rgba(246,244,244,.03); }
.state .icon.ok { border-color: rgba(60,207,149,.4); background: rgba(60,207,149,.08); color: var(--ok); }
.state .icon.bad { border-color: rgba(255,107,129,.4); background: rgba(255,107,129,.08); color: var(--bad); }
.state .h2 { font-size: 1.75rem; }
.state p { color: var(--ink-2); max-width: 46ch; margin: .75rem auto 0; }

/* footer */
.foot { position: relative; margin-top: 24px; padding: 28px clamp(16px, 3vw, 28px) 36px; }
.foot::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 1px; background: var(--grad); opacity: .7; }
.foot-in { max-width: 1160px; margin: 0 auto; display: flex; flex-wrap: wrap; gap: 1rem 2rem; align-items: center; justify-content: space-between; }
.foot .brand img { width: 22px; height: 22px; }
.foot .tag { font-size: .8125rem; color: var(--ink-3); margin-top: .35rem; }
.foot-links { display: flex; gap: .5rem; flex-wrap: wrap; }
.foot-links a, .links a { display: inline-flex; align-items: center; gap: .45rem; text-decoration: none; font-size: .8125rem; font-weight: 500; color: var(--ink-2); padding: .4rem .75rem; border-radius: var(--r-sm); border: 1px solid var(--line); transition: color .2s, border-color .2s; }
.foot-links a:hover, .links a:hover { color: var(--ink); border-color: rgba(246,244,244,.4); }
.foot-links svg, .links svg { width: 15px; height: 15px; }
.links { display: flex; gap: .6rem; justify-content: center; flex-wrap: wrap; margin-top: 1.25rem; }
.testing .foot { display: none; }
.testing .top .brand { pointer-events: none; }

.fade-in { animation: fade .35s var(--ease); }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } }

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