:root {
  --bg: #f5f1eb;
  --surface: #fffaf3;
  --surface-alt: #f0e5d7;
  --surface-soft: rgba(255, 250, 243, 0.84);
  --border: #ddcfbf;
  --border-strong: #cebba7;
  --border-light: rgba(206, 187, 167, 0.55);
  --text: #2d2b28;
  --text-muted: #746b63;
  --text-secondary: #746b63;
  --accent: #b35c1e;
  --accent-strong: #8d4310;
  --accent-soft: #f6dec4;
  --accent-light: rgba(179, 92, 30, 0.12);
  --accent-subtle: rgba(179, 92, 30, 0.08);
  --success: #266d51;
  --success-bg: #d8efe4;
  --success-text: #1f5d45;
  --warning: #8d5b11;
  --warning-bg: #f7e5bf;
  --error: #a6441a;
  --error-bg: #f9d9cc;
  --error-text: #7f3012;
  --shadow: 0 10px 30px rgba(76, 52, 35, 0.08);
  --shadow-md: 0 12px 26px rgba(76, 52, 35, 0.12);
  --shadow-lg: 0 24px 56px rgba(55, 37, 25, 0.22);
  --radius: 16px;
  --radius-sm: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --radius-pill: 999px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-serif: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  --font-mono: "SFMono-Regular", Consolas, monospace;
  --code-bg: rgba(141, 67, 16, 0.08);
  --code-border: rgba(141, 67, 16, 0.12);
  --code-text: #5d3a23;
  --tutor-bubble: #fffaf3;
  --tutor-text: #2d2b28;
  --user-bubble: #874515;
  --user-text: #fff7ef;
  --tool-accent: var(--accent-strong);
  --duration-fast: 0.16s;
  --duration-normal: 0.24s;
  --duration-slow: 0.36s;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --nav-height: 74px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background:
    radial-gradient(circle at top left, rgba(179, 92, 30, 0.08), transparent 30%),
    linear-gradient(180deg, #fbf7f1 0%, var(--bg) 100%);
  color: var(--text);
  font-family: var(--font-sans);
}

a {
  color: inherit;
}

code {
  font-family: var(--font-mono);
}

pre,
code {
  word-break: break-word;
}

#nav {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: var(--nav-height);
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 250, 243, 0.9);
  backdrop-filter: blur(8px);
}

.nav-brand-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.nav-brand {
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.01em;
  text-decoration: none;
}

.nav-badge {
  padding: 6px 10px;
  border-radius: var(--radius-pill);
  background: var(--surface-alt);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-user {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-width: 120px;
}

.nav-user-card {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-avatar,
.nav-avatar-fallback {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex: 0 0 auto;
}

.nav-avatar {
  object-fit: cover;
}

.nav-avatar-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
}

.nav-user-name {
  max-width: 140px;
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-link {
  padding: 9px 14px;
  border-radius: var(--radius-pill);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  transition: background var(--duration-fast) var(--ease), color var(--duration-fast) var(--ease), box-shadow var(--duration-fast) var(--ease);
}

.nav-link:hover {
  background: var(--surface-alt);
  color: var(--text);
}

.nav-link.active {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
  color: #fff;
  box-shadow: 0 8px 18px rgba(179, 92, 30, 0.2);
}

.btn-small {
  padding: 7px 10px;
  font-size: 12px;
}

#app {
  padding: 36px 24px 64px;
}

#app.flow-app {
  padding: 10px 18px 18px;
}

#app.app-detail {
  padding: 0;
}

.page {
  max-width: 1180px;
  margin: 0 auto;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 28px;
}

.page-title-wrap {
  min-width: 0;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

h1 {
  margin: 0;
  font-size: 32px;
  line-height: 1.08;
}

.subtitle {
  max-width: 760px;
  margin-top: 10px;
  color: var(--text-muted);
  line-height: 1.65;
}

.summary-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.summary-pill,
.badge,
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 11px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.summary-pill {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
}

.badge {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.status-pill.pending {
  background: var(--warning-bg);
  color: var(--warning);
}

.status-pill.completed {
  background: var(--success-bg);
  color: var(--success);
}

.status-pill.running {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.status-pill.failed {
  background: var(--error-bg);
  color: var(--error-text);
}

.status-pill.cancelled,
.status-pill.stale {
  background: rgba(116, 107, 99, 0.1);
  color: var(--text-muted);
}

.shell-card,
.panel,
.session-card,
.task-card,
.detail-card,
.empty-state,
.error-state,
.loading-state {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.loading-state,
.error-state,
.empty-state {
  max-width: 860px;
  margin: 0 auto;
  padding: 24px 28px;
}

.loading-state p,
.empty-state p,
.error-state p {
  margin: 8px 0 0;
  color: var(--text-muted);
  line-height: 1.6;
}

.error-state strong {
  color: var(--accent-strong);
}

.filter-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
  padding: 18px;
}

.filter-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.filter-label {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.filter-input,
.filter-select {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
  font: inherit;
  transition: border-color var(--duration-fast) var(--ease), box-shadow var(--duration-fast) var(--ease), background var(--duration-fast) var(--ease);
}

.filter-input:hover,
.filter-select:hover {
  border-color: var(--border-strong);
  background: rgba(255, 255, 255, 0.92);
}

.filter-input:focus,
.filter-select:focus,
.filter-select.is-active {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(179, 92, 30, 0.12);
}

.results-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.results-count {
  color: var(--text-muted);
  font-size: 14px;
}

.results-grid {
  display: grid;
  gap: 14px;
}

.session-card {
  display: block;
  padding: 18px 20px;
  text-decoration: none;
  transition: transform var(--duration-fast) var(--ease), box-shadow var(--duration-fast) var(--ease), border-color var(--duration-fast) var(--ease);
}

.session-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: 0 16px 26px rgba(179, 92, 30, 0.12);
}

.session-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.session-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
}

.session-subtitle {
  margin-top: 8px;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.6;
}

.session-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.meta-chip {
  padding: 7px 10px;
  border-radius: var(--radius-pill);
  background: rgba(141, 67, 16, 0.06);
  color: var(--text-muted);
  font-size: 13px;
}

.meta-chip code {
  background: transparent;
  padding: 0;
}

.score-chip {
  background: rgba(38, 109, 81, 0.12);
  color: var(--success);
}

.unknown-chip {
  background: rgba(116, 107, 99, 0.1);
}

.task-catalog-layout {
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.task-catalog-layout.is-task-class-hidden {
  grid-template-columns: minmax(0, 1fr);
}

.task-catalog-layout.is-task-class-hidden .task-class-panel {
  display: none;
}

.task-class-panel {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.task-class-panel-head,
.tasks-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.task-class-panel-head h2 {
  margin: 0;
  font-size: 16px;
}

.task-class-panel-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.task-class-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.72);
  color: var(--accent-strong);
  font: inherit;
  font-size: 13px;
  font-weight: 850;
  line-height: 1;
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease), border-color var(--duration-fast) var(--ease), box-shadow var(--duration-fast) var(--ease);
}

.task-class-toggle:hover {
  border-color: rgba(179, 92, 30, 0.42);
  background: rgba(246, 222, 196, 0.42);
  box-shadow: 0 6px 14px rgba(179, 92, 30, 0.1);
}

.task-class-list {
  display: grid;
  gap: 8px;
}

.task-class-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.62);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 750;
  text-align: left;
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease), border-color var(--duration-fast) var(--ease), box-shadow var(--duration-fast) var(--ease);
}

