:root {
  --blue-50: #eff6ff;
  --blue-100: #dbeafe;
  --blue-200: #bfdbfe;
  --blue-400: #60a5fa;
  --blue-500: #3b82f6;
  --blue-600: #2563eb;
  --blue-700: #1d4ed8;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --green-500: #22c55e;
  --green-600: #16a34a;
  --yellow-500: #eab308;
  --yellow-600: #ca8a04;
  --red-500: #ef4444;
  --red-600: #dc2626;
  --white: #ffffff;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07), 0 2px 4px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1), 0 4px 6px rgba(0, 0, 0, 0.05);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-full: 9999px;
  --transition: 0.2s ease;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--gray-50);
  color: var(--gray-800);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

#app {
  min-height: 100vh;
}

/* ── Container ── */

.container {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ── Progress bar ── */

.progress-wrap {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--white);
  padding: 16px 0 12px;
  border-bottom: 1px solid var(--gray-100);
}

.progress-label {
  font-size: 13px;
  color: var(--gray-500);
  margin-bottom: 6px;
  text-align: center;
}

.progress-track {
  height: 6px;
  background: var(--gray-200);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--blue-400), var(--blue-600));
  border-radius: var(--radius-full);
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  min-width: 4%;
}

/* ── Question card ── */

.question-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 32px 28px;
  margin: 24px 0;
  animation: fadeSlideIn 0.35s ease;
}

@keyframes fadeSlideIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.question-card h2 {
  font-size: 20px;
  font-weight: 600;
  color: var(--gray-900);
  margin-bottom: 6px;
  line-height: 1.4;
}

.question-subtitle {
  font-size: 14px;
  color: var(--gray-500);
  margin-bottom: 20px;
}

/* ── Option cards (radio / single select) ── */

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

.option-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--gray-50);
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  font-size: 15px;
  color: var(--gray-700);
  user-select: none;
}

.option-card:hover {
  border-color: var(--blue-400);
  background: var(--blue-50);
}

.option-card.selected {
  border-color: var(--blue-500);
  background: var(--blue-50);
  color: var(--blue-700);
  font-weight: 500;
}

.option-radio,
.option-check {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--gray-300);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.option-check {
  border-radius: 5px;
}

.option-card.selected .option-radio {
  border-color: var(--blue-500);
}

.option-card.selected .option-radio::after {
  content: "";
  width: 10px;
  height: 10px;
  background: var(--blue-500);
  border-radius: 50%;
}

.option-card.selected .option-check {
  border-color: var(--blue-500);
  background: var(--blue-500);
}

.option-card.selected .option-check::after {
  content: "";
  width: 12px;
  height: 8px;
  border-left: 2px solid var(--white);
  border-bottom: 2px solid var(--white);
  transform: rotate(-45deg) translateY(-1px);
}

/* ── Multi-select pills ── */

.pills-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill {
  padding: 8px 16px;
  background: var(--gray-100);
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-full);
  font-size: 14px;
  cursor: pointer;
  transition: all var(--transition);
  user-select: none;
  color: var(--gray-600);
}

.pill:hover {
  border-color: var(--blue-400);
  background: var(--blue-50);
}

.pill.selected {
  background: var(--blue-500);
  border-color: var(--blue-500);
  color: var(--white);
  font-weight: 500;
}

/* ── File upload ── */

.upload-zone {
  border: 2px dashed var(--gray-300);
  border-radius: var(--radius);
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  background: var(--gray-50);
}

.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--blue-400);
  background: var(--blue-50);
}

.upload-zone-icon {
  font-size: 40px;
  margin-bottom: 12px;
  opacity: 0.5;
}

.upload-zone-text {
  font-size: 15px;
  color: var(--gray-600);
  margin-bottom: 4px;
}

.upload-zone-hint {
  font-size: 13px;
  color: var(--gray-400);
}

.file-list {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--gray-100);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--gray-700);
}

.file-item-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 70%;
}

.file-remove {
  background: none;
  border: none;
  color: var(--gray-400);
  cursor: pointer;
  font-size: 18px;
  padding: 0 4px;
  transition: color var(--transition);
}

.file-remove:hover {
  color: var(--red-500);
}

/* ── Info card ── */

.info-text {
  font-size: 15px;
  color: var(--gray-600);
  line-height: 1.7;
  white-space: pre-line;
}

/* ── Buttons ── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 500;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  line-height: 1;
}

.btn-primary {
  background: var(--blue-600);
  color: var(--white);
}

.btn-primary:hover {
  background: var(--blue-700);
}

.btn-secondary {
  background: var(--white);
  color: var(--blue-600);
  border-color: var(--blue-600);
}

.btn-secondary:hover {
  background: var(--blue-50);
}

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

.btn-block {
  width: 100%;
}

.nav-buttons {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

.nav-buttons .btn {
  flex: 1;
}

/* ── Spinner ── */

