:root {
  --bg: #f8f9fb;
  --surface: #ffffff;
  --border: #e2e5ea;
  --text: #1a1d23;
  --text-secondary: #5f6776;
  --text-muted: #8b92a0;
  --green: #16a34a;
  --green-bg: #dcfce7;
  --green-border: #bbf7d0;
  --yellow: #ca8a04;
  --yellow-bg: #fef9c3;
  --yellow-border: #fef08a;
  --red: #dc2626;
  --red-bg: #fee2e2;
  --red-border: #fecaca;
  --blue: #2563eb;
  --blue-bg: #dbeafe;
  --blue-border: #bfdbfe;
  --purple: #7c3aed;
  --purple-bg: #ede9fe;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.12);
  --transition: 0.2s ease;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  /* Suppress horizontal scroll from 50vw-based full-bleed breakouts interacting
     with the vertical scrollbar width. `clip` does not establish a scroll
     container, so position: sticky still works as expected. */
  overflow-x: clip;
}

/* ===== Top bar ===== */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 32px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}
.topbar-left { display: flex; align-items: center; gap: 24px; }
.logo {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}
.logo svg { width: 22px; height: 22px; }
.topbar-nav { display: flex; gap: 4px; }
.topbar-nav a {
  background: none;
  border: none;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-secondary);
  cursor: pointer;
  font-weight: 500;
  transition: var(--transition);
  text-decoration: none;
}
.topbar-nav a { position: relative; }
.topbar-nav a:hover { background: var(--bg); color: var(--text); }
.topbar-nav a.active { background: var(--bg); color: var(--text); }
.nav-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--blue);
  margin-left: 4px;
  vertical-align: top;
  margin-top: 1px;
}
.topbar-right { display: flex; align-items: center; gap: 16px; }
.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--blue-bg);
  color: var(--blue);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600;
}
.user-name { font-size: 14px; color: var(--text-secondary); }
.topbar-logout {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  transition: var(--transition);
}
.topbar-logout:hover { color: var(--text); background: var(--bg); }

/* ===== Main content ===== */
.main { max-width: 960px; margin: 0 auto; padding: 32px 24px 80px; }

/* ===== View transitions ===== */
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
.page-content { animation: fadeIn 0.2s ease; }

/* ===== Trust status summary ===== */
.trust-summary { display: flex; gap: 16px; margin-bottom: 32px; }
.trust-card {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  color: inherit;
}
.trust-card:hover { box-shadow: var(--shadow-md); border-color: transparent; }
.trust-dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}
.trust-dot.green { background: var(--green); }
.trust-dot.yellow { background: var(--yellow); }
.trust-dot.red { background: var(--red); }
.trust-count { font-size: 28px; font-weight: 700; line-height: 1; }
.trust-label { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }
.trust-meta { font-size: 12px; color: var(--text-muted); margin-bottom: 32px; }

/* ===== Section headers ===== */
.section-header {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-header .count {
  background: var(--red-bg);
  color: var(--red);
  font-size: 12px;
  font-weight: 600;
  padding: 1px 8px;
  border-radius: 10px;
}

/* ===== Drift cards ===== */
.drift-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 12px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  color: inherit;
}
.drift-card:hover { box-shadow: var(--shadow-md); border-color: transparent; }
.drift-indicator {
  width: 10px; height: 10px;
  border-radius: 50%;
  margin-top: 6px;
  flex-shrink: 0;
}
.drift-indicator.red { background: var(--red); }
.drift-indicator.yellow { background: var(--yellow); }
.drift-body { flex: 1; }
.drift-title { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.drift-desc { font-size: 14px; color: var(--text-secondary); margin-bottom: 8px; }
.drift-meta { font-size: 12px; color: var(--text-muted); display: flex; gap: 16px; flex-wrap: wrap; }
.drift-action {
  align-self: center;
  padding: 7px 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  text-decoration: none;
}
.drift-action:hover { background: var(--surface); border-color: var(--blue); color: var(--blue); }

/* ===== Back button ===== */
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--text-secondary);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 0;
  margin-bottom: 24px;
  transition: var(--transition);
  text-decoration: none;
}
.back-btn:hover { color: var(--text); }
.back-btn svg { width: 16px; height: 16px; }