.task-class-btn strong {
  flex: 0 0 auto;
  min-width: 28px;
  padding: 4px 7px;
  border-radius: var(--radius-pill);
  background: rgba(141, 67, 16, 0.08);
  color: var(--accent-strong);
  font-size: 12px;
  text-align: center;
}

.task-class-btn:hover,
.task-class-btn.is-active {
  border-color: rgba(179, 92, 30, 0.38);
  background: rgba(246, 222, 196, 0.38);
}

.task-class-btn.is-active {
  box-shadow: 0 8px 18px rgba(179, 92, 30, 0.1);
}

.tasks-group {
  min-width: 0;
  margin-bottom: 30px;
}

.tasks-group-header {
  margin-bottom: 14px;
}

.tasks-group-title {
  margin: 0;
  font-size: 20px;
}

.tasks-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.task-card {
  padding: 18px 20px;
}

.task-card h3 {
  margin: 0;
  font-size: 18px;
  line-height: 1.25;
}

.task-description {
  margin-top: 12px;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.65;
}

.task-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.detail-card {
  max-width: 920px;
  margin: 0 auto;
  padding: 28px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
  color: var(--accent-strong);
  font-weight: 700;
  text-decoration: none;
}

.back-link:hover {
  text-decoration: underline;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease), color var(--duration-fast) var(--ease), border-color var(--duration-fast) var(--ease), box-shadow var(--duration-fast) var(--ease);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  box-shadow: 0 10px 18px rgba(179, 92, 30, 0.2);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--surface-alt);
}

.btn-sm {
  padding: 7px 12px;
  font-size: 12px;
}

.run-page {
  max-width: 1680px;
}

.run-sticky-header {
  position: static;
  z-index: 8;
  margin-bottom: 18px;
  background: transparent;
  backdrop-filter: none;
}

.run-mode-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

.run-mode-card {
  display: grid;
  gap: 14px;
  align-content: start;
  min-height: 260px;
  padding: 24px;
}

.run-mode-card h2 {
  margin: 0;
  font-size: 30px;
}

.run-mode-card p {
  margin: 0;
  color: var(--text-muted);
  line-height: 1.65;
}

.run-grid {
  display: grid;
  grid-template-columns: minmax(230px, 280px) minmax(620px, 1.6fr) minmax(260px, 330px);
  gap: 18px;
  align-items: start;
}

.run-agent-grid {
  display: grid;
  grid-template-columns: minmax(240px, 300px) minmax(560px, 1.4fr) minmax(260px, 320px);
  gap: 18px;
  align-items: start;
}

.run-agent-prompt-panel {
  max-width: 1040px;
}

.run-agent-prompt-card {
  display: grid;
  gap: 18px;
  padding: 26px;
}

.run-agent-prompt-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.run-agent-prompt-head h2 {
  margin: 0;
}

.run-agent-prompt-head .detail-empty-note {
  margin: 8px 0 0;
}

.run-selected-badge {
  flex: 0 0 auto;
  max-width: 120px;
  overflow: hidden;
  padding: 7px 10px;
  border: 1px solid rgba(179, 92, 30, 0.18);
  border-radius: var(--radius-pill);
  background: var(--accent-subtle);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.run-agent-prompt-head .run-selected-badge {
  max-width: 240px;
}

.run-agent-prompt-text {
  width: 100%;
  min-height: 260px;
  resize: vertical;
  padding: 16px 18px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.82);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.62;
}

.run-agent-prompt-text:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(179, 92, 30, 0.12);
}

.api-key-agent-prompt {
  min-height: 240px;
  margin-bottom: 10px;
}

.run-agent-skill-url {
  display: grid;
  gap: 8px;
  padding: 12px 14px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.66);
}

.run-agent-skill-url span {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.run-agent-skill-url code {
  color: var(--code-text);
  font-size: 12.5px;
}

.run-agent-api-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.run-control-panel,
.run-conversation-panel,
.run-background-panel,
.run-tools-panel {
  padding: 18px;
}

.run-control-panel h2,
.run-conversation-panel h2,
.run-background-panel h2,
.run-tools-panel h2,
.run-meta-block h3 {
  margin: 0;
}

.run-control-panel {
  display: grid;
  gap: 16px;
}

.run-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.run-error {
  margin: 0 0 18px;
  padding: 12px 14px;
  border: 1px solid rgba(166, 68, 26, 0.22);
  border-radius: var(--radius);
  background: var(--error-bg);
  color: var(--error-text);
  font-weight: 700;
}

.run-meta-block {
  display: grid;
  gap: 10px;
  padding-top: 14px;
  border-top: 1px solid var(--border-light);
}

.run-meta-block.compact {
  padding-top: 12px;
}

.run-tool-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.run-tool-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: rgba(141, 67, 16, 0.06);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12px;
}

.run-tool-chip small {
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.run-tool-chip.protocol {
  border-style: dashed;
  background: rgba(38, 109, 81, 0.08);
}

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

.run-panel-header p {
  margin: 6px 0 0;
  color: var(--text-muted);
  line-height: 1.55;
}

.run-agent-main {
  min-height: 420px;
}

.run-flow-list {
  display: grid;
  gap: 12px;
  margin: 0;
  padding-left: 24px;
  color: var(--text);
  line-height: 1.6;
}

.run-status-note {
  margin-top: 18px;
  padding: 14px 16px;
  border: 1px solid rgba(38, 109, 81, 0.2);
  border-radius: var(--radius);
  background: rgba(38, 109, 81, 0.08);
  color: var(--text-secondary);
  line-height: 1.6;
}

.run-conversation {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 440px;
  max-height: 58vh;
  margin-bottom: 16px;
  padding: 16px;
  overflow: auto;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  background:
    radial-gradient(circle at top right, rgba(179, 92, 30, 0.07), transparent 34%),
    rgba(255, 248, 238, 0.72);
}

.run-empty-conversation {
  margin: auto;
  color: var(--text-muted);
  text-align: center;
}

.run-message {
  max-width: 84%;
}

.run-message.tutor {
  align-self: flex-start;
}

.run-message.user {
  align-self: flex-end;
}

.run-message-label {
  margin-bottom: 6px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.run-message.user .run-message-label {
  text-align: right;
}

.run-message-bubble {
  padding: 13px 15px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--tutor-bubble);
  color: var(--tutor-text);
  line-height: 1.58;
  box-shadow: 0 8px 18px rgba(76, 52, 35, 0.07);
}

.run-message.user .run-message-bubble {
  border-color: rgba(135, 69, 21, 0.28);
  background: var(--user-bubble);
  color: var(--user-text);
}

.run-message-bubble > :first-child {
  margin-top: 0;
}

.run-message-bubble > :last-child {
  margin-bottom: 0;
}

.run-message-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.run-send-form {
  display: grid;
  gap: 12px;
}

.run-textarea {
  width: 100%;
  min-height: 120px;
  resize: vertical;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
  font: inherit;
  line-height: 1.55;
}

.run-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(179, 92, 30, 0.12);
}

