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

:root {
  --color-bg: #ffffff;
  --color-text: #1a1a1a;
  --color-primary: #2563eb;
  --color-primary-hover: #1d4ed8;
  --color-border: #d1d5db;
  --color-muted: #6b7280;
  --color-disclaimer-bg: #fef9c3;
  --color-disclaimer-border: #fbbf24;
  --color-privacy-bg: #f0fdf4;
  --color-privacy-border: #86efac;
  --color-resume-bg: #eff6ff;
  --color-resume-border: #93c5fd;
  --font-base: 112.5%; /* 18px at the browser-default 16px; scales with user preference */
  --max-width: 720px;
  --spacing-xs: 0.5rem;
  --spacing-sm: 1rem;
  --spacing-md: 1.5rem;
  --spacing-lg: 2.5rem;
}

html { font-size: var(--font-base); }
body {
  font-family: Arial, Helvetica, sans-serif;
  color: var(--color-text);
  background: var(--color-bg);
  margin: 0;
  padding: 2rem;
  line-height: 1.6;
}

.screen[hidden] { display: none; }
.screen { max-width: var(--max-width); margin: 0 auto; }

/* Headings receive programmatic focus after navigation — no visible ring. */
h1[tabindex="-1"]:focus,
h2[tabindex="-1"]:focus {
  outline: none;
}

/* --- Viewport gate --- */

#viewport-gate {
  text-align: center;
  padding-top: 20vh;
}
.url-display {
  font-family: monospace;
  font-size: 1rem;
  background: #f3f4f6;
  padding: 0.75rem 1.5rem;
  border-radius: 0.5rem;
  word-break: break-all;
  user-select: all;
}

/* --- App container --- */

#app {
  max-width: var(--max-width);
  margin: 0 auto;
}

/* --- Welcome screen --- */

.welcome-title {
  font-size: 1.75rem;
  font-weight: 700;
  margin-top: 0;
  margin-bottom: var(--spacing-md);
  color: var(--color-text);
  text-align: center;
}

/* Disclaimer box */
.disclaimer-box {
  background: var(--color-disclaimer-bg);
  border: 2px solid var(--color-disclaimer-border);
  border-radius: 0.5rem;
  padding: var(--spacing-md);
  margin-bottom: var(--spacing-md);
}

