@font-face { font-family: "Space Grotesk"; src: url(fonts/space-grotesk.woff2) format("woff2"); font-weight: 300 700; font-display: swap; }
@font-face { font-family: "JetBrains Mono"; src: url(fonts/jetbrains-mono.woff2) format("woff2"); font-weight: 400 500; font-display: swap; }

:root {
  color-scheme: dark;
  --bg: #0a0e0c;
  --surface: #111815;
  --surface-2: #17201b;
  --line: #22302a;
  --line-strong: #2f4038;
  --text: #e4ede7;
  --muted: #84948b;
  --faint: #56645c;
  --venom: #8ef0a6;
  --venom-ink: #062411;
  --amber: #f5b544;
  --danger: #ff6b6b;
  --live: #ff4d5e;
  --twitch: #a970ff;
  --youtube: #ff4e45;
  --kick: #53fc18;
  --radius: 14px;
  --sans: "Space Grotesk", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --head-h: 62px;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0; min-height: 100vh; color: var(--text); font: 15px/1.5 var(--sans);
  background:
    radial-gradient(900px 500px at 15% -10%, rgba(142, 240, 166, .07), transparent 60%),
    radial-gradient(700px 400px at 100% 0%, rgba(169, 112, 255, .05), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
.defs { position: absolute; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.02em; line-height: 1.2; }
h2 { font-size: 19px; display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
b { font-weight: 600; }
.muted { color: var(--muted); margin: 0 0 16px; }
.error { color: var(--danger); margin: 10px 0 0; font-size: 14px; }

/* ---------- controls */
label { display: block; font-size: 12px; font-weight: 500; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 14px; }
input {
  display: block; width: 100%; margin-top: 6px; padding: 10px 12px;
  font: 14px var(--mono); color: var(--text); letter-spacing: 0; text-transform: none;
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
  transition: border-color .15s, box-shadow .15s;
}
input::placeholder { color: var(--faint); font-family: var(--sans); }
input:focus { outline: none; border-color: var(--venom); box-shadow: 0 0 0 3px rgba(142, 240, 166, .15); }
button {
  font: 500 14px var(--sans); padding: 9px 16px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--text);
  transition: background .15s, border-color .15s, transform .05s;
}
button:hover { border-color: var(--muted); }
button:active { transform: translateY(1px); }
button:focus-visible, summary:focus-visible { outline: 2px solid var(--venom); outline-offset: 2px; }
button.primary { background: var(--venom); color: var(--venom-ink); border-color: transparent; font-weight: 600; }
button.primary:hover { background: #a8f5bb; }
button.ghost { background: transparent; }
button.small { padding: 5px 11px; font-size: 13px; border-radius: 8px; }
button.wide { width: 100%; padding: 11px; }
button.danger { color: var(--danger); }
button:disabled { opacity: .5; cursor: default; }
details > summary { cursor: pointer; color: var(--muted); font-size: 13px; list-style: none; user-select: none; }
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: "›"; display: inline-block; width: 1em; transition: transform .15s; }
details[open] > summary::before { transform: rotate(90deg); }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.eyebrow { font-size: 11px; font-weight: 500; letter-spacing: .12em; text-transform: uppercase; color: var(--faint); }
.wordmark { font-weight: 700; letter-spacing: -0.03em; }

/* ---------- login */
.login { max-width: 380px; margin: 0 auto; padding: 14vh 16px 48px; }
.login-brand { text-align: center; margin-bottom: 28px; }
.login-mark { width: 64px; height: 64px; color: var(--venom); filter: drop-shadow(0 0 18px rgba(142, 240, 166, .35)); }
.login .wordmark { font-size: 40px; margin: 6px 0 4px; }
.tagline { color: var(--muted); margin: 0; }

/* ---------- layout */
.dash > main { max-width: 1120px; margin: 0 auto; padding: 8px 20px 64px; }
.topbar { max-width: 1120px; margin: 0 auto; padding: 18px 20px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 28px; height: 28px; color: var(--venom); }
.brand .wordmark { font-size: 22px; }
.who { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 14px; }
.grid { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 20px; align-items: start; margin-top: 20px; }
.step {
  display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%;
  font: 600 12px var(--mono); color: var(--venom); border: 1px solid rgba(142, 240, 166, .4);
}

/* ---------- flow diagram */
.flow {
  display: grid; grid-template-columns: minmax(150px, 190px) minmax(40px, 1fr) minmax(220px, 280px) minmax(270px, 1.6fr);
  align-items: center; padding: 26px; border-radius: 18px;
  background: linear-gradient(180deg, var(--surface), rgba(17, 24, 21, .6));
  border: 1px solid var(--line);
}
.node { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; background: var(--bg); position: relative; z-index: 1; }
.node-title { display: block; font-size: 17px; }
.node-sub { display: block; font-size: 13px; color: var(--muted); font-family: var(--mono); }
.source .node-title { margin-top: 2px; }
.core { display: flex; align-items: center; gap: 14px; transition: border-color .3s, box-shadow .3s; }
.core-mark { width: 52px; height: 52px; flex: none; color: var(--line-strong); transition: color .3s; }
.core-head { fill: var(--line-strong); transition: fill .3s; }
.flow.live .core { border-color: rgba(142, 240, 166, .45); box-shadow: 0 0 0 4px rgba(142, 240, 166, .06), 0 0 40px rgba(142, 240, 166, .08); }
.flow.live .core-mark { color: var(--venom); }
.flow.live #status-title::before {
  content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--live);
  margin-right: 8px; vertical-align: 2px; animation: pulse 2s infinite;
}
.core-head.live[data-platform="twitch"] { fill: var(--twitch); }
.core-head.live[data-platform="youtube"] { fill: var(--youtube); }
.core-head.live[data-platform="kick"] { fill: var(--kick); }
.core-head.connecting, .core-head.retrying { fill: var(--amber); }

