:root {
  color-scheme: dark;
  --bg: #060607;
  --panel: rgba(20, 20, 23, 0.86);
  --panel-strong: #0d0d0f;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.18);
  --text: #fafafa;
  --muted: #9a9aa2;
  --dim: #66666e;
  --accent: #ffffff;
  --amber: #d8d8dc;
  --danger: #f06868;
  --twitch: #e4e4e7;
  --x: #fafafa;
  --kick: #e4e4e7;
  --radius: 14px;
  --shadow: rgba(0, 0, 0, 0.55);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  background:
    radial-gradient(120% 80% at 50% -10%, rgba(255, 255, 255, 0.05), transparent 60%),
    var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body.is-overlay {
  width: 1920px;
  height: 1080px;
  min-height: 1080px;
  overflow: hidden;
  background: transparent;
}

button,
input {
  font: inherit;
}

button,
.button-link {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  padding: 0 16px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.01em;
  text-decoration: none;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, transform 120ms ease;
}

button:hover,
.button-link:hover {
  border-color: rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.09);
}

button:active,
.button-link:active {
  transform: translateY(1px);
}

button:focus-visible,
.button-link:focus-visible,
input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.button-link.primary,
button.primary {
  background: var(--text);
  color: #0a0a0a;
  border-color: var(--text);
  font-weight: 800;
}

.button-link.primary:hover,
button.primary:hover {
  background: #ffffff;
  border-color: #ffffff;
}

button.active,
button[aria-pressed="true"] {
  border-color: rgba(255, 255, 255, 0.55);
  background: rgba(255, 255, 255, 0.14);
  color: var(--text);
}

button.danger {
  border-color: rgba(240, 104, 104, 0.4);
  color: var(--danger);
}

button.danger:hover {
  border-color: rgba(240, 104, 104, 0.7);
  background: rgba(240, 104, 104, 0.12);
}

input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.4);
  color: var(--text);
  padding: 0 13px;
  transition: border-color 120ms ease;
}

input::placeholder {
  color: var(--dim);
}

input:hover {
  border-color: var(--line-strong);
}

