:root {
  --bg-dark: #0b0f19;
  --bg-card: rgba(21, 30, 47, 0.75);
  --bg-card-hover: rgba(30, 42, 66, 0.85);
  --border-color: rgba(255, 255, 255, 0.12);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --primary: #38bdf8;
  --primary-glow: rgba(56, 189, 248, 0.25);
  --accent-gold: #fbbf24;
  --success: #10b981;
  --danger: #f87171;
  --warning: #fb923c;
  --radius-lg: 16px;
  --radius-md: 10px;
  --shadow: 0 12px 36px -10px rgba(0, 0, 0, 0.6);
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-dark);
  background-image: 
    radial-gradient(at 0% 0%, rgba(56, 189, 248, 0.14) 0px, transparent 55%),
    radial-gradient(at 100% 100%, rgba(251, 191, 36, 0.09) 0px, transparent 55%);
  color: var(--text-main);
  font-family: var(--font-family);
  min-height: 100vh;
  padding: 2rem 1.5rem;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

.brand {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.brand-icon {
  width: 52px;
  height: 52px;
  background: linear-gradient(135deg, var(--primary), var(--accent-gold));
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  box-shadow: 0 0 24px var(--primary-glow);
}

.brand-text h1 {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.brand-text p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.badge-tag {
  background: rgba(56, 189, 248, 0.15);
  color: var(--primary);
  border: 1px solid rgba(56, 189, 248, 0.35);
  padding: 0.35rem 0.85rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
}

.card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  margin-bottom: 2rem;
  min-width: 0;
  overflow: hidden;
}

.card-header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.model-select-container {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(56, 189, 248, 0.35);
  padding: 0.4rem 0.85rem;
  border-radius: 24px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
  transition: all 0.2s ease;
}

.model-select-container:hover {
  border-color: var(--primary);
  box-shadow: 0 0 12px var(--primary-glow);
}

.model-select-label {
  font-weight: 600;
  font-size: 0.82rem;
  color: var(--primary);
  white-space: nowrap;
}

.model-dropdown {
  background: transparent;
  color: #f8fafc;
  border: none;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  outline: none;
  padding-right: 0.25rem;
}

.model-dropdown optgroup {
  background: #0f172a;
  color: var(--primary);
  font-weight: 700;
}

.model-dropdown option {
  background: #1e293b;
  color: #f8fafc;
  font-weight: 500;
}

.card-title {
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: #e2e8f0;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

textarea {
  width: 100%;
  height: 90px;
  background: rgba(11, 15, 25, 0.85);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  color: var(--text-main);
  font-size: 1.05rem;
  direction: rtl;
  font-family: inherit;
  resize: vertical;
  transition: all 0.2s ease;
}

textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.action-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
  justify-content: space-between;
  align-items: center;
}

.btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.btn {
  padding: 0.65rem 1.3rem;
  border-radius: var(--radius-md);
  border: none;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-primary {
  background: linear-gradient(135deg, #0284c7, #38bdf8);
  color: white;
  box-shadow: 0 4px 16px rgba(2, 132, 199, 0.4);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 22px rgba(2, 132, 199, 0.6);
}

.btn-secondary {
  background: rgba(51, 65, 85, 0.6);
  color: var(--text-main);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: rgba(71, 85, 105, 0.8);
}

.btn-warning {
  background: rgba(251, 191, 36, 0.15);
  color: var(--accent-gold);
  border: 1px solid rgba(251, 191, 36, 0.35);
}

.btn-warning:hover {
  background: rgba(251, 191, 36, 0.25);
}

/* Agent Grid Layout: STRICTLY 2 AGENTS PER ROW */
.agents-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.75rem;
}

@media (max-width: 900px) {
  .agents-grid {
    grid-template-columns: 1fr;
  }
}

.agent-column {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
  transition: transform 0.2s ease, border-color 0.2s ease;
  min-width: 0;
  overflow: hidden;
}

.agent-column:hover {
  border-color: rgba(56, 189, 248, 0.3);
}

.agent-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 0.85rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
  min-width: 0;
}

.agent-name {
  font-weight: 700;
  font-size: 1.1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-badge {
  padding: 0.25rem 0.65rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  flex-shrink: 0;
}

.status-untested {
  background: rgba(148, 163, 184, 0.15);
  color: #cbd5e1;
  border: 1px solid rgba(148, 163, 184, 0.3);
}

.status-failed {
  background: rgba(248, 113, 113, 0.18);
  color: #fca5a5;
  border: 1px solid rgba(248, 113, 113, 0.4);
}

.status-success {
  background: rgba(16, 185, 129, 0.18);
  color: #6ee7b7;
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.metrics-row {
  display: flex;
  justify-content: space-around;
  background: rgba(11, 15, 25, 0.7);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  margin-bottom: 1.25rem;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.metric-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.metric-label {
  color: var(--text-muted);
  font-size: 0.725rem;
  margin-bottom: 0.2rem;
}

.metric-val {
  font-weight: 700;
  color: var(--primary);
  font-size: 0.95rem;
}

.final-answer-box {
  background: rgba(11, 15, 25, 0.85);
  border-right: 4px solid var(--primary);
  padding: 1rem;
  border-radius: var(--radius-md);
  font-size: 0.925rem;
  direction: rtl;
  margin-bottom: 1.25rem;
  line-height: 1.5;
  color: #f1f5f9;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
  word-break: break-word;
  overflow-wrap: anywhere;
  overflow-x: auto;
  max-width: 100%;
}

.trajectory-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  overflow-y: auto;
  overflow-x: hidden;
  max-height: 480px;
  padding-right: 0.25rem;
  min-width: 0;
  width: 100%;
}

/* Rich Visual Trajectory Cards */
.step-card {
  background: rgba(11, 15, 25, 0.75);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  font-size: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  transition: all 0.2s ease;
  min-width: 0;
  max-width: 100%;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.step-card.is-hallucination {
  border-color: rgba(248, 113, 113, 0.5);
  background: rgba(248, 113, 113, 0.08);
}

.step-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.step-num-badge {
  background: rgba(251, 191, 36, 0.15);
  color: var(--accent-gold);
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  font-weight: 700;
  font-size: 0.75rem;
}

.step-action-badge {
  background: rgba(56, 189, 248, 0.15);
  color: var(--primary);
  border: 1px solid rgba(56, 189, 248, 0.3);
  padding: 0.2rem 0.6rem;
  border-radius: 6px;
  font-family: monospace;
  font-weight: 600;
  font-size: 0.8rem;
  word-break: break-all;
}

.thought-block {
  color: #cbd5e1;
  font-style: italic;
  line-height: 1.4;
  background: rgba(255, 255, 255, 0.03);
  padding: 0.6rem 0.8rem;
  border-radius: 6px;
  border-left: 3px solid rgba(251, 191, 36, 0.5);
  word-break: break-word;
  overflow-wrap: anywhere;
}

.input-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.2rem;
  min-width: 0;
}

.chip {
  background: rgba(255, 255, 255, 0.07);
  color: #e2e8f0;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-family: monospace;
  word-break: break-word;
  overflow-wrap: anywhere;
  max-width: 100%;
}

.chip-key {
  color: var(--primary);
  font-weight: 600;
}

/* Rich Visual Observation Cards */
.obs-card {
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.25);
  border-radius: 6px;
  padding: 0.65rem 0.85rem;
  color: #a7f3d0;
  font-size: 0.8rem;
  line-height: 1.4;
  word-break: break-word;
  overflow-wrap: anywhere;
  max-width: 100%;
  overflow-x: auto;
}

.obs-card.obs-error {
  background: rgba(248, 113, 113, 0.1);
  border-color: rgba(248, 113, 113, 0.35);
  color: #fca5a5;
}

.obs-title {
  font-weight: 700;
  font-size: 0.75rem;
  text-transform: uppercase;
  margin-bottom: 0.3rem;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

/* Comparison Table */
.table-wrapper {
  overflow-x: auto;
  max-width: 100%;
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
  table-layout: auto;
}

th {
  background: rgba(11, 15, 25, 0.95);
  padding: 0.85rem 1rem;
  color: var(--primary);
  border-bottom: 2px solid var(--border-color);
}

td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
  word-break: break-word;
  overflow-wrap: anywhere;
}

tr:hover {
  background: rgba(51, 65, 85, 0.25);
}

.failure-pill {
  background: rgba(248, 113, 113, 0.18);
  color: #fca5a5;
  border: 1px solid rgba(248, 113, 113, 0.4);
  padding: 0.2rem 0.6rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.success-pill {
  background: rgba(16, 185, 129, 0.18);
  color: #6ee7b7;
  border: 1px solid rgba(16, 185, 129, 0.4);
  padding: 0.2rem 0.6rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

/* Spinner */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: white;
  animation: spin 0.8s linear infinite;
}

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