/* =========================================================
   UX Eval Agent — Prototype Styles
   Design language: warm, minimal, document-inspired.
   ========================================================= */

:root {
  --bg: #fafaf7;
  --surface: #ffffff;
  --surface-alt: #f3f1ec;
  --border: #e6e2d8;
  --text: #1a1a1a;
  --text-muted: #6b6b66;
  --accent: #b65a2a;        /* warm rust */
  --accent-soft: #f0d5be;
  --accent-deep: #2d6a4f;   /* deep green for "good" */

  --verdict-evidenced:    #2d6a4f;
  --verdict-interpreted:  #1d4ed8;
  --verdict-weak:         #b45309;
  --verdict-disputed:     #7c3aed;
  --verdict-contradicted: #b91c1c;
  --verdict-unsupported:  #6b6b66;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 2px 8px rgba(0,0,0,0.08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI",
               Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Layout ---------- */

.app {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 280px;
  flex-shrink: 0;
  background: var(--surface-alt);
  border-right: 1px solid var(--border);
  padding: 20px 16px;
  transition: width 0.2s ease;
  overflow: hidden;
}
.sidebar.collapsed { width: 56px; padding: 20px 8px; }
.sidebar.collapsed .sidebar-content { display: none; }

.sidebar-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  cursor: pointer;
  font-size: 14px;
  margin-bottom: 18px;
  color: var(--text-muted);
}
.sidebar-toggle:hover { background: var(--surface); }

.sidebar-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin: 0 0 12px 0;
}

.activity-summary {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  margin-bottom: 14px;
}
.activity-summary-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 600;
  margin: 0 0 2px 0;
}
.activity-summary-value {
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 22px;
  color: var(--accent-deep);
  font-weight: 600;
  margin: 0;
}

.activity-list {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 13px;
  line-height: 1.4;
}
.activity-item {
  display: flex;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  align-items: flex-start;
}
.activity-item:last-child { border-bottom: none; }
.activity-status {
  display: inline-block;
  width: 16px;
  flex-shrink: 0;
  text-align: center;
  color: var(--accent-deep);
  font-weight: 600;
}
.activity-label { flex: 1; }

.activity-item--skipped {
  color: var(--text-muted);
}
.activity-item--skipped .activity-status {
  color: var(--verdict-contradicted);
}
.activity-item--skipped .activity-label {
  text-decoration: line-through;
  text-decoration-color: var(--text-muted);
  text-decoration-thickness: 1px;
}
.activity-skipped-tag {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--verdict-contradicted);
  background: #fde2e2;
  padding: 1px 5px;
  border-radius: 8px;
  font-weight: 700;
  flex-shrink: 0;
  align-self: center;
}

.main {
  flex: 1;
  padding: 28px 36px 60px;
  max-width: 1280px;
  margin: 0 auto;
  width: 100%;
}

/* ---------- Header ---------- */

.page-back-link {
  font-size: 13px;
  margin: 0 0 8px 0;
}
.page-back-link a {
  color: var(--accent);
  text-decoration: none;
}
.page-back-link a:hover { text-decoration: underline; }

.page-header {
  margin-bottom: 22px;
}
.page-header .brand { margin: 0 0 4px 0; }
.page-header .page-title { margin: 0 0 14px 0; }
.page-header .page-header-actions {
  margin: 0 0 14px 0;
  flex-wrap: wrap;
}
.page-header .page-meta { margin: 0; }

.page-title {
  font-size: 26px;
  font-weight: 700;
  margin: 0 0 6px 0;
  letter-spacing: -0.01em;
}

.page-meta {
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
}
.page-meta span + span::before {
  content: "·";
  margin-right: 12px;
  color: var(--border);
}
@media (max-width: 700px) {
  /* On mobile, the bullet separator at line-wrap looks orphaned. Drop it
     and let the spans space themselves via the flex gap. */
  .page-meta { gap: 2px 10px; }
  .page-meta span + span::before { content: none; margin: 0; }
}

.brand {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s ease, transform 0.05s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn--primary {
  background: #1d4ed8;
  color: white;
}
.btn--primary:hover { background: #1e40af; }
.btn--secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}
.btn--secondary:hover { background: var(--surface-alt); }
.btn--signoff {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}
.btn--signoff:hover { background: var(--surface-alt); }
.btn--signoff.is-signed {
  background: var(--accent-deep);
  color: white;
  border-color: var(--accent-deep);
}
.btn--signoff.is-signed:hover { background: #245a42; }
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed !important;
  transform: none !important;
}

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

.rerun-form { margin: 0; }

.run-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin: -8px 0 16px 0;
  font-family: "SF Mono", Menlo, Consolas, monospace;
}
.run-meta strong { color: var(--text); font-weight: 600; }

.truncation-warning {
  background: #fff7ed;
  border: 1px solid #fbbf24;
  border-left: 4px solid #d97706;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 13px;
  color: #78350f;
  margin: 0 0 16px 0;
}
.truncation-warning strong { color: #78350f; }

/* ---------- HITL: review counter, sign-off popover and banner ---------- */

.hitl-counter {
  font-size: 12px;
  color: var(--text-muted);
  margin: 8px 0 0 0;
  font-family: "SF Mono", Menlo, Consolas, monospace;
}

.signoff-popover {
  background: var(--surface);
  border: 1px solid var(--accent-soft);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin: 0 0 16px 0;
  box-shadow: var(--shadow-md);
}
.signoff-popover[hidden] { display: none; }
.signoff-label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 6px;
}
.signoff-comment {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  resize: vertical;
  background: var(--bg);
  color: var(--text);
}
.signoff-comment:focus {
  outline: none;
  border-color: var(--accent);
}
.signoff-popover-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 12px;
}

