:root {
  --rb-bg: #0b0d10;
  --rb-panel: #13171d;
  --rb-panel-2: #171c23;
  --rb-line: rgba(221, 228, 238, 0.11);
  --rb-line-strong: rgba(221, 228, 238, 0.2);
  --rb-text: #edf2f7;
  --rb-text-soft: #aab4c0;
  --rb-text-muted: #737f8d;
  --rb-accent: #32d0ba;
  --rb-accent-2: #7dd3fc;
  --rb-warning: #f5b841;
  --rb-danger: #f87171;
  --rb-ok: #7dd3a8;
  --rb-shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
  --rb-radius: 8px;
  --font-main: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--rb-bg);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--rb-text);
  font-family: var(--font-main);
  font-size: 14px;
  line-height: 1.5;
  background:
    linear-gradient(180deg, rgba(50, 208, 186, 0.05), transparent 320px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(180deg, rgba(255, 255, 255, 0.026) 1px, transparent 1px),
    var(--rb-bg);
  background-size: auto, 40px 40px, 40px 40px, auto;
}

button,
textarea,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 256px minmax(0, 1fr);
}

.topbar {
  display: none;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 24px 18px;
  background: rgba(12, 15, 19, 0.96);
  border-right: 1px solid var(--rb-line);
  z-index: 20;
}

.sidebar-brand,
.brand-compact {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  text-decoration: none;
}

.brand-mark {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  display: grid;
  place-items: center;
  border-radius: var(--rb-radius);
  color: #06100e;
  background: var(--rb-accent);
  font-weight: 800;
  letter-spacing: 0;
}

.brand-copy {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.brand-copy strong,
.brand-compact span:last-child {
  font-size: 0.96rem;
  font-weight: 750;
}

.brand-copy small {
  color: var(--rb-text-muted);
  font-size: 0.75rem;
}

.nav-section {
  display: grid;
  gap: 8px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 44px;
  padding: 0 12px;
  border-radius: var(--rb-radius);
  color: var(--rb-text-soft);
  text-decoration: none;
  transition: background 160ms ease, color 160ms ease, border-color 160ms ease;
}

.nav-link:hover,
.nav-link:focus-visible,
.nav-link.active {
  color: var(--rb-text);
  background: rgba(255, 255, 255, 0.055);
  outline: none;
}

.nav-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--rb-text-muted);
  flex: 0 0 8px;
}

.nav-link.active .nav-dot {
  background: var(--rb-accent);
  box-shadow: 0 0 0 4px rgba(50, 208, 186, 0.12);
}

.sidebar-status {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--rb-line);
  border-radius: var(--rb-radius);
  background: rgba(255, 255, 255, 0.025);
}

.status-kicker {
  display: block;
  color: var(--rb-text-muted);
  font-family: var(--font-mono);
  font-size: 0.66rem;
  text-transform: uppercase;
}

.sidebar-status strong {
  display: block;
  margin-top: 2px;
  font-size: 0.86rem;
}

.status-pill,
.live-badge,
.panel-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 26px;
  padding: 0 9px;
  border: 1px solid var(--rb-line);
  border-radius: 999px;
  color: var(--rb-text-soft);
  background: rgba(255, 255, 255, 0.035);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  white-space: nowrap;
}

.status-pill span,
.live-badge span {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--rb-ok);
}

.workspace {
  width: min(100%, 1480px);
  margin: 0 auto;
  padding: 38px clamp(24px, 4vw, 56px) 56px;
}

.workspace-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: end;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--rb-accent);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 9px;
  font-size: clamp(2rem, 4vw, 3.6rem);
  line-height: 1.02;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 1.12rem;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 3px;
  font-size: 0.9rem;
  letter-spacing: 0;
}

.header-copy {
  max-width: 760px;
  margin-bottom: 0;
  color: var(--rb-text-soft);
  font-size: 1rem;
}

.time-panel {
  min-width: 214px;
  padding: 13px 14px;
  border: 1px solid var(--rb-line);
  border-radius: var(--rb-radius);
  background: rgba(255, 255, 255, 0.03);
}

.time-panel span {
  display: block;
  color: var(--rb-text-muted);
  font-family: var(--font-mono);
  font-size: 0.66rem;
  text-transform: uppercase;
}

.time-panel strong {
  display: block;
  margin-top: 4px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--rb-text);
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.status-card {
  min-height: 104px;
  padding: 15px;
  border: 1px solid var(--rb-line);
  border-radius: var(--rb-radius);
  background: rgba(255, 255, 255, 0.026);
}

.status-card span {
  display: block;
  min-height: 38px;
  color: var(--rb-text-soft);
  font-size: 0.82rem;
}

.status-card strong {
  display: block;
  margin-bottom: 10px;
  font-family: var(--font-mono);
  font-size: 0.9rem;
}

