/* ============================================================
   Hi Twin – Main Stylesheet
   ============================================================ */

/* ── Design tokens ── */
:root {
  --primary:       #5B47E0;
  --primary-dark:  #4338CA;
  --primary-light: #EEF2FF;
  --primary-rgb:   91, 71, 224;

  --success: #10B981;
  --warning: #F59E0B;
  --danger:  #EF4444;

  --bg:           #F1F5F9;
  --card:         #FFFFFF;
  --border:       #E2E8F0;
  --border-focus: #A5B4FC;

  --text:       #1E293B;
  --text-muted: #64748B;
  --text-light: #94A3B8;

  --nav-h:    60px;
  --r-sm:     6px;
  --r:        12px;
  --r-lg:     16px;

  --shadow-sm: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow:    0 4px 12px rgba(0,0,0,.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,.10);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding-top: var(--nav-h);
  line-height: 1.55;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: inherit; }
button { cursor: pointer; border: none; background: none; font-family: inherit; font-size: inherit; }
input, textarea, select { font-family: inherit; font-size: inherit; }

/* ── Navbar ── */
.navbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: #fff;
  border-bottom: 1px solid var(--border);
  z-index: 200;
  box-shadow: var(--shadow-sm);
}
.navbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand {
  display: flex;
  align-items: center;
}
.brand-logo {
  height: 36px;
  width: auto;
  display: block;
}
.nav-logs-link {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  border-radius: 8px;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}
.nav-logs-link:hover {
  background: var(--bg-card);
  color: var(--text);
}
.navbar-right { display: flex; align-items: center; gap: 8px; }
.user-menu    { position: relative; }
.user-badge {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 14px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  border: none;
  cursor: pointer;
}
.user-badge:hover { filter: brightness(.95); }
.user-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0,0,0,.1);
  min-width: 180px;
  z-index: 200;
  overflow: hidden;
}
.user-dropdown.open { display: block; }
.user-dropdown-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 11px 16px;
  font-size: 13px;
  color: var(--text);
  background: none;
  border: none;
  cursor: pointer;
  text-decoration: none;
  box-sizing: border-box;
}
.user-dropdown-item:hover { background: var(--bg); }
.user-dropdown-item--danger { color: #dc2626; }

/* ── Layout ── */
.main-content { min-height: calc(100vh - var(--nav-h)); }
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px;
}
.container-narrow { max-width: 720px; }

/* ── Hero ── */
.hero {
  background: linear-gradient(135deg, #5B47E0 0%, #7C3AED 100%);
  color: #fff;
  padding: 44px 0;
}
.hero-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}
.hero-title {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 6px;
  letter-spacing: -0.5px;
}
.hero-title .accent { opacity: .85; }
.hero-subtitle { font-size: 15px; opacity: .8; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s ease;
  border: 1.5px solid transparent;
  white-space: nowrap;
  line-height: 1;
}
.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.btn-primary:hover:not(:disabled) {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(var(--primary-rgb),.35);
}
.btn-primary:disabled {
  background: #94A3B8;
  border-color: #94A3B8;
  cursor: not-allowed;
}
.btn-white {
  background: #fff;
  color: var(--primary);
  border-color: #fff;
}
.btn-white:hover {
  background: #f0f0f0;
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(0,0,0,.15);
}
.btn-outline {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
.btn-outline:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: transparent;
}
.btn-ghost:hover { color: var(--primary); background: var(--primary-light); }
.btn-danger-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: transparent;
}
.btn-danger-ghost:hover { color: var(--danger); background: #FEF2F2; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-sm { padding: 6px 12px; font-size: 12px; }

/* ── Section header ── */
.section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 32px 0 18px;
}
.section-title { font-size: 18px; font-weight: 600; }
.count-badge {
  background: var(--primary-light);
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 12px;
}

/* ── Project cards ── */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}
.project-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 20px;
  cursor: pointer;
  transition: all .2s ease;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.project-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}
.card-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}
.card-title { font-size: 16px; font-weight: 600; line-height: 1.3; }
.card-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-files { display: flex; gap: 6px; flex-wrap: wrap; }
.file-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
}
.chip-ok      { background: #D1FAE5; color: #065F46; }
.chip-missing { background: #FEE2E2; color: #991B1B; }
.chip-neutral { background: #F1F5F9; color: var(--text-muted); }
.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.card-date {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text-muted);
}

/* ── Status badges ── */
.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .4px;
  white-space: nowrap;
}
.status-badge.status-lg { font-size: 13px; padding: 5px 14px; }
.status-draft     { background: #FEF3C7; color: #92400E; }
.status-running   { background: #DBEAFE; color: #1E40AF; }
.status-done,
.status-completed { background: #D1FAE5; color: #065F46; }

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 80px 24px;
}
.empty-icon  { font-size: 64px; margin-bottom: 16px; }
.empty-title { font-size: 20px; font-weight: 600; margin-bottom: 8px; }
.empty-desc  { color: var(--text-muted); margin-bottom: 24px; font-size: 15px; }

/* ── Page header ── */
.page-header {
  margin-bottom: 28px;
}
.page-header-slim { margin-bottom: 16px; }
.uploading-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1d4ed8;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 16px;
}
.uploading-banner span:nth-child(2) { flex: 1; }
.uploading-banner-close {
  background: none;
  border: none;
  cursor: pointer;
  color: #93c5fd;
  font-size: 14px;
  padding: 2px 4px;
  line-height: 1;
}
.uploading-banner-close:hover { color: #1d4ed8; }
.breadcrumb {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 12px;
  transition: color .15s;
}
.breadcrumb:hover { color: var(--primary); }
.page-title {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -.5px;
  margin-bottom: 6px;
}
.page-subtitle { color: var(--text-muted); font-size: 15px; }

/* ── Form cards ── */
.form-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  margin-bottom: 16px;
  overflow: hidden;
}
.form-card-header {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.step-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 2px;
}
.step-optional { background: #94A3B8; }
.form-section-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 3px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.form-section-desc { font-size: 13px; color: var(--text-muted); }
.form-body { padding: 24px; }
.form-group { margin-bottom: 20px; }
.form-group:last-child { margin-bottom: 0; }
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 7px;
}
.required   { color: var(--danger); }
.optional-tag {
  font-size: 11px;
  font-weight: 500;
  padding: 2px 7px;
  background: #F1F5F9;
  color: var(--text-muted);
  border-radius: 10px;
  vertical-align: middle;
}
.form-input,
.form-textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text);
  background: var(--card);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
  resize: vertical;
}
.form-input:focus,
.form-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb),.12);
}
.form-input::placeholder,
.form-textarea::placeholder { color: var(--text-light); }
.form-input.error { border-color: var(--danger); }
.field-error {
  margin-top: 5px;
  font-size: 12px;
  color: var(--danger);
}

/* ── Dropzone ── */
.dropzone {
  position: relative;
  border: 2px dashed var(--border);
  border-radius: var(--r);
  padding: 36px 24px;
  text-align: center;
  cursor: pointer;
  transition: all .2s ease;
  background: #FAFBFD;
}
.dropzone:hover,
.dropzone.drag-over {
  border-color: var(--primary);
  background: var(--primary-light);
}
.dropzone.has-file {
  border-style: solid;
  border-color: var(--success);
  background: #F0FDF4;
  cursor: default;
  padding: 20px 24px;
}
.file-input {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  opacity: 0;
  cursor: pointer;
  z-index: 1;
}
.dropzone.has-file .file-input { display: none; }
.dropzone-idle { pointer-events: none; }
.dropzone-icon { font-size: 38px; margin-bottom: 12px; }
.dz-primary  { font-size: 15px; font-weight: 500; color: var(--text); margin-bottom: 4px; }
.dz-secondary{ font-size: 13px; color: var(--text-muted); margin-bottom: 8px; }
.dz-link     { color: var(--primary); font-weight: 500; }
.dz-hint     { font-size: 12px; color: var(--text-light); }
.dropzone-selected {
  display: flex;
  align-items: center;
  gap: 14px;
  text-align: left;
}
.file-info { flex: 1; overflow: hidden; }
.file-name {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-size {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 3px;
}
.btn-remove {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--danger);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  flex-shrink: 0;
  transition: background .15s;
  z-index: 2;
  position: relative;
}
.btn-remove:hover { background: #DC2626; }
.stimulus-preview {
  width: 56px; height: 56px;
  border-radius: var(--r-sm);
  overflow: hidden;
  background: var(--bg);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}
.stimulus-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ── Form actions ── */
.form-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  padding: 24px 0 8px;
}

/* ── Upload overlay ── */
.upload-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.55);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
}
.upload-dialog {
  background: var(--card);
  border-radius: var(--r-lg);
  padding: 44px 48px;
  text-align: center;
  min-width: 280px;
  box-shadow: var(--shadow-lg);
}
.upload-spinner {
  width: 48px; height: 48px;
  border: 4px solid var(--primary-light);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .75s linear infinite;
  margin: 0 auto 18px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.upload-title   { font-size: 16px; font-weight: 600; margin-bottom: 5px; }
.upload-subtitle{ font-size: 13px; color: var(--text-muted); }

/* ── Project detail ── */
.project-header-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 28px;
  margin-bottom: 20px;
}
.project-header-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.project-title-block { flex: 1; min-width: 0; }
.project-title {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -.4px;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.btn-edit-meta {
  width: 26px; height: 26px;
  border-radius: 6px;
  background: var(--primary-light);
  color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity .15s, background .15s;
}
.project-title:hover .btn-edit-meta,
.project-title-block:hover .btn-edit-meta { opacity: 1; }
.btn-edit-meta:hover { background: var(--primary); color: #fff; }
.text-muted-italic { color: var(--text-light); font-style: italic; font-weight: 400; font-size: 13px; }
.meta-name-inp { font-size: 18px; font-weight: 600; margin-bottom: 8px; }
.meta-desc-ta  { resize: vertical; min-height: 58px; margin-bottom: 8px; }
.meta-edit-actions { display: flex; gap: 8px; }
.project-desc {
  color: var(--text-muted);
  font-size: 15px;
  max-width: 600px;
  line-height: 1.6;
}
.project-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.project-meta {
  display: flex;
  gap: 20px;
  font-size: 13px;
  color: var(--text-muted);
  flex-wrap: wrap;
}
.project-meta span {
  display: flex;
  align-items: center;
  gap: 5px;
}

/* ── Two-col grid ── */
.two-col-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
@media (max-width: 768px) {
  .two-col-grid { grid-template-columns: 1fr; }
}

/* ── Info cards ── */
.info-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 24px;
}
.info-card-full { margin-top: 0; }
.info-card-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.info-card-title i { color: var(--primary); }

/* ── File list ── */
.file-list { display: flex; flex-direction: column; gap: 10px; }
.file-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--bg);
}
.file-ok       { background: #F0FDF4; border-color: #BBF7D0; }
.file-missing  { background: #FFF5F5; border-color: #FED7D7; }
.file-optional { background: var(--bg); }
.file-row-icon {
  width: 34px; height: 34px;
  border-radius: var(--r-sm);
  background: #fff;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  color: var(--primary);
  flex-shrink: 0;
}
.file-row-info { flex: 1; overflow: hidden; }
.file-row-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 2px;
}
.file-row-name {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-row-missing {
  display: block;
  font-size: 13px;
  color: var(--text-light);
  font-style: italic;
}
.file-row-status { font-size: 18px; flex-shrink: 0; }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-muted   { color: var(--text-light); }

/* ── Coming soon panel ── */
.coming-soon-panel {
  text-align: center;
  padding: 16px 0 8px;
}
.sim-state-panel {
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 16px 0 8px;
  gap: 4px;
}
.sim-proc-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 8px;
}
.cs-icon  { font-size: 42px; margin-bottom: 12px; }
.cs-title { font-size: 16px; font-weight: 600; margin-bottom: 8px; }
.cs-desc  {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 20px;
  line-height: 1.65;
}
.coming-soon-tag {
  font-size: 11px;
  background: rgba(255,255,255,.25);
  padding: 2px 8px;
  border-radius: 10px;
  margin-left: 4px;
  vertical-align: middle;
}

/* ── Simulation experiment picker ── */
.sim-choose-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.sim-exp-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.sim-exp-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
}
.sim-exp-card:hover {
  border-color: var(--primary);
  box-shadow: 0 2px 10px rgba(var(--primary-rgb),.1);
}
.sim-exp-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.sim-exp-body {
  flex: 1;
  min-width: 0;
}
.sim-exp-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 2px;
}
.sim-exp-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}
.sim-exp-btn {
  flex-shrink: 0;
}