/* ===== Review page ===== */
.review-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}
.save-status {
  font-size: 13px;
  font-weight: 500;
  margin-left: auto;
  transition: opacity 0.3s ease;
}
.save-status:empty { opacity: 0; }
.save-status.saving { color: var(--text-muted); }
.save-status.saved { color: var(--green, #22c55e); }
.save-status.error { color: var(--red, #ef4444); }
.review-title { font-size: 22px; font-weight: 700; }
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
}
.badge.red { background: var(--red-bg); color: var(--red); }
.badge.yellow { background: var(--yellow-bg); color: var(--yellow); }
.badge.green { background: var(--green-bg); color: var(--green); }
.badge.blue { background: var(--blue-bg); color: var(--blue); }
.review-subtitle { font-size: 14px; color: var(--text-muted); margin-bottom: 28px; }

/* ===== Comparison columns ===== */
.comparison {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
  margin-bottom: 28px;
}
.comp-col {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.comp-col-header {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.comp-col-body { font-size: 14px; line-height: 1.7; color: var(--text); }
.comp-col.intended { border-top: 3px solid var(--blue); }
.comp-col.current { border-top: 3px solid var(--red); }
.comp-col.changed { border-top: 3px solid var(--yellow); }

/* ===== Explanation box ===== */
.explanation-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 16px;
}
.explanation-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.explanation-text { font-size: 14px; line-height: 1.7; color: var(--text-secondary); }
.evidence-box {
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-top: 14px;
}
.evidence-label { font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; }
.evidence-item { font-size: 13px; color: var(--text-secondary); padding: 2px 0; }
.evidence-item::before { content: "\b7"; margin-right: 8px; color: var(--text-muted); }

/* ===== Action buttons ===== */
.actions {
  display: flex;
  gap: 12px;
  margin-top: 28px;
}
.btn {
  padding: 10px 24px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  border: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}
.btn-primary { background: var(--green); color: #fff; }
.btn-primary:hover { background: #15803d; }
.btn-danger { background: var(--red); color: #fff; border: 1px solid var(--red); }
.btn-danger:hover { background: #b91c1c; }
.btn-danger-outline { background: transparent; color: var(--red); border: 1px solid var(--red-border); }
.btn-danger-outline:hover { background: var(--red-bg); }
.btn-secondary { background: var(--surface); color: var(--text-secondary); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg); }
.btn-blue { background: var(--blue); color: #fff; }
.btn-blue:hover { background: #1d4ed8; }

/* ===== Modal ===== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 200;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.15s ease;
}
.modal-overlay.active { display: flex; }
.modal {
  background: var(--surface);
  border-radius: 14px;
  padding: 32px;
  max-width: 520px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.2s ease;
}
@keyframes slideUp { from { transform: translateY(12px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-title { font-size: 18px; font-weight: 700; margin-bottom: 20px; }
.modal-list { list-style: none; margin-bottom: 20px; }
.modal-list li {
  padding: 6px 0;
  font-size: 14px;
  color: var(--text);
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.modal-list li::before { content: "\2022"; color: var(--text-muted); flex-shrink: 0; }
.modal-will { margin-bottom: 20px; }
.modal-will-label { font-size: 13px; font-weight: 600; color: var(--text-muted); margin-bottom: 8px; }
.modal-will-item {
  font-size: 14px;
  color: var(--green);
  padding: 3px 0;
  display: flex;
  align-items: center;
  gap: 6px;
}
.modal-will-item svg { width: 14px; height: 14px; flex-shrink: 0; }
.modal-note { margin-bottom: 24px; }
.modal-note label { font-size: 13px; color: var(--text-secondary); display: block; margin-bottom: 6px; }
.modal-note textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  min-height: 70px;
  line-height: 1.5;
  color: var(--text);
}
.modal-note textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-bg); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* ===== Feature/Intent card page ===== */
.feature-goal {
  margin-bottom: 20px;
  padding: 16px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.feature-goal-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.feature-goal-text { font-size: 15px; line-height: 1.6; }

.behavior-list { margin-bottom: 28px; }
.behavior-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 8px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.behavior-check {
  width: 20px; height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}
.behavior-check.green { background: var(--green-bg); color: var(--green); }
.behavior-check.yellow { background: var(--yellow-bg); color: var(--yellow); }
.behavior-check.red { background: var(--red-bg); color: var(--red); }
.behavior-check.gray { background: var(--bg); color: var(--text-muted); }
.behavior-check svg { width: 12px; height: 12px; }
.behavior-text { font-size: 14px; }
.behavior-detail { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.clause-detail { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* Rendered markdown in view mode */
.markdown-content { font-size: 14px; line-height: 1.6; }
.markdown-content p { margin: 0; }
.markdown-content p + p { margin-top: 6px; }
.markdown-content ul, .markdown-content ol { padding-left: 22px; margin: 4px 0; }
.markdown-content li { margin: 2px 0; }
.markdown-content strong { font-weight: 600; color: var(--text); }
.markdown-content em { font-style: italic; }
.markdown-content table {
  border-collapse: collapse;
  width: 100%;
  margin: 8px 0;
  font-size: 13px;
}
.markdown-content td, .markdown-content th {
  border: 1px solid var(--border);
  padding: 6px 10px;
  text-align: left;
}
.markdown-content th {
  background: var(--bg);
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.markdown-content del { text-decoration: line-through; color: var(--text-muted); }
.markdown-content code {
  background: var(--bg);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 13px;
}

/* ===== Tabs ===== */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
}
.tab {
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: var(--transition);
  text-decoration: none;
}
.tab:hover { color: var(--text-secondary); }
.tab.active { color: var(--text); border-bottom-color: var(--text); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ===== Timeline ===== */
.timeline { padding: 0; }
.timeline-item {
  display: flex;
  gap: 16px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}
.timeline-item:last-child { border-bottom: none; }
.timeline-icon {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.timeline-icon.drift { background: var(--red-bg); color: var(--red); }
.timeline-icon.decision { background: var(--green-bg); color: var(--green); }
.timeline-icon.spec { background: var(--blue-bg); color: var(--blue); }
.timeline-icon.flag { background: var(--yellow-bg); color: var(--yellow); }
.timeline-icon svg { width: 16px; height: 16px; }
.timeline-date { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.timeline-title { font-size: 14px; font-weight: 500; }
.timeline-desc { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }
.timeline-note {
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 8px;
  font-style: italic;
}

/* ===== Specs list ===== */
.specs-list { margin-top: 8px; }
.spec-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  color: inherit;
}
.spec-row:hover { box-shadow: var(--shadow); border-color: transparent; }
.spec-row-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.spec-row-name { font-size: 14px; font-weight: 600; flex: 1; }
.spec-row-meta { font-size: 13px; color: var(--text-muted); }
.spec-row-owner { font-size: 13px; color: var(--text-secondary); }

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 32px;
  right: 32px;
  background: var(--text);
  color: #fff;
  padding: 14px 24px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 300;
  display: none;
  align-items: center;
  gap: 8px;
  animation: slideUp 0.3s ease;
}
.toast.active { display: flex; }
.toast svg { width: 18px; height: 18px; }

/* ===== Acceptance criteria list ===== */
.criteria-list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.criteria-item {
  padding: 8px 0;
  font-size: 14px;
  color: var(--text-secondary);
  display: flex;
  align-items: flex-start;
  gap: 8px;
  border-bottom: 1px solid var(--bg);
}
.criteria-item:last-child { border-bottom: none; }
.criteria-check { color: var(--green); flex-shrink: 0; margin-top: 2px; }
.criteria-check.green { color: var(--green); }
.criteria-check.red { color: var(--red); }
.criteria-check.gray { color: var(--text-muted); }
.criteria-check svg { width: 14px; height: 14px; }

/* ===== Empty state ===== */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.empty-state svg { width: 48px; height: 48px; margin-bottom: 16px; color: var(--green); }
.empty-state h3 { font-size: 16px; color: var(--text-secondary); margin-bottom: 6px; }
.empty-state p { font-size: 14px; }

/* ===== Editor ===== */
.spec-initial-source {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* =========================
   Google-Docs-style spec view
   ========================= */

.spec-app {
  display: block;
  /* The spec-chrome is fixed at the top of the viewport; cancel .main padding-top
     and reserve room for the fixed chrome so content doesn't slide underneath.
     Cancel .main's bottom padding so the document page is flush with the viewport bottom. */
  margin-top: -32px;
  margin-bottom: -80px;
  padding-top: 54px;
}

.spec-chrome {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 24px;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 30;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.spec-chrome-back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: var(--text-secondary);
  text-decoration: none;
  flex-shrink: 0;
  transition: var(--transition);
}
.spec-chrome-back:hover {
  background: var(--border);
  color: var(--text);
}
.spec-chrome-back svg { width: 18px; height: 18px; }

.spec-chrome-title-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
}
.spec-chrome-title {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  padding: 6px 10px;
  font-size: 18px;
  font-weight: 600;
  font-family: inherit;
  color: var(--text);
  border-radius: var(--radius-sm);
  transition: var(--transition);
}
.spec-chrome-title::placeholder {
  color: var(--text-muted);
  font-weight: 500;
}
.spec-chrome-title:hover {
  border-color: var(--border);
}
.spec-chrome-title:focus {
  outline: none;
  border-color: var(--blue);
  background: var(--surface);
}

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

.spec-chrome-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
}
.spec-chrome-btn:hover {
  background: var(--border);
  color: var(--text);
}
.spec-chrome-btn svg { width: 18px; height: 18px; }

/* User menu embedded in the spec chrome (replaces the global topbar) */
.spec-chrome-divider {
  display: inline-block;
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 4px;
}
.spec-chrome-user {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.spec-chrome-user .user-name {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
}
.spec-chrome-user .avatar {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}
.spec-chrome-user form {
  display: inline-flex;
}

/* Kebab popover */
.spec-chrome-menu-wrap {
  position: relative;
}
.spec-chrome-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 240px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 8px;
  z-index: 40;
}
.spec-chrome-menu[hidden] { display: none; }
.spec-menu-section {
  padding: 6px 8px 8px;
}
.spec-menu-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.spec-menu-input {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
}
.spec-menu-input:focus {
  outline: none;
  border-color: var(--blue);
}
.spec-menu-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}
.spec-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text);
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  transition: var(--transition);
}
.spec-menu-item svg { width: 16px; height: 16px; color: var(--text-secondary); flex-shrink: 0; }
.spec-menu-item:hover { background: var(--bg); }
.spec-menu-item.is-busy { opacity: 0.6; cursor: default; }
.spec-menu-item--danger { color: var(--red); }
.spec-menu-item--danger svg { color: var(--red); }
.spec-menu-item--danger:hover { background: var(--red-bg); }

/* Sticky formatting toolbar (visually merged with chrome above) */
.spec-toolbar-wrap {
  position: sticky;
  top: 54px; /* below spec-chrome (~54) */
  z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 4px 24px;
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
}
.spec-toolbar {
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 2px;
  max-width: none;
  margin: 0;
}
.spec-toolbar .tiptap-toolbar {
  border-bottom: none;
  background: transparent;
  padding: 0;
  margin: 0;
  flex: 1;
}

/* Centered document page + gutter */
.spec-page-wrap {
  display: flex;
  justify-content: center;
  align-items: stretch;
  gap: 10px;
  padding: 24px 0 0;
  /* Fill the viewport below the fixed chrome (~54) + sticky toolbar (~37). */
  min-height: calc(100vh - 91px);
  /* Positioning context for the absolutely-placed comments column so it can
     appear on the right without shifting the centered .spec-page. */
  position: relative;
}
.spec-gutter {
  position: relative;
  width: 10px;
  flex-shrink: 0;
  align-self: stretch;
  pointer-events: none;
}
.spec-gutter-dot {
  position: absolute;
  left: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  transform: translateY(-50%);
  box-shadow: 0 0 0 2px var(--bg);
  pointer-events: auto;
  cursor: help;
}
.spec-gutter-dot--green { background: var(--green); }
.spec-gutter-dot--red { background: var(--red); }
.spec-gutter-dot--yellow { background: var(--yellow); }
.spec-gutter-dot--gray { background: var(--text-muted); opacity: 0.5; }
.spec-gutter-dot--empty { background: transparent; border: 1px solid var(--text-muted); opacity: 0.6; }

.spec-page {
  position: relative;
  width: 100%;
  max-width: 720px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0;
  box-shadow: var(--shadow);
  min-height: 0;
}

/* --- Inline comments -------------------------------------------------------
   Comment threads render as floating boxes anchored under the block they
   reference. #spec-comments-list is an overlay layer spanning .spec-page; the
   editor positions each card with an absolute `top`. Boxes may overlap the
   content below them — each has a clear border and a close (×) button. A
   right-hand gutter holds speech-bubble markers that toggle a block's boxes. */

/* Right-hand gutter with speech-bubble markers (mirrors the left status gutter). */
.spec-comment-gutter {
  position: relative;
  width: 30px;
  flex-shrink: 0;
  align-self: stretch;
}
.spec-comment-marker {
  position: absolute;
  left: 2px;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px 5px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-secondary);
  box-shadow: var(--shadow);
  cursor: pointer;
  transform: translateY(-2px);
  transition: var(--transition);
  font: inherit;
  line-height: 1;
}
.spec-comment-marker:hover { color: var(--text); border-color: var(--text-muted); }
.spec-comment-marker.is-open {
  color: var(--blue);
  border-color: var(--blue);
  background: var(--blue-bg);
}
.spec-comment-marker-count { font-size: 11px; font-weight: 600; }
@media (max-width: 900px) {
  .spec-comment-gutter { display: none; }
}

/* Overlay layer: spans the page, lets clicks fall through except on boxes. */
.spec-comments-list {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 12;
}
.spec-comments-empty { display: none; }

/* Floating comment box. */
.spec-comment-card {
  position: absolute;
  display: none;
  left: 48px;
  width: min(380px, calc(100% - 72px));
  pointer-events: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 10px 12px;
  cursor: pointer;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.spec-comment-card:hover { border-color: var(--text-muted); }
.spec-comment-card.is-active {
  border-color: var(--blue);
  box-shadow: 0 0 0 2px var(--blue-bg), var(--shadow);
}
.spec-comment-card.is-resolved { display: none; }
.spec-comment-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 4px;
}
.spec-comment-head .spec-comment-time { margin-left: auto; }
.spec-comment-box-close {
  flex-shrink: 0;
  align-self: flex-start;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 16px;
  line-height: 1;
  padding: 0 2px;
  cursor: pointer;
}
.spec-comment-box-close:hover { color: var(--text); }

/* Inline composer (shown when adding a comment). */
.spec-comment-box-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.spec-comment-box-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.spec-comment-box-head .spec-comment-box-close { margin-left: auto; }
.spec-comment-composer {
  position: absolute;
  display: block;
  left: 48px;
  width: min(380px, calc(100% - 72px));
  pointer-events: auto;
  background: var(--surface);
  border: 1px solid var(--blue);
  border-radius: var(--radius);
  box-shadow: 0 0 0 2px var(--blue-bg), var(--shadow);
  padding: 10px 12px;
  z-index: 14;
}
.spec-comment-composer-input {
  width: 100%;
  box-sizing: border-box;
  resize: vertical;
  font: inherit;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  margin: 4px 0;
  background: var(--bg);
  color: var(--text);
}

/* Floating "Add comment" button shown next to a non-empty selection. */
.spec-comment-add-floating {
  position: absolute;
  z-index: 30;
  display: none;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  background: var(--blue);
  border: none;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  cursor: pointer;
}
.spec-comment-add-floating:hover { filter: brightness(1.05); }
.spec-comment-author {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.spec-comment-time {
  font-size: 11px;
  color: var(--text-muted);
}
.spec-comment-quote {
  margin: 4px 0;
  padding: 4px 8px;
  border-left: 2px solid var(--yellow);
  background: var(--yellow-bg);
  font-size: 12px;
  color: var(--text-secondary);
  font-style: italic;
  max-height: 3.6em;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}
.spec-comment-body {
  font-size: 13px;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}
.spec-comment-actions {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 6px;
}
.spec-comment-btn {
  font-size: 11px;
  padding: 3px 8px;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
}
.spec-comment-btn:hover {
  background: var(--border);
  color: var(--text);
}
.spec-comment-btn--danger:hover {
  background: var(--red-bg);
  color: var(--red);
}

/* Inline anchor highlighting in the editor. */
.tiptap-unified-doc-editor .comment-anchor,
.tiptap-doc-mount-inner .comment-anchor {
  background: var(--yellow-bg);
  border-bottom: 2px solid var(--yellow);
  border-radius: 2px;
  cursor: pointer;
  transition: background 120ms ease;
}
.tiptap-unified-doc-editor .comment-anchor:hover,
.tiptap-doc-mount-inner .comment-anchor:hover,
.tiptap-unified-doc-editor .comment-anchor.is-active,
.tiptap-doc-mount-inner .comment-anchor.is-active {
  background: var(--yellow-border);
}
.spec-doc-mount {
  display: block;
}
.tiptap-unified-doc-editor.ProseMirror {
  min-height: 560px;
  padding: 56px 64px 80px;
  font-size: 15px;
  line-height: 1.65;
}
.tiptap-doc-mount-inner .ProseMirror {
  min-height: 560px;
  padding: 56px 64px 80px;
  font-size: 15px;
  line-height: 1.65;
}

/* Right-hand slide-over side panel */
.spec-side-panel {
  position: fixed;
  top: 56px; /* below global topbar */
  right: 0;
  bottom: 0;
  width: 360px;
  max-width: 92vw;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  z-index: 50;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.2s ease;
}
.spec-side-panel.is-open {
  transform: translateX(0);
}
.spec-side-panel[hidden] {
  display: none;
}
.spec-side-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.spec-side-panel-title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.spec-side-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px 24px;
}

.spec-panel-content[hidden] { display: none; }
.spec-panel-empty {
  font-size: 13px;
  color: var(--text-muted);
  padding: 16px 4px;
  line-height: 1.5;
}
.spec-panel-empty code {
  font-size: 12px;
  background: var(--bg);
  padding: 1px 5px;
  border-radius: 4px;
}
.spec-panel-loading {
  font-size: 13px;
  color: var(--text-muted);
  padding: 16px 4px;
}

.spec-sections-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.spec-sections-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 4px;
  border-radius: var(--radius-sm);
}
.spec-sections-item:hover { background: var(--bg); }
.spec-sections-item--h3 { padding-left: 20px; }
.spec-sections-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.spec-sections-dot--green { background: var(--green); }
.spec-sections-dot--red { background: var(--red); }
.spec-sections-dot--yellow { background: var(--yellow); }
.spec-sections-dot--gray { background: var(--text-muted); opacity: 0.5; }
.spec-sections-dot--empty { background: transparent; border: 1px solid var(--text-muted); opacity: 0.6; }
.spec-sections-link {
  flex: 1;
  min-width: 0;
  text-align: left;
  border: none;
  background: transparent;
  padding: 0;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.spec-sections-link:hover {
  color: var(--blue);
}
.spec-sections-status {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

/* Desktop: keep the main spec scrollable while the side panel (review/sections/
   history) is open. Mobile full-bleed panel still locks body scroll below. */

/* Spec AI review bar + panel */
.spec-review-bar {
  position: sticky;
  bottom: 0;
  z-index: 20;
  display: flex;
  justify-content: center;
  padding: 12px 16px 20px;
  background: linear-gradient(to top, var(--bg) 60%, transparent);
  pointer-events: none;
}
.spec-review-bar-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  pointer-events: auto;
}
.spec-review-bar .btn {
  min-width: 120px;
  box-shadow: var(--shadow);
}
.spec-review-log-link {
  font-size: 13px;
  color: var(--blue);
  text-decoration: none;
  padding: 0 4px;
}
.spec-review-log-link:hover { text-decoration: underline; }
a.spec-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: inherit;
}
.review-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 100%;
}
.review-section-meta {
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.review-section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}
.review-section-title {
  font-size: 14px;
  font-weight: 600;
  margin-top: 2px;
}
.review-section-goal {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
  line-height: 1.4;
}
.review-section-progress {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
}
.review-messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}
.review-msg {
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 13px;
  line-height: 1.45;
}
.review-msg--assistant {
  background: var(--bg);
  border: 1px solid var(--border);
}
.review-msg--user {
  background: color-mix(in srgb, var(--blue) 10%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--blue) 25%, var(--border));
}
.review-msg-role {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.review-msg-body {
  white-space: pre-wrap;
  color: var(--text);
}
.review-composer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.review-composer-input {
  width: 100%;
  resize: vertical;
  min-height: 72px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 13px;
  color: var(--text);
  background: var(--surface);
}
.review-composer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.btn-sm {
  padding: 6px 10px;
  font-size: 12px;
}
.review-tokens {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  font-size: 11px;
  color: var(--text-muted);
  padding-top: 4px;
}
.review-token-model {
  font-family: ui-monospace, monospace;
}
.review-est-cost {
  color: var(--text-secondary);
}
.review-est-cost strong {
  color: var(--text);
  font-weight: 600;
}
.review-est-rates {
  color: var(--text-muted);
}
.review-log-link {
  margin-left: auto;
  color: var(--blue);
  text-decoration: none;
}
.review-log-link:hover { text-decoration: underline; }
.review-busy {
  color: var(--blue);
  font-weight: 600;
}
.review-error {
  padding: 12px;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--red) 10%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--red) 30%, var(--border));
  font-size: 13px;
  line-height: 1.45;
}
.review-error-hint {
  margin-top: 8px;
}
.review-complete {
  padding: 12px 0;
  font-size: 13px;
  line-height: 1.5;
}
.review-complete .btn { margin-top: 10px; }

/* Active AI-review section overlay (sibling of the editor, not inside PM) */
.review-section-overlay {
  position: absolute;
  left: 8px;
  right: 8px;
  top: 0;
  height: 0;
  pointer-events: none;
  z-index: 2;
  border-radius: 6px;
  background: rgba(37, 99, 235, 0.14);
  border-left: 4px solid var(--blue, #2563eb);
  box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.25);
  opacity: 0;
  transition: opacity 0.15s ease;
}
.review-section-overlay.is-visible {
  opacity: 1;
}
.tiptap-unified-doc-editor.ProseMirror h1,
.tiptap-unified-doc-editor.ProseMirror h2,
.tiptap-unified-doc-editor.ProseMirror h3 {
  scroll-margin-top: 120px;
}

/* Review panel needs a bit more width for chat */
body.spec-side-panel-open .spec-side-panel:has(#review-panel:not([hidden])) {
  width: 400px;
}

@media (max-width: 800px) {
  .spec-gutter { display: none; }
  .spec-chrome-title { font-size: 16px; }
  .tiptap-unified-doc-editor.ProseMirror,
  .tiptap-doc-mount-inner .ProseMirror {
    padding: 32px 20px 48px;
  }
  .spec-side-panel {
    top: 0;
    width: 100%;
  }
  body.spec-side-panel-open {
    overflow: hidden;
  }
}

.field-group { display: flex; flex-direction: column; gap: 4px; }
.field-group label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}
.field-group input,
.field-group select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
}
.field-group input:focus,
.field-group select:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-bg);
}

