:root {
  --sim-text-scale: 1;
  --bg: #0f1419;
  --surface: #1a222c;
  --border: #2d3a47;
  --text: #e7ecf1;
  --muted: #a9b6c6;
  --accent: #3d8bfd;
  --accent-dim: #2563c7;
  --marcus: #f0c14b;
  --user: #5eead4;
  --shadow: rgba(0, 0, 0, 0.35);
  --overlay: rgba(0, 0, 0, 0.55);

  /* Chat bubble surfaces (dark theme) */
  --bubble-marcus-bg: #2a2418;
  --bubble-marcus-border: #5c4d24;
  --bubble-salesops-bg: #18222a;
  --bubble-salesops-border: #24455c;
  --bubble-user-bg: #142824;
  --bubble-user-border: #1e4d42;
  --bubble-instructor-bg: #16243a;
  --bubble-instructor-border: #27476d;
  --radius: 10px;
  font-family: "Segoe UI", system-ui, sans-serif;
}

[data-theme="light"] {
  --bg: #f3f6fb;
  --surface: #ffffff;
  --border: #cfd8e3;
  --text: #0b1220;
  --muted: #344256;
  --accent: #2563eb;
  --accent-dim: #1e4fd1;
  --marcus: #b56b00;
  --user: #0f766e;
  --shadow: rgba(16, 24, 40, 0.12);
  --overlay: rgba(2, 6, 23, 0.45);

  /* Chat bubble surfaces (light theme) */
  --bubble-marcus-bg: #fff6e8;
  --bubble-marcus-border: #f2c27b;
  --bubble-salesops-bg: #edf6ff;
  --bubble-salesops-border: #8cc4ff;
  --bubble-user-bg: #e6fffb;
  --bubble-user-border: #79e2d6;
  --bubble-instructor-bg: #eef2ff;
  --bubble-instructor-border: #9bb4ff;
}

* {
  box-sizing: border-box;
}

html {
  font-size: calc(100% * var(--sim-text-scale, 1));
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
}

body:has(.v-sim-bar):not(:has(.admin-wrap)) {
  min-height: 100dvh;
  height: 100dvh;
  overflow: hidden;
}

.slack-app {
  flex: 1;
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
  --slack-sidebar-width: 210px;
}

.slack-sidebar {
  width: var(--slack-sidebar-width, 210px);
  flex: 0 0 var(--slack-sidebar-width, 210px);
  min-width: 0;
  background: linear-gradient(180deg, rgba(78, 30, 85, 0.96), rgba(50, 20, 60, 0.96));
  color: #fff;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
}

.slack-sidebar-resizer {
  flex: 0 0 10px;
  width: 10px;
  margin: 0 -4px;
  position: relative;
  z-index: 15;
  cursor: col-resize;
  touch-action: none;
  background: transparent;
  flex-shrink: 0;
}

.slack-sidebar-resizer::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 1px;
  transform: translateX(-50%);
  background: var(--border);
  transition: width 0.12s ease, background 0.12s ease;
}

.slack-sidebar-resizer:hover::before,
.slack-sidebar-resizer:focus-visible::before,
.slack-sidebar-resizer.is-dragging::before {
  width: 3px;
  background: var(--accent);
}

.slack-sidebar-resizer:focus-visible {
  outline: none;
}

body.slack-sidebar-resize-active {
  cursor: col-resize;
  user-select: none;
}

body.slack-sidebar-resize-active * {
  cursor: col-resize !important;
}

[data-theme="light"] .slack-sidebar {
  background: linear-gradient(180deg, #4b174f, #3a1242);
}

.slack-workspace {
  padding: 0.85rem 0.9rem 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  text-align: left;
}

.slack-brand {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.45rem;
  justify-content: flex-start;
  width: 100%;
  padding: 0.1rem 0 0.35rem;
}

.slack-brand-mark {
  flex: 0 0 auto;
  width: 80px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

.slack-brand-img {
  width: 80px;
  height: 80px;
  max-width: 80px;
  max-height: 80px;
  object-fit: contain;
  display: block;
}

.slack-brand-text {
  min-width: 0;
  width: 100%;
}

.slack-brand-name {
  font-weight: 800;
  font-size: 0.93rem;
  letter-spacing: 0.01em;
  line-height: 1.12;
}

.slack-brand-sub {
  margin-top: 0.12rem;
  font-size: 0.78rem;
  opacity: 0.82;
  line-height: 1.35;
  white-space: normal;
  overflow: visible;
  word-break: break-word;
}

.slack-brand.slack-brand--product .slack-brand-product {
  margin: 0;
  font-size: 1.42rem;
  font-weight: 800;
  line-height: 1.12;
  letter-spacing: -0.03em;
}

.slack-brand.slack-brand--product .slack-brand-tagline {
  margin: 0.45rem 0 0;
  padding-top: 0.45rem;
  border-top: 1px solid rgba(255, 255, 255, 0.22);
  font-size: 0.98rem;
  font-weight: 600;
  line-height: 1.32;
  opacity: 1;
}

.slack-brand.slack-brand--product .slack-brand-name {
  font-size: 1.28rem;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.03em;
}

.slack-brand.slack-brand--product .slack-brand-sub {
  font-size: 0.92rem;
  font-weight: 500;
  line-height: 1.38;
  margin-top: 0.28rem;
  opacity: 0.92;
}

.slack-nav {
  padding: 0.6rem 0.6rem 0.75rem;
  overflow: auto;
  flex: 1;
}

.slack-nav-section + .slack-nav-section {
  margin-top: 0.75rem;
}

.slack-nav-title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.75;
  padding: 0.2rem 0.3rem;
}

.slack-nav-item {
  padding: 0.35rem 0.45rem;
  border-radius: 8px;
  opacity: 0.92;
}

.slack-nav-item.active {
  background: rgba(255, 255, 255, 0.14);
  opacity: 1;
}

.slack-nav-section--history {
  margin-top: 0.85rem;
}

.slack-history-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0 0.2rem 0.45rem;
}

.slack-history-clear-btn {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0.28rem 0.45rem;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
  color: inherit;
  font-size: 0.68rem;
  line-height: 1.2;
  cursor: pointer;
  opacity: 0.92;
}

.slack-history-clear-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  opacity: 1;
}

