/* ==========================================================================
   ClearForm — Low-Vision & High-Contrast Accessible Stylesheet
   WCAG AAA contrast ratios across all 4 themes + continuous scalable sizing
   ========================================================================== */

:root {
  --base-font: 22px;
  --input-font: 26px;
  --heading-scale: 1.45;
  --radius: 12px;
  --border-w: 3px;
  --focus-w: 4px;
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --sig-font: "Brush Script MT", "Segoe Script", "Lucida Handwriting", Georgia, serif;
}

/* Text Size Scales */
html.size-large {
  --base-font: 22px;
  --input-font: 26px;
}
html.size-xlarge {
  --base-font: 28px;
  --input-font: 32px;
}
html.size-huge {
  --base-font: 34px;
  --input-font: 38px;
}
html.size-massive {
  --base-font: 42px;
  --input-font: 46px;
}

/* Theme 1: Yellow on Black (Classic Low-Vision High Contrast) */
html.theme-yellow-black {
  --bg: #000000;
  --surface: #121212;
  --surface-alt: #1d1d1d;
  --text: #ffe600;
  --text-muted: #ffd000;
  --input-bg: #080808;
  --input-text: #ffffff;
  --input-placeholder: #b8a840;
  --border: #ffe600;
  --border-soft: #998a00;
  --accent: #ffe600;
  --accent-text: #000000;
  --accent-hover: #fff36b;
  --focus: #00e5ff;
  --success: #4ade80;
  --warning-bg: #2a1d00;
  --warning-border: #ffae00;
  --error-bg: #330000;
  --error-border: #ff5555;
  --error-text: #ffb3b3;
  --badge-bg: #2b2600;
}

/* Theme 2: White on Black */
html.theme-white-black {
  --bg: #000000;
  --surface: #111317;
  --surface-alt: #1b1f26;
  --text: #ffffff;
  --text-muted: #d4dce8;
  --input-bg: #060709;
  --input-text: #ffffff;
  --input-placeholder: #9aa7ba;
  --border: #ffffff;
  --border-soft: #738096;
  --accent: #38bdf8;
  --accent-text: #000000;
  --accent-hover: #7dd3fc;
  --focus: #ffe600;
  --success: #4ade80;
  --warning-bg: #261d00;
  --warning-border: #facc15;
  --error-bg: #360707;
  --error-border: #f87171;
  --error-text: #fecaca;
  --badge-bg: #1e293b;
}

/* Theme 3: Black on White (WCAG AAA 7:1+ across all text & feedback) */
html.theme-black-white {
  --bg: #ffffff;
  --surface: #f4f6f9;
  --surface-alt: #e9edf3;
  --text: #000000;
  --text-muted: #1f2937;
  --input-bg: #ffffff;
  --input-text: #000000;
  --input-placeholder: #374151;
  --border: #000000;
  --border-soft: #374151;
  --accent: #00359e;
  --accent-text: #ffffff;
  --accent-hover: #00236b;
  --focus: #9a3412;
  --success: #0b532b;
  --warning-bg: #fff8db;
  --warning-border: #7c2d12;
  --error-bg: #fee2e2;
  --error-border: #991b1b;
  --error-text: #7f1d1d;
  --badge-bg: #dbeafe;
}

/* Theme 4: Low-Glare Warm Cream (WCAG AAA 7:1+ across all text & feedback) */
html.theme-cream {
  --bg: #faf3e0;
  --surface: #f2e7cb;
  --surface-alt: #e8dab6;
  --text: #1a1510;
  --text-muted: #2d241b;
  --input-bg: #fffdf5;
  --input-text: #111111;
  --input-placeholder: #4a3f32;
  --border: #2a2118;
  --border-soft: #544636;
  --accent: #153ba8;
  --accent-text: #ffffff;
  --accent-hover: #0f2c80;
  --focus: #9a3412;
  --success: #0c4d26;
  --warning-bg: #fef0c7;
  --warning-border: #7c2d12;
  --error-bg: #fde2e2;
  --error-border: #991b1b;
  --error-text: #7f1d1d;
  --badge-bg: #e0d3b2;
}

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