/* ── Copy Test page ── */
.ct-header {
  display: flex;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 24px;
}
.ct-header-icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: #eef2ff;
  color: #6366f1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
}
.ct-exp-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--primary);
  margin-bottom: 4px;
}
.ct-title {
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}
.ct-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.6;
  max-width: 560px;
}

/* Stimulus selector */
.ct-stim-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ct-stim-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.ct-stim-card:hover {
  border-color: var(--primary);
  box-shadow: 0 2px 10px rgba(var(--primary-rgb),.08);
}
.ct-stim-card.selected {
  border-color: var(--primary);
  background: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb),.10);
}
.ct-stim-thumb {
  width: 56px;
  height: 56px;
  border-radius: 10px;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: var(--text-muted);
  flex-shrink: 0;
  overflow: hidden;
}
.ct-stim-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 10px;
}
.ct-stim-info { flex: 1; min-width: 0; }
.ct-stim-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 3px;
}
.ct-stim-type {
  font-size: 12px;
  color: var(--text-muted);
}
.ct-stim-checkmark {
  font-size: 18px;
  color: var(--border);
  flex-shrink: 0;
  transition: color .15s;
}
.ct-stim-card.selected .ct-stim-checkmark { color: var(--primary); }

/* Empty state */
.ct-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 32px 0;
  gap: 10px;
  color: var(--text-muted);
  font-size: 32px;
}
.ct-empty-state p { font-size: 13px; margin: 0; }

/* RAG toggle */
.toggle-label {
  display: flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  user-select: none;
  flex-shrink: 0;
}
.toggle-label input { display: none; }
.toggle-track {
  width: 34px;
  height: 18px;
  border-radius: 9px;
  background: var(--border);
  position: relative;
  transition: background .2s;
  flex-shrink: 0;
}
.toggle-thumb {
  position: absolute;
  top: 2px; left: 2px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
  transition: transform .2s;
}
.toggle-label input:checked ~ .toggle-track { background: var(--primary); }
.toggle-label input:checked ~ .toggle-track .toggle-thumb { transform: translateX(16px); }
.toggle-text {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}
.toggle-label input:checked ~ .toggle-text { color: var(--primary); }

/* Launch bar */
.ct-launch-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 20px;
  margin-top: 16px;
  margin-bottom: 40px;
  box-shadow: var(--shadow-sm);
}
.ct-launch-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text);
  min-width: 0;
}
.ct-launch-summary strong {
  font-weight: 600;
}

/* How it works card */
.ct-how-card {
  margin-bottom: 20px;
}
.ct-how-header {
  text-align: center;
  margin-bottom: 32px;
}
.ct-how-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  margin-top: 6px;
}
.ct-steps-flow {
  margin-bottom: 8px;
}
.ct-step-arrow {
  flex-shrink: 0;
  font-size: 20px;
  color: var(--primary);
  margin-top: 20px;
  padding: 0 4px;
  align-self: flex-start;
  opacity: .7;
}

/* ── Talk to a Twin ── */
.chat-layout           { display: flex; gap: 16px; align-items: flex-start; }
.chat-sidebar          { width: 280px; flex-shrink: 0; background: var(--card);
                          border: 1px solid var(--border); border-radius: 14px;
                          box-shadow: var(--shadow-sm); overflow: hidden; transition: width .2s; }
.chat-sidebar--collapsed { width: 48px; }
.chat-sidebar-header   { display: flex; align-items: center; justify-content: space-between;
                          padding: 12px 14px; border-bottom: 1px solid var(--border);
                          font-size: 13px; font-weight: 600; color: var(--text); gap: 8px; }
.chat-sidebar--collapsed .chat-sidebar-header { justify-content: center; }
.chat-sidebar--collapsed .chat-sidebar-header span { display: none; }
.chat-sidebar-toggle   { background: none; border: none; cursor: pointer; color: var(--text-muted);
                          font-size: 12px; padding: 2px 4px; transition: color .15s; flex-shrink: 0; }
.chat-sidebar-toggle:hover { color: var(--primary); }
.chat-sidebar-body     { padding: 14px; }
.chat-main             { flex: 1; min-width: 0; }
.chat-filter-row       { margin-bottom: 10px; border-bottom: 1px solid var(--border); }
.chat-filter-row[open] { margin-bottom: 14px; }
.chat-filter-label     { font-size: 12px; color: var(--text); margin: 0 0 7px; line-height: 1.5;
                          cursor: pointer; padding: 5px 0; list-style: none;
                          display: flex; align-items: center; justify-content: space-between; user-select: none; }
.chat-filter-label::-webkit-details-marker { display: none; }
.chat-filter-label::after { content: '\f078'; font-family: 'Font Awesome 6 Free'; font-weight: 900;
                              font-size: 9px; color: var(--text-muted); transition: transform .2s; }
.chat-filter-row[open] > .chat-filter-label::after { transform: rotate(-180deg); }
.chat-filter-opts      { display: flex; flex-wrap: wrap; gap: 6px; }
.chat-filter-opt       { display: inline-flex; align-items: center; gap: 5px; font-size: 12px;
                          background: var(--bg); border: 1px solid var(--border); border-radius: 7px;
                          padding: 4px 8px; cursor: pointer; transition: border-color .15s, background .15s; }
.chat-filter-opt:hover { border-color: var(--primary); background: var(--primary-light); }
.chat-filter-opt input { accent-color: var(--primary); cursor: pointer; }
.chat-filter-range     { display: flex; align-items: center; gap: 6px; margin-top: 4px; }
.chat-range-input      { width: 60px; padding: 4px 6px; text-align: center; font-size: 12px; }
.chat-count-bar        { display:flex; align-items:baseline; gap:8px; background:var(--primary-light);
                          border:1px solid rgba(99,102,241,.2); border-radius:12px;
                          padding:14px 18px; margin-bottom:16px; transition:background .2s,border-color .2s; }
.chat-count-bar--zero  { background:#fee2e2; border-color:#fca5a5; }
.chat-count-num        { font-size:32px; font-weight:800; color:var(--primary); line-height:1; }
.chat-count-bar--zero .chat-count-num { color:#dc2626; }
.chat-count-label      { font-size:14px; color:var(--text-muted); }
.chat-sidebar-collapsed-filters { display:flex; flex-direction:column; align-items:center; gap:6px; padding:8px 0; }
.chat-dot              { display:flex; flex-direction:column; align-items:center; gap:2px;
                          background:var(--primary-light); color:var(--primary);
                          border-radius:6px; padding:4px; width:36px; }
.chat-dot--empty       { background:none; color:var(--text-muted); }
/* ── Chat mode buttons ── */
.chat-mode-btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 20px;
  border-radius: 12px; font-size: 14px; font-weight: 500; cursor: pointer;
  border: 1px solid var(--border); background: var(--card); color: var(--text);
  transition: border-color .15s, background .15s, color .15s;
}
.chat-mode-btn:hover:not(:disabled)      { border-color: var(--primary); color: var(--primary); }
.chat-mode-btn--active                   { background: var(--primary); border-color: var(--primary); color: #fff; }
.chat-mode-btn--active:hover:not(:disabled) { background: var(--primary); }
.chat-mode-btn:disabled                  { opacity: .45; cursor: not-allowed; }

/* ── Ongoing chat tabs ── */
.chat-tab {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: 20px; font-size: 12px;
  background: var(--bg); border: 1px solid var(--border);
  color: var(--text); cursor: pointer; white-space: nowrap;
  transition: border-color .15s, background .15s;
}
.chat-tab:hover      { border-color: var(--primary); background: var(--primary-light); color: var(--primary); }
.chat-tab--active    { background: var(--primary); border-color: var(--primary); color: #fff; }
.chat-tab-count      { background: rgba(0,0,0,.1); border-radius: 10px; padding: 1px 6px; font-size: 11px; }

/* ── Chat window ── */
.chat-window        { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; margin-top: 16px; }
.chat-window-header { display:flex; align-items:center; justify-content:space-between; padding:8px 12px; border-bottom:1px solid var(--border); background:var(--card); }
.chat-messages    { height: 320px; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; background: var(--bg); }
.chat-input-row   { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--border); background: var(--card); }
.chat-input       { flex: 1; }
.chat-bubble      { display: flex; max-width: 80%; }
.chat-bubble--user  { align-self: flex-end; flex-direction: row-reverse; }
.chat-bubble--twin  { align-self: flex-start; }
.chat-bubble-body   { padding: 10px 14px; border-radius: 14px; font-size: 13px; line-height: 1.6; word-break: break-word; }
.chat-bubble--user .chat-bubble-body  { background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.chat-bubble--twin .chat-bubble-body  { background: var(--card); border: 1px solid var(--border); color: var(--text); border-bottom-left-radius: 4px; }
.chat-typing      { display: flex; align-items: center; gap: 4px; padding: 12px 16px; }
.chat-typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--text-muted); animation: chat-bounce .9s infinite; }
.chat-typing span:nth-child(2) { animation-delay: .15s; }
.chat-typing span:nth-child(3) { animation-delay: .30s; }
@keyframes chat-bounce { 0%,80%,100%{transform:translateY(0)} 40%{transform:translateY(-6px)} }
.ctp-id    { font-size: 13px; color: var(--text-muted); margin-bottom: 14px; }
.ctp-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.ctp-table th { text-align: left; padding: 6px 10px; color: var(--text-muted); font-weight: 600;
                border-bottom: 2px solid var(--border); }
.ctp-q     { padding: 7px 10px; font-weight: 600; color: var(--text); border-bottom: 1px solid var(--border);
             width: 25%; white-space: nowrap; }
.ctp-a     { padding: 7px 10px; color: var(--text); border-bottom: 1px solid var(--border); }

/* ── Results placeholder ── */
.results-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 0 8px;
}
.rp-bars {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 72px;
  margin-bottom: 14px;
}
.rp-bar {
  width: 24px;
  background: var(--border);
  border-radius: 4px 4px 0 0;
}
.rp-label { font-size: 13px; color: var(--text-muted); }