.run-background-text {
  max-height: 40vh;
  overflow: auto;
  color: var(--text-muted);
  line-height: 1.65;
}

.run-event-list {
  display: grid;
  gap: 10px;
  max-height: 46vh;
  overflow: auto;
}

.run-event {
  padding: 10px 12px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.72);
}

.run-event.error {
  border-color: rgba(166, 68, 26, 0.25);
  background: var(--error-bg);
}

.run-event-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12px;
}

.run-event-head span {
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 11px;
  white-space: nowrap;
}

.run-event p {
  margin: 8px 0 0;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.45;
}

/* ── Connection info panel (My Agent) ── */

.run-connect-panel {
  padding: 20px 22px;
}

.run-connect-panel h2 {
  margin: 0 0 14px;
}

.run-connect-section {
  margin-bottom: 16px;
  padding: 14px 16px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.7);
}

.run-connect-section h3 {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.run-connect-field {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.run-connect-label {
  flex-shrink: 0;
  min-width: 90px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
}

.run-connect-value {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: var(--bg);
  font-family: var(--font-mono);
  font-size: 12px;
  word-break: break-all;
}

.run-connect-cmd {
  display: block;
  padding: 8px 12px;
  margin-bottom: 8px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: var(--bg);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.5;
  word-break: break-all;
}

.run-copy-btn {
  flex-shrink: 0;
}

.btn-small {
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 700;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--accent);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.btn-small:hover {
  background: rgba(179, 92, 30, 0.08);
  border-color: var(--accent);
}

/* ── Status pills for run states ── */

.run-status-waiting {
  color: var(--text-muted);
}

.run-status-waiting::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: run-pulse 1.5s ease-in-out infinite;
}

.run-status-claimed {
  color: #3c74b0;
}

.run-status-active {
  color: #266d51;
}

.run-status-active::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 6px;
  border-radius: 50%;
  background: #266d51;
  animation: run-pulse 1.2s ease-in-out infinite;
}

.run-status-completed {
  color: #266d51;
  font-weight: 700;
}

.run-status-failed {
  color: var(--error-text);
  font-weight: 700;
}

.run-status-cancelled {
  color: var(--text-muted);
}

.run-status-stale {
  color: var(--warning);
  font-weight: 700;
}

@keyframes run-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

/* ── Run list page (Runs history) ── */

.my-run-header {
  align-items: flex-start;
}

.my-run-summary .my-run-metric strong {
  color: var(--text);
  font-size: 14px;
}

.my-run-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: -4px 0 18px;
}

.my-run-refresh-status {
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
}

.my-run-state-card {
  max-width: 760px;
}

.my-run-empty {
  display: grid;
  gap: 12px;
  justify-items: start;
}

.my-run-task-list {
  display: grid;
  gap: 14px;
}

.my-run-task-card {
  display: grid;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.my-run-task-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.my-run-task-title {
  min-width: 0;
}

.my-run-task-title h2 {
  margin: 0;
  font-size: 22px;
  line-height: 1.18;
  overflow-wrap: anywhere;
}

.my-run-task-meta,
.my-run-row-detail {
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.5;
}

.my-run-task-meta {
  margin-top: 6px;
}

.my-run-row-list {
  display: grid;
  gap: 8px;
}

.my-run-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.54);
  color: var(--text);
  text-decoration: none;
  transition: border-color var(--duration-fast) var(--ease), background var(--duration-fast) var(--ease);
}

.my-run-row:hover {
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.82);
}

.my-run-row-main {
  display: grid;
  min-width: 0;
  gap: 4px;
}

.my-run-row-title {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 800;
}

.my-run-status {
  flex: 0 0 auto;
}

.runs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.run-card {
  display: block;
  padding: 18px 20px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  background: var(--surface);
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s;
  cursor: pointer;
}

.run-card:hover {
  border-color: var(--accent);
  box-shadow: 0 6px 16px rgba(76, 52, 35, 0.1);
}

.run-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 10px;
}

.run-card-label {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
}

.run-card-mode {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.run-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.run-card-time {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.page-run {
  height: calc(100vh - var(--nav-height));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(255, 250, 243, 0.42) 0%, rgba(240, 229, 215, 0.18) 100%);
}

.detail-header {
  position: sticky;
  top: 0;
  z-index: 12;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 250, 243, 0.94);
  backdrop-filter: blur(10px);
}

.detail-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
  background: var(--surface-alt);
  border: 1px solid var(--border);
  transition: all var(--duration-fast) var(--ease);
}

.detail-back:hover {
  background: var(--bg);
  color: var(--text);
  border-color: var(--accent);
}

.detail-title-block {
  flex: 1;
  min-width: 0;
}

.detail-task-id {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 400;
  color: var(--text);
  letter-spacing: -0.01em;
}

.detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.detail-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  padding: 5px 11px;
  border-radius: var(--radius-pill);
}

.detail-tag-agent {
  background: var(--accent-light);
  color: var(--accent-strong);
}

.detail-tag-model {
  background: #f7e5bf;
  color: #7a4b0a;
}

.detail-tag-persona {
  background: rgba(38, 109, 81, 0.12);
  color: var(--success);
}

.detail-tag-status {
  background: rgba(116, 107, 99, 0.1);
  color: var(--text-muted);
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.detail-report-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease);
}

.detail-report-btn:hover {
  background: var(--surface-alt);
  border-color: var(--accent);
  color: var(--accent-strong);
}

.run-layout {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  overflow: hidden;
}

.run-config {
  width: 240px;
  flex-shrink: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface);
  border-right: 1px solid var(--border);
  transition: width var(--duration-normal) var(--ease);
}

.run-config.collapsed {
  width: 0;
  border-right: none;
}

.run-config.collapsed .panel-body {
  display: none;
}