input[readonly] {
  color: var(--muted);
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

.dashboard {
  width: min(1440px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0 32px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  color: var(--dim);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

h1 {
  margin-top: 6px;
  font-size: 32px;
  line-height: 1;
  letter-spacing: -0.02em;
  font-weight: 800;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 14px 0;
}

.source-card {
  min-height: 58px;
  display: grid;
  grid-template-columns: 10px 1fr auto;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 11px 14px;
}

.source-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--dim);
  transition: background 200ms ease, box-shadow 200ms ease;
}

.source-card strong {
  font-size: 14px;
  font-weight: 700;
}

.source-card em {
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.source-card[data-state="live"] .source-dot {
  background: #ffffff;
  box-shadow: 0 0 16px rgba(255, 255, 255, 0.55);
}

.source-card[data-state="warn"] .source-dot {
  background: var(--muted);
  box-shadow: 0 0 14px rgba(154, 154, 162, 0.5);
}

.source-card[data-state="error"] .source-dot {
  background: var(--danger);
  box-shadow: 0 0 14px rgba(240, 104, 104, 0.6);
}

.workspace {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 260px;
  gap: 14px;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 24px 60px var(--shadow);
  backdrop-filter: blur(8px);
}

.controls,
.ops {
  display: grid;
  align-content: start;
}

.panel-section {
  display: grid;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.panel-section:last-child {
  border-bottom: 0;
}

.panel-section h2,
.feed-toolbar h2 {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.split-buttons {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.split-buttons.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

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

.feed-panel {
  min-height: 720px;
  display: grid;
  grid-template-rows: auto auto 1fr;
}

.feed-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.feed-toolbar p,
.note {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.note.hint {
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-left: 2px solid var(--line-strong);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  line-height: 1.45;
}

.steps {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.5;
}

.steps li::marker {
  color: var(--text);
  font-weight: 800;
}

.steps code {
  padding: 1px 5px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.4);
  color: var(--text);
  font-size: 11px;
}

.segmented {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.segmented button {
  min-height: 40px;
  padding-inline: 12px;
}

.state-block {
  margin: 14px;
  padding: 18px;
  display: grid;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
  color: var(--muted);
}

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

.state-block.error {
  border-color: rgba(255, 110, 123, 0.5);
  background: rgba(255, 110, 123, 0.08);
}

.skeleton {
  height: 16px;
  width: 56%;
  display: block;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.17), rgba(255, 255, 255, 0.08));
  background-size: 220% 100%;
}

.skeleton.wide {
  width: 86%;
}

.feed-list {
  min-height: 0;
  height: 100%;
  margin: 0;
  padding: 14px;
  display: grid;
  align-content: start;
  gap: 10px;
  overflow: auto;
  list-style: none;
}

.message {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
  padding: 12px 14px;
  transition: background 120ms ease, border-color 120ms ease;
}

.message:hover {
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.04);
}

/* Monochrome pill badges with a small per-platform color dot — premium
   black & white, readable at any label length (X, KICK, TWITCH). */
.source-label {
  min-width: 0;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 11px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
}

.source-label::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
}

.message.twitch .source-label::before,
.overlay-message.twitch .source-label::before {
  background: #a970ff;
  box-shadow: 0 0 8px rgba(169, 112, 255, 0.7);
}

.message.x .source-label::before,
.overlay-message.x .source-label::before {
  background: #fafafa;
  box-shadow: 0 0 8px rgba(250, 250, 250, 0.7);
}

.message.kick .source-label::before,
.overlay-message.kick .source-label::before {
  background: #53fc18;
  box-shadow: 0 0 8px rgba(83, 252, 24, 0.7);
}

.message-main {
  min-width: 0;
}

.message-meta {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.message-author {
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.message-channel {
  color: var(--dim);
  font-size: 12px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.xlive-row {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 7px;
}

.xlive-cmd {
  flex: 1;
  min-width: 0;
  padding: 6px 8px;
  border: 1px solid rgba(245, 240, 223, 0.14);
  border-radius: 7px;
  background: rgba(0, 0, 0, 0.35);
  font-size: 10px;
  line-height: 1.4;
  overflow-wrap: anywhere;
  color: var(--dim);
}

.xlive-row button {
  flex-shrink: 0;
}

details.advanced summary {
  cursor: pointer;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--dim);
  margin-bottom: 4px;
}

details.advanced[open] summary {
  margin-bottom: 10px;
}

.host-list {
  display: grid;
  gap: 7px;
  margin-bottom: 4px;
}

.host-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  padding: 7px 8px;
  border: 1px solid rgba(245, 240, 223, 0.14);
  border-radius: 8px;
  background: rgba(245, 240, 223, 0.04);
}

.host-dot {
  --identity-color: var(--accent);
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--identity-color);
  flex-shrink: 0;
}

.host-name {
  font-size: 13px;
  margin-right: auto;
}

.host-chips {
  display: inline-flex;
  gap: 5px;
}

.connect-chip {
  display: inline-grid;
  place-items: center;
  min-height: 20px;
  padding: 0 7px;
  border: 1px solid rgba(245, 240, 223, 0.25);
  border-radius: 6px;
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
  text-transform: uppercase;
  text-decoration: none;
  color: #f5f0df;
  cursor: pointer;
}

.connect-chip:hover {
  border-color: rgba(245, 240, 223, 0.6);
}

.connect-chip {
  background: none;
  font-family: inherit;
}

.connect-chip.toggle.on {
  border-color: rgba(110, 231, 183, 0.55);
  color: #6ee7b7;
}

.connect-chip.toggle.off {
  border-color: rgba(245, 240, 223, 0.18);
  color: rgba(245, 240, 223, 0.4);
  text-decoration: line-through;
}

.connect-chip.add {
  border-style: dashed;
  color: rgba(245, 240, 223, 0.55);
}

.host-add-row input[type="color"] {
  padding: 2px;
  min-width: 44px;
  height: 34px;
  cursor: pointer;
}

.identity-tag,
.overlay-identity-tag {
  --identity-color: var(--accent);
  display: inline-grid;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--identity-color), white 18%);
  background: color-mix(in srgb, var(--identity-color), transparent 74%);
  color: color-mix(in srgb, var(--identity-color), white 34%);
  font-size: 11px;
  font-weight: 950;
  line-height: 1;
  text-transform: uppercase;
}

.identity-tag {
  min-height: 20px;
  padding: 0 7px;
}