html {
  font-size: var(--base-font);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-family);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-wrap: anywhere;
}

/* Unmistakable keyboard focus ring everywhere */
:focus-visible {
  outline: var(--focus-w) solid var(--focus) !important;
  outline-offset: 4px !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.hidden {
  display: none !important;
}

/* Skip Link */
.skip-link {
  position: absolute;
  top: -120px;
  left: 16px;
  z-index: 1000;
  background: var(--accent);
  color: var(--accent-text);
  padding: 16px 24px;
  font-weight: 800;
  border-radius: var(--radius);
  text-decoration: none;
  border: var(--border-w) solid var(--border);
}
.skip-link:focus {
  top: 16px;
}

/* Top Bar */
.top-bar {
  background: var(--surface);
  border-bottom: var(--border-w) solid var(--border);
  padding: 18px 20px;
}

.top-bar-inner {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.brand-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.top-right-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.settings-drawer {
  padding: 18px;
  border-radius: var(--radius);
  background: var(--surface-alt);
  border: 2px solid var(--border);
}

.settings-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.voice-select-group {
  align-items: center;
}

.compact-select {
  min-height: 48px;
  padding: 8px 14px;
  width: 100%;
  min-width: 0;
  max-width: 420px;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 800;
  background: var(--input-bg);
  color: var(--input-text);
  border: 2px solid var(--border);
  border-radius: 10px;
}

.small-helper {
  margin: -6px 0 0;
  font-size: 0.72rem;
}

.zero-margin {
  margin: 0;
}

/* Always-Reachable Fixed Bottom Read-Aloud Playback Dock */
.speech-bar {
  position: fixed;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  width: min(920px, calc(100vw - 24px));
  z-index: 950;
  padding: 12px 18px;
  border-radius: var(--radius);
  background: var(--surface-alt);
  border: 4px solid var(--accent);
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.7);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 14px;
}

body.speech-dock-open {
  padding-bottom: 130px;
}

.speech-status-label {
  font-size: 0.85rem;
  font-weight: 900;
}

.speech-bar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 900;
  font-size: 26px;
  border: var(--border-w) solid var(--border);
  flex-shrink: 0;
}

.brand-title {
  margin: 0;
  font-size: 1.35rem;
  line-height: 1.15;
  font-weight: 900;
}

.brand-subtitle {
  margin: 0;
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 600;
}

.privacy-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--surface-alt);
  border: 2px solid var(--border);
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--text);
  font-family: inherit;
}

.privacy-pill-btn {
  cursor: pointer;
  min-height: 48px;
}

.privacy-pill-btn:hover {
  background: var(--accent);
  color: var(--accent-text);
}

.privacy-pill-btn.is-offline {
  border-color: var(--success);
  border-width: 3px;
}

.privacy-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
}

/* Accessibility Controls */
.a11y-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px 22px;
}

.control-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.control-label {
  font-size: 0.78rem;
  font-weight: 800;
}

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

.seg-btn {
  appearance: none;
  background: var(--input-bg);
  color: var(--text);
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 0.78rem;
  font-weight: 800;
  font-family: inherit;
  cursor: pointer;
  min-height: 48px;
}

.seg-btn:hover {
  background: var(--surface-alt);
}

.seg-btn.active {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--border);
}

/* Step Navigation */
.step-nav {
  max-width: 960px;
  margin: 18px auto 0;
  padding: 0 20px;
}

.step-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.step-item {
  flex: 1 1 180px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 2px solid var(--border-soft);
  font-size: 0.82rem;
  font-weight: 700;
  opacity: 0.75;
}

.step-item.current {
  border: var(--border-w) solid var(--border);
  background: var(--surface-alt);
  opacity: 1;
  font-weight: 900;
}