.run-main {
  flex: 1;
  min-height: 0;
  display: flex;
  overflow: hidden;
}

.run-chat-panel {
  flex: 2;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  min-width: 0;
}

.run-tool-panel {
  width: 360px;
  min-width: 320px;
  flex-shrink: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  transition: width var(--duration-normal) var(--ease), flex var(--duration-normal) var(--ease);
}

.run-tool-panel.collapsed {
  width: 0;
  min-width: 0;
  overflow: hidden;
}

.run-tool-panel.collapsed .tool-area {
  display: none;
}

.panel-header {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
}

.panel-header-title {
  min-width: 0;
}

.panel-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.chat-area {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  background:
    radial-gradient(circle, rgba(206, 187, 167, 0.7) 1px, transparent 1px) 0 0 / 20px 20px,
    linear-gradient(180deg, rgba(255, 250, 243, 0.82) 0%, rgba(245, 241, 235, 0.92) 100%);
}

.tool-area {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: linear-gradient(180deg, rgba(255, 250, 243, 0.66) 0%, rgba(245, 241, 235, 0.92) 100%);
}

.panel-reopen-tab {
  display: block;
  position: absolute;
  top: 50%;
  z-index: 10;
  min-height: 112px;
  padding: 14px 8px;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255, 250, 243, 0.98) 0%, rgba(240, 229, 215, 0.96) 100%);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 12px 22px rgba(76, 52, 35, 0.14);
  transition:
    background var(--duration-normal) var(--ease),
    color var(--duration-normal) var(--ease),
    border-color var(--duration-normal) var(--ease),
    box-shadow var(--duration-normal) var(--ease);
}

.panel-reopen-tab:hover {
  background: linear-gradient(180deg, rgba(246, 222, 196, 0.98) 0%, rgba(240, 229, 215, 0.98) 100%);
  color: var(--accent-strong);
  border-color: var(--accent);
  box-shadow: 0 16px 28px rgba(76, 52, 35, 0.18);
}

.panel-reopen-tab.tab-left {
  left: 240px;
  transform: translateY(-50%);
  border-left: none;
  border-radius: 0 var(--radius) var(--radius) 0;
}

.run-config.collapsed ~ .panel-reopen-tab.tab-left {
  left: 0;
}

.panel-reopen-tab.tab-right {
  right: 0;
  transform: translateY(-50%);
  border-right: none;
  border-radius: var(--radius) 0 0 var(--radius);
}

.panel-reopen-tab.tab-right.is-expanded {
  border-left: 1px solid var(--border);
  border-right: none;
  border-radius: var(--radius) 0 0 var(--radius);
}

.panel-reopen-tab .tab-arrow {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 900;
  line-height: 1;
}

.panel-reopen-tab .tab-label {
  font-size: 11px;
  font-weight: 800;
}

.panel-reopen-tab.is-collapsed {
  background: linear-gradient(180deg, rgba(179, 92, 30, 0.98) 0%, rgba(141, 67, 16, 0.98) 100%);
  color: #fff8f0;
  border-color: var(--accent-strong);
}

.panel-reopen-tab.is-collapsed:hover {
  background: linear-gradient(180deg, rgba(155, 72, 19, 0.98) 0%, rgba(125, 56, 13, 0.98) 100%);
  color: #fff;
}

.info-section h2 {
  margin: 0 0 8px;
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* ── Modal info sections ── */

.modal-body .info-section {
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-light);
}

.modal-body .info-section:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

/* ── Server Detail Modal ── */

.server-modal-content {
  max-width: 1240px;
  max-height: 90vh;
}

.server-modal-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 20px 24px;
  line-height: 1.6;
}

.server-modal-body .workspace-explorer {
  height: 480px;
  min-height: 0;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  overflow: hidden;
}

.server-modal-body .workspace-sidebar,
.server-modal-body .workspace-preview-pane {
  overflow-y: auto;
}

.detail-meta-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 13px;
}

.detail-meta-item:last-child {
  border-bottom: none;
}

.detail-meta-item .dm-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.detail-meta-item .dm-value {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  word-break: break-word;
}

.detail-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.detail-chip {
  padding: 6px 10px;
  border-radius: var(--radius-pill);
  background: var(--accent-light);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 700;
}

.detail-file-list,
.detail-history-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.detail-file-link,
.detail-history-item {
  display: block;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.7);
  text-decoration: none;
}

.detail-file-link:hover {
  border-color: var(--accent);
  background: rgba(246, 222, 196, 0.5);
}

.detail-file-name {
  display: block;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent-strong);
}

.detail-file-hint {
  display: block;
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 12px;
}

.detail-history-item strong {
  color: var(--text);
}

.detail-history-meta {
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 12px;
}

.detail-empty-note {
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.6;
}

.msg {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  max-width: 85%;
  animation: msg-slide-in var(--duration-slow) var(--ease) both;
}

.msg.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.msg.tutor {
  align-self: flex-start;
}

@keyframes msg-slide-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.msg-col {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.msg.user .msg-col {
  align-items: flex-end;
}

.msg.tutor .msg-col {
  align-items: flex-start;
}

.msg-label {
  padding: 0 4px;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.avatar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  margin-top: 18px;
  overflow: visible;
  border-radius: 50%;
}

.avatar::after {
  content: "";
  position: absolute;
  inset: -3px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  opacity: 0.3;
  animation: avatar-pulse 3s ease-in-out infinite;
}

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

  50% {
    opacity: 0.45;
    transform: scale(1.06);
  }
}

.avatar svg {
  width: 34px;
  height: 34px;
  display: block;
}

.bubble {
  padding: 12px 16px;
  border-radius: var(--radius-lg);
  font-size: 14px;
  line-height: 1.65;
  word-break: break-word;
}

.msg.tutor .bubble {
  background: linear-gradient(135deg, var(--tutor-bubble) 0%, var(--surface-alt) 100%);
  color: var(--tutor-text);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-top-left-radius: 4px;
  box-shadow: var(--shadow);
}