.progress-track {
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.progress-track span {
  display: block;
  height: 100%;
  min-height: 0;
  background: linear-gradient(90deg, var(--rb-accent), var(--rb-accent-2));
}

.workspace-section {
  display: none;
}

.workspace-section.active {
  display: block;
}

.panel {
  border: 1px solid var(--rb-line);
  border-radius: var(--rb-radius);
  background: rgba(19, 23, 29, 0.92);
  box-shadow: var(--rb-shadow);
}

.panel-heading,
.stream-header,
.composer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.panel-heading {
  margin-bottom: 22px;
}

.panel-heading.compact {
  margin-bottom: 16px;
}

.intake-panel,
.report-panel,
.pipeline-panel,
.stream-panel,
.side-stack .panel {
  padding: clamp(20px, 3vw, 32px);
}

.composer textarea {
  width: 100%;
  min-height: 220px;
  display: block;
  resize: vertical;
  padding: 18px;
  color: var(--rb-text);
  border: 1px solid var(--rb-line);
  border-radius: var(--rb-radius);
  outline: none;
  background: rgba(0, 0, 0, 0.2);
  line-height: 1.55;
  font-size: 1rem;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.composer textarea:focus {
  border-color: rgba(50, 208, 186, 0.68);
  box-shadow: 0 0 0 3px rgba(50, 208, 186, 0.12);
  background: rgba(0, 0, 0, 0.28);
}

.prompt-rail {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 0 2px;
}

.prompt-chip {
  flex: 1 1 220px;
  max-width: 320px;
  min-height: 42px;
  padding: 8px 12px;
  border: 1px solid var(--rb-line);
  border-radius: var(--rb-radius);
  color: var(--rb-text-soft);
  background: rgba(255, 255, 255, 0.032);
  font-size: 0.78rem;
  line-height: 1.3;
  overflow-wrap: anywhere;
  text-align: left;
  white-space: normal;
  transition: border-color 160ms ease, color 160ms ease, background 160ms ease;
}

.prompt-chip:hover,
.prompt-chip:focus-visible {
  color: var(--rb-text);
  border-color: var(--rb-line-strong);
  background: rgba(255, 255, 255, 0.06);
  outline: none;
}

.composer-footer {
  margin-top: 22px;
}

.run-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--rb-text-muted);
  font-family: var(--font-mono);
  font-size: 0.72rem;
}

.run-meta strong {
  color: var(--rb-text);
}

.primary-action {
  min-height: 44px;
  max-width: 100%;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: var(--rb-radius);
  color: #06100e;
  background: var(--rb-accent);
  font-weight: 800;
  white-space: nowrap;
  transition: transform 140ms ease, background 140ms ease, opacity 140ms ease;
}

.primary-action:hover,
.primary-action:focus-visible {
  transform: translateY(-1px);
  background: #5ee0cf;
  outline: none;
}

.primary-action:disabled {
  cursor: wait;
  opacity: 0.68;
  transform: none;
}

.analysis-grid,
.report-grid {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 20px;
}

.agent-list {
  display: grid;
  gap: 10px;
}

.agent-row {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 74px;
  padding: 12px;
  border: 1px solid var(--rb-line);
  border-radius: var(--rb-radius);
  background: rgba(255, 255, 255, 0.025);
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.agent-row.active {
  border-color: rgba(50, 208, 186, 0.55);
  background: rgba(50, 208, 186, 0.07);
  transform: translateX(3px);
}

.agent-indicator {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--rb-text-muted);
}

.agent-row.active .agent-indicator {
  background: var(--rb-accent);
}

.agent-row p {
  margin-bottom: 0;
  color: var(--rb-text-muted);
  font-size: 0.78rem;
}

.agent-state {
  align-self: start;
  padding: 4px 7px;
  border: 1px solid var(--rb-line);
  border-radius: 999px;
  color: var(--rb-text-soft);
  font-family: var(--font-mono);
  font-size: 0.62rem;
  white-space: nowrap;
}

.stream-panel {
  min-height: 650px;
  display: flex;
  flex-direction: column;
}

.stream-header {
  padding-bottom: 18px;
  border-bottom: 1px solid var(--rb-line);
}

.live-badge span {
  background: var(--rb-danger);
}

.debate-log {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 18px 0 0;
  scrollbar-width: thin;
  scrollbar-color: var(--rb-line-strong) transparent;
}

.empty-state {
  min-height: 420px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 9px;
  color: var(--rb-text-muted);
  text-align: center;
}

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

.empty-state p {
  max-width: 360px;
  margin-bottom: 0;
}

.empty-line {
  width: 36px;
  height: 2px;
  background: var(--rb-accent);
}