.editor-section {
  margin-bottom: 24px;
}
.editor-section-header {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.editor-section-header button {
  font-size: 12px;
  color: var(--blue);
  background: none;
  border: none;
  cursor: pointer;
  font-weight: 500;
}
.editor-section-header button:hover { text-decoration: underline; }

.statement-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  background: var(--surface);
  position: relative;
  transition: var(--transition);
}
.statement-item:hover { border-color: var(--blue-border); }
.statement-item:focus-within { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-bg); }
.statement-bullet {
  color: var(--text-muted);
  margin-top: 2px;
  flex-shrink: 0;
  user-select: none;
}
.statement-input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 14px;
  font-family: inherit;
  line-height: 1.5;
  color: var(--text);
  resize: none;
  min-height: 22px;
  background: transparent;
}
/* ===== Three-dot dropdown menu ===== */
.statement-menu {
  position: relative;
  flex-shrink: 0;
}
.menu-trigger {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  transition: var(--transition);
  letter-spacing: 1px;
  line-height: 1;
  opacity: 0;
}
.statement-item:hover .menu-trigger,
.statement-item:focus-within .menu-trigger,
.menu-trigger.active,
.menu-trigger.loading {
  opacity: 1;
}
.menu-trigger:hover { background: var(--bg); color: var(--text); }
.menu-trigger.active { background: var(--bg); color: var(--text); }
.menu-trigger.loading {
  pointer-events: none;
  color: var(--purple);
  animation: spin 0.8s linear infinite;
}
@keyframes menuPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
.menu-trigger.loading { animation: menuPulse 1s ease-in-out infinite; }