.slack-history-clear-btn--danger {
  border-color: rgba(254, 202, 202, 0.45);
  background: rgba(127, 29, 29, 0.35);
}

.slack-history-clear-btn--danger:hover {
  background: rgba(127, 29, 29, 0.5);
}

.slack-run-history {
  padding: 0.15rem 0.2rem 0.35rem;
}

.slack-history-scope {
  margin: 0 0 0.45rem;
  padding: 0 0.25rem;
  font-size: 0.68rem;
  line-height: 1.35;
  opacity: 0.78;
}

.slack-history-empty {
  margin: 0.15rem 0.25rem;
  font-size: 0.74rem;
  line-height: 1.35;
  opacity: 0.78;
}

.slack-history-empty--error {
  color: #fecaca;
  opacity: 1;
}

.slack-history-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.slack-history-item {
  padding: 0.45rem 0.5rem;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.slack-history-item-title {
  font-size: 0.8rem;
  font-weight: 650;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.slack-history-item-meta {
  margin-top: 0.18rem;
  font-size: 0.68rem;
  line-height: 1.3;
  opacity: 0.78;
}

.slack-history-item-actions {
  margin-top: 0.35rem;
}

.slack-history-pdf-btn {
  appearance: none;
  font: inherit;
  cursor: pointer;
  border-radius: 7px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.12);
  color: inherit;
  font-size: 0.68rem;
  font-weight: 650;
  padding: 0.28rem 0.55rem;
  line-height: 1.2;
}

.slack-history-pdf-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.slack-history-pending {
  font-size: 0.66rem;
  opacity: 0.65;
  font-style: italic;
}

.slack-sidebar-top {
  padding: 0.65rem 0.75rem 0.6rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  flex-shrink: 0;
}

.slack-sidebar-top-controls {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 0.45rem;
  flex-wrap: wrap;
  width: 100%;
}

.slack-sidebar .theme-toggle.theme-toggle--sidebar {
  width: 32px;
  height: 32px;
  min-width: 32px;
  min-height: 32px;
  border-color: rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.slack-sidebar .theme-toggle.theme-toggle--sidebar .theme-icon svg {
  width: 16px;
  height: 16px;
  display: block;
}

[data-theme="light"] .slack-sidebar .theme-toggle.theme-toggle--sidebar {
  border-color: rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.slack-sidebar .theme-toggle.theme-toggle--sidebar:hover {
  filter: brightness(1.12);
}

.app-version-badge {
  font-size: 0.72rem;
  font-weight: 650;
  color: var(--muted);
  letter-spacing: 0.04em;
  line-height: 1.25;
  user-select: none;
}

.slack-sidebar .app-version-badge--sidebar,
.slack-sidebar .app-version-badge.app-version-badge--sidebar {
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

[data-theme="light"] .slack-sidebar .app-version-badge--sidebar,
[data-theme="light"] .slack-sidebar .app-version-badge.app-version-badge--sidebar {
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

.slack-sidebar button.secondary {
  width: 100%;
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.slack-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.slack-topbar {
  display: flex;
  flex-wrap: nowrap;
  justify-content: flex-start;
  gap: 0.65rem 1rem;
  align-items: flex-start;
  padding: 0.85rem 1.25rem;
  padding-left: max(1.25rem, env(safe-area-inset-left, 0px));
  padding-right: max(1.35rem, env(safe-area-inset-right, 0px));
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 8;
  flex-shrink: 0;
  min-height: min-content;
}

/* Owns the first full row in .actions so long labels align with stacked controls below. */
.scenario-picker {
  position: relative;
  display: flex;
  align-items: stretch;
  min-width: 0;
  width: 100%;
  flex: 1 1 100%;
  flex-basis: 100%;
  max-width: 100%;
}

.scenario-select-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;
  clip-path: inset(50%);
}

.scenario-picker-trigger {
  /* Sole in-flow flex child of .scenario-picker (select/list are out of flow): must grow or it stays content-width (~half a 2-col grid on mobile). */
  display: flex;
  flex: 1 1 0%;
  min-width: 0;
  align-items: center;
  justify-content: flex-start;
  text-align: left;
  gap: 0;
  width: 100%;
  max-width: 100%;
  min-height: 2.5rem;
  padding: 0.45rem 0.65rem;
  line-height: 1.35;
  overflow: hidden;
  box-sizing: border-box;
}

.scenario-picker-trigger:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.scenario-picker-trigger-inner {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: normal;
  word-break: break-word;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  line-height: 1.3;
}

.scenario-picker-strong {
  font-weight: 750;
  letter-spacing: -0.02em;
}

.scenario-picker-trigger-tail,
.scenario-picker-option-tail {
  font-weight: 450;
  color: var(--text);
}

.scenario-picker-list {
  position: absolute;
  left: 0;
  top: calc(100% + 4px);
  z-index: 90;
  min-width: 100%;
  max-width: min(calc(100vw - 1rem), 52rem);
  max-height: min(70vh, 22rem);
  overflow-y: auto;
  margin: 0;
  padding: 0.35rem 0;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 12px 40px var(--shadow);
}

.scenario-picker-list.hidden {
  display: none;
}

.scenario-picker-option {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0.55rem 0.75rem;
  border: none;
  background: transparent;
  color: var(--text);
  text-align: left;
  font: inherit;
  line-height: 1.35;
  cursor: pointer;
  white-space: normal;
  word-break: break-word;
}

.scenario-picker-option:hover,
.scenario-picker-option:focus-visible {
  background: var(--bg);
  outline: none;
}

.scenario-picker-option[aria-selected="true"] {
  background: var(--border);
}

.scenario-picker-option--create {
  margin-top: 0.25rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--border);
  color: var(--accent, #2563eb);
  font-weight: 600;
}

.scenario-picker-option--create:hover,
.scenario-picker-option--create:focus-visible {
  background: color-mix(in srgb, var(--accent, #2563eb) 10%, var(--bg));
}

.scenario-picker-option--create .scenario-picker-strong {
  color: inherit;
}

.slack-topbar-lead {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
  flex: 0 0 auto;
}

.btn-mobile-nav {
  display: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  flex-shrink: 0;
}

.btn-mobile-nav-icon {
  display: block;
  width: 18px;
  height: 2px;
  background: currentColor;
  border-radius: 1px;
  box-shadow: 0 -6px 0 currentColor, 0 6px 0 currentColor;
}

.mobile-nav-backdrop {
  display: none;
}

.actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: stretch;
  flex: 1 1 100%;
  min-width: 0;
  width: 100%;
  flex-shrink: 0;
  box-sizing: border-box;
  padding-inline-end: 0.35rem;
  --topbar-control-h: 2.5rem;
  --topbar-control-font: 0.9375rem;
  --topbar-select-pad-x: 0.65rem;
  --topbar-select-pad-y: 0.45rem;
}

.actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: stretch;
  min-width: 0;
}

.actions-row select.secondary,
.actions-row .scenario-picker-trigger {
  min-height: var(--topbar-control-h);
  font-size: var(--topbar-control-font);
  line-height: 1.3;
  box-sizing: border-box;
}

.actions-row select.secondary {
  padding: var(--topbar-select-pad-y) calc(var(--topbar-select-pad-x) + 1.1rem) var(--topbar-select-pad-y)
    var(--topbar-select-pad-x);
}

.actions-row button {
  min-height: var(--topbar-control-h);
  font-size: var(--topbar-control-font);
  box-sizing: border-box;
}

.actions-row--setup .scenario-picker {
  flex: 1 1 14rem;
  min-width: min(100%, 14rem);
  width: auto;
  max-width: none;
  flex-basis: auto;
}

.actions-row--setup #agent-provider {
  flex: 0 0 10.5rem;
  width: 10.5rem;
  min-width: 10.5rem;
  max-width: 10.5rem;
}

.actions-row--setup #agent-model,
.actions-row--setup #agent-model-b {
  flex: 1 1 20rem;
  width: auto;
  min-width: min(100%, 20rem);
  max-width: 28rem;
}

.actions-row--setup #compare-two-wrap {
  flex: 0 0 auto;
  align-self: center;
  min-height: var(--topbar-control-h);
  font-size: var(--topbar-control-font);
}

.actions-row--run {
  flex-wrap: wrap;
}

.actions-row--run #agent-turns {
  flex: 0 0 auto;
  width: auto;
  min-width: 11.75rem;
  max-width: none;
}

.theme-toggle {
  appearance: none;
  width: 44px;
  height: 44px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  flex-shrink: 0;
  position: relative;
  z-index: 2;
  box-sizing: border-box;
}

.theme-toggle:hover {
  filter: brightness(1.08);
}

/* First-visit spotlight (see app.js / localStorage flight_sim_theme_spotlight_v1) */
@keyframes theme-toggle-spotlight {
  0% {
    box-shadow: 0 0 0 0 rgba(82, 154, 255, 0.65);
    transform: scale(1);
  }
  40% {
    box-shadow:
      0 0 0 4px rgba(82, 154, 255, 0.45),
      0 0 22px rgba(82, 154, 255, 0.35);
    transform: scale(1.07);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(82, 154, 255, 0);
    transform: scale(1);
  }
}

.theme-toggle-spotlight {
  animation: theme-toggle-spotlight 1s ease-in-out forwards;
  z-index: 6;
  outline: none;
}

.theme-toggle .theme-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
}

