/* Rcast dashboard, in TikTok's colours: TikTok black and white, TikTok red for primary actions,
   LIVE and the current page, TikTok aqua for "connected / on", amber for problems. TikTok Sans for
   UI, JetBrains Mono for anything that is a console command.

   Light and dark come from one set of tokens through light-dark(). The device setting decides,
   unless the user picked a theme in Settings (html[data-theme], set before first paint by
   index.html). Anything can force a theme on its subtree with color-scheme, e.g. the phone mockup. */

:root {
  color-scheme: light dark;

  /* TikTok's own colours, the same in both themes. Marks only: dots, rings, the logo. */
  --tiktok-red: #fe2c55;
  --tiktok-aqua: #25f4ee;

  /* Surfaces. The sidebar is the frame around the page panel. In dark, depth comes from lighter
     surfaces; in light, from hairlines and soft shadows. */
  --sidebar: light-dark(#f3f3f4, #000000);
  --canvas: light-dark(#ffffff, #121212);
  --surface: light-dark(#ffffff, #1b1b1b);
  --surface-2: light-dark(#f1f1f2, #252525);
  --surface-3: light-dark(#e3e3e5, #303030);
  /* Pop-ups (settings, dialogs, the setup guide) sit a step above the page in dark. */
  --surface-pop: light-dark(#ffffff, #212121);
  --field: light-dark(#f7f7f8, #121212);
  --hover: light-dark(rgb(22 24 35 / 0.05), rgb(255 255 255 / 0.06));
  --press: light-dark(rgb(22 24 35 / 0.08), rgb(255 255 255 / 0.1));
  --line: light-dark(rgb(22 24 35 / 0.1), rgb(255 255 255 / 0.09));
  --line-strong: light-dark(rgb(22 24 35 / 0.16), rgb(255 255 255 / 0.14));
  --line-hover: light-dark(rgb(22 24 35 / 0.3), rgb(255 255 255 / 0.24));
  /* A faint tint for bands and wells inside a card; a stronger one for console lines. */
  --tint: light-dark(rgb(22 24 35 / 0.025), rgb(255 255 255 / 0.02));
  --well: light-dark(rgb(22 24 35 / 0.04), rgb(0 0 0 / 0.22));
  --code-bg: light-dark(#f1f1f2, rgb(0 0 0 / 0.35));
  --dots: light-dark(rgb(22 24 35 / 0.1), rgb(255 255 255 / 0.08));
  --scrollbar: light-dark(rgb(22 24 35 / 0.22), rgb(255 255 255 / 0.18));
  --backdrop: light-dark(rgb(22 24 35 / 0.36), rgb(0 0 0 / 0.72));

  /* Text, starting from TikTok's ink. Every step clears 4.5:1 on --surface-2 and below. */
  --text: light-dark(#161823, #f1f1f2);
  --text-2: light-dark(#3e4049, #c9c9cc);
  --muted: light-dark(#5a5c64, #a5a5a9);
  --faint: light-dark(#6b6d74, #8e8e93);

  /* Roles. As a fill, TikTok red is a shade deeper so white text on it clears 4.5:1. */
  --brand: var(--tiktok-red);
  --accent: #e0244b;
  --accent-hover: #c81e42;
  --accent-text: light-dark(#d4183f, #ff5277);
  --accent-soft: light-dark(rgb(254 44 85 / 0.1), rgb(254 44 85 / 0.16));
  --accent-wash: light-dark(rgb(254 44 85 / 0.05), rgb(254 44 85 / 0.08));
  /* Aqua is unreadable on white, so light mode uses a deep teal for the same meaning. */
  --ok: light-dark(#007570, #25f4ee);
  --on-ok: light-dark(#ffffff, #00302e);
  --ok-soft: light-dark(rgb(0 117 112 / 0.1), rgb(37 244 238 / 0.12));
  --ok-wash: light-dark(rgb(0 117 112 / 0.05), rgb(37 244 238 / 0.04));
  --warn: light-dark(#9a5300, #ffc24d);
  --warn-text: light-dark(#7d4400, #ffdc94);
  --warn-soft: light-dark(rgb(230 140 0 / 0.13), rgb(255 194 77 / 0.12));
  --warn-wash: light-dark(rgb(230 140 0 / 0.06), rgb(255 194 77 / 0.06));
  --ok-line: light-dark(rgb(0 117 112 / 0.3), rgb(37 244 238 / 0.28));
  --accent-line: light-dark(rgb(212 24 63 / 0.28), rgb(255 82 119 / 0.3));
  --focus-border: light-dark(rgb(212 24 63 / 0.65), rgb(255 82 119 / 0.75));
  --focus-ring: light-dark(rgb(254 44 85 / 0.14), rgb(254 44 85 / 0.22));

  --font: 'TikTok Sans', system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;

  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;
  /* Cards sit just above the canvas: a soft drop below, and in dark a hairline of light on top. */
  --shadow-card:
    inset 0 1px 0 light-dark(transparent, rgb(255 255 255 / 0.04)),
    0 1px 2px light-dark(rgb(22 24 35 / 0.05), rgb(0 0 0 / 0.3));
  --shadow-pop:
    0 0 0 1px light-dark(rgb(22 24 35 / 0.04), rgb(0 0 0 / 0.3)),
    0 18px 44px -14px light-dark(rgb(22 24 35 / 0.24), rgb(0 0 0 / 0.8));
  /* Raised controls in dark: light catches the top edge. */
  --bevel: inset 0 1px 0 light-dark(transparent, rgb(255 255 255 / 0.06));

  --ease-out: cubic-bezier(0.25, 1, 0.5, 1);
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);

  --z-sticky: 10;
  --z-dock: 20;
  --z-toast: 40;
}

:root[data-theme='light'] {
  color-scheme: light;
}

:root[data-theme='dark'] {
  color-scheme: dark;
}

/* Switching theme swaps every colour at once rather than letting each control ease separately. */
.theme-switching,
.theme-switching * {
  transition: none !important;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  background: var(--canvas);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-optical-sizing: auto;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--sidebar);
}

/* Shown only without JavaScript (index.html), so crawlers and no-JS visitors get a summary. */
.noscript {
  max-width: 40rem;
  margin: 0 auto;
  padding: 4rem 1rem;
}

a {
  color: inherit;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1,
h2,
h3 {
  text-wrap: balance;
}

p {
  text-wrap: pretty;
}

:focus-visible {
  outline: 2px solid var(--accent-text);
  outline-offset: 2px;
}

code {
  font-family: var(--mono);
  font-size: 0.92em;
}

.icon {
  flex: none;
  vertical-align: -0.2em;
}

.mono {
  font-family: var(--mono);
  font-size: 0.92em;
}

.muted {
  color: var(--muted);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.hint {
  color: var(--muted);
  font-size: 13px;
}

* {
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar) transparent;
}

.reveal {
  animation: fade-in 0.2s var(--ease-out);
  animation-delay: calc(var(--i, 0) * 30ms);
  animation-fill-mode: backwards;
}

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* A longer, softer entrance for things that arrive on their own: the sign-in page, empty pages. */
@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
}

/* A live number that just changed. */
@keyframes bump {
  40% {
    transform: scale(1.12);
    color: var(--accent-text);
  }
}

/* Every page's header settles in as the route changes (the router replaces it each time). */
.page-head {
  animation: fade-in 0.25s var(--ease-out) backwards;
}

.empty-page > * {
  animation: rise-in 0.4s var(--ease-out-expo) backwards;
}

.empty-page > :nth-child(2) {
  animation-delay: 50ms;
}

.empty-page > :nth-child(3) {
  animation-delay: 100ms;
}

.empty-page > :nth-child(4) {
  animation-delay: 150ms;
}

.stat-value.is-bump {
  display: inline-block;
  transform-origin: left center;
  animation: bump 0.45s var(--ease-out);
}

/* ---------- Brand ---------- */

.brand {
  display: inline-flex;
  align-items: center;
  flex: none;
  border-radius: var(--radius-sm);
  text-decoration: none;
}

.brand-logo {
  display: block;
  width: auto;
  height: var(--logo-h, 28px);
}

/* One logo per theme, following the same rules as the colour tokens: white "CAST" on dark,
   ink "CAST" on light. */
.brand-logo.is-light {
  display: none;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme='dark']) .brand-logo.is-dark {
    display: none;
  }

  :root:not([data-theme='dark']) .brand-logo.is-light {
    display: block;
  }
}

:root[data-theme='light'] .brand-logo.is-dark {
  display: none;
}

:root[data-theme='light'] .brand-logo.is-light {
  display: block;
}

/* ---------- App shell ---------- */

.app {
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 18px 12px 12px;
  background: var(--sidebar);
}

.sidebar > .brand {
  margin: 0 8px 24px;
}

.side-nav {
  position: relative;
  display: grid;
  gap: 1px;
}

/* One highlight that slides to the current link (positioned by shell.ts). The links sit above it. */
.nav-indicator {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  border-radius: var(--radius-sm);
  background: var(--accent-wash);
  transition:
    transform 0.35s var(--ease-out-expo),
    height 0.35s var(--ease-out-expo);
}

.nav-indicator.is-placing {
  transition: none;
}

.side-nav a {
  position: relative;
}

.side-label {
  margin: 18px 10px 6px;
  color: var(--faint);
  font-size: 12px;
  font-weight: 500;
}

.side-nav a,
.side-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 34px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-2);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition:
    background 0.15s,
    color 0.15s;
}

.side-nav a .icon,
.side-btn .icon {
  color: var(--muted);
  transition: color 0.15s;
}

.side-nav a:hover,
.side-btn:hover {
  background: var(--hover);
  color: var(--text);
}

/* The current page reads like TikTok's nav: red label and icon, bolder, on a faint red wash. */
.side-nav a[aria-current='page'] {
  color: var(--accent-text);
  font-weight: 650;
}

.side-nav a[aria-current='page'] .icon {
  color: var(--brand);
}

.nav-live {
  margin-left: auto;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 0 0 3px rgb(254 44 85 / 0.25);
  animation: live-pulse 2s var(--ease-out) infinite;
}

@keyframes live-pulse {
  50% {
    box-shadow: 0 0 0 5px rgb(254 44 85 / 0);
  }
}

.side-foot {
  margin-top: auto;
  display: grid;
  gap: 8px;
}

.side-btn .count {
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

/* The profile, bottom left: opens Settings. A hairline above separates it from the nav. */
.side-user {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin-top: 9px;
  padding: 7px 10px 7px 7px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s;
}

.side-user::before {
  content: '';
  position: absolute;
  top: -9px;
  left: 4px;
  right: 4px;
  height: 1px;
  background: var(--line);
}

.side-user:hover,
.side-user[aria-expanded='true'] {
  background: var(--hover);
}

.side-user > .icon {
  color: var(--muted);
  transition:
    color 0.15s,
    transform 0.3s var(--ease-out-expo);
}

.side-user:hover > .icon {
  color: var(--text);
}

.side-user[aria-expanded='true'] > .icon {
  color: var(--text);
  transform: rotate(60deg);
}

.side-user-name {
  flex: 1;
  min-width: 0;
  font-size: 13.5px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* The same thing on phones: the avatar at the end of the top bar. */
.avatar-btn {
  display: grid;
  place-items: center;
  flex: none;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}

.avatar-btn .avatar {
  transition: box-shadow 0.15s;
}

.avatar-btn:hover .avatar,
.avatar-btn[aria-expanded='true'] .avatar {
  box-shadow: 0 0 0 2px var(--sidebar), 0 0 0 4px var(--line-hover);
}

.mobile-top,
.tabbar {
  display: none;
}

/* The page sits on a panel inset from the window, so the sidebar reads as the frame around it. */
.content {
  min-width: 0;
  min-height: calc(100vh - 16px);
  margin: 8px 8px 8px 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--canvas);
}

/* Wide enough to use a big monitor; the cap only stops lines getting absurd on ultrawides. */
.page {
  width: 100%;
  max-width: 1600px;
  margin-inline: auto;
  padding: 32px 40px 40px;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.page-head h1 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.page-head p {
  margin-top: 6px;
  max-width: 70ch;
  color: var(--muted);
}

/* ---------- Building blocks ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-card);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.card-title {
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.005em;
}

.card-sub {
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
}

.card-head + .card-sub {
  margin: -10px 0 14px;
}

/* A card that's only its head, like a setting beside its switch. */
.card-head:last-child {
  margin-bottom: 0;
}

.stack {
  display: grid;
  gap: 16px;
}

/* Side columns (forms, summaries) keep a working width; the main column takes the rest of the
   screen, so extra width goes to the content instead of stretching inputs. */
.grid-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 420px);
  gap: 16px;
  align-items: start;
}

.grid-home {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 380px);
  gap: 16px;
  align-items: start;
}

.notice {
  margin-top: 8px;
  padding: 7px 10px;
  border-radius: var(--radius);
  background: var(--warn-soft);
  color: var(--warn-text);
  font-size: 13px;
}

/* Empty states teach what will appear and how to get there. */
.empty {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 32px 16px;
  text-align: center;
}

.empty-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-bottom: 6px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--muted);
}

.empty-title {
  font-size: 15px;
  font-weight: 600;
}

.empty-text {
  max-width: 46ch;
  color: var(--muted);
  font-size: 13.5px;
}

.empty-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 10px;
}

.empty-page {
  min-height: 60vh;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 12px;
  padding: 40px 16px;
  text-align: center;
}

.empty-page h1 {
  font-size: 20px;
  font-weight: 650;
}

/* Loading placeholders, shown only when a page takes a moment. */
.skeleton {
  display: grid;
  gap: 16px;
}

.sk {
  border-radius: var(--radius);
  background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%) 0 0 / 300% 100%;
  animation: shimmer 1.4s linear infinite;
}

.sk-title {
  width: 180px;
  height: 26px;
}

.sk-line {
  width: min(420px, 70%);
  height: 14px;
}

.sk-block {
  height: 140px;
  border-radius: var(--radius-lg);
}

.sk-block.is-tall {
  height: 280px;
}

@keyframes shimmer {
  to {
    background-position: -150% 0;
  }
}

/* ---------- Pills ---------- */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}

.pill-live {
  height: 20px;
  padding: 0 7px;
  border-radius: 4px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.pill-ok::before,
.pill-wait::before,
.pill-bad::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.pill-ok {
  background: var(--ok-soft);
  color: var(--ok);
}

.pill-wait {
  color: var(--text-2);
}

.pill-wait::before {
  animation: blink 1s steps(2, jump-none) infinite;
}

/* A server that's still connecting: a softly pulsing dot rather than a blink. */
.pill.is-connecting::before {
  animation: connecting 1.2s var(--ease-out) infinite;
}

@keyframes connecting {
  0% {
    box-shadow: 0 0 0 0 currentColor;
  }
  100% {
    box-shadow: 0 0 0 5px transparent;
  }
}

/* ...and the moment it finishes: the dot becomes a check or a cross that pops in. */
.pill.is-settled {
  animation: pop 0.45s var(--ease-out-expo);
}

.pill.is-settled::before {
  display: none;
}

.pill.is-settled .icon {
  stroke-width: 3;
  animation: pop 0.5s var(--ease-out-expo) 0.1s backwards;
}

@keyframes pop {
  from {
    transform: scale(0.6);
    opacity: 0;
  }
  60% {
    transform: scale(1.08);
  }
}

.pill-bad {
  background: var(--warn-soft);
  color: var(--warn);
}

@keyframes blink {
  50% {
    opacity: 0.2;
  }
}

/* ---------- Avatars ---------- */

.avatar {
  position: relative;
  flex: none;
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
}

.avatar img,
.avatar-letter {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.avatar-letter {
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 700;
  font-size: calc(var(--size) * 0.42);
}

/* "Is live": TikTok's red ring. The LIVE pill next to it carries the words. */
.avatar.is-live {
  box-shadow:
    0 0 0 2px var(--surface),
    0 0 0 4px var(--brand);
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition:
    background 0.15s,
    border-color 0.15s,
    color 0.15s,
    transform 0.1s;
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn[aria-busy='true'] {
  opacity: 0.8;
  cursor: progress;
}

.btn[aria-busy='true']::before {
  content: '';
  width: 13px;
  height: 13px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.btn-sm {
  height: 30px;
  padding: 0 10px;
  font-size: 13px;
}

/* Flat TikTok red, like TikTok's own Follow and Post buttons. */
.btn-primary,
.btn-danger {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover:not(:disabled),
.btn-danger:hover:not(:disabled) {
  background: var(--accent-hover);
}

/* TikTok's grey fill buttons, like Message or Share. */
.btn-secondary {
  background: var(--surface-2);
  border-color: light-dark(transparent, var(--line));
  color: var(--text);
  box-shadow: var(--bevel);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--surface-3);
}

.btn-ghost {
  background: transparent;
  color: var(--text-2);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--hover);
  color: var(--text);
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: none;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition:
    background 0.15s,
    color 0.15s;
}

.icon-btn:hover {
  background: var(--hover);
  color: var(--text);
}

.icon-btn.is-danger:hover {
  background: var(--accent-soft);
  color: var(--accent-text);
}

.link-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}

.link-btn:hover {
  color: var(--text);
}

.switch {
  appearance: none;
  position: relative;
  flex: none;
  width: 34px;
  height: 20px;
  margin: 0;
  border-radius: 10px;
  background: light-dark(#cfd0d4, var(--surface-3));
  cursor: pointer;
  transition: background 0.2s var(--ease-out);
}

.switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.35);
  transition: transform 0.2s var(--ease-out);
}

.switch:checked {
  background: var(--ok);
}

.switch:checked::after {
  transform: translateX(14px);
}

/* ---------- Forms ---------- */

.form {
  display: grid;
  gap: 16px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.field {
  display: grid;
  gap: 6px;
  align-content: start;
}

.field label,
.field-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
}

.input {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--field);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}

.input.mono {
  font-family: var(--mono);
  font-size: 13px;
}

.input::placeholder {
  color: var(--faint);
}

.input:hover {
  border-color: var(--line-hover);
}

.input:focus {
  outline: none;
  border-color: var(--focus-border);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

select.input {
  appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238a8b91' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-position: right 10px center;
  background-repeat: no-repeat;
  cursor: pointer;
}

.textarea {
  height: auto;
  min-height: 100px;
  padding: 9px 12px;
  line-height: 1.6;
  resize: vertical;
}

.input-group {
  display: flex;
  align-items: center;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--field);
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}

.input-group:hover {
  border-color: var(--line-hover);
}

.input-group:focus-within {
  border-color: var(--focus-border);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.input-group .prefix {
  padding-left: 12px;
  color: var(--muted);
  font-weight: 600;
}

.input-group .input,
.input-group .input:hover,
.input-group .input:focus {
  border: 0;
  background: transparent;
  box-shadow: none;
  padding-left: 4px;
}

.form-error {
  margin: -4px 0 0;
  color: var(--warn);
  font-size: 13px;
}

.form-error:empty {
  display: none;
}

.form-actions {
  display: flex;
  gap: 8px;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13.5px;
  cursor: pointer;
}

/* Beside a card's title and description, the switch and its label keep their size; the description wraps instead. */
.card-head > .toggle-row {
  flex: none;
  white-space: nowrap;
}

.add-bar {
  display: flex;
  gap: 8px;
}

.add-bar .input-group {
  flex: 1;
}

/* Same height as the field beside it, rather than the 36px a button usually is. Stacked on
   phones it keeps the usual height. */
.add-bar > .btn {
  height: auto;
  min-height: 36px;
}

.add-bar + .form-error {
  margin: 10px 0 0;
}

.add-bar ~ .hint {
  margin-top: 10px;
}

/* A one-line form card: its title on the left and the form beside it, wrapping on narrow screens. */
.card.is-inline-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 24px;
}

.card.is-inline-form > .card-head {
  margin: 0;
}

.card.is-inline-form > .add-bar {
  flex: 1 1 360px;
  max-width: 520px;
}

.card.is-inline-form > .form-error {
  flex-basis: 100%;
  margin: 0;
}

/* Add or edit a server in one row: name, IP, port, password, in-game name, then the buttons. */
.server-form {
  display: grid;
  grid-template-columns:
    minmax(110px, 0.8fr) minmax(140px, 1.1fr) minmax(84px, 0.5fr)
    minmax(140px, 1fr) minmax(150px, 1fr) auto;
  align-items: end;
  gap: 12px;
}

/* How a viewer links their player: three numbered steps, then who has. */
.link-steps {
  display: grid;
  gap: 8px;
  margin: 0 0 18px;
  padding: 14px 16px 14px 36px;
  border-radius: 10px;
  background: var(--well);
  color: var(--text-2);
  font-size: 13.5px;
}

/* Stands in for the steps while the streamer has linking turned off. */
.linking-off {
  margin: 0 0 18px;
  padding: 12px 16px;
  border-radius: 10px;
  background: var(--well);
  color: var(--muted);
  font-size: 13.5px;
}

.link-steps li::marker {
  color: var(--accent-text);
  font-weight: 700;
}

.link-steps code {
  white-space: nowrap;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--code-bg);
  color: var(--text);
}

.link-steps b {
  color: var(--text);
  font-weight: 600;
}

.link-arrow {
  color: var(--faint);
  font-weight: 500;
}

/* Who's in game, to pick your own name from. */
.server-form > .player-pick {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
}

.player-pick > .hint {
  margin: 0;
}

.pick-label {
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
}

/* Like the Live filters: grey pills, solid ink when chosen. */
.pick {
  height: 28px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-2);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition:
    background 0.15s,
    color 0.15s;
}

.pick:hover {
  background: var(--surface-3);
  color: var(--text);
}

.pick[aria-pressed='true'] {
  background: var(--text);
  color: var(--canvas);
}

.in-game {
  color: var(--ok);
  font-weight: 600;
  white-space: nowrap;
}

/* A button that reads as a link inside a line of text. */
.link-inline {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent-text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.link-inline:hover {
  text-decoration: underline;
}

.server-form > .hint code {
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--code-bg);
  color: var(--text);
}

.server-form > .hint,
.server-form > .form-error {
  grid-column: 1 / -1;
  margin: 0;
}

.server-form > .hint:empty {
  display: none;
}

.server-form > .form-actions .btn {
  height: 38px;
}

@media (max-width: 1320px) {
  .server-form {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .server-form > .form-actions {
    grid-column: 1 / -1;
  }
}

@media (max-width: 560px) {
  .server-form {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ---------- Lists ---------- */

.list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.list-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
}

.list-row:first-child {
  border-top: 0;
  padding-top: 0;
}

.list-row:last-child {
  padding-bottom: 0;
}

.list-main {
  flex: 1;
  min-width: 0;
}

.list-title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 10px;
  font-size: 14.5px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.list-sub {
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
}

.list-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.list-actions .switch {
  margin-right: 8px;
}

.tile {
  display: grid;
  place-items: center;
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text-2);
}

.tile.is-ok,
.tile.is-chat {
  background: var(--ok-soft);
  color: var(--ok);
}

.tile.is-gift,
.tile.is-likes {
  background: var(--accent-soft);
  color: var(--accent-text);
}

.tile.is-follow,
.tile.is-share,
.tile.is-viewers {
  background: var(--surface-3);
  color: var(--text);
}

/* Gold, like the diamonds on the stream overlays. */
.tile.is-diamonds {
  background: var(--warn-soft);
  color: var(--warn-text);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-2);
  font: inherit;
  font-size: 12px;
  font-weight: 500;
}

/* A placeholder: the code it inserts, and underneath, what that becomes. */
.chip.is-token {
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  height: auto;
  padding: 5px 10px 6px;
  border-radius: var(--radius);
  text-align: left;
  cursor: pointer;
  transition:
    background 0.15s,
    border-color 0.15s;
}

.chip.is-token code {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
}

.chip.is-token span {
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.3;
}

.chip.is-token:hover {
  background: var(--surface-3);
  border-color: var(--line-hover);
}

/* TikTok's side in aqua, the game's in pink, so {user} and {player} never look alike. */
.token-group.is-tiktok code {
  color: var(--ok);
}

.token-group.is-game code {
  color: var(--accent-text);
}

/* ---------- Home ---------- */

/* TikTok -> rules -> server, and whether events can flow along it. */
.pipeline {
  container: pipeline / inline-size;
  padding: 0;
  overflow: hidden;
}

/* While events flow, the TikTok end glows Rcast red and the server end glows "connected" cyan. */
.pipeline.is-flowing {
  background:
    radial-gradient(50% 140% at 0% 0%, light-dark(rgb(254 44 85 / 0.07), rgb(254 44 85 / 0.12)), transparent 70%),
    radial-gradient(50% 140% at 100% 0%, light-dark(rgb(37 244 238 / 0.14), rgb(37 244 238 / 0.08)), transparent 70%),
    var(--surface);
}

.pipeline-track {
  display: grid;
  grid-template-columns:
    minmax(0, max-content) minmax(32px, 1fr) minmax(0, max-content)
    minmax(32px, 1fr) minmax(0, max-content);
  align-items: center;
  gap: 20px;
  padding: 28px 28px 26px;
}

.pipeline-node {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.pipeline-node > div {
  display: grid;
  justify-items: start;
  gap: 4px;
  min-width: 0;
}

.node-label {
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 500;
}

/* Home's choice of the server they're streaming on, under its status. */
.node-picker {
  width: auto;
  max-width: 100%;
  height: 32px;
  margin-top: 4px;
  padding-top: 0;
  padding-bottom: 0;
  font-size: 13px;
}

.node-name {
  max-width: 100%;
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.01em;
  line-height: 1.25;
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

a.node-name {
  color: var(--accent-text);
}

a.node-name:hover {
  text-decoration: underline;
}

.node-circle {
  display: grid;
  place-items: center;
  flex: none;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--muted);
  box-shadow: inset 0 0 0 1px var(--line);
}

.node-circle.is-ok {
  background: var(--ok-soft);
  color: var(--ok);
  box-shadow: inset 0 0 0 1px var(--ok-line);
}

.node-circle.is-rule {
  background: var(--accent-soft);
  color: var(--accent-text);
  box-shadow: inset 0 0 0 1px var(--accent-line);
}

/* A dashed track while a hop is down; solid once it's ready; a travelling pulse while events flow. */
.pipeline-link {
  position: relative;
  height: 2px;
  overflow: hidden;
  border-radius: 1px;
  background: repeating-linear-gradient(90deg, var(--line-strong) 0 5px, transparent 5px 10px);
}

.pipeline-link.is-ok {
  background: var(--ok-line);
}

.pipeline.is-flowing .pipeline-link::after {
  content: '';
  position: absolute;
  inset: 0;
  width: 45%;
  background: linear-gradient(90deg, transparent, var(--ok), transparent);
  animation: pulse-across 1.8s var(--ease-out) infinite;
}

.pipeline.is-flowing .pipeline-link + .pipeline-node + .pipeline-link::after {
  animation-delay: 0.6s;
}

/* A link that has just connected draws itself across, then the pulse starts. */
.pipeline-link.is-drawing {
  background: repeating-linear-gradient(90deg, var(--line-strong) 0 5px, transparent 5px 10px);
}

.pipeline-link.is-drawing::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--ok-line);
  transform-origin: left center;
  animation: draw-across 0.8s var(--ease-out-expo) both;
}

.pipeline.is-flowing .pipeline-link.is-drawing::after,
.pipeline.is-flowing .pipeline-link + .pipeline-node + .pipeline-link.is-drawing::after {
  animation-delay: 0.8s;
}

@keyframes draw-across {
  from {
    transform: scaleX(0);
    background: var(--ok);
  }
}

@keyframes draw-down {
  from {
    transform: scaleY(0);
    background: var(--ok);
  }
}

@keyframes pulse-across {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(225%);
  }
}

@keyframes pulse-down {
  from {
    transform: translateY(-100%);
  }
  to {
    transform: translateY(170%);
  }
}

/* Too narrow for one line (tablets, phones): each hop becomes a row, with its status on the right. */
@container pipeline (max-width: 760px) {
  .pipeline-track {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
  }

  .pipeline-node > div {
    flex: 1;
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: 10px;
  }

  .pipeline-node > div > .pill {
    grid-area: 1 / 2 / span 2;
    align-self: center;
  }

  .pipeline-link {
    width: 2px;
    height: 16px;
    margin: 5px 0 5px 23px;
    background: repeating-linear-gradient(180deg, var(--line-strong) 0 4px, transparent 4px 8px);
  }

  .pipeline-link.is-drawing {
    background: repeating-linear-gradient(180deg, var(--line-strong) 0 4px, transparent 4px 8px);
  }

  .pipeline-link.is-drawing::before {
    transform-origin: center top;
    animation-name: draw-down;
  }

  .pipeline.is-flowing .pipeline-link::after {
    width: 100%;
    height: 60%;
    background: linear-gradient(180deg, transparent, var(--ok), transparent);
    animation-name: pulse-down;
  }
}

/* The verdict, as a footer band tinted by how things stand. */
.pipeline-caption {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 13px 28px;
  border-top: 1px solid var(--line);
  background: var(--tint);
  color: var(--text-2);
}

.pipeline-caption .icon {
  margin-top: 1px;
  color: var(--muted);
}

.pipeline-caption.is-ok {
  background: var(--ok-wash);
  color: var(--text);
}

.pipeline-caption.is-ok .icon {
  color: var(--ok);
}

.pipeline-caption.is-bad {
  background: var(--warn-soft);
  color: var(--warn-text);
}

.pipeline-caption.is-bad .icon {
  color: var(--warn);
}

/* Setup progress: a segmented bar, one segment per step. */
.progress {
  display: flex;
  gap: 4px;
}

.progress span {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: var(--surface-3);
  transition: background 0.3s var(--ease-out);
}

.progress span.is-done {
  background: var(--ok);
}

/* Only on Overview: the setup guide's bar re-renders on every navigation and would replay. */
.setup-card .progress span.is-done {
  transform-origin: left center;
  animation: fill-in 0.5s var(--ease-out-expo) backwards;
}

.setup-card .progress span.is-done:nth-child(2) {
  animation-delay: 80ms;
}

.setup-card .progress span.is-done:nth-child(3) {
  animation-delay: 160ms;
}

@keyframes fill-in {
  from {
    transform: scaleX(0);
  }
}

.setup-card .progress {
  margin-bottom: 6px;
}

.setup-card .steps > li:first-child {
  border-top: 0;
}

.steps {
  list-style: none;
  margin: 0;
  padding: 0;
}

.steps > li {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  gap: 2px 14px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
}

.steps > li:last-child {
  padding-bottom: 0;
}

.step-dot {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.is-done > .step-dot {
  background: var(--ok);
  color: var(--on-ok);
}

.is-current > .step-dot {
  background: var(--accent-soft);
  color: var(--accent-text);
  box-shadow: inset 0 0 0 1px var(--focus-border);
}

.step-title {
  font-weight: 600;
}

.step-desc {
  color: var(--muted);
  font-size: 13px;
}

.steps > li.is-done .step-title {
  color: var(--muted);
}

.mini-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.mini-list li {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  border-top: 1px solid var(--line);
}

.mini-list li:first-child {
  border-top: 0;
  padding-top: 0;
}

.mini-list li:last-child {
  padding-bottom: 0;
}

.mini-list .tile {
  width: 32px;
  height: 32px;
  border-radius: var(--radius);
}

.mini-list li.is-off .tile,
.mini-list li.is-off > div {
  opacity: 0.55;
}

.mini-title,
.mini-sub {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini-title {
  font-weight: 600;
}

.mini-sub {
  color: var(--muted);
  font-size: 12.5px;
}

/* ---------- Live chat ---------- */

.live-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 16px;
  align-items: start;
}

/* Doubled class so the phone rule that pads every .card can't pad this one. */
.card.chat-card {
  display: flex;
  flex-direction: column;
  height: 70vh;
  min-height: 460px;
  padding: 0;
  overflow: hidden;
}

/* Side by side, Live fills the window and only the feed scrolls, never the page. The page gets a
   definite height (the window less .content's 8px margins and 1px borders), and the feed card
   stretches into whatever the header leaves. */
@media (min-width: 1081px) {
  .page:has(.live-layout) {
    display: flex;
    flex-direction: column;
    height: max(calc(100vh - 18px), 640px);
  }

  .page:has(.live-layout) > div {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
  }

  .live-layout {
    flex: 1;
    min-height: 0;
    grid-template-rows: minmax(0, 1fr);
  }

  .card.chat-card {
    height: auto;
    align-self: stretch;
  }
}

/* Feed filters: a row of pills that scrolls sideways when it doesn't fit. */
.tabs {
  display: flex;
  gap: 6px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: none;
  flex: none;
}

.tab {
  flex: none;
  height: 30px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-2);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition:
    background 0.15s,
    color 0.15s;
}

.tab:hover {
  background: var(--surface-3);
  color: var(--text);
}

/* Selected like TikTok's category chips: solid ink in light, solid white in dark. */
.tab[aria-pressed='true'] {
  background: var(--text);
  color: var(--canvas);
}

.chat {
  flex: 1;
  list-style: none;
  margin: 0;
  padding: 8px;
  overflow-y: auto;
}

.msg + .msg {
  margin-top: 2px;
}

.chat.is-compact {
  padding: 0;
  margin: 0 -10px;
  overflow: visible;
}

.msg {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 10px;
}

.msg:hover {
  background: var(--hover);
}

.msg.is-new {
  animation: fade-in 0.3s var(--ease-out);
}

/* A fresh command, or the message that triggered one, lights up aqua for a moment. */
.msg.is-new.is-fired,
.msg-system.is-new:not(.is-failed) {
  animation:
    fade-in 0.3s var(--ease-out),
    fired-flash 1.4s var(--ease-out);
}

@keyframes fired-flash {
  0%,
  15% {
    background: var(--ok-soft);
    box-shadow: inset 0 0 0 1px var(--ok-line);
  }
}

/* ---------- Live effects (gifts and hearts) ---------- */

.card.chat-card {
  position: relative;
}

.fx-layer {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

.fx-gift {
  position: absolute;
  left: var(--x);
  bottom: 24px;
  display: grid;
  place-items: center;
  width: var(--size);
  height: var(--size);
  margin-left: calc(var(--size) / -2);
  color: var(--accent-text);
  filter: drop-shadow(0 6px 14px light-dark(rgb(22 24 35 / 0.25), rgb(0 0 0 / 0.6)));
  animation: gift-float 2.2s var(--ease-out) backwards;
}

.fx-gift img,
.fx-gift .icon {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.fx-gift.is-small {
  --size: 40px;
}

.fx-gift.is-mid {
  --size: 56px;
}

.fx-gift.is-big {
  --size: 84px;
  animation-duration: 2.8s;
  filter: drop-shadow(0 0 18px var(--accent-line)) drop-shadow(0 8px 18px light-dark(rgb(22 24 35 / 0.25), rgb(0 0 0 / 0.6)));
}

@keyframes gift-float {
  0% {
    opacity: 0;
    transform: translateY(20px) scale(0.4) rotate(var(--rot));
  }
  15% {
    opacity: 1;
    transform: translateY(0) scale(1.15) rotate(var(--rot));
  }
  25% {
    transform: translateY(-10px) scale(1) rotate(0deg);
  }
  75% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateY(-140px) scale(0.9);
  }
}

/* Sparks fly out from where a bigger gift lands. */
.fx-spark {
  position: absolute;
  left: var(--x);
  bottom: 64px;
  width: 6px;
  height: 6px;
  margin-left: -3px;
  border-radius: 50%;
  background: var(--tiktok-red);
  box-shadow: 0 0 8px var(--tiktok-red);
  animation: spark 0.8s var(--ease-out-expo) backwards;
}

.fx-spark:nth-child(even) {
  background: var(--tiktok-aqua);
  box-shadow: 0 0 8px var(--tiktok-aqua);
}

@keyframes spark {
  from {
    opacity: 1;
    transform: translate(0, 0) scale(1);
  }
  to {
    opacity: 0;
    transform: translate(var(--dx), var(--dy)) scale(0.3);
  }
}

.fx-heart {
  position: absolute;
  left: var(--left);
  top: var(--top);
  display: grid;
  color: var(--tiktok-red);
  filter: hue-rotate(calc(var(--hue) * 1deg));
  translate: -50% -50%;
  animation: heart-rise 1.6s var(--ease-out) backwards;
}

@keyframes heart-rise {
  0% {
    opacity: 0;
    transform: translate(0, 0) scale(0.3);
  }
  15% {
    opacity: 1;
    transform: translate(0, -10px) scale(1.1);
  }
  100% {
    opacity: 0;
    transform: translate(var(--dx), -90px) scale(0.8);
  }
}

.msg-body {
  flex: 1;
  min-width: 0;
}

.msg-name {
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.msg-time {
  color: var(--faint);
  font-weight: 400;
}

.msg-text {
  color: var(--text);
  overflow-wrap: anywhere;
}

.msg-gift {
  background: var(--accent-wash);
}

.msg-gift .msg-text b {
  color: var(--accent-text);
}

.gift-img {
  width: 20px;
  height: 20px;
  vertical-align: middle;
}

.msg-like .msg-text {
  color: var(--accent-text);
}

.msg-social .msg-text {
  color: var(--ok);
}

.msg-fired {
  align-self: center;
  color: var(--accent-text);
}

/* What Rcast did. A faint tint marks it apart from viewers without turning a burst into a slab. */
.msg-system {
  align-items: center;
  background: var(--ok-wash);
}

.msg-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--ok-soft);
  color: var(--ok);
}

.msg-cmd {
  display: block;
  width: fit-content;
  max-width: 100%;
  margin-top: 3px;
  padding: 2px 8px;
  border-radius: 5px;
  background: var(--code-bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 12.5px;
  overflow-wrap: anywhere;
}

.msg-system.is-failed {
  background: var(--warn-wash);
}

.msg-system.is-failed .msg-icon {
  background: var(--warn-soft);
  color: var(--warn);
}

.msg-error {
  color: var(--warn);
  font-size: 12.5px;
}

.chat-empty {
  display: grid;
  place-content: center;
  height: 100%;
}

.live-side {
  position: sticky;
  top: 28px;
  display: grid;
  gap: 16px;
}

.live-status {
  display: grid;
  gap: 16px;
}

.live-host {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 12px;
  font-size: 15px;
}

.live-status a {
  color: var(--accent-text);
  font-weight: 600;
}

.stats {
  display: grid;
}

.stat {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 0;
  border-top: 1px solid var(--line);
}

.stat:first-child {
  padding-top: 0;
  border-top: 0;
}

.stat:last-child {
  padding-bottom: 0;
}

.stat-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
}

.stat-icon.is-heart {
  background: var(--accent-soft);
  color: var(--accent-text);
}

.stat-icon.is-chat {
  background: var(--surface-3);
  color: var(--text);
}

.stat-icon.is-bolt {
  background: var(--ok-soft);
  color: var(--ok);
}

.stat-value {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.stat-label {
  color: var(--muted);
  font-size: 12.5px;
}

/* ---------- Analytics ---------- */

/* Headline numbers: eight, so four to a row, or two in a narrow card, stacked on phones. */
.metrics-card {
  container-type: inline-size;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.metric {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--tint);
}

.metric-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--text);
}