.menu-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  z-index: 50;
  min-width: 160px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 4px;
  margin-top: 4px;
}
.menu-dropdown.open { display: block; animation: fadeIn 0.12s ease; }

.menu-dropdown button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  border: none;
  background: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: var(--transition);
}
.menu-dropdown button:hover { background: var(--bg); }
.menu-dropdown button svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  color: var(--text-muted);
}
.menu-dropdown button:hover svg { color: var(--purple); }
.menu-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}
.menu-danger { color: var(--red) !important; }
.menu-danger:hover { background: var(--red-bg) !important; }
.menu-danger svg { color: var(--red) !important; }

.ai-suggestion {
  background: var(--blue-bg);
  border: 1px solid var(--blue-border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-top: 6px;
  margin-bottom: 6px;
}
.ai-suggestion-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--blue);
  margin-bottom: 6px;
}
.ai-suggestion-text { font-size: 14px; color: var(--text); line-height: 1.5; }
.ai-suggestion-actions { display: flex; gap: 8px; margin-top: 8px; }
.ai-suggestion-actions button {
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 500;
  border-radius: 4px;
  cursor: pointer;
  border: none;
  transition: var(--transition);
}
.ai-accept { background: var(--green); color: #fff; }
.ai-accept:hover { background: #15803d; }
.ai-reject { background: var(--surface); color: var(--text-secondary); border: 1px solid var(--border); }
.ai-reject:hover { background: var(--bg); }

/* ===== Loading indicator ===== */
.htmx-indicator {
  display: none;
}
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  display: inline-block;
}
.spinner {
  width: 16px; height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.htmx-request #tab-content {
  opacity: 0.5;
  transition: opacity 0.15s;
}

.ai-loading {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--purple);
  padding: 4px 8px;
}
.ai-loading .spinner {
  width: 12px; height: 12px;
  border-width: 1.5px;
  border-top-color: var(--purple);
}