.msg.user .bubble {
  background: linear-gradient(135deg, var(--user-bubble) 0%, #5b2c0e 100%);
  color: var(--user-text);
  border-top-right-radius: 4px;
  box-shadow: 0 2px 8px rgba(120, 53, 15, 0.25);
}

.bubble h1,
.bubble h2,
.bubble h3 {
  margin: 10px 0 6px;
  font-weight: 700;
}

.bubble h1 {
  font-size: 17px;
}

.bubble h2 {
  font-size: 16px;
}

.bubble h3 {
  font-size: 15px;
}

.bubble p {
  margin: 6px 0;
}

.bubble ul,
.bubble ol {
  margin: 6px 0;
  padding-left: 20px;
}

.bubble li {
  margin: 2px 0;
}

.bubble strong {
  font-weight: 700;
}

.bubble code {
  padding: 2px 5px;
  border: 1px solid var(--code-border);
  border-radius: var(--radius-sm);
  background: var(--code-bg);
  color: var(--code-text);
  font-size: 12.5px;
}

.bubble pre {
  margin: 10px 0;
  padding: 12px 14px;
  overflow-x: auto;
  border: 1px solid var(--code-border);
  border-radius: var(--radius);
  background: var(--code-bg);
  color: var(--code-text);
  font-size: 12.5px;
  line-height: 1.55;
}

.bubble pre code {
  padding: 0;
  border: none;
  background: none;
  color: inherit;
}

.bubble table {
  width: 100%;
  margin: 8px 0;
  border-collapse: collapse;
  font-size: 13px;
}

.bubble th,
.bubble td {
  padding: 4px 8px;
  border: 1px solid var(--border);
  text-align: left;
}

.bubble th {
  background: var(--surface-alt);
  font-weight: 700;
}

.bubble blockquote {
  margin: 8px 0;
  padding-left: 12px;
  border-left: 3px solid var(--accent);
  color: var(--text-muted);
}

.bubble img {
  max-width: 100%;
  margin: 8px 0;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.msg.user .bubble code {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.18);
  color: #fef3c7;
}

.msg.user .bubble pre {
  background: rgba(0, 0, 0, 0.16);
  border-color: rgba(255, 255, 255, 0.12);
  color: #fef3c7;
}

.protocol-event {
  appearance: none;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  max-width: 100%;
  margin-top: 4px;
  padding: 8px 12px;
  border: 1px dashed rgba(146, 64, 14, 0.22);
  border-left: 3px solid rgba(146, 64, 14, 0.7);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: linear-gradient(135deg, rgba(255, 248, 238, 0.98) 0%, rgba(248, 240, 230, 0.98) 100%);
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.45;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(76, 52, 35, 0.08);
  transition:
    border-color var(--duration-fast) var(--ease),
    box-shadow var(--duration-fast) var(--ease),
    background var(--duration-fast) var(--ease);
}

.protocol-event:hover {
  border-color: rgba(180, 83, 9, 0.5);
  background: linear-gradient(135deg, rgba(255, 244, 230, 0.98) 0%, rgba(248, 236, 219, 0.98) 100%);
  box-shadow: var(--shadow-md);
}

.protocol-name {
  color: var(--accent-strong);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 800;
}

.protocol-arrow {
  color: var(--text-muted);
  font-size: 11px;
}

.protocol-status {
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.protocol-status.active,
.protocol-status.completed {
  background: rgba(21, 128, 61, 0.12);
  color: var(--success);
}

.protocol-status.failed,
.protocol-status.error,
.protocol-status.closed {
  background: rgba(220, 38, 38, 0.1);
  color: var(--error);
}

.protocol-summary {
  color: var(--text-muted);
}

.protocol-attachment-chip {
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(146, 64, 14, 0.1);
  color: var(--accent-strong);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.protocol-duration {
  margin-left: auto;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 11px;
}

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

.protocol-attachment-item {
  border: 1px solid rgba(146, 64, 14, 0.14);
  border-radius: var(--radius);
  background: rgba(255, 248, 238, 0.72);
  padding: 10px;
}

.protocol-attachment-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.protocol-attachment-name {
  color: var(--accent-strong);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 800;
}

.protocol-attachment-meta,
.protocol-attachment-path {
  color: var(--text-muted);
  font-size: 12px;
}

.protocol-attachment-content {
  max-height: 280px;
  margin: 0;
  overflow: auto;
}

.protocol-attachment-image {
  display: block;
  max-width: 100%;
  max-height: 420px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  object-fit: contain;
}

.thinking-bubble {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px !important;
  opacity: 0.85;
}

.thinking-dots {
  display: flex;
  gap: 4px;
}

.thinking-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: thinking-bounce 1.2s ease-in-out infinite;
}

.thinking-dots span:nth-child(2) {
  animation-delay: 0.15s;
}

.thinking-dots span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes thinking-bounce {
  0%,
  60%,
  100% {
    opacity: 0.3;
    transform: translateY(0);
  }

  30% {
    opacity: 1;
    transform: translateY(-4px);
  }
}

.thinking-text {
  color: var(--text-muted);
  font-size: 13px;
  font-style: italic;
}

.responding-dots span {
  background: #fef3c7 !important;
}

.tool-call {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 13px;
}

.tool-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.tool-name {
  color: var(--tool-accent);
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.tool-name:hover {
  text-decoration: underline;
}

.tool-status {
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 700;
}

.tool-status.running {
  background: var(--accent-light);
  color: var(--accent);
}

.tool-status.success {
  background: var(--success-bg);
  color: var(--success-text);
}

.tool-status.failed {
  background: var(--error-bg);
  color: var(--error-text);
}

.tool-duration {
  margin-left: auto;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 11px;
}

.tool-preview {
  margin-top: 6px;
  overflow: hidden;
  display: -webkit-box;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-all;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

.cb-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.cb-thinking {
  overflow: hidden;
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--accent-subtle);
  transition: all var(--duration-normal) var(--ease);
}

.cb-thinking-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  cursor: pointer;
  user-select: none;
}

.cb-thinking-header:hover {
  background: var(--accent-light);
}

.cb-toggle {
  width: 12px;
  flex-shrink: 0;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 11px;
}

.cb-thinking-label {
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

.cb-thinking-body {
  max-height: 400px;
  overflow-y: auto;
  padding: 0 12px 10px;
}

.cb-thinking-body pre {
  margin: 0;
  padding: 0;
  border: none;
  background: none;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.cb-thinking.collapsed .cb-thinking-body {
  display: none;
}

.cb-tool {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--surface);
  font-size: 13px;
  transition: border-color var(--duration-fast) var(--ease), box-shadow var(--duration-fast) var(--ease);
}

.cb-tool:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
}

.cb-tool.cb-tool-error {
  border-left-color: var(--error);
}

.cb-tool-header {
  display: flex;
  align-items: center;
  gap: 6px;
}

.cb-tool-icon {
  font-size: 12px;
  flex-shrink: 0;
}

.cb-tool-name {
  color: var(--tool-accent);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.cb-tool-name:hover {
  text-decoration: underline;
}

.cb-tool-status {
  margin-left: 2px;
  font-size: 13px;
  font-weight: 700;
}

.cb-tool-status.success {
  color: var(--success);
}

.cb-tool-status.failed {
  color: var(--error);
}

.cb-tool-status.running {
  color: var(--text-muted);
}

.cb-tool-duration {
  margin-left: auto;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 11px;
}

.cb-tool-images,
.tool-images {
  margin-top: 8px;
}

.cb-tool-img,
.tool-img-preview {
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: box-shadow var(--duration-normal) var(--ease);
}

.cb-tool-img {
  max-height: 300px;
}

.tool-img-preview {
  max-height: 220px;
}

.cb-tool-img:hover,
.tool-img-preview:hover {
  box-shadow: var(--shadow-md);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.45);
  animation: modal-fade-in var(--duration-fast) var(--ease);
}

@keyframes modal-fade-in {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.modal-content {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 920px;
  max-height: 85vh;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  animation: modal-slide-up var(--duration-normal) var(--ease);
}

@keyframes modal-slide-up {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 400;
  color: var(--text);
}

.modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: var(--surface-alt);
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
}

.modal-close:hover {
  background: var(--error-bg);
  color: var(--error);
}

.modal-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 24px;
  font-size: 14px;
  line-height: 1.6;
}

.modal-body h1,
.modal-body h2,
.modal-body h3 {
  margin: 12px 0 8px;
  font-weight: 700;
}

.modal-body h1 {
  font-size: 18px;
}

.modal-body h2 {
  font-size: 16px;
}

.modal-body h3 {
  font-size: 14px;
}

.modal-body table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.modal-body th,
.modal-body td {
  padding: 8px 12px;
  border: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}

.modal-body th {
  background: var(--surface-alt);
  color: var(--text-secondary);
  font-weight: 700;
}

.modal-body hr {
  margin: 12px 0;
  border: none;
  border-top: 1px solid var(--border-light);
}

.modal-body pre {
  overflow-x: auto;
  padding: 12px 14px;
  border: 1px solid var(--code-border);
  border-radius: var(--radius);
  background: var(--code-bg);
  color: var(--code-text);
  font-size: 12.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-all;
}

.modal-body code {
  padding: 2px 5px;
  border-radius: var(--radius-sm);
  background: var(--code-bg);
  font-size: 12.5px;
}

.modal-body img {
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.workspace-modal-content {
  max-width: 1240px;
  max-height: 88vh;
}

.workspace-modal-body {
  padding: 0;
  overflow: hidden;
}

.workspace-explorer {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  min-height: 0;
  height: 74vh;
}

.workspace-sidebar {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  border-right: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255, 251, 246, 0.98) 0%, rgba(245, 237, 226, 0.95) 100%);
}