/* ── How It Works section ── */
.how-it-works {
  background: #fff;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 64px 0 56px;
}
.hiw-header {
  text-align: center;
  max-width: 640px;
  margin: 0 auto 52px;
}
.hiw-label {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--primary);
  background: var(--primary-light);
  padding: 4px 14px;
  border-radius: 20px;
  margin-bottom: 16px;
}
.hiw-title {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -.5px;
  color: var(--text);
  margin-bottom: 12px;
  line-height: 1.25;
}
.hiw-subtitle {
  font-size: 15px;
  color: var(--text-muted);
  line-height: 1.7;
}

/* Steps flow */
.steps-flow {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 0;
  margin-bottom: 52px;
  flex-wrap: wrap;
}
.step-item {
  position: relative;
  flex: 1;
  min-width: 140px;
  max-width: 190px;
  text-align: center;
  padding: 0 8px;
}
.step-icon-wrap {
  width: 68px;
  height: 68px;
  border-radius: 20px;
  background: var(--sl);
  color: var(--sc);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  margin: 0 auto 10px;
  transition: transform .2s ease, box-shadow .2s ease;
}
.step-item:hover .step-icon-wrap {
  transform: translateY(-4px);
  box-shadow: 0 8px 20px rgba(0,0,0,.10);
}
.step-num-badge {
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(18px);
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
}
.step-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}
.step-desc {
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.55;
}
.step-arrow {
  flex-shrink: 0;
  color: var(--border);
  font-size: 18px;
  margin-top: 24px;
  padding: 0 4px;
  align-self: flex-start;
}

/* Capability cards */
.cap-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}
@media (max-width: 900px) {
  .cap-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 520px) {
  .cap-grid { grid-template-columns: 1fr; }
}
.cap-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 24px 20px;
  transition: box-shadow .2s ease, transform .2s ease;
}
.cap-card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}
.cap-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  margin-bottom: 14px;
}
.cap-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 7px;
}
.cap-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
}

/* Steps responsive */
@media (max-width: 768px) {
  .steps-flow { flex-direction: column; align-items: center; gap: 8px; }
  .step-item  { max-width: 320px; width: 100%; }
  .step-arrow { transform: rotate(90deg); margin: 0; }
  .hiw-title  { font-size: 22px; }
}

/* ── Responsive ── */
@media (max-width: 600px) {
  .container { padding: 20px 16px; }
  .hero-inner { flex-direction: column; align-items: flex-start; }
  .project-header-top { flex-direction: column; }
  .form-actions { flex-direction: column-reverse; }
  .form-actions .btn { width: 100%; justify-content: center; }
}


/* ── File sections (project detail) ── */
.fs-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 0;
}
.fs-icon-wrap {
  width: 36px; height: 36px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
}
.fs-body { flex: 1; overflow: hidden; }
.fs-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .4px;
  margin-bottom: 2px;
}
.fs-name {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.fs-missing {
  display: block;
  font-size: 13px;
  color: var(--text-light);
  font-style: italic;
}
.fs-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.fs-status-icon { font-size: 17px; }
.fs-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 0;
}
.fs-subrow {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0 12px 48px;
  flex-wrap: wrap;
}
.fs-empty {
  font-size: 13px;
  color: var(--text-light);
  font-style: italic;
  padding: 6px 0 8px 48px;
}
.q-count-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--primary-light);
  color: var(--primary);
  font-size: 12px;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: 12px;
}

/* ── Stimuli list ── */
.stimuli-list {
  padding: 4px 0 8px 48px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.stimulus-item {
  display: flex;
  flex-direction: column;
  padding: 10px 12px 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: border-color .2s;
  overflow: hidden;
}
.stimulus-item[data-status="processing"] { border-color: var(--primary-light); }
.stimulus-item[data-status="error"]      { border-color: var(--danger); }

/* Top row: icon + name + status badges */
.stim-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 8px;
}
.stim-icon { font-size: 18px; flex-shrink: 0; }
.stim-name {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Status badges */
.stim-processing-badge, .stim-error-badge { display: none; }
.stimulus-item[data-status="processing"] .stim-processing-badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: .76rem; font-weight: 500; color: var(--primary);
  white-space: nowrap;
}
.stimulus-item[data-status="error"] .stim-error-badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: .76rem; font-weight: 500; color: var(--danger);
}

/* Bottom action bar — horizontal strip */
.stim-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 0 8px;
  border-top: 1px solid var(--border);
  margin-top: 2px;
}
.stimulus-item[data-status="processing"] .stim-actions {
  opacity: .35; pointer-events: none;
}

/* Action buttons in the bottom bar */
.btn-remove-stim {
  height: 26px; padding: 0 10px;
  border-radius: 13px;
  background: #fee2e2;
  color: var(--danger);
  display: flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 600;
  flex-shrink: 0;
  transition: background .15s, color .15s;
}
.btn-remove-stim:hover { background: var(--danger); color: #fff; }
.btn-preview-stim {
  height: 26px; padding: 0 10px;
  border-radius: 13px;
  background: var(--primary-light);
  color: var(--primary);
  display: flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 600;
  flex-shrink: 0;
  transition: background .15s, color .15s;
}
.btn-preview-stim:hover { background: var(--primary); color: #fff; }
.btn-replace-stim {
  height: 26px; padding: 0 10px;
  border-radius: 13px;
  background: #fef3c7;
  color: #b45309;
  display: flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 600;
  flex-shrink: 0;
  transition: background .15s, color .15s;
}
.btn-replace-stim:hover { background: #b45309; color: #fff; }
.btn-artifact-toggle {
  height: 26px; padding: 0 10px;
  border-radius: 13px;
  background: #f0fdf4;
  color: #16a34a;
  font-size: 11px; font-weight: 600;
  display: flex; align-items: center; gap: 4px;
  flex-shrink: 0;
  transition: background .15s, color .15s;
  white-space: nowrap;
}
.btn-artifact-toggle:hover { background: #16a34a; color: #fff; }

/* Hidden data container for artifact values */
.stim-artifact { display: none; }

/* ── Artifact modal ── */
.artifact-modal-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px 22px;
}
.artifact-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 22px 18px;
  border-top: 1px solid var(--border);
}
.artifact-field-label {
  display: block;
  font-size: .7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 5px;
}
.artifact-textarea {
  width: 100%;
  min-height: 90px;
  font-size: .84rem;
  color: var(--text);
  line-height: 1.65;
  resize: vertical;
  padding: 8px 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  background: var(--card);
  font-family: inherit;
  transition: border-color .15s;
  box-sizing: border-box;
}
.artifact-textarea:focus {
  outline: none;
  border-color: var(--primary);
}
.artifact-actions {
  display: flex;
  justify-content: flex-end;
  padding-top: 4px;
}
/* Uploading placeholder (while fetch is in progress) */
.stim-uploading-placeholder {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--primary-light);
  border: 1.5px dashed var(--primary);
  border-radius: 8px;
  font-size: 13px;
  color: var(--primary);
  font-weight: 500;
}

/* ── CSV Preview Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.55);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
}
.modal-box {
  background: var(--card);
  border-radius: var(--r-lg);
  width: 92%;
  max-width: 960px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.modal-header {
  padding: 16px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.modal-title {
  font-size: 15px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}
.modal-title i { color: var(--primary); }
.modal-close {
  width: 30px; height: 30px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  color: var(--text-muted);
  transition: background .15s;
}
.modal-close:hover { background: var(--bg); color: var(--text); }
.modal-body {
  padding: 18px 22px;
  overflow: auto;
  flex: 1;
}
.modal-note {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 12px;
}
.loading-text { color: var(--text-muted); font-size: 13px; }
.error-text   { color: var(--danger);     font-size: 13px; }

/* Preview table */
.preview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.preview-table th {
  background: var(--bg);
  padding: 8px 12px;
  text-align: left;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .3px;
  border: 1px solid var(--border);
  white-space: nowrap;
  position: sticky;
  top: 0;
}
.preview-table td {
  padding: 7px 12px;
  border: 1px solid var(--border);
  color: var(--text);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.preview-table tr:nth-child(even) td { background: #FAFBFC; }
.preview-table tr:hover td { background: var(--primary-light); }

/* ── Questions editor ── */
.qe-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0;
}
.qe-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.qe-item:last-child { border-bottom: none; }
.qe-num {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  font-size: 11px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  margin-top: 9px;
}
.qe-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.qe-row2 {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.qe-type { max-width: 160px; }
.qe-opts { flex: 1; min-width: 180px; }
.btn-remove-q {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px;
  color: var(--text-muted);
  transition: all .15s;
  flex-shrink: 0;
  margin-top: 8px;
}
.btn-remove-q:hover { background: #FEE2E2; color: var(--danger); }

/* ── Toast notifications ── */
.toast {
  position: fixed;
  bottom: 24px; right: 24px;
  padding: 11px 18px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: #fff;
  z-index: 1000;
  transform: translateY(12px);
  opacity: 0;
  transition: all .25s ease;
  box-shadow: 0 4px 14px rgba(0,0,0,.18);
  max-width: 320px;
}
.toast-show  { transform: translateY(0); opacity: 1; }
.toast-success { background: var(--success); }
.toast-error   { background: var(--danger);  }
.toast-info    { background: var(--primary); }


/* ── fs-path hint ── */
.fs-path {
  font-size: 10px;
  font-weight: 400;
  color: var(--text-light);
  font-family: monospace;
  background: var(--bg);
  padding: 1px 5px;
  border-radius: 4px;
}

/* ── Questions modal ── */
.qmodal-overlay {
  position: fixed; inset: 0;
  background: rgba(15,23,42,.6);
  z-index: 600;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(3px);
}
.qmodal-box {
  background: var(--card);
  border-radius: var(--r-lg);
  width: 92%; max-width: 820px;
  max-height: 88vh;
  display: flex; flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
  overflow: hidden;
  resize: both;
  min-width: 340px; min-height: 280px;
}
/* Split (PDF side-panel) mode */
.qmodal-box.qmodal-split {
  width: 92vw; max-width: 1400px;
}
.qmodal-box.qmodal-split .qmodal-body {
  flex-direction: row;
  padding: 0;
  overflow: hidden;
}
/* In non-split mode this wrapper is transparent to layout */
.qmodal-questions-pane {
  display: contents;
}
.qmodal-box.qmodal-split .qmodal-questions-pane {
  display: flex; flex-direction: column;
  flex: 0 0 420px; min-width: 260px;
  overflow-y: auto;
  padding: 20px;
}
.qmodal-split-handle {
  width: 5px; flex-shrink: 0;
  background: var(--border);
  cursor: col-resize;
  transition: background .15s;
}
.qmodal-split-handle:hover,
.qmodal-split-handle.dragging { background: var(--primary); }
.qmodal-pdf-pane {
  flex: 1; min-width: 260px;
  overflow: hidden;
  border-left: 1px solid var(--border);
}
.qmodal-pdf-frame {
  width: 100%; height: 100%; border: none; display: block;
}
.qmodal-header {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
  flex-wrap: wrap;
}
.qmodal-title-row {
  display: flex; align-items: center; gap: 8px; flex: 1; min-width: 140px;
}
.qmodal-title {
  font-size: 15px; font-weight: 600;
  display: flex; align-items: center; gap: 7px;
}
.qmodal-title i { color: var(--primary); }
.qmodal-tabs {
  display: flex; gap: 4px;
}
.qm-tab {
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px; font-weight: 500;
  border: 1.5px solid transparent;
  color: var(--text-muted);
  transition: all .15s;
  display: flex; align-items: center; gap: 6px;
}
.qm-tab:hover { color: var(--primary); background: var(--primary-light); }
.qm-tab-active {
  background: var(--primary); color: #fff;
  border-color: var(--primary);
}
.qm-tab-active:hover { background: var(--primary-dark); }
.qmodal-actions { display: flex; gap: 8px; align-items: center; margin-left: auto; }

/* body panels */
.qmodal-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* question items */
.qm-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.qm-item:last-child { border-bottom: none; }
.qm-num-input {
  width: 60px; flex-shrink: 0;
  font-size: 12px; font-weight: 600; color: var(--primary);
  text-align: center; padding: 5px 6px;
}
.qm-body { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.qm-row2 { display: flex; gap: 8px; flex-wrap: wrap; }
.qm-opts { flex: 1; min-width: 160px; }
.qm-scale-edit { align-items: center; }
.qm-scale-edit .form-input { font-size: 12px; padding: 5px 8px; }

/* add-question form */
.qe-main-row  { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; width: 100%; }
.qe-extra-row {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap; width: 100%;
  padding-top: 8px;
}

/* empty state */
.qmodal-empty {
  text-align: center; padding: 40px 20px;
}
.qmodal-empty-icon { font-size: 48px; margin-bottom: 12px; }
.qmodal-empty p { color: var(--text-muted); font-size: 14px; margin-bottom: 6px; }
.qmodal-empty-sub { font-size: 13px !important; }

/* add row */
.qe-add {
  display: flex; flex-direction: column; gap: 0;
  padding: 14px 0 0;
  border-top: 2px dashed var(--border);
  margin-top: 8px;
  flex-shrink: 0;
}

/* source text tab */
.source-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
  flex-shrink: 0;
}
.source-hint {
  font-size: 13px; color: var(--text-muted);
  display: flex; align-items: center; gap: 6px;
}
.source-lines-wrap {
  flex: 1; overflow-y: auto;
}
.source-line {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 9px 10px;
  border-radius: 6px;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: all .15s;
  margin-bottom: 3px;
}
.source-line:hover {
  background: var(--primary-light);
  border-color: var(--primary);
}
.source-line-added {
  background: #F0FDF4;
  border-color: var(--success) !important;
}
.source-line-num {
  font-size: 11px; font-weight: 600; color: var(--text-light);
  width: 22px; text-align: right; flex-shrink: 0; padding-top: 1px;
}
.source-line-text { flex: 1; font-size: 13px; color: var(--text); line-height: 1.5; }
.source-line-add {
  font-size: 13px; color: var(--text-light); flex-shrink: 0; padding-top: 1px;
  transition: color .15s;
}
.source-line:hover .source-line-add { color: var(--primary); }
.source-line-added .source-line-add { color: var(--success); }
.source-empty {
  text-align: center; padding: 40px 20px; color: var(--text-muted);
}
.source-empty i { font-size: 40px; margin-bottom: 14px; display: block; color: var(--text-light); }


/* ── Survey extraction states ── */
.spinner-sm {
  display: inline-block;
  width: 13px; height: 13px;
  border: 2px solid rgba(var(--primary-rgb), .2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
}
.survey-proc-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--primary);
  background: var(--primary-light);
  padding: 4px 10px;
  border-radius: 12px;
}
.survey-proc-row {
  background: #f5f3ff;
  border-radius: var(--r-sm);
  padding: 10px 14px 10px 48px !important;
}
.survey-proc-msg {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--primary);
  font-size: 13px;
}
.survey-error-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #991B1B;
  background: #FEF2F2;
  border: 1px solid #FCA5A5;
  border-radius: var(--r-sm);
  padding: 8px 12px;
  font-size: 13px;
}
.fs-hint {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-light);
  background: #F1F5F9;
  padding: 1px 6px;
  border-radius: 8px;
  vertical-align: middle;
}
.modal-box-media {
  max-width: 860px;
}
.stim-modal-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 120px;
  padding: 20px 22px;
  background: #0f0f0f;
}
.stim-modal-body img,
.stim-modal-body video {
  max-width: 100%;
  max-height: 70vh;
  border-radius: 6px;
  display: block;
}