.theme-toggle .theme-icon svg {
  display: block;
  stroke: currentColor;
}

/* Extra contrast: moon/sun can wash out on pale topbars */
[data-theme="light"] .theme-toggle svg {
  filter: drop-shadow(0 0 0.35px rgba(0, 0, 0, 0.45));
}

/* Light mode: offer dark (moon). Dark mode: offer light (sun). */
[data-theme="light"] .theme-toggle .theme-icon-sun {
  display: none;
}

[data-theme="dark"] .theme-toggle .theme-icon-moon {
  display: none;
}

/* Before JS runs, default <body data-theme="light"> still shows one icon; if missing, assume light. */
body:not([data-theme]) .theme-toggle .theme-icon-sun {
  display: none;
}

button {
  font: inherit;
  cursor: pointer;
  border-radius: 8px;
  border: 1px solid var(--border);
  padding: 0.5rem 0.9rem;
  background: var(--surface);
  color: var(--text);
}

select.secondary {
  font: inherit;
  border-radius: 8px;
  border: 1px solid var(--border);
  padding: 0.5rem 0.65rem;
  background: var(--surface);
  color: var(--text);
}

/* Buttons in the topbar should read as actions (not inputs). */
.actions .action-btn {
  background: rgba(127, 127, 127, 0.12);
  border-color: rgba(127, 127, 127, 0.25);
}

[data-theme="light"] .actions .action-btn {
  background: rgba(2, 6, 23, 0.06);
  border-color: rgba(2, 6, 23, 0.18);
}

.always-hidden {
  display: none !important;
}

.actions #btn-help.action-btn {
  width: 44px;
  padding-left: 0;
  padding-right: 0;
  text-align: center;
  font-weight: 800;
}

button.primary {
  background: var(--accent);
  border-color: var(--accent-dim);
  color: #fff;
}

button.danger {
  background: #dc2626;
  border-color: #b91c1c;
  color: #fff;
}

button.secondary:hover,
button.primary:hover {
  filter: brightness(1.08);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.chat-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  margin: 0;
  padding: 0.85rem 1rem 1rem;
  padding-left: max(1rem, env(safe-area-inset-left, 0px));
  padding-right: max(1rem, env(safe-area-inset-right, 0px));
  padding-bottom: max(1rem, env(safe-area-inset-bottom, 0px));
  min-height: 0;
}

.messages-shell {
  flex: 1;
  min-height: 0;
  position: relative;
  display: flex;
  flex-direction: column;
  --sim-compare-label-w: 8.25rem;
  --sim-compare-gap: 0.65rem;
}

.sim-single-pane {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.sim-single-pane.hidden,
.sim-compare-pane.hidden,
.sim-compare-summary.hidden,
.sim-compare-scorecards.hidden {
  display: none !important;
}

.sim-compare-pane {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  column-gap: var(--sim-compare-gap);
  row-gap: var(--sim-compare-gap);
}

.sim-compare-pane--with-labels {
  grid-template-columns: var(--sim-compare-label-w) minmax(0, 1fr) minmax(0, 1fr);
}

.sim-compare-pane-spacer {
  grid-column: 1;
  min-width: 0;
  display: none;
}

.sim-compare-pane--with-labels .sim-compare-pane-spacer {
  display: block;
}

.sim-compare-col {
  min-height: 0;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  overflow: hidden;
}

.sim-compare-col-head {
  flex: 0 0 auto;
  padding: 0.45rem 0.6rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 88%, var(--border));
  word-break: break-word;
}

