:root {
  --bg: #09090b;
  --surface: #18181b;
  --surface-2: #1f1f24;
  --surface-3: #2a2a31;
  --field: #0f0f12;
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #fafafa;
  --muted: #a1a1aa;
  --muted-2: #71717a;
  --accent: #9146ff;
  --accent-hover: #a46bff;
  --accent-press: #7c35e6;
  --accent-soft: rgba(145, 70, 255, 0.14);
  --accent-line: rgba(145, 70, 255, 0.5);
  --success: #34d399;
  --warning: #facc15;
  --danger: #f87171;
  --info: #60a5fa;
  --success-soft: rgba(52, 211, 153, 0.12);
  --warning-soft: rgba(250, 204, 21, 0.12);
  --danger-soft: rgba(248, 113, 113, 0.12);
  --red: var(--danger);
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --fast: 120ms;
  --base: 200ms;
  --shadow-pop: 0 18px 48px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.04);
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: "Cascadia Code", "SFMono-Regular", Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background:
    radial-gradient(900px 420px at 50% -160px, rgba(145, 70, 255, 0.13), transparent 70%),
    var(--bg);
  background-repeat: no-repeat;
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

h1,
h2,
h3,
p {
  margin: 0;
}

code {
  font-family: var(--mono);
  font-size: 0.9em;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 1px 5px;
}

small {
  color: var(--muted-2);
  font-weight: 400;
}

.hidden {
  display: none !important;
}

.sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.icon {
  width: 1.15em;
  height: 1.15em;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

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

.muted {
  color: var(--muted);
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-thumb {
  background: var(--surface-3);
  border-radius: 999px;
  border: 2px solid var(--surface);
}

/* ---------- Layout ---------- */

.topbar {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--space-5) var(--space-5) var(--space-3);
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: var(--space-4);
}

.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--space-3) var(--space-5) 64px;
  display: grid;
  gap: var(--space-4);
}

.view {
  display: grid;
  gap: var(--space-4);
}

.view[hidden] {
  display: none;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
  gap: var(--space-4);
  align-items: start;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4);
}

