:root {
  --bg: #0d0d0d;
  --bg-2: #121212;
  --panel: #171717;
  --panel-2: #1c1c1c;
  --line: #2a2a2a;
  --line-2: #3a3a3a;
  --text: #f5f5f2;
  --muted: #a3a39c;
  --dim: #73736c;
  --acid: #dafa9c;
  --acid-2: #c6f19d;
  --ember: #ff6a45;
  --cyan: #9be8d8;
  --radius: 16px;
  --font-ui: "Host Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --shadow: 0 28px 80px rgba(0, 0, 0, .55);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font-family: inherit; font-size: inherit; }
button { color: inherit; cursor: pointer; }
a { color: var(--acid); text-decoration: none; }
:focus-visible { outline: 2px solid var(--acid); outline-offset: 2px; }

body::before {
  content: "";
  position: fixed; inset: 0; z-index: -3;
  background:
    radial-gradient(900px 600px at 6% -12%, rgba(218, 250, 156, .085), transparent 62%),
    radial-gradient(820px 560px at 102% 8%, rgba(155, 232, 216, .04), transparent 60%),
    radial-gradient(700px 700px at 55% 112%, rgba(255, 106, 69, .035), transparent 60%),
    linear-gradient(180deg, #121212, #0d0d0d 58%, #090909);
}
body::after {
  content: "";
  position: fixed; inset: 0; z-index: -2; pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, .018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .018) 1px, transparent 1px);
  background-size: 76px 76px;
  mask-image: radial-gradient(ellipse at 42% 6%, #000 22%, transparent 80%);
}

.shell { width: min(1240px, calc(100% - 40px)); margin: 0 auto; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
  padding: 16px 0;
  background: rgba(13, 13, 13, .74);
  backdrop-filter: blur(18px) saturate(120%);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.brand .wordmark {
  display: flex; align-items: baseline; gap: 4px; white-space: nowrap;
  font-family: var(--font-ui); font-weight: 700; font-size: 19px;
  letter-spacing: -.055em; text-transform: uppercase;
}
.brand .wordmark .slash { color: var(--acid); font-weight: 300; }
.brand .wordmark em { font-style: normal; color: transparent; -webkit-text-stroke: 1px var(--text); letter-spacing: .06em; }
.brand .tag {
  font-family: var(--font-mono); font-size: 8px; letter-spacing: .2em;
  text-transform: uppercase; color: var(--dim); white-space: nowrap;
}
.top-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.user-chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px;
  border: 1px solid var(--line-2); border-radius: 999px; background: rgba(20, 20, 20, .8);
  font-family: var(--font-mono); font-size: 10px; letter-spacing: .08em; color: var(--muted);
  max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.user-chip b { color: var(--text); font-weight: 500; }
.pill {
  display: inline-flex; align-items: center; gap: 8px; padding: 7px 11px;
  border: 1px solid var(--line-2); border-radius: 999px; background: rgba(20, 20, 20, .8);
  font-size: 11px; letter-spacing: .01em; color: var(--muted); white-space: nowrap;
}
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--dim); flex-shrink: 0; }
.pill.live { border-color: rgba(218, 250, 156, .42); color: var(--acid); }
.pill.live .dot { background: var(--acid); animation: pulse 1.7s ease-out infinite; }
.pill.warn { border-color: rgba(255, 106, 69, .42); color: var(--ember); }
.pill.warn .dot { background: var(--ember); }
.pill.busy { border-color: rgba(155, 232, 216, .42); color: var(--cyan); }
.pill.busy .dot { background: var(--cyan); animation: pulse 1.1s ease-out infinite; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(218, 250, 156, .45); }
  70% { box-shadow: 0 0 0 8px rgba(218, 250, 156, 0); }
  100% { box-shadow: 0 0 0 0 rgba(218, 250, 156, 0); }
}