/* ===== Page header ===== */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}
.page-title { font-size: 20px; font-weight: 700; }

/* ===== Constraints list ===== */
.constraints-list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.constraint-item {
  padding: 8px 0;
  font-size: 14px;
  color: var(--text-secondary);
  display: flex;
  align-items: flex-start;
  gap: 8px;
  border-bottom: 1px solid var(--bg);
}
.constraint-item:last-child { border-bottom: none; }
.constraint-icon { color: var(--yellow); flex-shrink: 0; margin-top: 2px; }
.constraint-icon.green { color: var(--green); }
.constraint-icon.red { color: var(--red); }
.constraint-icon.gray { color: var(--text-muted); }
.constraint-icon svg { width: 14px; height: 14px; }

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .topbar { padding: 0 16px; }
  .main { padding: 20px 16px 60px; }
  .spec-app { margin-top: -20px; margin-bottom: -60px; padding-top: 50px; }
  .spec-chrome { padding: 6px 16px; }
  .spec-toolbar-wrap { padding: 4px 16px; top: 50px; }
  .spec-page-wrap { min-height: calc(100vh - 87px); }
  .trust-summary { flex-direction: column; gap: 8px; }
  .comparison { grid-template-columns: 1fr; }
  .actions { flex-direction: column; }
  .actions .btn { width: 100%; justify-content: center; }
  .drift-card { flex-direction: column; gap: 12px; }
  .drift-action { align-self: flex-start; }
  .modal { margin: 16px; max-width: none; }
}

