/* ================================================================
   AUTH OVERLAY
================================================================ */
.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}
.auth-overlay.hidden { display: none; }
.auth-card {
  width: 380px;
  padding: 40px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  text-align: center;
}
.auth-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}
.auth-subtitle {
  font-size: 13px;
  color: var(--text-3);
  margin-bottom: 24px;
}
.auth-error {
  font-size: 13px;
  color: var(--red, #ef4444);
  margin-bottom: 16px;
  padding: 8px 12px;
  background: rgba(239,68,68,0.08);
  border-radius: var(--r-sm);
}
.auth-error.hidden { display: none; }
.auth-input {
  display: block;
  width: 100%;
  padding: 10px 14px;
  margin-bottom: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color var(--t-fast);
}
.auth-input:focus { border-color: var(--accent); }
.auth-input::placeholder { color: var(--text-3); }
.auth-submit-btn {
  width: 100%;
  padding: 10px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--r-md);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--t-fast);
  margin-top: 4px;
}
.auth-submit-btn:hover { background: var(--accent-2); }
.auth-submit-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.auth-toggle-btn {
  display: block;
  width: 100%;
  margin-top: 16px;
  background: none;
  border: none;
  color: var(--text-3);
  font-size: 12px;
  cursor: pointer;
  transition: color var(--t-fast);
}
.auth-toggle-btn:hover { color: var(--accent-2); }

/* JBA-188: tab-style mode switcher — primary Log In / Sign Up surface.
   Active tab is filled accent so the mode change is visually unmistakable. */
.auth-tabs {
  display: flex;
  gap: var(--sp-1);
  margin-bottom: var(--sp-5);
}
.auth-tab {
  flex: 1;
  padding: var(--sp-2);
  font-size: var(--text-sm);
  font-weight: 600;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text-3);
  cursor: pointer;
  transition: all var(--t-fast);
}
.auth-tab:hover:not(.active) { border-color: var(--text-3); color: var(--text-2); }
.auth-tab.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}

/* JBA-188: subtle password-requirement hint (signup only) */
.auth-hint {
  font-size: var(--text-xs);
  color: var(--text-3);
  text-align: left;
  margin: -6px 0 12px;
}
.auth-hint.hidden { display: none; }

/* JBA-202: password field + inline eye-icon visibility toggle.
   Wrap owns the bottom margin (moved off the input) so the absolutely
   positioned toggle centers on the input, not the margin box. */
.auth-input-wrap {
  position: relative;
  margin-bottom: 12px;
}
.auth-input-wrap .auth-input {
  margin-bottom: 0;
  padding-right: 40px;  /* clear the icon so typed text doesn't run under it */
}
.auth-eye-toggle {
  position: absolute;
  right: var(--sp-2);
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  background: transparent;
  border: 0;
  border-radius: var(--r-sm);
  color: var(--text-3);
  cursor: pointer;
  transition: color var(--t-fast);
}
.auth-eye-toggle:hover { color: var(--accent); }
.auth-eye-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.auth-eye-toggle svg { width: 18px; height: 18px; display: block; }

/* JBA-188: inline field-level error (confirm mismatch, email-in-use) */
.auth-field-error {
  font-size: var(--text-xs);
  color: var(--red);
  text-align: left;
  margin: -6px 0 12px;
}
.auth-field-error.hidden { display: none; }

/* JBA-188: inline "Log in instead?" link inside the email-in-use error */
.auth-inline-link {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: var(--accent-2);
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
}
.auth-inline-link:hover { color: var(--accent); }

/* Sidebar user info and logout */
.sidebar-user-email {
  display: block;
  font-size: 11px;
  color: var(--text-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: 4px;
}
.sidebar-logout-btn {
  display: block;
  width: 100%;
  padding: 6px;
  margin-bottom: 8px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--r-sm);
  color: var(--text-3);
  font-size: 12px;
  cursor: pointer;
  transition: all var(--t-fast);
}
.sidebar-logout-btn:hover { color: var(--text); border-color: rgba(255,255,255,0.15); }

/* Bee tier selector cards */
.bee-tier-card {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  width: 100%;
  padding: var(--sp-3) var(--sp-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: left;
}
.bee-tier-card:hover {
  background: var(--surface-2);
  border-color: var(--accent);
  transform: translateY(-1px);
}
.bee-tier-icon { font-size: 28px; flex-shrink: 0; }
.bee-tier-info { flex: 1; min-width: 0; }
.bee-tier-name {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--text);
  margin-bottom: 2px;
}
.bee-tier-desc {
  font-size: var(--text-xs);
  color: var(--text-3);
  line-height: 1.4;
}
.bee-tier-badge {
  font-size: 0.65rem;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: var(--r-sm);
  background: rgba(255,255,255,0.06);
  color: var(--text-3);
  margin-left: var(--sp-1);
}

/* ================================================================
   CARD
================================================================ */
.card {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
}

.card-title {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text);
  margin-bottom: var(--sp-4);
}

.card-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-4);
}

.card-actions .card-title { margin-bottom: 0; }

/* ================================================================
   BUTTONS
================================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--r-md);
  font-size: var(--text-sm);
  font-weight: 600;
  transition: all var(--t-fast);
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-2); }

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border-2);
}
.btn-secondary:hover { background: var(--border); }

.btn-ghost {
  background: transparent;
  color: var(--text-2);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--surface); color: var(--text); }

.btn-sm {
  padding: var(--sp-1) var(--sp-3);
  font-size: var(--text-xs);
}

/* JBA-162d: "View Site" — opens the walkthrough server in a new tab.
   Shared accent style for the sidebar button (#view-site-btn) and the Forge
   toolbar button (#view-site-btn-forge). The Forge instance carries no .btn
   class, so this rule is fully self-contained. */
.view-site-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: var(--sp-1) var(--sp-3);
  border: 1px solid transparent;
  border-radius: var(--r-md);
  font-size: var(--text-xs);
  font-weight: 600;
  background: var(--accent);
  color: #fff;
  white-space: nowrap;
  cursor: pointer;
  transition: all var(--t-fast);
}
.view-site-btn:hover { background: var(--accent-2); }
.view-site-btn:disabled { opacity: 0.6; cursor: not-allowed; pointer-events: none; }

/* Sidebar instance: full-width, directly below "+ New Project". */
#view-site-btn { width: 100%; margin-top: var(--sp-2); }

/* Forge toolbar instance: pushed to the far right end of the flex toolbar. */
#view-site-btn-forge { margin-left: auto; }

.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: var(--r-md);
}

.btn-row {
  display: flex;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

/* ================================================================
   FORM ELEMENTS
================================================================ */
.field-row {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  margin-bottom: var(--sp-3);
}

.field-label {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
}

.field-hint {
  font-size: var(--text-sm);
  color: var(--text-2);
  margin-bottom: var(--sp-3);
}

.input, .select, .textarea {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text);
  padding: var(--sp-2) var(--sp-3);
  font-size: var(--text-sm);
  transition: border-color var(--t-fast);
  width: 100%;
}

.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.input::placeholder, .textarea::placeholder { color: var(--text-3); }

.textarea { resize: vertical; min-height: 60px; }

.select { appearance: none; cursor: pointer; }

.select-wrap {
  position: relative;
  margin-bottom: var(--sp-2);
}
.select-wrap::after {
  content: '▾';
  position: absolute;
  right: var(--sp-3);
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-3);
  pointer-events: none;
  font-size: var(--text-xs);
}

.select-sm {
  padding: var(--sp-1) var(--sp-2);
  font-size: var(--text-xs);
}

/* Empty-state project dropdown — JBA-146 */
#project-selector-wrap.is-empty #project-select {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}
#project-selector-wrap.is-empty .select-wrap::after {
  opacity: 0.4;
}
#project-selector-wrap.is-empty #new-project-btn {
  width: 100%;
  justify-content: center;
  margin-top: var(--sp-2);
}

/* ================================================================
   UPLOAD ZONE
================================================================ */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-8) var(--sp-6);
  text-align: center;
  cursor: pointer;
  transition: all var(--t-med);
  margin-bottom: var(--sp-4);
  background: var(--surface);
}

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

.upload-zone.has-image {
  padding: 0;
  border-style: solid;
  border-color: var(--accent);
  overflow: hidden;
}

.upload-zone.has-image img {
  width: 100%;
  max-height: 240px;
  object-fit: cover;
  border-radius: var(--r-md);
}

.upload-icon {
  font-size: 1.5rem;
  color: var(--text-3);
  margin-bottom: var(--sp-2);
}

.upload-text {
  font-size: var(--text-sm);
  color: var(--text-2);
}

.upload-link {
  color: var(--accent-2);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.upload-hint {
  font-size: var(--text-xs);
  color: var(--text-3);
  margin-top: var(--sp-1);
}

.upload-zone-sm {
  padding: var(--sp-4);
  margin-bottom: var(--sp-3);
}

/* ================================================================
   TAGS
================================================================ */
.tag-group {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-1);
}

.tag {
  padding: 3px var(--sp-2);
  border-radius: var(--r-full);
  border: 1px solid var(--border);
  font-size: var(--text-xs);
  color: var(--text-2);
  background: var(--surface);
  cursor: pointer;
  transition: all var(--t-fast);
}

.tag:hover { border-color: var(--accent); color: var(--accent-2); }

.tag.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent-2);
}

/* ================================================================
   BADGE
================================================================ */
.badge {
  display: inline-block;
  padding: 2px var(--sp-2);
  border-radius: var(--r-full);
  font-size: var(--text-xs);
  font-weight: 600;
  background: var(--surface-2);
  color: var(--text-2);
  border: 1px solid var(--border);
}

/* ================================================================
   RATING
================================================================ */
.rating-input {
  display: flex;
  gap: 2px;
}

.star {
  font-size: 1.25rem;
  color: var(--border-2);
  cursor: pointer;
  transition: color var(--t-fast);
  padding: 0 1px;
}

.star.active, .star:hover { color: var(--yellow); }

/* ================================================================
   IMAGE GRID
================================================================ */
.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--sp-3);
}

.image-card {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  cursor: pointer;
  transition: border-color var(--t-fast), transform var(--t-fast);
}

.image-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.image-card img {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  display: block;
}

.image-card-meta {
  padding: var(--sp-2) var(--sp-3);
}

.image-card-similarity {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--accent-2);
}

.image-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin-top: 3px;
}

.image-card-tag {
  font-size: 0.625rem;
  color: var(--text-3);
  background: var(--surface);
  padding: 1px 5px;
  border-radius: var(--r-full);
  border: 1px solid var(--border);
}

/* ================================================================
   SEARCH ROW
================================================================ */
.search-row {
  display: flex;
  gap: var(--sp-2);
  margin-bottom: var(--sp-3);
}

.search-row .input { flex: 1; }

.filter-row {
  display: flex;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

/* ================================================================
   ANALYSIS DISPLAY
================================================================ */
.analysis-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
}

