/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color: #1f2937;
  background: #f9fafb;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: #2563eb; text-decoration: none; }
a:hover { color: #1d4ed8; text-decoration: underline; }

/* === Header === */
.portal-header {
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 1.5rem;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.header-brand {
  display: flex;
  align-items: center;
  gap: 0.625rem;
}
.header-project {
  font-weight: 600;
  font-size: 0.9375rem;
  color: #111827;
}
.header-nav { display: flex; gap: 0.25rem; }
.nav-link {
  padding: 0.375rem 0.75rem;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  color: #4b5563;
  transition: background 0.15s, color 0.15s;
}
.nav-link:hover { background: #f3f4f6; color: #111827; text-decoration: none; }
.nav-link.active { background: #eff6ff; color: #2563eb; }
.nav-link--muted { color: #9ca3af; }

/* === Layout === */
.container { max-width: 960px; margin: 0 auto; padding: 2rem 1.5rem; flex: 1; }
.container--narrow { max-width: 720px; }
.portal-main { flex: 1; }
.portal-footer {
  text-align: center;
  padding: 1.5rem;
  color: #9ca3af;
  font-size: 0.8125rem;
  border-top: 1px solid #e5e7eb;
}

/* === Login === */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
  background: linear-gradient(135deg, #eff6ff 0%, #f9fafb 100%);
}
.login-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 2.5rem;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.login-logo { text-align: center; margin-bottom: 1rem; }
.login-title { text-align: center; font-size: 1.375rem; font-weight: 700; margin-bottom: 0.25rem; }
.login-subtitle { text-align: center; color: #6b7280; font-size: 0.875rem; margin-bottom: 1.5rem; }
.login-form { display: flex; flex-direction: column; gap: 1rem; }

/* === Typography === */
.page-title { font-size: 1.5rem; font-weight: 700; color: #111827; }
.page-subtitle { color: #6b7280; font-size: 0.9375rem; margin-top: 0.25rem; }
.text-muted { color: #9ca3af; }
.section-title { font-size: 0.9375rem; font-weight: 600; color: #374151; margin-bottom: 0.75rem; }

/* === Dashboard === */
.dashboard-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 1.5rem; }
.dashboard-header-actions { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.section { margin-top: 2rem; }
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }

/* === Info Card === */
.info-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  border-radius: 8px;
  padding: 1rem 1.25rem;
}
.info-card-label { font-size: 0.8125rem; color: #6b7280; margin-bottom: 0.125rem; }
.info-card-link { font-weight: 500; }

/* === Badge === */
.badge {
  background: #f3f4f6;
  color: #6b7280;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.125rem 0.5rem;
  border-radius: 10px;
}

/* === Status Badges === */
.status-badge {
  display: inline-block;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.125rem 0.5rem;
  border-radius: 4px;
}
.status-badge--lg { font-size: 0.75rem; padding: 0.25rem 0.625rem; margin-bottom: 0.5rem; }
.status--submitted { background: #dbeafe; color: #1d4ed8; }
.status--under-review { background: #fef3c7; color: #92400e; }
.status--approved { background: #d1fae5; color: #065f46; }
.status--rejected { background: #fee2e2; color: #991b1b; }
.status--in-progress { background: #e0e7ff; color: #3730a3; }
.status--completed { background: #ecfdf5; color: #047857; }

/* === Request List === */
.request-list { display: flex; flex-direction: column; gap: 0.5rem; }
.request-card {
  display: block;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 1rem 1.25rem;
  transition: border-color 0.15s, box-shadow 0.15s;
  color: inherit;
}
.request-card:hover { border-color: #93c5fd; box-shadow: 0 0 0 3px rgba(37,99,235,0.08); text-decoration: none; color: inherit; }
.request-card-top { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.375rem; }
.request-type { font-size: 0.75rem; color: #9ca3af; text-transform: capitalize; }
.request-card-title { font-size: 0.9375rem; font-weight: 600; color: #111827; margin-bottom: 0.375rem; }
.request-card-meta { display: flex; align-items: center; gap: 0.625rem; }
.meta-item { display: flex; align-items: center; gap: 0.25rem; font-size: 0.8125rem; color: #6b7280; }
.meta-item--urgent { color: #dc2626; }
.meta-sep { color: #d1d5db; }

/* === Empty State === */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: #6b7280;
}
.empty-state svg { margin-bottom: 1rem; }
.empty-state p { margin-top: 0.25rem; }

/* === Forms === */
.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: #374151;
  margin-bottom: 0.375rem;
}
.required { color: #ef4444; }
.form-input, .form-textarea, .form-select {
  display: block;
  width: 100%;
  padding: 0.625rem 0.75rem;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.9375rem;
  font-family: inherit;
  color: #111827;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-input:focus, .form-textarea:focus, .form-select:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}
.form-textarea { resize: vertical; }
.form-hint { font-size: 0.8125rem; color: #9ca3af; margin-top: 0.25rem; }
.form-group { margin-bottom: 1.25rem; }
.form-group--half { flex: 1; }
.form-row { display: flex; gap: 1rem; }
.form-actions { display: flex; justify-content: flex-end; gap: 0.75rem; padding-top: 1rem; border-top: 1px solid #e5e7eb; }

/* === Type Grid === */
.type-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
.type-option { cursor: pointer; }
.type-option input { display: none; }
.type-option-inner {
  display: flex;
  flex-direction: column;
  padding: 0.75rem 1rem;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  transition: border-color 0.15s, background 0.15s;
}
.type-option input:checked + .type-option-inner { border-color: #2563eb; background: #eff6ff; }
.type-option-inner:hover { border-color: #93c5fd; }
.type-option-label { font-size: 0.875rem; font-weight: 600; color: #111827; }
.type-option-desc { font-size: 0.75rem; color: #6b7280; }

/* === File Upload === */
.file-upload {
  border: 2px dashed #d1d5db;
  border-radius: 8px;
  padding: 1.5rem;
  text-align: center;
  transition: border-color 0.15s, background 0.15s;
  cursor: pointer;
}
.file-upload.dragover { border-color: #2563eb; background: #eff6ff; }
.file-upload p { font-size: 0.875rem; color: #6b7280; margin-top: 0.5rem; }
.file-upload-link { color: #2563eb; font-weight: 500; cursor: pointer; }
.file-input { display: none; }
.file-list { margin-top: 0.5rem; }
.file-item {
  font-size: 0.8125rem;
  color: #4b5563;
  padding: 0.25rem 0;
}

/* === Detail Page === */
.page-back { margin-bottom: 1rem; }
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.875rem;
  color: #6b7280;
}
.back-link:hover { color: #2563eb; text-decoration: none; }
.detail-header { margin-bottom: 1.5rem; }
.detail-meta { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.5rem; flex-wrap: wrap; }
.detail-section { margin-top: 2rem; }
.detail-body {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 1rem 1.25rem;
  white-space: pre-wrap;
  line-height: 1.7;
}

/* === Attachments === */
.attachment-list { display: flex; flex-direction: column; gap: 0.375rem; }
.attachment-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: #374151;
}

/* === Comments === */
.comment-thread { display: flex; flex-direction: column; gap: 0.75rem; margin-bottom: 1.5rem; }
.comment {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 0.875rem 1rem;
}
.comment--agency { border-left: 3px solid #2563eb; }
.comment--client { border-left: 3px solid #10b981; }
.comment-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.5rem; }
.comment-author { display: flex; align-items: center; gap: 0.375rem; font-size: 0.8125rem; font-weight: 600; color: #374151; }
.comment-time { font-size: 0.75rem; color: #9ca3af; }
.comment-body { font-size: 0.875rem; color: #4b5563; white-space: pre-wrap; line-height: 1.6; }
.comment-form { display: flex; flex-direction: column; gap: 0.5rem; align-items: flex-end; }
.comment-form .form-textarea { width: 100%; }

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
  text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn--primary { background: #2563eb; color: #fff; border-color: #2563eb; }
.btn--primary:hover { background: #1d4ed8; color: #fff; }
.btn--ghost { background: transparent; color: #6b7280; border-color: #d1d5db; }
.btn--ghost:hover { background: #f3f4f6; color: #374151; }
.btn--sm { padding: 0.375rem 0.75rem; font-size: 0.8125rem; }
.btn--full { width: 100%; }
.btn--google {
  background: #fff;
  color: #3c4043;
  border: 1px solid #dadce0;
  font-weight: 500;
  gap: 0.625rem;
  padding: 0.625rem 1rem;
}
.btn--google:hover { background: #f8f9fa; box-shadow: 0 1px 3px rgba(0,0,0,0.08); color: #3c4043; }

/* === Login Divider === */
.login-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1.25rem 0;
  color: #9ca3af;
  font-size: 0.8125rem;
}
.login-divider::before, .login-divider::after {
  content: '';
  flex: 1;
  border-top: 1px solid #e5e7eb;
}

/* === Project Select === */
.project-select-btn {
  display: flex;
  flex-direction: column;
  width: 100%;
  padding: 1rem 1.25rem;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.project-select-btn:hover { border-color: #93c5fd; box-shadow: 0 0 0 3px rgba(37,99,235,0.08); }
.project-select-name { font-size: 0.9375rem; font-weight: 600; color: #111827; }
.project-select-url { font-size: 0.8125rem; color: #6b7280; margin-top: 0.125rem; }

/* === Alerts === */
.alert {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.875rem;
  margin-bottom: 1rem;
}
.alert--error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

/* === Language Toggle === */
.nav-link--lang {
  font-size: 0.8rem;
  padding: 0.2rem 0.5rem;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
  color: #6b7280 !important;
}
.nav-link--lang:hover { background: #f3f4f6; text-decoration: none !important; }

.login-header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.5rem;
}
.lang-toggle {
  font-size: 0.8rem;
  padding: 0.2rem 0.5rem;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
  color: #6b7280 !important;
}
.lang-toggle:hover { background: #f3f4f6; text-decoration: none !important; }

/* === Project Grid (multi-project hub) === */
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}
.project-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.project-card--active { border-color: #2563eb; box-shadow: 0 0 0 1px #2563eb; }
.project-card-name { font-size: 1.1rem; font-weight: 600; }
.project-card-url { font-size: 0.85rem; color: #6b7280; }
.project-card-stats { display: flex; gap: 0.75rem; }
.project-stat { font-size: 0.85rem; color: #6b7280; }
.project-stat--open { color: #d97706; font-weight: 500; }
.btn--sm { font-size: 0.85rem; padding: 0.4rem 0.75rem; }
.btn--full { width: 100%; justify-content: center; }

/* === Responsive === */
@media (max-width: 640px) {
  .header-inner { padding: 0 1rem; }
  .container { padding: 1.25rem 1rem; }
  .dashboard-header { flex-direction: column; gap: 1rem; }
  .form-row { flex-direction: column; gap: 0; }
  .type-grid { grid-template-columns: 1fr; }
  .form-actions { flex-direction: column-reverse; }
  .form-actions .btn { width: 100%; }
  .detail-meta { flex-direction: column; align-items: flex-start; gap: 0.25rem; }
  .meta-sep { display: none; }
  .project-grid { grid-template-columns: 1fr; }
}

/* === Onboarding chat === */
.onboarding-container { max-width: 760px; }
.chat-status { padding: 0.75rem 1rem; border-radius: 6px; margin: 1rem 0; font-size: 0.9rem; }
.chat-status[hidden] { display: none; }
.chat-status--submitted, .chat-status--delivered, .chat-status--approved { background: #e0f2fe; color: #075985; border: 1px solid #bae6fd; }
.chat-status--building { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.chat-status--deployed { background: #dcfce7; color: #14532d; border: 1px solid #86efac; font-weight: 500; }
.chat-status--rejected, .chat-status--failed { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.chat-status-link { color: inherit; text-decoration: underline; margin-left: 0.25rem; }

.chat-transcript {
  background: #fff; border: 1px solid #e5e7eb; border-radius: 8px;
  padding: 1rem; min-height: 260px; max-height: 520px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 0.75rem;
}

/* Drag-and-drop file upload highlight */
#chatApp { position: relative; }
#chatApp.is-dragover .chat-transcript {
  border-color: #2563eb;
  border-style: dashed;
  background: #eff6ff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
#chatApp.is-dragover::after {
  content: "Drop files to upload";
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; color: #1d4ed8;
  background: rgba(239, 246, 255, 0.55);
  border-radius: 8px;
  pointer-events: none;
  z-index: 5;
}
.chat-msg { display: flex; flex-direction: column; gap: 0.25rem; max-width: 90%; }
.chat-msg--user { align-self: flex-end; align-items: flex-end; }
.chat-msg--assistant { align-self: flex-start; align-items: flex-start; }
.chat-msg-role { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; color: #6b7280; }
.chat-msg-content {
  padding: 0.6rem 0.9rem; border-radius: 10px; white-space: pre-wrap;
  font-size: 0.92rem; line-height: 1.45;
}
.chat-msg--user .chat-msg-content { background: #2563eb; color: #fff; }
.chat-msg--assistant .chat-msg-content { background: #f3f4f6; color: #111827; border: 1px solid #e5e7eb; }
.chat-msg--transient .chat-msg-content { opacity: 0.6; font-style: italic; }

.chat-attachments { margin-top: 1rem; font-size: 0.85rem; color: #4b5563; }
.chat-attachments-title { font-weight: 600; color: #111827; margin-bottom: 0.35rem; }
.chat-attachments ul { list-style: none; padding: 0; margin: 0; }
.chat-attachments li { padding: 0.25rem 0; }
.chat-attachment-size { color: #9ca3af; }

.chat-composer { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 1rem; }
.chat-input { width: 100%; resize: vertical; }
.chat-composer-actions { display: flex; gap: 0.5rem; justify-content: flex-end; flex-wrap: wrap; }
.chat-attach-btn { cursor: pointer; display: inline-flex; gap: 0.35rem; align-items: center; }
.chat-composer .file-input { display: none; }

/* ==========================================================================
   Onboarding Chat v2 — history sidebar, composer, chips, mic, drop zone
   ========================================================================== */

.chat-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 0;
  max-width: 1200px;
  margin: 1rem auto;
  padding: 0 1rem;
  min-height: calc(100vh - 220px);
}
@media (max-width: 760px) {
  .chat-shell { grid-template-columns: 1fr; }
}

.chat-sidebar {
  border-right: 1px solid #e5e7eb;
  padding-right: 1rem;
  display: flex; flex-direction: column;
  gap: 0.75rem;
}
@media (max-width: 760px) {
  .chat-sidebar { border-right: 0; padding-right: 0; border-bottom: 1px solid #e5e7eb; padding-bottom: 1rem; }
}
.chat-sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.5rem;
  padding: 0.25rem 0.25rem 0.5rem;
  border-bottom: 1px solid #f1f5f9;
}
.chat-sidebar-title {
  font-size: 0.75rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: #6b7280;
}
.chat-new-btn {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.35rem 0.6rem;
  background: #2563eb; color: #fff;
  border-radius: 6px; font-size: 0.8rem; font-weight: 500;
  text-decoration: none;
}
.chat-new-btn:hover { background: #1d4ed8; }
.chat-history-list {
  display: flex; flex-direction: column; gap: 0.25rem;
  overflow-y: auto; padding-right: 0.25rem;
  max-height: 540px;
}
.chat-history-empty { font-size: 0.8rem; color: #9ca3af; padding: 0.5rem 0.25rem; }
.chat-history-item {
  display: block;
  padding: 0.5rem 0.6rem;
  border-radius: 6px;
  color: #374151;
  text-decoration: none;
  border: 1px solid transparent;
}
.chat-history-item:hover { background: #f3f4f6; }
.chat-history-item--active { background: #eff6ff; border-color: #bfdbfe; color: #1d4ed8; }
.chat-history-item-title { font-size: 0.85rem; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-history-item-meta { font-size: 0.7rem; color: #6b7280; margin-top: 0.15rem; display: flex; gap: 0.5rem; }
.chat-history-item-status {
  display: inline-block;
  padding: 0.05rem 0.4rem;
  border-radius: 10px;
  font-size: 0.65rem;
  text-transform: uppercase; letter-spacing: 0.04em;
  background: #f3f4f6; color: #4b5563;
}
.chat-history-item-status--collecting { background: #fef3c7; color: #92400e; }
.chat-history-item-status--submitted { background: #dbeafe; color: #1e40af; }
.chat-history-item-status--building { background: #fef3c7; color: #92400e; }
.chat-history-item-status--deployed { background: #dcfce7; color: #14532d; }
.chat-history-item-status--rejected,
.chat-history-item-status--failed { background: #fee2e2; color: #991b1b; }

.chat-main {
  display: flex; flex-direction: column;
  min-width: 0;
  padding: 0 0 0 1rem;
}
@media (max-width: 760px) {
  .chat-main { padding: 0; }
}
.chat-header-bar { margin-bottom: 0.75rem; }
.chat-title { font-size: 1.3rem; font-weight: 700; color: #111827; margin: 0; }
.chat-subtitle { font-size: 0.85rem; color: #6b7280; margin: 0.25rem 0 0; }

.chat-transcript {
  background: #fff; border: 1px solid #e5e7eb; border-radius: 8px;
  padding: 1rem;
  flex: 1;
  min-height: 320px;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 0.75rem;
}

.chat-readonly-banner {
  margin-top: 0.75rem;
  padding: 0.75rem 1rem;
  background: #f3f4f6;
  border-left: 3px solid #6b7280;
  color: #4b5563;
  border-radius: 4px;
  font-size: 0.85rem;
}

/* --- composer v2 --- */
.chat-composer {
  margin-top: 0.75rem;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 0.6rem 0.75rem;
  display: flex; flex-direction: column; gap: 0.5rem;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}
.chat-composer:focus-within {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}
.chat-composer-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.chat-chip {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.2rem 0.5rem;
  background: #eef2ff; color: #3730a3;
  border-radius: 999px;
  font-size: 0.75rem;
  transition: opacity 0.5s;
  border: 1px solid #e0e7ff;
}
.chat-chip--upload-ok { background: #dcfce7; color: #14532d; border-color: #bbf7d0; }
.chat-chip--upload-err,
.chat-chip--voice-err { background: #fee2e2; color: #991b1b; border-color: #fecaca; }
.chat-chip--voice { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.chat-chip--voice-ok { background: #dbeafe; color: #1e40af; border-color: #bfdbfe; }
.chat-chip--fade { opacity: 0; }

.chat-composer-row { display: flex; }
.chat-composer .chat-input {
  width: 100%;
  border: none; outline: none;
  resize: none;
  padding: 0.35rem 0.25rem;
  font: inherit;
  background: transparent;
  max-height: 240px;
  min-height: 1.5em;
}

.chat-composer-actions {
  display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
}
.chat-composer-left, .chat-composer-right { display: flex; align-items: center; gap: 0.4rem; }
.chat-send-hint { font-size: 0.7rem; color: #9ca3af; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  color: #4b5563;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.icon-btn:hover { background: #f3f4f6; color: #111827; }
.icon-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.icon-btn--ghost { background: transparent; }
.icon-btn--recording {
  background: #fee2e2; color: #b91c1c; border-color: #fca5a5;
  animation: micPulse 1.2s infinite;
}
.icon-btn--busy { opacity: 0.6; pointer-events: none; }
@keyframes micPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(185, 28, 28, 0.5); }
  50% { box-shadow: 0 0 0 6px rgba(185, 28, 28, 0); }
}

.chat-send-btn { padding: 0.45rem 0.9rem; }
.chat-send-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* --- dragover highlight v2 (overrides earlier rule) --- */
#chatApp.chat-shell { position: relative; }
#chatApp.chat-shell.is-dragover .chat-transcript {
  border-color: #2563eb;
  border-style: dashed;
  background: #eff6ff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
#chatApp.chat-shell.is-dragover::after {
  content: attr(data-t-drop-here);
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; color: #1d4ed8;
  background: rgba(239, 246, 255, 0.55);
  border-radius: 8px;
  pointer-events: none;
  z-index: 5;
}


/* Pending requests banner in onboarding chat */
.chat-pending-banner {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-left: 4px solid #2563eb;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-bottom: 0.75rem;
  color: #1e3a8a;
}
.chat-pending-title {
  display: flex; align-items: center; gap: 0.5rem;
  font-weight: 600; font-size: 0.9rem;
  color: #1d4ed8;
  margin-bottom: 0.5rem;
}
.chat-pending-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.35rem; }
.chat-pending-item {
  display: flex; align-items: center; gap: 0.6rem;
  font-size: 0.85rem;
  flex-wrap: wrap;
}
.chat-pending-item-title { font-weight: 500; color: #1e3a8a; }
.chat-pending-link {
  margin-left: auto;
  color: #2563eb; text-decoration: none; font-weight: 500;
}
.chat-pending-link:hover { text-decoration: underline; }

/* ==========================================================================
   Request Detail Page + Timeline
   ========================================================================== */
.request-detail { max-width: 820px; margin: 1.5rem auto; padding: 0 1rem; }
.request-detail-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap;
}
.request-detail-title { font-size: 1.6rem; font-weight: 700; color: #111827; margin: 0; }
.request-detail-status {
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  font-size: 0.75rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.04em;
  background: #f3f4f6; color: #4b5563;
}
.request-detail-status--collecting { background: #fef3c7; color: #92400e; }
.request-detail-status--submitted,
.request-detail-status--delivered { background: #dbeafe; color: #1e40af; }
.request-detail-status--approved { background: #e0e7ff; color: #3730a3; }
.request-detail-status--building { background: #fef3c7; color: #92400e; }
.request-detail-status--deployed { background: #dcfce7; color: #14532d; }
.request-detail-status--rejected,
.request-detail-status--failed { background: #fee2e2; color: #991b1b; }

.request-detail-sub { color: #6b7280; font-size: 0.85rem; margin: 0.5rem 0 1rem; }
.request-detail-sub .sep { margin: 0 0.4rem; }
.request-detail-sub code {
  background: #f3f4f6; padding: 0.1rem 0.4rem; border-radius: 4px;
  font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 0.8rem;
}

.request-detail-hero {
  display: flex; align-items: flex-start; gap: 0.75rem;
  padding: 1rem 1.2rem;
  border-radius: 10px;
  margin-bottom: 1rem;
}
.request-detail-hero--success { background: #dcfce7; color: #14532d; border: 1px solid #86efac; }
.request-detail-hero--error { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.request-detail-hero-title { font-weight: 600; font-size: 1rem; margin-bottom: 0.2rem; }
.request-detail-hero-link { color: inherit; text-decoration: underline; font-weight: 500; word-break: break-all; }
.request-detail-hero-reason { font-size: 0.9rem; }

.request-detail-section {
  background: #fff; border: 1px solid #e5e7eb; border-radius: 10px;
  padding: 1rem 1.2rem; margin-bottom: 1rem;
}
.request-detail-section-title { font-size: 1rem; font-weight: 600; color: #111827; margin: 0 0 0.75rem; }
.request-detail-brief {
  white-space: pre-wrap; word-wrap: break-word;
  background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 6px;
  padding: 0.75rem; font-size: 0.85rem; line-height: 1.5; color: #374151;
  max-height: 360px; overflow-y: auto;
}
.request-detail-attachments { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.35rem; }
.request-detail-attachments .muted { color: #9ca3af; font-size: 0.8rem; }

/* Timeline */
.timeline { list-style: none; padding: 0; margin: 0; position: relative; }
.timeline::before {
  content: ''; position: absolute;
  left: 11px; top: 4px; bottom: 4px;
  width: 2px; background: #e5e7eb;
}
.timeline-step {
  position: relative;
  padding: 0 0 1.25rem 2.25rem;
}
.timeline-step:last-child { padding-bottom: 0; }
.timeline-dot {
  position: absolute; left: 0; top: 2px;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: #f3f4f6;
  border: 2px solid #e5e7eb;
  display: inline-flex; align-items: center; justify-content: center;
  color: #9ca3af;
  z-index: 1;
}
.timeline-step--done .timeline-dot { background: #22c55e; border-color: #22c55e; color: #fff; }
.timeline-step--current .timeline-dot { background: #2563eb; border-color: #bfdbfe; }
.timeline-pulse {
  width: 10px; height: 10px; border-radius: 50%;
  background: #fff;
  animation: tlPulse 1.5s infinite;
}
@keyframes tlPulse {
  0%, 100% { transform: scale(0.8); opacity: 0.8; }
  50% { transform: scale(1.2); opacity: 1; }
}
.timeline-label { font-weight: 600; color: #111827; font-size: 0.95rem; }
.timeline-step--pending .timeline-label { color: #9ca3af; font-weight: 500; }
.timeline-at { font-size: 0.75rem; color: #6b7280; margin-top: 0.15rem; }
.timeline-note { font-size: 0.85rem; color: #4b5563; margin-top: 0.25rem; word-break: break-word; }
.timeline-step--pending .timeline-note { color: #9ca3af; }


/* ==========================================================================
   Ready-for-review CTA card (inline in chat transcript)
   ========================================================================== */
.chat-review-cta {
  margin-top: 0.5rem;
  padding: 1rem 1.2rem;
  background: linear-gradient(135deg, #eff6ff, #e0e7ff);
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  display: flex; flex-direction: column; gap: 0.6rem;
  box-shadow: 0 1px 3px rgba(30, 64, 175, 0.08);
}
.chat-review-cta-title { font-weight: 600; color: #1e3a8a; font-size: 0.95rem; }
.chat-review-cta-btn {
  align-self: flex-start;
  padding: 0.5rem 1rem;
  background: #2563eb;
  color: #fff;
  text-decoration: none;
  border-radius: 6px;
  font-weight: 500;
  font-size: 0.9rem;
}
.chat-review-cta-btn:hover { background: #1d4ed8; }

/* Request detail status chip — add ready_for_review variant */
.request-detail-status--ready_for_review,
.chat-history-item-status--ready_for_review {
  background: #e0e7ff; color: #3730a3;
}

/* ==========================================================================
   Review page layout
   ========================================================================== */
.review-page { max-width: 780px; margin: 1.5rem auto; padding: 0 1rem; }
.review-header { margin-bottom: 1.5rem; }
.review-title { font-size: 1.6rem; font-weight: 700; color: #111827; margin: 0 0 0.4rem; }
.review-subtitle { color: #6b7280; font-size: 0.95rem; margin: 0; line-height: 1.5; }
.review-form {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 1.5rem;
}
.review-form .form-row {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1rem;
}
@media (max-width: 640px) { .review-form .form-row { grid-template-columns: 1fr; } }
.review-form .form-input { width: 100%; }
.review-form .required { color: #dc2626; font-weight: 700; }
.review-brief { width: 100%; font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 0.88rem; line-height: 1.55; min-height: 260px; }
.form-hint { font-size: 0.78rem; color: #6b7280; margin: 0.4rem 0 0; }
.review-attachments { list-style: none; padding: 0; margin: 0.25rem 0 0; display: flex; flex-direction: column; gap: 0.4rem; }
.review-attachments li { display: flex; align-items: center; gap: 0.4rem; font-size: 0.9rem; }
.review-attachments .muted { color: #9ca3af; font-size: 0.8rem; }
.review-actions {
  display: flex; justify-content: space-between; align-items: center; gap: 0.75rem;
  margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid #f3f4f6;
  flex-wrap: wrap;
}
.review-actions .btn { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.55rem 1rem; }