.step-item.done {
  opacity: 1;
  border-color: var(--border);
}

.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 900;
  flex-shrink: 0;
}

/* Main Container */
.main-container {
  max-width: 960px;
  margin: 22px auto 60px;
  padding: 0 20px;
}

.section-heading {
  margin: 0 0 12px;
  font-size: 1.5rem;
  line-height: 1.25;
  font-weight: 900;
}

.lead-text {
  margin: 0 0 24px;
  font-size: 1rem;
  color: var(--text-muted);
}

.muted-note {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin: 6px 0;
}

/* Cards */
.hero-card,
.doc-header-card,
.key-info-card,
.bottom-save-card,
.page-section-card,
.focus-card {
  background: var(--surface);
  border: var(--border-w) solid var(--border);
  border-radius: var(--radius);
  padding: 26px;
  margin-bottom: 24px;
}

/* Buttons */
.action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 58px;
  padding: 14px 26px;
  border-radius: var(--radius);
  border: var(--border-w) solid var(--border);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 900;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  line-height: 1.2;
}

.action-btn.primary {
  background: var(--accent);
  color: var(--accent-text);
}
.action-btn.primary:hover {
  background: var(--accent-hover);
}

.action-btn.secondary {
  background: var(--input-bg);
  color: var(--text);
}
.action-btn.secondary:hover {
  background: var(--surface-alt);
}

.action-btn.large-cta {
  min-height: 70px;
  padding: 18px 34px;
  font-size: 1.08rem;
}

.action-btn.small-btn {
  min-height: 46px;
  padding: 8px 16px;
  font-size: 0.8rem;
}

.action-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Drop Zone */
.drop-zone {
  border: 4px dashed var(--border);
  border-radius: var(--radius);
  background: var(--input-bg);
  padding: 40px 24px;
  text-align: center;
  margin-bottom: 24px;
  transition: background 0.15s ease;
}

.drop-zone.drag-over {
  background: var(--surface-alt);
  border-style: solid;
}

.drop-zone-title {
  margin: 0 0 8px;
  font-size: 1.35rem;
  font-weight: 900;
}

.drop-zone-sub {
  margin: 0 0 22px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.demo-row {
  border-top: 2px solid var(--border-soft);
  padding-top: 20px;
  margin-top: 20px;
}

.demo-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 10px;
}

.trust-box {
  margin-top: 26px;
  padding: 20px;
  border-radius: var(--radius);
  background: var(--surface-alt);
  border: 2px solid var(--border-soft);
}

.trust-box h3 {
  margin: 0 0 10px;
  font-size: 1.05rem;
}

.clean-list {
  margin: 0;
  padding-left: 26px;
}
.clean-list li {
  margin-bottom: 8px;
}

/* Status & Alerts */
.status-banner,
.error-banner,
.warning-card {
  padding: 18px 22px;
  border-radius: var(--radius);
  margin: 18px 0;
  font-weight: 700;
}

.status-banner {
  background: var(--surface-alt);
  border: var(--border-w) solid var(--border);
}

.error-banner {
  background: var(--error-bg);
  border: var(--border-w) solid var(--error-border);
  color: var(--error-text);
}

.warning-card {
  background: var(--warning-bg);
  border: var(--border-w) solid var(--warning-border);
}

/* Document Header */
.doc-header-top {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 20px;
}

.doc-badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 10px;
}

.badge {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 0.72rem;
  font-weight: 900;
  border: 2px solid var(--border);
}

.secondary-badge {
  background: var(--badge-bg);
  color: var(--text);
}

.office-badge {
  background: var(--warning-bg);
  color: var(--text);
  border-color: var(--warning-border);
}

.doc-header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

/* Mode Toolbar */
.mode-toolbar {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px;
  border-radius: var(--radius);
  background: var(--surface-alt);
  border: 2px solid var(--border-soft);
  margin-bottom: 18px;
}