.signoff-banner {
  background: #e8f5ee;
  border: 1px solid var(--accent-deep);
  border-left: 4px solid var(--accent-deep);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin: 0 0 16px 0;
  font-size: 13px;
  color: #1a3d2c;
}
.signoff-banner[hidden] { display: none; }
.signoff-banner-line {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}
.signoff-banner-line strong { color: var(--accent-deep); }
.signoff-banner-comment {
  margin: 6px 0 0 0;
  font-size: 13px;
  color: #1a3d2c;
  font-style: italic;
}
.signoff-banner-comment:empty { display: none; }
.signoff-revoke-btn {
  margin-left: auto;
  background: none;
  border: 1px solid var(--accent-deep);
  border-radius: 12px;
  color: var(--accent-deep);
  padding: 2px 10px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.signoff-revoke-btn:hover { background: var(--accent-deep); color: white; }

/* ---------- Streaming: live status (sidebar) ---------- */

.live-status {
  background: var(--surface);
  border: 1px solid var(--accent-soft);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 14px;
  position: relative;
}
.live-status::before {
  content: "● LIVE";
  position: absolute;
  top: -8px;
  left: 12px;
  background: var(--accent);
  color: white;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 2px 8px;
  border-radius: 8px;
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}
.live-status-phase {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin: 6px 0 4px 0;
}
.live-status-elapsed {
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 18px;
  color: var(--accent);
  margin: 0;
  font-weight: 600;
}
.live-status-section-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin: 0 0 2px 0;
  font-weight: 600;
}
.live-status-section {
  font-size: 12px;
  color: var(--text);
  margin: 0;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  word-break: break-word;
}
.live-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 12px 0;
}

/* ---------- Streaming: live output panel (main) ---------- */

.live-output { border-color: var(--accent); }
.live-output .section-title {
  color: var(--accent);
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}
.live-output-hint {
  font-size: 11px;
  text-transform: none;
  letter-spacing: normal;
  color: var(--text-muted);
  font-weight: 400;
}

.live-console {
  background: #1a1a1a;
  color: #e8e8e2;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.55;
  padding: 16px;
  border-radius: var(--radius-sm);
  max-height: 360px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-wrap: break-word;
  margin: 0;
}
.live-console:empty::before {
  content: "Waiting for the model to start streaming…";
  color: #6b6b66;
  font-style: italic;
}

.live-output-footer {
  margin: 10px 0 0 0;
  font-size: 11px;
  color: var(--text-muted);
  font-family: "SF Mono", Menlo, Consolas, monospace;
}

/* ---------- Error banner ---------- */

.error-banner {
  border-color: var(--verdict-contradicted);
  background: #fef2f2;
}

/* ---------- Sections ---------- */

.section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

.section-title {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin: 0 0 14px 0;
  font-weight: 600;
}

/* ---------- Scorecard ---------- */

.scorecard {
  display: grid;
  gap: 16px;
}

.score-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
@media (max-width: 700px) {
  .score-row { grid-template-columns: 1fr; }
}

.score-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.score-card:hover {
  border-color: var(--accent-soft);
  transform: translateY(-1px);
}
.score-card.expanded {
  border-color: var(--accent);
}

.score-value {
  font-size: 38px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
}
.score-value sup {
  font-size: 16px;
  font-weight: 500;
  color: var(--text-muted);
  margin-left: 2px;
}

.score-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin: 12px 0 8px;
  font-weight: 600;
}

.score-bar {
  height: 4px;
  background: var(--surface-alt);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 6px;
}
.score-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
}

.score-rationale {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 8px;
  display: none;
}
.score-card.expanded .score-rationale { display: block; }

.score-subscores {
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-muted);
  display: none;
}
.score-card.expanded .score-subscores { display: block; }
.score-subscores li { margin: 4px 0; }

.score-total {
  background: var(--accent-deep);
  color: white;
  border-radius: var(--radius-md);
  padding: 24px 28px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}
.score-total .score-value {
  font-size: 56px;
  color: white;
  line-height: 1;
}
.score-total .score-value sup {
  font-size: 20px;
  color: rgba(255,255,255,0.7);
  margin-left: 4px;
}
.score-total .score-label {
  margin: 8px 0 6px;
  color: rgba(255,255,255,0.85);
}
.score-total .score-bar { background: rgba(255,255,255,0.2); width: 100%; }
.score-total .score-bar-fill { background: white; }
.score-total-rating {
  margin: 10px 0 0 0;
  font-size: 13px;
  color: rgba(255,255,255,0.92);
}
.score-total-rating strong { color: white; font-weight: 600; }

.scorecard-hint {
  margin: 6px 2px 0 2px;
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
}

/* ---------- Journey swimlane ---------- */