.metric-icon.is-red {
  background: var(--accent-soft);
  color: var(--accent-text);
}

.metric-icon.is-aqua {
  background: var(--ok-soft);
  color: var(--ok);
}

.metric-value {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.metric-label {
  color: var(--muted);
  font-size: 12.5px;
}

.gifters {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.gifters-title,
.rule-stats-title {
  margin-bottom: 10px;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 650;
}

.gifters-list {
  display: grid;
  gap: 8px;
  max-width: 560px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.gifters-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.gifter-rank {
  display: grid;
  place-items: center;
  flex: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 700;
}

.gifter-rank.is-first {
  background: var(--accent);
  color: #fff;
}

.gifter-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gifter-diamonds,
.row-stat {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.gifter-diamonds {
  color: var(--muted);
}

.stream-row {
  align-items: flex-start;
}

.row-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin-top: 8px;
}

.row-stat {
  color: var(--text-2);
  font-weight: 600;
}

.row-stat .icon {
  color: var(--faint);
}

/* What each rule did: on the all-time card under the gifters, and folded away under each stream. */
.rule-stats-block {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.rule-stats-block .rule-stats-title {
  margin-bottom: 4px;
}

.rule-stats-note {
  max-width: 70ch;
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12.5px;
}

.rule-stats {
  width: 100%;
  max-width: 560px;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.rule-stats th,
.rule-stats td {
  padding: 6px 0 6px 12px;
  text-align: right;
  white-space: nowrap;
}

.rule-stats :is(th, td):first-child {
  overflow: hidden;
  padding-left: 0;
  text-align: left;
  text-overflow: ellipsis;
}

.rule-stats thead th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

/* The fixed layout takes the column widths from the header: the numbers get what they need, the name the rest. */
.rule-stats thead th:not(:first-child) {
  width: 8em;
}

.rule-stats thead .icon {
  margin-right: 4px;
  color: var(--faint);
  vertical-align: -2px;
}

.rule-stats tbody tr {
  border-top: 1px solid var(--line);
}

.rule-stats tbody th {
  font-weight: 600;
}

.rule-stats tbody th.is-deleted {
  color: var(--muted);
  font-style: italic;
  font-weight: 500;
}

.rule-stats td {
  color: var(--text-2);
  font-weight: 600;
}

.rule-stats-toggle {
  margin-top: 8px;
}

.rule-stats-toggle > summary {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  list-style: none;
  cursor: pointer;
}

.rule-stats-toggle > summary::-webkit-details-marker {
  display: none;
}

.rule-stats-toggle > summary:hover {
  color: var(--text);
}

.rule-stats-toggle > summary .icon {
  transition: transform 0.2s var(--ease-out);
}

/* The arrow points down while the rules are open. */
.rule-stats-toggle[open] > summary .icon {
  transform: rotate(90deg);
}

.rule-stats-toggle > .rule-stats-note {
  margin-top: 8px;
}

.list-more {
  display: flex;
  justify-content: center;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

/* The share dialog: a preview of the image, sized to fit the screen, then what to do with it. */
.share-dialog {
  width: min(460px, calc(100vw - 32px));
}

.share-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.share-head .icon-btn {
  margin: -6px -8px -6px 0;
}

.share-frame {
  position: relative;
  justify-self: center;
  width: min(100%, max(180px, calc((100dvh - 340px) * 9 / 16)));
  aspect-ratio: 9 / 16;
  margin: 6px 0 4px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  background: #000;
}

.share-preview {
  display: block;
  width: 100%;
  height: 100%;
}

.share-preview:not([src]) {
  visibility: hidden;
}

.share-frame[aria-busy='true']::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 28px;
  height: 28px;
  margin: -14px 0 0 -14px;
  border: 3px solid rgb(255 255 255 / 0.8);
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.dialog-actions.share-actions {
  flex-wrap: wrap;
  margin-top: 6px;
}

@container (max-width: 680px) {
  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@container (max-width: 420px) {
  .metric {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 12px;
  }
}

/* Phones: the stream's share button keeps just its icon, and the actions sit two to a row
   under a full-width primary. The rules' columns are headed by their icons, which leaves the
   rule's name room. */
@media (max-width: 560px) {
  .stream-row > .tile,
  .stream-row .btn-text {
    display: none;
  }

  .rule-stats th,
  .rule-stats td {
    padding-left: 8px;
  }

  .rule-stats thead th:not(:first-child) {
    width: 4.25em;
  }

  .rule-stats thead .icon {
    margin-right: 0;
  }

  /* Kept for screen readers, like .sr-only. */
  .rule-stats-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .dialog-actions.share-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .share-actions > .btn-primary,
  .share-actions > .btn:nth-child(2):last-child {
    grid-column: 1 / -1;
  }
}

/* ---------- Rules ---------- */

.rule-row {
  align-items: flex-start;
}

.rule-row.is-off .list-main,
.rule-row.is-off .tile {
  opacity: 0.5;
}

.rule-then {
  display: grid;
  gap: 4px;
  margin-top: 10px;
}

/* Console lines, sized to the command, with a prompt so they read as output rather than inputs. */
.rule-then code {
  display: block;
  width: fit-content;
  max-width: 100%;
  padding: 4px 10px 4px 8px;
  border-radius: var(--radius-sm);
  background: var(--code-bg);
  color: var(--text);
  font-size: 12.5px;
  overflow-wrap: anywhere;
}

.rule-then code::before {
  content: '›';
  margin-right: 8px;
  color: var(--accent-text);
  font-weight: 500;
}

.rule-then > .muted {
  font-size: 12.5px;
}

.rule-row .chips {
  margin-top: 12px;
}

/* Where and how often: quieter than the rule itself. */
.rule-row .chip {
  height: 22px;
  padding: 0 8px;
  background: transparent;
  color: var(--muted);
}

/* On phones the commands and chips take the full row instead of a narrow column beside the actions,
   and the actions (a switch and five buttons) get a row of their own underneath, leaving the name room. */
@media (max-width: 560px) {
  .rule-row {
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr);
    gap: 0 12px;
  }

  .rule-row .list-main {
    display: contents;
  }

  .rule-row > .tile {
    grid-row: 1 / span 2;
  }

  .rule-row .list-title {
    grid-area: 1 / 2;
  }

  .rule-row .list-sub {
    grid-area: 2 / 2;
  }

  .rule-row .list-actions {
    grid-column: 1 / -1;
    justify-content: flex-end;
    margin-top: 8px;
  }

  .rule-row .rule-then,
  .rule-row .chips {
    grid-column: 1 / -1;
  }

  .rule-row.is-off .list-main > * {
    opacity: 0.5;
  }

  /* A linked account's controls drop under its name, so the name and status get the width. */
  .account-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 10px 14px;
  }

  .account-row > .avatar {
    grid-row: 1 / span 2;
    align-self: start;
  }

  .account-row .list-actions {
    grid-column: 2;
    margin-left: -8px;
  }
}

.editor {
  position: sticky;
  top: 28px;
}

/* Seven tiles: four on the first row and three on the second, each row filling the width (a
   12-column grid: the first four span 3, the rest 4), so none is left on its own. */
.type-tiles {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 6px;
}

.type-tiles > .type-tile {
  grid-column: span 3;
}

.type-tiles > .type-tile:nth-child(n + 5) {
  grid-column: span 4;
}

.type-tile {
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 10px 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--field);
  color: var(--text-2);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition:
    background 0.15s,
    border-color 0.15s,
    color 0.15s;
}

.type-tile:hover {
  border-color: var(--line-strong);
  color: var(--text);
}

.type-tile[aria-pressed='true'] {
  border-color: var(--focus-border);
  background: var(--accent-soft);
  color: var(--text);
}

.type-tile[aria-pressed='true'] .icon {
  color: var(--accent-text);
}

/* Placeholder chips, in two labelled rows: what comes from TikTok, and you in game. */
.token-groups {
  display: grid;
  gap: 12px;
}

.token-group {
  display: grid;
  gap: 6px;
}

.token-label {
  color: var(--muted);
  font-size: 12.5px;
}

.token-label b {
  color: var(--text-2);
  font-weight: 600;
}

.player-warning:empty {
  display: none;
}

.player-warning .notice {
  margin: 0;
}

.notice a {
  font-weight: 600;
}

/* The selected trigger's own settings: a tinted well under the tiles, not a card in a card. */
.trigger-box {
  padding: 14px;
  border-radius: 10px;
  background: var(--well);
}

/* ---------- Overlays ---------- */

/* The style controls above the links, set apart from them like a list row. */
.overlay-style {
  display: grid;
  gap: 10px;
  padding-bottom: 16px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.overlay-style-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px 16px;
}

.overlay-accent {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
}

.overlay-color {
  flex: none;
  width: 52px;
  padding: 4px;
  cursor: pointer;
}

.overlay-color::-webkit-color-swatch-wrapper {
  padding: 0;
}

.overlay-color::-webkit-color-swatch {
  border: 0;
  border-radius: var(--radius-sm);
}

.overlay-color::-moz-color-swatch {
  border: 0;
  border-radius: var(--radius-sm);
}

.overlay-accent-value {
  flex: 1;
  min-width: 0;
  color: var(--text-2);
  font-family: var(--mono);
  font-size: 13px;
}

/* Each link with its position picker in front. */
.overlay-link {
  display: grid;
  grid-template-columns: minmax(150px, 190px) minmax(0, 1fr);
  gap: 8px;
  margin-top: 8px;
}

@media (max-width: 560px) {
  .overlay-link {
    grid-template-columns: 1fr;
  }
}

.overlay-row .list-actions {
  align-self: flex-end;
}

.overlay-howtos {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px 32px;
  margin-bottom: 16px;
}

.overlay-howto h3 {
  margin: 0 0 6px;
}

.overlay-howto ol {
  margin: 0;
  padding-left: 20px;
  color: var(--text-2);
  font-size: 13.5px;
  line-height: 1.6;
}

/* ---------- Polls ---------- */

.poll-question {
  margin: 0 0 14px;
  font-size: 17px;
  font-weight: 650;
  overflow-wrap: anywhere;
}

.poll-countdown {
  font-variant-numeric: tabular-nums;
}

/* Each answer: its number, text and votes on one line, its bar under the text. */
.poll-results {
  display: grid;
  gap: 12px;
  margin: 0 0 12px;
  padding: 0;
  list-style: none;
}

.poll-results li {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px 10px;
  font-size: 14px;
}

.poll-num {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 700;
}

.poll-answer {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.poll-votes {
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.poll-bar {
  grid-column: 2 / -1;
  height: 6px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.poll-bar > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--line-hover);
}

/* In the lead while it runs; the winner once it's final. */
.poll-results .is-leading .poll-num {
  background: var(--accent-soft);
  color: var(--accent-text);
}

.poll-results .is-winner .poll-num {
  background: var(--accent);
  color: #fff;
}

.poll-results .is-leading .poll-bar > span,
.poll-results .is-winner .poll-bar > span {
  background: var(--accent);
}

.poll-answers {
  display: grid;
  gap: 8px;
}

.poll-answer-row {
  display: flex;
  align-items: center;
  gap: 4px;
}

.poll-answer-row .input-group {
  flex: 1;
}

/* A past poll: its question and how it went, opening to each answer's votes. */
.poll-row {
  align-items: flex-start;
}

.poll-past summary {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  list-style: none;
  cursor: pointer;
}

.poll-past summary::-webkit-details-marker {
  display: none;
}

.poll-past summary::before {
  content: '';
  flex: none;
  width: 7px;
  height: 7px;
  margin: 6px 2px 0;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg);
  transition: transform 0.15s;
}

.poll-past[open] summary::before {
  transform: rotate(45deg);
}

.poll-past-text {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.poll-past .poll-results {
  margin: 12px 0 0 21px;
}

/* ---------- Dialogs ---------- */

.dialog {
  width: min(440px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: var(--surface-pop);
  color: var(--text);
  box-shadow: var(--shadow-pop);
}

.dialog[open] {
  animation: dialog-in 0.22s var(--ease-out-expo);
}

.dialog::backdrop {
  background: var(--backdrop);
  animation: backdrop-in 0.22s var(--ease-out);
}

@keyframes dialog-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
}

@keyframes backdrop-in {
  from {
    opacity: 0;
  }
}

.dialog-body {
  display: grid;
  gap: 8px;
  padding: 22px;
}

.dialog h2 {
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.dialog-body > p {
  color: var(--text-2);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}

/* Rule templates: each a button showing what it listens for and the commands it fills in. */
.templates {
  width: min(560px, calc(100vw - 32px));
  overflow: hidden;
}

/* The list scrolls between the tabs and the buttons, so Close never scrolls out of reach. */
.templates .dialog-body {
  box-sizing: border-box;
  max-height: calc(100vh - 48px);
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
}

.template-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.template-list {
  display: grid;
  align-content: start;
  gap: 8px;
  /* Room for the buttons' focus rings, which the scrolling would otherwise clip. */
  margin: 6px -3px 0;
  padding: 3px;
  list-style: none;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.template-list > [hidden] {
  display: none;
}

.template {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  width: 100%;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--field);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition:
    background 0.15s,
    border-color 0.15s;
}

.template:hover {
  border-color: var(--line-strong);
  background: var(--surface-2);
}

.template-main {
  display: grid;
  flex: 1;
  min-width: 0;
}

.template-about {
  margin-top: 6px;
  color: var(--text-2);
  font-size: 13px;
}

.template .rule-then {
  margin-top: 8px;
}

/* "How did you find us?": each answer a row to click, its radio showing which is picked. */
.found-options {
  display: grid;
  gap: 8px;
  margin-top: 6px;
}

.found-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--field);
  font-weight: 550;
  cursor: pointer;
  transition:
    background 0.15s,
    border-color 0.15s;
}

.found-option:hover {
  border-color: var(--line-strong);
  background: var(--surface-2);
}

.found-option:has(input:checked) {
  border-color: var(--brand);
}

.found-option input {
  margin: 0;
  accent-color: var(--brand);
}

/* After a LIVE: what it made, as the headline, then how it went. */
.stream-summary {
  width: min(600px, calc(100vw - 32px));
}

.stream-summary h2 {
  font-size: 21px;
  line-height: 1.3;
  text-wrap: balance;
}

.summary-kicker {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.stream-summary .stream-results {
  margin-top: 10px;
}

.earned-amount {
  color: var(--accent-text);
  font-variant-numeric: tabular-nums;
}

/* The same line on the subscribe page's free stream results. */
.earned {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border-radius: var(--radius-lg);
  background: var(--accent-soft);
}

.earned > p:first-child {
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
}

/* A link at the start of a dialog's buttons, away from Close. */
.dialog-actions .is-start {
  margin-right: auto;
}

/* ---------- Marketplace ---------- */

/* Search and sort on one line, the filters under them. */
.market-bar {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.market-search {
  display: flex;
  gap: 8px;
}

.market-search .input-group {
  flex: 1;
  min-width: 0;
}

.market-search .prefix {
  display: grid;
  place-items: center;
}

.market-sort {
  flex: none;
  width: auto;
}

.market-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* As many cards to a row as fit at a width a console command reads well in. */
.market-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr));
  gap: 16px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.listing {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.listing-head,
.rule-summary {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.listing-name {
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.005em;
}

/* The name opens the listing. It reads as a heading until hovered. */
.listing-open {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  overflow-wrap: anywhere;
  cursor: pointer;
}

.listing-open:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* Three lines on a card; the listing dialog shows all of it, line breaks included. */
.listing-about {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  color: var(--text-2);
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
}

.listing-about.is-full {
  display: block;
  white-space: pre-wrap;
}

.listing .rule-then,
.listing-dialog .rule-then {
  margin-top: 0;
}

/* Who shared it and how it's done, pinned to the bottom so cards in a row line up. */
.listing-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.listing-meta.is-top {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.byline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  font-size: 13px;
}

.byline-name {
  overflow: hidden;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.listing-stats {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.listing-stat,
.like-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.like-btn {
  height: 28px;
  padding: 0 8px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  font-family: inherit;
  cursor: pointer;
  transition:
    background 0.15s,
    color 0.15s;
}

/* An outline until liked, then a solid TikTok-red heart. */
.like-btn .icon {
  fill: none;
}

.like-btn:not(.is-static):hover {
  background: var(--accent-soft);
  color: var(--accent-text);
}

.like-btn[aria-pressed='true'] {
  color: var(--accent-text);
}

.like-btn[aria-pressed='true'] .icon {
  fill: currentColor;
}

.like-btn.is-static {
  padding: 0;
  cursor: default;
}

.listing-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.listing-actions .btn {
  margin-right: auto;
}

.market-more {
  display: flex;
  justify-content: center;
}

/* Wide enough for most console commands to sit on one line. */
.listing-dialog {
  width: min(560px, calc(100vw - 32px));
}

.listing-dialog .dialog-body {
  gap: 12px;
}

.listing-dialog .dialog-actions {
  margin-top: 4px;
}

/* The rule being shared, as a tinted well like the editor's trigger settings. */
.rule-summary {
  padding: 14px;
  border-radius: 10px;
  background: var(--well);
}

.rule-summary .rule-then {
  margin-top: 8px;
}

.listing-install {
  display: grid;
  gap: 12px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.listing-dialog .hint {
  margin: 0;
}

/* Testing a rule: what each command did, as console lines with the server's reply under them. */
.test-dialog {
  width: min(560px, calc(100vw - 32px));
}

.test-dialog .dialog-body {
  gap: 12px;
}

.test-dialog .hint,
.test-dialog .notice {
  margin: 0;
}

.test-results {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 14px;
  border-radius: 10px;
  background: var(--well);
  list-style: none;
}

.test-result {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.test-result > .icon {
  flex: none;
  margin-top: 5px;
}

.test-result.is-sent > .icon {
  color: var(--ok);
}

.test-result.is-failed > .icon {
  color: var(--warn);
}

.test-result.is-waiting > .icon {
  color: var(--muted);
}

.test-result-main {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.test-result code {
  width: fit-content;
  max-width: 100%;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  background: var(--code-bg);
  color: var(--text);
  font-size: 12.5px;
  overflow-wrap: anywhere;
}

/* Replies can be long (a player list, serverinfo's JSON), so a few lines show and the rest scroll. */
.test-reply {
  max-height: 7.5em;
  margin: 0;
  overflow: auto;
  color: var(--text-2);
  font-family: var(--mono);
  font-size: 12px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.test-note {
  color: var(--muted);
  font-size: 13px;
}

.test-result.is-failed .test-note {
  color: var(--warn-text);
}

.test-status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--text-2);
  font-size: 13px;
}

.test-status:empty {
  display: none;
}

.test-status.is-busy::before {
  content: '';
  width: 12px;
  height: 12px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* First-run welcome. */
.welcome {
  width: min(600px, calc(100vw - 32px));
}

.welcome-flow {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: start;
  gap: 10px;
  padding: 24px 22px;
  border-bottom: 1px solid var(--line);
  background: var(--canvas);
  border-radius: 14px 14px 0 0;
}

.flow-node {
  display: grid;
  justify-items: center;
  gap: 8px;
  text-align: center;
  min-width: 0;
}

.flow-node b {
  font-size: 13px;
  font-weight: 600;
}

.flow-node code {
  max-width: 100%;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--field);
  color: var(--text-2);
  font-size: 11.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.flow-arrow {
  margin-top: 12px;
  color: var(--faint);
}

.welcome .dialog-body {
  gap: 10px;
  padding: 22px 24px 24px;
}

.welcome h2 {
  font-size: 20px;
}

.welcome .steps {
  margin-top: 8px;
}

.welcome .steps > li {
  padding: 10px 0;
}

.welcome .steps > li:last-child {
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.step-time {
  color: var(--muted);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}

/* ---------- Setup guide (bottom-right dock) ---------- */

.guide {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: var(--z-dock);
  width: 344px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: var(--surface-pop);
  box-shadow: var(--shadow-pop);
  animation: dock-in 0.3s var(--ease-out-expo);
}

@keyframes dock-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
}

.guide-head {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 8px 0 16px;
}

.guide-head > div {
  flex: 1;
  min-width: 0;
}

.guide-title {
  font-size: 14px;
  font-weight: 650;
}

.guide-count {
  color: var(--muted);
  font-size: 12.5px;
}

.guide > .progress {
  margin: 12px 16px 4px;
}

.guide-steps {
  list-style: none;
  margin: 0;
  padding: 6px 8px 8px;
}

.guide-step {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  align-items: center;
  gap: 0 10px;
  padding: 8px;
  border-radius: 10px;
}

.guide-step > .step-dot {
  width: 24px;
  height: 24px;
  font-size: 12px;
}

.guide-step.is-current {
  align-items: start;
  background: var(--canvas);
}

.guide-step.is-upcoming .step-title {
  color: var(--muted);
}

.guide-step.is-done .step-title {
  color: var(--muted);
}

.guide-step.is-current .step-title {
  line-height: 24px;
}

.guide-body {
  grid-column: 2;
  display: grid;
  gap: 10px;
  margin-top: 4px;
  color: var(--text-2);
  font-size: 13px;
}

.guide-tip {
  display: flex;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 12.5px;
}

.guide-tip .icon {
  margin-top: 1px;
  color: var(--muted);
}

.guide-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.guide-here {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--accent-text);
  font-size: 12.5px;
  font-weight: 600;
}

.guide-done {
  display: grid;
  gap: 10px;
  padding: 8px 16px 16px;
  color: var(--text-2);
  font-size: 13px;
}

.guide-done h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 15px;
  font-weight: 650;
}

.guide-done h3 .icon {
  color: var(--ok);
}

.guide-done ul {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.guide-done li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.guide-done li > span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Collapsed guide: a pill with a progress ring. */
/* When the highlighted form sits under the dock's usual corner, the dock moves left of it. */
.guide.is-left {
  right: auto;
  left: 256px;
}

.guide-pill {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: var(--z-dock);
  display: flex;
  align-items: center;
  gap: 10px;
  height: 40px;
  padding: 0 16px 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface-pop);
  color: var(--text);
  box-shadow: var(--shadow-pop);
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  animation: dock-in 0.3s var(--ease-out-expo);
  transition: background 0.15s;
}

.guide-pill:hover {
  background: var(--surface-2);
}

.ring {
  flex: none;
  transform: rotate(-90deg);
}

.ring circle {
  fill: none;
  stroke-width: 3;
}

.ring .ring-track {
  stroke: var(--surface-3);
}

.ring .ring-value {
  stroke: var(--ok);
  stroke-linecap: round;
  transition: stroke-dashoffset 0.4s var(--ease-out);
}

/* The part of the page the current guide step is about. */
.tour-target {
  outline: 2px solid var(--focus-border);
  outline-offset: 3px;
  animation: tour-pulse 1.4s var(--ease-out) 2;
}

@keyframes tour-pulse {
  from {
    box-shadow: 0 0 0 0 rgb(254 44 85 / 0.35);
  }
  to {
    box-shadow: 0 0 0 16px rgb(254 44 85 / 0);
  }
}

/* ---------- Sign-in ---------- */

.signin {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(380px, 0.7fr);
  background: var(--canvas);
}

.signin-pitch {
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-rows: auto 1fr;
  padding: 28px 48px 48px;
  overflow: hidden;
}

/* A faint dot grid, fading out from the middle: a stage for the pitch, not a pattern to look at. */
.signin-pitch::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background-image: radial-gradient(var(--dots) 1px, transparent 1.5px);
  background-size: 24px 24px;
  mask-image: radial-gradient(ellipse 65% 60% at 62% 50%, #000 10%, transparent 75%);
}

.signin-pitch-body {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 56px;
}

/* The logo, and on the homepage, links down the page and to the Marketplace. */
.pitch-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.pitch-nav {
  display: flex;
  align-items: center;
  gap: 2px;
}

.pitch-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--text-2);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition:
    background 0.15s,
    color 0.15s;
}

.pitch-link:hover {
  background: var(--hover);
  color: var(--text);
}

.pitch-text {
  max-width: 440px;
}

/* The logo's voice: heavy slanted capitals, TikTok's side in aqua and Rust's in pink. Saira is
   only used here, on the one page that is the brand rather than the tool. */
.signin-pitch h1 {
  font-family: 'Saira', var(--font);
  font-size: clamp(34px, 3.6vw, 52px);
  font-style: italic;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.01em;
  text-transform: uppercase;
}

.signin-pitch h1 .is-tiktok {
  color: var(--ok);
}

.signin-pitch h1 .is-rust {
  color: var(--accent-text);
}

.signin-pitch p {
  margin-top: 16px;
  max-width: 38ch;
  color: var(--text-2);
  font-size: 16px;
}

.pitch-points {
  display: grid;
  gap: 12px;
  margin: 28px 0 0;
  padding: 0;
  list-style: none;
}

.pitch-points li {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-2);
}

.pitch-points .tile {
  width: 32px;
  height: 32px;
  border-radius: var(--radius);
}

/* Shown on phones too, where the points above are hidden. */
.pitch-discord {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 24px;
  color: var(--text-2);
  font-weight: 600;
  text-decoration: none;
  transition: color 0.15s;
}

.pitch-discord .icon {
  color: #5865f2;
}

.pitch-discord:hover {
  color: var(--text);
}

.signin-side {
  display: grid;
  place-items: center;
  padding: 32px;
  background: var(--sidebar);
  border-left: 1px solid var(--line);
}

.signin-card {
  display: grid;
  gap: 12px;
  width: min(360px, 100%);
  animation: rise-in 0.6s var(--ease-out-expo) 0.15s backwards;
}

/* The pitch arrives line by line, then the phone floats up beside it. */
.pitch-text > :not(.pitch-points),
.pitch-points li,
.signin-pitch .phone {
  animation: rise-in 0.6s var(--ease-out-expo) backwards;
}

.pitch-text > :nth-child(2) {
  animation-delay: 80ms;
}

.pitch-points li:nth-child(1) {
  animation-delay: 160ms;
}

.pitch-points li:nth-child(2) {
  animation-delay: 220ms;
}

.pitch-points li:nth-child(3) {
  animation-delay: 280ms;
}

.pitch-points li:nth-child(4) {
  animation-delay: 340ms;
}

.pitch-text > :nth-child(4) {
  animation-delay: 400ms;
}

.signin-pitch .phone {
  animation-duration: 0.9s;
  animation-delay: 0.25s;
}

.signin-card h2 {
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.signin-card h2 + p {
  margin: -6px 0 12px;
  color: var(--muted);
}

.signin-card .notice {
  margin: 0;
}

.login-option {
  display: grid;
  grid-template-columns: 22px 1fr 22px;
  align-items: center;
  height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition:
    background 0.15s,
    border-color 0.15s;
}

.login-option span {
  text-align: center;
}

.login-option:hover:not(:disabled) {
  background: var(--surface-2);
  border-color: var(--line-hover);
}

.login-option:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.login-option.is-discord {
  border-color: transparent;
  background: #5865f2;
  color: #fff;
}

.login-option.is-discord:hover:not(:disabled) {
  background: #4752c4;
  border-color: transparent;
}

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--faint);
  font-size: 12px;
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}

.fine-print {
  margin-top: 8px;
  color: var(--faint);
  font-size: 12px;
}

/* ---------- Subscribe page (the sign-in layout, with the plan in the card) ---------- */

.plan {
  display: grid;
  gap: 16px;
  padding: 20px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

.plan-price {
  display: flex;
  align-items: baseline;
  gap: 2px;
  color: var(--muted);
  font-size: 15px;
}

.plan-price b {
  color: var(--text);
  font-size: 36px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
}

/* Under the price during a free trial: what it costs after, and when. */
.plan-then {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13.5px;
}

.plan-includes {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--text-2);
  font-size: 14px;
}

.plan-includes li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.plan-includes .icon {
  flex: none;
  margin-top: 2px;
  color: var(--ok);
}

.plan-cta {
  width: 100%;
  height: 44px;
  font-size: 15px;
}

.plan-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--line-strong);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.signed-in-as {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

.signed-in-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.signed-in-name b {
  color: var(--text);
  font-weight: 600;
}

/* Settings: the subscription's state and when it renews or ends. */
.plan-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  color: var(--text-2);
  font-size: 13px;
}

/* Across the top of the page panel while a renewal payment is failing. */
.billing-alert {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px 10px 20px;
  border-bottom: 1px solid var(--line);
  /* Follow the panel's top corners: rounded on desktop, square on phones. */
  border-start-start-radius: inherit;
  border-start-end-radius: inherit;
  background: var(--warn-wash);
  color: var(--warn-text);
  font-size: 13.5px;
}

.billing-alert .btn {
  flex: none;
}

/* The same strip during someone's free stream: news, not a problem. */
.billing-alert.is-free {
  background: var(--accent-wash);
  color: var(--text-2);
}

.billing-alert.is-free > span {
  flex: 1;
}

.billing-alert.is-free > .icon {
  flex: none;
  color: var(--accent-text);
}

.billing-alert.is-free b {
  color: var(--text);
}

/* The subscribe page after the free stream: its results above the plan, so a little wider. */
.signin-card.is-results {
  width: min(420px, 100%);
}

.stream-results {
  display: grid;
  justify-items: start;
  gap: 12px;
}

.stream-results > .metrics,
.stream-results > .gifters {
  width: 100%;
}

.stream-results > .gifters {
  margin-top: 4px;
}

/* Illustrative phone showing a LIVE with Rcast at work. */
.phone {
  position: relative;
  flex: none;
  width: 268px;
  height: 548px;
  padding: 8px;
  border-radius: 40px;
  background: #000;
  box-shadow:
    0 0 0 1px light-dark(rgb(22 24 35 / 0.2), rgb(255 255 255 / 0.12)),
    inset 0 0 0 1px rgb(255 255 255 / 0.06),
    0 40px 80px -24px light-dark(rgb(22 24 35 / 0.45), rgb(0 0 0 / 0.9));
}

/* The screen's light spilling onto the page behind it. */
.phone::before {
  content: '';
  position: absolute;
  inset: 8% -30%;
  z-index: -1;
  background:
    radial-gradient(closest-side at 35% 35%, rgb(254 44 85 / 0.3), transparent),
    radial-gradient(closest-side at 68% 70%, rgb(37 244 238 / 0.22), transparent);
  filter: blur(24px);
}

.phone-screen {
  color-scheme: dark;
  position: relative;
  color: var(--text);
  height: 100%;
  overflow: hidden;
  border-radius: 33px;
  background:
    radial-gradient(circle at 30% 28%, rgb(254 44 85 / 0.32), transparent 50%),
    radial-gradient(circle at 72% 62%, rgb(37 244 238 / 0.2), transparent 50%),
    linear-gradient(180deg, #2a2226, #111416);
}

.phone-top {
  position: absolute;
  top: 18px;
  left: 14px;
  right: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.phone-top .avatar.is-live {
  box-shadow:
    0 0 0 2px #000,
    0 0 0 4px var(--accent);
}

.phone-host {
  display: grid;
  line-height: 1.2;
}

.phone-host b {
  font-size: 13px;
}

.phone-host span {
  color: var(--text-2);
  font-size: 11px;
}

.phone-top .pill-live {
  margin-left: auto;
}

.phone-side {
  position: absolute;
  right: 10px;
  bottom: 170px;
  display: grid;
  gap: 16px;
  font-size: 11px;
  font-weight: 700;
}

.phone-side span {
  display: grid;
  justify-items: center;
  gap: 2px;
}

.demo-chat {
  position: absolute;
  left: 12px;
  right: 56px;
  bottom: 18px;
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.demo-msg {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12.5px;
  opacity: 0;
  animation: demo 10s infinite;
}

.demo-msg:nth-child(2) {
  animation-delay: 1.3s;
}
.demo-msg:nth-child(3) {
  animation-delay: 2.6s;
}
.demo-msg:nth-child(4) {
  animation-delay: 3.9s;
}
.demo-msg:nth-child(5) {
  animation-delay: 5.2s;
}

.demo-msg b {
  display: block;
  color: var(--text-2);
  font-size: 11.5px;
}

.demo-msg.is-system {
  align-items: center;
  padding: 6px 9px;
  border-radius: 10px;
  background: rgb(0 0 0 / 0.55);
  color: var(--ok);
}

.demo-msg.is-system code {
  color: #fff;
}

.demo-msg.is-gift > div {
  padding: 3px 10px 3px 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgb(254 44 85 / 0.6), rgb(254 44 85 / 0));
}

@keyframes demo {
  0% {
    opacity: 0;
    transform: translateY(10px);
  }
  5%,
  85% {
    opacity: 1;
    transform: none;
  }
  95%,
  100% {
    opacity: 0;
  }
}

/* ---------- Homepage, below the sign-in ---------- */

.landing {
  background: var(--canvas);
}

.landing > .signin {
  border-bottom: 1px solid var(--line);
}

/* minmax(0, 1fr): a long name that can't wrap, like a streamer's, is cut short rather than widening the page. */
.landing-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 96px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 88px 48px 96px;
}

.landing-section {
  scroll-margin-top: 24px;
}

.landing-head {
  display: grid;
  gap: 10px;
  margin-bottom: 28px;
}

/* The pitch's voice, a size down. */
.landing-head h2,
.landing-cta h2 {
  font-family: 'Saira', var(--font);
  font-size: clamp(26px, 2.8vw, 38px);
  font-style: italic;
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.01em;
  text-transform: uppercase;
}

.landing-head p {
  max-width: 62ch;
  color: var(--text-2);
  font-size: 16px;
}

/* Live now: a pulsing dot in the heading, then a card per streamer that opens their LIVE. */
.live-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  margin: 0 14px 0 2px;
  border-radius: 50%;
  background: var(--brand);
  vertical-align: 0.12em;
  box-shadow: 0 0 0 3px rgb(254 44 85 / 0.25);
  animation: live-pulse 2s var(--ease-out) infinite;
}

.live-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.live-card {
  display: flex;
  align-items: center;
  gap: 14px;
  height: 100%;
  padding: 16px;
  color: inherit;
  text-decoration: none;
  transition: border-color 0.15s;
}

.live-card:hover {
  border-color: var(--line-hover);
}

.live-card-main {
  display: grid;
  flex: 1;
  min-width: 0;
}

.live-card-name {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-size: 15px;
}

.live-card-name b {
  overflow: hidden;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.live-card-name .pill {
  flex: none;
}

.live-card-handle,
.live-card-server span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.live-card-handle {
  color: var(--muted);
  font-size: 13px;
}

.live-card-server {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  color: var(--text-2);
  font-size: 13px;
}

.live-card-watch {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: none;
  color: var(--accent-text);
  font-size: 13px;
  font-weight: 650;
}

/* What viewers can do: the rule templates, then the way into the Marketplace in the same grid. */
.example-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
  gap: 16px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.example {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Templates past the first few, until Show all. */
.example[hidden] {
  display: none;
}

.examples-all {
  display: flex;
  width: fit-content;
  margin: 20px auto 0;
}

.example-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.example h3 {
  font-size: 15px;
  font-weight: 650;
}

.example-when {
  color: var(--muted);
  font-size: 13px;
}

.example-about {
  color: var(--text-2);
}

/* The commands sit at the bottom, so the cards in a row line up. */
.example .rule-then {
  margin-top: auto;
}

.example-more {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  height: 100%;
  padding: 20px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-lg);
  color: inherit;
  text-decoration: none;
  transition:
    border-color 0.15s,
    background 0.15s;
}

.example-more:hover {
  border-color: var(--line-hover);
  background: var(--hover);
}

.example-more b {
  margin-top: 4px;
  font-size: 15px;
  font-weight: 650;
}

.example-more .link-btn {
  margin-top: auto;
  padding-top: 4px;
  color: var(--accent-text);
}

/* How it works: the setup guide's three steps, side by side, then going live. */
.how-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.how-step {
  display: grid;
  align-content: start;
  gap: 10px;
}

.how-step-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.how-step .step-dot {
  background: var(--accent-soft);
  color: var(--accent-text);
}

.how-step h3 {
  font-size: 16px;
  font-weight: 650;
}

.how-step p {
  color: var(--text-2);
}

.how-step .hint {
  color: var(--muted);
}

.how-then {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 24px;
  color: var(--text-2);
  font-size: 15px;
}

.how-then .icon {
  color: var(--brand);
}

.how-then b {
  color: var(--text);
}

/* Questions: one to a row, the answer opening under it. */
.faq {
  max-width: 820px;
  border-top: 1px solid var(--line);
}

.faq-item {
  border-bottom: 1px solid var(--line);
}

.faq-item summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 4px;
  font-size: 16px;
  font-weight: 600;
  list-style: none;
  cursor: pointer;
}

.faq-item summary::-webkit-details-marker {
  display: none;
}

.faq-item summary .icon {
  color: var(--muted);
  transition: transform 0.2s var(--ease-out);
}

.faq-item summary:hover .icon {
  color: var(--text);
}

/* The plus turns into a cross while the answer is open. */
.faq-item[open] summary .icon {
  transform: rotate(45deg);
}

.faq-item p {
  max-width: 70ch;
  padding: 0 4px 20px;
  color: var(--text-2);
  font-size: 15px;
}

/* The end of the page: the way in again, on the pitch's dot grid. */
.landing-cta {
  position: relative;
  isolation: isolate;
  display: grid;
  justify-items: center;
  gap: 14px;
  padding: 64px 24px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  text-align: center;
}

.landing-cta::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background-image: radial-gradient(var(--dots) 1px, transparent 1.5px);
  background-size: 24px 24px;
  mask-image: radial-gradient(ellipse 60% 70% at 50% 50%, #000 10%, transparent 75%);
}

.landing-cta p {
  max-width: 46ch;
  color: var(--text-2);
  font-size: 16px;
}

.landing-cta .login-option,
.landing-cta-btn {
  width: min(300px, 100%);
  height: 44px;
  margin-top: 6px;
  font-size: 15px;
}

/* ---------- The Marketplace for visitors, under a bar with the logo ---------- */

.public {
  min-height: 100vh;
  background: var(--canvas);
}

.public-top {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 60px;
  padding: 0 24px;
  background: var(--sidebar);
  border-bottom: 1px solid var(--line);
}

/* ---------- Settings (opens from the profile) ---------- */

/* A popover in the top layer, placed by settings.ts next to whichever profile button opened it. */
.settings {
  position: fixed;
  inset: auto;
  width: min(304px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  margin: 0;
  padding: 0;
  overflow-y: auto;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: var(--surface-pop);
  color: var(--text);
  box-shadow: var(--shadow-pop);
  transform-origin: bottom left;
  opacity: 0;
  transform: translateY(6px) scale(0.98);
  transition:
    opacity 0.16s var(--ease-out),
    transform 0.22s var(--ease-out-expo),
    overlay 0.22s allow-discrete,
    display 0.22s allow-discrete;
}

.settings[data-side='below'] {
  transform-origin: top right;
  transform: translateY(-6px) scale(0.98);
}

.settings:popover-open {
  opacity: 1;
  transform: none;
}

@starting-style {
  .settings:popover-open {
    opacity: 0;
    transform: translateY(6px) scale(0.98);
  }

  .settings[data-side='below']:popover-open {
    transform: translateY(-6px) scale(0.98);
  }
}

.settings-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 16px 14px;
}

.settings-head > div {
  flex: 1;
  display: grid;
  min-width: 0;
}

.settings-name {
  font-size: 15px;
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settings-sub {
  color: var(--muted);
  font-size: 12.5px;
}

.settings-section {
  margin: 0;
  padding: 14px 16px 16px;
  border: 0;
  border-top: 1px solid var(--line);
}

.settings-label {
  margin-bottom: 10px;
  padding: 0;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
}

.theme-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.theme-option {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.15s;
}

/* The radio stays focusable and announced; the preview is what you see and click. */
.theme-option input {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.theme-option:hover,
.theme-option:has(input:checked) {
  color: var(--text);
}

/* A miniature of the dashboard, drawn with the real tokens: color-scheme makes each one resolve
   light or dark, so the previews always match what the theme will actually look like. */
.theme-preview {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: 9px;
  box-shadow: 0 0 0 1px var(--line-strong);
  transition: box-shadow 0.15s;
}

.theme-option:hover .theme-preview {
  box-shadow: 0 0 0 1px var(--line-hover);
}

.theme-option:has(input:checked) .theme-preview {
  box-shadow:
    0 0 0 2px var(--surface-pop),
    0 0 0 4px var(--brand);
}

.theme-option:has(input:focus-visible) .theme-preview {
  outline: 2px solid var(--accent-text);
  outline-offset: 5px;
}

.mini-app {
  position: absolute;
  inset: 0;
  display: flex;
  gap: 4px;
  padding: 5px 5px 5px 0;
  background: var(--sidebar);
}

.mini-app.is-light {
  color-scheme: light;
}

.mini-app.is-dark {
  color-scheme: dark;
}

/* System: light on one side of the diagonal, dark on the other. */
.theme-preview.is-split .mini-app.is-dark {
  clip-path: polygon(100% 0, 100% 100%, 0 100%);
}

.mini-app i {
  display: block;
  height: 3px;
  border-radius: 2px;
  background: var(--line-strong);
}

.mini-side {
  display: grid;
  align-content: start;
  gap: 4px;
  width: 26%;
  padding: 6px 0 0 5px;
}

.mini-side i:first-child {
  background: var(--brand);
}

.mini-main {
  flex: 1;
  display: grid;
  align-content: start;
  gap: 4px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--canvas);
}

.mini-main i:first-child {
  width: 55%;
  height: 4px;
  background: var(--text);
}

.mini-main i:nth-child(2) {
  width: 80%;
}

.mini-main i:last-child {
  width: 34%;
  height: 7px;
  margin-top: 3px;
  border-radius: 2px;
  background: var(--accent);
}

.settings-actions {
  padding: 6px;
  border-top: 1px solid var(--line);
}

.settings-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 38px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-2);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition:
    background 0.15s,
    color 0.15s;
}

.settings-item .icon {
  color: var(--muted);
  transition: color 0.15s;
}

.settings-item:hover {
  background: var(--hover);
  color: var(--text);
}

.settings-item:hover .icon {
  color: var(--text);
}

/* ---------- Toasts ---------- */

.toasts {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: var(--z-toast);
  display: grid;
  justify-items: center;
  gap: 8px;
  transform: translateX(-50%);
  pointer-events: none;
}

.toast {
  color-scheme: dark;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px 9px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: var(--shadow-pop);
  animation: toast-in 0.35s var(--ease-out-expo);
}

/* Set by toast() just before removing it, so it slides away instead of vanishing. */
.toast.is-leaving {
  animation: toast-out 0.2s var(--ease-out) forwards;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.96);
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
}

.toast .icon {
  color: var(--ok);
}

.toast.is-error .icon {
  color: var(--warn);
}

/* ---------- Narrower screens ---------- */

@media (max-width: 1080px) {
  .grid-split,
  .grid-home,
  .live-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .editor,
  .live-side {
    position: static;
  }

  .live-side {
    order: -1;
  }

  .stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
  }

  .stat,
  .stat:first-child,
  .stat:last-child {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 0;
    border-top: 0;
  }

  .signin {
    grid-template-columns: minmax(0, 1fr) minmax(360px, 0.8fr);
  }

  .signin-pitch-body {
    justify-content: flex-start;
  }

  /* With no phone to frame, the dot grid would only sit behind the heading. */
  .phone,
  .signin-pitch::before {
    display: none;
  }

  /* No room beside the logo for links down the page; it's a short scroll anyway. */
  .pitch-link.is-jump {
    display: none;
  }
}

/* ---------- Phones ---------- */

@media (max-width: 820px) {
  /* Top bar, then the page. The page row takes any spare height, so a short page doesn't
     stretch the top bar's row and leave a gap under it. */
  .app {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto 1fr;
  }

  .sidebar {
    display: none;
  }

  .mobile-top {
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
    display: flex;
    align-items: center;
    gap: 8px;
    height: 56px;
    padding: 0 12px 0 16px;
    background: var(--sidebar);
    border-bottom: 1px solid var(--line);
  }

  .mobile-top .brand {
    margin-right: auto;
  }

  .tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: var(--z-sticky);
    display: grid;
    /* One equal column per link, however many there are. */
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--sidebar);
    border-top: 1px solid var(--line);
  }

  .tabbar a,
  .tab-more {
    position: relative;
    display: grid;
    justify-items: center;
    gap: 2px;
    padding: 8px 0 7px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
    text-decoration: none;
  }

  .tab-more {
    border: 0;
    background: transparent;
    font-family: inherit;
    cursor: pointer;
  }

  .tabbar a[aria-current='page'],
  .tab-more.is-current {
    color: var(--text);
  }

  .tabbar a[aria-current='page'] .icon,
  .tab-more.is-current .icon {
    color: var(--accent-text);
  }

  .tabbar .nav-live {
    position: absolute;
    top: 7px;
    left: calc(50% + 9px);
    margin: 0;
  }

  /* The pages that don't fit in the tab bar, in a sheet just above More (bottom right). */
  .more-sheet {
    position: fixed;
    inset: auto 12px calc(64px + env(safe-area-inset-bottom)) auto;
    width: min(260px, calc(100vw - 24px));
    margin: 0;
    padding: 6px;
    border: 1px solid var(--line-strong);
    border-radius: 14px;
    background: var(--surface-pop);
    color: var(--text);
    box-shadow: var(--shadow-pop);
    transform-origin: bottom right;
    opacity: 0;
    transform: translateY(6px) scale(0.98);
    transition:
      opacity 0.16s var(--ease-out),
      transform 0.22s var(--ease-out-expo),
      overlay 0.22s allow-discrete,
      display 0.22s allow-discrete;
  }

  .more-sheet:popover-open {
    opacity: 1;
    transform: none;
  }

  @starting-style {
    .more-sheet:popover-open {
      opacity: 0;
      transform: translateY(6px) scale(0.98);
    }
  }

  .more-sheet a {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 44px;
    padding: 0 12px;
    border-radius: var(--radius);
    color: var(--text-2);
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
  }

  .more-sheet a .icon {
    color: var(--muted);
  }

  .more-sheet a:hover,
  .more-sheet a[aria-current='page'] {
    background: var(--hover);
    color: var(--text);
  }

  .more-sheet a[aria-current='page'] .icon {
    color: var(--accent-text);
  }

  /* No inset panel on phones: the page runs edge to edge under the top bar. */
  body {
    background: var(--canvas);
  }

  .content {
    min-height: 0;
    margin: 0;
    border: 0;
    border-radius: 0;
  }

  .page {
    padding: 20px 16px 96px;
  }

  .page-head {
    flex-wrap: wrap;
    margin-bottom: 20px;
  }

  .page-head h1 {
    font-size: 21px;
  }

  .card {
    padding: 16px;
  }

  .pipeline {
    padding: 0;
  }

  .pipeline-track {
    padding: 18px 16px;
  }

  .pipeline-caption {
    padding: 12px 16px;
  }

  /* Filters that run off the edge fade out there, so it's clear the row scrolls. */
  .tabs {
    padding-right: 40px;
    mask-image: linear-gradient(90deg, #000 calc(100% - 40px), transparent);
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  /* Three, two and two: a 6-column grid with the first three spanning 2 and the rest 3. */
  .type-tiles {
    grid-template-columns: repeat(6, 1fr);
  }

  .type-tiles > .type-tile {
    grid-column: span 2;
  }

  .type-tiles > .type-tile:nth-child(n + 4) {
    grid-column: span 3;
  }

  .add-bar {
    flex-direction: column;
  }

  .welcome-flow {
    gap: 4px;
    padding: 18px 12px;
  }

  .welcome-flow .node-circle {
    width: 36px;
    height: 36px;
  }

  .flow-node b {
    font-size: 12px;
  }

  .flow-node code {
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .flow-arrow {
    margin-top: 8px;
  }

  .welcome .dialog-body {
    padding: 18px 18px 20px;
  }

  .guide,
  .guide-pill {
    right: 12px;
    bottom: calc(66px + env(safe-area-inset-bottom));
  }

  .guide,
  .guide.is-left {
    left: 12px;
    right: 12px;
    width: auto;
    max-height: 62vh;
  }

  /* Room to scroll the end of a form clear of the dock. */
  body:has(.guide:not([hidden])) .page {
    padding-bottom: 340px;
  }

  /* On the step's own page, keep the dock short so the form stays visible. */
  .guide.is-here .guide-step:not(.is-current),
  .guide.is-here .guide-body > p:not(.guide-here) {
    display: none;
  }

  .toasts {
    top: 68px;
    bottom: auto;
    width: calc(100% - 32px);
  }

  /* Stacked, the two halves sit together at the top instead of splitting the screen's height. */
  .signin {
    grid-template-columns: minmax(0, 1fr);
    align-content: start;
  }

  .signin-pitch {
    padding: 24px 20px 8px;
  }

  .signin-pitch-body {
    padding-top: 32px;
  }

  .pitch-points {
    display: none;
  }

  .signin-side {
    align-items: start;
    padding: 28px 20px 40px;
    background: var(--canvas);
    border-left: 0;
  }

  /* On the homepage the sections follow straight on, rather than after a screen's height. */
  .landing > .signin {
    min-height: 0;
  }

  .landing-body {
    gap: 64px;
    padding: 48px 20px 64px;
  }

  .how-steps {
    grid-template-columns: minmax(0, 1fr);
  }

  .landing-cta {
    padding: 48px 20px;
  }

  .public-top {
    padding: 0 16px;
  }

  /* No tab bar to clear. */
  .public .page {
    padding-bottom: 48px;
  }
}

/* ---------- One-off moments ---------- */

/* A row that was just saved glows so you can see where it went. */
.list-row.is-saved {
  animation: saved-glow 1.8s var(--ease-out);
}

@keyframes saved-glow {
  0%,
  20% {
    background: var(--ok-wash);
    box-shadow: inset 0 0 0 1px var(--ok-line);
  }
}

/* Analytics on arrival: tiles cascade in, gifters slide in by rank. */
.is-entering .metric,
.is-entering .gifters-list li {
  animation: rise-in 0.5s var(--ease-out-expo) backwards;
}

.is-entering .metric:nth-child(2) {
  animation-delay: 40ms;
}

.is-entering .metric:nth-child(3) {
  animation-delay: 80ms;
}

.is-entering .metric:nth-child(4) {
  animation-delay: 120ms;
}

.is-entering .metric:nth-child(5) {
  animation-delay: 160ms;
}

.is-entering .metric:nth-child(6) {
  animation-delay: 200ms;
}

.is-entering .metric:nth-child(7) {
  animation-delay: 240ms;
}

.is-entering .metric:nth-child(n + 8) {
  animation-delay: 280ms;
}

.is-entering .gifters-list li:nth-child(1) {
  animation-delay: 200ms;
}

.is-entering .gifters-list li:nth-child(2) {
  animation-delay: 260ms;
}

.is-entering .gifters-list li:nth-child(3) {
  animation-delay: 320ms;
}

.is-entering .gifters-list li:nth-child(n + 4) {
  animation-delay: 380ms;
}

/* Finishing setup. */
.fx-confetti {
  position: fixed;
  inset: 0;
  z-index: var(--z-toast);
  overflow: hidden;
  pointer-events: none;
}

.fx-confetti span {
  position: absolute;
  top: -20px;
  border-radius: 2px;
  animation: confetti-fall linear forwards;
}

@keyframes confetti-fall {
  to {
    transform: translate(var(--dx), 105vh) rotate(var(--spin));
  }
}

/* The theme change wipes in as a circle (theme.ts animates it) instead of crossfading. */
::view-transition-old(root),
::view-transition-new(root) {
  animation: none;
  mix-blend-mode: normal;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .demo-msg {
    opacity: 1;
  }

  .tour-target {
    animation: none;
  }
}

/* ---------- Spaces (Enterprise), shown as Streamers ---------- */

/* The live card sits above the tabs on an owner's server page. */
.space-live-top {
  margin-bottom: 20px;
}

/* "Got another server?" under a server's connection: the text, with its button beside it (below on phones). */
.another-server {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 16px;
}

/* Your streamers: a tick per server, for which of them each streams on. */
.server-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.server-toggle {
  height: 32px;
  padding: 0 12px 0 9px;
  cursor: pointer;
}

.server-toggle input {
  margin: 0;
  accent-color: var(--accent);
}

.server-toggle.is-on {
  border-color: var(--line-strong);
  background: var(--surface);
  color: var(--text);
}

.server-toggle:has(input:disabled) {
  cursor: not-allowed;
  opacity: 0.6;
}

.space-tabs {
  margin: -4px 0 16px;
  padding: 0;
  border-bottom: 0;
}

.space-rule {
  height: 1px;
  margin: 18px 0;
  border: 0;
  background: var(--line);
}

.space-link {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 12px;
}

.space-link .input {
  flex: 1;
  min-width: 0;
}

.space-live .stats {
  margin-bottom: 8px;
}

.space-players {
  margin-top: 14px;
}

.space-players .chips,
.list-main > .chips {
  margin-top: 8px;
}

.seat-meter {
  display: grid;
  gap: 8px;
}

.seat-meter-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.seat-meter-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.seat-meter-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
  grid-auto-flow: column;
  gap: 4px;
}

.seat-meter-bar > span {
  height: 8px;
  border-radius: 999px;
  background: var(--surface-3);
}

.seat-meter-bar > .is-used {
  background: var(--ok);
}

.seat-meter.is-full .seat-meter-bar > .is-used {
  background: var(--warn);
}

.masked {
  display: grid;
  gap: 4px;
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--well);
}

.perm-picker {
  display: grid;
  gap: 14px;
  margin: 14px 0;
}

.perm-presets,
.perm-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  border: 0;
}

.perm-option {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
}

.perm-option:hover {
  background: var(--hover);
}

.perm-option input {
  margin-top: 3px;
  accent-color: var(--accent);
}

.perm-option > span {
  display: grid;
  gap: 2px;
}

.perm-option strong {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 14px;
}

.space-dialog {
  width: min(520px, calc(100vw - 32px));
}

.space-invite-banner {
  border-color: var(--accent-line);
  background: var(--accent-wash);
}

.space-create {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.invite-standalone {
  max-width: 560px;
  margin: 48px auto;
  padding: 0 16px;
}

.invite-who {
  display: flex;
  gap: 12px;
  align-items: center;
}

.invite-who .card-title {
  margin: 2px 0 0;
  font-size: 22px;
}

.audit-list .list-title {
  font-weight: 500;
}