/* ---------- buttons / fields ---------- */
.btn {
  appearance: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line-2); background: rgba(255, 255, 255, .015);
  border-radius: 10px; padding: 10px 15px; font-size: 12.5px; font-weight: 500;
  transition: .16s ease; white-space: nowrap;
}
.btn:hover:not(:disabled) { border-color: var(--acid); color: var(--acid); background: rgba(218, 250, 156, .05); transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: translateY(0) scale(.99); }
.btn:disabled { opacity: .35; cursor: not-allowed; }
.btn.primary { background: var(--acid); border-color: var(--acid); color: #11160b; font-weight: 700; }
.btn.primary:hover:not(:disabled) { background: #e9ff7a; color: #11160b; }
.btn.danger { border-color: rgba(255, 106, 69, .5); color: var(--ember); }
.btn.danger:hover:not(:disabled) { border-color: var(--ember); background: rgba(255, 106, 69, .07); }
.btn.ghost { color: var(--muted); border-color: transparent; }
.btn.ghost:hover:not(:disabled) { color: var(--text); background: rgba(255, 255, 255, .03); }
.btn.sm { padding: 7px 10px; font-size: 11.5px; border-radius: 8px; }
.btn.wide { width: 100%; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 13px; }
.field:last-child { margin-bottom: 0; }
.field label { font-size: 11.5px; color: var(--muted); font-weight: 500; letter-spacing: .01em; }
.field input, .field select, .field textarea {
  width: 100%; background: #101010; border: 1px solid var(--line); color: var(--text);
  border-radius: 9px; padding: 11px 12px; font-size: 12.5px; outline: none;
  transition: border-color .16s ease, box-shadow .16s ease;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--acid-2); box-shadow: 0 0 0 3px rgba(218, 250, 156, .08);
}
.field .hint { font-size: 11px; color: var(--dim); line-height: 1.55; }
.field textarea { min-height: 84px; resize: vertical; font-family: var(--font-mono); font-size: 11px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 560px) { .field-row { grid-template-columns: 1fr; } }

/* ---------- landing / auth ---------- */
.landing { padding: clamp(30px, 6vw, 92px) 0 70px; }
.landing-grid { display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(340px, .92fr); gap: clamp(26px, 5vw, 80px); align-items: center; }
@media (max-width: 940px) { .landing-grid { grid-template-columns: 1fr; } }
.eyebrow {
  display: inline-flex; align-items: center; gap: 9px;
  font-family: var(--font-mono); font-size: 9px; letter-spacing: .22em; text-transform: uppercase; color: var(--acid);
}
.eyebrow::before { content: ""; width: 22px; height: 1px; background: var(--acid); opacity: .7; }
h1.hero {
  margin: 22px 0 0; font-size: clamp(40px, 6.2vw, 78px); line-height: .94;
  letter-spacing: -.055em; font-weight: 500; text-wrap: balance;
}
h1.hero em { font-style: normal; color: transparent; -webkit-text-stroke: 1px var(--text); }
.lede { max-width: 46ch; margin: 22px 0 0; color: var(--muted); font-size: 14.5px; line-height: 1.75; }
.lede b { color: var(--text); font-weight: 500; }
.hero-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 26px; }
.hero-meta span {
  font-family: var(--font-mono); font-size: 9px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--dim); border: 1px solid var(--line); border-radius: 999px; padding: 6px 10px;
}
.auth-card {
  position: relative; padding: 26px; border: 1px solid var(--line-2); border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(27, 27, 27, .98), rgba(18, 18, 18, .99));
  box-shadow: var(--shadow);
}
.auth-card::before {
  content: ""; position: absolute; inset: -1px; border-radius: inherit; pointer-events: none;
  background: linear-gradient(135deg, rgba(218, 250, 156, .22), transparent 32%, transparent 68%, rgba(155, 232, 216, .16));
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask-composite: exclude; padding: 1px;
}
.auth-card h2 { margin: 0; font-size: 21px; letter-spacing: -.03em; font-weight: 500; }
.auth-card .sub { margin: 7px 0 22px; color: var(--muted); font-size: 12.5px; line-height: 1.6; }
.auth-foot { margin-top: 16px; display: flex; justify-content: space-between; gap: 10px; align-items: center; font-family: var(--font-mono); font-size: 9px; letter-spacing: .08em; color: var(--dim); text-transform: uppercase; }
.error-box {
  display: none; margin: 0 0 14px; padding: 10px 12px; border-radius: 9px;
  border: 1px solid rgba(255, 106, 69, .4); background: rgba(255, 106, 69, .07);
  color: var(--ember); font-size: 12px; line-height: 1.55;
}
.error-box.show { display: block; }