.disclaimer-heading {
  font-size: 1rem;
  font-weight: 700;
  margin-top: 0;
  margin-bottom: var(--spacing-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #92400e;
}

.disclaimer-list {
  margin: 0;
  padding-left: 1.5rem;
  color: #78350f;
}

.disclaimer-list li {
  margin-bottom: 0.4rem;
  line-height: 1.5;
}

.disclaimer-list li:last-child {
  margin-bottom: 0;
}

/* Success box (cross-track comparison — consistent) */
.success-box {
  background: var(--color-privacy-bg);
  border: 2px solid var(--color-privacy-border);
  border-radius: 0.5rem;
  padding: var(--spacing-md);
  margin-top: var(--spacing-sm);
}

.success-box p {
  margin: 0 0 var(--spacing-xs) 0;
}

.success-box p:last-child {
  margin-bottom: 0;
}

/* Info section */
.welcome-info {
  margin-bottom: var(--spacing-md);
}

.welcome-section-heading {
  font-size: 1.125rem;
  font-weight: 700;
  margin-top: 0;
  margin-bottom: var(--spacing-xs);
}

.welcome-section-subheading {
  font-size: 1rem;
  font-weight: 600;
  margin-top: var(--spacing-sm);
  margin-bottom: var(--spacing-xs);
}

.conditions-list {
  margin: 0;
  padding-left: 1.5rem;
}

.conditions-list li {
  margin-bottom: 0.4rem;
  line-height: 1.5;
}

.conditions-list li:last-child {
  margin-bottom: 0;
}

/* Privacy badge */
.privacy-badge {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: var(--spacing-xs);
  background: none;
  border: none;
  border-radius: 0;
  padding: 0.75rem var(--spacing-sm);
  margin-bottom: var(--spacing-lg);
  font-size: 0.9rem;
  color: #166534;
  line-height: 1.5;
}

.privacy-icon {
  flex-shrink: 0;
  font-size: 1rem;
  line-height: 1.5;
}

/* Button group */
.welcome-buttons {
  display: flex;
  gap: var(--spacing-sm);
  flex-wrap: wrap;
  justify-content: center;
}

/* --- Buttons --- */

.btn {
  display: inline-block;
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  font-family: inherit;
  font-weight: 600;
  border-radius: 0.375rem;
  border: 2px solid transparent;
  cursor: pointer;
  text-align: center;
  line-height: 1.25;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn:focus-visible {
  outline: 3px solid var(--color-primary);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--color-primary);
  color: #ffffff;
  border-color: var(--color-primary);
}

.btn-primary:hover {
  background: var(--color-primary-hover);
  border-color: var(--color-primary-hover);
}

.btn-secondary {
  background: #ffffff;
  color: var(--color-text);
  border-color: var(--color-border);
}

.btn-secondary:hover {
  background: #f9fafb;
  border-color: #9ca3af;
}

/* --- Resume prompt --- */

.resume-box {
  background: var(--color-resume-bg);
  border: 2px solid var(--color-resume-border);
  border-radius: 0.5rem;
  padding: var(--spacing-md);
  margin-bottom: var(--spacing-md);
}

.resume-box h2 {
  margin-top: 0;
  margin-bottom: var(--spacing-xs);
  font-size: 1.125rem;
  color: #1e40af;
}

.resume-box p {
  margin-top: 0;
  margin-bottom: var(--spacing-sm);
  color: #1e3a8a;
}

.resume-buttons {
  display: flex;
  gap: var(--spacing-sm);
  flex-wrap: wrap;
}

/* --- Track selection --- */

.track-option {
  display: flex;
  flex-direction: column;
  width: 100%;
  text-align: left;
  background: #ffffff;
  border: 2px solid var(--color-border);
  border-radius: 0.5rem;
  padding: var(--spacing-md);
  margin-bottom: var(--spacing-sm);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  line-height: 1.6;
}

.track-option:hover {
  border-color: var(--color-primary);
  background: #f8faff;
}

.track-option.selected {
  border-color: var(--color-primary);
  background: var(--color-resume-bg);
}

.track-option:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.track-option-name {
  font-size: 1.125rem;
  font-weight: 700;
  margin-bottom: var(--spacing-xs);
}

.track-completed-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-privacy-border);
  background: var(--color-privacy-bg);
  padding: 0.125rem 0.5rem;
  border-radius: 0.75rem;
  margin-left: 0.5rem;
  vertical-align: middle;
}

.track-option-desc {
  color: var(--color-muted);
  margin-bottom: var(--spacing-xs);
}

.track-option-preview {
  font-size: 0.9rem;
  padding: var(--spacing-xs) var(--spacing-sm);
  background: #f9fafb;
  border-radius: 0.25rem;
  border-left: 3px solid var(--color-border);
}

.track-confirm {
  margin-top: var(--spacing-sm);
}

.track-rec-warning {
  font-size: 0.875rem;
  color: var(--color-muted);
  margin-top: var(--spacing-xs);
}

.try-other-track {
  margin-top: var(--spacing-md);
  margin-bottom: var(--spacing-sm);
}

/* --- Question components --- */

.question-block {
  margin-bottom: var(--spacing-md);
}

.question-stem {
  font-weight: 700;
  font-size: 1.1rem;
  margin-top: 0;
  margin-bottom: var(--spacing-sm);
  line-height: 1.5;
}