.overlay-identity-tag {
  min-height: 18px;
  margin-left: 8px;
  padding: 0 6px;
  vertical-align: 1px;
  font-size: 10px;
}

.message-text {
  margin-top: 5px;
  color: #e8e8ea;
  font-size: 15px;
  line-height: 1.36;
  overflow-wrap: anywhere;
}

.message-time {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.stat-row {
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.stat-row:last-child {
  border-bottom: 0;
}

.stat-row strong {
  color: var(--text);
  font-size: 20px;
}

.overlay {
  display: none;
}

body.is-overlay .dashboard {
  display: none;
}

body.is-overlay .overlay {
  position: relative;
  width: 1920px;
  height: 1080px;
  display: block;
  overflow: hidden;
  background: transparent;
}

.overlay-card {
  position: absolute;
  left: 56px;
  right: 56px;
  bottom: 56px;
  height: 128px;
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background:
    linear-gradient(90deg, rgba(10, 10, 12, 0.95), rgba(255, 255, 255, 0.05)),
    rgba(10, 10, 12, 0.88);
  box-shadow: 0 18px 54px rgba(0, 0, 0, 0.5), inset 0 3px 0 rgba(255, 255, 255, 0.5);
}

.overlay-heading {
  display: grid;
  gap: 4px;
  text-transform: uppercase;
}

.overlay-heading strong {
  color: var(--accent);
  font-size: 28px;
  font-weight: 950;
}

.overlay-heading span {
  color: var(--amber);
  font-size: 14px;
  font-weight: 900;
}

.overlay-feed {
  min-width: 0;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  list-style: none;
}

.overlay-message {
  min-width: 0;
  height: 90px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(0, 0, 0, 0.34);
  padding: 10px 12px;
}

.overlay-message .source-label {
  height: 28px;
  font-size: 12px;
  align-self: start;
}

.overlay-message strong,
.overlay-message p {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.overlay-message strong {
  display: block;
  margin-bottom: 4px;
  color: var(--accent);
  font-size: 14px;
  font-weight: 950;
}

.overlay-message p {
  color: var(--text);
  font-size: 24px;
  line-height: 1.12;
  font-weight: 900;
}

body[data-overlay-layout="rail"] .overlay-card {
  top: 72px;
  bottom: 72px;
  left: auto;
  right: 52px;
  width: 392px;
  height: auto;
  grid-template-columns: 1fr;
  align-content: start;
  align-items: stretch;
  gap: 14px;
  padding: 16px;
  background:
    linear-gradient(180deg, rgba(8, 10, 15, 0.96), rgba(8, 10, 15, 0.84)),
    rgba(8, 10, 15, 0.9);
  box-shadow: 0 18px 54px rgba(0, 0, 0, 0.52), inset 4px 0 0 rgba(255, 255, 255, 0.6);
}

body[data-overlay-layout="rail"][data-overlay-position="left"] .overlay-card {
  left: 52px;
  right: auto;
  box-shadow: 0 18px 54px rgba(0, 0, 0, 0.52), inset -4px 0 0 rgba(255, 255, 255, 0.6);
}

body[data-overlay-layout="rail"] .overlay-heading {
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(230, 238, 255, 0.2);
}

body[data-overlay-layout="rail"] .overlay-heading strong {
  font-size: 26px;
}

body[data-overlay-layout="rail"] .overlay-feed {
  grid-template-columns: 1fr;
  align-content: start;
  gap: 10px;
}

body[data-overlay-layout="rail"] .overlay-message {
  height: auto;
  min-height: 104px;
  grid-template-columns: 68px minmax(0, 1fr);
  align-items: start;
  padding: 11px;
}

body[data-overlay-layout="rail"] .overlay-message .source-label {
  height: 26px;
  font-size: 12px;
}

body[data-overlay-layout="rail"] .overlay-message strong {
  font-size: 14px;
  white-space: nowrap;
}

body[data-overlay-layout="rail"] .overlay-message p {
  margin-top: 4px;
  display: -webkit-box;
  color: var(--text);
  font-size: 19px;
  line-height: 1.2;
  overflow: hidden;
  white-space: normal;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

body[data-overlay-layout="compact"] .overlay-card {
  left: auto;
  right: 56px;
  bottom: 56px;
  width: 520px;
  height: auto;
  grid-template-columns: 1fr;
  align-content: start;
  align-items: stretch;
  gap: 10px;
  padding: 14px;
}

body[data-overlay-layout="compact"][data-overlay-position="bottom-left"] .overlay-card,
body[data-overlay-layout="compact"][data-overlay-position="left"] .overlay-card {
  left: 56px;
  right: auto;
}

body[data-overlay-layout="compact"] .overlay-heading {
  grid-template-columns: 1fr auto;
  align-items: baseline;
}

body[data-overlay-layout="compact"] .overlay-heading strong {
  font-size: 22px;
}

body[data-overlay-layout="compact"] .overlay-heading span {
  font-size: 12px;
}

body[data-overlay-layout="compact"] .overlay-feed {
  grid-template-columns: 1fr;
  gap: 8px;
}

body[data-overlay-layout="compact"] .overlay-message {
  height: 74px;
  grid-template-columns: 72px minmax(0, 1fr);
  padding: 9px;
}

body[data-overlay-layout="compact"] .overlay-message .source-label {
  height: 26px;
  font-size: 12px;
}

body[data-overlay-layout="compact"] .overlay-message p {
  font-size: 18px;
}

/* Box layout: a clean standalone chat panel that fills the browser source.
   Point an OBS browser source at /overlay?layout=box and size it to taste. */
body[data-overlay-layout="box"].is-overlay {
  width: 100%;
  height: 100vh;
  min-height: 0;
}

body[data-overlay-layout="box"].is-overlay .overlay {
  width: 100%;
  height: 100vh;
  overflow: hidden;
}

body[data-overlay-layout="box"] .overlay-card {
  inset: 0;
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 0;
  align-items: stretch;
  padding: 0;
  border: none;
  border-radius: 0;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(10, 12, 18, 0.97), rgba(10, 12, 18, 0.9));
  box-shadow: inset 0 0 0 2px rgba(230, 238, 255, 0.12);
}

body[data-overlay-layout="box"] .overlay-heading {
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.08), rgba(10, 12, 18, 0));
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

body[data-overlay-layout="box"] .overlay-heading strong {
  font-size: 22px;
}

body[data-overlay-layout="box"] .overlay-heading span {
  font-size: 12px;
}

body[data-overlay-layout="box"] .overlay-feed {
  grid-template-columns: 1fr;
  gap: 0;
  align-content: start;
  padding: 8px 0;
  overflow: hidden;
}

body[data-overlay-layout="box"] .overlay-message {
  height: auto;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 12px;
  padding: 12px 20px;
  border: none;
  background: none;
}

body[data-overlay-layout="box"] .overlay-message:nth-child(even) {
  background: rgba(255, 255, 255, 0.025);
}

body[data-overlay-layout="box"] .overlay-message .source-label {
  height: 26px;
  font-size: 12px;
  margin-top: 1px;
}

body[data-overlay-layout="box"] .overlay-message strong {
  font-size: 16px;
  white-space: nowrap;
  color: var(--text);
}

body[data-overlay-layout="box"] .overlay-message p {
  margin-top: 3px;
  font-size: 20px;
  line-height: 1.28;
  font-weight: 800;
  white-space: normal;
  overflow-wrap: anywhere;
}

body[data-overlay-layout="box"] .overlay-identity-tag {
  vertical-align: 2px;
}

@media (prefers-reduced-motion: no-preference) {
  .skeleton {
    animation: shimmer 1.4s ease-in-out infinite;
  }

  .message {
    animation: liftIn 170ms ease-out both;
  }
}

@keyframes shimmer {
  from { background-position: 120% 0; }
  to { background-position: -120% 0; }
}

@keyframes liftIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1120px) {
  .workspace {
    grid-template-columns: 280px minmax(0, 1fr);
  }

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

@media (max-width: 760px) {
  .dashboard {
    width: min(100vw - 24px, 640px);
    padding-top: 16px;
  }

  .topbar,
  .feed-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions,
  .status-strip,
  .workspace,
  .ops {
    grid-template-columns: 1fr;
  }

  .top-actions {
    display: grid;
  }

  h1 {
    font-size: 28px;
  }

  .message {
    grid-template-columns: 1fr;
  }

  .source-label {
    width: max-content;
  }
}