.phases {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.phase {
  border-left: 3px solid var(--accent-soft);
  padding: 6px 0 6px 14px;
}
.phase-title {
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 8px 0;
  color: var(--text);
}
.phase-id {
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 6px;
  border-radius: 4px;
  margin-right: 8px;
}

.steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.step {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px 12px 14px;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  position: relative;
}
.step:hover { border-color: var(--accent-soft); box-shadow: var(--shadow-sm); }
.step.is-open-in-panel { border-color: var(--accent); border-left-color: var(--accent); box-shadow: var(--shadow-md); }
.step.is-reviewed { border-left-color: var(--accent-deep); }

.step-review-toggle {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: transparent;     /* hide the checkmark until reviewed */
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.step-review-toggle:hover {
  border-color: var(--accent-deep);
  color: var(--accent-deep);
}
.step.is-reviewed .step-review-toggle {
  background: var(--accent-deep);
  border-color: var(--accent-deep);
  color: white;
}
.step.is-reviewed .step-review-toggle:hover {
  background: #245a42;
}
/* step-details: visibility controlled solely by the `hidden` attribute.
   Browser default for [hidden] is display:none, so source copies stay hidden;
   when JS clones into the Sources panel and removes the attribute, they show. */

.step-id {
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 11px;
  color: var(--text-muted);
}
.step-title {
  font-size: 13px;
  font-weight: 600;
  margin: 4px 0 8px;
  line-height: 1.3;
}

.verdict-row {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.verdict-dot {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 6px;
  border-radius: 10px;
  background: var(--surface-alt);
  color: var(--text-muted);
  font-weight: 600;
}
.verdict-dot::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
}

.verdict--evidenced::before    { background: var(--verdict-evidenced); }
.verdict--interpreted::before  { background: var(--verdict-interpreted); }
.verdict--weak::before         { background: var(--verdict-weak); }
.verdict--disputed::before     { background: var(--verdict-disputed); }
.verdict--contradicted::before { background: var(--verdict-contradicted); }
.verdict--unsupported::before  { background: var(--verdict-unsupported); }

.verdict-badge {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border-radius: 10px;
  font-weight: 600;
  white-space: nowrap;
}
.verdict-badge.verdict--evidenced    { background: #e8f5ee; color: var(--verdict-evidenced); }
.verdict-badge.verdict--interpreted  { background: #e3ecfd; color: var(--verdict-interpreted); }
.verdict-badge.verdict--weak         { background: #fff0d6; color: var(--verdict-weak); }
.verdict-badge.verdict--disputed     { background: #f0e6ff; color: var(--verdict-disputed); }
.verdict-badge.verdict--contradicted { background: #fde2e2; color: var(--verdict-contradicted); }
.verdict-badge.verdict--unsupported  { background: var(--surface-alt); color: var(--text-muted); }

/* (step-details visibility — see comment above; relies on [hidden] attribute) */

.element {
  padding: 10px 0;
  border-bottom: 1px dashed var(--border);
}
.element:last-child { border-bottom: none; }

.element-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.element-kind {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 600;
  min-width: 70px;
}
.element-content {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  flex: 1;
}
.element-evidence {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-top: 4px;
  padding-left: 78px;
}
.element-evidence code {
  background: var(--surface-alt);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 11px;
  font-family: "SF Mono", Menlo, Consolas, monospace;
}

/* ---------- Findings (narrative) ---------- */

.findings {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
}
@media (max-width: 900px) {
  .findings { grid-template-columns: 1fr; }
}

.finding-block h3 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin: 0 0 10px 0;
  font-weight: 600;
}
.finding-block-content {
  font-size: 13px;
  line-height: 1.55;
  color: var(--text);
}
.finding-block-content ol,
.finding-block-content ul {
  padding-left: 20px;
  margin: 0;
}
.finding-block-content li {
  margin-bottom: 8px;
}

/* ---------- Sources panel (right slide-in) ---------- */

.sources-backdrop {
  /* Visual dimming only; clicks always pass through to elements underneath.
     The "click-outside-to-close" logic lives in a document-level JS handler. */
  position: fixed;
  inset: 0;
  background: rgba(26, 26, 26, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 90;
}
.sources-backdrop.is-visible { opacity: 1; }
.sources-backdrop[hidden] { display: none; }

.sources-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 480px;
  max-width: 90vw;
  background: var(--bg);
  border-left: 1px solid var(--border);
  box-shadow: -8px 0 24px rgba(0, 0, 0, 0.08);
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 100;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sources-panel.is-open { transform: translateX(0); }
.sources-panel[hidden] { display: none; }

.sources-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 22px 16px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}
.sources-panel-header-text { min-width: 0; }
.sources-panel-eyebrow {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin: 0 0 4px 0;
  font-weight: 600;
}
.sources-panel-title {
  font-size: 17px;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.01em;
  line-height: 1.3;
}
.sources-panel-review {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  font-family: inherit;
  flex-shrink: 0;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.sources-panel-review:hover {
  border-color: var(--accent-deep);
  color: var(--accent-deep);
}
.sources-panel-review.is-reviewed {
  background: var(--accent-deep);
  border-color: var(--accent-deep);
  color: white;
}
.sources-panel-review.is-reviewed .sources-panel-review-label::before {
  content: "Reviewed";
}
.sources-panel-review.is-reviewed .sources-panel-review-label {
  font-size: 0;  /* hide original "Mark as reviewed" text */
}
.sources-panel-review.is-reviewed .sources-panel-review-label::before {
  font-size: 11px;
}
.sources-panel-review-icon { font-size: 12px; line-height: 1; }
.sources-panel-review[hidden] { display: none; }

.sources-panel-close {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 22px;
  line-height: 1;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
  transition: background 0.12s ease, color 0.12s ease;
}
.sources-panel-close:hover { background: var(--surface-alt); color: var(--text); }
.sources-panel-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.sources-panel-body {
  padding: 18px 22px 28px 24px;
  overflow-y: auto;
  flex: 1;
}
.sources-panel-body .element {
  padding: 14px 0;
  border-bottom: 1px dashed var(--border);
  scroll-margin-top: 12px;
}
.sources-panel-body .element:last-child { border-bottom: none; }
.sources-panel-body .element.is-highlighted {
  background: var(--accent-soft);
  margin: 0 -10px;
  padding: 14px 10px;
  border-radius: var(--radius-sm);
  border-bottom: 1px dashed var(--border);
  animation: highlight-fade 1.6s ease-out;
}
@keyframes highlight-fade {
  0%   { background: var(--accent-soft); }
  100% { background: transparent; }
}
.sources-panel-body .element-evidence { padding-left: 0; margin-top: 8px; }

/* Mobile: full-width sheet */
@media (max-width: 700px) {
  .sources-panel {
    width: 100%;
    max-width: 100%;
    border-left: none;
  }
  .sources-panel-body { padding: 18px; }
  .sources-panel-body .element.is-highlighted { margin: 0 -8px; padding: 14px 8px; }
}

/* Verdict dots: clickable, slightly more interactive */
.verdict-dot {
  cursor: pointer;
  transition: transform 0.1s ease;
}
.verdict-dot:hover {
  transform: translateY(-1px);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* ---------- Validation report (inside Sources panel) ---------- */

.validation-run-meta {
  margin: 0 0 14px 0;
  font-size: 11px;
  color: var(--text-muted);
  font-family: "SF Mono", Menlo, Consolas, monospace;
  word-break: break-word;
}
.validation-run-meta strong { color: var(--text); font-weight: 600; }

.validation-run-again {
  margin-left: 10px;
  padding: 2px 8px;
  font-family: inherit;
  font-size: 11px;
  color: var(--accent);
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease;
}
.validation-run-again:hover { background: var(--accent-soft); }

.validation-parse-error {
  margin: 0 0 14px 0;
  padding: 10px 14px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--text);
  background: rgba(217, 119, 6, 0.08);
  border: 1px solid rgba(217, 119, 6, 0.30);
  border-radius: 8px;
}
.validation-parse-error p { margin: 0 0 6px; }
.validation-parse-error p:last-child { margin-bottom: 0; }
.validation-parse-error code {
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 11px;
  background: var(--surface);
  padding: 1px 5px;
  border-radius: 3px;
}
.validation-parse-error-detail {
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 11px;
  color: var(--text-muted);
}

.validation-summary {
  margin-bottom: 18px;
  padding: 14px 16px;
  background: var(--surface-alt);
  border-radius: var(--radius-md);
}
.validation-summary-headline {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 10px 0;
}
.validation-summary-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 12px;
  font-size: 13px;
}
.validation-summary-list li {
  display: flex;
  align-items: center;
  gap: 6px;
}
.validation-summary-list .verdict-dot {
  width: 10px;
  height: 10px;
  padding: 0;
  border-radius: 50%;
  background: none;
}
.validation-summary-list .verdict-dot::before {
  width: 10px;
  height: 10px;
}
.validation-stub-note {
  margin: 12px 0 0 0;
  font-size: 11px;
  color: #78350f;
  background: #fff7ed;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border-left: 3px solid #d97706;
}

.validation-findings-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.validation-finding {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  transition: border-color 0.15s ease;
}
.validation-finding.is-reviewed {
  border-left-color: var(--accent-deep);
  background: #f4f9f6;
}
.validation-finding-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.validation-finding-review {
  width: 22px;
  height: 22px;
  padding: 0;
  margin-left: auto;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text-muted);   /* show a visible light ✓ in unreviewed state */
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.validation-finding-review:hover {
  border-color: var(--accent-deep);
  color: var(--accent-deep);
  background: #f4f9f6;
}
.validation-finding.is-reviewed .validation-finding-review {
  background: var(--accent-deep);
  border-color: var(--accent-deep);
  color: white;
}
.validation-finding-step {
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 6px;
  border-radius: 4px;
}
.validation-finding-element {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 600;
}
.validation-finding-row {
  display: grid;
  grid-template-columns: 60px 1fr;
  gap: 8px;
  font-size: 12px;
  margin: 4px 0;
}
.validation-finding-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 600;
  padding-top: 2px;
}
.validation-finding-value {
  font-size: 12px;
  color: var(--text);
  line-height: 1.5;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  background: var(--surface-alt);
  padding: 4px 8px;
  border-radius: 4px;
  word-break: break-word;
}
.validation-finding-note {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
  margin: 8px 0 0 0;
  padding-left: 68px;
}
.validation-finding-meta {
  font-size: 10px;
  color: var(--text-muted);
  margin: 8px 0 0 0;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  letter-spacing: 0.02em;
}

.validation-error {
  padding: 16px 18px;
  background: #fef2f2;
  border: 1px solid var(--verdict-contradicted);
  border-left: 4px solid var(--verdict-contradicted);
  border-radius: var(--radius-md);
}
.validation-error-headline {
  margin: 0 0 8px 0;
  font-weight: 600;
  color: var(--verdict-contradicted);
}
.validation-error-message {
  margin: 0 0 12px 0;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
  word-break: break-word;
  color: var(--text);
}
.validation-error-trace {
  margin: 0 0 12px 0;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.04);
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text-muted);
}
.validation-error-hint {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
}

/* Acknowledge banner / button at the bottom of the validation panel */
.validation-ack {
  margin-top: 20px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.validation-ack--done {
  background: #e8f5ee;
  border-color: var(--accent-deep);
  border-left: 4px solid var(--accent-deep);
}
.validation-ack-line {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: #1a3d2c;
}
.validation-ack-line strong { color: var(--accent-deep); }
.validation-ack-sub {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
}
.validation-ack-btn {
  align-self: flex-start;
}
.validation-ack-revoke {
  margin-left: auto;
  background: none;
  border: 1px solid var(--accent-deep);
  border-radius: 12px;
  color: var(--accent-deep);
  padding: 2px 10px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.validation-ack-revoke:hover { background: var(--accent-deep); color: white; }

/* ---------- Mobile sidebar drawer ---------- */
/* On desktop: sidebar is an inline column (default rules already cover that).
   On mobile (≤700px): sidebar becomes a slide-in drawer triggered by a
   floating button. The existing .collapsed class is reused to mean
   "off-screen" on mobile. */

.mobile-activity-toggle {
  display: none;  /* hidden on desktop */
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(26, 26, 26, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 150;
}
.sidebar-backdrop.is-visible {
  opacity: 1;
  pointer-events: auto;
}
.sidebar-backdrop[hidden] { display: none; }

@media (max-width: 700px) {
  /* The inline-column sidebar becomes a fixed slide-in drawer */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 82%;
    max-width: 320px;
    padding: 20px 18px;
    transform: translateX(0);
    transition: transform 0.25s ease;
    z-index: 160;
    box-shadow: 4px 0 16px rgba(0, 0, 0, 0.15);
    overflow-y: auto;
  }
  /* `.collapsed` on mobile = drawer hidden off-screen */
  .sidebar.collapsed {
    transform: translateX(-100%);
    padding: 20px 18px;
  }
  /* Hide the inline toggle when drawer is closed (it's inside the off-screen drawer);
     show it as a Close hint when drawer is open */
  .sidebar.collapsed .sidebar-toggle { display: none; }
  .sidebar .sidebar-toggle {
    display: inline-flex;
    margin-bottom: 16px;
  }
  /* Always show sidebar content on mobile when sidebar is on-screen */
  .sidebar .sidebar-content,
  .sidebar.collapsed .sidebar-content {
    display: block;
  }

  /* Floating button at top-left to open the drawer */
  .mobile-activity-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    position: fixed;
    top: 14px;
    left: 14px;
    z-index: 155;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 7px 13px;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
  }
  /* Hide the floating button while the drawer is open */
  .mobile-activity-toggle.is-hidden { display: none; }

  /* Main content reclaims full width since sidebar is fixed (off-flow) */
  .main {
    padding: 56px 16px 60px;  /* extra top padding for the floating button */
    max-width: 100%;
  }
}

/* ---------- Chat (sticky bottom) ---------- */

.chat-container {
  position: sticky;
  bottom: 0;
  /* Extend to viewport edges of the .main padding */
  margin: 36px -36px -60px -36px;
  padding: 14px 36px 18px 36px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.04);
  z-index: 50;
}

.chat-history-wrapper {
  position: relative;
  margin-bottom: 12px;
}
.chat-history-wrapper[hidden] { display: none; }

.chat-history-minimize {
  position: absolute;
  top: -2px;
  right: 0;
  z-index: 2;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 3px 12px;
  font-size: 11px;
  color: var(--text-muted);
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.02em;
}
.chat-history-minimize:hover { background: var(--surface); color: var(--text); }

.chat-history {
  max-height: 360px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 28px 2px 4px 2px;
}

.chat-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  max-width: 80%;
  font-size: 14px;
  line-height: 1.55;
  word-wrap: break-word;
  white-space: pre-wrap;
}
.chat-bubble--user {
  background: var(--accent-soft);
  color: var(--text);
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}
.chat-bubble--assistant {
  background: var(--surface-alt);
  color: var(--text);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}
.chat-bubble--error {
  background: #fde2e2;
  color: var(--verdict-contradicted);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}
.chat-bubble--streaming::after {
  content: "▊";
  color: var(--text-muted);
  animation: blink 1s steps(2) infinite;
}
@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

.chat-form {
  display: flex;
  gap: 8px;
  align-items: center;
}
.chat-input {
  flex: 1;
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: 22px;
  font-size: 14px;
  font-family: inherit;
  background: var(--bg);
  color: var(--text);
  transition: border-color 0.12s ease;
}
.chat-input:focus {
  outline: none;
  border-color: var(--accent);
}
.chat-input:disabled { opacity: 0.6; }

.chat-submit {
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 600;
  background: #1d4ed8;
  color: white;
  border: 1px solid transparent;
  border-radius: 22px;
  cursor: pointer;
  font-family: inherit;
}
.chat-submit:hover:not(:disabled) { background: #1e40af; }
.chat-submit:disabled { opacity: 0.55; cursor: not-allowed; }

.chat-clear,
.chat-show-history {
  padding: 6px 12px;
  font-size: 12px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 16px;
  color: var(--text-muted);
  cursor: pointer;
  font-family: inherit;
}
.chat-clear:hover,
.chat-show-history:hover { background: var(--surface-alt); color: var(--text); }
.chat-show-history[hidden] { display: none; }

/* Mobile */
@media (max-width: 700px) {
  .chat-container { margin: 24px -16px -40px -16px; padding: 12px 16px 16px 16px; }
  .chat-bubble { max-width: 90%; }
  .chat-history { max-height: 220px; }  /* tighter on mobile */
}

/* ---------- Index page ---------- */

.eval-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
  margin-top: 20px;
}
.eval-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  display: block;
  color: var(--text);
  text-decoration: none;
  transition: border-color 0.15s ease;
}
.eval-item:hover {
  border-color: var(--accent);
  text-decoration: none;
}
.eval-item-id {
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 11px;
  color: var(--text-muted);
}
.eval-item-title {
  font-size: 16px;
  font-weight: 600;
  margin: 4px 0 10px;
}
.eval-item-meta {
  font-size: 12px;
  color: var(--text-muted);
}

/* ======================================================================
   Login page — passcode gate for the hosted demo
   ====================================================================== */

.login-body {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-alt);
  padding: 32px 16px;
  font-family: inherit;
}