.column {
  display: grid;
  gap: var(--space-4);
  min-width: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.logo {
  width: 42px;
  height: 42px;
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 20px;
  color: #fff;
  background: linear-gradient(145deg, #a46bff, #6d28d9);
  box-shadow: 0 6px 20px rgba(145, 70, 255, 0.35);
}

.brand h1 {
  font-size: 20px;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.brand p {
  color: var(--muted);
  font-size: 13px;
}

.top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.user {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 3px 3px 3px 6px;
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
}

.user-name {
  font-size: 13px;
  font-weight: 600;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- View tabs and config tabs ---------- */

.viewtabs {
  justify-self: center;
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
}

.viewtab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition:
    background var(--fast) ease,
    color var(--fast) ease;
}

.viewtab:hover {
  color: var(--text);
}

.viewtab[aria-selected="true"] {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 4px 14px rgba(145, 70, 255, 0.35);
}

.tabs {
  display: flex;
  gap: 2px;
  padding: 3px;
  background: var(--field);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  margin-bottom: var(--space-4);
}

.tab {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 36px;
  padding: 6px 12px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition:
    background var(--fast) ease,
    color var(--fast) ease;
}

.tab:hover {
  color: var(--text);
}

.tab[aria-selected="true"] {
  background: var(--surface-3);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--border-strong);
}

.tab[aria-selected="true"] .icon {
  color: var(--accent-hover);
}

.tabpanel {
  animation: enter var(--base) var(--ease);
}

.tabpanel:focus-visible {
  outline-offset: 6px;
  border-radius: var(--radius-sm);
}

@keyframes enter {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

/* ---------- Cards ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  min-width: 0;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.card-head h2 {
  font-size: 18px;
  letter-spacing: -0.01em;
}

.eyebrow {
  color: var(--accent-hover);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 2px;
}

.subhead {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: var(--space-5) 0 var(--space-3);
}

.subhead h3 {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.count {
  min-width: 22px;
  padding: 0 7px;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  line-height: 20px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-hover);
}

.hint {
  margin-top: var(--space-3);
  color: var(--muted-2);
  font-size: 13px;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 38px;
  padding: 8px 14px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition:
    transform var(--fast) var(--ease),
    background var(--fast) ease,
    border-color var(--fast) ease,
    box-shadow var(--fast) ease,
    opacity var(--fast) ease;
}

.btn:hover:not(:disabled) {
  background: var(--surface-3);
  border-color: rgba(255, 255, 255, 0.28);
  transform: translateY(-1px);
}

.btn:active:not(:disabled) {
  transform: translateY(0) scale(0.98);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn.primary {
  background: linear-gradient(180deg, var(--accent-hover), var(--accent));
  border-color: var(--accent);
  color: #fff;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.18) inset,
    0 6px 18px rgba(145, 70, 255, 0.25);
}

.btn.primary:hover:not(:disabled) {
  background: linear-gradient(180deg, #b385ff, var(--accent-hover));
  border-color: var(--accent-hover);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.22) inset,
    0 8px 24px rgba(145, 70, 255, 0.4);
}

.btn.primary:active:not(:disabled) {
  background: var(--accent-press);
}

.btn.ghost {
  background: transparent;
  border-color: var(--border-subtle);
  color: var(--muted);
}

.btn.ghost:hover:not(:disabled) {
  color: var(--text);
  background: var(--surface-2);
}

.btn.danger {
  color: var(--danger);
  border-color: rgba(248, 113, 113, 0.35);
  background: var(--danger-soft);
}

.btn.danger:hover:not(:disabled) {
  background: rgba(248, 113, 113, 0.2);
  border-color: rgba(248, 113, 113, 0.6);
}

.btn.small {
  min-height: 30px;
  padding: 4px 10px;
  font-size: 13px;
}

.btn.tiny {
  min-height: 26px;
  padding: 0 8px;
  gap: 4px;
  font-size: 12px;
  border-radius: 7px;
}

.btn.big {
  min-height: 46px;
  padding: 10px 20px;
  font-size: 15px;
  border-radius: var(--radius);
}

.btn.icon-only {
  width: 38px;
  padding: 0;
}

.user .btn.icon-only {
  width: 30px;
  min-height: 30px;
  border-radius: 999px;
}

.btn[aria-pressed="true"] {
  background: var(--warning-soft);
  border-color: rgba(250, 204, 21, 0.5);
  color: var(--warning);
}

.btn[aria-busy="true"] {
  pointer-events: none;
  opacity: 0.85;
}

.btn[aria-busy="true"] .icon {
  display: none;
}

.btn[aria-busy="true"]::before,
.spinner {
  content: "";
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex: none;
}

.spinner {
  display: inline-block;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- Badges ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 10px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--muted);
  white-space: nowrap;
}

.badge .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.badge.ok {
  color: var(--success);
  background: var(--success-soft);
  border-color: rgba(52, 211, 153, 0.3);
}

.badge.warn {
  color: var(--warning);
  background: var(--warning-soft);
  border-color: rgba(250, 204, 21, 0.3);
}

.badge.bad {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: rgba(248, 113, 113, 0.3);
}

.badge.ok .dot {
  box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.18);
}

.badge.warn .dot {
  animation: pulse 1.6s ease-in-out infinite;
}

@keyframes pulse {
  50% {
    opacity: 0.35;
  }
}

/* ---------- Status ---------- */

.status-card {
  padding-bottom: var(--space-4);
}

.channel {
  font-size: 13px;
  text-align: right;
}

.status-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-3);
}

.status-grid li {
  display: grid;
  gap: var(--space-2);
  justify-items: start;
  padding: var(--space-3);
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
}

.status-name {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.status-foot {
  margin-top: var(--space-3);
  font-size: 13px;
}

/* ---------- Controls, now playing, queue ---------- */

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.now-body {
  margin-top: var(--space-4);
}

.current {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: var(--space-3);
  padding: var(--space-4);
  background: linear-gradient(135deg, var(--accent-soft), rgba(145, 70, 255, 0.04));
  border: 1px solid var(--accent-line);
  border-radius: var(--radius);
  animation: enter var(--base) var(--ease);
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 800;
  background: linear-gradient(145deg, #a46bff, #6d28d9);
  flex: none;
}

.avatar.small {
  width: 28px;
  height: 28px;
  font-size: 11px;
  border-radius: 999px;
}

.queue-item .avatar.small {
  border-radius: 7px;
}

.who {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.who .name {
  font-weight: 700;
}

.who .handle {
  color: var(--muted);
  font-size: 13px;
}

.narration {
  margin-top: var(--space-1);
  font-size: 17px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.source {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 1px 6px;
  border-radius: 999px;
  color: var(--accent-hover);
  background: var(--accent-soft);
}

.empty {
  display: grid;
  gap: 2px;
  padding: var(--space-4);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 14px;
}

.empty strong {
  color: var(--text);
}

.loading {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
  color: var(--muted);
}

.notice {
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-3);
  border-radius: var(--radius);
  border: 1px solid rgba(250, 204, 21, 0.3);
  background: var(--warning-soft);
  color: var(--warning);
  font-size: 14px;
}

.queue-list,
.history-list {
  display: grid;
  gap: var(--space-2);
}

.history-list {
  max-height: 360px;
  overflow-y: auto;
  padding-right: 2px;
}

.queue-item {
  display: grid;
  grid-template-columns: 20px auto minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
}

.queue-index,
.queue-time {
  color: var(--muted-2);
  font-size: 12px;
}

.queue-main {
  display: grid;
  min-width: 0;
}

.queue-user {
  font-size: 13px;
  font-weight: 600;
}

.queue-text,
.history-text {
  color: var(--muted);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px var(--space-3);
  padding: var(--space-2) var(--space-3);
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
}

.history-top {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.history-user {
  font-size: 13px;
  font-weight: 600;
}

.history-text {
  grid-column: 1 / -1;
}

.outcome {
  font-size: 11px;
  font-weight: 700;
  padding: 1px 8px;
  border-radius: 999px;
  align-self: center;
  color: var(--muted);
  background: var(--surface-3);
}

.outcome.played {
  color: var(--success);
  background: var(--success-soft);
}

.outcome.queued {
  color: var(--accent-hover);
  background: var(--accent-soft);
}

.outcome.skipped,
.outcome.canceled {
  color: var(--warning);
  background: var(--warning-soft);
}

.outcome.failed,
.outcome.rejected {
  color: var(--danger);
  background: var(--danger-soft);
}

/* ---------- Forms ---------- */

.stack {
  display: grid;
  gap: var(--space-4);
}

.two {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
}

.field {
  display: grid;
  gap: 6px;
  min-width: 0;
  border: 0;
  padding: 0;
  margin: 0;
  align-content: start;
}

.field > span,
.field > legend,
.field-label,
.slider-head label {
  display: flex;
  justify-content: space-between;
  gap: var(--space-2);
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  padding: 0;
}

input,
textarea {
  width: 100%;
  min-height: 40px;
  padding: 8px 12px;
  background: var(--field);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  transition:
    border-color var(--fast) ease,
    box-shadow var(--fast) ease;
}

textarea {
  resize: vertical;
  min-height: 64px;
}

input::placeholder,
textarea::placeholder {
  color: var(--muted-2);
}

input:hover,
textarea:hover {
  border-color: rgba(255, 255, 255, 0.28);
}

input:focus-visible,
textarea:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

input[aria-invalid="true"],
textarea[aria-invalid="true"] {
  border-color: var(--danger);
}

input:disabled,
textarea:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.sim-row {
  display: flex;
  align-items: flex-end;
  gap: var(--space-3);
  margin-top: var(--space-3);
}

.sim-row .field {
  flex: 1;
}

.actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.form-note {
  font-size: 13px;
}

.form-error {
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(248, 113, 113, 0.35);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 14px;
}

/* ---------- Custom select ---------- */

.select {
  position: relative;
}

.select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  width: 100%;
  min-height: 40px;
  padding: 8px 12px;
  background: var(--field);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  text-align: left;
  cursor: pointer;
  transition:
    border-color var(--fast) ease,
    box-shadow var(--fast) ease;
}

.select-trigger:hover:not(:disabled) {
  border-color: rgba(255, 255, 255, 0.28);
}

.select-trigger:focus-visible,
.select.is-open .select-trigger {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.select-trigger:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.select-value {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.select-value.is-placeholder {
  color: var(--muted-2);
}

.select .chevron {
  color: var(--muted);
  transition: transform var(--fast) var(--ease);
}

.select.is-open .chevron {
  transform: rotate(180deg);
}

.select-pop {
  position: absolute;
  z-index: 30;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  min-width: 220px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-pop);
  overflow: hidden;
  animation: pop-in var(--fast) var(--ease);
}

@keyframes pop-in {
  from {
    opacity: 0;
    transform: translateY(-4px) scale(0.99);
  }
}

.select-search {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0 var(--space-3);
  border-bottom: 1px solid var(--border-subtle);
  color: var(--muted);
}

.select-search input {
  min-height: 40px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.select-search input:focus-visible {
  box-shadow: none;
}

.select-list {
  max-height: 300px;
  overflow-y: auto;
  padding: 6px;
  outline: none;
}

.select-group {
  padding: 8px 10px 4px;
  color: var(--muted-2);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.select-option {
  position: relative;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 8px 32px 8px 10px;
  border-radius: 8px;
  cursor: pointer;
}

.select-option small {
  color: var(--muted-2);
}

.select-option.is-active {
  background: var(--surface-3);
}

.select-option[aria-selected="true"] {
  color: var(--accent-hover);
  font-weight: 600;
}

.select-option[aria-selected="true"]::after {
  content: "";
  position: absolute;
  right: 12px;
  top: 50%;
  width: 5px;
  height: 10px;
  margin-top: -7px;
  border: solid var(--accent-hover);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.select-empty {
  padding: var(--space-4);
  color: var(--muted);
  text-align: center;
  font-size: 14px;
}

.select.compact .select-trigger {
  min-height: 36px;
  min-width: 170px;
}

.select.compact .select-pop {
  right: auto;
  min-width: 100%;
}

/* ---------- Number stepper ---------- */

.num {
  display: flex;
  align-items: stretch;
  background: var(--field);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition:
    border-color var(--fast) ease,
    box-shadow var(--fast) ease;
}

.num:hover {
  border-color: rgba(255, 255, 255, 0.28);
}

.num:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.num input {
  min-height: 38px;
  padding: 0 4px;
  border: 0;
  border-radius: 0;
  background: transparent;
  text-align: center;
  font-weight: 600;
  box-shadow: none;
  appearance: textfield;
  -moz-appearance: textfield;
}

.num input::-webkit-outer-spin-button,
.num input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.num input:focus-visible {
  box-shadow: none;
}

.num-unit {
  align-self: center;
  padding-right: var(--space-2);
  color: var(--muted-2);
  font-size: 13px;
}

.num-btn {
  flex: none;
  width: 36px;
  border: 0;
  background: var(--surface-2);
  color: var(--muted);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition:
    background var(--fast) ease,
    color var(--fast) ease;
}

.num-btn:hover:not(:disabled) {
  background: var(--surface-3);
  color: var(--text);
}

.num-btn:active:not(:disabled) {
  background: var(--accent-soft);
  color: var(--accent-hover);
}

.num-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.num:has(input:disabled) {
  opacity: 0.5;
}

/* ---------- Switch ---------- */

.switch-row {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.switch {
  position: relative;
  width: 38px;
  height: 22px;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface-3);
  cursor: pointer;
  transition:
    background var(--fast) ease,
    border-color var(--fast) ease;
}

.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  transition: transform var(--fast) var(--ease);
}

.switch[aria-checked="true"] {
  background: var(--accent);
  border-color: var(--accent);
}

.switch[aria-checked="true"]::after {
  transform: translateX(16px);
}

/* ---------- Sliders ---------- */

.slider-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.slider-tools {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.slider-tools output {
  min-width: 56px;
  padding: 2px 8px;
  text-align: center;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-hover);
  background: var(--accent-soft);
  border-radius: 6px;
}

.slider {
  --fill: 50%;
  appearance: none;
  height: 24px;
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.slider::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(to right, var(--accent) var(--fill), var(--surface-3) var(--fill));
}

.slider::-moz-range-track {
  height: 6px;
  border-radius: 999px;
  background: var(--surface-3);
}

.slider::-moz-range-progress {
  height: 6px;
  border-radius: 999px;
  background: var(--accent);
}

.slider::-webkit-slider-thumb {
  appearance: none;
  width: 18px;
  height: 18px;
  margin-top: -6px;
  border-radius: 50%;
  border: 2px solid #fff;
  background: var(--accent);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  transition: transform var(--fast) var(--ease);
}

.slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid #fff;
  background: var(--accent);
}

.slider:hover::-webkit-slider-thumb,
.slider:active::-webkit-slider-thumb {
  transform: scale(1.15);
}

.slider:focus-visible {
  outline: none;
  box-shadow: none;
}

.slider:focus-visible::-webkit-slider-thumb {
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.slider-scale {
  display: flex;
  justify-content: space-between;
  color: var(--muted-2);
  font-size: 11px;
}

/* ---------- Reward form ---------- */

.sync-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  font-size: 13px;
}

.choice {
  gap: var(--space-2);
}

.choice-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3);
  background: var(--field);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition:
    border-color var(--fast) ease,
    background var(--fast) ease;
}

.choice-item:hover {
  border-color: rgba(255, 255, 255, 0.28);
}

.choice-item:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.choice-item:has(input:focus-visible) {
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.choice-item input {
  appearance: none;
  flex: none;
  width: 18px;
  min-height: 0;
  height: 18px;
  margin-top: 2px;
  padding: 0;
  border-radius: 50%;
  background: var(--field);
  border: 2px solid var(--border-strong);
  display: grid;
  place-items: center;
}

.choice-item input::after {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #fff;
  transform: scale(0);
  transition: transform var(--fast) var(--ease);
}

.choice-item input:checked {
  background: var(--accent);
  border-color: var(--accent);
}

.choice-item input:checked::after {
  transform: scale(1);
}

.choice-item span {
  display: grid;
  font-size: 14px;
  color: var(--text);
}

.choice-item small {
  font-size: 13px;
  color: var(--muted);
}

/* ---------- OBS ---------- */

.url-box {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-3);
  padding: var(--space-2) var(--space-2) var(--space-2) var(--space-3);
  background: var(--field);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
}

.url-box code {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: none;
  border: 0;
  padding: 0;
}

/* ---------- Setup alert ---------- */

.alert {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-lg);
  border: 1px solid rgba(248, 113, 113, 0.35);
  background: var(--danger-soft);
}

.alert h2 {
  font-size: 16px;
  color: var(--danger);
}

.alert p {
  margin-top: 2px;
  color: var(--text);
}

.alert-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.steps {
  margin: var(--space-3) 0 0;
  padding-left: 20px;
  color: var(--muted);
  font-size: 14px;
}

/* ---------- Statistics ---------- */

.toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--space-3);
}

.kpis {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: var(--space-3);
}

.kpi {
  position: relative;
  display: grid;
  gap: 2px;
  align-content: start;
  padding: var(--space-3) var(--space-4);
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  overflow: hidden;
  animation: enter var(--base) var(--ease);
}

.kpi-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.kpi-value {
  font-size: 28px;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.kpi-note {
  color: var(--muted-2);
  font-size: 12px;
}

.spark {
  position: absolute;
  right: var(--space-3);
  top: var(--space-3);
  width: 72px;
  height: 22px;
}

.spark-line {
  fill: none;
  stroke: var(--accent-hover);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.chart-box {
  min-height: 120px;
}

.chart {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.chart .grid {
  stroke: rgba(255, 255, 255, 0.07);
  stroke-width: 1;
  stroke-dasharray: 3 4;
}

.chart .axis {
  fill: var(--muted-2);
  font-size: 11px;
  font-family: var(--font);
}

.chart .axis.end {
  text-anchor: end;
}

.chart .axis.mid {
  text-anchor: middle;
}

.chart .hit {
  fill: transparent;
}

.chart .bar-group:hover .hit {
  fill: rgba(255, 255, 255, 0.045);
}

.chart .bar {
  transform-box: fill-box;
  transform-origin: bottom;
  animation: grow 0.55s var(--ease) both;
}

.chart .bar.played {
  fill: var(--accent);
}

.chart .bar.other {
  fill: #6b6b78;
}

.chart .bar.soft {
  fill: rgba(145, 70, 255, 0.42);
}

.chart .bar.none {
  fill: rgba(255, 255, 255, 0.07);
}

@keyframes grow {
  from {
    transform: scaleY(0);
  }
}

.chart-empty {
  display: grid;
  place-items: center;
  min-height: 120px;
  padding: var(--space-4);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.legend {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--space-2);
}

.legend.inline {
  display: flex;
  gap: var(--space-4);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 13px;
}

.legend-item .legend-name {
  flex: 1;
  color: var(--muted);
}

.legend-item small {
  min-width: 44px;
  text-align: right;
}

.swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex: none;
}

.o-played {
  background: var(--accent);
}

.o-other {
  background: #6b6b78;
}

.o-skipped {
  background: var(--warning);
}

.o-rejected {
  background: #fb7185;
}

.o-failed {
  background: var(--danger);
}

.o-canceled {
  background: #71717a;
}

.o-queued {
  background: var(--info);
}

.outcomes {
  display: grid;
  gap: var(--space-4);
}

.stack-track {
  display: flex;
  gap: 2px;
  height: 14px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface-2);
}

.segment {
  flex-basis: 0;
  min-width: 4px;
  animation: grow-x 0.6s var(--ease) both;
  transform-origin: left;
}

@keyframes grow-x {
  from {
    transform: scaleX(0);
  }
}

.ranking {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--space-3);
}

.rank-row {
  display: grid;
  grid-template-columns: 22px minmax(90px, 200px) minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-3);
  font-size: 14px;
}

