/* Living Intelligence Lab — Design System */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ─── Tokens ─────────────────────────────────────────────── */
:root {
  --color-cobalt: #0057B8;
  --color-cobalt-deep: #0033A0;
  --color-cobalt-wash: #EAF1FB;
  --color-cobalt-tint: #E8EFF9;
  --color-ink: #0A1633;
  --color-slate: #5A6478;
  --color-hairline: #E4E8F0;
  --color-bg: #F5F7FA;
  --color-surface: #FFFFFF;
  --color-success: #10B981;
  --color-error: #EF4444;
  --sidebar-width: 296px;
  --header-height: 60px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ─── Reset ───────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  background: var(--color-bg);
  color: var(--color-ink);
  -webkit-font-smoothing: antialiased;
  height: 100%;
}

/* ─── Animations ──────────────────────────────────────────── */
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

.animate-rise {
  animation: rise 0.35s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

/* ─── Header ──────────────────────────────────────────────── */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: var(--header-height);
  border-top: 3px solid var(--color-cobalt);
  border-bottom: 1px solid var(--color-hairline);
  background: var(--color-surface);
  box-shadow: 0 1px 4px rgba(10, 22, 51, 0.06);
}

.header-inner {
  height: 100%;
  max-width: 1600px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  color: var(--color-ink);
  letter-spacing: -0.01em;
}

.brand-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--color-cobalt);
  flex-shrink: 0;
}

.brand-badge {
  font-size: 11px;
  font-weight: 500;
  color: var(--color-cobalt);
  background: var(--color-cobalt-wash);
  padding: 2px 8px;
  border-radius: 10px;
}

.nav-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-btn {
  background: none;
  border: none;
  padding: 6px 14px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-slate);
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.15s;
}

.nav-btn:hover {
  color: var(--color-cobalt);
  background: var(--color-cobalt-wash);
}

.nav-btn.active {
  color: var(--color-cobalt);
  background: var(--color-cobalt-wash);
  font-weight: 600;
}

/* ─── Workspace Layout (two-column) ──────────────────────── */
.workspace {
  display: none;
  padding-top: var(--header-height);
  min-height: 100vh;
  /* Side-by-side: main + sidebar */
  align-items: flex-start;
}

.workspace.active {
  display: flex;
}

.workspace-full.active {
  display: block;
}

.workspace-main {
  flex: 1;
  min-width: 0;
  padding: 28px 28px 60px 28px;
  overflow-y: auto;
}

/* ─── Sticky Settings Sidebar ────────────────────────────── */
.settings-sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  position: sticky;
  top: var(--header-height);
  height: calc(100vh - var(--header-height));
  overflow-y: auto;
  border-left: 1px solid var(--color-hairline);
  background: var(--color-surface);
  padding: 20px 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.sidebar-section {
  padding: 12px 0;
}

.sidebar-section:first-child {
  padding-top: 0;
}

.sidebar-section-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--color-slate);
  margin-bottom: 10px;
}

.sidebar-divider {
  height: 1px;
  background: var(--color-hairline);
  margin: 4px 0;
}

/* ─── Panels (in main area) ──────────────────────────────── */
.panel {
  background: var(--color-surface);
  border: 1px solid var(--color-hairline);
  border-radius: 10px;
  padding: 20px 22px;
  margin-bottom: 20px;
  box-shadow: 0 1px 3px rgba(10, 22, 51, 0.04);
}

.panel-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 16px;
}

.panel-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--color-ink);
}

.panel-hint {
  font-size: 12px;
  color: var(--color-slate);
}

.cost-estimate {
  font-size: 11.5px;
  color: var(--color-slate);
  margin-top: 6px;
  min-height: 14px;
}

.panel-subtitle {
  font-size: 12.5px;
  color: var(--color-slate);
  margin-top: -8px;
  margin-bottom: 16px;
  line-height: 1.45;
  font-weight: 400;
}

/* ─── Peer Blocks (Option A Layout) ────────────────────────── */
.peer-block {
  border: 1px solid var(--color-hairline);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 16px;
  background: var(--color-surface);
  transition: border-color 0.15s;
}

.peer-block:last-child {
  margin-bottom: 0;
}

.peer-block-header {
  margin-bottom: 10px;
}

.peer-block-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--color-ink);
  line-height: 1.2;
}

.peer-block-subtitle {
  font-size: 12px;
  color: var(--color-slate);
  margin-top: 2px;
}