.login-shell {
  width: 100%;
  max-width: 440px;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px 32px 28px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.06);
}

.login-card .brand {
  margin: 0 0 4px;
}

.login-title {
  margin: 0 0 8px;
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
}

.login-lede {
  margin: 0 0 22px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-muted);
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.login-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  color: var(--text-muted);
}

.login-input {
  width: 100%;
  padding: 12px 14px;
  font-family: inherit;
  font-size: 16px;            /* 16px+ prevents iOS auto-zoom on focus */
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-sizing: border-box;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.login-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.login-error {
  margin: 4px 0 0;
  padding: 10px 12px;
  font-size: 13px;
  color: #b91c1c;
  background: rgba(185, 28, 28, 0.06);
  border: 1px solid rgba(185, 28, 28, 0.25);
  border-radius: 6px;
}

.login-submit {
  margin-top: 14px;
  align-self: stretch;
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 600;
}

.login-footnote {
  margin: 28px 0 0;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}
.login-footnote a {
  color: var(--accent);
}


/* ======================================================================
   Option C — Self-correction
   Apply-correction button per finding, modal with before/after diff,
   "corrected" badges on patched journey-view elements.
   ====================================================================== */

/* Small + ghost button variants used by the modal */
.btn--small {
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
  border-radius: 6px;
}
.btn--ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: transparent;
}
.btn--ghost:hover {
  background: var(--surface-alt);
  color: var(--text);
}