.question-options {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.question-option {
  display: block;
  width: 100%;
  padding: 0.875rem 1rem;
  font-size: 1rem;
  font-family: inherit;
  font-weight: 400;
  text-align: left;
  background: #ffffff;
  color: var(--color-text);
  border: 2px solid var(--color-border);
  border-radius: 0.375rem;
  cursor: pointer;
  line-height: 1.4;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.question-option:hover {
  background: #f9fafb;
  border-color: #9ca3af;
}

.question-option.selected {
  border-color: var(--color-primary);
  background: #eff6ff;
  color: var(--color-text);
  font-weight: 600;
}

.question-option:focus-visible {
  outline: 3px solid var(--color-primary);
  outline-offset: 2px;
}

/* --- Comfort rating --- */

.comfort-options {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.comfort-option {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.875rem 1rem;
  font-size: 1rem;
  font-family: inherit;
  text-align: left;
  background: #ffffff;
  color: var(--color-text);
  border: 2px solid var(--color-border);
  border-radius: 0.375rem;
  cursor: pointer;
  line-height: 1.4;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.comfort-option:hover {
  background: #f9fafb;
  border-color: #9ca3af;
}

.comfort-option.selected {
  border-color: var(--color-primary);
  background: #eff6ff;
  font-weight: 600;
}

.comfort-option:focus-visible {
  outline: 3px solid var(--color-primary);
  outline-offset: 2px;
}

.comfort-number {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  background: var(--color-border);
  border-radius: 50%;
  font-weight: 700;
  font-size: 1rem;
  color: var(--color-text);
}

.comfort-option.selected .comfort-number {
  background: var(--color-primary);
  color: #ffffff;
}

.comfort-label {
  flex: 1;
}

/* --- Next button --- */

.btn-next {
  display: inline-block;
  padding: 0.75rem 2rem;
  font-size: 1rem;
  font-family: inherit;
  font-weight: 600;
  border-radius: 0.375rem;
  border: 2px solid var(--color-primary);
  background: var(--color-primary);
  color: #ffffff;
  cursor: pointer;
  margin-top: var(--spacing-md);
  transition: background-color 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}

.btn-next:hover:not(:disabled) {
  background: var(--color-primary-hover);
  border-color: var(--color-primary-hover);
}

.btn-next:disabled {
  background: #d1d5db;
  border-color: #d1d5db;
  color: #6b7280;
  cursor: not-allowed;
  opacity: 0.7;
}

.btn-next:focus-visible {
  outline: 3px solid var(--color-primary);
  outline-offset: 2px;
}

/* --- Progress bar --- */

.progress-wrapper {
  margin-bottom: var(--spacing-md);
}

.progress-label {
  font-size: 0.875rem;
  color: var(--color-muted);
  margin-top: 0;
  margin-bottom: 0.375rem;
}

.progress-bar {
  width: 100%;
  height: 6px;
  background: #e5e7eb;
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--color-primary);
  border-radius: 3px;
  transition: width 0.3s ease;
}

/* --- Passage container --- */

.passage {
  margin: 1.5rem 0;
  padding: 1.5rem;
  border-radius: 0.5rem;
}

/* --- Mode A: Baseline --- */

.mode-baseline {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 18px;
  line-height: 1.6;
  color: #000;
  background: #fff;
  max-width: 600px;
}

/* --- Mode B: Narrow column --- */

.mode-narrow {
  max-width: 180px;
  margin-left: auto;
  margin-right: auto;
  text-align: center;
  line-height: 2.0;
  font-size: 20px;
}

/* --- Mode C: Spacing --- */

.mode-spacing {
  letter-spacing: 0.15em;
  word-spacing: 0.3em;
  line-height: 2.0;
  font-size: 18px;
}

/* --- Mode D: Chunks --- */

.mode-chunks {
  line-height: 1.8;
  font-size: 18px;
}
.mode-chunks .chunk-sentence {
  border-left: 3px solid #e5e7eb;
  padding-left: 1rem;
  margin-bottom: 1rem;
}
.mode-chunks .chunk-sentence:nth-child(odd) {
  border-left-color: #c7d2fe;
}
.mode-chunks .chunk-phrase {
  display: block;
}

/* --- Mode E: Reveal --- */

.mode-reveal {
  font-size: 18px;
  line-height: 1.6;
}
.mode-reveal .sentence {
  transition: opacity 0.3s ease;
}
.mode-reveal .sentence.faded {
  opacity: 0.4;
}

/* --- Mode F: Tinted --- */

.mode-tinted {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 18px;
  line-height: 1.6;
  color: #333333;
  background: #FFF8E7;
  max-width: 600px;
  padding: 1.5rem;
  border-radius: 0.5rem;
}

/* --- Sentence counter (Mode E) --- */

.sentence-counter {
  font-size: 0.875rem;
  color: var(--color-muted);
  margin-bottom: 0.5rem;
}

/* --- Reveal mode hints --- */

.reveal-hint,
.paste-reveal-hint {
  font-size: 0.875rem;
  color: var(--color-muted);
  margin-top: 0;
  margin-bottom: var(--spacing-xs);
}

/* --- Results screen --- */

.results-heading {
  margin-top: 0;
  margin-bottom: var(--spacing-md);
}

/* Profile summary block */
.results-summary {
  background: #f8fafc;
  border: 1px solid var(--color-border);
  border-radius: 0.5rem;
  padding: var(--spacing-md);
  margin-bottom: var(--spacing-md);
}

.profile-name {
  font-size: 1.125rem;
  font-weight: 700;
  margin-top: 0;
  margin-bottom: var(--spacing-xs);
  color: var(--color-text);
}

.profile-description {
  margin-top: 0;
  margin-bottom: var(--spacing-xs);
  line-height: 1.6;
}

.profile-evidence-note {
  margin: 0;
  font-size: 0.875rem;
  color: var(--color-muted);
  font-style: italic;
  line-height: 1.5;
}

/* Confidence badge */
.confidence-wrapper {
  margin-bottom: var(--spacing-md);
  font-size: 0.9rem;
}

.confidence-badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 9999px;
  font-weight: 700;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  vertical-align: middle;
}

.confidence-high {
  background: #dcfce7;
  color: #15803d;
}

.confidence-moderate {
  background: #fef9c3;
  color: #92400e;
}

.confidence-low {
  background: #f3f4f6;
  color: #374151;
}

.confidence-reason {
  margin-top: 0.5rem;
  margin-bottom: 0;
  font-size: 0.875rem;
  color: var(--color-muted);
  line-height: 1.5;
}

/* Bar chart */
.chart-section {
  margin-bottom: var(--spacing-md);
}

.chart-section h3 {
  margin-top: 0;
  margin-bottom: var(--spacing-xs);
  font-size: 1rem;
  font-weight: 700;
}

.chart-note {
  font-size: 0.8rem;
  color: var(--color-muted);
  margin-top: 0;
  margin-bottom: var(--spacing-sm);
  line-height: 1.4;
}

.bar-chart {
  width: 100%;
  margin: 0.5rem 0;
}

.bar-row {
  display: flex;
  align-items: center;
  margin-bottom: 0.5rem;
}

.bar-label {
  width: 160px;
  font-size: 0.875rem;
  flex-shrink: 0;
  color: var(--color-text);
}

.bar-track {
  flex: 1;
  background: #f1f5f9;
  border-radius: 4px;
  overflow: hidden;
  height: 28px;
}

.bar-fill {
  height: 28px;
  border-radius: 4px;
  transition: width 0.3s ease;
  display: flex;
  align-items: center;
  padding-left: 0.5rem;
  font-size: 0.8rem;
  font-weight: 700;
  color: #fff;
  min-width: 30px;
  box-sizing: border-box;
}

.bar-fill.beneficial { background: #22c55e; }
.bar-fill.neutral    { background: #94a3b8; }
.bar-fill.baseline   { background: #3b82f6; }

/* Null result box */
.null-result {
  background: #f8fafc;
  border: 1px solid var(--color-border);
  border-left: 4px solid #94a3b8;
  border-radius: 0.5rem;
  padding: var(--spacing-md);
  margin-bottom: var(--spacing-md);
}

.null-result-heading {
  font-size: 1rem;
  font-weight: 700;
  margin-top: 0;
  margin-bottom: var(--spacing-xs);
  color: var(--color-text);
}

.null-result p {
  margin-top: 0;
  margin-bottom: var(--spacing-xs);
  line-height: 1.6;
}

.null-result h4 {
  font-size: 0.9rem;
  font-weight: 700;
  margin-top: var(--spacing-sm);
  margin-bottom: var(--spacing-xs);
}

.null-result ul {
  margin: 0;
  padding-left: 1.5rem;
}

.null-result li {
  margin-bottom: 0.4rem;
  line-height: 1.5;
  font-size: 0.9rem;
}

/* --- Paste box ("Try It Now") --- */

.paste-box-section { margin-top: 2rem; }
.paste-box-heading { margin-bottom: 0.5rem; }
.paste-box-instruction { color: var(--color-muted); margin-bottom: 1rem; }

.mode-toggles { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1rem; }
.mode-toggle {
  padding: 0.4rem 1rem;
  border: 2px solid var(--color-border);
  border-radius: 2rem;
  background: transparent;
  cursor: pointer;
  font-size: 0.875rem;
  font-family: inherit;
  line-height: 1.4;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.mode-toggle:hover {
  border-color: var(--color-primary);
}
.mode-toggle.active {
  border-color: var(--color-primary);
  background: var(--color-primary);
  color: #fff;
}
.mode-toggle:focus-visible {
  outline: 3px solid var(--color-primary);
  outline-offset: 2px;
}

.paste-input {
  width: 100%;
  min-height: 120px;
  padding: 1rem;
  border: 1px solid var(--color-border);
  border-radius: 0.5rem;
  font-family: inherit;
  font-size: 1rem;
  resize: vertical;
  margin-bottom: 1rem;
  line-height: 1.6;
  color: var(--color-text);
  background: #fff;
}
.paste-input:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: 1px;
}

.paste-output {
  min-height: 60px;
  padding: 1rem;
  border: 1px dashed var(--color-border);
  border-radius: 0.5rem;
}
.paste-output:empty::before {
  content: 'Your text will appear here\2026';
  color: var(--color-muted);
  font-style: italic;
}

/* Results action buttons */
.results-actions {
  display: flex;
  gap: var(--spacing-sm);
  flex-wrap: wrap;
  margin-top: var(--spacing-lg);
  padding-top: var(--spacing-md);
  border-top: 1px solid var(--color-border);
}

/* --- Clinical report --- */

.report-header {
  margin-bottom: var(--spacing-md);
  padding-bottom: var(--spacing-sm);
  border-bottom: 2px solid var(--color-border);
}

.report-title {
  font-size: 1.375rem;
  font-weight: 700;
  margin-top: 0;
  margin-bottom: var(--spacing-xs);
  line-height: 1.3;
}

.report-meta {
  margin-top: 0;
}

.report-meta-line {
  margin: 0.2rem 0;
  font-size: 0.875rem;
  color: var(--color-muted);
}

/* Disclaimer box */
.report-disclaimer {
  background: var(--color-disclaimer-bg);
  border: 2px solid var(--color-disclaimer-border);
  border-radius: 0.5rem;
  padding: var(--spacing-md);
  margin-bottom: var(--spacing-md);
}

.report-disclaimer-heading {
  font-size: 0.9rem;
  font-weight: 700;
  margin-top: 0;
  margin-bottom: var(--spacing-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #92400e;
}

.report-limitation-list {
  margin: 0;
  padding-left: 1.5rem;
  color: #78350f;
}

.report-limitation-list li {
  margin-bottom: 0.4rem;
  line-height: 1.5;
  font-size: 0.9rem;
}

.report-limitation-list li:last-child {
  margin-bottom: 0;
}

/* Report sections */
.report-section {
  margin-bottom: var(--spacing-md);
  break-inside: avoid;
}

.report-section h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-top: 0;
  margin-bottom: var(--spacing-xs);
  padding-bottom: 0.25rem;
  border-bottom: 1px solid var(--color-border);
}

/* Report tables */
.report-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  margin-top: 0.5rem;
}

.report-table th,
.report-table td {
  padding: 0.5rem 0.75rem;
  text-align: left;
  border: 1px solid var(--color-border);
  line-height: 1.4;
}

.report-table th {
  background: #f8fafc;
  font-weight: 700;
  color: var(--color-text);
}

.report-table tr:nth-child(even) td {
  background: #f8fafc;
}

.cell-yes { color: #15803d; font-weight: 700; }
.cell-no  { color: var(--color-muted); }

/* Evidence strength badges */
.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 1rem;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-strong      { background: #dcfce7; color: #166534; }
.badge-exploratory { background: #fef9c3; color: #854d0e; }
.badge-contested   { background: #ffedd5; color: #9a3412; }

/* Anchor note */
.anchor-note {
  margin-top: 0.75rem;
  font-size: 0.875rem;
  color: var(--color-muted);
  line-height: 1.5;
}

/* Clinical profile name */
.clinical-profile-name {
  font-weight: 700;
  font-size: 1.1rem;
  margin-top: 0;
  margin-bottom: var(--spacing-xs);
}

/* Confidence wrapper (clinical) */
.clinical-confidence {
  margin-top: var(--spacing-sm);
  font-size: 0.9rem;
}

/* Recommendations */
.rec-caution {
  font-style: italic;
  color: var(--color-muted);
  font-size: 0.9rem;
  margin-top: var(--spacing-xs);
}

.rec-tinted {
  font-size: 0.9rem;
  margin-top: var(--spacing-xs);
  padding-left: 0.75rem;
  border-left: 3px solid var(--color-disclaimer-border);
}

/* Citation list */
.citation-list {
  margin: 0;
  padding-left: 1.5rem;
}

.citation-item {
  margin-bottom: 1rem;
  line-height: 1.5;
}

.citation-item:last-child {
  margin-bottom: 0;
}

.citation-meta {
  margin: 0 0 0.25rem 0;
  font-size: 0.875rem;
}

.citation-summary {
  margin: 0.25rem 0 0 0;
  font-size: 0.8rem;
  color: var(--color-muted);
  font-style: italic;
  line-height: 1.5;
}

.no-citations {
  font-size: 0.875rem;
  color: var(--color-muted);
  font-style: italic;
  margin: 0;
}

/* Print / back row */
.report-print-row,
.report-back-row {
  display: flex;
  gap: var(--spacing-sm);
  margin-top: var(--spacing-sm);
  flex-wrap: wrap;
}

/* Anchor confirm note */
.anchor-confirm-note {
  margin-top: 0;
  margin-bottom: var(--spacing-sm);
  color: var(--color-muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

/* Export fallback overlay */
.export-fallback-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.export-fallback-box {
  background: #fff;
  border-radius: 0.5rem;
  padding: var(--spacing-md);
  max-width: 560px;
  width: 100%;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.18);
}

.export-fallback-box h3 {
  margin-top: 0;
  margin-bottom: var(--spacing-xs);
}

.export-fallback-textarea {
  width: 100%;
  font-family: monospace;
  font-size: 0.8rem;
  border: 1px solid var(--color-border);
  border-radius: 0.375rem;
  padding: 0.75rem;
  resize: vertical;
  margin-top: var(--spacing-xs);
  margin-bottom: var(--spacing-sm);
  line-height: 1.5;
  background: #f8fafc;
  color: var(--color-text);
}

.export-fallback-btns {
  display: flex;
  gap: var(--spacing-xs);
  flex-wrap: wrap;
}

/* --- Responsive layout (768–900px tablet range) --- */

@media (max-width: 900px) {
  body {
    padding: 1rem;
  }

  /* Bar chart: narrower label so bars have more room */
  .bar-label {
    width: 120px;
    font-size: 0.8rem;
  }

  /* Paste box: stack textarea and output vertically (they already are, but
     ensure the section doesn't overflow on narrow widths) */
  .paste-box-section {
    overflow-x: hidden;
  }

  .paste-input {
    font-size: 0.9rem;
  }

  /* Mode toggles: allow wrapping more aggressively */
  .mode-toggles {
    gap: 0.375rem;
  }

  .mode-toggle {
    font-size: 0.8rem;
    padding: 0.35rem 0.75rem;
  }

  /* Clinical report tables: horizontal scroll on narrow screens */
  .report-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .report-table {
    min-width: 400px;
  }

  /* Welcome buttons: stack on narrow */
  .welcome-buttons {
    flex-direction: column;
  }

  .welcome-buttons .btn {
    width: 100%;
    text-align: center;
  }

  /* Resume buttons: stack on narrow */
  .resume-buttons {
    flex-direction: column;
  }

  .resume-buttons .btn {
    width: 100%;
    text-align: center;
  }

  /* Results action buttons: stack on narrow */
  .results-actions {
    flex-direction: column;
  }

  .results-actions .btn {
    width: 100%;
    text-align: center;
  }

  /* Question options: ensure comfortable tap target */
  .question-option {
    padding: 0.75rem 0.875rem;
  }

  /* Comfort options: same */
  .comfort-option {
    padding: 0.75rem 0.875rem;
  }
}

/* --- Print styles --- */

@media print {
  body { padding: 0; }
  #viewport-gate, .no-print { display: none !important; }
  .badge { border: 1px solid currentColor; }
  .report-section { break-inside: avoid; }
  .report-disclaimer { border: 2px solid #fbbf24; }
  .paste-box-section { display: none !important; }
}