.analysis-block {
  background: var(--surface);
  border-radius: var(--r-md);
  padding: var(--sp-3);
}

.analysis-block-label {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
  margin-bottom: var(--sp-1);
}

.analysis-block-value {
  font-size: var(--text-sm);
  color: var(--text-2);
}

.color-swatches {
  display: flex;
  gap: var(--sp-1);
  flex-wrap: wrap;
}

.color-swatch {
  width: 24px;
  height: 24px;
  border-radius: var(--r-sm);
  border: 1px solid rgba(255,255,255,0.1);
  cursor: pointer;
  position: relative;
}

.color-swatch:hover::after {
  content: attr(data-hex);
  position: absolute;
  bottom: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
}

.analysis-summary {
  background: var(--surface);
  border-radius: var(--r-md);
  padding: var(--sp-3);
  font-size: var(--text-sm);
  color: var(--text-2);
  line-height: 1.6;
  margin-bottom: var(--sp-4);
}

/* ================================================================
   CHAT
================================================================ */
.chat-container {
  display: flex;
  flex-direction: column;
  /* Fill available viewport height minus header/input chrome */
  height: calc(100vh - 200px);
  min-height: 400px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  /* Ensure this element is the scroll container, not growing unbounded */
  min-height: 0;
}

.chat-message {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chat-message.user { align-items: flex-end; }
.chat-message.model { align-items: flex-start; }

.chat-bubble {
  max-width: 85%;
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-lg);
  font-size: var(--text-sm);
  line-height: 1.6;
}

.chat-message.user .chat-bubble {
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: var(--sp-1);
}

.chat-message.model .chat-bubble {
  background: var(--surface-2);
  color: var(--text);
  border-bottom-left-radius: var(--sp-1);
}

.chat-role {
  font-size: var(--text-xs);
  color: var(--text-3);
  padding: 0 var(--sp-1);
}

.chat-input-row {
  display: flex;
  align-items: flex-end;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.chat-input-row .btn {
  height: 40px;
  flex-shrink: 0;
}

.chat-input { flex: 1; resize: none; }

/* ---- Chat Image Upload ---- */
.chat-file-preview {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-4);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.chat-file-preview img {
  height: 56px;
  width: auto;
  max-width: 120px;
  object-fit: cover;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-2);
}

.chat-doc-preview {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  color: var(--text-2);
  font-size: var(--text-sm);
}

.chat-doc-preview svg { color: var(--accent); flex-shrink: 0; }

.chat-image-remove {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-full);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-3);
  font-size: 11px;
  cursor: pointer;
}

.chat-image-remove:hover { color: var(--red); border-color: var(--red); }

.chat-bubble-image {
  max-width: 180px;
  border-radius: var(--r-md);
  border: 1px solid var(--border-2);
  margin-bottom: var(--sp-2);
}

.chat-doc-attachment {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  margin-bottom: var(--sp-2);
}

.chat-doc-attachment svg { color: var(--accent); flex-shrink: 0; }

.chat-doc-filename {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text);
}

.chat-doc-snippet {
  font-size: var(--text-xs);
  color: var(--text-3);
  white-space: pre-wrap;
  max-height: 80px;
  overflow: hidden;
  margin-bottom: var(--sp-2);
  line-height: 1.4;
}

.chat-output {
  background: var(--surface);
  border-radius: var(--r-md);
  padding: var(--sp-4);
  font-size: var(--text-sm);
  color: var(--text-2);
  line-height: 1.6;
  margin-top: var(--sp-3);
  white-space: pre-wrap;
}

/* ================================================================
   MARKDOWN OUTPUT
================================================================ */
.markdown-output {
  font-size: var(--text-sm);
  color: var(--text-2);
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

.markdown-output h1, .markdown-output h2, .markdown-output h3 {
  color: var(--text);
  margin: var(--sp-5) 0 var(--sp-2);
  font-weight: 600;
}

.markdown-output h1 { font-size: var(--text-xl); }
.markdown-output h2 { font-size: var(--text-lg); }
.markdown-output h3 { font-size: var(--text-base); }

.markdown-output p { margin-bottom: var(--sp-3); }

.markdown-output ul, .markdown-output ol {
  padding-left: var(--sp-5);
  margin-bottom: var(--sp-3);
  list-style: disc;
}

.markdown-output ol { list-style: decimal; }
.markdown-output li { margin-bottom: var(--sp-1); }

.markdown-output code {
  background: var(--surface);
  padding: 2px 6px;
  border-radius: var(--r-sm);
  font-family: var(--font-mono);
  font-size: 0.9em;
  color: var(--accent-2);
}

.markdown-output strong { color: var(--text); font-weight: 600; }

/* ================================================================
   SECTION TITLE
================================================================ */
.section-title {
  font-size: var(--text-sm);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
  margin-bottom: var(--sp-3);
}

/* ================================================================
   EMPTY STATE
================================================================ */
.empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-12);
  text-align: center;
}

.empty-state p {
  color: var(--text-3);
  font-size: var(--text-sm);
  max-width: 320px;
}

.empty-state--rich {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--sp-8);
  max-width: 480px;
  margin: 0 auto;
  gap: var(--sp-3);
  background: color-mix(in srgb, var(--accent) 4%, var(--bg-3));
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--r-lg);
}
.empty-state--rich .empty-state__icon {
  font-size: 2rem;
  color: var(--accent);
  line-height: 1;
}
.empty-state--rich .empty-state__heading {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--text);
  margin: 0;
}
.empty-state--rich .empty-state__body {
  font-size: var(--text-base);
  color: var(--text-2);
  margin: 0;
  max-width: 380px;
  line-height: 1.5;
}
.empty-state--rich .empty-state__hint {
  font-size: var(--text-sm);
  color: var(--text-3);
  margin: 0;
  font-style: italic;
}

/* ================================================================
   CRITIQUE SCORECARD
================================================================ */
.scorecard {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  margin-bottom: var(--sp-5);
}

.score-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.score-label {
  width: 160px;
  flex-shrink: 0;
  font-size: var(--text-sm);
  color: var(--text-2);
}

.score-bar-wrap {
  flex: 1;
  height: 6px;
  background: var(--surface);
  border-radius: var(--r-full);
  overflow: hidden;
}

.score-bar {
  height: 100%;
  border-radius: var(--r-full);
  transition: width 0.6s ease;
}

.score-value {
  width: 28px;
  text-align: right;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text);
}

.score-bar.high   { background: var(--green); }
.score-bar.mid    { background: var(--yellow); }
.score-bar.low    { background: var(--red); }

.critique-summary {
  font-size: var(--text-sm);
  color: var(--text-2);
  line-height: 1.6;
  padding: var(--sp-3);
  background: var(--surface);
  border-radius: var(--r-md);
  margin-bottom: var(--sp-4);
}

.fix-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  list-style: none;
}

.fix-list li {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-2);
  font-size: var(--text-sm);
  color: var(--text-2);
  padding: var(--sp-2) var(--sp-3);
  background: var(--red-dim);
  border-radius: var(--r-md);
  border-left: 2px solid var(--red);
}

.fix-list li::before { content: '!'; color: var(--red); font-weight: 700; flex-shrink: 0; }

/* ================================================================
   DESIGN PROPOSALS
================================================================ */
.proposal-card {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
  margin-bottom: var(--sp-4);
}

.proposal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-4);
  gap: var(--sp-2);
}

.proposal-header-actions {
  display: flex;
  gap: var(--sp-2);
  flex-shrink: 0;
}

.proposal-name {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--text);
}

/* ---- Interactive palette ---- */
/* Proposal preview */
.proposal-preview-slot {
  margin-bottom: var(--sp-4);
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  min-height: 60px;
}
.proposal-preview-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-4);
}
.proposal-preview-iframe {
  width: 100%;
  height: 400px;
  border: none;
  display: block;
  background: #fff;
}

.proposal-palette-section {
  margin-bottom: var(--sp-4);
}

.proposal-palette-hint {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  font-style: italic;
  opacity: 0.6;
}

.proposal-palette {
  display: flex;
  gap: var(--sp-3);
  flex-wrap: wrap;
}

.proposal-swatch-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  position: relative;
  cursor: pointer;
}

.proposal-swatch {
  width: 40px;
  height: 40px;
  border-radius: var(--r-md);
  border: 2px solid rgba(255,255,255,0.08);
  transition: transform var(--t-fast), border-color var(--t-fast);
}

.proposal-swatch-wrap:hover .proposal-swatch {
  transform: scale(1.1);
  border-color: rgba(255,255,255,0.3);
}

.proposal-swatch--modified {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 2px var(--accent-dim);
}

.proposal-swatch--modified::after {
  content: '';
  position: absolute;
  top: -3px;
  right: -3px;
  width: 8px;
  height: 8px;
  background: var(--accent);
  border-radius: 50%;
  border: 1px solid var(--bg-3);
}

.proposal-swatch-hex {
  font-size: 0.6rem;
  color: var(--text-3);
  font-family: var(--font-mono, monospace);
}

.proposal-swatch-reset {
  position: absolute;
  top: -6px;
  left: -6px;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-3);
  font-size: 10px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--t-fast), color var(--t-fast);
}

.proposal-swatch-wrap:hover .proposal-swatch-reset { opacity: 1; }
.proposal-swatch-reset:hover { color: var(--text); border-color: var(--accent); }

/* Color picker popover */
.palette-picker-popover {
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--sp-2);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

.palette-picker-input {
  width: 48px;
  height: 36px;
  padding: 0;
  border: none;
  border-radius: var(--r-sm);
  cursor: pointer;
  background: transparent;
}

.palette-picker-input::-webkit-color-swatch-wrapper { padding: 0; }
.palette-picker-input::-webkit-color-swatch {
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: var(--r-sm);
}

.palette-picker-hex {
  font-size: 0.6rem;
  color: var(--text-3);
  font-family: var(--font-mono, monospace);
}

/* AI palette feedback */
.palette-feedback {
  margin-bottom: var(--sp-4);
  padding: var(--sp-3);
  background: var(--surface);
  border-radius: var(--r-md);
  border: 1px solid var(--border);
}

.palette-feedback-text {
  font-size: var(--text-sm);
  color: var(--text-2);
  line-height: 1.6;
  white-space: pre-wrap;
}

.proposal-section {
  margin-bottom: var(--sp-3);
}

.proposal-section-label {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
  margin-bottom: var(--sp-1);
}

.proposal-section-value {
  font-size: var(--text-sm);
  color: var(--text-2);
  line-height: 1.5;
}

/* ---- Inline refine per option ---- */
.proposal-refine {
  margin-top: var(--sp-4);
  padding-top: var(--sp-3);
  border-top: 1px solid var(--border);
}

.proposal-refine-row {
  display: flex;
  align-items: flex-end;
  gap: var(--sp-2);
}

.proposal-refine-input {
  flex: 1;
  min-height: 36px;
  resize: none;
}

.proposal-refine-btn {
  height: 36px;
  flex-shrink: 0;
}