/* ===== Settings page ===== */
.settings-form { max-width: 640px; }
.settings-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
}
.settings-section-header {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.settings-icon { width: 22px; height: 22px; color: var(--text-secondary); }
.settings-description {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 20px;
}
.settings-status-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
}
.status-badge.connected { background: var(--green-bg); color: var(--green); }
.status-badge.disconnected { background: var(--bg); color: var(--text-muted); }
.settings-fields {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 24px;
}
.settings-fields .field-group input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
}
.settings-fields .field-group input:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-bg);
}
.field-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}
.field-hint a { color: var(--blue); text-decoration: none; }
.field-hint a:hover { text-decoration: underline; }
.field-hint code {
  background: var(--bg);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 11px;
}
.field-group-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.settings-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}


/* ===== Settings gear icon (topbar) ===== */
.topbar-settings {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  transition: var(--transition);
  text-decoration: none;
}
.topbar-settings:hover { background: var(--bg); color: var(--text); }
.topbar-settings svg { width: 18px; height: 18px; }

/* ===== GitHub error banner ===== */
.gh-error-banner {
  background: var(--red-bg);
  border-bottom: 1px solid var(--red-border);
  padding: 10px 32px;
  font-size: 13px;
  color: var(--red);
  display: flex;
  align-items: center;
  gap: 8px;
}
.gh-error-banner svg { width: 16px; height: 16px; flex-shrink: 0; }
.gh-error-banner span { flex: 1; }
.gh-error-banner a {
  color: var(--red);
  font-weight: 600;
  text-decoration: underline;
  white-space: nowrap;
}

/* ===== Pending changes banner ===== */
.pending-banner {
  background: var(--blue-bg);
  border: 1px solid var(--blue-border);
  border-radius: var(--radius);
  padding: 14px 20px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.pending-banner-text {
  font-size: 14px;
  color: var(--blue);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
}
.pending-banner-text svg { width: 18px; height: 18px; flex-shrink: 0; }

/* ===== Submit preview modal ===== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: backdropIn 0.15s ease;
}
@keyframes backdropIn { from { opacity: 0; } to { opacity: 1; } }
.modal-backdrop .dialog {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 500px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 64px);
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
  animation: dialogIn 0.2s ease;
}
@keyframes dialogIn { from { transform: translateY(12px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 0;
  flex-shrink: 0;
}
.dialog-header h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}
.dialog-close {
  background: none;
  border: none;
  font-size: 22px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}
.dialog-close:hover { color: var(--text); }
.dialog-body {
  padding: 16px 24px;
  overflow-y: auto;
  min-height: 0;
}
.dialog-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0 0 14px;
}
.dialog-notice {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--blue-bg);
  border: 1px solid var(--blue-border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--blue);
  font-weight: 500;
  margin-bottom: 14px;
}
.dialog-notice svg { width: 16px; height: 16px; flex-shrink: 0; }
.dialog-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 16px 24px 20px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.dialog-footer-right {
  display: flex;
  gap: 8px;
}
.dialog-footer-count {
  font-size: 13px;
  color: var(--text-secondary);
}

/* ===== Submit preview list ===== */
.submit-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.submit-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  user-select: none;
}
.submit-item:hover { background: var(--bg); }
.submit-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  accent-color: var(--blue);
  cursor: pointer;
}
.submit-item-body { flex: 1; min-width: 0; }
.submit-item-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}
.submit-item-meta {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 1px;
}
.submit-item.unchecked .submit-item-name,
.submit-item.unchecked .submit-item-meta { opacity: 0.45; }
.submit-item-delete { border-left: 3px solid var(--red); }
.badge-delete {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  color: var(--red);
  background: var(--red-bg);
  border: 1px solid var(--red-border);
  border-radius: 4px;
  padding: 0 5px;
  margin-left: 6px;
  vertical-align: middle;
  line-height: 18px;
}
.submit-select-all {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}
.submit-select-all input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--blue);
  cursor: pointer;
}

/* ===== Secondary button ===== */
.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}
.btn-secondary:hover { background: var(--bg); }

@media (max-width: 768px) {
  .field-group-row { grid-template-columns: 1fr; }
  .settings-actions { flex-direction: column; }
  .settings-actions .btn { width: 100%; justify-content: center; }
  .pending-banner { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 480px) {
  .topbar-nav { display: none; }
  .user-name { display: none; }
  .review-title { font-size: 18px; }
  .menu-trigger { opacity: 1; }
}

/* ===== Tiptap editors ===== */
.tiptap-wrapper {
  flex: 1;
  min-width: 0;
}
.tiptap-mount .ProseMirror {
  outline: none;
  font-size: 14px;
  font-family: inherit;
  line-height: 1.5;
  color: var(--text);
  min-height: 22px;
  cursor: text;
  caret-color: var(--text);
}
.tiptap-mount .ProseMirror p { margin: 0; }
.tiptap-mount .ProseMirror p.is-editor-empty:first-child::before {
  content: attr(data-placeholder);
  float: left;
  color: var(--text-muted);
  pointer-events: none;
  height: 0;
}

/* Context editor with toolbar */
.tiptap-context-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  overflow: hidden;
  transition: var(--transition);
}
.tiptap-context-wrap:focus-within {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-bg);
}
.tiptap-context-wrap .tiptap-mount .ProseMirror {
  padding: 10px 14px;
  min-height: 80px;
}
.tiptap-mount .ProseMirror ul,
.tiptap-mount .ProseMirror ol {
  padding-left: 24px;
  margin: 4px 0;
}
.tiptap-mount .ProseMirror li { margin: 2px 0; }
.tiptap-mount .ProseMirror li p { margin: 0; }