.mode-bar-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.mode-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.mode-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.mode-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  padding-top: 12px;
  border-top: 2px solid var(--border-soft);
}

.toggle-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 0.82rem;
  font-weight: 800;
  cursor: pointer;
  min-height: 44px;
}

.toggle-chip input[type="checkbox"] {
  width: 28px;
  height: 28px;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}

/* Progress Bar */
.progress-wrap {
  margin-top: 6px;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  font-weight: 800;
  margin-bottom: 8px;
}

.progress-track {
  height: 18px;
  border-radius: 999px;
  background: var(--input-bg);
  border: 2px solid var(--border);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  transition: width 0.2s ease;
}

/* Key Info Panel */
.key-info-summary {
  font-size: 1.08rem;
  font-weight: 900;
  cursor: pointer;
  padding: 4px 0;
  list-style-position: outside;
}

.summary-hint {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-left: 8px;
}

.key-info-body {
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.key-info-group {
  padding: 16px 18px;
  border-radius: var(--radius);
  background: var(--surface-alt);
  border: 2px solid var(--border-soft);
}

.key-info-group h3 {
  margin: 0 0 10px;
  font-size: 0.95rem;
  font-weight: 900;
}

.key-info-list {
  margin: 0;
  padding-left: 24px;
}

.key-info-list li {
  margin-bottom: 8px;
  font-size: 0.88rem;
}

.key-alert {
  padding: 14px 18px;
  border-radius: var(--radius);
  background: var(--warning-bg);
  border: var(--border-w) solid var(--warning-border);
  font-weight: 800;
  font-size: 0.9rem;
}

.page-jump-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* Reading & Form Flow */
.page-banner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding-bottom: 14px;
  margin-bottom: 20px;
  border-bottom: var(--border-w) solid var(--border);
}

.page-banner-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 900;
}

.section-subhead-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: 28px 0 16px;
  padding: 12px 16px;
  border-left: 8px solid var(--accent);
  background: var(--surface-alt);
  border-radius: 0 var(--radius) var(--radius) 0;
}

.section-subhead-row h4 {
  margin: 0;
  font-size: 1.12rem;
  font-weight: 900;
}

.section-subhead {
  margin: 28px 0 16px;
  padding: 12px 16px;
  border-left: 8px solid var(--accent);
  background: var(--surface-alt);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 1.12rem;
  font-weight: 900;
}

.signing-statement-box {
  margin: 12px 0 16px;
  padding: 16px 18px;
  border-radius: var(--radius);
  background: var(--input-bg);
  border: 2px solid var(--accent);
  font-size: 0.92rem;
  line-height: 1.55;
}

.signing-statement-title {
  margin: 0 0 6px;
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.skip-section-banner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  padding: 12px 16px;
  border-radius: var(--radius);
  background: var(--input-bg);
  border: 2px dashed var(--border-soft);
  font-size: 0.85rem;
  font-weight: 800;
}

.field-feedback.feedback-ok {
  color: var(--success);
}

.field-feedback.feedback-warn {
  color: var(--warning-border);
}

.reading-block {
  background: var(--input-bg);
  border: 2px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 20px;
}

.reading-block-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.reading-tag {
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.reading-paragraph {
  margin: 0 0 14px;
  font-size: 1rem;
  line-height: 1.65;
}
.reading-paragraph:last-child {
  margin-bottom: 0;
}

.reading-bullet {
  margin: 0 0 12px;
  padding-left: 24px;
  font-size: 1rem;
  line-height: 1.65;
}

/* Form Field Cards — Big Words, Big Boxes & Active-Field Spotlight for Screen Magnifiers */
.field-card {
  background: var(--surface-alt);
  border: var(--border-w) solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 22px;
  transition: box-shadow 0.15s ease;
}

.field-card:focus-within {
  border-color: var(--focus);
  box-shadow: inset 8px 0 0 var(--focus);
}

.field-card.is-filled {
  border-color: var(--success);
}

.field-card.is-office {
  border-style: dashed;
}

.field-top-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 10px;
}