/* connectors: --c is the colour, .on animates the dashes */
/* --c is inherited by each element's own connector pseudo-elements */
.flow { --c: var(--line-strong); }
.flow.live { --c: var(--venom); }
.head { --c: var(--line-strong); }
.link { height: 2px; background: var(--c); }
.link.on, .flow.live .heads::after {
  background: repeating-linear-gradient(90deg, var(--c) 0 10px, transparent 10px 18px);
  background-size: 18px 2px; animation: flow-x .6s linear infinite;
}
.heads { position: relative; display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; padding-left: 44px; min-width: 0; }
.heads::after { content: ""; position: absolute; left: 0; top: calc(50% - 1px); width: 22px; height: 2px; background: var(--c); }
.heads::before {
  content: ""; position: absolute; left: 21px; width: 2px;
  top: calc(var(--head-h) / 2); bottom: calc(var(--head-h) / 2); background: var(--c);
}
.flow.live .heads::before { background: repeating-linear-gradient(180deg, var(--c) 0 10px, transparent 10px 18px); background-size: 2px 18px; animation: flow-y .6s linear infinite; }
.head {
  position: relative; display: flex; align-items: center; gap: 12px; height: var(--head-h);
  padding: 0 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg);
  transition: border-color .3s, box-shadow .3s;
}
.head::before { content: ""; position: absolute; left: -23px; top: calc(50% - 1px); width: 22px; height: 2px; background: var(--c); }
.head.live::before, .head.connecting::before, .head.retrying::before {
  background: repeating-linear-gradient(90deg, var(--c) 0 10px, transparent 10px 18px); background-size: 18px 2px; animation: flow-x .6s linear infinite;
}
.head.live { --c: var(--pc); border-color: color-mix(in srgb, var(--pc) 45%, transparent); box-shadow: 0 0 24px color-mix(in srgb, var(--pc) 12%, transparent); }
.head.connecting, .head.retrying { --c: var(--amber); }
.head.retrying::before { animation-duration: 2s; }
.head.off, .head.no_key { opacity: .55; }
.head-text { min-width: 0; flex: 1; }
.head-name { display: block; font-size: 15px; }
.head-detail { display: block; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-family: var(--mono); }
.head.retrying .head-detail { color: var(--amber); }

.glyph {
  flex: none; display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 9px;
  font: 700 14px var(--sans); color: #0a0e0c; background: var(--pc);
}
[data-platform="twitch"] { --pc: var(--twitch); }
[data-platform="youtube"] { --pc: var(--youtube); }
[data-platform="kick"] { --pc: var(--kick); }

