:root {
  color-scheme: dark;
  --bg: #0b0d12;
  --panel: #141820;
  --panel-2: #1b202a;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.16);
  --text: #e7eaf1;
  --muted: #8d95a8;
  --accent: #7d8cff;
  --accent-2: #9aa6ff;
  --live: #3dcb8c;
  --failed: #f07178;
  --warn: #e3b341;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 16px 40px rgba(0, 0, 0, 0.28);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(900px 420px at 0% -10%, rgba(125, 140, 255, 0.12), transparent 55%),
    var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}

::selection { background: rgba(125, 140, 255, 0.35); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

nav {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  gap: 8px;
  align-items: center;
  height: 56px;
  padding: 0 22px;
  background: rgba(11, 13, 18, 0.82);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-right: 12px;
  color: var(--text);
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.02em;
  text-decoration: none;
}

.mark {
  width: 18px;
  height: 18px;
  border-radius: 5px;
  background: linear-gradient(160deg, var(--accent-2), #4d5dff);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.16) inset;
}

.nav-links { display: flex; gap: 2px; align-items: center; }

.nav-links a {
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 560;
  padding: 6px 10px;
  border-radius: 8px;
}

.nav-links a:hover { color: var(--text); background: rgba(255, 255, 255, 0.04); }

.nav-links a[aria-current="page"] {
  color: var(--text);
  background: rgba(255, 255, 255, 0.07);
}

nav form { margin-left: auto; }

main {
  width: min(1120px, calc(100% - 40px));
  margin: 0 auto;
  padding: 28px 0 64px;
}

h1 {
  margin: 0;
  font-size: 30px;
  font-weight: 640;
  letter-spacing: -0.035em;
  line-height: 1.15;
}

h1[data-ingest]::before {
  content: "";
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 10px;
  border-radius: 50%;
  background: #5c6478;
  box-shadow: 0 0 0 4px rgba(92, 100, 120, 0.18);
  transform: translateY(-2px);
}

h1[data-ingest="live"]::before {
  background: var(--live);
  box-shadow: 0 0 0 4px rgba(61, 203, 140, 0.16);
}

h2 {
  margin: 0 0 12px;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

h3 { margin: 0 0 8px; font-size: 16px; font-weight: 620; letter-spacing: -0.02em; }

p { margin: 0 0 12px; }

a { color: var(--accent-2); }

button, .button {
  background: var(--accent);
  color: #f7f8ff;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 14px;
  font: inherit;
  font-size: 14px;
  font-weight: 620;
  letter-spacing: -0.01em;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}

button:hover, .button:hover { filter: brightness(1.08); }

button.quiet,
form[action="token"] button {
  background: transparent;
  color: var(--muted);
  border-color: var(--line-strong);
}

button.quiet:hover,
form[action="token"] button:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  filter: none;
}

input, select, textarea {
  width: 100%;
  margin-top: 6px;
  background: #0d1016;
  color: var(--text);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 9px 11px;
  font: inherit;
}

input::placeholder { color: #667085; }

input:focus, select:focus, textarea:focus {
  border-color: rgba(125, 140, 255, 0.7);
  outline: none;
  box-shadow: 0 0 0 3px rgba(125, 140, 255, 0.18);
}

label { display: block; margin: 12px 0; color: var(--muted); font-size: 13px; }

label:has(> input[type="checkbox"]) {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0;
  color: var(--text);
  font-size: 14px;
}

input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent);
}

.stack { max-width: 440px; }

.muted, .kicker, .summary { color: var(--muted); }

.kicker {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.lead { max-width: 68ch; color: var(--muted); }

.notice, .banner {
  margin-bottom: 16px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(125, 140, 255, 0.1);
  border: 1px solid rgba(125, 140, 255, 0.32);
}

.banner {
  background: rgba(240, 113, 120, 0.1);
  border-color: rgba(240, 113, 120, 0.38);
  color: #f6d0d3;
}

.auth {
  width: min(420px, 100%);
  margin: 10vh auto 0;
  padding: 28px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.auth h1 { margin-bottom: 6px; font-size: 26px; }

.mast {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: end;
  margin-bottom: 16px;
}

.summary { margin: 0; max-width: 36ch; text-align: right; }

.destinations, .inline, .feed, .chat, .goals, .links { list-style: none; padding: 0; margin: 0; }

.destinations, .inline { display: flex; gap: 8px; flex-wrap: wrap; }

.destinations { margin-bottom: 22px; }

.destinations li, .inline li {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.destinations li::before, .inline li::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #5c6478;
}

.destinations li[data-state="live"] { color: var(--live); border-color: rgba(61, 203, 140, 0.35); }
.destinations li[data-state="live"]::before { background: var(--live); }
.destinations li[data-state="failed"] { color: var(--failed); border-color: rgba(240, 113, 120, 0.4); }
.destinations li[data-state="failed"]::before { background: var(--failed); }
.destinations li[data-state="connecting"] { color: var(--warn); border-color: rgba(227, 179, 65, 0.4); }
.destinations li[data-state="connecting"]::before { background: var(--warn); }

.grid, .split, .cards { display: grid; gap: 16px; margin-top: 16px; align-items: start; }
main > .panel { margin-top: 16px; }
.grid { grid-template-columns: 1.45fr 0.85fr; }
.split { grid-template-columns: 1fr 1fr; }
.cards { grid-template-columns: repeat(3, 1fr); align-items: start; }

.panel h2:not(:first-child) { margin-top: 20px; }

.panel, .card, fieldset {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px 16px 14px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset;
}

.card > h2, fieldset legend {
  font-size: 15px;
  font-weight: 640;
  letter-spacing: -0.02em;
  text-transform: none;
  color: var(--text);
}

fieldset { margin: 0 0 12px; background: var(--panel-2); }
fieldset legend { padding: 0 6px; }

.card .button { margin: 4px 0 8px; }

.chat, .feed {
  min-height: 220px;
  max-height: 420px;
  overflow: auto;
  padding: 2px 2px 2px 0;
  scrollbar-color: #2a3142 transparent;
}

.chat li, .feed li, .goals li, .links li {
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.chat li:last-child, .feed li:last-child, .goals li:last-child, .links li:last-child { border-bottom: 0; }

.chat b { color: #d5dbff; font-weight: 640; }

.goals li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
  align-items: center;
}

.goals .track {
  grid-column: 1 / -1;
  height: 6px;
  margin: 6px 0 2px;
  background: #2a3142;
  border-radius: 99px;
  overflow: hidden;
}

.goals .fill { height: 100%; background: linear-gradient(90deg, #5d6dff, var(--accent-2)); }

.goals em { font-style: normal; color: var(--muted); font-variant-numeric: tabular-nums; }

.goals form {
  grid-column: 1 / -1;
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 6px;
}

.goals form input { width: 84px; margin: 0; }

#leaders-live { margin: 0; padding-left: 22px; color: var(--text); }
#leaders-live li { padding: 6px 0; }

.switch-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  align-items: start;
}

.switch-grid > button { justify-self: start; }

.checks { display: flex; gap: 14px; flex-wrap: wrap; }
.checks label { margin: 4px 0 10px; }

code {
  word-break: break-all;
  font-family: var(--mono);
  font-size: 12px;
  color: #c5cedd;
  background: #0d1016;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 2px 6px;
}

.links li { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.links a { color: var(--text); font-weight: 620; text-decoration: none; }
.links a:hover { color: var(--accent-2); }

.empty { color: var(--muted); }
.errors { margin: 0 0 12px; padding-left: 18px; color: var(--failed); }

form + form { margin-top: 14px; }

body.app-screen main {
  width: 100%;
  max-width: none;
  height: calc(100vh - 56px);
  margin: 0;
  padding: 0;
  overflow: hidden;
}

.screen {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.screen > .notice,
.screen > .banner { margin: 12px 20px 0; }

.tabbar {
  display: flex;
  gap: 6px;
  padding: 14px 20px 0;
}

.tab {
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  border-radius: 9px;
}

.tab[aria-selected="true"] {
  background: var(--panel);
  color: var(--text);
  border-color: var(--line);
}

.tab-panel {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 16px 20px 20px;
}
#panel-live { display: flex; flex-direction: column; overflow: hidden; }
#panel-live .monitor { flex: 1; height: auto; }

.broadcast { max-width: none; }
.broadcast-head { display: flex; justify-content: space-between; gap: 28px; align-items: end; margin-bottom: 18px; }
.broadcast-head .lead { max-width: 42ch; margin: 0; }
.broadcast-fields { display: grid; grid-template-columns: 1.4fr 0.8fr; gap: 12px; }

.platform-enable, .widget-list { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 8px; }
.platform-enable li, .widget-row, .connect-card {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
}
.platform-enable li div, .widget-row a, .connect-card header div { display: flex; flex-direction: column; gap: 2px; }
.platform-enable span, .widget-row a span, .connect-card p { color: var(--muted); font-size: 13px; }
.widget-row a { color: var(--text); text-decoration: none; flex: 1; }
.widget-row a strong { font-size: 16px; }
.widget-row form { margin: 0; }

.switch-row { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--text); font-size: 14px; }
.pill {
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 650;
}
.pill.on { color: var(--live); border-color: rgba(61, 203, 140, 0.4); background: rgba(61, 203, 140, 0.08); }

.page-head { margin-bottom: 18px; }
.page-head .lead { margin-top: 8px; }

.connect-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; align-items: stretch; }
.connect-card { flex-direction: column; align-items: stretch; min-height: 190px; }
.connect-card header { display: flex; gap: 12px; align-items: flex-start; }
.connect-card header div { flex: 1; }
.connect-card h2 { margin-bottom: 4px; text-transform: none; letter-spacing: -0.02em; font-size: 18px; color: var(--text); }
.connect-actions { display: flex; gap: 8px; align-items: center; margin-top: auto; }
.connect-actions form { margin: 0; }
.platform-mark { width: 14px; height: 14px; border-radius: 4px; margin-top: 4px; }
.platform-mark.twitch { background: #a78bfa; }
.platform-mark.kick { background: #53fc18; }
.platform-mark.youtube { background: #ff5a5a; }

.monitor {
  display: grid;
  grid-template-columns: 1fr 340px;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
  height: 100%;
  min-height: 0;
}
.monitor-top { grid-column: 1 / -1; display: flex; justify-content: space-between; gap: 16px; align-items: center; }
.viewer-pills { display: flex; gap: 8px; flex-wrap: wrap; list-style: none; margin: 0; padding: 0; }
.viewer-pills li {
  display: flex;
  gap: 8px;
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 640;
}
.viewer-pills b { color: var(--text); font-variant-numeric: tabular-nums; }
.viewer-pills em { font-style: normal; text-transform: capitalize; }
.viewer-pills li[data-state="live"] { color: var(--live); border-color: rgba(61, 203, 140, 0.35); }
.viewer-pills li[data-state="failed"] { color: var(--failed); border-color: rgba(240, 113, 120, 0.4); }
.viewer-pills li[data-state="connecting"] { color: var(--warn); border-color: rgba(227, 179, 65, 0.4); }
.viewer-pills li.empty { background: transparent; border: 0; padding: 0; font-weight: 500; }
.chat-panel, .support-panel { min-height: 0; display: flex; flex-direction: column; }
.chat-panel .chat, .support-panel .feed { flex: 1; min-height: 0; max-height: none; }

#chat-menu {
  position: fixed;
  z-index: 30;
  margin: 0;
  padding: 6px;
  display: grid;
  gap: 4px;
  background: #1b202a;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  box-shadow: var(--shadow);
}
#chat-menu[hidden] { display: none; }
#chat-menu button { background: transparent; color: var(--text); text-align: left; }
#chat-menu button:hover { background: rgba(255, 255, 255, 0.06); }

.widget-config { max-width: 760px; }
.design-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
input[type="color"] { width: 56px; height: 36px; padding: 4px; }

@media (max-width: 800px) {
  .grid, .split, .cards, .switch-grid { grid-template-columns: 1fr; }
  main { width: min(100% - 28px, 1120px); }
  .mast { flex-direction: column; align-items: flex-start; }
  .summary { text-align: left; }
  .chat, .feed { min-height: 140px; }
  nav {
    height: auto;
    flex-wrap: wrap;
    padding: 10px 14px 12px;
    row-gap: 8px;
  }
  .nav-links { order: 3; width: 100%; }
  nav form { margin-left: auto; }
  .broadcast-head, .monitor, .broadcast-fields, .connect-grid, .design-grid { display: grid; grid-template-columns: 1fr; }
  .monitor { grid-template-rows: auto auto auto; height: auto; }
  body.app-screen main { height: auto; overflow: visible; }
  .screen { height: auto; }
}