.field-context {
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--text-muted);
  margin: 0 0 4px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.field-label {
  display: block;
  font-size: 1.18rem;
  font-weight: 900;
  line-height: 1.3;
  margin-bottom: 6px;
}

.field-hint {
  margin: 0 0 12px;
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 600;
}

.big-input,
.big-select,
.big-textarea {
  width: 100%;
  min-height: 68px;
  padding: 16px 20px;
  font-family: inherit;
  font-size: var(--input-font);
  font-weight: 700;
  background: var(--input-bg);
  color: var(--input-text);
  border: var(--border-w) solid var(--border);
  border-radius: var(--radius);
  line-height: 1.35;
}

.big-input::placeholder,
.big-textarea::placeholder {
  color: var(--input-placeholder);
  font-weight: 500;
}

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

.field-tools-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.field-feedback {
  margin-top: 8px;
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--text-muted);
}

/* Big Accessible Checkbox & Radio Options */
.choice-fieldset {
  border: none;
  padding: 0;
  margin: 0;
}

.choice-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 8px;
}

.choice-option {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 68px;
  padding: 14px 20px;
  border-radius: var(--radius);
  background: var(--input-bg);
  border: var(--border-w) solid var(--border);
  font-size: 1.05rem;
  font-weight: 800;
  cursor: pointer;
}

.choice-option:has(input:checked) {
  background: var(--accent);
  color: var(--accent-text);
}

.choice-option:has(input:checked) input {
  accent-color: var(--accent-text);
}

.choice-option input {
  width: 32px;
  height: 32px;
  accent-color: var(--accent);
  flex-shrink: 0;
  cursor: pointer;
}

/* Signature Widget */
.sig-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.sig-preview {
  margin-top: 12px;
  padding: 14px 20px;
  border-radius: var(--radius);
  background: var(--input-bg);
  border: 2px dashed var(--border-soft);
  font-family: var(--sig-font);
  font-size: 1.7rem;
  color: var(--input-text);
  min-height: 68px;
  display: flex;
  align-items: center;
}

.sig-canvas-wrap {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sig-canvas {
  width: 100%;
  height: 180px;
  background: #ffffff;
  border: var(--border-w) solid var(--border);
  border-radius: var(--radius);
  touch-action: none;
  cursor: crosshair;
}

/* One-at-a-Time Focus View */
.focus-nav-top {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.focus-counter {
  font-size: 1.05rem;
  font-weight: 900;
}

.focus-card-host .field-card,
.focus-card-host .reading-block {
  padding: 30px;
  border-width: 4px;
}

.focus-nav-bottom {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 16px;
  margin-top: 20px;
}

.nav-big-btn {
  flex: 1 1 220px;
  min-height: 74px;
  font-size: 1.15rem;
}

.shortcut-hint {
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 14px;
}

/* Bottom Save Card */
.bottom-save-card {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
}

.bottom-save-card h3 {
  margin: 0 0 6px;
  font-size: 1.15rem;
}

.bottom-save-actions,
.save-actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 12px;
}

/* Review All Your Answers List (Step 3) */
.answers-review-section {
  margin-top: 26px;
  padding: 22px;
  border-radius: var(--radius);
  background: var(--surface-alt);
  border: var(--border-w) solid var(--border);
}

.answers-review-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.answers-review-header h3 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 900;
}

.answers-review-list {
  list-style: none;
  padding: 0;
  margin: 14px 0 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.answer-review-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-radius: var(--radius);
  background: var(--input-bg);
  border: 2px solid var(--border-soft);
}

.answer-review-meta {
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
  margin: 0 0 2px;
}

.answer-review-label {
  font-size: 0.88rem;
  font-weight: 800;
  margin: 0 0 4px;
}