.sim-compare-messages {
  flex: 1;
  min-height: 0;
  max-height: none;
}

.sim-compare-summary {
  flex: 0 0 auto;
  margin-top: 0.5rem;
  width: 100%;
}

.sim-compare-summary-inner {
  width: 100%;
  box-sizing: border-box;
  padding: 0.65rem 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: color-mix(in srgb, var(--accent) 6%, var(--surface));
}

.sim-compare-summary-title {
  font-weight: 700;
  font-size: 0.88rem;
  margin-bottom: 0.55rem;
  padding: 0 0.75rem;
  color: var(--text);
}

.sim-compare-summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}

.sim-compare-summary-card {
  padding: 0.55rem 0.6rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.sim-compare-summary-model {
  font-weight: 650;
  font-size: 0.82rem;
  margin-bottom: 0.25rem;
  word-break: break-word;
}

.sim-compare-summary-score {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 0.45rem;
}

.sim-analysis-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.85rem;
  padding-top: 0.85rem;
  padding-bottom: 0.35rem;
  border-top: 1px solid var(--border);
}

.sim-analysis-footer-btn,
.sim-analysis-footer .secondary {
  min-height: 3rem;
  padding: 0.75rem 1.35rem;
  font-size: 1rem;
  font-weight: 650;
  border-radius: 10px;
}

.modal-card--scorecard .modal-actions .secondary,
.modal-card--scorecard .modal-actions .primary {
  min-height: 2.85rem;
  padding: 0.65rem 1.2rem;
  font-size: 0.98rem;
  font-weight: 650;
}

.compare-two-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.82rem;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}

.compare-two-wrap input {
  margin: 0;
}

.scroll-to-top.always-hidden {
  display: none !important;
}

.messages-shell--compare {
  overflow-y: auto;
}

.sim-compare-pane--compact {
  flex: 0 0 auto;
  max-height: min(36vh, 380px);
}

/* Label column + two model columns — aligned with compare pane & scorecards. */
.sim-compare-metrics-shell {
  display: grid;
  grid-template-columns: var(--sim-compare-label-w) minmax(0, 1fr) minmax(0, 1fr);
  column-gap: var(--sim-compare-gap);
  width: 100%;
  font-size: 0.84rem;
  margin-bottom: 0.45rem;
}

.sim-compare-metrics-labels {
  grid-column: 1;
  grid-row: 1;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: color-mix(in srgb, var(--surface) 92%, var(--border));
}

.sim-compare-metrics-col--a {
  grid-column: 2;
  min-width: 0;
}

.sim-compare-metrics-col--b {
  grid-column: 3;
  min-width: 0;
}

.sim-compare-metrics-label {
  flex: 1 1 auto;
  min-height: 2.5rem;
  padding: 0.5rem 0.55rem;
  color: var(--muted);
  font-weight: 650;
  text-align: left;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  line-height: 1.3;
}

.sim-compare-metrics-label--spacer {
  flex: 0 0 auto;
  min-height: 2.45rem;
  border-top: none;
  background: color-mix(in srgb, var(--surface) 85%, var(--border));
}

.sim-compare-metrics-col {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
}

.sim-compare-metrics-head {
  flex: 0 0 auto;
  padding: 0.45rem 0.5rem;
  font-weight: 700;
  text-align: center;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 85%, var(--border));
  word-break: break-word;
  line-height: 1.25;
}

.sim-compare-metrics-cell {
  flex: 1 1 auto;
  min-height: 2.5rem;
  padding: 0.5rem 0.5rem;
  text-align: center;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  word-break: break-word;
}

.sim-compare-metrics-best {
  background: color-mix(in srgb, #2ea043 14%, var(--surface));
  font-weight: 700;
}

.sim-compare-metrics-label--section,
.sim-compare-metrics-cell--section {
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--muted);
  background: color-mix(in srgb, var(--surface) 88%, var(--border));
}

.sim-compare-metrics-label--section {
  min-height: 2.35rem;
  flex: 0 0 auto;
}

.sim-compare-metrics-cell--section {
  border-top-width: 2px;
}

.sim-compare-metrics-label--dimension,
.sim-compare-metrics-cell--dimension {
  font-size: 0.8rem;
}

.sim-compare-metrics-label--dimension {
  font-weight: 600;
  min-height: 3.25rem;
  line-height: 1.28;
  padding-top: 0.55rem;
  padding-bottom: 0.55rem;
  align-items: flex-start;
}

.sim-compare-metrics-cell--dimension {
  min-height: 3.25rem;
}

.sim-compare-metrics-note {
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.4;
  padding: 0 0.75rem;
}

.sim-compare-scorecards {
  flex: 0 0 auto;
  display: none;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  column-gap: var(--sim-compare-gap);
  row-gap: var(--sim-compare-gap);
  margin-top: 0.55rem;
}

.sim-compare-scorecards:not(.hidden) {
  display: grid;
}

.sim-compare-scorecards--with-labels {
  grid-template-columns: var(--sim-compare-label-w) minmax(0, 1fr) minmax(0, 1fr);
}

.sim-compare-scorecards > .sim-compare-scorecard-col:first-child {
  grid-column: 1;
}

.sim-compare-scorecards > .sim-compare-scorecard-col:last-child {
  grid-column: 2;
}

.sim-compare-scorecards--with-labels > .sim-compare-scorecard-col:first-child {
  grid-column: 2;
}

.sim-compare-scorecards--with-labels > .sim-compare-scorecard-col:last-child {
  grid-column: 3;
}

.sim-compare-scorecard-col {
  min-width: 0;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface);
}

.scorecard--compare {
  padding: 0.55rem 0.65rem 0.75rem;
  max-height: min(52vh, 560px);
  overflow-y: auto;
  font-size: 0.88rem;
}

.scorecard--compare .score-big {
  font-size: 1.65rem;
}

.scorecard--compare .card {
  margin-bottom: 0.55rem;
}

.scorecard--compare .score-analysis-good-bad {
  flex-direction: column;
}