/* ---------- dashboard ---------- */
.dash { padding: 34px 0 70px; }
.dash-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 18px; flex-wrap: wrap; margin-bottom: 22px; }
.dash-head h1 { margin: 0; font-size: clamp(28px, 3.2vw, 40px); letter-spacing: -.045em; font-weight: 500; }
.dash-head p { margin: 8px 0 0; color: var(--muted); font-size: 12.5px; }
.metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 22px; }
@media (max-width: 620px) { .metrics { grid-template-columns: 1fr; } }
.metric { padding: 15px 16px; border: 1px solid var(--line); border-radius: 12px; background: rgba(20, 20, 20, .65); }
.metric .k { font-family: var(--font-mono); font-size: 8.5px; letter-spacing: .16em; text-transform: uppercase; color: var(--dim); }
.metric .v { margin-top: 8px; font-size: 22px; letter-spacing: -.03em; }
.metric .v small { font-size: 11px; color: var(--muted); letter-spacing: 0; }

.nodes { display: grid; gap: 14px; }
.node {
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
  background: linear-gradient(180deg, rgba(26, 26, 26, .97), rgba(19, 19, 19, .99));
  box-shadow: 0 18px 50px rgba(0, 0, 0, .3);
}
.node-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 17px 19px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.node-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.node-title .ico {
  width: 34px; height: 34px; border-radius: 10px; border: 1px solid rgba(218, 250, 156, .3);
  background: rgba(218, 250, 156, .06); color: var(--acid); display: grid; place-items: center;
  font-family: var(--font-mono); font-size: 13px; flex-shrink: 0;
}
.node-title h3 { margin: 0; font-size: 15px; font-weight: 500; letter-spacing: -.01em; }
.node-title .meta { margin-top: 4px; font-family: var(--font-mono); font-size: 9px; letter-spacing: .07em; color: var(--dim); }
.devices { display: flex; flex-direction: column; }
.device {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 14px; align-items: center;
  padding: 14px 19px; border-top: 1px solid var(--line);
}
.device:first-child { border-top: 0; }
.device .name { font-size: 13.5px; display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.device .meta { margin-top: 4px; font-family: var(--font-mono); font-size: 9px; letter-spacing: .06em; color: var(--dim); }
.device .actions { display: flex; gap: 8px; align-items: center; }
.tag { display: inline-flex; padding: 3px 7px; border-radius: 6px; border: 1px solid var(--line-2); font-family: var(--font-mono); font-size: 8.5px; letter-spacing: .06em; color: var(--muted); text-transform: uppercase; }
.tag.ps5 { color: var(--cyan); border-color: rgba(155, 232, 216, .35); }
.tag.ready { color: var(--acid); border-color: rgba(218, 250, 156, .35); }
.tag.standby { color: var(--ember); border-color: rgba(255, 106, 69, .35); }
.node-foot { padding: 11px 19px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-family: var(--font-mono); font-size: 9px; color: var(--dim); letter-spacing: .06em; }

.empty-state {
  padding: clamp(30px, 5vw, 56px) clamp(20px, 4vw, 44px);
  border: 1px dashed var(--line-2); border-radius: var(--radius);
  background: rgba(18, 18, 18, .55); text-align: center;
}
.empty-state h3 { margin: 0 0 8px; font-size: 17px; font-weight: 500; letter-spacing: -.02em; }
.empty-state p { margin: 0 auto; max-width: 52ch; color: var(--muted); font-size: 12.5px; line-height: 1.7; }
.steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 22px; text-align: left; }
@media (max-width: 720px) { .steps { grid-template-columns: 1fr; } }
.step { padding: 14px 15px; border: 1px solid var(--line); border-radius: 11px; background: rgba(20, 20, 20, .6); }
.step .n { font-family: var(--font-mono); font-size: 9px; color: var(--acid); letter-spacing: .1em; }
.step .t { margin-top: 7px; font-size: 12.5px; }
.step .d { margin-top: 4px; color: var(--dim); font-size: 11px; line-height: 1.55; }