.proposal-revision-controls {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-top: var(--sp-2);
}

.proposal-revision-badge {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--accent-2);
  background: var(--accent-dim);
  padding: 1px var(--sp-2);
  border-radius: var(--r-full);
  margin-left: var(--sp-1);
}

/* Revision history panel */
.proposal-history {
  margin-top: var(--sp-2);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.proposal-history-item {
  padding: var(--sp-2) var(--sp-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}

.proposal-history-header {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-bottom: 4px;
}

.proposal-history-label {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--text-3);
}

.proposal-history-swatch {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1px solid rgba(255,255,255,0.1);
  display: inline-block;
}

.proposal-history-detail {
  font-size: var(--text-xs);
  color: var(--text-3);
  line-height: 1.4;
}

/* ================================================================
   COMPLIANCE
================================================================ */
.violation-list { display: flex; flex-direction: column; gap: var(--sp-2); }

.violation-item {
  padding: var(--sp-3);
  border-radius: var(--r-md);
  border-left: 3px solid transparent;
}

.violation-item.high   { background: var(--red-dim);    border-color: var(--red); }
.violation-item.medium { background: var(--yellow-dim); border-color: var(--yellow); }
.violation-item.low    { background: var(--blue-dim);   border-color: var(--blue); }

.violation-section {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-3);
}

.violation-finding {
  font-size: var(--text-sm);
  color: var(--text-2);
  margin-top: 2px;
}

/* ================================================================
   DRIFT SCORE
================================================================ */
.drift-score {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3);
  background: var(--surface);
  border-radius: var(--r-md);
  margin-bottom: var(--sp-4);
}

.drift-label { font-size: var(--text-sm); color: var(--text-2); }

.drift-bar-wrap {
  flex: 1;
  height: 8px;
  background: var(--green-dim);
  border-radius: var(--r-full);
  overflow: hidden;
}

.drift-bar {
  height: 100%;
  border-radius: var(--r-full);
  background: linear-gradient(90deg, var(--green) 0%, var(--yellow) 50%, var(--red) 100%);
  transition: width 0.5s ease;
}

.drift-value { font-size: var(--text-sm); font-weight: 600; color: var(--text); }

/* ================================================================
   MODAL
================================================================ */
#modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

#modal-box {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: var(--sp-6);
  max-width: 640px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  position: relative;
}

.modal-close {
  position: absolute;
  top: var(--sp-4);
  right: var(--sp-4);
  color: var(--text-3);
  font-size: var(--text-sm);
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--border);
}

.modal-close:hover { color: var(--text); background: var(--surface-2); }

/* Project gate modal */
.project-gate-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  max-height: 300px;
  overflow-y: auto;
}

.project-gate-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: border-color var(--t-fast), background var(--t-fast);
}

.project-gate-item:hover {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.project-gate-item-name {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text);
}

.project-gate-item-meta {
  font-size: var(--text-xs);
  color: var(--text-3);
}

.project-gate-empty {
  font-size: var(--text-sm);
  color: var(--text-3);
  text-align: center;
  padding: var(--sp-6);
}

/* ================================================================
   TOAST
================================================================ */
.toast {
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md);
  font-size: var(--text-sm);
  color: #fff;
  font-weight: 500;
  min-width: 220px;
  animation: slideIn 0.2s ease;
  border: 1px solid rgba(255,255,255,0.1);
}

.toast.success { background: #1e3a2f; border-color: var(--green); color: var(--green); }
.toast.error   { background: #3a1e1e; border-color: var(--red);   color: var(--red);   }
.toast.info    { background: #1e2a3a; border-color: var(--blue);  color: var(--blue);  }

@keyframes slideIn {
  from { opacity: 0; transform: translateX(16px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ================================================================
   UTILITIES
================================================================ */
.hidden { display: none !important; }
.mt-3 { margin-top: var(--sp-3); }
.mt-4 { margin-top: var(--sp-4); }
.loading { opacity: 0.6; pointer-events: none; }

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

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

/* Typing indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: var(--sp-2) var(--sp-3) !important;
  min-height: 32px;
}

.typing-dot {
  width: 7px;
  height: 7px;
  background: var(--text-3);
  border-radius: 50%;
  animation: typing-bounce 1.4s ease-in-out infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

.typing-status-text {
  font-size: var(--text-xs);
  color: var(--text-3);
  margin-left: var(--sp-1);
}

/* Copy-to-clipboard button on AI messages */
.chat-bubble {
  position: relative;
}

.chat-copy-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  background: none;
  border: none;
  color: var(--text-3);
  cursor: pointer;
  padding: 3px;
  border-radius: var(--r-sm);
  line-height: 1;
  opacity: 0;
  transition: opacity var(--t-fast), color var(--t-fast), background var(--t-fast);
}

.chat-message:hover .chat-copy-btn { opacity: 1; }

.chat-copy-btn:hover {
  color: var(--text);
  background: rgba(255,255,255,0.1);
}

.chat-copy-btn.copied {
  opacity: 1;
  color: var(--green);
  font-size: var(--text-xs);
  font-weight: 600;
}

/* Brief resume list */
.brief-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.brief-list-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3);
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: border-color var(--t-fast), background var(--t-fast);
}

.brief-list-item:hover {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.brief-list-item-info { flex: 1; min-width: 0; }

.brief-list-item-name {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brief-list-item-meta {
  font-size: var(--text-xs);
  color: var(--text-3);
  display: flex;
  gap: var(--sp-2);
  margin-top: 2px;
}

.brief-list-item-status {
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 1px var(--sp-2);
  border-radius: var(--r-full);
  flex-shrink: 0;
}

.brief-list-item-status.draft {
  background: var(--yellow-dim);
  color: var(--yellow);
}

.brief-list-item-status.active {
  background: var(--green-dim);
  color: var(--green);
}

.brief-list-item-delete {
  background: none;
  border: none;
  color: var(--text-3);
  font-size: var(--text-base);
  cursor: pointer;
  padding: var(--sp-1) var(--sp-2);
  border-radius: var(--r-sm);
  line-height: 1;
  transition: all var(--t-fast);
  flex-shrink: 0;
}

.brief-list-item-delete:hover {
  color: var(--red);
  background: var(--red-dim);
}

/* Brief summary display */
.brief-field {
  margin-bottom: var(--sp-3);
}

.brief-field-label {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
  margin-bottom: 3px;
}

.brief-field-value {
  font-size: var(--text-sm);
  color: var(--text-2);
  line-height: 1.5;
}

/* Brief review card (inline in chat) */
.brief-review-wrapper { max-width: 100%; }

.brief-review-card {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-4) var(--sp-5);
  max-width: 520px;
}

.brief-review-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-4);
}

.brief-review-title {
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--text);
  margin: 0;
}

.brief-raw-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text-3);
  font-size: var(--text-xs);
  padding: 2px var(--sp-2);
  cursor: pointer;
  transition: all var(--t-fast);
}

.brief-raw-toggle:hover {
  color: var(--text);
  border-color: var(--text-3);
}

.brief-review-fields .brief-field {
  margin-bottom: var(--sp-3);
}

.brief-review-raw {
  max-height: 320px;
  overflow-y: auto;
}

.brief-review-raw pre {
  font-size: var(--text-xs);
  color: var(--text-3);
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
  line-height: 1.5;
}

.brief-review-actions {
  display: flex;
  gap: var(--sp-2);
  margin-top: var(--sp-4);
  padding-top: var(--sp-3);
  border-top: 1px solid var(--border);
}

.brief-saved-badge {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--green);
  padding: var(--sp-1) 0;
}

/* ================================================================
   RESEARCH MODE
================================================================ */

/* Brief summary tags */
.research-brief-summary {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin-top: var(--sp-3);
}

.research-brief-tag {
  font-size: var(--text-xs);
  color: var(--text-2);
  background: var(--surface);
  padding: 2px var(--sp-2);
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
}

.research-brief-tag strong {
  color: var(--text);
}

/* Category tabs */
.research-category-tabs {
  display: flex;
  gap: var(--sp-1);
}

.research-tab {
  flex: 1;
  padding: var(--sp-2);
  font-size: var(--text-xs);
  font-weight: 600;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text-3);
  cursor: pointer;
  transition: all var(--t-fast);
}

.research-tab:hover { border-color: var(--text-3); color: var(--text-2); }
.research-tab.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}

/* Custom search row */
.research-custom-row {
  display: flex;
  gap: var(--sp-2);
}

.research-custom-row .input { flex: 1; }

/* Loading indicator */
.research-loading {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-5);
  color: var(--text-3);
  font-size: var(--text-sm);
}

/* Board header + filters */
.research-board-header {
  display: flex;
  flex-direction: column;
  margin-bottom: var(--sp-3);
  gap: var(--sp-2);
}

.research-board-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
}

.research-regenerate-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  white-space: nowrap;
}

.research-regenerate-btn svg {
  flex-shrink: 0;
}

.research-dismissed-btn {
  font-size: var(--text-xs);
  color: var(--text-3);
  opacity: 0.6;
  transition: opacity var(--t-fast);
}

.research-dismissed-btn:hover { opacity: 1; }

.research-board-filters {
  display: flex;
  gap: var(--sp-1);
  flex-wrap: wrap;
}

.research-filter {
  padding: 2px var(--sp-2);
  font-size: var(--text-xs);
  font-weight: 600;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  color: var(--text-3);
  cursor: pointer;
  transition: all var(--t-fast);
}

.research-filter:hover { color: var(--text-2); border-color: var(--text-3); }
.research-filter.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}

/* Results grid */
.research-results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--sp-3);
}

/* Result card */
.research-card {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  transition: border-color var(--t-fast);
}

.research-card:hover { border-color: var(--accent); }
.research-card.saved {
  border-color: var(--green);
  background: color-mix(in srgb, var(--green) 5%, var(--bg-3));
}

.research-saved-icon {
  color: var(--green);
  vertical-align: -2px;
  margin-right: 4px;
}

/* Saved filter tab highlight */
.research-filter[data-filter="saved"].active {
  background: color-mix(in srgb, var(--green) 15%, transparent);
  border-color: var(--green);
  color: var(--green);
}

.research-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.research-card-category {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: capitalize;
  color: var(--accent);
  background: var(--accent-dim);
  padding: 1px var(--sp-2);
  border-radius: var(--r-full);
}

.research-card-link {
  font-size: var(--text-base);
  color: var(--text-3);
  text-decoration: none;
  transition: color var(--t-fast);
}

.research-card-link:hover { color: var(--accent); }

.research-card-name {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--text);
  margin: 0;
}