.rank-pos {
  color: var(--muted-2);
  font-size: 12px;
  font-weight: 700;
}

.rank-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.rank-track {
  height: 8px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.rank-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-hover));
  animation: grow-x 0.6s var(--ease) both;
  transform-origin: left;
}

/* ---------- Toasts ---------- */

.toasts {
  position: fixed;
  right: var(--space-4);
  bottom: var(--space-4);
  z-index: 50;
  display: grid;
  gap: var(--space-2);
  width: min(380px, calc(100vw - 32px));
  pointer-events: none;
}

.toast {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-3) var(--space-3) var(--space-4);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow-pop);
  font-size: 14px;
  pointer-events: auto;
  animation: toast-in var(--base) var(--ease);
}

.toast.ok {
  border-left-color: var(--success);
}

.toast.bad {
  border-left-color: var(--danger);
}

.toast.leaving {
  animation: toast-out var(--base) ease forwards;
}

.toast-icon {
  font-weight: 800;
  line-height: 1.4;
}

.toast.ok .toast-icon {
  color: var(--success);
}

.toast.bad .toast-icon {
  color: var(--danger);
}

.toast-close {
  border: 0;
  background: transparent;
  color: var(--muted);
  width: 24px;
  height: 24px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
}

.toast-close:hover {
  background: var(--surface-3);
  color: var(--text);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateX(16px);
  }
}