/* Apply-correction button in the Sources panel */
.validation-finding-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}
.validation-finding-correct {
  background: var(--surface);
  color: var(--accent);
  border: 1px solid var(--accent);
}
.validation-finding-correct:hover {
  background: var(--accent-soft);
}
.validation-finding-correct:disabled {
  opacity: 0.6;
  cursor: wait;
}

/* "Correction applied" pill inside the validation panel */
.correction-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 500;
  color: var(--accent-deep);
  background: rgba(45, 106, 79, 0.10);
  border: 1px solid rgba(45, 106, 79, 0.35);
  border-radius: 999px;
}

/* Corrected-finding card subtle hint */
.validation-finding.is-corrected {
  background: rgba(45, 106, 79, 0.04);
}

/* Inline error under the button */
.correction-inline-error {
  margin: 6px 0 0;
  font-size: 12px;
  color: #b91c1c;
}

/* ── Modal ───────────────────────────────────────────────────────── */

.correction-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.correction-modal[hidden] { display: none; }

.correction-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
}

.correction-modal-card {
  position: relative;
  width: min(880px, 100%);
  /* Use dvh (dynamic viewport height) on browsers that support it so the
     iOS Safari bottom URL bar doesn't eat the modal footer. Fallback to
     vh for older engines. */
  max-height: calc(100vh - 48px);
  max-height: calc(100dvh - 48px);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  overflow: hidden;
}