.research-card-url {
  font-size: var(--text-xs);
  color: var(--text-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.research-card-summary {
  font-size: var(--text-xs);
  color: var(--text-2);
  line-height: 1.5;
  margin: 0;
}

.research-card-relevance {
  font-size: var(--text-xs);
  color: var(--text-3);
  line-height: 1.4;
  padding-top: var(--sp-1);
  border-top: 1px solid var(--border);
}

.research-card-relevance strong { color: var(--text-2); }

/* Dismiss button */
.research-card-header-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
}

.research-card-dismiss {
  background: none;
  border: none;
  color: var(--text-3);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
  border-radius: var(--r-sm);
  transition: color 0.15s, background 0.15s;
  opacity: 0;
}

.research-card:hover .research-card-dismiss { opacity: 1; }

.research-card-dismiss:hover {
  color: var(--red);
  background: rgba(255,59,48,0.1);
}

.research-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding-top: var(--sp-2);
}

.research-card-actions {
  display: flex;
  gap: var(--sp-1);
}

/* Star rating */
.research-card-rating {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
}

.research-rating-label {
  font-size: var(--text-xs);
  color: var(--text-3);
  font-weight: 600;
}

.research-card-stars {
  display: flex;
  gap: 1px;
  padding: 2px 4px;
  border-radius: var(--r-sm);
  transition: background 0.3s;
}

.research-card-stars.rating-flash {
  background: rgba(255, 184, 0, 0.15);
}

@keyframes star-pop {
  0% { transform: scale(1); }
  50% { transform: scale(1.3); }
  100% { transform: scale(1); }
}

.research-star {
  font-size: 20px;
  color: rgba(255,255,255,0.15);
  cursor: pointer;
  transition: color 0.15s, transform 0.15s;
  user-select: none;
  line-height: 1;
}

.research-star:hover {
  color: rgba(255, 184, 0, 0.6);
  transform: scale(1.15);
}

/* Fill all stars up to hovered one */
.research-card-stars:hover .research-star {
  color: rgba(255, 184, 0, 0.6);
}
.research-card-stars:hover .research-star:hover ~ .research-star {
  color: rgba(255,255,255,0.15);
}

.research-star.filled {
  color: #FFB800;
}

.research-card-stars.rating-flash .research-star.filled {
  animation: star-pop 0.3s ease;
}

/* Extra small button variant */
.btn-xs {
  padding: 2px var(--sp-2);
  font-size: var(--text-xs);
  font-weight: 600;
}

/* ---- Research Chat ---- */
/* Make the research left panel sticky so chat + controls stay visible while scrolling results */
#mode-research .panel-left {
  position: sticky;
  top: var(--sp-4);
  align-self: flex-start;
  max-height: calc(100vh - var(--sp-8));
  overflow-y: auto;
  gap: var(--sp-5);
  padding-right: var(--sp-5);
  border-right: 1px solid var(--border);
}

.research-chat-sticky {
  background: var(--bg-3);
  border: 1px solid var(--accent);
  border-radius: var(--r-lg);
  padding: var(--sp-3) var(--sp-4);
  box-shadow: 0 0 0 1px var(--accent-dim), 0 4px 24px rgba(0,0,0,0.25);
  transition: padding 0.2s;
}

/* Collapsed state — just the header bar */
.research-chat-sticky.collapsed {
  padding-bottom: var(--sp-3);
}

.research-chat-sticky.collapsed .research-chat-body,
.research-chat-sticky.collapsed .research-chat-hint {
  display: none;
}

.research-chat-sticky.collapsed .research-chat-toggle svg {
  transform: rotate(-90deg);
}

.research-chat-header {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: var(--sp-2);
}

.research-chat-sticky.collapsed .research-chat-header {
  margin-bottom: 0;
}

.research-chat-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.research-chat-title-row .card-title {
  margin-bottom: 0;
  font-size: var(--text-sm);
}

.research-chat-toggle {
  background: none;
  border: none;
  color: var(--text-3);
  cursor: pointer;
  padding: 2px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  transition: color 0.15s, background 0.15s;
}

.research-chat-toggle:hover {
  color: var(--text);
  background: var(--surface);
}

.research-chat-toggle svg {
  transition: transform 0.2s;
}

.research-chat-hint {
  font-size: var(--text-xs);
  color: var(--text-3);
  font-style: italic;
  line-height: 1.3;
}

.research-chat-body {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

/* Messages area — hidden when empty, scrollable when populated */
.research-chat-messages {
  max-height: 400px;
  overflow-y: auto;
  background: var(--bg-2);
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  padding: var(--sp-3);
}

.research-chat-messages.hidden {
  display: none;
}

/* Model bubbles use full width in research chat */
.research-chat-messages .chat-message.model { align-items: stretch; }
.research-chat-messages .chat-message.model .chat-bubble {
  max-width: 100%;
}

/* Rendered markdown inside research chat bubbles */
.research-chat-messages .chat-bubble strong { font-weight: 700; }
.research-chat-messages .chat-bubble em { font-style: italic; }
.research-chat-messages .chat-bubble code {
  background: rgba(255,255,255,0.08);
  padding: 1px 4px;
  border-radius: 3px;
  font-family: monospace;
  font-size: 0.9em;
}

.research-chat-messages .chat-bubble ol,
.research-chat-messages .chat-bubble ul {
  margin: var(--sp-2) 0;
  padding-left: var(--sp-5);
}

.research-chat-messages .chat-bubble ol { list-style: decimal; }
.research-chat-messages .chat-bubble ul { list-style: disc; }

.research-chat-messages .chat-bubble li {
  margin-bottom: 2px;
  line-height: 1.5;
}

/* Compact input row for the chat */
.research-chat-body .chat-input-row {
  gap: var(--sp-2);
}

.research-chat-body .chat-input {
  font-size: var(--text-sm);
  min-height: 2.5rem;
  resize: none;
}

.research-suggested-searches {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-4);
  border-top: 1px solid var(--border);
  align-items: center;
}

.research-suggested-label {
  font-size: var(--text-xs);
  color: var(--muted);
  font-weight: 600;
}

.research-suggested-btn {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  padding: 2px var(--sp-3);
  font-size: var(--text-xs);
  color: var(--accent);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.research-suggested-btn:hover {
  background: var(--bg-1);
  border-color: var(--accent);
}

/* ---- Research Report ---- */
.research-report-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-3);
}

.research-report-header .section-title { margin-bottom: 0; }

/* Saved reports list */
.research-saved-report-item {
  padding: var(--sp-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: border-color var(--t-fast), background var(--t-fast);
  margin-bottom: var(--sp-2);
}

.research-saved-report-item:hover {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.research-saved-report-meta {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-bottom: 4px;
}

.research-saved-report-date {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text);
}

.research-saved-report-patterns {
  font-size: var(--text-xs);
  color: var(--text-3);
}

.research-saved-report-preview {
  font-size: var(--text-xs);
  color: var(--text-2);
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ================================================================
   PREFERENCE CARDS
================================================================ */
.pref-card {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  cursor: pointer;
  transition: border-color var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast);
}

.pref-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}

.pref-card-image {
  position: relative;
  background: var(--surface);
  aspect-ratio: 4/3;
  overflow: hidden;
}

.pref-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.pref-card-no-image {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-sm);
  color: var(--text-3);
  text-align: center;
  padding: var(--sp-3);
}

.pref-card-match {
  position: absolute;
  top: var(--sp-2);
  right: var(--sp-2);
  background: var(--accent);
  color: #fff;
  font-size: var(--text-xs);
  font-weight: 700;
  padding: 2px var(--sp-2);
  border-radius: var(--r-full);
}

.pref-card-body {
  padding: var(--sp-3);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.pref-card-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
}

.pref-card-stars {
  color: var(--yellow);
  font-size: var(--text-sm);
  letter-spacing: 1px;
  line-height: 1;
}

.pref-card-source {
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 1px var(--sp-2);
  border-radius: var(--r-full);
  border: 1px solid var(--border);
  color: var(--text-3);
  background: var(--surface);
}

.pref-card-source--research {
  border-color: var(--blue);
  color: var(--blue);
  background: var(--blue-dim);
}

.pref-card-source--upload {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}

.pref-card-colors {
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
}

.pref-card-swatch {
  width: 16px;
  height: 16px;
  border-radius: var(--r-sm);
  border: 1px solid rgba(255,255,255,0.1);
}

.pref-card-summary {
  font-size: var(--text-xs);
  color: var(--text-2);
  line-height: 1.4;
  margin: 0;
}

.pref-card-note {
  font-size: var(--text-xs);
  color: var(--text-3);
  font-style: italic;
  line-height: 1.4;
  margin: 0;
}

.pref-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}

.pref-mood-tag {
  border-color: var(--purple, var(--accent));
  color: var(--purple, var(--accent-2));
}

/* ================================================================
   ARCHITECTURE — Approval Flow
================================================================ */

/* Review / Approved banner */
.arch-banner {
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md);
  font-size: var(--text-sm);
  line-height: 1.5;
}

.arch-banner--review {
  background: var(--yellow-dim);
  border: 1px solid var(--yellow);
  color: var(--yellow);
}

.arch-banner--approved {
  background: var(--green-dim);
  border: 1px solid var(--green);
  color: var(--green);
}

.arch-banner-icon {
  font-weight: 700;
  margin-right: var(--sp-1);
}

/* Approve button — prominent amber/gold */
.arch-approve-btn {
  background: var(--yellow);
  color: #1a1a1a;
  font-weight: 700;
  padding: var(--sp-2) var(--sp-5);
  font-size: var(--text-sm);
  border-radius: var(--r-md);
  animation: arch-glow 2s ease-in-out infinite;
}

.arch-approve-btn:hover {
  background: #e6b800;
}

@keyframes arch-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(245, 197, 24, 0); }
  50% { box-shadow: 0 0 12px 2px rgba(245, 197, 24, 0.3); }
}

/* Action group */
.arch-action-group {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

/* Next step button */
.arch-next-btn {
  margin-top: var(--sp-5);
  width: 100%;
  justify-content: center;
  font-size: var(--text-sm);
  padding: var(--sp-3);
}

/* Approved card border */
.arch-approved-card {
  border-color: var(--green);
}

/* Locked refine panel after approval */
.arch-locked {
  opacity: 0.4;
  pointer-events: none;
}

/* Chat composer dimmed when its phase is finalized — JBA-148 */
.chat-input-row.is-locked {
  opacity: 0.5;
}

/* ================================================================
   DESIGN MODE — SAVED DIRECTIONS LIST
================================================================ */
.design-saved-item {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding: var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-2);
  transition: border-color 0.15s;
}

.design-saved-item:not(:last-child) {
  margin-bottom: var(--sp-2);
}

.design-saved-item--active {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 6%, var(--bg-2));
}

.design-saved-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
}

.design-saved-item-colors {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.design-saved-swatch {
  display: inline-block;
  width: 18px;
  height: 18px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.design-saved-item-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  flex-shrink: 0;
}

.design-saved-active-badge {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--accent);
  padding: 2px 8px;
  border: 1px solid var(--accent);
  border-radius: var(--r-full);
}

.design-saved-item-detail {
  font-size: var(--text-sm);
  color: var(--text-2);
  line-height: 1.4;
}