.workspace-sidebar-head {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--border);
}

.workspace-search-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.82);
  color: var(--text);
  font: inherit;
}

.workspace-search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(179, 92, 30, 0.12);
}

.workspace-summary {
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.5;
}

.workspace-summary strong {
  color: var(--text);
}

.workspace-file-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 10px;
}

.workspace-file-item {
  display: block;
  width: 100%;
  padding: 12px 12px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition:
    border-color var(--duration-fast) var(--ease),
    background var(--duration-fast) var(--ease),
    box-shadow var(--duration-fast) var(--ease);
}

.workspace-file-item + .workspace-file-item {
  margin-top: 6px;
}

.workspace-file-item:hover {
  border-color: rgba(179, 92, 30, 0.28);
  background: rgba(255, 255, 255, 0.68);
}

.workspace-file-item.active {
  border-color: rgba(179, 92, 30, 0.42);
  background: linear-gradient(135deg, rgba(246, 222, 196, 0.5) 0%, rgba(255, 250, 243, 0.82) 100%);
  box-shadow: inset 3px 0 0 var(--accent);
}

.workspace-file-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.workspace-file-path {
  color: var(--accent-strong);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.45;
  word-break: break-word;
}

.workspace-file-meta {
  color: var(--text-muted);
  font-size: 11px;
}

.workspace-preview-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: rgba(255, 250, 243, 0.86);
}

.workspace-preview-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
  min-height: 76px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}

.workspace-preview-meta {
  min-width: 0;
}

.workspace-preview-path {
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.5;
  word-break: break-word;
}

.workspace-preview-submeta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-top: 6px;
  color: var(--text-muted);
  font-size: 12px;
}

.workspace-truncate-chip {
  color: var(--warning);
  font-weight: 700;
}

.workspace-preview-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.workspace-preview-link {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}

.workspace-preview-link:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.workspace-preview-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 18px 22px 22px;
}

.workspace-banner {
  margin-bottom: 14px;
  padding: 10px 12px;
  border: 1px solid rgba(141, 91, 17, 0.18);
  border-radius: var(--radius-sm);
  background: rgba(247, 229, 191, 0.48);
  color: var(--warning);
  font-size: 12px;
  font-weight: 600;
}

.workspace-empty {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 180px;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.6;
}

.workspace-code {
  margin: 0;
  overflow: auto;
  padding: 16px 18px;
  border: 1px solid var(--code-border);
  border-radius: var(--radius);
  background: rgba(93, 58, 35, 0.04);
  color: var(--code-text);
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.workspace-markdown {
  padding: 2px 2px 16px;
}

.workspace-markdown > :first-child {
  margin-top: 0;
}

.workspace-image-wrap {
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.workspace-preview-image {
  max-width: 100%;
  max-height: 62vh;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.workspace-table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.72);
}

.workspace-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.workspace-table th,
.workspace-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-light);
  border-right: 1px solid var(--border-light);
  text-align: left;
  white-space: nowrap;
}

.workspace-table th:last-child,
.workspace-table td:last-child {
  border-right: none;
}

.workspace-table th {
  position: sticky;
  top: 0;
  background: var(--surface-alt);
  color: var(--text-secondary);
  font-weight: 700;
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

@media (max-width: 860px) {
  #nav {
    flex-direction: column;
    align-items: flex-start;
  }

  #app {
    padding: 24px 16px 48px;
  }

  .page-header,
  .session-top,
  .tasks-group-header,
  .results-meta,
  .detail-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .filter-bar,
  .session-card,
  .task-card,
  .detail-card {
    padding-left: 16px;
    padding-right: 16px;
  }

  .detail-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .run-mode-grid,
  .run-grid,
  .run-agent-grid,
  .task-catalog-layout {
    grid-template-columns: 1fr;
  }

  .task-class-panel {
    padding: 16px;
  }

  .run-agent-prompt-card {
    padding: 18px;
  }

  .run-agent-prompt-head {
    flex-direction: column;
  }

  .my-run-toolbar,
  .my-run-task-head,
  .my-run-row {
    align-items: stretch;
    flex-direction: column;
  }

  .my-run-toolbar .run-actions {
    width: 100%;
  }

  .my-run-toolbar .btn {
    flex: 1 1 auto;
  }

  .my-run-status {
    align-self: flex-start;
  }

  .run-conversation {
    max-height: 62vh;
  }

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

  .run-background-text {
    max-height: 42vh;
  }

  .run-layout {
    display: block;
    overflow: visible;
  }

  .page-run {
    height: auto;
    min-height: calc(100vh - var(--nav-height));
    overflow: visible;
  }

  .detail-header {
    position: static;
  }

  .run-config,
  .run-config.collapsed,
  .run-tool-panel,
  .run-tool-panel.collapsed {
    width: auto;
    min-width: 0;
    border-right: none;
  }

  .run-main {
    display: block;
  }

  .run-chat-panel {
    border-right: none;
  }

  .run-tool-panel {
    border-top: 1px solid var(--border);
  }

  .chat-area {
    min-height: 420px;
    max-height: 62vh;
  }

  .tool-area {
    min-height: 240px;
    max-height: 38vh;
  }

  .msg {
    max-width: 100%;
  }

  .modal-overlay {
    padding: 14px;
  }

  .modal-header,
  .modal-body {
    padding-left: 16px;
    padding-right: 16px;
  }

  .workspace-modal-body {
    padding: 0;
  }

  .workspace-explorer {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 70vh;
  }

  .workspace-sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

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

  .workspace-preview-actions {
    flex-wrap: wrap;
  }

  .workspace-preview-body {
    min-height: 42vh;
  }
}