.correction-modal-header {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: start;
  gap: 8px 16px;
  padding: 18px 24px 12px;
  border-bottom: 1px solid var(--border);
}
.correction-modal-eyebrow {
  grid-column: 1;
  margin: 0;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  font-weight: 600;
}
.correction-modal-title {
  grid-column: 1;
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}
.correction-modal-close {
  grid-row: 1 / span 2;
  grid-column: 2;
  background: transparent;
  border: none;
  font-size: 22px;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}
.correction-modal-close:hover {
  background: var(--surface-alt);
  color: var(--text);
}

.correction-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 24px 20px;
}

.correction-modal-context {
  margin: 0 0 6px;
  font-size: 12px;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  color: var(--text-muted);
}
.correction-modal-note {
  margin: 0 0 16px;
  font-size: 14px;
  color: var(--text);
  font-style: italic;
}

.correction-diff {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.correction-diff-col {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  background: var(--surface-alt);
}
.correction-diff-col--after {
  background: rgba(45, 106, 79, 0.06);
  border-color: rgba(45, 106, 79, 0.30);
}
.correction-diff-label {
  margin: 0 0 8px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 600;
}
.correction-diff-dl {
  margin: 0;
  display: grid;
  grid-template-columns: 70px 1fr;
  gap: 6px 12px;
  font-size: 13px;
}
.correction-diff-dl dt {
  color: var(--text-muted);
  font-weight: 500;
}
.correction-diff-dl dd {
  margin: 0;
  color: var(--text);
  word-break: break-word;
}
.correction-diff-evidence {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}

.correction-modal-meta {
  margin: 16px 0 0;
  font-size: 11px;
  color: var(--text-muted);
}
.correction-modal-error {
  margin: 12px 0 0;
  padding: 10px 12px;
  font-size: 13px;
  color: #b91c1c;
  background: rgba(185, 28, 28, 0.06);
  border: 1px solid rgba(185, 28, 28, 0.25);
  border-radius: 6px;
}

.correction-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  background: var(--surface-alt);
}

body.correction-modal-open {
  overflow: hidden;
}

/* ── Journey-view: corrected element badge ───────────────────────── */