.design-saved-item-meta {
  font-size: var(--text-xs);
  color: var(--text-3);
}

.design-saved-use-btn,
.design-saved-delete-btn {
  font-size: var(--text-xs);
  padding: 2px 8px;
}

.design-saved-delete-btn {
  color: var(--text-3);
}
.design-saved-delete-btn:hover {
  color: var(--red, #ef4444);
}

/* Save confirmation state */
.design-saved-confirmed {
  opacity: 0.7;
  pointer-events: none;
}

/* Next step link after save */
.design-next-step {
  margin-top: var(--sp-3);
  text-align: center;
}

.design-next-btn {
  width: 100%;
  justify-content: center;
  font-size: var(--text-sm);
  padding: var(--sp-3);
}

/* ================================================================
   DESIGN MODE — PALETTE HISTORY (Regenerate Palette)
================================================================ */
.palette-history-controls {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-top: var(--sp-2);
}

.palette-history {
  margin-top: var(--sp-2);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.palette-history-item {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-2);
  font-size: var(--text-sm);
}

.palette-history-item .proposal-history-swatch {
  width: 20px;
  height: 20px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.palette-history-restore-btn {
  margin-left: auto;
  font-size: var(--text-xs);
  white-space: nowrap;
}

/* ================================================================
   PHASE GATE BANNERS (cross-mode awareness)
================================================================ */
.phase-gate-banner {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-5);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--r-md);
  background: color-mix(in srgb, var(--accent) 5%, var(--bg-3));
  margin-bottom: var(--sp-5);
}

.phase-gate-icon {
  font-size: 1.5rem;
  color: var(--accent);
  flex-shrink: 0;
}

.phase-gate-text {
  flex: 1;
  font-size: var(--text-sm);
  color: var(--text-2);
  line-height: 1.5;
}

.phase-gate-text strong {
  color: var(--text);
  display: block;
  margin-bottom: 2px;
}

.phase-gate-link {
  flex-shrink: 0;
  white-space: nowrap;
}

/* ================================================================
   ACTIVE DESIGN DIRECTION BANNER (Critique Mode)
================================================================ */
.active-design-banner {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-3);
  margin-bottom: var(--sp-4);
}

.active-design-label {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-3);
  flex-shrink: 0;
}

.active-design-swatches {
  display: flex;
  gap: 3px;
}

.active-design-swatch {
  width: 20px;
  height: 20px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
}

.active-design-summary {
  font-size: var(--text-sm);
  color: var(--text-2);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.active-design-remove-btn {
  flex-shrink: 0;
  color: var(--text-3);
}
.active-design-remove-btn:hover {
  color: var(--red, #ef4444);
}

/* ================================================================
   CRITIQUE MODE — DIRECTION PREVIEW
================================================================ */
.critique-direction-preview {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding: var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-2);
  margin-bottom: var(--sp-3);
}

.critique-dir-colors {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-bottom: var(--sp-1);
}

.critique-dir-swatch {
  width: 24px;
  height: 24px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
}

.critique-dir-field {
  font-size: var(--text-xs);
  color: var(--text-2);
  line-height: 1.5;
}

.critique-dir-field strong {
  color: var(--text);
}

/* ================================================================
   SAVED DIRECTIONS — ENHANCED
================================================================ */
#design-saved-body.collapsed {
  display: none;
}

.design-saved-item-name {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.design-saved-item-typo {
  font-size: var(--text-xs);
  color: var(--text-3);
  font-style: italic;
}

.design-saved-item-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  margin-top: var(--sp-1);
}

.design-saved-critique-btn,
.design-saved-recall-btn {
  font-size: 0.65rem;
  padding: 2px 10px;
  white-space: nowrap;
}

.design-saved-recall-btn {
  color: var(--text-3);
  border-color: var(--border);
}
.design-saved-recall-btn:hover {
  color: var(--red, #ef4444);
  border-color: var(--red, #ef4444);
}

.design-saved-expand {
  margin-top: var(--sp-2);
  padding-top: var(--sp-2);
  border-top: 1px solid var(--border);
}

.design-saved-expand-section {
  font-size: var(--text-xs);
  color: var(--text-2);
  line-height: 1.5;
  margin-bottom: var(--sp-1);
}

.design-saved-expand-section strong {
  color: var(--text);
}

/* ================================================================
   DESIGN MODE — WINNER BADGE
================================================================ */
.design-saved-winner-badge {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--green);
  background: var(--green-dim);
  padding: 2px 8px;
  border-radius: var(--r-full);
  border: 1px solid var(--green);
  white-space: nowrap;
}

.design-saved-item--winner {
  border-color: var(--green);
  background: color-mix(in srgb, var(--green) 6%, var(--bg-2));
}

/* Revision indicator — indented child direction */
.design-saved-item--revision {
  margin-left: var(--sp-5);
  border-left: 2px solid var(--accent);
}

.design-saved-lineage {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  padding: 0 0 var(--sp-2);
  font-size: var(--text-xs);
  color: var(--text-3);
  line-height: 1;
}

.design-lineage-icon {
  font-size: var(--text-sm);
  color: var(--accent);
  flex-shrink: 0;
}

.design-lineage-text strong {
  color: var(--text-2);
  font-weight: 600;
}

.design-saved-children-badge {
  display: inline-block;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-dim);
  padding: 1px 6px;
  border-radius: var(--r-full);
  margin-left: var(--sp-2);
  white-space: nowrap;
}

/* In-Critique badge shown on Design Mode saved directions */
.design-saved-in-critique-badge {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--blue);
  background: var(--blue-dim);
  padding: 2px 8px;
  border-radius: var(--r-full);
  border: 1px solid var(--blue);
  white-space: nowrap;
}

/* ================================================================
   CRITIQUE MODE — DIRECTION TABS BAR
================================================================ */
.critique-directions-bar {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) 0;
  margin-bottom: var(--sp-4);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}

.critique-dir-tabs {
  display: flex;
  gap: var(--sp-2);
  flex: 1;
  min-width: 0;
  overflow-x: auto;
}

.critique-dir-tab {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: all var(--t-fast);
  white-space: nowrap;
  flex-shrink: 0;
  position: relative;
}

.critique-dir-tab:hover {
  border-color: var(--text-3);
}

.critique-dir-tab--active {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.critique-dir-tab--done {
  border-color: var(--green);
}

.critique-dir-tab--done .critique-tab-check {
  display: inline;
}

.critique-tab-swatch {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1px solid rgba(255,255,255,0.1);
  flex-shrink: 0;
}

.critique-tab-label {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.critique-dir-tab--active .critique-tab-label {
  color: var(--accent);
}

.critique-tab-check {
  display: none;
  font-size: var(--text-xs);
  color: var(--green);
  font-weight: 700;
}

.critique-tab-winner {
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--green);
  background: var(--green-dim);
  padding: 1px 6px;
  border-radius: var(--r-full);
  border: 1px solid var(--green);
}

.critique-tab-version {
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-dim);
  padding: 1px 5px;
  border-radius: var(--r-full);
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  white-space: nowrap;
}

.critique-tab-remove {
  background: none;
  border: none;
  color: var(--text-3);
  font-size: var(--text-sm);
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
  border-radius: var(--r-sm);
  transition: color var(--t-fast), background var(--t-fast);
  opacity: 0;
}

.critique-dir-tab:hover .critique-tab-remove {
  opacity: 1;
}

.critique-tab-remove:hover {
  color: var(--red);
  background: var(--red-dim);
}

/* ================================================================
   CRITIQUE MODE — COMPARE VIEW
================================================================ */
.critique-compare-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--sp-4);
  padding: var(--sp-4) 0;
}

.critique-compare-col {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}

.critique-compare-col--winner {
  border-color: var(--green);
  box-shadow: 0 0 0 1px var(--green-dim), 0 4px 16px rgba(0,0,0,0.15);
}

.critique-compare-header {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}

.critique-compare-name {
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.critique-compare-total {
  font-size: var(--text-lg);
  font-weight: 800;
  color: var(--accent);
}

.critique-compare-swatches {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.critique-compare-swatch {
  width: 22px;
  height: 22px;
  border-radius: var(--r-sm);
  border: 1px solid rgba(255,255,255,0.1);
}

.critique-compare-scores {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}

.score-row-compact {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-1) var(--sp-2);
  border-radius: var(--r-sm);
  background: var(--surface);
  font-size: var(--text-xs);
}

.score-row-compact .score-label {
  color: var(--text-2);
  font-weight: 600;
}

.score-row-compact .score-value {
  color: var(--text);
  font-weight: 700;
}

.critique-compare-summary {
  font-size: var(--text-sm);
  color: var(--text-2);
  line-height: 1.5;
}

.critique-compare-fixes {
  font-size: var(--text-xs);
  color: var(--text-3);
  line-height: 1.5;
}

.critique-compare-fixes strong {
  color: var(--text-2);
  display: block;
  margin-bottom: 2px;
}

.critique-compare-actions {
  margin-top: auto;
  padding-top: var(--sp-3);
  border-top: 1px solid var(--border);
}

/* Winner badge in compare view */
.critique-winner-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--green);
  background: var(--green-dim);
  padding: 3px 10px;
  border-radius: var(--r-full);
  border: 1px solid var(--green);
}

.critique-pick-winner-btn {
  width: 100%;
  justify-content: center;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border-2);
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--r-md);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--t-fast);
}

.critique-pick-winner-btn:hover {
  background: var(--green-dim);
  border-color: var(--green);
  color: var(--green);
}

/* Compare toggle button */
.critique-compare-btn {
  flex-shrink: 0;
  white-space: nowrap;
}

.critique-compare-btn.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}