.pill {
  flex: none; font: 500 11px var(--mono); letter-spacing: .04em; text-transform: uppercase;
  padding: 3px 9px; border-radius: 999px; color: var(--muted); border: 1px solid var(--line-strong);
}
.pill.live { color: #fff; background: var(--live); border-color: transparent; }
.pill.connecting, .pill.retrying { color: var(--amber); border-color: rgba(245, 181, 68, .45); }
.pill.standby { color: var(--venom); border-color: rgba(142, 240, 166, .35); }

.warning {
  margin: 14px 0 0; padding: 12px 16px; border-radius: 12px; font-size: 14px;
  color: #ffd9a0; background: rgba(245, 181, 68, .08); border: 1px solid rgba(245, 181, 68, .35);
}

@keyframes flow-x { to { background-position: 18px 0; } }
@keyframes flow-y { to { background-position: 0 18px; } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

/* ---------- OBS panel */
.field { margin-bottom: 14px; }
.field-label { display: block; font-size: 12px; font-weight: 500; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.field-row { display: flex; gap: 6px; align-items: center; }
.field-row code {
  flex: 1; min-width: 0; overflow-x: auto; white-space: nowrap; padding: 9px 12px;
  font: 13px var(--mono); color: var(--venom); background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
}
.field-row code.secret { color: var(--text); letter-spacing: .1em; }
.tips { margin: 18px 0 14px; padding: 0; list-style: none; display: grid; gap: 8px; }
.tips li { font-size: 13px; color: var(--muted); padding-left: 14px; border-left: 2px solid var(--line-strong); }
.tips b { color: var(--text); }
.obs details .muted { margin: 10px 0; font-size: 13px; }

/* ---------- destination cards */
.heads-config > .muted { margin-bottom: 14px; }
.dests { display: grid; gap: 12px; }
.dest {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; border-left: 3px solid var(--pc);
}
.dest header { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.dest h3 { font-size: 17px; flex: 1; }
.dest-status { margin: -4px 0 14px; padding: 10px 12px; border-radius: 10px; font-size: 13px; line-height: 1.4;
  color: #ffd9a0; background: rgba(245, 181, 68, .08); border: 1px solid rgba(245, 181, 68, .3); }
.dest label { margin-bottom: 10px; }
.dest .adv { margin-top: 2px; }
.dest .adv input { font-size: 12px; }
.hint { font-size: 12px; color: var(--faint); margin: 6px 0 0; }
.dest-actions { display: flex; align-items: center; gap: 10px; margin-top: 14px; }
.saved { color: var(--venom); font-size: 13px; }
.saved::before { content: "✓ "; }

.switch { position: relative; width: 44px; height: 24px; margin: 0; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; margin: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: var(--line-strong); border-radius: 999px; cursor: pointer; transition: background .15s; }
.switch span::before { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: var(--text); border-radius: 50%; transition: transform .15s; }
.switch input:checked + span { background: var(--pc, var(--venom)); }
.switch input:checked + span::before { transform: translateX(20px); background: #0a0e0c; }
.switch input:focus-visible + span { outline: 2px solid var(--venom); outline-offset: 2px; }

/* ---------- account */
.account { margin-top: 20px; padding: 16px 22px; }
.account[open] summary { margin-bottom: 14px; }
.row-form { display: flex; gap: 8px; flex-wrap: wrap; }
.row-form input { flex: 1 1 200px; margin: 0; width: auto; }

/* ---------- narrow screens: stack the flow vertically */
@media (max-width: 960px) {
  .grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .dash > main, .topbar { padding-left: 16px; padding-right: 16px; }
  .flow { grid-template-columns: minmax(0, 1fr); padding: 18px; }
  .link { width: 2px; height: 22px; margin-left: 32px; }
  .link.on { background: repeating-linear-gradient(180deg, var(--c) 0 10px, transparent 10px 18px); background-size: 2px 18px; animation-name: flow-y; }
  .heads { padding-left: 54px; margin-top: 14px; }
  .heads::after { display: none; }
  .heads::before { left: 32px; top: -14px; }
  .head::before { left: -23px; }
  .who #who { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; }
}