.debate-entry {
  margin-bottom: 14px;
  padding: 14px;
  border: 1px solid var(--rb-line);
  border-left: 3px solid var(--rb-accent);
  border-radius: var(--rb-radius);
  background: rgba(255, 255, 255, 0.03);
}

.entry-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 7px;
}

.entry-agent,
.entry-stance {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  text-transform: uppercase;
}

.entry-agent {
  color: var(--rb-accent);
  font-weight: 700;
}

.entry-rule {
  height: 1px;
  flex: 1;
  background: var(--rb-line);
}

.entry-stance {
  color: var(--rb-text-muted);
}

.entry-detail {
  margin: 0;
  color: var(--rb-text);
}

.report-grid {
  grid-template-columns: minmax(0, 1fr) minmax(300px, 390px);
}

.report-lead {
  max-width: 760px;
  margin-bottom: 20px;
  padding-left: 16px;
  border-left: 3px solid var(--rb-accent);
  color: var(--rb-text);
  font-size: clamp(1.2rem, 2vw, 1.55rem);
  line-height: 1.42;
}

.report-copy {
  max-width: 820px;
  color: var(--rb-text-soft);
  font-size: 1rem;
}

.side-stack {
  display: grid;
  gap: 20px;
}

.flag-list {
  display: grid;
  gap: 9px;
}

.flag-row {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 12px;
  border: 1px solid var(--rb-line);
  border-radius: var(--rb-radius);
  background: rgba(255, 255, 255, 0.025);
}

.flag-row span {
  color: var(--rb-text-soft);
}

.flag-row strong {
  font-family: var(--font-mono);
  font-size: 0.66rem;
}

.flag-row strong[data-level="High"] {
  color: var(--rb-danger);
}

.flag-row strong[data-level="Elevated"] {
  color: var(--rb-warning);
}

.flag-row strong[data-level="Watch"] {
  color: var(--rb-accent);
}

.flag-row strong[data-level="Likely"] {
  color: var(--rb-warning);
}

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

.metric {
  min-height: 92px;
  display: grid;
  align-content: center;
  gap: 7px;
  padding: 12px;
  border: 1px solid var(--rb-line);
  border-radius: var(--rb-radius);
  background: rgba(255, 255, 255, 0.025);
}

.metric span {
  color: var(--rb-text-muted);
  font-family: var(--font-mono);
  font-size: 0.66rem;
  text-transform: uppercase;
}

.metric strong {
  font-size: 1.4rem;
}

.readiness-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.readiness-meter {
  width: 76px;
  height: 76px;
  flex: 0 0 76px;
  display: grid;
  place-items: center;
  border: 3px solid var(--rb-accent);
  border-radius: 999px;
}

.readiness-meter span {
  font-family: var(--font-mono);
  font-weight: 800;
}

.icon-button {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  gap: 0;
  border: 1px solid var(--rb-line);
  border-radius: var(--rb-radius);
  background: rgba(255, 255, 255, 0.04);
}

.icon-button span {
  width: 18px;
  height: 2px;
  display: block;
  margin: 3px 0;
  background: var(--rb-text);
}

.nav-backdrop {
  display: none;
}

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

  .analysis-grid,
  .report-grid {
    grid-template-columns: 1fr;
  }

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

  .stream-panel {
    min-height: 560px;
  }
}

@media (max-width: 860px) {
  .app-shell {
    display: block;
    min-height: 100vh;
  }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    border-bottom: 1px solid var(--rb-line);
    background: rgba(11, 13, 16, 0.96);
    backdrop-filter: blur(18px);
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(82vw, 310px);
    transform: translateX(-100%);
    transition: transform 180ms ease;
  }

  .app-shell.nav-open .sidebar {
    transform: translateX(0);
  }

  .nav-backdrop {
    position: fixed;
    inset: 0;
    z-index: 15;
    display: none;
    background: rgba(0, 0, 0, 0.54);
  }

  .app-shell.nav-open .nav-backdrop {
    display: block;
  }

  .workspace {
    padding: 24px 16px 42px;
  }

  .workspace-header {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .time-panel {
    width: 100%;
  }

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

  .composer-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .primary-action {
    width: 100%;
    white-space: normal;
  }

  .agent-list,
  .metric-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .workspace {
    padding-inline: 12px;
  }

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

  .panel-heading,
  .stream-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .intake-panel,
  .report-panel,
  .pipeline-panel,
  .stream-panel,
  .side-stack .panel {
    padding: 18px;
  }

  .composer textarea {
    min-height: 180px;
    padding: 14px;
  }

  .agent-row {
    grid-template-columns: 10px minmax(0, 1fr);
  }

  .agent-state {
    grid-column: 2;
    justify-self: start;
  }

  .readiness-panel {
    align-items: flex-start;
    flex-direction: column;
  }
}