/* ================================================================
   CRITIQUE MODE — ACTIONABLE FIX LIST
================================================================ */
.fix-list-actionable {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.fix-empty {
  font-size: var(--text-sm);
  color: var(--text-3);
  padding: var(--sp-2) 0;
}

.fix-item {
  padding: var(--sp-3);
  border: 1px solid var(--red, #ef4444);
  border-left: 3px solid var(--red, #ef4444);
  border-radius: var(--r-md);
  background: var(--red-dim, rgba(239, 68, 68, 0.08));
  transition: opacity 0.2s, max-height 0.25s ease, padding 0.25s ease, margin 0.25s ease, border-color 0.15s;
  overflow: hidden;
}

.fix-item:hover {
  border-color: var(--red, #ef4444);
  background: color-mix(in srgb, var(--red, #ef4444) 12%, var(--surface));
}

.fix-item--applied {
  border-color: var(--green);
  background: color-mix(in srgb, var(--green) 6%, var(--surface));
}

.fix-item--applied:hover {
  border-color: var(--green);
}

.fix-item-main {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
}

.fix-item-text {
  flex: 1;
  font-size: var(--text-sm);
  color: var(--text-2);
  line-height: 1.5;
  min-width: 0;
}

.fix-item--applied .fix-item-text {
  color: var(--text-3);
}

.fix-item--applied .fix-item-text s {
  text-decoration: line-through;
}

.fix-applied-badge {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--green);
  white-space: nowrap;
  flex-shrink: 0;
}

.fix-item--reverted {
  border-color: #F59E0B;
  background: color-mix(in srgb, #F59E0B 6%, var(--surface));
}
.fix-item--reverted:hover {
  border-color: #F59E0B;
}
.fix-item--reverted .fix-item-text {
  color: var(--text-3);
}
.fix-reverted-badge {
  font-size: var(--text-xs);
  font-weight: 700;
  color: #F59E0B;
  white-space: nowrap;
  flex-shrink: 0;
}
.fix-reverted-reason {
  font-size: var(--text-xs);
  color: #F59E0B;
  opacity: 0.8;
  margin-top: var(--sp-1);
  padding-left: var(--sp-1);
}

/* Fix History panel */
.fix-history-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.fix-history-entry {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  padding: 6px 10px;
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid transparent;
  transition: all 0.15s ease;
}
.fix-history-entry:hover {
  background: var(--surface-2);
  border-color: var(--border);
}
.fix-history-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--text-xs);
  color: var(--text-2);
}
.fix-history-deltas {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.fix-history-delta {
  font-size: 0.7rem;
  font-weight: 600;
  white-space: nowrap;
}
.fix-history-delta--up { color: var(--green); }
.fix-history-delta--down { color: var(--red, #ef4444); }
.fix-history-type {
  font-size: 0.65rem;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}
#critique-undo-btn {
  margin-left: auto;
}

.fix-item-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  flex-shrink: 0;
}

.fix-apply-btn {
  white-space: nowrap;
}

.fix-explain-btn {
  white-space: nowrap;
  color: var(--text-3) !important;
  font-style: italic;
}

.fix-explain-btn:hover {
  color: var(--accent) !important;
}

.fix-dismiss-btn {
  background: none;
  border: none;
  color: var(--text-3);
  font-size: var(--text-base);
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
  border-radius: var(--r-sm);
  transition: color var(--t-fast), background var(--t-fast);
  opacity: 0;
}

.fix-item:hover .fix-dismiss-btn {
  opacity: 1;
}

.fix-dismiss-btn:hover {
  color: var(--red);
  background: var(--red-dim);
}

/* Explain expansion panel */
.fix-explain-panel {
  margin-top: var(--sp-2);
  padding-top: var(--sp-2);
  border-top: 1px solid var(--border);
}

.fix-explain-panel.hidden {
  display: none;
}

.fix-explain-loading {
  font-size: var(--text-xs);
  color: var(--text-3);
  font-style: italic;
}

.fix-explain-text {
  font-size: var(--text-xs);
  color: var(--text-2);
  line-height: 1.5;
  display: block;
}

/* ================================================================
   CRITIQUE MODE — SEND TO STYLE GUIDE ACTION
================================================================ */
.critique-stale-banner {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: color-mix(in srgb, var(--yellow) 10%, var(--bg-3));
  border: 1px solid color-mix(in srgb, var(--yellow) 40%, var(--border));
  border-left: 3px solid var(--yellow);
  border-radius: var(--r-lg);
  margin-bottom: var(--sp-4);
  font-size: var(--text-sm);
  color: var(--yellow);
  line-height: 1.5;
}

.critique-stale-icon {
  font-size: var(--text-lg);
  flex-shrink: 0;
}

/* Re-Critique Direction button — inline in Critique Results header.
   Purple left-accent by default; shifts to gold when --stale (design updated). */
.critique-direction-btn {
  background: rgba(255, 255, 255, 0.05);
  color: #e2e8f0;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-left: 3px solid #7c3aed;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}
.critique-direction-btn:hover {
  background: rgba(124, 58, 237, 0.1);
  box-shadow: 0 0 12px rgba(124, 58, 237, 0.15);
}
.critique-direction-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.critique-direction-btn--stale {
  border-left-color: #F59E0B;
}
.critique-direction-btn--stale:hover {
  background: rgba(245, 158, 11, 0.1);
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.15);
}
.critique-direction-btn .spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-top-color: #e2e8f0;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

/* Re-evaluating overlay */
.critique-reeval-overlay {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: color-mix(in srgb, var(--accent) 8%, var(--bg-3));
  border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--border));
  border-radius: var(--r-lg);
  margin-bottom: var(--sp-3);
  font-size: var(--text-sm);
  color: var(--accent);
  animation: critique-reeval-pulse 1.5s ease-in-out infinite;
}
.critique-reeval-overlay.hidden { display: none; }

@keyframes critique-reeval-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.critique-reeval-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: critique-reeval-spin 0.8s linear infinite;
  flex-shrink: 0;
}

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

.critique-scorecard--loading {
  opacity: 0.45;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

/* --- AI working / loading states --- */
.critique-ai-loading {
  padding: var(--sp-4);
}

.critique-ai-loading-row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-bottom: var(--sp-4);
  font-size: var(--text-sm);
  color: var(--text-2);
}

.critique-ai-loading-skeletons {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.critique-skeleton-card {
  height: 48px;
  border-radius: var(--r-md);
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 50%, var(--surface) 75%);
  background-size: 200% 100%;
  animation: critique-skeleton-shimmer 1.5s ease-in-out infinite;
}

.critique-skeleton-card--short {
  width: 65%;
}

@keyframes critique-skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.critique-ai-loading-slow {
  margin-top: var(--sp-3);
  font-size: var(--text-xs);
  color: var(--text-3);
  animation: critique-reeval-pulse 1.5s ease-in-out infinite;
}

/* Analyzing dimension row — pulsing bar */
.score-row--analyzing .score-bar {
  animation: critique-analyzing-bar 1s ease-in-out infinite;
}

@keyframes critique-analyzing-bar {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.score-row--analyzing {
  background: color-mix(in srgb, var(--primary) 5%, transparent);
  border-radius: var(--r-sm);
  margin: -2px -4px;
  padding: 2px 4px;
}

/* Focus button loading state */
.score-focus-btn--loading {
  min-width: 44px;
  pointer-events: none;
  background: color-mix(in srgb, var(--primary) 10%, transparent);
  border-color: color-mix(in srgb, var(--primary) 30%, var(--border));
}

.score-focus-btn--loading .critique-reeval-spinner {
  width: 12px;
  height: 12px;
  border-width: 1.5px;
}

/* Apply All progress + stop */
.fix-apply-all-progress {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--text-sm);
  color: var(--accent);
}

.fix-apply-all-label {
  white-space: nowrap;
}

.fix-apply-all-stop {
  color: var(--red) !important;
  border-color: var(--red) !important;
  padding: var(--sp-1) var(--sp-3) !important;
  font-size: var(--text-xs) !important;
  flex-shrink: 0;
}
.fix-apply-all-stop:hover {
  background: color-mix(in srgb, var(--red) 10%, transparent) !important;
}

/* ================================================================
   CRITIQUE MODE — LOCK SYSTEM
================================================================ */

/* --- Color lock toggle (prominent, near color swatches) --- */
.critique-color-lock {
  margin-top: var(--sp-3);
}

.critique-lock-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text-2);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--t-fast);
}

.critique-lock-toggle:hover {
  background: var(--surface-2);
  border-color: var(--border-2);
  color: var(--text);
}

.critique-lock-toggle--active {
  background: color-mix(in srgb, var(--yellow) 12%, var(--surface));
  border-color: color-mix(in srgb, var(--yellow) 40%, var(--border));
  color: var(--yellow);
}

.critique-lock-toggle--active:hover {
  background: color-mix(in srgb, var(--yellow) 18%, var(--surface));
}

.lock-icon {
  font-size: var(--text-base);
  line-height: 1;
}

.lock-label {
  line-height: 1;
}

/* --- Scorecard lock buttons --- */
.score-lock-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  flex-shrink: 0;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  font-size: var(--text-xs);
  color: var(--text-3);
  cursor: pointer;
  opacity: 0.4;
  transition: all var(--t-fast);
}

.score-row:hover .score-lock-btn {
  opacity: 0.7;
}

.score-lock-btn:hover {
  opacity: 1 !important;
  background: var(--surface-2);
  border-color: var(--border);
}

.score-lock-btn--active {
  opacity: 1 !important;
  color: var(--yellow);
  background: color-mix(in srgb, var(--yellow) 10%, transparent);
  border-color: color-mix(in srgb, var(--yellow) 30%, var(--border));
}

.score-lock-btn--active:hover {
  background: color-mix(in srgb, var(--yellow) 16%, transparent);
}

/* Locked score row */
.score-row--locked .score-label {
  color: var(--text-3);
}

.score-row--locked .score-value {
  color: var(--text-3);
}

.score-bar.locked {
  background: color-mix(in srgb, var(--text-3) 30%, transparent);
}

/* --- Threshold control --- */
.threshold-control {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) 0;
  margin-bottom: var(--sp-2);
}

.threshold-label {
  font-size: var(--text-xs);
  color: var(--text-3);
  white-space: nowrap;
}

.threshold-slider {
  flex: 1;
  max-width: 120px;
  height: 4px;
  accent-color: var(--primary);
  cursor: pointer;
}

.threshold-value {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-2);
  min-width: 32px;
}

/* --- Threshold / Focus indicators on score rows --- */
.score-row--passed .score-label {
  color: var(--green);
}

.score-row--passed .score-value {
  color: var(--green);
}

.score-passed-badge {
  color: var(--green);
  font-size: var(--text-sm);
  font-weight: 700;
  flex-shrink: 0;
  width: 28px;
  text-align: center;
}

/* Score delta indicators (after re-critique) */
.score-delta {
  font-size: 0.7rem;
  font-weight: 700;
  margin-left: 4px;
  vertical-align: super;
  line-height: 1;
}
.score-delta--up {
  color: var(--green);
}
.score-delta--down {
  color: var(--red, #ef4444);
}
.score-focus-btn {
  flex-shrink: 0;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--yellow);
  background: color-mix(in srgb, var(--yellow) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--yellow) 30%, var(--border));
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: all var(--t-fast);
}

.score-focus-btn:hover {
  background: color-mix(in srgb, var(--yellow) 20%, transparent);
  border-color: var(--yellow);
}

.score-focus-btn:disabled {
  opacity: 0.5;
  cursor: wait;
}

/* --- Phase toggle (Major / Fine-Tune) --- */
.critique-phase-toggle {
  flex-shrink: 0;
}

.phase-toggle-group {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}

.phase-toggle-btn {
  padding: 5px 14px;
  font-size: var(--text-xs);
  font-weight: 600;
  background: transparent;
  border: none;
  border-radius: calc(var(--r-md) - 2px);
  color: var(--text-3);
  cursor: pointer;
  transition: all var(--t-fast);
}

.phase-toggle-btn:hover:not(.phase-toggle-btn--active) {
  color: var(--text-1);
  background: color-mix(in srgb, var(--text-3) 8%, transparent);
}

