:root {
  color-scheme: dark;
  --bg: #080b12;
  --bg-soft: #0f172a;
  --panel: rgba(15, 23, 42, 0.86);
  --panel-strong: rgba(17, 24, 39, 0.96);
  --border: rgba(148, 163, 184, 0.22);
  --text: #f8fafc;
  --muted: #b6c2d1;
  --dim: #7f8da3;
  --accent: #8b5cf6;
  --accent-2: #22d3ee;
  --good: #34d399;
  --warn: #fbbf24;
  --bad: #fb7185;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
  --radius: 26px;
  --radius-small: 16px;
  --font: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100%;
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(circle at 10% 10%, rgba(139, 92, 246, 0.28), transparent 34rem),
    radial-gradient(circle at 90% 0%, rgba(34, 211, 238, 0.19), transparent 32rem),
    linear-gradient(135deg, #06070c 0%, #0b1020 45%, #090b13 100%);
}

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

button {
  border: 0;
  cursor: pointer;
}

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

.shell {
  width: min(1420px, 100%);
  margin: 0 auto;
  padding: 28px;
}

.hero {
  display: grid;
  grid-template-columns: 1fr minmax(280px, 390px);
  gap: 20px;
  align-items: stretch;
  margin-bottom: 20px;
}

.hero-copy,
.status-card,
.panel {
  border: 1px solid var(--border);
  background: var(--panel);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.hero-copy {
  min-height: 250px;
  padding: clamp(26px, 4vw, 48px);
  border-radius: var(--radius);
  position: relative;
  overflow: hidden;
}

.hero-copy::after {
  content: "";
  position: absolute;
  inset: auto -80px -140px auto;
  width: 330px;
  height: 330px;
  background: radial-gradient(circle, rgba(139, 92, 246, 0.45), transparent 60%);
  pointer-events: none;
}

.eyebrow,
.kicker {
  color: var(--accent-2);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.78rem;
  font-weight: 800;
}

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

h1 {
  font-size: clamp(2.8rem, 7vw, 6.8rem);
  letter-spacing: -0.08em;
  margin: 8px 0 8px;
  line-height: 0.9;
}

h2 {
  font-size: 1.22rem;
  margin-bottom: 0;
}

h3 {
  margin-bottom: 8px;
}

.lede {
  max-width: 820px;
  color: var(--muted);
  font-size: clamp(1.05rem, 2vw, 1.35rem);
  line-height: 1.55;
  margin-bottom: 28px;
}

.hero-actions,
.button-row,
.preset-row {
  display: flex;
  gap: 12px;
  align-items: center;
}

.wrap {
  flex-wrap: wrap;
}

.primary,
.ghost,
.secondary,
.tiny,
.chip {
  border-radius: 999px;
  color: var(--text);
  transition: transform 150ms ease, border-color 150ms ease, background 150ms ease, opacity 150ms ease;
}

.primary:hover,
.ghost:hover,
.secondary:hover,
.tiny:hover,
.chip:hover {
  transform: translateY(-1px);
}

.primary {
  background: linear-gradient(135deg, #8b5cf6, #06b6d4);
  padding: 14px 22px;
  font-weight: 850;
}

.ghost,
.secondary,
.tiny,
.chip {
  background: rgba(15, 23, 42, 0.72);
  border: 1px solid var(--border);
}

.ghost,
.secondary {
  padding: 13px 18px;
  color: var(--muted);
}

.secondary {
  font-size: 0.94rem;
}

.tiny {
  padding: 8px 12px;
  color: var(--muted);
  font-size: 0.86rem;
}

.chip {
  padding: 8px 11px;
  color: var(--muted);
  font-size: 0.88rem;
}

.danger {
  color: #fecdd3;
  border-color: rgba(251, 113, 133, 0.32);
}

.status-card {
  border-radius: var(--radius);
  padding: 26px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  min-height: 160px;
}

.status-card strong,
.status-card span:not(.status-dot) {
  display: block;
}

.status-card strong {
  margin-bottom: 6px;
}

.status-card span:not(.status-dot) {
  color: var(--muted);
  line-height: 1.45;
}

.status-dot {
  flex: 0 0 auto;
  width: 13px;
  height: 13px;
  margin-top: 4px;
  border-radius: 999px;
  background: var(--warn);
  box-shadow: 0 0 0 8px rgba(251, 191, 36, 0.13);
}

.status-dot.live {
  background: var(--good);
  box-shadow: 0 0 0 8px rgba(52, 211, 153, 0.13);
}

.status-dot.demo {
  background: var(--warn);
}

.status-dot.error {
  background: var(--bad);
  box-shadow: 0 0 0 8px rgba(251, 113, 133, 0.13);
}

.layout {
  display: grid;
  grid-template-columns: minmax(270px, 390px) minmax(290px, 390px) minmax(360px, 1fr);
  gap: 20px;
  align-items: start;
}

.panel {
  border-radius: var(--radius);
  overflow: hidden;
}

.control-panel,
.agents-panel {
  padding: 22px;
}

.transcript-panel {
  min-height: 670px;
  max-height: calc(100vh - 80px);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 20px;
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}

.sticky-heading {
  padding: 22px 22px 16px;
  margin: 0;
  border-bottom: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.92);
  z-index: 2;
}

.kicker {
  margin-bottom: 5px;
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.field span {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 750;
}

.field.mini {
  flex: 1 1 auto;
  margin-bottom: 0;
}

input,
textarea,
select {
  width: 100%;
  color: var(--text);
  background: rgba(2, 6, 23, 0.54);
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 17px;
  padding: 12px 13px;
  outline: none;
  transition: border-color 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

textarea {
  resize: vertical;
  line-height: 1.45;
}

select {
  appearance: none;
}

input:focus,
textarea:focus,
select:focus {
  border-color: rgba(34, 211, 238, 0.72);
  box-shadow: 0 0 0 4px rgba(34, 211, 238, 0.12);
  background: rgba(2, 6, 23, 0.75);
}

.preset-row {
  flex-wrap: wrap;
  margin: -4px 0 18px;
}

.control-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.compact {
  margin-bottom: 0;
}

.agents-list {
  display: grid;
  gap: 14px;
}

.agent-card {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  background: rgba(2, 6, 23, 0.34);
}

.agent-card-top {
  display: flex;
  gap: 10px;
  align-items: end;
  margin-bottom: 14px;
}

.turn-pill {
  flex: 0 0 auto;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(34, 211, 238, 0.22);
  color: #cffafe;
  background: rgba(8, 145, 178, 0.11);
  font-size: 0.9rem;
  font-weight: 800;
}

.transcript {
  flex: 1 1 auto;
  overflow: auto;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}

.empty-state {
  margin: auto;
  text-align: center;
  max-width: 420px;
  color: var(--muted);
  padding: 30px;
}

.empty-icon {
  width: 72px;
  height: 72px;
  display: grid;
  place-items: center;
  border-radius: 24px;
  margin: 0 auto 16px;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.28), rgba(34, 211, 238, 0.17));
  font-size: 2rem;
}

.message {
  display: grid;
  gap: 7px;
  max-width: 86%;
  align-self: flex-start;
}

.message:nth-child(2n) {
  align-self: flex-end;
}

.message-header {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--dim);
  font-size: 0.86rem;
  font-weight: 800;
}

.avatar {
  width: 25px;
  height: 25px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  color: #ffffff;
  background: linear-gradient(135deg, #8b5cf6, #22d3ee);
  font-size: 0.75rem;
}

.bubble {
  background: rgba(2, 6, 23, 0.66);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 15px 16px;
  color: #e5eefb;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message.demo .bubble {
  border-color: rgba(251, 191, 36, 0.25);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid rgba(251, 191, 36, 0.25);
  color: #fde68a;
  font-size: 0.76rem;
}

.thinking .bubble::after {
  content: "";
  display: inline-block;
  width: 1.1em;
  animation: dots 1.2s infinite steps(4, end);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%) translateY(24px);
  opacity: 0;
  pointer-events: none;
  background: rgba(2, 6, 23, 0.92);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 12px 16px;
  box-shadow: var(--shadow);
  transition: opacity 160ms ease, transform 160ms ease;
  z-index: 99;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@keyframes dots {
  0% { content: ""; }
  25% { content: "."; }
  50% { content: ".."; }
  75% { content: "..."; }
  100% { content: ""; }
}

@media (max-width: 1100px) {
  .hero,
  .layout {
    grid-template-columns: 1fr;
  }

  .transcript-panel {
    position: static;
    max-height: none;
    min-height: 560px;
  }
}

@media (max-width: 640px) {
  .shell {
    padding: 14px;
  }

  .hero-copy,
  .control-panel,
  .agents-panel,
  .sticky-heading,
  .transcript {
    padding: 18px;
  }

  .hero-actions,
  .button-row {
    align-items: stretch;
    flex-direction: column;
  }

  .primary,
  .ghost,
  .secondary {
    width: 100%;
  }

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

  .message {
    max-width: 100%;
  }
}

/* v1.2 per-agent model picker */
.model-preset-row {
  margin: -6px 0 16px;
}

.agent-card-top {
  flex-wrap: wrap;
}

.agent-name-field {
  min-width: 130px;
}

.agent-model-field {
  flex: 1 1 170px;
  min-width: 160px;
}

.agent-model {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.92rem;
}

@media (max-width: 640px) {
  .agent-card-top {
    align-items: stretch;
    flex-direction: column;
  }

  .agent-name-field,
  .agent-model-field,
  .remove-agent {
    width: 100%;
  }
}
