:root {
  color-scheme: light;
  --bg: #f5f7f4;
  --surface: #ffffff;
  --surface-soft: #f1f5f2;
  --border: #d8ddd7;
  --text: #1d2522;
  --muted: #66736e;
  --teal: #0f766e;
  --blue: #2563eb;
  --amber: #b45309;
  --red: #b91c1c;
  --shadow: 0 12px 28px rgba(31, 41, 35, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px clamp(18px, 4vw, 42px);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.language-switcher {
  display: flex;
  align-items: center;
  grid-template-columns: none;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.language-switcher select {
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fbfcfb;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  padding: 0 9px;
}

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

h1 {
  font-size: 24px;
  line-height: 1.15;
}

h2 {
  font-size: 17px;
  line-height: 1.2;
}

h3 {
  font-size: 15px;
  line-height: 1.2;
}

.topbar p,
.agent-head p,
.section-head p,
.session-meta,
.message-role {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
  width: min(1420px, 100%);
  margin: 0 auto;
  padding: 18px;
}

.layout > * {
  min-width: 0;
}

.sessions-panel,
.chat-panel,
.runtime-panel,
.answer-panel {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.sessions-panel,
.chat-panel,
.runtime-panel {
  min-height: calc(100vh - 104px);
  padding: 16px;
}

.sessions-panel {
  max-width: 100%;
  overflow: hidden;
}

.answer-panel {
  margin-top: 16px;
  padding: 16px;
  box-shadow: none;
}

.section-head,
.agent-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.session-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
}

.session-item {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 68px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--text);
  cursor: pointer;
  padding: 10px;
  text-align: left;
}

.session-item.active {
  border-color: var(--teal);
  background: #e6f4ef;
}

.session-title {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  font-size: 14px;
  font-weight: 750;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-meta {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 112px;
  gap: 12px;
  margin-top: 16px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fbfcfb;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  line-height: 1.45;
  outline: none;
}

input::placeholder,
textarea::placeholder {
  color: #9aa5a0;
  opacity: 1;
}

input {
  height: 40px;
  padding: 0 11px;
}

textarea {
  min-height: 110px;
  max-height: 260px;
  resize: vertical;
  padding: 11px;
}

input:focus,
textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

button {
  border: 0;
  border-radius: 8px;
  background: var(--teal);
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  font-weight: 750;
}

button:disabled {
  cursor: wait;
  opacity: 0.68;
}

.icon-button {
  width: 34px;
  height: 34px;
  font-size: 20px;
  line-height: 1;
}

.composer {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.composer button {
  height: 42px;
}

.transcript {
  display: grid;
  align-content: start;
  gap: 10px;
  min-height: 280px;
  max-height: 42vh;
  margin-top: 16px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 12px;
}

.empty-transcript {
  color: var(--muted);
  font-size: 14px;
}

.message {
  display: grid;
  gap: 4px;
  max-width: 92%;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.message.guest {
  justify-self: end;
  background: #dff4ef;
}

.message.assistant {
  justify-self: start;
  background: #ffffff;
  border: 1px solid var(--border);
}

.agent-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-top: 16px;
}

.agent-card {
  display: grid;
  grid-template-rows: auto minmax(96px, auto);
  min-height: 172px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
  overflow: hidden;
}

.agent-head {
  padding: 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.behavior-log {
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 12px;
}

.behavior-item {
  border-left: 3px solid var(--blue);
  padding: 0 0 0 10px;
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
}

.behavior-item strong {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.behavior-item ul {
  margin: 6px 0 0;
  padding-left: 18px;
}

.behavior-item li + li {
  margin-top: 4px;
}

.nested-details {
  display: grid;
  gap: 3px;
  margin-top: 4px;
  padding-left: 10px;
  border-left: 1px solid var(--border);
}

.answer-text {
  min-height: 112px;
  margin-top: 14px;
  color: var(--text);
  font-size: 14px;
  line-height: 1.58;
  white-space: pre-wrap;
}

.badge,
.status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  max-width: 100%;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 750;
  line-height: 1.15;
  white-space: nowrap;
}

.badge-waiting,
.status-waiting {
  background: #eef0ec;
  color: var(--muted);
}

.badge-running,
.status-running {
  background: #e0f2fe;
  color: var(--blue);
}

.badge-done,
.status-done {
  background: #dff4ef;
  color: var(--teal);
}

.badge-skipped,
.status-skipped {
  background: #f4eadf;
  color: var(--amber);
}

.badge-error,
.status-error {
  background: #f8dddd;
  color: var(--red);
}

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

  .runtime-panel {
    grid-column: 1 / -1;
    min-height: auto;
  }
}

@media (max-width: 760px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .layout {
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .sessions-panel,
  .chat-panel,
  .runtime-panel {
    min-height: auto;
  }

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

  .section-head,
  .agent-head {
    align-items: stretch;
    flex-direction: column;
  }

  .badge,
  .status {
    width: fit-content;
    white-space: normal;
  }
}