/* Toolbar */
.tiptap-toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px 6px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.tiptap-toolbar button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  background: none;
  border-radius: 4px;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
  transition: var(--transition);
}
.tiptap-toolbar button:hover { background: var(--surface); color: var(--text); }
.tiptap-toolbar button.active { background: var(--blue-bg); color: var(--blue); }
.tiptap-toolbar button:disabled { opacity: 0.3; cursor: default; }
.tiptap-toolbar button:disabled:hover { background: none; color: var(--text-secondary); }
.tiptap-toolbar-sep {
  width: 1px;
  height: 16px;
  background: var(--border);
  margin: 0 4px;
}

/* Bubble menu (floating on text selection) */
.tiptap-bubble-menu {
  position: fixed;
  z-index: 9999;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
  padding: 4px;
  background: var(--text);
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
}
.tiptap-bubble-menu .bubble-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  background: none;
  border-radius: 5px;
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  transition: color 0.12s ease, background 0.12s ease;
}
.tiptap-bubble-menu .bubble-btn:hover { color: #fff; }
.tiptap-bubble-menu .bubble-btn.is-active {
  color: #fff;
  background: rgba(255, 255, 255, 0.18);
}
.tiptap-bubble-menu .bubble-btn:disabled {
  opacity: 0.35;
  cursor: default;
}
.tiptap-bubble-menu .bubble-btn-danger { color: rgba(255, 100, 100, 0.8); }
.tiptap-bubble-menu .bubble-btn-danger:hover { color: #ff6b6b; }
.tiptap-bubble-menu .bubble-separator {
  width: 1px;
  height: 18px;
  background: rgba(255, 255, 255, 0.2);
  margin: 0 2px;
}
.tiptap-bubble-menu .bubble-link-input {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 0 2px 4px;
}
.tiptap-bubble-menu .bubble-link-url {
  width: 180px;
  padding: 3px 8px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 12px;
  font-family: inherit;
  outline: none;
}
.tiptap-bubble-menu .bubble-link-url::placeholder { color: rgba(255, 255, 255, 0.4); }
.tiptap-bubble-menu .bubble-link-url:focus { border-color: rgba(255, 255, 255, 0.5); }
.tiptap-bubble-menu .bubble-table-group { display: none; }

/* Tables inside tiptap editors */
.tiptap-mount .ProseMirror table {
  border-collapse: collapse;
  width: 100%;
  margin: 8px 0;
  table-layout: fixed;
  overflow: hidden;
}
.tiptap-mount .ProseMirror td,
.tiptap-mount .ProseMirror th {
  border: 1px solid var(--border);
  padding: 6px 10px;
  font-size: 13px;
  vertical-align: top;
  position: relative;
  min-width: 80px;
}
.tiptap-mount .ProseMirror th {
  background: var(--bg);
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.tiptap-mount .ProseMirror td p,
.tiptap-mount .ProseMirror th p {
  margin: 0;
}
.tiptap-mount .ProseMirror .selectedCell::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--blue-bg);
  pointer-events: none;
  z-index: 1;
}
.tiptap-mount .ProseMirror .column-resize-handle {
  position: absolute;
  right: -2px;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--blue);
  pointer-events: none;
}
.tiptap-mount .ProseMirror .tableWrapper {
  overflow-x: auto;
  margin: 8px 0;
}
.tiptap-context-editor.resize-cursor {
  cursor: col-resize;
}