.answer-review-value {
  font-size: 1.05rem;
  font-weight: 900;
  color: var(--input-text);
  margin: 0;
  word-break: break-word;
}

.reuse-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
}

/* Preview Section */
.preview-section {
  margin-top: 30px;
  padding-top: 24px;
  border-top: var(--border-w) solid var(--border);
}

.preview-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.preview-controls-stack {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px 20px;
}

.preview-contrast-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.preview-zoom-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 900;
}

.preview-pages-host {
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  overflow-x: auto;
}

.preview-page-frame {
  background: var(--surface-alt);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  overflow-x: auto;
}

.preview-page-label {
  margin: 0 0 10px;
  font-size: 0.85rem;
  font-weight: 900;
}

.preview-page-frame canvas {
  display: block;
  max-width: none;
  height: auto;
  background: #ffffff;
  border: 2px solid #000000;
  transition: filter 0.15s ease;
}

.preview-pages-host.preview-fit-width canvas {
  max-width: 100%;
  width: 100%;
}

/* High-Contrast PDF Preview Modes (visual only; downloaded PDF stays normal paper colors) */
.preview-pages-host.preview-dark canvas {
  filter: invert(1) hue-rotate(180deg) contrast(1.18);
  border-color: var(--border);
}

.preview-pages-host.preview-yellow canvas {
  filter: invert(1) sepia(1) saturate(6) hue-rotate(4deg) contrast(1.32);
  border-color: var(--border);
}

.preview-pages-host.preview-normal canvas {
  filter: none;
}

/* Footer */
.app-footer {
  max-width: 960px;
  margin: 0 auto 48px;
  padding: 20px 20px 0;
  border-top: 2px solid var(--border-soft);
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.footer-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 14px;
}

.trust-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 16px;
}

.support-nudge {
  margin-top: 20px;
  padding: 16px 20px;
  border-radius: var(--radius);
  background: var(--surface-alt);
  border: 2px solid var(--border-soft);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.85rem;
  font-weight: 700;
}

/* Accessible High-Contrast Dialog Modals */
.a11y-dialog {
  width: min(760px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  padding: 28px;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  border: 4px solid var(--border);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.75);
}

.a11y-dialog::backdrop {
  background: rgba(0, 0, 0, 0.82);
}

.dialog-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding-bottom: 14px;
  margin-bottom: 18px;
  border-bottom: var(--border-w) solid var(--border);
}

.dialog-header h2 {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 900;
}

.dialog-body h3 {
  margin: 22px 0 10px;
  font-size: 1.02rem;
  font-weight: 900;
}

.dialog-body p {
  margin: 0 0 14px;
}

.network-status-box {
  padding: 14px 18px;
  border-radius: var(--radius);
  background: var(--input-bg);
  border: var(--border-w) solid var(--border);
  font-weight: 900;
  font-size: 0.9rem;
  margin-bottom: 18px;
}

.network-status-box.is-offline {
  border-color: var(--success);
  color: var(--success);
}

.dialog-link-box {
  margin: 20px 0;
}

.dialog-footer-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 2px solid var(--border-soft);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

@media (forced-colors: active) {
  .privacy-dot {
    border: 3px solid CanvasText;
    forced-color-adjust: none;
    background: Highlight;
  }
  .progress-fill {
    background: Highlight;
    border-right: 2px solid CanvasText;
  }
  .field-card:focus-within {
    outline: 3px solid Highlight;
  }
}

@media (max-width: 640px) {
  .hero-card,
  .doc-header-card,
  .key-info-card,
  .bottom-save-card,
  .page-section-card,
  .field-card,
  .focus-card-host .field-card,
  .focus-card-host .reading-block {
    padding: 16px;
  }
  .speech-bar {
    bottom: 8px;
    padding: 10px 12px;
  }
}

html.size-massive .speech-bar {
  font-size: 22px;
}