.phase-toggle-btn--active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
}

.phase-toggle-btn--active:hover {
  background: var(--primary);
  color: #fff;
}

/* Phase banners */
.phase-suggest-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  margin-bottom: var(--sp-3);
  background: color-mix(in srgb, var(--green) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--green) 30%, var(--border));
  border-radius: var(--r-md);
  font-size: var(--text-sm);
  color: var(--text-2);
}

.phase-active-banner {
  padding: var(--sp-2) var(--sp-3);
  margin-bottom: var(--sp-3);
  border-radius: var(--r-md);
  font-size: var(--text-sm);
  font-weight: 500;
}

.phase-active-banner--finetune {
  background: color-mix(in srgb, var(--primary) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--primary) 25%, var(--border));
  color: var(--primary);
}

/* Fine-tune mode: softer fix cards */
.fix-list--finetune .fix-category-group {
  border-color: color-mix(in srgb, var(--primary) 25%, var(--border));
}

.fix-list--finetune .fix-category-header {
  background: color-mix(in srgb, var(--primary) 6%, transparent);
}

.fix-list--finetune .fix-item {
  border-left: 3px solid color-mix(in srgb, var(--primary) 40%, transparent);
}

.fix-list--finetune .fix-apply-btn {
  background: var(--primary);
  border-color: var(--primary);
}

/* --- Fix focus banner --- */
.fix-focus-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  margin-bottom: var(--sp-3);
  background: color-mix(in srgb, var(--yellow) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--yellow) 30%, var(--border));
  border-radius: var(--r-md);
  flex-wrap: wrap;
}

.fix-focus-banner-left,
.fix-focus-banner-right {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.fix-focus-label {
  font-size: var(--text-sm);
  color: var(--text-2);
}

.fix-focus-label strong {
  color: var(--yellow);
}

.fix-focus-reset-btn {
  white-space: nowrap;
  flex-shrink: 0;
}

.fix-focus-apply-all-btn {
  white-space: nowrap;
  flex-shrink: 0;
}

/* --- Fix category groups --- */
.fix-category-group {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  margin-bottom: var(--sp-2);
}

.fix-category-group--locked {
  border-color: color-mix(in srgb, var(--yellow) 30%, var(--border));
  background: color-mix(in srgb, var(--yellow) 4%, transparent);
}

.fix-category-header {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  user-select: none;
}

.fix-category-group--locked .fix-category-header {
  background: color-mix(in srgb, var(--yellow) 6%, var(--surface));
  border-bottom-color: color-mix(in srgb, var(--yellow) 20%, var(--border));
}

.fix-category-collapse {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  padding: 0;
  background: transparent;
  border: none;
  color: var(--text-3);
  font-size: var(--text-xs);
  cursor: pointer;
  transition: transform var(--t-fast);
  flex-shrink: 0;
}

.fix-category-collapse:hover {
  color: var(--text-2);
}

.fix-cat-chevron {
  display: inline-block;
  transition: transform 0.2s ease;
  font-size: 10px;
}

.fix-cat-chevron--collapsed {
  transform: rotate(-90deg);
}

.fix-category-label {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--text);
  text-transform: capitalize;
  flex: 1;
}

.fix-category-group--locked .fix-category-label {
  color: var(--text-3);
}

.fix-category-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--text-3);
  background: var(--surface-2);
  border-radius: var(--r-full);
}

.fix-category-lock {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  flex-shrink: 0;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  font-size: var(--text-xs);
  color: var(--text-3);
  cursor: pointer;
  opacity: 0.5;
  transition: all var(--t-fast);
}

.fix-category-header:hover .fix-category-lock {
  opacity: 0.8;
}

.fix-category-lock:hover {
  opacity: 1 !important;
  background: var(--surface-2);
  border-color: var(--border);
}

.fix-category-lock--active {
  opacity: 1 !important;
  color: var(--yellow);
  background: color-mix(in srgb, var(--yellow) 10%, transparent);
  border-color: color-mix(in srgb, var(--yellow) 30%, var(--border));
}

.fix-category-lock--active:hover {
  background: color-mix(in srgb, var(--yellow) 16%, transparent);
}

.fix-category-items {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
}

.fix-category-items.hidden {
  display: none;
}

/* Remove outer margin/border on fix items inside category groups */
.fix-category-items .fix-item {
  margin-bottom: 0;
}

/* Locked category fix items */
.fix-item--cat-locked {
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid color-mix(in srgb, var(--yellow) 20%, var(--border));
  border-left: 3px solid color-mix(in srgb, var(--yellow) 40%, var(--border));
  border-radius: var(--r-md);
  background: color-mix(in srgb, var(--yellow) 4%, var(--surface));
  opacity: 0.6;
}

.fix-item-text--locked {
  flex: 1;
  font-size: var(--text-sm);
  color: var(--text-3);
  line-height: 1.5;
  text-decoration: line-through;
  text-decoration-color: color-mix(in srgb, var(--text-3) 50%, transparent);
}

.fix-locked-badge {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--yellow);
  white-space: nowrap;
  flex-shrink: 0;
}

/* --- Locked dimension feedback --- */
.dim-locked-badge {
  display: inline-block;
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--yellow);
  margin-left: var(--sp-2);
  vertical-align: middle;
}

.brief-field--locked {
  opacity: 0.5;
  border-left: 2px solid color-mix(in srgb, var(--yellow) 40%, var(--border));
  padding-left: var(--sp-3);
}

.critique-styleguide-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  background: color-mix(in srgb, var(--green) 6%, var(--bg-3));
  border: 1px solid color-mix(in srgb, var(--green) 30%, var(--border));
  border-radius: var(--r-lg);
  margin-top: var(--sp-4);
}

.critique-styleguide-hint {
  font-size: var(--text-sm);
  color: var(--text-2);
  line-height: 1.5;
  flex: 1;
  margin: 0;
}

.critique-send-guide-btn {
  flex-shrink: 0;
  white-space: nowrap;
}

.critique-goto-guide-btn {
  flex-shrink: 0;
  white-space: nowrap;
}

/* ================================================================
   STYLE GUIDE MODE — CONTEXT BANNER
================================================================ */
.guide-context-banner {
  padding: var(--sp-4) var(--sp-5);
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-left: 3px solid var(--green);
  border-radius: var(--r-md);
  margin-bottom: var(--sp-4);
}

.guide-context-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-3);
}

.guide-context-label {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--green);
}

.guide-context-body {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.guide-context-body.collapsed {
  display: none;
}

.guide-context-swatches {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.guide-context-swatch {
  width: 28px;
  height: 28px;
  border-radius: var(--r-sm);
  border: 1px solid rgba(255,255,255,0.1);
}

.guide-context-details {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.guide-context-field {
  font-size: var(--text-sm);
  color: var(--text-2);
  line-height: 1.5;
}

.guide-context-dim {
  color: var(--text-3);
  font-weight: 600;
}

/* ================================================================
   STYLE GUIDE MODE — GENERATE INPUTS
================================================================ */
.guide-generate-inputs {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  margin-bottom: var(--sp-3);
  padding: var(--sp-3);
  background: var(--surface);
  border-radius: var(--r-md);
  border: 1px solid var(--border);
}

.guide-input-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: var(--text-xs);
}

.guide-input-label {
  color: var(--text-3);
  font-weight: 600;
}

.guide-input-value {
  color: var(--text-3);
  font-weight: 600;
}

.guide-input-value.guide-input-ready {
  color: var(--green);
}

/* ================================================================
   STYLE GUIDE MODE — SECTION NAVIGATION / TOC
================================================================ */
.guide-toc {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.guide-toc-item {
  display: block;
  padding: var(--sp-1) var(--sp-2);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-2);
  text-decoration: none;
  border-radius: var(--r-sm);
  transition: all var(--t-fast);
}

.guide-toc-item:hover {
  color: var(--accent);
  background: var(--accent-dim);
}

.guide-toc-l2 {
  padding-left: var(--sp-4);
}

.guide-toc-l3 {
  padding-left: var(--sp-6);
  font-weight: 500;
  color: var(--text-3);
}

/* ================================================================
   STYLE GUIDE MODE — RENDERED CONTENT
================================================================ */
.guide-rendered-content {
  font-size: var(--text-sm);
  color: var(--text-2);
  line-height: 1.6;
}

.guide-h1 {
  font-size: var(--text-xl, 1.25rem);
  font-weight: 800;
  color: var(--text);
  margin: var(--sp-6) 0 var(--sp-3);
  padding-bottom: var(--sp-2);
  border-bottom: 2px solid var(--accent);
}

.guide-h1:first-child {
  margin-top: 0;
}

.guide-h2 {
  font-size: var(--text-lg, 1.125rem);
  font-weight: 700;
  color: var(--text);
  margin: var(--sp-5) 0 var(--sp-2);
  padding-bottom: var(--sp-1);
  border-bottom: 1px solid var(--border);
}

.guide-h3 {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text);
  margin: var(--sp-4) 0 var(--sp-2);
}

.guide-h4 {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text);
  margin: var(--sp-3) 0 var(--sp-1);
}

.guide-p {
  margin: 0 0 var(--sp-2);
}

.guide-list {
  margin: var(--sp-2) 0;
  padding-left: var(--sp-5);
  list-style: disc;
}

.guide-list-ol {
  list-style: decimal;
}

.guide-list li {
  margin-bottom: 4px;
  line-height: 1.5;
}

.guide-list li strong {
  color: var(--text);
}

.guide-hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: var(--sp-5) 0;
}

.guide-code {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--sp-3);
  font-size: var(--text-xs);
  color: var(--text-2);
  overflow-x: auto;
  white-space: pre;
  line-height: 1.5;
  margin: var(--sp-2) 0;
}

.guide-inline-code {
  background: rgba(255,255,255,0.06);
  padding: 1px 5px;
  border-radius: 3px;
  font-family: monospace;
  font-size: 0.9em;
}