/* ── Flow demo page ───────────────────────────────────────────────── */

.flow-demo .page-header {
  align-items: center;
  margin-bottom: 8px;
}

.flow-demo {
  max-width: min(1560px, calc(100vw - 48px));
}

.flow-actions {
  flex-shrink: 0;
}

.flow-summary-strip {
  margin: 0 0 18px;
}

.flow-live-monitor {
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--nav-height) - 84px);
  min-height: 620px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255, 250, 243, 0.76);
  box-shadow: var(--shadow-md);
}

.flow-live-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 14px;
}

.flow-live-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  flex: 0 0 auto;
  gap: 8px;
  margin: 0;
  font-size: 18px;
  line-height: 1.15;
}

.flow-demo h1 {
  font-size: 22px;
  line-height: 1.1;
}

.flow-live-meta {
  justify-content: flex-end;
  flex: 1 1 auto;
  min-width: 0;
  padding: 0;
}

.flow-live-grid {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(310px, 380px);
  min-height: 0;
  overflow: hidden;
  border-top: 1px solid var(--border-light);
}

.flow-live-panel {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.flow-conversation-panel {
  border-right: 1px solid var(--border-light);
}

.flow-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 36px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border-light);
  background: rgba(255, 250, 243, 0.86);
}

.flow-panel-header h3 {
  margin: 0;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.flow-panel-header span {
  color: var(--text-muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.flow-conversation-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 14px;
  background:
    radial-gradient(circle, rgba(206, 187, 167, 0.62) 1px, transparent 1px) 0 0 / 20px 20px,
    linear-gradient(180deg, rgba(255, 250, 243, 0.78) 0%, rgba(245, 241, 235, 0.92) 100%);
}

.flow-conversation-body .msg {
  max-width: min(880px, 92%);
  animation: none;
}

.flow-tools-body {
  flex: 1;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px;
  background: linear-gradient(180deg, rgba(255, 250, 243, 0.7) 0%, rgba(245, 241, 235, 0.92) 100%);
}

.flow-conversation-body .empty-state,
.flow-tools-body .empty-state {
  margin: auto;
  color: var(--text-muted);
  text-align: center;
}

.flow-conversation-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background:
    radial-gradient(circle, rgba(206, 187, 167, 0.45) 1px, transparent 1px) 0 0 / 20px 20px,
    linear-gradient(180deg, rgba(255, 250, 243, 0.76) 0%, rgba(245, 241, 235, 0.9) 100%);
}

.flow-message {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-width: 0;
}

.flow-message-user {
  flex-direction: row-reverse;
}

.flow-message strong {
  flex: 0 0 68px;
  padding-top: 10px;
  color: var(--accent-strong);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.flow-full-message {
  display: grid;
  gap: 6px;
  max-width: min(880px, 92%);
}

.flow-full-message.user {
  align-self: flex-end;
  text-align: right;
}

.flow-full-message.tutor {
  align-self: flex-start;
}

.flow-full-message-label {
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.flow-message-user strong {
  text-align: right;
}

.flow-message-body {
  min-width: 0;
  max-width: min(760px, 100%);
  padding: 11px 13px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.9);
  color: var(--text);
  font-size: 14px;
  line-height: 1.65;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.flow-message-user .flow-message-body {
  background: #fff7ed;
  border-color: rgba(179, 92, 30, 0.24);
}

.flow-message-body > :first-child {
  margin-top: 0;
}

.flow-message-body > :last-child {
  margin-bottom: 0;
}

.flow-message-body pre {
  overflow-x: auto;
  white-space: pre-wrap;
}

.flow-full-message-body {
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--tutor-bubble) 0%, var(--surface-alt) 100%);
  color: var(--tutor-text);
  line-height: 1.65;
  white-space: pre-wrap;
  text-align: left;
  box-shadow: var(--shadow);
}

.flow-full-message.user .flow-full-message-body {
  border-color: rgba(135, 69, 21, 0.28);
  background: linear-gradient(135deg, var(--user-bubble) 0%, #5b2c0e 100%);
  color: var(--user-text);
}

.flow-tool-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.flow-tool-item {
  padding: 9px 10px;
  border: 1px solid var(--border-light);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  background: rgba(255, 250, 243, 0.78);
}

.flow-tool-item.err {
  border-left-color: var(--error-text);
}

.flow-tool-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
}

.flow-tool-head span,
.flow-tool-meta {
  color: var(--text-muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.flow-error-chip {
  color: var(--error-text);
}

.flow-now-banner {
  margin: 0 0 14px;
  padding: 12px 16px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: var(--accent-subtle);
  color: var(--accent-strong);
  font-size: 14px;
  font-weight: 600;
}

.flow-fail-banner {
  margin: 0 0 14px;
  padding: 12px 16px;
  border: 1px solid #d98080;
  border-radius: var(--radius-sm);
  background: #fcecec;
  color: #7a1f1f;
  font-size: 14px;
}

@media (max-width: 860px) {
  .flow-demo {
    max-width: none;
  }

  #app.flow-app {
    padding: 8px 10px 12px;
  }

  .flow-live-monitor {
    height: calc(100vh - var(--nav-height) - 58px);
    min-height: 540px;
  }

  .flow-live-top {
    display: grid;
    justify-items: start;
  }

  .flow-live-meta {
    justify-content: flex-start;
  }

  .flow-live-grid {
    grid-template-columns: 1fr;
  }

  .flow-message {
    display: block;
  }

  .flow-message strong {
    display: block;
    margin-bottom: 4px;
    padding-top: 0;
    text-align: left;
  }

  .flow-conversation-panel {
    border-right: none;
    border-bottom: 1px solid var(--border-light);
  }

  .flow-conversation-body,
  .flow-tools-body {
    min-height: 0;
  }
}

/* Human review console */
.review-refresh-wrap {
  display: flex;
  align-items: end;
}

.review-layout {
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(420px, 1fr) minmax(320px, 360px);
  gap: 16px;
  align-items: start;
}

.review-layout.is-context-hidden {
  grid-template-columns: 48px minmax(420px, 1fr) minmax(320px, 360px);
}

.review-layer-stack {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.review-layer,
.review-context-panel,
.review-chat-panel,
.review-opinion-panel {
  padding: 18px;
  min-width: 0;
}

.review-context-panel,
.review-opinion-panel {
  position: sticky;
  top: calc(var(--nav-height) + 18px);
  max-height: calc(100vh - var(--nav-height) - 36px);
  overflow-y: auto;
}

.review-context-rail {
  position: sticky;
  top: calc(var(--nav-height) + 18px);
  display: flex;
  justify-content: center;
  min-height: 180px;
  padding: 10px 6px;
}

.review-context-rail .review-context-toggle {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  white-space: nowrap;
}

.review-chat-panel {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - var(--nav-height) - 190px);
  overflow: hidden;
  padding: 0;
}

.review-chat-panel .review-layer-head {
  padding: 18px 18px 0;
}

.review-chat-area {
  min-height: 540px;
  max-height: calc(100vh - var(--nav-height) - 220px);
  border-top: 1px solid var(--border-light);
}

.review-chat-area .msg {
  max-width: min(82%, 820px);
}

.review-context-stack {
  display: grid;
  gap: 14px;
}

.review-context-section,
.review-context-details {
  padding-top: 14px;
  border-top: 1px solid var(--border-light);
}

.review-context-section:first-child {
  padding-top: 0;
  border-top: none;
}

.review-context-section h3 {
  margin: 0 0 10px;
  font-size: 14px;
}

.review-context-markdown {
  max-height: 260px;
  overflow-y: auto;
}

.review-context-panel .detail-meta-grid {
  grid-template-columns: 1fr;
}

.review-context-panel .detail-meta-item {
  padding: 7px 0;
}

.review-context-panel summary {
  cursor: pointer;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 700;
}

.review-context-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.review-context-evidence {
  min-width: 0;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-light);
}

.review-context-evidence:last-child {
  border-bottom: none;
}

.review-context-evidence summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.review-context-evidence-body {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.review-context-evidence-body h4 {
  margin: 0;
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
}

.review-context-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-light);
}