/* Table controls in toolbar (context editor) */
.tiptap-toolbar-table-group {
  display: contents;
}
.tiptap-toolbar-table-group .tiptap-table-controls-danger:hover {
  color: var(--red, #ef4444) !important;
  background: rgba(239, 68, 68, 0.1);
}

/* Anchored table bar (statement editors) */
.tiptap-wrapper {
  position: relative;
}
.tiptap-anchored-table-bar {
  position: absolute;
  right: 0;
  display: flex;
  align-items: center;
  gap: 1px;
  padding: 2px 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: var(--shadow);
  z-index: 10;
}
.tiptap-anchored-table-bar button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: none;
  background: none;
  border-radius: 4px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
}
.tiptap-anchored-table-bar button:hover { background: var(--bg); color: var(--text); }
.tiptap-anchored-table-bar .tiptap-table-controls-danger:hover { color: var(--red, #ef4444); }
.tiptap-anchored-table-bar .tiptap-toolbar-sep {
  width: 1px;
  height: 14px;
  background: var(--border);
  margin: 0 2px;
}


/* ===== Admin (cmd/admin) model browser ===== */

.admin-body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.admin-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.admin-topbar-left {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.admin-logo {
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  font-size: 16px;
}

.admin-subtitle {
  color: var(--text-secondary);
  font-size: 13px;
}

.admin-warning {
  color: var(--yellow);
  background: var(--yellow-bg);
  border: 1px solid var(--yellow-border);
  border-radius: var(--radius-sm);
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 500;
}

.admin-layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  min-height: 0;
}

.admin-pane-header {
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 1;
}

.admin-tree-pane {
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.admin-tree-scroll {
  overflow: auto;
  flex: 1;
  padding: 8px 6px 16px;
}

.admin-detail-pane {
  overflow: auto;
  padding: 24px 28px;
}

.admin-empty {
  color: var(--text-muted);
  font-size: 14px;
  max-width: 420px;
  margin-top: 40px;
}

/* --- Tree --- */

.admin-tree,
.admin-tree-children {
  list-style: none;
  padding-left: 0;
  margin: 0;
}

.admin-tree-children {
  padding-left: 18px;
  display: none;
}

.admin-tree-node.expanded > .admin-tree-children {
  display: block;
}

.admin-tree-empty,
.admin-tree-empty-child {
  color: var(--text-muted);
  font-size: 12px;
  padding: 6px 10px;
  font-style: italic;
}

.admin-tree-row {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 1px 4px;
  border-radius: var(--radius-sm);
}

.admin-tree-row:hover {
  background: var(--bg);
}

.admin-tree-toggle {
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--text-muted);
  cursor: pointer;
  width: 18px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  line-height: 1;
  padding: 0;
  flex-shrink: 0;
}

.admin-tree-toggle-leaf {
  cursor: default;
}

.admin-tree-chevron {
  display: inline-block;
  transition: transform 0.12s ease;
}

.admin-tree-node.expanded > .admin-tree-row > .admin-tree-toggle .admin-tree-chevron {
  transform: rotate(90deg);
}

.admin-tree-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  flex: 1;
  min-width: 0;
}

.admin-tree-label:hover {
  color: var(--blue);
}

.admin-tree-icon {
  width: 16px;
  text-align: center;
  font-size: 12px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.admin-tree-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.admin-tree-type {
  color: var(--text-muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}

/* --- Detail --- */

.admin-detail-header {
  border-bottom: 1px solid var(--border);
  padding-bottom: 16px;
  margin-bottom: 20px;
}

.admin-detail-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.admin-detail-title h1 {
  font-size: 20px;
  font-weight: 600;
  margin: 0;
}

.admin-detail-icon {
  font-size: 18px;
}

.admin-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--blue-bg);
  color: var(--blue);
  border: 1px solid var(--blue-border);
}

.admin-badge-folder { background: var(--yellow-bg); color: var(--yellow); border-color: var(--yellow-border); }
.admin-badge-file { background: var(--blue-bg); color: var(--blue); border-color: var(--blue-border); }
.admin-badge-function,
.admin-badge-method { background: var(--green-bg); color: var(--green); border-color: var(--green-border); }
.admin-badge-class,
.admin-badge-interface,
.admin-badge-type { background: var(--purple-bg); color: var(--purple); border-color: var(--purple); }

.admin-detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.admin-detail-path {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-size: 12px;
}

.admin-detail-timestamps {
  display: flex;
  gap: 14px;
  font-size: 11px;
  color: var(--text-muted);
}

.admin-detail-section {
  margin-top: 20px;
}

.admin-detail-section h2 {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.admin-detail-section h3 {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin: 10px 0 4px;
}

.admin-behaviours,
.admin-test-evidence {
  list-style: disc;
  padding-left: 20px;
  font-size: 13px;
  color: var(--text);
}

.admin-behaviours li,
.admin-test-evidence li {
  margin-bottom: 4px;
}

.admin-code {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
  overflow-x: auto;
  white-space: pre;
}

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

/* --- Reprocess --- */

.admin-reprocess form {
  margin: 8px 0;
}

.admin-reprocess-live {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0;
}

.admin-job-status {
  display: inline-block;
  font-size: 13px;
  font-weight: 600;
  text-transform: capitalize;
}

.admin-job-pending,
.admin-job-running {
  color: var(--text-muted);
}

.admin-job-done {
  color: var(--success, #2e7d32);
}

.admin-job-failed {
  color: var(--danger, #c62828);
}

/* --- Spec re-verify (admin spec sections) --- */

.admin-spec-actions {
  padding: 6px 10px 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

.admin-spec-verify {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.admin-spec-verify .btn-sm {
  font-size: 12px;
  padding: 4px 10px;
}

.admin-spec-verify .admin-job-status {
  font-size: 12px;
  text-transform: none;
}

/* --- Versions --- */

.admin-versions {
  border-top: 1px solid var(--border);
  padding-top: 20px;
  margin-top: 28px;
}

.admin-version-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.admin-version > details {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0;
}

.admin-version > details > summary {
  cursor: pointer;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--text-secondary);
}

.admin-version > details[open] > summary {
  border-bottom: 1px solid var(--border);
}

.admin-version-num {
  font-weight: 600;
  color: var(--text);
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}

.admin-version-change {
  color: var(--blue);
  font-weight: 500;
}

.admin-version-model,
.admin-version-tokens,
.admin-version-date {
  color: var(--text-muted);
}

.admin-version-date {
  margin-left: auto;
}

.admin-version-body {
  padding: 10px 14px 14px;
}


/* --- Admin topbar navigation --- */

.admin-topbar-nav {
  display: flex;
  gap: 6px;
  margin-left: 16px;
}

.admin-topbar-nav a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13px;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
}

.admin-topbar-nav a:hover {
  background: var(--bg);
  color: var(--text);
}

.admin-topbar-nav a.active {
  background: var(--blue-bg);
  color: var(--blue);
  font-weight: 500;
}

/* --- Admin orgs page --- */

.admin-layout-full {
  grid-template-columns: 1fr;
}

.admin-help {
  color: var(--text-secondary);
  font-size: 13px;
  margin: 12px 0 20px;
  max-width: 720px;
}

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

.admin-orgs-table th,
.admin-orgs-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.admin-orgs-table th {
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.admin-orgs-name {
  font-weight: 500;
  color: var(--text);
}

.admin-orgs-slug code {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 12px;
  color: var(--text-secondary);
}

.admin-orgs-created {
  color: var(--text-muted);
  font-size: 12px;
  white-space: nowrap;
}

.admin-orgs-actions {
  text-align: right;
}

/* --- Org-inactive banner --- */

.org-inactive-banner {
  background: var(--yellow-bg);
  color: var(--yellow);
  border-bottom: 1px solid var(--yellow-border);
}

/* --- Admin spec browser --- */

.admin-project-picker {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 560px;
}

.admin-project-picker a {
  display: block;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text);
  font-size: 14px;
}

.admin-project-picker a:hover {
  border-color: var(--blue);
  background: var(--bg);
}

.admin-spec-label {
  cursor: pointer;
}

.admin-spec-dot,
.admin-section-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
}

.admin-section-dot-empty {
  background: transparent;
  border: 1px solid var(--border);
}

.admin-spec-sections .admin-tree-row {
  padding-left: 0;
}

.admin-detail-id {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 11px;
  color: var(--text-muted);
}

.admin-section-status {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 4px;
}

.admin-section-status-pill {
  display: inline-block;
  padding: 2px 10px;
  border: 1px solid currentColor;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.admin-section-clause {
  font-size: 13px;
  color: var(--text);
  margin: 4px 0 0;
  padding: 8px 12px;
  background: var(--bg);
  border-left: 3px solid var(--border);
  border-radius: var(--radius-sm);
}