.element.is-corrected {
  position: relative;
  background: linear-gradient(
    90deg,
    rgba(45, 106, 79, 0.06) 0%,
    rgba(45, 106, 79, 0.0) 30%
  );
  border-left: 3px solid var(--accent-deep);
  padding-left: 10px;
}
.corrected-inline-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 500;
  color: var(--accent-deep);
  background: rgba(45, 106, 79, 0.10);
  border: 1px solid rgba(45, 106, 79, 0.35);
  border-radius: 999px;
  margin-left: 8px;
  white-space: nowrap;
}

/* Visible "corrected" pill on the step card — matches the panel badge */
.step-correction-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 500;
  color: var(--accent-deep);
  background: rgba(45, 106, 79, 0.10);
  border: 1px solid rgba(45, 106, 79, 0.35);
  border-radius: 999px;
  margin: 4px 0 6px;
  width: fit-content;
  white-space: nowrap;
  /* Make sure it doesn't overlap the absolute-positioned review-toggle in the
     top-right corner of the step. */
  max-width: calc(100% - 30px);
}
.step-correction-badge[hidden] { display: none; }

/* When the step has corrections, give the left border the same green hint
   as a reviewed step (still gets overridden by .is-reviewed if both apply). */
.step.step--has-correction {
  border-left-color: var(--accent-deep);
}

/* Mobile: diff stacks instead of side-by-side */
@media (max-width: 700px) {
  .correction-modal {
    /* Extra bottom padding accommodates the iOS Safari URL bar plus the
       device safe-area; otherwise the footer's Apply / Discard buttons
       end up half-hidden under the browser chrome. */
    padding: 12px 12px calc(80px + env(safe-area-inset-bottom, 0px));
  }
  .correction-modal-card {
    max-height: calc(100vh - 24px);
    max-height: calc(100dvh - 24px);
  }
  .correction-diff {
    grid-template-columns: 1fr;
  }
  .correction-diff-dl {
    grid-template-columns: 60px 1fr;
  }
}

/* ======================================================================
   "+ New Evaluation" modal on the home page
   ====================================================================== */

.new-eval-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.new-eval-modal[hidden] { display: none; }

.new-eval-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
}

.new-eval-modal-card {
  position: relative;
  width: min(680px, 100%);
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  overflow: hidden;
}

.new-eval-modal-header {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 16px;
  padding: 18px 24px 12px;
  border-bottom: 1px solid var(--border);
}
.new-eval-modal-eyebrow {
  grid-column: 1;
  margin: 0;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  font-weight: 600;
}
.new-eval-modal-title {
  grid-column: 1;
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}
.new-eval-modal-close {
  grid-row: 1 / span 2;
  grid-column: 2;
  background: transparent;
  border: none;
  font-size: 22px;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}
.new-eval-modal-close:hover {
  background: var(--surface-alt);
  color: var(--text);
}

.new-eval-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 24px 20px;
}

.new-eval-modal-hint {
  margin: 0 0 18px;
  font-size: 13px;
  color: var(--text-muted);
}

.briefing-group {
  margin: 0 0 18px;
}
.briefing-group-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 0 0 8px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 600;
}
.briefing-group-tag {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: none;
  padding: 2px 8px;
  border-radius: 999px;
  color: var(--text-muted);
  background: var(--surface-alt);
  border: 1px solid var(--border);
}

.briefing-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.briefing-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  transition: border-color 0.15s ease;
}
.briefing-card:hover {
  border-color: var(--accent-soft);
}
.briefing-card--disabled {
  background: var(--surface-alt);
  opacity: 0.75;
}
.briefing-card-text {
  flex: 1;
  min-width: 0;
}
.briefing-card-title {
  margin: 0 0 4px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.briefing-card-meta {
  margin: 0 0 2px;
  font-size: 12px;
  color: var(--text-muted);
}
.briefing-card-meta code {
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 11px;
}
.briefing-card-warning {
  color: var(--accent);
}

.new-eval-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  background: var(--surface-alt);
}

body.new-eval-modal-open { overflow: hidden; }

@media (max-width: 700px) {
  .new-eval-modal { padding: 12px; }
  .new-eval-modal-card { max-height: calc(100vh - 24px); }
  .briefing-card {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .briefing-card button { align-self: flex-end; }
}

/* ── Model picker (used in modal cards AND on the journey-view Re-run) ── */

.model-picker {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}
.model-picker-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 500;
}
.model-picker-select {
  font-family: inherit;
  font-size: 12px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 24px 4px 8px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path fill='%23666' d='M0 0l5 6 5-6z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 8px center;
}
.model-picker-select:hover {
  border-color: var(--accent);
}
.model-picker-select:focus {
  outline: 2px solid var(--accent-soft);
  outline-offset: 1px;
}
.model-picker-hint {
  margin: 4px 0 0;
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
}

/* Layout for the per-card model picker + Run button */
.briefing-card-run {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  min-width: 180px;
}
.briefing-card-run .btn {
  margin-top: 2px;
}