.spinner-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  gap: 20px;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--gray-200);
  border-top-color: var(--blue-500);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.spinner-text {
  font-size: 15px;
  color: var(--gray-500);
}

/* ── Results ── */

.results-page {
  padding-bottom: 60px;
}

.results-hero {
  text-align: center;
  padding: 40px 20px 32px;
}

.results-hero h1 {
  font-size: 24px;
  font-weight: 600;
  color: var(--gray-900);
  margin-bottom: 4px;
}

.results-hero .ba-value {
  font-size: 56px;
  font-weight: 700;
  color: var(--blue-600);
  line-height: 1.2;
}

.results-hero .ba-unit {
  font-size: 20px;
  font-weight: 400;
  color: var(--gray-500);
}

.delta-badge {
  display: inline-block;
  padding: 4px 14px;
  border-radius: var(--radius-full);
  font-size: 14px;
  font-weight: 600;
  margin-top: 8px;
}

.delta-badge.positive {
  background: #fef2f2;
  color: var(--red-600);
}

.delta-badge.negative {
  background: #f0fdf4;
  color: var(--green-600);
}

.delta-badge.neutral {
  background: var(--gray-100);
  color: var(--gray-600);
}

/* ── Circular gauge ── */

.gauge-wrap {
  display: flex;
  justify-content: center;
  margin: 16px 0 32px;
}

.gauge {
  position: relative;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gauge-bg {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(
    var(--gauge-color, var(--blue-500)) calc(var(--gauge-pct, 0) * 1%),
    var(--gray-200) calc(var(--gauge-pct, 0) * 1%)
  );
  mask: radial-gradient(transparent 60%, black 61%);
  -webkit-mask: radial-gradient(transparent 60%, black 61%);
}

.gauge-inner {
  position: relative;
  z-index: 1;
  text-align: center;
}

.gauge-value {
  font-size: 40px;
  font-weight: 700;
  color: var(--gray-900);
  line-height: 1;
}

.gauge-label {
  font-size: 13px;
  color: var(--gray-500);
  margin-top: 4px;
}

/* ── System scores (horizontal bars) ── */

.systems-section {
  margin: 24px 0;
}

.systems-section h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--gray-900);
  margin-bottom: 16px;
}

.system-bar-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.system-bar-label {
  width: 110px;
  flex-shrink: 0;
  font-size: 14px;
  color: var(--gray-600);
  text-align: right;
}

.system-bar-track {
  flex: 1;
  height: 14px;
  background: var(--gray-200);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.system-bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.system-bar-fill.bar-green {
  background: linear-gradient(90deg, #34d399, var(--green-500));
}

.system-bar-fill.bar-yellow {
  background: linear-gradient(90deg, #fbbf24, var(--yellow-500));
}

.system-bar-fill.bar-red {
  background: linear-gradient(90deg, #f87171, var(--red-500));
}

.system-bar-value {
  width: 36px;
  flex-shrink: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-700);
}

/* ── Product recommendations ── */

.recs-section {
  margin: 32px 0;
}

.recs-section h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--gray-900);
  margin-bottom: 16px;
}

.rec-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 14px;
  border-left: 4px solid var(--blue-500);
}

.rec-card-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--gray-900);
  margin-bottom: 4px;
}

.rec-card-desc {
  font-size: 14px;
  color: var(--gray-500);
  margin-bottom: 8px;
}

.rec-card-reason {
  font-size: 13px;
  color: var(--blue-600);
  background: var(--blue-50);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
}

/* ── Warnings ── */

.warnings-section {
  margin: 24px 0;
  padding: 16px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: var(--radius);
}

.warnings-section h4 {
  font-size: 15px;
  font-weight: 600;
  color: #92400e;
  margin-bottom: 8px;
}

.warnings-section ul {
  padding-left: 20px;
}

.warnings-section li {
  font-size: 14px;
  color: #78350f;
  margin-bottom: 4px;
}

/* ── Results actions ── */

.results-actions {
  display: flex;
  gap: 12px;
  margin-top: 32px;
  flex-wrap: wrap;
}

.results-actions .btn {
  flex: 1;
  min-width: 140px;
}

/* ── Error ── */

.error-box {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--radius);
  padding: 20px;
  margin: 24px 0;
  text-align: center;
}

.error-box p {
  color: var(--red-600);
  font-size: 15px;
  margin-bottom: 12px;
}

/* ── Loading screen ── */