/* Inline color chip next to hex codes */
.guide-color-ref {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.guide-color-chip {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 2px;
  border: 1px solid rgba(255,255,255,0.15);
  vertical-align: middle;
  flex-shrink: 0;
}

/* ================================================================
   FORGE MODE (Phase 8)
================================================================ */

/* Toolbar */
.forge-toolbar {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 0 var(--sp-4) var(--sp-3);
}
.forge-viewport-bar {
  display: flex;
  gap: var(--sp-2);
}
.forge-viewport-btn, .forge-fs-viewport-btn {
  padding: var(--sp-1) var(--sp-3);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: all var(--t-fast);
}
.forge-viewport-btn.active, .forge-fs-viewport-btn.active {
  color: var(--text);
  background: var(--surface-2);
  border-color: var(--accent);
}
.forge-viewport-btn:hover:not(.active), .forge-fs-viewport-btn:hover:not(.active) {
  color: var(--text-2);
  border-color: var(--border-2);
}

/* Undo/Redo */
.forge-history-btns {
  display: flex;
  gap: 2px;
}

/* Zoom bar */
.forge-zoom-bar {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-left: auto;
}
.forge-zoom-label {
  font-size: var(--text-xs);
  color: var(--text-3);
  min-width: 36px;
  text-align: right;
}
.forge-zoom-slider {
  width: 80px;
  accent-color: var(--accent);
}

/* Layout */
.forge-layout {
  min-height: 600px;
}

/* Collapsible left panel */
.forge-left {
  position: relative;
  transition: width 0.3s ease, min-width 0.3s ease;
}
.forge-left.forge-left--collapsed {
  width: 48px !important;
  min-width: 48px !important;
}
.forge-left.forge-left--collapsed .forge-left-content {
  opacity: 0;
  pointer-events: none;
  position: absolute;
}
.forge-left.forge-left--collapsed .forge-left-icons {
  display: flex !important;
}
.forge-left-content {
  transition: opacity 0.2s ease;
}
.forge-left-icons {
  display: none;
  flex-direction: column;
  gap: var(--sp-2);
  padding: var(--sp-2);
  align-items: center;
}
.forge-icon-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: all var(--t-fast);
}
.forge-icon-btn:hover {
  background: var(--surface-2);
  border-color: var(--accent);
}
.forge-collapse-btn {
  position: absolute;
  top: var(--sp-2);
  right: -14px;
  z-index: 5;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 50%;
  cursor: pointer;
  transition: all var(--t-fast);
  color: var(--text-3);
}
.forge-collapse-btn:hover {
  color: var(--text);
  border-color: var(--accent);
}

/* Layout: sticky left panel, flowing right panel */
.forge-layout .panel-left {
  position: sticky;
  top: 0;
  align-self: flex-start;
  max-height: 100vh;
  overflow-y: auto;
}

/* Preview panel */
.forge-preview-panel {
  display: flex;
  flex-direction: column;
}
.forge-preview-container {
  position: relative; /* anchor for .bee-loader-overlay */
  background: color-mix(in srgb, var(--surface) 60%, #000);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.forge-preview-container.hidden { display: none; }

/* Bee loader overlay — covers the preview container; inner is fixed-positioned
 * (by JS) to track the visible intersection with the viewport so it stays
 * centered even when the preview grows taller than the screen. */
.bee-loader-overlay {
  position: absolute;
  inset: 0;
  background: #0a0a0a;
  z-index: 10;
  overflow: hidden;
}
.bee-loader-overlay.hidden { display: none; }
.bee-loader-inner {
  position: fixed;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  transform: translate(-50%, -50%);
  pointer-events: none;
  will-change: top, left;
}
.bee-loader-bob { animation: bee-loader-bob 2.5s ease-in-out infinite; }
.bee-loader-svg { width: 160px; height: auto; display: block; }
.bee-loader-svg #Wing_Color,
.bee-loader-svg .wing-outline {
  animation: bee-loader-wing .15s ease-in-out infinite alternate;
  transform-origin: 30% 45%;
}
.bee-loader-svg #Hearts {
  animation: bee-loader-heart 1.8s ease-in-out infinite;
  transform-origin: center;
}
.bee-loader-svg #Eyes_shine { animation: bee-loader-eye 4s ease-in-out infinite; }
.bee-loader-msg {
  color: #b388ff;
  font: 500 15px/1 system-ui, sans-serif;
}
@keyframes bee-loader-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-12px); }
}
@keyframes bee-loader-wing {
  from { opacity: .7; transform: scaleY(1); }
  to { opacity: .9; transform: scaleY(.85); }
}
@keyframes bee-loader-heart {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .6; transform: scale(1.15); }
}
@keyframes bee-loader-eye {
  0%, 42%, 46%, 100% { opacity: 1; }
  44% { opacity: 0; }
}

.forge-preview-scaler {
  transform-origin: top left;
  /* width and height set by JS to the scaled dimensions */
}
.forge-preview-iframe {
  width: 1280px;
  min-height: 800px;
  border: none;
  background: #fff;
  display: block;
  /* height set dynamically by _autoSizeIframe */
}

/* Full-screen overlay */
.forge-fullscreen-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: #111;
  display: flex;
  flex-direction: column;
}
.forge-fullscreen-overlay.hidden { display: none; }
.forge-fullscreen-toolbar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-4);
  padding: var(--sp-2) var(--sp-4);
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(8px);
}
.forge-exit-fullscreen-btn {
  position: absolute;
  right: var(--sp-4);
  padding: var(--sp-1) var(--sp-3);
  font-size: var(--text-xs);
  font-weight: 600;
  color: #fff;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background var(--t-fast);
}
.forge-exit-fullscreen-btn:hover {
  background: rgba(255,255,255,0.2);
}
.forge-fullscreen-preview {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  overflow: auto;
  padding: var(--sp-4);
}
.forge-fullscreen-iframe {
  width: 1280px;
  height: calc(100vh - 60px);
  border: none;
  background: #fff;
  border-radius: var(--r-sm);
  box-shadow: 0 4px 40px rgba(0,0,0,0.5);
}

/* Screen list */
.forge-screen-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background var(--t-fast);
}
.forge-screen-item:hover {
  background: var(--surface-2);
}
.forge-screen-item--active {
  background: var(--accent-dim);
  border-left: 2px solid var(--accent);
}
.forge-screen-name {
  font-size: var(--text-sm);
  color: var(--text);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.forge-screen-status {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 1px 6px;
  border-radius: var(--r-sm);
  font-weight: 600;
}
.forge-screen-status--pending { color: var(--text-3); }
.forge-screen-status--generated { color: var(--green); }
.forge-screen-status--refined { color: var(--accent-2); }
.forge-screen-status--generating {
  color: var(--accent);
  animation: forge-pulse 1.2s ease-in-out infinite;
}
@keyframes forge-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }
.forge-screen-delete {
  opacity: 0;
  background: none;
  border: none;
  color: var(--text-3);
  font-size: 16px;
  cursor: pointer;
  padding: 0 4px;
  transition: opacity var(--t-fast), color var(--t-fast);
}
.forge-screen-item:hover .forge-screen-delete { opacity: 1; }
.forge-screen-delete:hover { color: var(--red, #ef4444); }

/* View/Edit mode toggle — promoted to read as a primary mode switch (JBA-61) */
.forge-mode-toggle {
  display: flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  box-shadow: 0 0 0 1px var(--accent-dim, transparent);
}
.forge-mode-btn {
  padding: var(--sp-2) var(--sp-4);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-2);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all var(--t-fast);
}
.forge-mode-btn.active {
  color: var(--text);
  background: var(--accent);
  color: white;
}
.forge-mode-btn:hover:not(.active) {
  color: var(--text);
  background: var(--surface-2);
}

/* Edit mode preview border */
.forge-preview--edit {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 1px var(--accent), 0 0 12px rgba(124, 110, 245, 0.1);
}

/* Edit CLI panel — terminal-style input bar */
.forge-edit-cli {
  background: #0d0d12;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--r-lg);
  padding: var(--sp-2) var(--sp-3);
  margin-top: var(--sp-3);
}
.forge-edit-cli.hidden { display: none; }
.forge-edit-cli-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-2);
}
.forge-edit-cli-label {
  font: 500 12px/1 system-ui, sans-serif;
  color: var(--accent-2);
  cursor: help;
  border-bottom: 1px dotted rgba(155,143,248,0.3);
}
.forge-edit-cli-actions {
  display: flex;
  gap: var(--sp-2);
}
.forge-edit-cli-btn {
  font-size: 11px;
  font-weight: 600;
  color: rgba(255,255,255,0.4);
  background: none;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--r-sm);
  padding: 2px 8px;
  cursor: pointer;
  transition: all var(--t-fast);
}
.forge-edit-cli-btn:hover { color: rgba(255,255,255,0.7); border-color: rgba(255,255,255,0.15); }
.forge-edit-cli-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.forge-edit-cli-input-row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}
.forge-edit-cli-prompt {
  font: 400 16px/1 system-ui, sans-serif;
  color: rgba(255,255,255,0.25);
  flex-shrink: 0;
}
.forge-edit-cli-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font: 400 13px/1.4 'SF Mono', 'Cascadia Code', 'Fira Code', monospace;
  color: #e2e8f0;
  padding: 4px 0;
}
.forge-edit-cli-input::placeholder { color: rgba(255,255,255,0.2); }
.forge-edit-cli-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.1);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  flex-shrink: 0;
}
.forge-edit-cli-spinner.hidden { display: none; }

/* ================================================================
   SHOWCASE MODE (Phase 9)
================================================================ */

.showcase-variant-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-3);
  border: 1px solid transparent;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: all var(--t-fast);
}
.showcase-variant-item:hover { background: var(--surface-2); }
.showcase-variant-item--active { background: var(--accent-dim); border-color: var(--accent); }
.showcase-variant-item--winner { border-color: #F59E0B; }
.showcase-variant-info { flex: 1; min-width: 0; }
.showcase-variant-name {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.showcase-winner-badge {
  font-size: 0.65rem;
  font-weight: 700;
  color: #F59E0B;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-left: var(--sp-1);
}
.showcase-variant-meta {
  font-size: var(--text-xs);
  color: var(--text-3);
  margin-top: 2px;
}
.showcase-variant-colors {
  display: flex;
  gap: 3px;
  margin-top: 4px;
}
.showcase-swatch {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1px solid rgba(255,255,255,0.1);
}
.showcase-variant-actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity var(--t-fast);
}
.showcase-variant-item:hover .showcase-variant-actions { opacity: 1; }

/* Header */
.showcase-variant-header { margin-bottom: var(--sp-4); }
.showcase-variant-title { font-size: var(--text-lg); font-weight: 600; color: var(--text); }
.showcase-variant-desc { font-size: var(--text-sm); color: var(--text-2); margin-top: var(--sp-1); }

/* Screen tabs */
.showcase-screen-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: var(--sp-4);
  flex-wrap: wrap;
}
.showcase-screen-tab {
  padding: var(--sp-1) var(--sp-3);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: all var(--t-fast);
}
.showcase-screen-tab.active {
  color: var(--text);
  background: var(--surface-2);
  border-color: var(--accent);
}

/* Preview */
.showcase-preview-area { min-height: 300px; }
.showcase-iframe {
  width: 100%;
  min-height: 400px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: #fff;
}

/* Compare */
.showcase-compare-panels {
  display: flex;
  gap: var(--sp-4);
}
.showcase-compare-col { flex: 1; min-width: 0; }
.showcase-compare-label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--accent-2);
  margin-bottom: var(--sp-2);
  text-align: center;
}

/* Comments */
.showcase-comment {
  padding: var(--sp-2) 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  font-size: var(--text-sm);
  color: var(--text-2);
}
.showcase-comment strong { color: var(--text); }
.showcase-comment-text { margin-left: var(--sp-2); }
.showcase-comment-date { float: right; font-size: var(--text-xs); color: var(--text-3); }