/* Layout for the Journey-view Re-run group */
.rerun-group {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px 4px 10px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.model-picker--rerun {
  color: var(--text-muted);
}
.model-picker--rerun .model-picker-label {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  font-size: 12px;
}

@media (max-width: 700px) {
  .briefing-card-run {
    align-items: stretch;
    min-width: 0;
  }
  .briefing-card-run .model-picker {
    justify-content: space-between;
  }
  .rerun-group {
    flex-wrap: wrap;
    width: 100%;
    justify-content: space-between;
  }
}

/* ======================================================================
   Persona Evaluation View
   Assertions grouped by persona field; completeness table; consistency list.
   ====================================================================== */

.section-subtitle {
  font-size: 14px;
  font-weight: 400;
  color: var(--text-muted);
  margin-left: 8px;
}

.assertion-groups {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  gap: 20px;
  align-items: start;
}
@media (max-width: 700px) {
  .assertion-groups { grid-template-columns: 1fr; gap: 16px; }
}

.assertion-group {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 18px 18px;
}

.assertion-group-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
}
.assertion-group-count {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--surface-alt);
  padding: 2px 8px;
  border-radius: 999px;
  text-transform: none;
  letter-spacing: 0;
}

.assertion-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.assertion {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 14px 12px 14px;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.assertion:hover {
  border-color: var(--accent-soft);
  box-shadow: var(--shadow-sm);
}
.assertion.is-open-in-panel {
  border-color: var(--accent);
  border-left-color: var(--accent);
  box-shadow: var(--shadow-md);
}
.assertion.is-reviewed { border-left-color: var(--accent-deep); }
.assertion.is-corrected { border-left-color: var(--accent-deep); }

.assertion-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}
.assertion-hint {
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.assertion:hover .assertion-hint { opacity: 1; }

.assertion-header {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 6px;
  padding-right: 26px; /* room for the review-toggle */
}
.assertion-id {
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 11px;
  color: var(--text-muted);
  background: var(--surface-alt);
  padding: 2px 6px;
  border-radius: 4px;
}

.assertion-content {
  margin: 4px 0 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.45;
}

.assertion-meta {
  margin: 0 0 8px;
  font-size: 11px;
  color: var(--text-muted);
}
.assertion-counts {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.count-support {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  background: rgba(45, 106, 79, 0.10);
  color: var(--accent-deep);
  border-radius: 4px;
  font-weight: 600;
}
.count-contradict {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  background: rgba(185, 28, 28, 0.08);
  color: #b91c1c;
  border-radius: 4px;
  font-weight: 600;
}

.assertion-evidence {
  font-size: 12px;
  line-height: 1.55;
  color: var(--text-muted);
  background: var(--surface-alt);
  padding: 8px 10px;
  border-radius: 6px;
  border-left: 2px solid var(--border);
}
.assertion-evidence code {
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 11px;
}

/* ── Completeness table ── */

/* Wrap the table in a horizontal scroller so the mobile viewport doesn't
   simply clip the right-hand columns. The table keeps its readable
   min-width; the user can swipe sideways inside its container. */
.completeness-table {
  display: block;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 13px;
}
.completeness-table > thead,
.completeness-table > tbody {
  display: table;
  width: 100%;
  min-width: 520px;
}
@media (max-width: 700px) {
  .completeness-table th,
  .completeness-table td { padding: 9px 12px; }
  .completeness-field { white-space: nowrap; }
}
.completeness-table th,
.completeness-table td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.completeness-table thead th {
  background: var(--surface-alt);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  color: var(--text-muted);
}
.completeness-table tbody tr:last-child td { border-bottom: none; }

.completeness-field {
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
  color: var(--text);
}
.completeness-note {
  color: var(--text-muted);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 500;
  border-radius: 999px;
  white-space: nowrap;
}
.status-pill--ok {
  color: var(--accent-deep);
  background: rgba(45, 106, 79, 0.10);
  border: 1px solid rgba(45, 106, 79, 0.30);
}
.status-pill--thin {
  color: #b45309;
  background: rgba(217, 119, 6, 0.10);
  border: 1px solid rgba(217, 119, 6, 0.30);
}
.status-pill--missing {
  color: #b91c1c;
  background: rgba(185, 28, 28, 0.08);
  border: 1px solid rgba(185, 28, 28, 0.25);
}

/* ── Consistency findings ── */

.consistency-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.consistency-finding {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}
.consistency-finding-body {
  margin: 0 0 6px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
}
.consistency-finding-refs {
  margin: 0;
  font-size: 11px;
  color: var(--text-muted);
}
.consistency-finding-refs code {
  font-family: "SF Mono", Menlo, Consolas, monospace;
  background: var(--surface-alt);
  padding: 1px 6px;
  border-radius: 4px;
}

/* ======================================================================
   Evaluation tabs
   Scorecard stays above; everything else is sliced into tabs so a long
   page with 67 assertions doesn't dominate the scroll-space.
   ====================================================================== */

.eval-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  margin: 24px 0 0;
  padding: 0;
}

.eval-tab {
  position: relative;
  appearance: none;
  background: transparent;
  border: none;
  padding: 12px 16px 14px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;        /* align underline with .eval-tabs border */
  transition: color 0.12s ease, border-color 0.12s ease;
}
.eval-tab:hover {
  color: var(--text);
}
.eval-tab.is-active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.eval-tab-count {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--surface-alt);
  border-radius: 999px;
  vertical-align: 1px;
}
.eval-tab.is-active .eval-tab-count {
  background: var(--accent-soft);
  color: var(--accent);
}

.eval-tab-pane {
  /* The tab pane inherits .section styling; nothing extra needed. */
}
.eval-tab-pane[hidden] { display: none; }

@media (max-width: 700px) {
  .eval-tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    margin-left: -8px;
    margin-right: -8px;
    padding-left: 8px;
    padding-right: 8px;
  }
  .eval-tab { white-space: nowrap; padding: 10px 12px 12px; }
}