.peer-textarea {
  resize: vertical;
  min-height: 80px;
  font-size: 13.5px;
  line-height: 1.5;
}

.rubric-block {
  background: var(--color-cobalt-tint, #E8EFF9);
  border: 1px solid #D0DFFA;
}

.rubric-control {
  background: var(--color-surface);
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-slate);
  margin-bottom: 5px;
  letter-spacing: 0.01em;
}

.form-control {
  width: 100%;
  padding: 8px 12px;
  font-family: inherit;
  font-size: 13px;
  color: var(--color-ink);
  background: var(--color-surface);
  border: 1px solid var(--color-hairline);
  border-radius: 6px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  appearance: none;
  -webkit-appearance: none;
}

.form-control:focus {
  border-color: var(--color-cobalt);
  box-shadow: 0 0 0 3px rgba(0, 87, 184, 0.1);
}

textarea.form-control {
  resize: vertical;
  min-height: 100px;
}

/* ─── Custom Select ───────────────────────────────────────── */
.select-wrap {
  position: relative;
}

.select-wrap::after {
  content: '';
  pointer-events: none;
  position: absolute;
  right: 11px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid var(--color-slate);
}

.select-wrap .form-control {
  padding-right: 30px;
  cursor: pointer;
}

/* ─── Slider ───────────────────────────────────────────────── */
.slider-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.slider {
  flex: 1;
  height: 4px;
  appearance: none;
  -webkit-appearance: none;
  background: var(--color-hairline);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

.slider::-webkit-slider-thumb {
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--color-cobalt);
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 87, 184, 0.3);
  transition: transform 0.15s;
}

.slider::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

.slider-val {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-ink);
  min-width: 34px;
  text-align: right;
}

/* ─── Toggle Switch ───────────────────────────────────────── */
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
  margin-bottom: 10px;
}

.setting-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--color-ink);
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 22px;
  cursor: pointer;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.toggle-track {
  position: absolute;
  inset: 0;
  border-radius: 11px;
  background: var(--color-hairline);
  transition: background 0.2s;
}

.toggle-track::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  left: 3px;
  top: 3px;
  border-radius: 50%;
  background: var(--color-surface);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
  transition: transform 0.2s;
}

.toggle-switch input:checked+.toggle-track {
  background: var(--color-cobalt);
}

.toggle-switch input:checked+.toggle-track::before {
  transform: translateX(16px);
}

/* ─── Model Selector Grid (compare) ─────────────────────── */
.models-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 10px;
}

.model-checkbox-card {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 11px 13px;
  border: 1px solid var(--color-hairline);
  border-radius: 8px;
  background: var(--color-surface);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.model-checkbox-card:hover {
  border-color: var(--color-cobalt);
  background: var(--color-cobalt-wash);
}

.model-checkbox-card input[type="checkbox"] {
  accent-color: var(--color-cobalt);
  margin-top: 2px;
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.model-info-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-ink);
}

.model-info-role {
  font-size: 11px;
  color: var(--color-slate);
  margin-top: 1px;
}

.model-info-meta {
  font-size: 11px;
  color: var(--color-cobalt);
  font-weight: 500;
  margin-top: 2px;
}

/* ─── Run Button ──────────────────────────────────────────── */
.btn-run {
  width: 100%;
  padding: 11px 16px;
  background: var(--color-cobalt);
  color: #fff;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  border: none;
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  margin-top: auto;
}

.btn-run:hover {
  background: var(--color-cobalt-deep);
}

.btn-run:active {
  transform: scale(0.98);
}

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

.btn-run-sm {
  width: auto;
  padding: 9px 18px;
}

.btn-ghost {
  background: none;
  border: 1px solid var(--color-hairline);
  color: var(--color-slate);
  padding: 5px 12px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-ghost:hover {
  border-color: var(--color-cobalt);
  color: var(--color-cobalt);
}

/* ─── Upload Zone ─────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--color-hairline);
  border-radius: 7px;
  padding: 14px 12px;
  text-align: center;
  background: var(--color-bg);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--color-cobalt);
  background: var(--color-cobalt-wash);
}

.upload-text {
  font-size: 12px;
  color: var(--color-slate);
}

.file-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 10px;
  background: var(--color-cobalt-wash);
  color: var(--color-cobalt);
  font-size: 11px;
  font-weight: 600;
  border-radius: 14px;
  margin-top: 8px;
  word-break: break-all;
}

/* ─── Results Grid ────────────────────────────────────────── */
.results-heading {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-ink);
  margin-bottom: 14px;
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 14px;
}