.review-context-row:last-child {
  border-bottom: none;
}

.review-context-row span,
.review-context-row code {
  min-width: 0;
  overflow-wrap: anywhere;
}

.review-context-judge-row {
  min-width: 0;
}

.review-layer-head,
.review-row-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.review-layer-head h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
}

.review-layer-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

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

.review-spec-block {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: rgba(255, 250, 243, 0.64);
}

.review-spec-block h3 {
  margin: 0 0 12px;
  font-size: 15px;
}

.review-markdown {
  color: var(--text);
  font-size: 14px;
  line-height: 1.65;
}

.review-markdown pre,
.review-markdown code {
  white-space: pre-wrap;
}

.review-turn-list,
.review-tool-list,
.review-judge-table,
.review-opinion-list {
  display: grid;
  gap: 12px;
}

.review-turn,
.review-tool-call,
.review-judge-row,
.review-opinion-card,
.review-file-row {
  padding: 14px;
  border: 1px solid var(--border-light);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  background: rgba(255, 250, 243, 0.76);
}

.review-row-head > div,
.review-file-row > div {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.review-row-head strong,
.review-file-row strong {
  overflow-wrap: anywhere;
}

.review-tool-call details,
.review-layer details {
  margin-top: 10px;
}

.review-tool-call summary,
.review-layer summary {
  cursor: pointer;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 700;
}

.review-rubric-track-list,
.review-file-list {
  display: grid;
  gap: 8px;
}

.review-file-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-left-color: var(--success);
}

.review-opinion-editor {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: rgba(255, 250, 243, 0.72);
}

.review-score-editor {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: rgba(255, 250, 243, 0.82);
}

.review-editor-title h3 {
  margin: 2px 0 0;
  font-size: 15px;
  line-height: 1.25;
}

.review-inline-form .run-actions {
  justify-content: flex-start;
}

.review-advanced-fields {
  display: grid;
  gap: 12px;
}

.review-advanced-fields summary {
  cursor: pointer;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 700;
}

.review-advanced-fields[open] {
  padding-top: 4px;
}

.review-advanced-fields[open] > *:not(summary) {
  margin-top: 12px;
}

.review-opinion-card {
  border-left-color: var(--success);
}

.review-opinion-card.severity-concern {
  border-left-color: var(--warning);
}

.review-opinion-card.severity-blocker {
  border-left-color: var(--error-text);
}

.review-opinion-card p {
  margin: 8px 0;
  line-height: 1.55;
}

.review-card-time {
  color: var(--text-muted);
  font-size: 12px;
  white-space: nowrap;
}

.review-opinion-form,
.review-score-form,
.review-form-grid {
  display: grid;
  gap: 14px;
}

.review-score-criterion {
  display: grid;
  gap: 10px;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--border-light);
  border-left: 3px solid var(--accent-strong);
  border-radius: var(--radius-sm);
  background: rgba(240, 229, 215, 0.42);
}

.review-score-criterion .filter-select {
  width: 82px;
  flex: 0 0 auto;
}

.review-anchor-list {
  margin: 8px 0 0;
  padding-left: 18px;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.45;
}

.review-anchor-list li + li {
  margin-top: 4px;
}

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

@media (max-width: 1280px) {
  .review-layout {
    grid-template-columns: minmax(210px, 250px) minmax(360px, 1fr) minmax(300px, 330px);
  }

  .review-layout.is-context-hidden {
    grid-template-columns: 48px minmax(360px, 1fr) minmax(300px, 330px);
  }
}

@media (max-width: 1080px) {
  .review-layout,
  .review-layout.is-context-hidden,
  .review-spec-grid {
    grid-template-columns: 1fr;
  }

  .review-context-panel,
  .review-context-rail,
  .review-opinion-panel {
    position: static;
    max-height: none;
  }

  .review-context-rail {
    min-height: auto;
    justify-content: flex-start;
  }

  .review-context-rail .review-context-toggle {
    writing-mode: horizontal-tb;
  }

  .review-chat-panel {
    min-height: auto;
  }

  .review-chat-area {
    max-height: none;
  }
}

@media (max-width: 720px) {
  .review-layer-head,
  .review-row-head,
  .review-file-row {
    display: grid;
  }

  .review-layer-actions {
    justify-content: flex-start;
  }

  .review-form-grid {
    grid-template-columns: 1fr;
  }
}