.loading-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  gap: 20px;
}

/* ── Extracted markers badge ── */

.markers-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: var(--radius-full);
  font-size: 14px;
  color: var(--green-600);
  font-weight: 500;
  margin-top: 12px;
}

/* ── Responsive ── */

@media (max-width: 480px) {
  .container {
    padding: 0 16px;
  }

  .question-card {
    padding: 24px 20px;
    margin: 16px 0;
    border-radius: var(--radius-sm);
  }

  .question-card h2 {
    font-size: 18px;
  }

  .option-card {
    padding: 12px 14px;
    font-size: 14px;
  }

  .results-hero .ba-value {
    font-size: 44px;
  }

  .gauge {
    width: 170px;
    height: 170px;
  }

  .system-bar-label {
    width: 90px;
    font-size: 13px;
  }

  .nav-buttons {
    flex-direction: column;
    gap: 8px;
  }

  .results-actions {
    flex-direction: column;
  }
}

/* ── Detail / Debug Sections ── */

.detail-section,
.debug-section {
  background: var(--white);
  border-radius: var(--radius);
  padding: 24px;
  margin: 20px 0;
  box-shadow: var(--shadow-sm);
}

.debug-section {
  background: #f8f9fb;
  border: 1px dashed var(--gray-300);
}

.debug-section h3 {
  color: var(--gray-500);
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 16px;
}

.detail-section h3 {
  margin-bottom: 16px;
  color: var(--gray-800);
}

.detail-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  margin-bottom: 12px;
}

.detail-table td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--gray-200);
}

.detail-table td:first-child {
  color: var(--gray-500);
  width: 50%;
}

.detail-value {
  font-weight: 600;
  color: var(--gray-800);
  font-variant-numeric: tabular-nums;
}

.detail-sub {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-600);
  margin: 12px 0 6px;
}

.detail-deficit {
  font-size: 13px;
  color: var(--red-500);
  padding-left: 12px;
}

.section-hint {
  font-size: 13px;
  color: var(--gray-400);
  margin: -8px 0 16px;
}

.system-score-cell {
  font-size: 13px;
  color: var(--gray-500);
  min-width: 50px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.system-header {
  font-size: 12px;
  color: var(--gray-400);
  text-transform: uppercase;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--gray-200);
  margin-bottom: 8px;
}

.rec-card-system {
  font-size: 12px;
  color: var(--blue-500);
  margin-top: 4px;
}

.debug-json {
  background: var(--gray-800);
  color: #a5d6a7;
  padding: 16px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  line-height: 1.5;
  overflow-x: auto;
  max-height: 400px;
  overflow-y: auto;
  margin-top: 8px;
}

.ba-display {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 4px;
}

/* ── Number Input ── */

.number-input-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 280px;
  margin: 20px auto;
}

.number-input {
  width: 100%;
  padding: 16px 20px;
  font-size: 24px;
  font-weight: 600;
  text-align: center;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius);
  outline: none;
  transition: border-color 0.2s;
  -moz-appearance: textfield;
  color: var(--gray-800);
  background: var(--white);
}

.number-input::-webkit-outer-spin-button,
.number-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.number-input:focus {
  border-color: var(--blue-500);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.number-input.input-error {
  border-color: var(--red-500);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
  animation: shake 0.3s;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

.number-unit {
  font-size: 18px;
  color: var(--gray-400);
  font-weight: 500;
  white-space: nowrap;
}

.bmi-badge {
  text-align: center;
  font-size: 15px;
  color: var(--blue-500);
  font-weight: 600;
  margin-top: 8px;
}

/* LinAge2 Lab BA section */
.linage2-section {
  background: linear-gradient(135deg, #e8f5e9 0%, #e3f2fd 100%);
  border: 2px solid #66bb6a;
  border-radius: 12px;
  padding: 1.5rem;
  margin-top: 1.5rem;
}
.linage2-section h3 {
  color: #2e7d32;
  margin-bottom: 0.75rem;
}
.ba-lab-display {
  text-align: center;
  margin: 0.5rem 0;
}
.ba-lab-value {
  font-size: 3rem;
  font-weight: 700;
  color: #1b5e20;
}

/* Text input styling */
.text-input-wrap {
  display: flex;
  justify-content: center;
  margin: 1rem 0;
}
.text-input {
  font-size: 1.25rem;
  padding: 0.75rem 1rem;
  border: 2px solid var(--border-color, #e0e0e0);
  border-radius: 8px;
  width: 100%;
  max-width: 400px;
  text-align: center;
}
.text-input:focus {
  outline: none;
  border-color: var(--primary-color, #3b82f6);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}