.result-card {
  background: var(--color-surface);
  border: 1px solid var(--color-hairline);
  border-radius: 8px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  animation: rise 0.3s ease forwards;
}

.result-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--color-hairline);
  margin-bottom: 10px;
  gap: 8px;
}

.result-model-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-ink);
}

.result-meta-badges {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.badge {
  font-size: 10px;
  font-weight: 500;
  padding: 2px 7px;
  border-radius: 4px;
}

.badge-cobalt {
  background: var(--color-cobalt-wash);
  color: var(--color-cobalt);
}

.badge-slate {
  background: #F1F5F9;
  color: var(--color-slate);
}

.result-body {
  font-size: 13px;
  color: var(--color-ink);
  white-space: pre-wrap;
  word-break: break-word;
  flex-grow: 1;
  max-height: 400px;
  overflow-y: auto;
  line-height: 1.65;
}

/* ─── Judge Panel ─────────────────────────────────────────── */
.judge-panel {
  background: #FAFAFC;
  border: 1px solid var(--color-hairline);
  border-radius: 10px;
  padding: 18px 20px;
  margin-top: 20px;
}

.judge-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-ink);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.verdicts-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.verdict-chip {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 10px;
}

.verdict-meets {
  background: #ECFDF5;
  color: #065F46;
}

.verdict-fails {
  background: #FEF2F2;
  color: #991B1B;
}

.judge-pending {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13px;
  color: var(--color-slate);
  padding: 4px 0;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 0.35; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1); }
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-cobalt);
  flex: none;
  animation: pulse-dot 1.1s ease-in-out infinite;
}

/* ─── Chat ────────────────────────────────────────────────── */
.chat-shell {
  background: var(--color-surface);
  border: 1px solid var(--color-hairline);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--header-height) - 56px);
  overflow: hidden;
}

.chat-messages {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-bubble {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13.5px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.chat-bubble.user {
  align-self: flex-end;
  background: var(--color-cobalt);
  color: #fff;
}

.chat-bubble.assistant {
  align-self: flex-start;
  background: var(--color-bg);
  border: 1px solid var(--color-hairline);
  color: var(--color-ink);
}

.chat-input-area {
  border-top: 1px solid var(--color-hairline);
  background: var(--color-surface);
}

.chat-input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 14px 4px;
}

textarea.form-control.chat-textarea {
  resize: none;
  overflow-y: auto;
  min-height: 40px;
  max-height: 160px;
  line-height: 1.45;
  padding-top: 10px;
  padding-bottom: 10px;
}

.chat-input-area .cost-estimate {
  padding: 0 14px 10px;
  margin-top: 0;
}

/* ─── Trace Table ─────────────────────────────────────────── */
.trace-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.trace-table th,
.trace-table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--color-hairline);
  vertical-align: top;
}

.trace-table th {
  background: #F8FAFC;
  font-weight: 600;
  color: var(--color-slate);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.trace-table tr:hover td {
  background: var(--color-cobalt-wash);
}

/* ─── Model Spec Card (Single Chat Sidebar) ────────────────── */
.model-spec-card {
  margin-top: 10px;
  background: var(--color-cobalt-wash);
  border: 1px solid #D0DFFA;
  border-radius: 8px;
  padding: 12px;
  animation: rise 0.2s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

.spec-card-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
}

.spec-card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-ink);
}

.spec-card-tag {
  display: inline-block;
  align-self: flex-start;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--color-cobalt-deep);
  background: #D9E6FA;
  padding: 2px 7px;
  border-radius: 4px;
}

.spec-card-desc {
  font-size: 11.5px;
  color: var(--color-slate);
  line-height: 1.45;
  margin-bottom: 10px;
}

.spec-card-grid {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding-top: 8px;
  border-top: 1px dashed #CBDCF7;
}

.spec-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11.5px;
}

.spec-label {
  color: var(--color-slate);
}

.spec-value {
  font-weight: 600;
  color: var(--color-ink);
}

/* ─── Query area ──────────────────────────────────────────── */
.query-area {
  min-height: 120px;
}

/* ─── Responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {
  .workspace.active {
    flex-direction: column;
  }

  .settings-sidebar {
    width: 100%;
    height: auto;
    position: static;
    border-left: none;
    border-top: 1px solid var(--color-hairline);
  }

  .chat-shell {
    height: 60vh;
  }
}