/* ---------- Login ---------- */

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--space-5) var(--space-4);
}

.login-card {
  width: min(440px, 100%);
  display: grid;
  gap: var(--space-5);
  padding: var(--space-6);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.04),
    0 24px 64px rgba(0, 0, 0, 0.5);
}

.login-step {
  display: grid;
  gap: var(--space-4);
}

.login-lead {
  color: var(--muted);
}

.login-steps {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  font-size: 14px;
  display: grid;
  gap: 4px;
}

.code-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-3) var(--space-3) var(--space-4);
  background: var(--field);
  border: 1px solid var(--accent-line);
  border-radius: var(--radius);
}

.code {
  font-family: var(--mono);
  font-size: 30px;
  font-weight: 700;
  letter-spacing: 0.22em;
  color: var(--accent-hover);
}

.login-status {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--muted);
  font-size: 14px;
}

.login-error {
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(248, 113, 113, 0.35);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 14px;
}

/* ---------- Responsive ---------- */

@media (max-width: 1040px) {
  .kpis {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .topbar {
    grid-template-columns: 1fr auto;
  }

  .viewtabs {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-self: stretch;
  }

  .viewtab {
    flex: 1;
    justify-content: center;
  }
}

@media (max-width: 960px) {
  .layout,
  .grid-2 {
    grid-template-columns: minmax(0, 1fr);
  }

  .status-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .alert {
    flex-direction: column;
  }
}

@media (max-width: 620px) {
  .topbar {
    padding: var(--space-4) var(--space-4) var(--space-2);
    grid-template-columns: 1fr;
  }

  .viewtabs {
    grid-row: auto;
  }

  .page {
    padding: var(--space-2) var(--space-4) 40px;
  }

  .card {
    padding: var(--space-4);
  }

  .top-actions {
    justify-content: flex-start;
  }

  .controls .btn {
    flex: 1 1 100%;
  }

  .sim-row {
    flex-direction: column;
    align-items: stretch;
  }

  .two {
    grid-template-columns: minmax(0, 1fr);
  }

  .kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .toolbar {
    justify-content: flex-start;
  }

  .actions .btn {
    flex: 1;
  }

  .queue-item {
    grid-template-columns: 20px minmax(0, 1fr) auto;
  }

  .queue-item .avatar {
    display: none;
  }

  .rank-row {
    grid-template-columns: 22px minmax(0, 1fr) auto;
  }

  .rank-track {
    display: none;
  }

  .narration {
    font-size: 16px;
  }

  .code {
    font-size: 24px;
  }

  .toasts {
    right: var(--space-4);
    left: var(--space-4);
    width: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  /* A frozen spinner would read as a hang, so it keeps turning. */
  .spinner,
  .btn[aria-busy="true"]::before {
    animation-duration: 1.4s !important;
    animation-iteration-count: infinite !important;
  }
}