@media (max-width: 900px) {
  .sim-compare-pane:not(.hidden) {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    column-gap: 0.4rem;
    row-gap: 0.4rem;
    align-items: stretch;
  }

  .sim-compare-pane--with-labels:not(.hidden) {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .sim-compare-summary-grid {
    grid-template-columns: 1fr;
  }

  .sim-compare-pane-spacer {
    display: none;
  }

  .sim-compare-col {
    min-width: 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-height: min(58vh, 480px);
  }

  .sim-compare-col-head {
    flex-shrink: 0;
    font-size: 0.66rem;
    line-height: 1.25;
    padding: 0.35rem 0.4rem;
    background: color-mix(in srgb, var(--bg) 65%, var(--surface));
    border-bottom: 1px solid var(--border);
    word-break: break-word;
  }

  .sim-compare-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 0.3rem 0.35rem;
  }

  .sim-compare-messages .msg {
    gap: 0.3rem;
  }

  .sim-compare-messages .avatar {
    width: 22px;
    height: 22px;
    flex: 0 0 22px;
  }

  .sim-compare-messages .msg-body {
    padding: 0.38rem 0.45rem;
    font-size: 0.76rem;
    line-height: 1.35;
  }

  .sim-compare-messages .msg-name {
    font-size: 0.72rem;
  }

  .sim-compare-messages .msg-time {
    font-size: 0.65rem;
  }

  .sim-compare-metrics-shell {
    grid-template-columns: 1fr;
  }
  .sim-compare-metrics-labels {
    display: none;
  }
  .sim-compare-metrics-col--a,
  .sim-compare-metrics-col--b {
    grid-column: 1;
  }
  .sim-compare-metrics-cell::before {
    content: attr(data-label);
    display: block;
    font-size: 0.72rem;
    font-weight: 650;
    color: var(--muted);
    margin-bottom: 0.15rem;
  }
  .sim-compare-scorecards {
    grid-template-columns: 1fr;
  }
  .sim-compare-scorecards > .sim-compare-scorecard-col:first-child,
  .sim-compare-scorecards > .sim-compare-scorecard-col:last-child,
  .sim-compare-scorecards--with-labels > .sim-compare-scorecard-col:first-child,
  .sim-compare-scorecards--with-labels > .sim-compare-scorecard-col:last-child {
    grid-column: 1;
  }
}

.messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding-bottom: 1rem;
}

.sim-ended-banner {
  margin-top: auto;
  padding: 0.75rem 0.5rem 0.25rem;
  text-align: center;
  font-size: 0.84rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  border-top: 1px dashed var(--border);
}

.scroll-to-top {
  position: absolute;
  right: 0.15rem;
  bottom: 0.2rem;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
  transition:
    opacity 0.2s ease,
    transform 0.2s ease,
    color 0.15s ease,
    border-color 0.15s ease;
}

.scroll-to-top.is-visible {
  opacity: 0.42;
  pointer-events: auto;
  transform: translateY(0);
}

.scroll-to-top:hover {
  opacity: 0.78;
  color: var(--text);
  border-color: var(--accent-dim);
}