/* ---------- stream ---------- */
.stream-body { overflow: hidden; height: 100dvh; background: #060606; }
.stage { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: #050505; }
#stream-canvas {
  width: 100%; height: 100%; object-fit: contain; display: block;
  background: #050505;
}
.hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
.hud-top {
  position: absolute; top: 0; left: 0; right: 0; display: flex; justify-content: space-between; gap: 12px;
  padding: 14px 16px; background: linear-gradient(180deg, rgba(0, 0, 0, .62), transparent);
}
.hud-block { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.hud .pill { background: rgba(6, 6, 6, .62); backdrop-filter: blur(10px); }
.hud-bottom {
  position: absolute; bottom: 0; left: 0; right: 0; display: flex; justify-content: center;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  background: linear-gradient(0deg, rgba(0, 0, 0, .7), transparent);
  pointer-events: auto;
}
.toolbar {
  display: flex; align-items: center; gap: 6px; padding: 7px; border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, .12); background: rgba(12, 12, 12, .78);
  backdrop-filter: blur(16px);
}
.toolbar .btn { border-color: transparent; background: transparent; color: var(--muted); }
.toolbar .btn:hover:not(:disabled) { color: var(--acid); background: rgba(218, 250, 156, .07); }
.toolbar .sep { width: 1px; height: 20px; background: rgba(255, 255, 255, .12); margin: 0 4px; }
.overlay {
  position: fixed; inset: 0; z-index: 10; display: grid; place-items: center;
  background: radial-gradient(ellipse at 50% 38%, rgba(218, 250, 156, .06), transparent 55%), rgba(6, 6, 6, .9);
  backdrop-filter: blur(6px); transition: opacity .3s ease, visibility .3s ease;
}
.overlay.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.overlay-card { width: min(440px, calc(100% - 36px)); text-align: center; padding: 30px 26px; border: 1px solid var(--line-2); border-radius: 18px; background: linear-gradient(180deg, rgba(26, 26, 26, .98), rgba(16, 16, 16, .99)); box-shadow: var(--shadow); }
.overlay-card .eyebrow { justify-content: center; }
.overlay-card h2 { margin: 16px 0 0; font-size: 26px; letter-spacing: -.04em; font-weight: 500; }
.overlay-card p { margin: 10px 0 0; color: var(--muted); font-size: 12.5px; line-height: 1.65; }
.overlay-card .btn { margin-top: 22px; }
.overlay-card .error-box { text-align: left; margin-top: 16px; }
.spinner { width: 22px; height: 22px; margin: 0 auto; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .14); border-top-color: var(--acid); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.stream-note { position: fixed; bottom: 14px; left: 16px; z-index: 4; font-family: var(--font-mono); font-size: 9px; letter-spacing: .08em; color: var(--dim); pointer-events: none; }

/* ---------- toast ---------- */
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 100; display: flex; flex-direction: column; gap: 8px; max-width: min(380px, calc(100% - 32px)); }
.toast {
  padding: 11px 14px; border-radius: 10px; border: 1px solid var(--line-2);
  background: rgba(24, 24, 24, .97); color: var(--text); font-size: 12px; line-height: 1.5;
  box-shadow: 0 14px 40px rgba(0, 0, 0, .45); animation: toastIn .2s ease both;
}
.toast.err { border-color: rgba(255, 106, 69, .55); color: #ffd9ce; }
.toast.ok { border-color: rgba(218, 250, 156, .45); color: var(--acid); }
@keyframes toastIn { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); border: 0; }
.hidden { display: none !important; }
