:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, sans-serif;
  background: #080a0d;
  color: #f3f4f6;
  --panel: #11151a;
  --line: #283039;
  --muted: #8c98a5;
  --accent: #68f0b2;
  --brand: #68f0b2;
  --warning: #ffcc66;
  --danger: #ff8585;
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: radial-gradient(circle at 85% -10%, rgba(104, 240, 178, .12), transparent 34rem), #080a0d; }
button, input, select { font: inherit; }
button { border: 0; border-radius: .55rem; padding: .72rem 1rem; background: var(--accent); color: #06130d; font-weight: 800; cursor: pointer; }
button:disabled { opacity: .45; cursor: not-allowed; }
button.secondary { background: #222a32; color: #e5e7eb; }
button.danger { background: rgba(255, 107, 107, .15); color: var(--danger); }
.hidden { display: none !important; }
.app-header { min-height: 92px; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 14px 24px 10px; background: #171820; border-bottom: 1px solid #30313e; }
.app-header > small { color: var(--muted); align-self: flex-end; }
.brand { display: flex; flex-direction: column; gap: 3px; }
.brand-name { color: var(--brand); font-size: 32px; font-weight: 800; letter-spacing: -.04em; line-height: 1; }
.brand-product { color: var(--muted); font-size: 13px; font-weight: 600; letter-spacing: .06em; }
.brand-powered { color: var(--brand); font-size: 10px; font-weight: 600; letter-spacing: .03em; opacity: .84; }
.session-header { display: flex; align-items: center; gap: .7rem; min-width: 0; }
#session-email { max-width: 36vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.role { padding: .28rem .5rem; border: 1px solid var(--line); border-radius: 999px; color: var(--accent); font: 700 .7rem ui-monospace, monospace; text-transform: uppercase; }
.shell { width: min(1180px, calc(100% - 2rem)); margin: 0 auto; padding: 2rem 0 4rem; }
.masthead, .section-heading, .card-heading, .player-panel { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(2rem, 7vw, 4.8rem); letter-spacing: -.065em; }
h2 { margin-bottom: .35rem; }
.eyebrow { margin-bottom: .45rem; color: var(--accent); font-size: .7rem; font-weight: 850; letter-spacing: .15em; }
.section-heading { margin-top: 1.5rem; }
.section-heading > p { color: var(--muted); text-align: right; }
.state { border: 1px solid var(--line); border-radius: 999px; padding: .5rem .72rem; color: var(--muted); font: 750 .7rem ui-monospace, monospace; }
.state-healthy { border-color: rgba(104, 240, 178, .5); background: rgba(104, 240, 178, .08); color: var(--accent); }
.state-degraded, .state-attention { border-color: rgba(255, 204, 102, .6); color: var(--warning); }
.state-critical, .state-failed, .state-unavailable { border-color: rgba(255, 107, 107, .5); color: var(--danger); }
.panel { margin-top: 1rem; border: 1px solid var(--line); border-radius: 1rem; padding: 1.35rem; background: rgba(17, 21, 26, .94); }
.login-panel { display: grid; grid-template-columns: 1fr minmax(17rem, 26rem); gap: 3rem; margin-top: 5rem; }
form { display: grid; gap: 1rem; }
label { display: grid; gap: .42rem; color: var(--muted); font-size: .78rem; font-weight: 700; }
input, select { width: 100%; border: 1px solid var(--line); border-radius: .5rem; padding: .72rem .75rem; background: #0b0e12; color: #f3f4f6; }
input[type="checkbox"] { width: auto; accent-color: var(--accent); }
button:focus-visible, input:focus-visible, select:focus-visible, .chart-point:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.message { min-height: 1.25rem; margin: 0; color: var(--warning); }
.tabs { display: flex; gap: .35rem; margin-top: 1.5rem; overflow-x: auto; border: 1px solid var(--line); border-radius: .85rem; padding: .35rem; background: rgba(17, 21, 26, .92); }
.tab { flex: 0 0 auto; border: 1px solid transparent; background: transparent; color: var(--muted); }
.tab:hover { color: #f3f4f6; background: rgba(255, 255, 255, .04); }
.tab.active { border-color: rgba(104, 240, 178, .38); background: rgba(104, 240, 178, .1); color: var(--accent); }
.pipeline { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-top: 1.25rem; }
.flow-node { display: grid; gap: .5rem; min-height: 135px; padding: 1.2rem; border: 1px solid var(--line); border-radius: 1rem; background: var(--panel); }
.flow-node.state-healthy { border-color: rgba(104, 240, 178, .42); }
.flow-index { color: var(--muted); font: 700 .75rem ui-monospace, monospace; }
.flow-node strong { font-size: 1.2rem; }
.flow-node small { color: var(--muted); }
.metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-top: 1rem; }
.metric { min-width: 0; padding: 1rem; border: 1px solid var(--line); border-radius: .8rem; background: var(--panel); }
.metric span { display: block; color: var(--muted); font-size: .74rem; }
.metric strong { display: block; margin-top: .45rem; overflow: hidden; text-overflow: ellipsis; font-size: 1.1rem; }
.player-panel { align-items: stretch; flex-direction: column; }
.player-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.player-panel audio { width: min(30rem, 100%); }
.distribution-copy { display: grid; gap: .42rem; }
.copy-label, .distribution-copy label {
  color: var(--muted);
  font-size: .78rem;
  font-weight: 700;
}
.copy-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .6rem; }
.copy-row input {
  min-width: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.copy-message {
  min-height: 1.1rem;
  margin: 0;
  color: var(--accent);
  font-size: .75rem;
}
.compact-distribution-copy { margin-top: 1rem; }
.card-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
.channel-card dl, .immutable dl { display: grid; grid-template-columns: repeat(2, 1fr); gap: .7rem; }
dl div { min-width: 0; padding: .75rem; border: 1px solid var(--line); border-radius: .65rem; }
dt { color: var(--muted); font-size: .72rem; }
dd { margin: .3rem 0 0; overflow-wrap: anywhere; font-weight: 700; }
.channel-form { align-content: start; }
.channel-form label:has(input[type="checkbox"]), .confirmation { display: flex; align-items: center; gap: .55rem; }
.compact-form { grid-template-columns: 1fr minmax(12rem, 18rem) auto; align-items: end; }
.compact-form .confirmation { grid-column: 2 / -1; }
.monitoring-panel { display: grid; grid-template-columns: minmax(14rem, .7fr) 1.3fr; gap: 2rem; }
.monitoring-panel p { color: var(--muted); }
.monitoring-fields { display: grid; gap: .7rem; }
.monitoring-contract {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .7rem;
  margin: 0;
}
.monitoring-key-form { grid-template-columns: minmax(0, 1fr) auto; align-items: end; }
.transient-copy { position: fixed; top: -10000px; left: -10000px; }
.audience-controls {
  display: grid;
  grid-template-columns: 1.4fr repeat(3, minmax(8rem, .8fr)) auto auto;
  align-items: end;
  gap: .75rem;
}
.quick-ranges { display: flex; gap: .4rem; align-self: end; }
.quick-ranges button { flex: 1 1 auto; white-space: nowrap; }
.quick-ranges button[aria-pressed="true"] {
  border: 1px solid rgba(104, 240, 178, .45);
  background: rgba(104, 240, 178, .12);
  color: var(--accent);
}
.audience-summary { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.audience-chart-panel { position: relative; }
.audience-chart-panel .card-heading { align-items: flex-start; }
.chart-scroll { overflow-x: auto; }
.audience-chart { display: block; min-width: 700px; width: 100%; height: auto; }
.chart-grid { stroke: #283039; stroke-width: 1; }
.chart-axis-label, .chart-empty {
  fill: var(--muted);
  font: 12px ui-monospace, SFMono-Regular, Menlo, monospace;
  text-anchor: end;
}
.chart-empty { text-anchor: middle; }
.chart-line {
  fill: none;
  stroke: var(--accent);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.5;
}
.series-channel-2 { stroke: #8cb4ff; stroke-dasharray: 8 5; }
.series-total { stroke: #ffcc66; stroke-dasharray: 2 5; stroke-width: 3; }
.series-payload { stroke: var(--accent); }
.series-host { stroke: #d8a5ff; stroke-dasharray: 9 5; }
.chart-point { fill: #080a0d; stroke-width: 2; cursor: crosshair; }
.chart-point.series-channel-1, .chart-peak.series-channel-1,
.chart-point.series-payload, .chart-peak.series-payload { stroke: var(--accent); }
.chart-point.series-channel-2, .chart-peak.series-channel-2 { stroke: #8cb4ff; }
.chart-point.series-total, .chart-peak.series-total { stroke: #ffcc66; }
.chart-point.series-host, .chart-peak.series-host { stroke: #d8a5ff; }
.chart-peak { fill: #080a0d; stroke-width: 3; pointer-events: none; }
.chart-legend { display: flex; flex-wrap: wrap; gap: .4rem; }
.chart-legend button { padding: .45rem .65rem; font-size: .75rem; }
.chart-legend button[aria-pressed="false"] { opacity: .45; text-decoration: line-through; }
.chart-tooltip {
  position: sticky;
  bottom: 1rem;
  z-index: 2;
  width: fit-content;
  max-width: 100%;
  margin: 1rem auto 0;
  border: 1px solid var(--line);
  border-radius: .55rem;
  padding: .6rem .8rem;
  background: #080a0d;
  color: #f3f4f6;
  font-size: .78rem;
}
.audience-table caption {
  padding: 0 0 1rem;
  color: #f3f4f6;
  font-weight: 800;
  text-align: left;
}
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .75rem; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { color: var(--muted); font-size: .72rem; }
.event-list { display: grid; gap: .7rem; }
.event { display: grid; grid-template-columns: 1fr auto; gap: .25rem 1rem; padding: 1rem; border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: .7rem; background: var(--panel); }
.event-attention { border-left-color: var(--warning); }
.event-critical { border-left-color: var(--danger); }
.event p, .event small { grid-column: 1 / -1; margin: 0; color: var(--muted); }
.empty { color: var(--muted); }
.account-form { width: min(34rem, 100%); }
@media (max-width: 760px) {
  .app-header { align-items: flex-start; flex-wrap: wrap; }
  .session-header { order: 3; width: 100%; }
  #session-email { max-width: 55vw; }
  .masthead, .section-heading, .player-heading {
    align-items: flex-start;
    flex-direction: column;
  }
  .section-heading > p { text-align: left; }
  .login-panel, .pipeline, .metrics, .card-grid, .compact-form,
  .monitoring-panel, .monitoring-key-form, .audience-controls,
  .audience-summary { grid-template-columns: 1fr; }
  .compact-form .confirmation { grid-column: auto; }
  .channel-card dl, .immutable dl { grid-template-columns: 1fr; }
  .monitoring-contract { grid-template-columns: 1fr; }
  .copy-row { grid-template-columns: 1fr; }
  .quick-ranges { overflow-x: auto; }
}