/* ── Panel Overview ── */
.panel-ov-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.mapping-panel {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 14px 16px;
  margin-bottom: 20px;
}
.mapping-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}
.mapping-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1;
  min-width: 160px;
}
.mapping-label {
  font-size: .7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  display: flex;
  align-items: center;
  gap: 5px;
}
.charts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}
@media (max-width: 640px) {
  .charts-row { grid-template-columns: 1fr; }
}
.chart-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 16px;
}
.chart-title {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.chart-wrap {
  position: relative;
  height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.chart-no-data {
  text-align: center;
  font-size: 13px;
  color: var(--text-light);
  line-height: 1.6;
  padding: 0 12px;
}
/* ── Panel Summary Stats ── */
.panel-summary-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}
.panel-stat {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1;
  min-width: 140px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 14px 16px;
}
.panel-stat-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  flex-shrink: 0;
}
.panel-stat-value {
  display: block;
  font-size: 24px;
  font-weight: 700;
  line-height: 1.1;
  color: var(--text);
}
.panel-stat-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  margin-top: 3px;
}

/* ── Log viewer ── */
.log-toolbar {
  display: flex; align-items: center; gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.log-title {
  font-size: 17px; font-weight: 600;
  display: flex; align-items: center; gap: 8px;
  flex: 1;
}
.log-title i { color: var(--primary); }
.log-controls {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.log-auto-label {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--text-muted); cursor: pointer;
  user-select: none;
}
.log-meta {
  font-size: 12px; color: var(--text-light);
  margin-bottom: 8px;
}
.log-box {
  background: #0f172a;
  color: #cbd5e1;
  border-radius: var(--r-lg);
  padding: 16px 20px;
  font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: 12.5px;
  line-height: 1.7;
  overflow-x: auto;
  overflow-y: auto;
  max-height: 72vh;
  min-height: 200px;
  white-space: pre;
  tab-size: 4;
}
.log-placeholder { color: #475569; font-style: italic; }
.log-error   { color: #f87171; }
.log-warn    { color: #fbbf24; }
.log-info    { color: #cbd5e1; }
.log-debug   { color: #64748b; }

/* ── Simulation inline card ── */
@keyframes twin-bounce {
  0%, 100% { transform: translateY(0) scale(1); }
  40%       { transform: translateY(-10px) scale(1.15); }
  60%       { transform: translateY(-5px) scale(1.07); }
}
@keyframes sim-slide-in {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes progress-glow {
  0%, 100% { opacity: 1; }
  50%       { opacity: .65; }
}

.sim-inline {
  background: var(--card);
  border: 1px solid var(--primary);
  border-radius: 16px;
  box-shadow: 0 4px 24px rgba(var(--primary-rgb),.10);
  padding: 24px 26px 22px;
  margin-bottom: 40px;
  animation: sim-slide-in .3s ease;
}
.sim-inline-top {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 18px;
}
.sim-twins-row {
  display: flex;
  gap: 5px;
  flex-shrink: 0;
}
.sim-twin {
  font-size: 22px;
  display: inline-block;
  animation: twin-bounce 1.4s ease-in-out infinite;
  line-height: 1;
}
.sim-inline-info {
  flex: 1;
  min-width: 0;
}
.sim-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 2px;
}
.sim-stage {
  font-size: 12px;
  color: var(--text-muted);
  min-height: 18px;
}
.sim-progress-track {
  height: 5px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 16px;
}
.sim-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #818cf8);
  border-radius: 99px;
  width: 4%;
  transition: width 1.6s ease;
  animation: progress-glow 2s ease-in-out infinite;
}
.sim-steps {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sim-step {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
  transition: color .4s;
}
.sim-step-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--border);
  flex-shrink: 0;
  transition: background .4s, transform .3s;
}
.sim-step.active { color: var(--text); }
.sim-step.active .sim-step-dot {
  background: var(--primary);
  transform: scale(1.3);
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb),.18);
}
.sim-step.done .sim-step-dot {
  background: #10b981;
  box-shadow: 0 0 0 3px rgba(16,185,129,.15);
}
.sim-done-icon,
.sim-error-icon {
  font-size: 28px;
  flex-shrink: 0;
  animation: twin-bounce .8s ease-in-out 1;
}

/* ── Past simulations grid ── */
.psim-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
.psim-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.psim-card.psim-done    { border-color: #bbf7d0; background: #f0fdf4; }
.psim-card.psim-running { border-color: #bfdbfe; background: #eff6ff; }
.psim-card.psim-error,
.psim-card.psim-interrupted { border-color: #fecaca; background: #fef2f2; }
.psim-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.psim-badge {
  font-size: 11px;
  font-weight: 600;
  border-radius: 99px;
  padding: 2px 8px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.psim-badge-done        { background: #dcfce7; color: #16a34a; }
.psim-badge-running     { background: #dbeafe; color: #2563eb; }
.psim-badge-error,
.psim-badge-interrupted { background: #fee2e2; color: #dc2626; }
.psim-date {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}
.psim-stim {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 5px;
}
.psim-btn { align-self: flex-start; margin-top: 2px; }

/* ── Simulation detail page badge ── */
.sim-detail-badge {
  font-size: 12px;
  font-weight: 600;
  border-radius: 99px;
  padding: 5px 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  white-space: nowrap;
}
.sim-detail-badge-done        { background: #dcfce7; color: #16a34a; }
.sim-detail-badge-running     { background: #dbeafe; color: #2563eb; }
.sim-detail-badge-error,
.sim-detail-badge-interrupted { background: #fee2e2; color: #dc2626; }


/* ══════════════════════════════════════════════════════════════
   Simulation Results page
   ══════════════════════════════════════════════════════════════ */

/* Results header card */
.res-header-card       { margin-bottom: 20px; }
.res-hdr-top           { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.res-hdr-title         { font-size: 20px; font-weight: 800; color: var(--text); margin: 0; }
.res-hdr-badge         { display: inline-flex; align-items: center; gap: 5px; background: #d1fae5; color: #059669; font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 20px; border: 1px solid #6ee7b7; white-space: nowrap; }
.res-usage-info-btn       { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 50%; border: none; background: none; color: var(--text-muted); font-size: 15px; cursor: pointer; transition: color .15s; padding: 0; }
.res-usage-info-btn:hover { color: var(--primary); }
.res-hdr-desc          { font-size: 13px; color: var(--text-muted); line-height: 1.6; margin: 0 0 14px; }
.res-hdr-notice        { display: flex; align-items: flex-start; gap: 10px; background: #1e3a5f; color: #93c5fd; font-size: 13px; line-height: 1.55; padding: 12px 16px; border-radius: 10px; border: 1px solid #3b82f6; margin-bottom: 18px; }
.res-hdr-notice-icon   { font-size: 16px; flex-shrink: 0; margin-top: 1px; }
.res-hdr-stats         { display: flex; align-items: center; flex-wrap: wrap; gap: 0; }
.res-hdr-stat          { display: flex; flex-direction: column; gap: 3px; padding: 0 20px 0 0; }
.res-hdr-stat:first-child { padding-left: 0; }
.res-hdr-stat-div      { width: 1px; height: 32px; background: var(--border); margin: 0 20px; flex-shrink: 0; }
.res-hdr-stat-label    { font-size: 11px; color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: .04em; }
.res-hdr-stat-val      { font-size: 15px; font-weight: 700; color: var(--text); }
.res-hdr-stat-val--stim { font-size: 13px; font-weight: 600; color: var(--text-muted); display: flex; align-items: center; gap: 5px; }

/* Summary bar */
.res-summary-bar {
  display: flex;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
  flex-wrap: wrap;
  gap: 10px 0;
}
.res-summary-stat {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 16px;
}
.res-summary-divider { width:1px; height:24px; background:var(--border); flex-shrink:0; }
.res-summary-num { font-size:20px; font-weight:800; color:var(--primary); line-height:1; }
.res-summary-label { font-size:12px; color:var(--text-muted); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; max-width:200px; }

/* Demographic tabs */
/* ── Top-level result tabs (Summary / View Results / Download) ── */
.res-top-tabs {
  display: flex; gap: 8px; margin-bottom: 20px; align-items: center;
}
.res-top-tab {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 20px; border-radius: 10px; font-size: 14px; font-weight: 600;
  border: 1px solid var(--border); background: var(--card); color: var(--text-muted);
  cursor: pointer; transition: background .15s, color .15s, border-color .15s;
}
.res-top-tab:hover        { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }
.res-top-tab.active       { background: var(--primary); color: #fff; border-color: var(--primary); }
.res-top-tab--dl          { margin-left: auto; background: var(--bg); }
.res-top-tab--dl:hover    { background: #fee2e2; color: #dc2626; border-color: #dc2626; }

/* Preparing spinner */
/* Inline report content */
.res-report-body { padding: 32px 40px; max-width: 800px; margin: 0 auto; }
.res-report-body h1 { font-size: 22px; font-weight: 800; color: var(--text); margin: 0 0 20px; }
.res-report-body h2 { font-size: 16px; font-weight: 700; color: var(--primary); margin: 28px 0 8px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.res-report-body p  { font-size: 14px; line-height: 1.75; color: var(--text-muted); margin: 0 0 12px; }

/* Preparing spinner */
.res-preparing-spinner {
  width: 48px; height: 48px; border-radius: 50%;
  border: 4px solid var(--border); border-top-color: var(--primary);
  animation: spin .8s linear infinite; margin: 0 auto 20px;
}
@keyframes spin { to { transform: rotate(360deg); } }

[data-theme="dark"] .res-top-tab       { background: #1e293b; border-color: #334155; }
[data-theme="dark"] .res-top-tab--dl   { background: #0f172a; }

.res-demo-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px;
  width: fit-content;
}
.res-demo-tab {
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  border-radius: 7px;
  cursor: pointer;
  transition: background .15s, color .15s;
  display: flex;
  align-items: center;
  gap: 5px;
  user-select: none;
}
.res-demo-tab:hover { background: var(--card); color: var(--text); }
.res-demo-tab.active { background: var(--card); color: var(--primary); font-weight: 600; box-shadow: var(--shadow-sm); }

/* Section cards (container for grouped question types) */
.res-section-card { margin-bottom: 16px; }
.res-section-hdr { display:flex; align-items:center; justify-content:space-between; margin-bottom:14px; flex-wrap:wrap; gap:8px; }
.res-section-title { font-size:13px; font-weight:700; color:var(--text); display:flex; align-items:center; gap:8px; }
.res-section-title i { color:var(--primary); }
.res-lk-global-toggle { display:flex; gap:4px; }

/* Mini question cards (inside section cards) */
.res-q-mini { position: relative; padding:12px; border:1px solid var(--border); border-radius:10px; background:var(--bg); }
.res-q-mini-hdr { display:flex; align-items:flex-start; gap:8px; margin-bottom:10px; }
.res-q-num { font-size:11px; font-weight:700; background:var(--primary-light); color:var(--primary); border-radius:6px; padding:3px 8px; flex-shrink:0; margin-top:1px; }
.res-q-mini-text { flex:1; font-size:12px; font-weight:600; color:var(--text); line-height:1.45; display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; }
.res-q-mini--open { padding:14px; }
.res-q-mini--sep { margin-bottom:14px; padding-bottom:14px; border-bottom:1px solid var(--border); }

/* Likert 3-col grid (inside section card) */
.res-likert-grid { display:grid; grid-template-columns:repeat(3,1fr); gap:10px; }
@media (max-width:900px) { .res-likert-grid { grid-template-columns:1fr 1fr; } }
@media (max-width:640px) { .res-likert-grid { grid-template-columns:1fr; } }

/* Choice/multi grid: 2 cols by default, full-width when solo */
.res-choice-grid { display:grid; grid-template-columns:1fr 1fr; gap:10px; }
.res-choice-grid--solo { grid-template-columns:1fr; }

/* Chart area */
.res-chart-area {
  position: relative;
  cursor: zoom-in;
  min-height: 40px;
}

/* Likert vertical bars */
.res-lk-wrap { display:flex; flex-direction:column; gap:8px; }
.res-lk-cols {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 5px;
}
.res-lk-col { display:flex; flex-direction:column; align-items:center; gap:2px; width:30px; }
.res-lk-cnt { font-size:11px; font-weight:700; color:var(--text); line-height:1; }
.res-lk-track {
  width: 100%;
  display: flex;
  align-items: flex-end;
  border-radius: 5px 5px 0 0;
  overflow: hidden;
  /* height set by JS */
}
.res-lk-fill {
  width: 100%;
  border-radius: 5px 5px 0 0;
  flex-shrink: 0;
  min-height: 0;
  align-self: flex-end;
  transition: height .5s ease;
}
.res-lk-fill-1 { background:#ef4444; }
.res-lk-fill-2 { background:#f97316; }
.res-lk-fill-3 { background:#eab308; }
.res-lk-fill-4 { background:#84cc16; }
.res-lk-fill-5 { background:#22c55e; }
.res-lk-val { font-size:11px; font-weight:600; color:var(--text-muted); line-height:1; }
.res-likert-kpis { display:flex; align-items:center; gap:6px; font-size:12px; color:var(--text); flex-wrap:wrap; }
.res-kpi-sep { color:var(--border); }

/* Grouped mean bars (demographic view for likert) */
.res-group-wrap { display:flex; flex-direction:column; gap:8px; }
.res-group-row { display:flex; align-items:center; gap:10px; }
.res-group-lbl { width:80px; font-size:12px; color:var(--text); flex-shrink:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.res-group-track { flex:1; height:20px; border-radius:5px; overflow:hidden; }
.res-group-fill { height:100%; border-radius:5px; transition:width .5s ease; }
.res-group-val { font-size:12px; min-width:60px; }

/* Vertical bar chart: two-row layout (bars + rotated labels) */
.res-vbar-outer { width:100%; overflow:visible; }
.res-vbar-bars-row { display:flex; align-items:flex-end; gap:6px; }
.res-vbar-bar-col { display:flex; flex-direction:column; align-items:center; gap:2px; flex:1; min-width:36px; }
.res-vbar-cnt { font-size:11px; font-weight:700; color:var(--text); line-height:1; }
.res-vbar-track { width:100%; display:flex; align-items:flex-end; background:var(--border); border-radius:5px 5px 0 0; overflow:hidden; }
.res-vbar-fill { width:100%; border-radius:5px 5px 0 0; align-self:flex-end; flex-shrink:0; transition:height .5s ease; cursor:default; }
.res-vbar-labs-row { display:flex; gap:6px; height:72px; overflow:visible; }
.res-vbar-lab-col { flex:1; min-width:36px; position:relative; overflow:visible; }
.res-vbar-lbl { position:absolute; top:5px; left:50%; white-space:nowrap; font-size:11px; font-weight:500; color:var(--text); transform:rotate(38deg); transform-origin:left top; line-height:1.2; }

/* Grouped vertical charts (demographic view for choice) */
.res-vbar-group-wrap { display:flex; gap:24px; flex-wrap:wrap; }
.res-vbar-group-item { flex:0 0 auto; overflow:visible; }

.res-total-note { font-size:11px; color:var(--text-muted); margin-top:6px; }

/* Likert grouped toggle */
.res-lk-toggle-row { display:flex; gap:4px; margin-bottom:10px; }
.res-lk-toggle-btn { font-size:11px; font-weight:500; padding:3px 10px; border-radius:6px; border:1px solid var(--border); background:none; color:var(--text-muted); cursor:pointer; }
.res-lk-toggle-btn.active { background:var(--primary-light); color:var(--primary); border-color:var(--primary); font-weight:600; }
.res-lk-toggle-btn:hover:not(.active) { background:var(--bg); }

/* Likert grouped count layout (mini charts per group) */
.res-group-count-wrap { display:flex; gap:16px; flex-wrap:wrap; }
.res-group-count-item { flex:0 0 auto; }
.res-group-count-title { font-size:11px; font-weight:600; margin-bottom:5px; }

/* Open question layout */
.res-chart-area--noclick { cursor:default; }
.res-open-row { display:flex; gap:16px; align-items:flex-start; }
.res-open-samples-panel { flex:0 0 calc(50% - 8px); max-width:calc(50% - 8px); }
.res-open-samples-hdr { font-size:11px; font-weight:700; text-transform:uppercase; letter-spacing:.05em; color:var(--text-muted); margin-bottom:8px; display:flex; align-items:center; gap:6px; }
.res-sample-quote { font-size:12px; color:var(--text); line-height:1.55; border-left:3px solid var(--primary); padding:5px 10px; margin:0 0 6px; background:var(--card); border-radius:0 6px 6px 0; }
.res-wordcloud { flex:0 0 calc(50% - 8px); max-width:calc(50% - 8px); display:flex; flex-wrap:wrap; align-items:center; gap:4px 8px; padding:12px; background:var(--bg); border-radius:10px; border:1px solid var(--border); min-height:70px; align-content:flex-start; }
.res-wordcloud--mini { padding:8px; min-height:50px; gap:3px 6px; flex:unset; max-width:none; width:100%; }
/* Grouped open: word clouds per demographic group */
.res-open-clouds-group { flex:0 0 calc(50% - 8px); max-width:calc(50% - 8px); display:flex; flex-direction:column; gap:12px; }
.res-open-cloud-item { }
.res-open-cloud-title { font-size:11px; font-weight:700; margin-bottom:5px; }
/* Grouped cloud items: lay out side by side when few groups */
@media (min-width:800px) {
  .res-open-clouds-group { flex-direction:row; flex-wrap:wrap; }
  .res-open-cloud-item { flex:1; min-width:120px; }
  .res-wordcloud--mini { min-width:100px; }
}
@media (max-width:640px) { .res-open-row { flex-direction:column; } .res-open-samples-panel,.res-wordcloud,.res-open-clouds-group { flex:0 0 100%; max-width:100%; } }
.wc-word { display:inline-block; font-weight:600; cursor:default; transition:transform .15s; }
.wc-word:hover { transform:scale(1.15); }

/* Zoom modal */
.res-zoom-overlay {
  position:fixed; inset:0; background:rgba(15,23,42,.6); backdrop-filter:blur(4px);
  z-index:3000; display:flex; align-items:center; justify-content:center; padding:32px;
}
.res-zoom-modal {
  background:var(--card); border:1px solid var(--border); border-radius:20px;
  box-shadow:0 24px 64px rgba(0,0,0,.2); padding:28px 32px 24px; width:100%;
  max-width:660px; max-height:85vh; overflow-y:auto; position:relative;
}
.res-zoom-close {
  position:absolute; top:12px; right:14px; background:none; border:none;
  font-size:16px; color:var(--text-muted); cursor:pointer; padding:4px 8px; border-radius:6px;
}
.res-zoom-close:hover { background:var(--surface); color:var(--text); }

/* ── Dashboard (profile + library) ─────────────────────────────────── */

/* Onboarding */
.db-onboard { text-align:center; padding:80px 20px; max-width:480px; margin:0 auto; }
.db-onboard-icon { font-size:56px; color:var(--primary); margin-bottom:20px; }
.db-onboard-title { font-size:26px; font-weight:700; color:var(--text); margin-bottom:12px; }
.db-onboard-desc { font-size:15px; color:var(--text-muted); line-height:1.6; margin-bottom:28px; }

/* Profile header */
.db-profile-hdr { display:flex; align-items:center; gap:12px; padding:12px 0 14px; flex-wrap:wrap; }
.db-profile-avatar { font-size:20px; color:var(--primary); line-height:1; }
.db-profile-name { font-size:16px; font-weight:700; color:var(--text); margin:0; }
.db-profile-hdr .btn { margin-left:auto; }

/* Library card / tabs */
.db-lib-card { padding:0; overflow:hidden; margin-bottom:24px; }
.db-lib-tabs { display:flex; gap:0; border-bottom:1px solid var(--border); padding:0 4px; }
.db-tab { background:none; border:none; border-bottom:2px solid transparent; padding:12px 16px;
          font-size:13px; font-weight:500; color:var(--text-muted); cursor:pointer;
          display:flex; align-items:center; gap:7px; margin-bottom:-1px; transition:color .15s,border-color .15s; }
.db-tab:hover { color:var(--text); }
.db-tab.active { color:var(--primary); border-bottom-color:var(--primary); font-weight:600; }
.db-tab-count { background:var(--surface); border:1px solid var(--border); border-radius:10px;
                font-size:11px; font-weight:600; padding:1px 7px; color:var(--text-muted); }
.db-tab.active .db-tab-count { background:var(--primary-light); border-color:var(--primary); color:var(--primary); }

/* Tab pane */
.db-tab-pane { padding:16px; }
.db-pane-actions { display:flex; justify-content:flex-end; margin-bottom:14px; }
.db-empty { font-size:13px; color:var(--text-muted); padding:12px 0; }
.db-asset-hidden { display: none; }
.db-show-more {
  display: flex; align-items: center; gap: 6px;
  margin: 8px auto 4px; padding: 7px 18px;
  font-size: 13px; font-weight: 500; color: var(--primary);
  background: var(--primary-light); border: 1px solid transparent;
  border-radius: 20px; cursor: pointer; transition: background .15s, border-color .15s;
}
.db-show-more:hover { background: var(--primary-light); border-color: var(--primary); }

/* Asset grid */
.db-asset-grid { display:flex; flex-direction:column; gap:8px; }
.db-asset-card { display:flex; align-items:center; gap:12px; padding:12px 14px;
                 border:1px solid var(--border); border-radius:10px; background:var(--bg);
                 transition:box-shadow .15s; }
.db-asset-card:hover { box-shadow:var(--shadow-sm); }
.db-asset-icon { width:40px; height:40px; border-radius:10px; display:flex; align-items:center; justify-content:center; font-size:18px; flex-shrink:0; }
.db-asset-body { flex:1; min-width:0; }
.db-asset-name { font-size:13px; font-weight:600; color:var(--text); margin:0 0 2px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.db-asset-scope { font-size:12px; color:var(--text-muted); margin:0 0 2px; }
.db-asset-meta { font-size:11px; color:var(--text-muted); margin:0; }
.db-asset-status { flex-shrink:0; }
.db-asset-del { background:none; border:none; color:var(--text-muted); cursor:pointer; padding:6px 8px; border-radius:6px; font-size:13px; flex-shrink:0; }
.db-asset-del:hover { background:var(--danger-light,#fee2e2); color:var(--danger,#ef4444); }

/* Status badges */
.db-status-badge { display:inline-flex; align-items:center; gap:5px; font-size:11px; font-weight:600; padding:3px 9px; border-radius:20px; }
.db-status-done { background:#d1fae5; color:#065f46; }
.db-status-proc { background:#dbeafe; color:#1e40af; }
.db-status-err  { background:#fee2e2; color:#991b1b; }
.db-status-pend { background:var(--surface); color:var(--text-muted); border:1px solid var(--border); }

/* Experiments section */
.db-section-hdr { display:flex; align-items:center; gap:10px; margin-bottom:14px; }
.db-section-title { font-size:16px; font-weight:700; color:var(--text); margin:0; }
.db-exp-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(300px,1fr)); gap:16px; margin-bottom:40px; }

/* Card shell */
.db-exp-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 16px;
  overflow: hidden; cursor: pointer; display: flex; flex-direction: column;
  transition: box-shadow .2s, transform .2s;
}
.db-exp-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-3px); }

/* Hero banner */
.db-exp-hero {
  position: relative; height: 90px;
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 60%, #a855f7 100%);
  display: flex; align-items: center; justify-content: center;
}
/* Hero color by experiment type (matches launch card gradients) */
.db-exp-card[data-exp-type="copytest"] .db-exp-hero { background: linear-gradient(135deg,#4f46e5,#7c3aed,#a855f7); }
.db-exp-card[data-exp-type="focus"]   .db-exp-hero { background: linear-gradient(135deg,#0891b2,#06b6d4,#22d3ee); }
.db-exp-card[data-exp-type="survey"]  .db-exp-hero { background: linear-gradient(135deg,#0d9488,#14b8a6,#2dd4bf); }
.db-exp-hero-icon { font-size: 32px; color: rgba(255,255,255,.85); }

/* Status badge — overlaid top-right */
.db-exp-status {
  position: absolute; top: 10px; right: 10px;
  font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: 20px;
  display: flex; align-items: center; gap: 4px; white-space: nowrap;
  backdrop-filter: blur(4px);
}
.db-exp-status-done        { background: rgba(255,255,255,.25); color: #fff; }
.db-exp-status-running     { background: rgba(255,255,255,.25); color: #fff; }
.db-exp-status-interrupted { background: rgba(0,0,0,.25); color: #fff; }
.db-exp-status-error       { background: rgba(0,0,0,.25); color: #fff; }

/* Card body */
.db-exp-body   { padding: 14px 16px 10px; flex: 1; display: flex; flex-direction: column; gap: 4px; }
.db-exp-name   { font-size: 15px; font-weight: 700; color: var(--text); margin: 0 0 2px; line-height: 1.35; }
.db-exp-desc   { font-size: 13px; color: var(--text-muted); margin: 0 0 2px; line-height: 1.5;
                 display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.db-exp-desc:empty,
.db-exp-desc--empty { font-style: italic; color: var(--text-light); font-size: 12px; }

/* Chips row */
.db-exp-chips  { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 4px; }
.db-exp-chip   { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; color: var(--text-muted);
                 background: var(--bg); border: 1px solid var(--border); border-radius: 20px; padding: 2px 8px; }
.db-exp-chip--stim  { color: #6366f1; border-color: #c7d2fe; background: #eef2ff; }
.db-exp-chip--panel { color: #059669; border-color: #a7f3d0; background: #d1fae5; }

/* Footer CTA */
.db-exp-footer { padding: 10px 16px 14px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; }
.db-exp-cta    { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600;
                 color: var(--primary); padding: 5px 12px; border-radius: 8px; border: 1px solid var(--primary-light);
                 background: var(--primary-light); transition: background .15s, color .15s; }
.db-exp-cta:hover { background: var(--primary); color: #fff; }

/* ── New Experiment (type selector) ─────────────────────────────────── */
.exp-type-grid { display:flex; flex-direction:column; gap:14px; padding-bottom:40px; }
.exp-type-card { display:flex; align-items:flex-start; gap:18px; padding:22px 24px;
                 border:1.5px solid var(--border); border-radius:16px; background:var(--card);
                 text-decoration:none; color:inherit; transition:box-shadow .15s,border-color .15s; cursor:pointer; }
.exp-type-card:hover:not(.exp-type-card--disabled) { box-shadow:var(--shadow-md); border-color:var(--primary); }
.exp-type-card--disabled { opacity:.55; cursor:not-allowed; pointer-events:none; }
.exp-type-icon { width:48px; height:48px; border-radius:12px; display:flex; align-items:center; justify-content:center; font-size:22px; flex-shrink:0; }
.exp-type-body { flex:1; }
.exp-type-name { font-size:16px; font-weight:700; color:var(--text); margin:0 0 6px; display:flex; align-items:center; gap:10px; }
.exp-type-desc { font-size:13px; color:var(--text-muted); line-height:1.55; margin:0 0 10px; }
.exp-type-cta { font-size:13px; font-weight:600; color:var(--primary); display:flex; align-items:center; gap:6px; }
.coming-soon-tag { font-size:10px; font-weight:600; background:var(--surface); border:1px solid var(--border); color:var(--text-muted); border-radius:6px; padding:2px 7px; }

/* ── Launch new experiment cards ─────────────────────────────────── */
.db-launch-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 36px;
}
@media (max-width: 720px) {
  .db-launch-grid { grid-template-columns: 1fr; }
}
.db-launch-card {
  display: flex;
  flex-direction: column;
  border-radius: 16px;
  border: 1.5px solid var(--border);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  background: var(--card);
  transition: box-shadow .18s, transform .18s, border-color .18s;
  cursor: pointer;
}
.db-launch-card:hover:not(.db-launch-card--disabled) {
  box-shadow: 0 8px 28px rgba(99,102,241,.18);
  transform: translateY(-3px);
  border-color: #6366f1;
}
.db-launch-card--disabled {
  cursor: not-allowed;
  pointer-events: none;
}
.db-launch-card-top {
  height: 110px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.db-launch-card-icon {
  font-size: 42px;
  color: #fff;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,.18));
}
.db-launch-flow         { display: flex; align-items: center; gap: 10px; }
.db-launch-flow-step    { width: 44px; height: 44px; border-radius: 12px; background: rgba(255,255,255,.2);
                          display: flex; align-items: center; justify-content: center;
                          font-size: 18px; color: #fff; backdrop-filter: blur(4px);
                          box-shadow: 0 2px 8px rgba(0,0,0,.15); }
.db-launch-flow-arrow        { font-size: 11px; color: rgba(255,255,255,.7); }
.db-launch-flow-step--sm     { width: 34px; height: 34px; border-radius: 9px; font-size: 14px; }
.db-launch-card-body {
  padding: 18px 20px 14px;
  display: flex;
  flex-direction: column;
  flex: 1;
}
.db-launch-card-footer {
  padding: 0 16px 16px;
}
.db-launch-card-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.db-launch-card-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.55;
  margin: 0 0 16px;
  flex: 1;
}

/* db-asset-actions: replaces db-asset-status — holds buttons + badge in a row */
.db-asset-actions { display:flex; align-items:center; gap:6px; flex-shrink:0; flex-wrap:wrap; justify-content:flex-end; }
.db-asset-card { flex-wrap:wrap; }

/* modal-footer (upload modal) */
.modal-footer { display:flex; justify-content:flex-end; gap:8px; padding:12px 20px 16px; border-top:1px solid var(--border); }

/* db-status-error alias */
.db-status-error { background:#fee2e2; color:#991b1b; }

/* ── Project detail (simplified) ──────────────────────────────────── */
.proj-sims-section { margin-top:24px; }
.proj-sim-list { display:flex; flex-direction:column; gap:12px; }
.proj-sim-card { background:var(--card); border:1px solid var(--border); border-radius:14px; padding:18px 20px; }
.proj-sim-top { display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:0; }
.proj-sim-meta { display:flex; align-items:center; gap:14px; flex-wrap:wrap; }
.proj-sim-type { font-size:14px; font-weight:600; color:var(--text); display:flex; align-items:center; gap:6px; }
.proj-sim-stim { font-size:12px; color:var(--text-muted); display:flex; align-items:center; gap:5px; }
.proj-sim-date { font-size:12px; color:var(--text-muted); display:flex; align-items:center; gap:5px; }
.proj-sim-status { flex-shrink:0; }

/* Running animation */
.proj-sim-running { display:flex; align-items:center; gap:16px; margin-top:16px; padding:14px 16px; background:var(--surface); border-radius:10px; }
.proj-sim-anim { position:relative; width:36px; height:36px; flex-shrink:0; display:flex; align-items:center; justify-content:center; }
.proj-sim-pulse { position:absolute; width:36px; height:36px; border-radius:50%; background:#6366f1; opacity:.25; animation:simPulse 2s ease-out infinite; }
.proj-sim-pulse--2 { animation-delay:.6s; }
.proj-sim-pulse--3 { animation-delay:1.2s; }
.proj-sim-robot { position:relative; color:#6366f1; font-size:16px; }
@keyframes simPulse { 0%{transform:scale(.6);opacity:.4} 100%{transform:scale(1.8);opacity:0} }
.proj-sim-running-label { font-size:13px; color:var(--text-muted); margin:0; }

/* Done / error actions */
.proj-sim-actions { margin-top:14px; display:flex; align-items:center; gap:10px; }
.proj-sim-error { margin-top:12px; display:flex; align-items:center; gap:8px; font-size:13px; color:#b91c1c; background:#fee2e2; padding:10px 14px; border-radius:8px; }

/* Empty state */
.proj-nosim-card { display:flex; justify-content:center; padding:40px 24px; }
.proj-nosim-inner { text-align:center; max-width:340px; }
.proj-nosim-icon { font-size:32px; color:var(--text-muted); margin-bottom:12px; }
.proj-nosim-title { font-size:16px; font-weight:700; color:var(--text); margin:0 0 8px; }
.proj-nosim-desc { font-size:13px; color:var(--text-muted); margin:0 0 18px; line-height:1.55; }

/* ── Delete buttons — red ────────────────────────────────────────── */
.db-asset-del { color: #dc2626 !important; }
.db-asset-del:hover { background: #fef2f2 !important; color: #991b1b !important; }

/* ── Choice table ────────────────────────────────────────────────── */
.res-ct-wrap { margin: 10px 0 4px; overflow-x: auto; }
.res-choice-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.res-ct-label-h { text-align:left; padding: 5px 8px; font-weight:600; color:var(--text-muted); border-bottom:1.5px solid var(--border); }
.res-ct-num-h { text-align:right; padding: 5px 8px; font-weight:600; color:var(--text-muted); border-bottom:1.5px solid var(--border); white-space:nowrap; width:60px; }
.res-ct-label-c { padding: 5px 8px; max-width:220px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.res-ct-num-c { text-align:right; padding: 5px 8px; color:var(--text); font-variant-numeric:tabular-nums; }
.res-ct-row-even { background:var(--surface); }

/* ── Word cloud grouped grid (2 per row) ─────────────────────────── */
.res-wc-group-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.res-wc-group-grid > :last-child:nth-child(odd) { grid-column: 1; }
@media (max-width: 640px) { .res-wc-group-grid { grid-template-columns: 1fr; } }
.res-wc-group-item { background: var(--surface); border-radius: 10px; padding: 12px; }

/* ── Download button ─────────────────────────────────────────────── */
.res-dl-btn {
  display: inline-flex; align-items: center; justify-content: center;
  background: none; border: 1.5px solid var(--border); color: var(--text-muted);
  border-radius: 6px; padding: 3px 8px; font-size: 11px; cursor: pointer;
  margin-top: 6px; transition: all .15s;
}
.res-dl-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }

/* ── Copy-test select ── */
.ct-select {
  max-width: 100%;
  width: 100%;
  padding: 12px 16px;
  font-size: 15px;
  height: 48px;
  cursor: pointer;
  appearance: auto;
}

/* ── Copy-test experiment details form ── */
.ct-field-row { display:flex; align-items:flex-start; gap:16px; }
.ct-field-label {
  flex:0 0 120px; font-size:13px; font-weight:600; color:var(--text);
  padding-top:9px; /* align with input text */
}
.ct-field-required { color:var(--danger); margin-left:2px; }
.ct-field-input { flex:1; min-width:0; }

/* ── Per-card footer (toggle + download) ── */
.res-card-footer {
  display: flex; align-items: center; gap: 8px;
  margin-top: 10px; padding-top: 10px;
  border-top: 1px solid var(--border);
}
.res-card-lk-toggle { display: flex; gap: 4px; }

/* ── Section header actions (toggle + download) ── */
.res-sec-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.res-sec-lk-toggle { display: flex; gap: 4px; align-items: center; }
.res-lk-info-icon  { position: relative; font-size: 13px; color: var(--text-muted); cursor: pointer; margin-left: 2px; user-select: none; }
.res-lk-popover    { display: none; position: absolute; right: 0; top: calc(100% + 6px); width: 260px; background: var(--text); color: #fff; font-size: 12px; font-weight: 400; line-height: 1.5; padding: 10px 12px; border-radius: 8px; box-shadow: 0 4px 16px rgba(0,0,0,.18); z-index: 200; white-space: normal; pointer-events: none; }
.res-lk-popover.open { display: block; }

/* ── Survey questions page split layout ── */
.sq-split-wrap      { display: flex; gap: 0; height: calc(100vh - 220px); min-height: 400px; margin-bottom: 40px; }
.sq-questions-pane  { flex: 1; min-width: 0; overflow: hidden; display: flex; flex-direction: column; }
.sq-questions-pane .info-card { height: 100%; overflow: hidden; }
.sq-pdf-pane        { flex: 0 0 45%; min-width: 300px; height: 100%; }
.sq-handle          { width: 6px; cursor: col-resize; background: var(--border); border-radius: 3px; margin: 0 4px; flex-shrink: 0; }
.sq-handle:hover    { background: var(--primary); }

/* ── Subcard info button ── */
.res-subcard-info-btn { position: absolute; bottom: 8px; right: 8px; display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; border-radius: 50%; background: var(--border); color: var(--text-muted); font-size: 10px; font-weight: 700; font-style: italic; cursor: pointer; user-select: none; z-index: 10; transition: background .15s, color .15s; }
.res-subcard-info-btn:hover { background: var(--primary-light); color: var(--primary); }
.res-subcard-info-btn .res-lk-popover { right: 0; left: auto; transform: none; top: auto; bottom: calc(100% + 6px); }

/* ── Open questions 2-column grid ── */
.res-open-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}
.res-open-grid.res-open-2col { grid-template-columns: repeat(2, 1fr); }
.res-open-grid.res-open-2col > :only-child { grid-column: 1 / -1; }

/* ── Demographic tab layout overrides ── */
.res-grid--solo { grid-template-columns: 1fr !important; }

/* ── Gender symbol ── */
.res-gender-sym { font-size: 26px; font-weight: 700; line-height: 1; }

/* ── Gender side-by-side (♂ / ♀) layout ── */
.res-group-sb { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 20px; }
.res-group-sb-col { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.res-group-sb-sym { font-size: 32px; line-height: 1; }
.res-group-sb-col .res-group-track { width: 100%; }
.res-group-sb-col .res-group-val   { text-align: center; }

/* ── Zoomable word cloud item ── */
.res-wc-group-item { cursor: zoom-in; }

/* ── Choice cross-tab matrix (age groups) ── */
.res-crosstab { width: 100%; }
.res-crosstab-gh { font-size: 11px; font-weight: 700; white-space: nowrap; max-width: 80px; overflow: hidden; text-overflow: ellipsis; }
.res-crosstab-tot-row td { border-top: 2px solid var(--border); font-size: 11px; padding-top: 6px; }

/* ── Stacked horizontal bar (likert count by group) ── */
.res-stacked-wrap        { display: flex; flex-direction: column; gap: 10px; padding: 4px 0; }
.res-stacked-legend      { display: flex; gap: 12px; margin-bottom: 2px; flex-wrap: wrap; }
.res-stacked-legend-item { display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--text-muted); }
.res-stacked-swatch      { width: 10px; height: 10px; border-radius: 2px; display: inline-block; flex-shrink: 0; }
.res-stacked-row         { display: flex; align-items: center; gap: 10px; }
.res-stacked-lbl         { flex: 0 0 38px; text-align: right; font-size: 13px; font-weight: 600; line-height: 1; }
.res-stacked-bar         { flex: 1; height: 24px; border-radius: 5px; overflow: hidden; display: flex; background: var(--border); }
.res-stacked-seg         { height: 100%; display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 600; color: rgba(255,255,255,0.9); overflow: hidden; white-space: nowrap; }
.res-stacked-tot         { flex: 0 0 42px; font-size: 11px; color: var(--text-muted); }

/* ============================================================
   Dark mode
   ============================================================ */
[data-theme="dark"] {
  --bg:           #0f172a;
  --card:         #1e293b;
  --border:       #334155;
  --border-focus: #818cf8;
  --text:         #f1f5f9;
  --text-muted:   #94a3b8;
  --text-light:   #64748b;
  --primary-light: #1e1b4b;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.4);
  --shadow:    0 4px 12px rgba(0,0,0,.5);
  --shadow-lg: 0 8px 24px rgba(0,0,0,.6);
}
[data-theme="dark"] .navbar          { background: #0f172a; border-bottom-color: #1e293b; }
[data-theme="dark"] .info-card       { background: #1e293b; border-color: #334155; }
[data-theme="dark"] .modal-box       { background: #1e293b; }
[data-theme="dark"] .modal-header    { border-bottom-color: #334155; }
[data-theme="dark"] .form-input      { background: #0f172a; border-color: #334155; color: #f1f5f9; }
[data-theme="dark"] .form-input::placeholder { color: #64748b; }
[data-theme="dark"] .dropzone        { background: #0f172a; border-color: #334155; }
[data-theme="dark"] .btn-outline     { border-color: #334155; color: #94a3b8; }
[data-theme="dark"] .btn-outline:hover { background: #334155; color: #f1f5f9; }
[data-theme="dark"] .btn-ghost:hover { background: #334155; }
[data-theme="dark"] .db-asset-card   { background: #0f172a; border-color: #334155; }
[data-theme="dark"] .db-exp-card     { background: #1e293b; border-color: #334155; }
[data-theme="dark"] .db-launch-card  { background: #1e293b; border-color: #334155; }
[data-theme="dark"] .db-tab          { background: #0f172a; color: #94a3b8; border-color: #334155; }
[data-theme="dark"] .db-tab.active   { background: #1e293b; color: #f1f5f9; }
[data-theme="dark"] .db-lib-card     { background: #1e293b; }
[data-theme="dark"] .res-q-mini      { background: #0f172a; border-color: #334155; }
[data-theme="dark"] .res-ct-row-even { background: rgba(255,255,255,.03); }
[data-theme="dark"] .res-lk-popover  { background: #f1f5f9; color: #1e293b; }
[data-theme="dark"] .res-demo-tab    { color: #94a3b8; }
[data-theme="dark"] .res-demo-tab.active { background: #1e293b; color: #f1f5f9; border-color: #334155; }
[data-theme="dark"] .res-lk-toggle-btn { background: #0f172a; border-color: #334155; color: #94a3b8; }
[data-theme="dark"] .res-lk-toggle-btn.active { background: var(--primary); color: #fff; }
[data-theme="dark"] .res-dl-btn      { background: #0f172a; border-color: #334155; color: #94a3b8; }
[data-theme="dark"] .res-dl-btn:hover { background: #334155; color: #f1f5f9; }
[data-theme="dark"] .res-stacked-bar { background: #334155; }
[data-theme="dark"] .res-header-card { background: #1e293b; border-color: #334155; }
[data-theme="dark"] .res-hdr-notice  { background: #0c1a2e; border-color: #3b82f6; }
[data-theme="dark"] table            { color: #f1f5f9; }
[data-theme="dark"] .res-choice-table th { background: #0f172a; }

/* ── Theme toggle button ── */
.theme-toggle {
  display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--bg); border: 1px solid var(--border);
  color: var(--text-muted); font-size: 14px;
  transition: background .2s, color .2s, border-color .2s;
}
.theme-toggle:hover { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }

/* ============================================================
   Dashboard color improvements
   ============================================================ */

/* Profile header */
.db-profile-hdr { position: relative; padding: 12px 0 14px; }
.db-profile-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #818cf8);
  color: #fff; font-size: 18px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; box-shadow: 0 2px 8px rgba(91,71,224,.25);
}
.db-profile-initials { font-size: 20px; font-weight: 700; color: #fff; line-height: 1; letter-spacing: 0; }
.db-profile-name { font-size: 16px; font-weight: 700; color: var(--text); margin: 0; background: none; -webkit-text-fill-color: unset; }

/* Coloured left accent on asset cards */
.db-asset-card { border-left: 3px solid transparent; }
#pane-panels   .db-asset-card { border-left-color: #6366f1; }
#pane-surveys  .db-asset-card { border-left-color: #10b981; }
#pane-stimuli  .db-asset-card { border-left-color: #f59e0b; }

/* Section title accent */
.db-section-title { background: linear-gradient(135deg,var(--primary),#818cf8); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; font-size: 17px; }

/* Dark mode: exp card chips */
[data-theme="dark"] .db-exp-chip           { background: #0f172a; border-color: #334155; }
[data-theme="dark"] .db-exp-chip--stim     { background: #1e1b4b; border-color: #4338ca; color: #a5b4fc; }
[data-theme="dark"] .db-exp-chip--panel    { background: #064e3b; border-color: #065f46; color: #6ee7b7; }
[data-theme="dark"] .db-exp-footer         { border-top-color: #334155; }
[data-theme="dark"] .db-exp-cta            { background: #1e1b4b; border-color: #4338ca; color: #a5b4fc; }
[data-theme="dark"] .db-exp-cta:hover      { background: var(--primary); color: #fff; }

/* Library tabs */
.db-tab.active { background: var(--primary-light); color: var(--primary); border-color: var(--primary); font-weight: 700; }
.db-tab-count  { background: var(--primary); color: #fff; border-radius: 10px; padding: 1px 7px; font-size: 11px; font-weight: 700; margin-left: 4px; }


/* Count badge */
.count-badge { background: linear-gradient(135deg,var(--primary),#818cf8); color:#fff; border-radius:20px; padding:2px 10px; font-size:12px; font-weight:700; }

/* ============================================================
   Survey Questions page  (.sq-*)
   ============================================================ */

/* Split layout */
.sq-split-wrap      { display:flex; gap:16px; align-items:flex-start; }
.sq-questions-pane  { flex:1; min-width:0; display:flex; flex-direction:column; gap:12px; }
.sq-pdf-pane        { flex:1; min-width:320px; height:calc(100vh - 160px); border-radius:12px; overflow:hidden; border:1px solid var(--border); position:sticky; top:16px; }
.sq-handle          { width:6px; border-radius:3px; background:var(--border); cursor:col-resize; flex-shrink:0; position:sticky; top:0; align-self:stretch; transition:background .2s; }
.sq-handle:hover    { background:var(--primary); }

/* Question list */
.sq-list            { display:flex; flex-direction:column; gap:10px; }
.sq-empty           { text-align:center; padding:40px 20px; color:var(--text-muted); }
.sq-empty i         { font-size:32px; margin-bottom:10px; display:block; }
.sq-empty p         { font-size:14px; margin:0; }

/* Question card */
.sq-q-card          { background:var(--card); border:1px solid var(--border); border-radius:12px; overflow:hidden; transition:border-color .2s, box-shadow .2s; }
.sq-q-card:hover    { border-color:var(--primary); box-shadow:var(--shadow-sm); }
.sq-q-card--editing { border-color:var(--primary); box-shadow:0 0 0 3px var(--primary-light); }

.sq-q-card-main     { display:flex; align-items:center; gap:12px; padding:14px 16px; cursor:pointer; }
.sq-q-num           { width:36px; height:36px; border-radius:8px; display:flex; align-items:center; justify-content:center; font-size:12px; font-weight:800; flex-shrink:0; }
.sq-q-body          { flex:1; min-width:0; }
.sq-q-text          { font-size:14px; font-weight:600; margin:0 0 6px; color:var(--text); line-height:1.4; }
.sq-q-type-pill     { display:inline-flex; align-items:center; gap:5px; padding:2px 10px; border-radius:20px; font-size:11px; font-weight:700; }

/* Options chips */
.sq-q-opts          { display:flex; flex-wrap:wrap; gap:4px; margin-top:4px; }
.sq-q-chip          { padding:2px 8px; background:var(--bg); border:1px solid var(--border); border-radius:20px; font-size:11px; color:var(--text-muted); }
.sq-q-chip--scale   { background:var(--bg); border-color:var(--border); }

/* Scale range display */
.sq-q-scale-range   { display:flex; align-items:center; gap:6px; margin-top:4px; flex-wrap:wrap; }

/* Action buttons */
.sq-q-actions       { display:flex; gap:6px; flex-shrink:0; opacity:0; transition:opacity .15s; }
.sq-q-card:hover .sq-q-actions { opacity:1; }
.sq-q-card--editing .sq-q-actions { opacity:1; }
.sq-q-edit-btn,
.sq-q-del-btn       { width:30px; height:30px; border-radius:8px; border:1px solid var(--border); background:var(--bg); color:var(--text-muted); font-size:12px; display:flex; align-items:center; justify-content:center; cursor:pointer; transition:background .15s, color .15s, border-color .15s; }
.sq-q-edit-btn:hover,
.sq-q-edit-btn.active { background:var(--primary-light); color:var(--primary); border-color:var(--primary); }
.sq-q-del-btn:hover { background:#fee2e2; color:#dc2626; border-color:#dc2626; }

/* Inline edit panel */
.sq-edit-panel      { padding:14px 16px; border-top:1px solid var(--border); background:var(--bg); }

/* Add question card */
.sq-add-card        { margin-top:4px; }
.sq-add-row         { display:flex; gap:10px; align-items:center; flex-wrap:wrap; }
.sq-add-extra       { margin-top:12px; }
.sq-add-label       { display:block; font-size:12px; font-weight:600; color:var(--text-muted); margin-bottom:4px; }
.sq-scale-row       { display:flex; gap:10px; flex-wrap:wrap; }
.sq-scale-field     { display:flex; flex-direction:column; }

/* Dark mode overrides */
[data-theme="dark"] .sq-q-card         { background:#1e293b; border-color:#334155; }
[data-theme="dark"] .sq-q-card:hover   { border-color:#818cf8; }
[data-theme="dark"] .sq-edit-panel     { background:#0f172a; border-color:#334155; }
[data-theme="dark"] .sq-q-edit-btn,
[data-theme="dark"] .sq-q-del-btn      { background:#0f172a; border-color:#334155; }
[data-theme="dark"] .sq-q-chip         { background:#0f172a; border-color:#334155; }
[data-theme="dark"] .sq-pdf-pane       { border-color:#334155; }