.scroll-to-top:focus-visible {
  opacity: 0.9;
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.msg {
  display: flex;
  gap: 0.65rem;
  align-items: flex-start;
  padding: 0.15rem 0;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  flex: 0 0 32px;
}

.avatar.marcus {
  border-color: var(--bubble-marcus-border);
  background: var(--bubble-marcus-bg);
}

.avatar.salesops {
  border-color: var(--bubble-salesops-border);
  background: var(--bubble-salesops-bg);
}

.avatar.user {
  border-color: var(--bubble-user-border);
  background: var(--bubble-user-bg);
}

.avatar.instructor {
  border-color: var(--bubble-instructor-border);
  background: var(--bubble-instructor-bg);
}

.msg-main {
  flex: 1;
  min-width: 0;
}

.msg-header {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: baseline;
}

.msg-name {
  font-weight: 650;
}

.msg-time {
  font-size: 0.8rem;
  color: var(--muted);
}

.msg-body {
  margin-top: 0.15rem;
  line-height: 1.45;
  white-space: pre-wrap;
  padding: 0.6rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.msg.marcus .msg-body {
  background: var(--bubble-marcus-bg);
  border-color: var(--bubble-marcus-border);
}

.msg.salesops .msg-body {
  background: var(--bubble-salesops-bg);
  border-color: var(--bubble-salesops-border);
}

.msg.user .msg-body {
  background: var(--bubble-user-bg);
  border-color: var(--bubble-user-border);
}

.msg.instructor .msg-body {
  background: var(--bubble-instructor-bg);
  border-color: var(--bubble-instructor-border);
}

.msg--flagged .msg-body {
  box-shadow: inset 3px 0 0 0 color-mix(in srgb, #d97706 70%, transparent);
}

.msg--flagged-soft .msg-body {
  box-shadow: inset 3px 0 0 0 color-mix(in srgb, #2563eb 45%, transparent);
}

.msg-flags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem;
  margin-left: auto;
}

.msg-flag {
  font-size: 0.65rem;
  font-weight: 650;
  padding: 0.08rem 0.32rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  color: var(--muted);
  line-height: 1.2;
}

.transcript-hl-banner {
  margin: 0 0 0.55rem;
  padding: 0.5rem 0.6rem;
  border-radius: 10px;
  border: 1px solid color-mix(in srgb, #d97706 45%, var(--border));
  background: color-mix(in srgb, #d97706 12%, var(--surface));
  font-size: 0.84rem;
  line-height: 1.45;
}

.transcript-hl-banner-line + .transcript-hl-banner-line {
  margin-top: 0.35rem;
}

.transcript-hl-legend {
  margin: 0 0 0.5rem;
  padding: 0.4rem 0.55rem;
  border-radius: 8px;
  border: 1px dashed var(--border);
  background: color-mix(in srgb, var(--panel) 92%, transparent);
}

.transcript-hl-legend-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.transcript-hl-legend-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.transcript-hl-chip {
  font-size: 0.72rem;
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.transcript-hl-chip--customer_aggravation {
  border-color: rgba(220, 38, 38, 0.45);
  background: rgba(220, 38, 38, 0.08);
}

.transcript-hl-chip--customer_escalation {
  border-color: rgba(185, 28, 28, 0.5);
  background: rgba(185, 28, 28, 0.1);
}

.transcript-hl-chip--agent_emotional,
.transcript-hl-chip--agent_rude,
.transcript-hl-chip--agent_dismissive {
  border-color: rgba(147, 51, 234, 0.45);
  background: rgba(147, 51, 234, 0.08);
}

.transcript-hl-chip--premature_commitment,
.transcript-hl-chip--premature_root_cause {
  border-color: rgba(217, 119, 6, 0.5);
  background: rgba(217, 119, 6, 0.1);
}

.transcript-hl-chip--agent_weak_empathy,
.transcript-hl-chip--agent_vague_response,
.transcript-hl-chip--agent_helpless {
  border-color: rgba(37, 99, 235, 0.45);
  background: rgba(37, 99, 235, 0.08);
}

.msg-body .t-hl {
  padding: 0.05rem 0.12rem;
  border-radius: 3px;
  font-weight: 600;
  color: inherit;
}

.msg-body .t-hl--customer_aggravation,
.msg-body .t-hl--customer_escalation {
  background: rgba(220, 38, 38, 0.22);
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

.msg-body .t-hl--agent_emotional,
.msg-body .t-hl--agent_rude,
.msg-body .t-hl--agent_dismissive {
  background: rgba(147, 51, 234, 0.2);
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

.msg-body .t-hl--premature_commitment,
.msg-body .t-hl--premature_root_cause {
  background: rgba(217, 119, 6, 0.28);
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

.msg-body .t-hl--agent_weak_empathy,
.msg-body .t-hl--agent_vague_response,
.msg-body .t-hl--agent_helpless {
  background: rgba(37, 99, 235, 0.2);
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

.screening-banner {
  flex: 0 0 auto;
  margin: 0.35rem 0 0;
  padding: 0.45rem 0.65rem;
  font-size: 0.78rem;
  line-height: 1.35;
  border-radius: 8px;
  border: 1px solid color-mix(in srgb, #2563eb 40%, var(--border));
  background: color-mix(in srgb, #2563eb 10%, var(--surface));
  color: var(--text);
}

.screening-banner.hidden {
  display: none !important;
}

.composer {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}

.slack-composer {
  padding-top: 0.75rem;
}

.composer textarea {
  flex: 1;
  resize: vertical;
  min-height: 2.4rem;
  max-height: 9rem;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.status {
  min-height: 1.25rem;
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0.5rem 0 0;
}

.sim-run-heartbeat {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  margin-top: 0.35rem;
  padding: 0.5rem 0.65rem;
  border: 1px solid color-mix(in srgb, var(--accent) 32%, var(--border));
  border-radius: 10px;
  background: color-mix(in srgb, var(--accent) 7%, var(--surface));
  flex-shrink: 0;
}

.sim-run-heartbeat.hidden {
  display: none;
}

.sim-run-heartbeat__main {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  min-width: 0;
  flex: 1 1 auto;
}

.sim-run-heartbeat__pulse {
  width: 0.58rem;
  height: 0.58rem;
  margin-top: 0.28rem;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
  animation: sim-heartbeat-pulse 1.35s ease-in-out infinite;
}

.sim-run-heartbeat--stale .sim-run-heartbeat__pulse {
  background: #d97706;
  animation-duration: 2.1s;
}

@keyframes sim-heartbeat-pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }

  50% {
    opacity: 0.42;
    transform: scale(0.82);
  }
}

.sim-run-heartbeat__text {
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
  min-width: 0;
}

.sim-run-heartbeat__label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

.sim-run-heartbeat__detail {
  font-size: 0.74rem;
  line-height: 1.35;
  color: var(--muted);
}

.sim-run-heartbeat--stale .sim-run-heartbeat__detail {
  color: color-mix(in srgb, #d97706 55%, var(--text));
}

.sim-run-heartbeat__end {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 0.32rem 0.62rem;
  font-size: 0.78rem;
  white-space: nowrap;
}

.chat-wrap--running .sim-run-heartbeat:not(.hidden) {
  position: sticky;
  bottom: 0;
  z-index: 45;
  box-shadow: 0 -6px 18px color-mix(in srgb, var(--shadow) 35%, transparent);
}

#status.status {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.status-spinner {
  display: inline-block;
  flex-shrink: 0;
  width: 1rem;
  height: 1rem;
  box-sizing: border-box;
  border: 2px solid color-mix(in srgb, var(--muted) 55%, transparent);
  border-top-color: var(--accent);
  border-radius: 50%;
  vertical-align: middle;
  animation: status-starting-spin 0.7s linear infinite;
}

#status.status.status--starting {
  color: var(--text);
  font-size: 0.875rem;
}

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

.slack-composer.slack-composer--agent-locked {
  display: none;
}

.runbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.runbar.hidden {
  display: none;
}

.runbar-label {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.runbar-id {
  padding: 0.15rem 0.35rem;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.runbar-hint {
  font-size: 0.8rem;
  color: var(--muted);
}

.briefing-inline {
  flex-shrink: 0;
  margin-bottom: 0.75rem;
  padding: 1rem 1.1rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  position: relative;
}

.briefing-inline-close {
  display: none;
  position: absolute;
  top: 0.45rem;
  right: 0.45rem;
  z-index: 3;
  appearance: none;
  width: 2rem;
  height: 2rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  padding: 0;
  box-shadow: 0 1px 4px var(--shadow);
}

.briefing-inline-close:hover {
  color: var(--text);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
}

.briefing-inline-close:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.briefing-inline.briefing-inline--overlay .briefing-inline-close {
  display: inline-flex;
}

.briefing-inline.briefing-inline--overlay .briefing-inline-body {
  padding-right: 2.35rem;
}

.briefing-inline.hidden {
  display: none;
}

.briefing-inline-body {
  overflow: visible;
  flex-shrink: 0;
  padding-right: 0.15rem;
}

.briefing-inline-actions {
  display: none;
  justify-content: center;
  gap: 0.5rem;
  flex-shrink: 0;
  padding-top: 0.15rem;
  border-top: 1px solid var(--border);
  margin: 0 -1.1rem -1rem;
  padding: 0.75rem 1.1rem 1rem;
}

.briefing-inline-actions .primary {
  min-width: 10rem;
  padding-inline: 2rem;
  font-weight: 600;
}

.chat-wrap--prestart .briefing-inline-actions {
  display: flex;
}

.chat-wrap--prestart .messages-shell,
.chat-wrap--prestart .slack-composer,
.chat-wrap--prestart #runbar,
.chat-wrap--prestart #status,
.chat-wrap--prestart #sim-analysis-footer,
.chat-wrap--prestart #screening-banner {
  display: none !important;
}

.chat-wrap--prestart {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.chat-wrap--prestart .briefing-inline {
  flex: 1;
  min-height: 0;
  margin-bottom: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.chat-wrap--prestart .briefing-inline-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.chat-wrap--prestart .briefing-inline-actions {
  flex-shrink: 0;
  position: sticky;
  bottom: 0;
  background: var(--surface);
  display: flex;
}

body.briefing-run-open::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 380;
  background: var(--overlay);
  pointer-events: none;
}

.chat-wrap--running .briefing-inline.briefing-inline--overlay,
.chat-wrap--ended .briefing-inline.briefing-inline--overlay {
  position: fixed;
  z-index: 400;
  left: max(0.65rem, env(safe-area-inset-left, 0px));
  right: max(0.65rem, env(safe-area-inset-right, 0px));
  top: max(3.25rem, calc(env(safe-area-inset-top, 0px) + 2.75rem));
  bottom: max(0.65rem, env(safe-area-inset-bottom, 0px));
  margin: 0;
  max-height: none;
  display: flex !important;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 16px 48px var(--shadow);
}

.chat-wrap--running .briefing-inline.briefing-inline--overlay .briefing-inline-body,
.chat-wrap--ended .briefing-inline.briefing-inline--overlay .briefing-inline-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.chat-wrap--running .briefing-inline.briefing-inline--overlay .briefing-inline-actions,
.chat-wrap--ended .briefing-inline.briefing-inline--overlay .briefing-inline-actions {
  display: none !important;
}

/* Run controls sit in .slack-topbar (sibling of .chat-wrap), not inside it. */
.slack-main:has(.chat-wrap--prestart) .actions-row--run {
  display: none !important;
}

.slack-topbar-channel {
  display: none;
  min-width: 0;
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: -0.02em;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.text-scale-controls {
  display: inline-flex;
  align-items: stretch;
  gap: 0.15rem;
  margin-left: auto;
}

.text-scale-btn {
  appearance: none;
  min-width: 2rem;
  height: 2rem;
  padding: 0 0.35rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.08);
  color: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}

.text-scale-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.16);
}

.text-scale-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.icon-close {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  border: none;
  background: transparent;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--muted);
  padding: 0.25rem 0.5rem;
}

.briefing-body {
  line-height: 1.55;
}

.briefing-body h1 {
  margin-top: 0;
  font-size: 1.2rem;
}

.briefing-body p,
.briefing-body li {
  color: var(--text);
}

.participant-fields {
  margin-top: 0.75rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}

.participant-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.85rem;
}

.participant-field-full {
  grid-column: 1 / -1;
}

.participant-field-label {
  color: var(--muted);
}

.participant-field input {
  font: inherit;
  padding: 0.55rem 0.65rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

.participant-error {
  grid-column: 1 / -1;
  margin: 0.1rem 0 0;
  color: #dc2626;
  font-size: 0.85rem;
}

[data-theme="light"] .participant-error {
  color: #b91c1c;
}

.participant-error.hidden {
  display: none;
}

@media (max-width: 520px) {
  .participant-fields {
    grid-template-columns: 1fr;
  }
}

.briefing-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1rem 0;
}

.modal {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal.hidden {
  display: none;
}

.modal-card {
  position: relative;
  width: 100%;
  max-width: 520px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 18px 60px var(--shadow);
  padding: 1rem 1.1rem;
}

.modal-head {
  display: flex;
  gap: 0.75rem;
  justify-content: space-between;
  align-items: flex-start;
}

.modal-title {
  font-weight: 650;
  font-size: 1rem;
}

.modal-message {
  margin-top: 0.35rem;
  color: var(--muted);
  line-height: 1.45;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1rem;
}

.cam-preview {
  margin-top: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: rgba(127, 127, 127, 0.08);
  max-height: 320px;
}

.cam-preview video {
  width: 100%;
  height: auto;
  display: block;
}

/* ——— Mobile / tablet / narrow viewports (1024 catches phone “desktop site” mode) ——— */
@media (max-width: 1024px) {
  .mobile-nav-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 85;
    background: var(--overlay);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }

  body.mobile-nav-open .mobile-nav-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  body.mobile-nav-open {
    overflow: hidden;
    touch-action: none;
  }

  .slack-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: min(var(--slack-sidebar-width, 210px), 88vw);
    flex: none;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    box-shadow: 8px 0 32px var(--shadow);
    overscroll-behavior: contain;
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .slack-sidebar-resizer {
    display: none;
  }

  body.mobile-nav-open .slack-sidebar {
    transform: translateX(0);
  }

  body:has(.v-sim-bar) .slack-sidebar {
    top: 0;
    height: 100dvh;
    padding-top: max(env(safe-area-inset-top, 0px), 0px);
  }

  .btn-mobile-nav {
    display: inline-flex;
  }

  .slack-topbar-channel {
    display: block;
  }

  .slack-topbar {
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 0.65rem;
    padding: 0.55rem 1rem;
    padding-left: max(1rem, env(safe-area-inset-left, 0px));
    padding-right: max(1.1rem, env(safe-area-inset-right, 0px));
    flex-shrink: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    max-height: min(52vh, 24rem);
  }

  .slack-topbar-lead {
    width: 100%;
    align-items: center;
  }

  .chat-wrap {
    padding: 0.55rem 0.75rem 0.75rem;
  }

  .slack-topbar .actions {
    flex: 0 0 auto;
  }

  .slack-topbar:has(.scenario-picker-list:not(.hidden)) {
    overflow: visible;
    max-height: none;
  }

  .actions-row--setup {
    overflow: visible;
  }

  .scenario-picker-list {
    z-index: 200;
  }

  .briefing-inline {
    padding: 0.85rem 0.9rem 0;
  }

  .briefing-inline-actions .primary {
    width: 100%;
    min-height: 44px;
  }

  .briefing-body h1 {
    font-size: 1.05rem;
  }

  .briefing-body p,
  .briefing-body li {
    font-size: 0.92rem;
  }

  .slack-channel {
    min-width: 0;
    padding-top: 0.15rem;
  }

  .actions {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    gap: 0.5rem;
    flex-shrink: 0;
  }

  .actions-row {
    width: 100%;
    min-width: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    justify-items: stretch;
  }

  /* How to + scenario: auto-sized guide, picker fills the rest (not 50/50). */
  .actions-row--setup {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .actions-row--setup .v-guide-mount {
    grid-column: 1;
    justify-self: start;
  }

  .actions-row--setup .scenario-picker {
    grid-column: 2;
    width: 100%;
    max-width: none;
    min-width: 0;
    flex: none;
    flex-basis: auto;
    justify-self: stretch;
  }

  .actions-row--setup:not(:has(.v-guide-popover)) {
    grid-template-columns: 1fr;
  }

  .actions-row--setup:not(:has(.v-guide-popover)) .scenario-picker {
    grid-column: 1;
  }

  .actions-row--setup .scenario-picker-trigger {
    width: 100%;
    max-width: none;
    min-width: 0;
    flex: 1 1 0%;
    min-height: 44px;
  }

  .actions-row--setup select.secondary,
  .actions-row--setup #agent-model,
  .actions-row--setup #agent-model-b,
  .actions-row--setup #agent-provider {
    grid-column: 1 / span 2;
    width: 100%;
    max-width: none;
    min-width: 0;
    min-height: 44px;
    font-size: 16px;
  }

  .actions-row--setup #compare-two-wrap {
    grid-column: 1 / span 2;
  }

  .actions-row--run select.secondary {
    grid-column: 1 / span 2;
    min-height: 44px;
    font-size: 16px;
  }

  .actions-row button {
    min-height: 44px;
    padding: 0.5rem 0.65rem;
  }

  /* Primary + key actions full width on small screens */
  .actions-row--run #btn-start,
  .actions-row--run #btn-export,
  .actions-row--run #btn-view-briefing,
  .actions-row--run #btn-help,
  .actions-row--run #btn-end,
  .actions-row--run #btn-reset,
  .actions-row--run #btn-view-analysis {
    grid-column: 1 / span 2;
  }

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

  .slack-composer button.primary {
    width: 100%;
    min-height: 44px;
  }

  .composer textarea {
    font-size: 16px;
    min-height: 3rem;
  }

  .modal-card {
    max-height: calc(100dvh - 2rem - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    overflow: auto;
  }

  .slack-brand-mark,
  .slack-brand-img {
    width: 64px;
    height: 64px;
    max-width: 64px;
    max-height: 64px;
  }

  /* ——— Mobile run mode: thread first, config collapsed ——— */
  .slack-main:has(.chat-wrap--running) .slack-topbar,
  .slack-main:has(.chat-wrap--ended) .slack-topbar {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem 0.45rem;
    padding: 0.38rem 0.65rem;
    max-height: none;
    overflow: visible;
  }

  .slack-main:has(.chat-wrap--running) .slack-topbar-lead,
  .slack-main:has(.chat-wrap--ended) .slack-topbar-lead {
    flex: 1 1 auto;
    min-width: 0;
  }

  .slack-main:has(.chat-wrap--running) .slack-topbar .actions,
  .slack-main:has(.chat-wrap--ended) .slack-topbar .actions {
    flex: 1 1 100%;
    gap: 0.35rem;
  }

  .slack-main:has(.chat-wrap--running) .actions-row--setup,
  .slack-main:has(.chat-wrap--ended) .actions-row--setup {
    display: none !important;
  }

  .slack-main:has(.chat-wrap--running) .actions-row--run,
  .slack-main:has(.chat-wrap--ended) .actions-row--run {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
    width: 100%;
  }

  .slack-main:has(.chat-wrap--running) .actions-row--run #btn-view-briefing,
  .slack-main:has(.chat-wrap--running) .actions-row--run #btn-help,
  .slack-main:has(.chat-wrap--running) .actions-row--run #btn-end,
  .slack-main:has(.chat-wrap--ended) .actions-row--run #btn-reset,
  .slack-main:has(.chat-wrap--ended) .actions-row--run #btn-export,
  .slack-main:has(.chat-wrap--ended) .actions-row--run #btn-view-briefing,
  .slack-main:has(.chat-wrap--ended) .actions-row--run #btn-view-analysis {
    grid-column: auto;
    width: auto;
    min-height: 34px;
    padding: 0.3rem 0.55rem;
    font-size: 0.8rem;
    flex: 0 1 auto;
  }

  .slack-main:has(.chat-wrap--running) .chat-wrap,
  .slack-main:has(.chat-wrap--ended) .chat-wrap {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 0.35rem 0.55rem 0.4rem;
  }

  .slack-main:has(.chat-wrap--running) .messages-shell,
  .slack-main:has(.chat-wrap--ended) .messages-shell {
    flex: 1;
    min-height: 0;
  }

  .slack-main:has(.chat-wrap--running) .messages-shell--compare .sim-compare-pane:not(.hidden),
  .slack-main:has(.chat-wrap--ended) .messages-shell--compare .sim-compare-pane:not(.hidden) {
    flex: 1;
    min-height: 0;
    max-height: none;
  }

  .slack-main:has(.chat-wrap--running) .messages-shell--compare .sim-compare-pane:not(.hidden) .sim-compare-col,
  .slack-main:has(.chat-wrap--ended) .messages-shell--compare .sim-compare-pane:not(.hidden) .sim-compare-col {
    max-height: none;
  }

  .slack-main:has(.chat-wrap--running) .sim-single-pane,
  .slack-main:has(.chat-wrap--ended) .sim-single-pane,
  .slack-main:has(.chat-wrap--running) .messages,
  .slack-main:has(.chat-wrap--ended) .messages {
    min-height: 0;
  }

  .chat-wrap--running .slack-composer.slack-composer--agent-locked,
  .chat-wrap--ended .slack-composer.slack-composer--agent-locked {
    display: none !important;
  }

  .chat-wrap--running:has(.slack-composer--agent-locked) #status,
  .chat-wrap--ended:has(.slack-composer--agent-locked) #status {
    margin: 0.2rem 0 0;
    font-size: 0.72rem;
    line-height: 1.3;
    flex-shrink: 0;
  }
}

@media (max-width: 480px) {
  .msg {
    gap: 0.5rem;
  }

  .avatar {
    width: 28px;
    height: 28px;
    flex-basis: 28px;
  }

  .msg-body {
    padding: 0.55rem 0.65rem;
    font-size: 0.95rem;
  }

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