:root {
  --ink: #17211e;
  --muted: #65716c;
  --forest-950: #102a25;
  --forest-900: #18332d;
  --forest-800: #21443b;
  --forest-700: #2f5b4f;
  --sage: #dce8df;
  --sage-light: #eef4ef;
  --paper: #fbfaf6;
  --paper-deep: #f3f0e7;
  --white: #ffffff;
  --line: #dfe3dd;
  --line-dark: #c9d0ca;
  --amber: #bf762d;
  --amber-light: #fff0d9;
  --coral: #c85f4a;
  --coral-light: #fde8e2;
  --blue: #3c7181;
  --blue-light: #e1f0f3;
  --shadow-sm: 0 1px 2px rgba(22, 38, 33, .05), 0 4px 16px rgba(22, 38, 33, .04);
  --shadow-md: 0 16px 50px rgba(22, 38, 33, .11);
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --font-ui: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-text: "Noto Serif", "Source Serif 4", "Palatino Linotype", Palatino, Georgia, serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 9% 5%, rgba(193, 214, 197, .42), transparent 28rem),
    linear-gradient(180deg, #f8f7f2 0, #fbfaf6 36rem, #f7f6f1 100%);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; }
button, select, input[type="range"] { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid rgba(60, 113, 129, .25);
  outline-offset: 2px;
}

.app-header {
  min-height: 76px;
  padding: 0 5vw;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  color: var(--white);
  background: var(--forest-900);
  border-bottom: 1px solid rgba(255,255,255,.09);
}

.minimal-header { min-height: 64px; }

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255,255,255,.25);
  border-radius: 12px;
  background: rgba(255,255,255,.08);
  color: #d9eadc;
  font-family: var(--font-text);
  font-size: 22px;
}

.brand strong, .brand small { display: block; }
.brand strong { letter-spacing: .01em; font-size: 15px; }
.brand small { margin-top: 2px; color: rgba(255,255,255,.62); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; }

.header-actions { display: flex; align-items: center; gap: 16px; }

.privacy-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: rgba(255,255,255,.7);
  font-size: 12px;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #78c99a;
  box-shadow: 0 0 0 4px rgba(120,201,154,.11);
}

main { min-height: 100vh; }

.hero {
  width: min(1180px, 90vw);
  margin: 0 auto;
  padding: 72px 0 52px;
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, .65fr);
  gap: 72px;
  align-items: end;
}

.eyebrow {
  margin: 0 0 14px;
  color: var(--forest-700);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .17em;
}

.hero h1 {
  max-width: 760px;
  margin: 0;
  font-family: var(--font-text);
  font-size: clamp(42px, 5.4vw, 72px);
  font-weight: 520;
  line-height: 1.02;
  letter-spacing: -.045em;
}

.hero h1 em { color: var(--amber); font-weight: 430; }

.hero-copy {
  max-width: 710px;
  margin: 25px 0 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.72;
}

.hero-note {
  padding: 24px;
  display: flex;
  gap: 16px;
  background: rgba(255,255,255,.55);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.hero-note-icon {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  color: var(--forest-700);
  background: var(--sage);
  border-radius: 10px;
  font-size: 22px;
}

.hero-note strong { display: block; margin: 1px 0 7px; font-size: 14px; }
.hero-note p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.55; }

.workspace {
  width: min(1180px, 90vw);
  margin: 0 auto 88px;
  padding: 26px;
  background: rgba(255,255,255,.82);
  border: 1px solid rgba(207, 215, 208, .9);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(12px);
}

.compare-workspace {
  width: min(1100px, 92vw);
  margin-top: 28px;
  padding: 22px;
}

.setup-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.setup-header h1 {
  margin: 0;
  font-family: var(--font-text);
  font-size: clamp(28px, 4vw, 42px);
  font-weight: 540;
  letter-spacing: -.03em;
}

.setup-header p:not(.eyebrow) {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.setup-note {
  max-width: 260px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.5;
  text-align: right;
}

.source-selectors {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.source-selector {
  min-width: 0;
  padding: 16px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.selector-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 13px;
}

.selector-head strong { font-size: 13px; }

.selector-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr)) auto;
  gap: 9px;
  align-items: end;
}

.selector-controls .select-control { min-width: 0; }
.selector-controls.custom-only { grid-template-columns: 1fr; }
.selector-controls select { width: 100%; min-width: 0; }

.custom-upload {
  min-width: 94px;
  height: 38px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--forest-700);
  background: var(--white);
  border: 1px solid var(--line-dark);
  border-radius: 9px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.custom-upload:hover { background: var(--sage-light); border-color: var(--forest-700); }
.custom-upload input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

.selector-hint {
  margin-top: 10px;
  color: var(--amber);
  font-size: 10px;
  line-height: 1.45;
}

.source-status {
  min-height: 18px;
  margin-top: 12px;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-status.ready { color: var(--forest-700); font-weight: 700; }
.compare-action { display: flex; justify-content: center; margin-top: 18px; }


.source-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: stretch;
}

.source-card {
  min-width: 0;
  padding: 20px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  transition: border-color .2s, box-shadow .2s, background .2s;
}

.source-card.dragging {
  border-color: var(--forest-700);
  background: var(--sage-light);
  box-shadow: 0 0 0 4px rgba(47,91,79,.08);
}

.source-card-head {
  min-height: 42px;
  margin-bottom: 14px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.step-label {
  display: block;
  margin-bottom: 4px;
  color: var(--amber);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .14em;
}

.source-card h2 { margin: 0; font-family: var(--font-text); font-size: 20px; font-weight: 580; }

.icon-button {
  width: 32px;
  height: 32px;
  padding: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 8px;
  font-size: 23px;
  line-height: 1;
}

.icon-button:hover { color: var(--coral); background: var(--coral-light); }

.drop-zone {
  min-height: 150px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 1.5px dashed var(--line-dark);
  border-radius: 13px;
  background: rgba(255,255,255,.55);
  cursor: pointer;
  transition: border-color .2s, background .2s, transform .2s;
}

.drop-zone:hover, .drop-zone.dragging { border-color: var(--forest-700); background: var(--sage-light); transform: translateY(-1px); }
.drop-zone input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.drop-zone strong { margin-top: 10px; font-size: 14px; }
.drop-zone > span:last-child { margin-top: 4px; color: var(--muted); font-size: 12px; }

.upload-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  color: var(--forest-700);
  background: var(--sage);
  border-radius: 50%;
  font-size: 19px;
  font-weight: 600;
}

.edition-picker {
  padding: 15px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.edition-picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.edition-picker-head strong { font-size: 13px; }
.edition-picker-head span { color: var(--muted); font-size: 10px; text-align: right; }
.edition-picker-grid { margin-top: 13px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.edition-picker .select-control { min-width: 0; }
.edition-picker select { width: 100%; min-width: 0; }
.edition-picker p { margin: 12px 0 0; color: var(--muted); font-size: 10px; line-height: 1.5; }
.edition-picker code { color: var(--forest-700); font-family: var(--font-ui); font-weight: 800; }

.file-summary {
  min-height: 82px;
  padding: 14px;
  display: grid;
  grid-template-columns: 42px minmax(0,1fr) auto;
  gap: 12px;
  align-items: center;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.file-icon {
  width: 42px;
  height: 48px;
  display: grid;
  place-items: center;
  color: var(--blue);
  background: var(--blue-light);
  border-radius: 9px;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .05em;
}

.file-icon.manuscript { color: var(--amber); background: var(--amber-light); }
.file-copy { min-width: 0; }
.file-copy strong, .file-copy span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-copy strong { font-size: 13px; }
.file-copy span { margin-top: 5px; color: var(--muted); font-size: 11px; }

.detect-badge {
  padding: 5px 8px;
  color: var(--forest-700);
  background: var(--sage-light);
  border-radius: 20px;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.source-actions { margin-top: 12px; display: flex; justify-content: space-between; align-items: center; gap: 12px; color: var(--muted); font-size: 11px; }

.text-button {
  padding: 0;
  color: var(--forest-700);
  background: transparent;
  border: 0;
  font-size: 12px;
  font-weight: 700;
  text-decoration: underline;
  text-decoration-color: rgba(47,91,79,.28);
  text-underline-offset: 3px;
}

.options-bar {
  margin-top: 20px;
  padding-top: 20px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
  border-top: 1px solid var(--line);
}

.option-group { display: flex; align-items: flex-end; gap: 20px; }
.select-control, .range-control { display: flex; flex-direction: column; gap: 7px; }
.select-control > span, .range-control > span { color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.range-control output { color: var(--forest-700); font-variant-numeric: tabular-nums; }

select {
  min-width: 132px;
  height: 38px;
  padding: 0 34px 0 12px;
  color: var(--ink);
  background: var(--white);
  border: 1px solid var(--line-dark);
  border-radius: 9px;
  font-size: 12px;
}

input[type="range"] {
  width: 150px;
  height: 18px;
  accent-color: var(--forest-700);
}

.button {
  min-height: 42px;
  padding: 0 17px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
  transition: transform .16s, box-shadow .16s, background .16s, border-color .16s;
}

.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:disabled { cursor: not-allowed; opacity: .42; }
.button-primary { color: var(--white); background: var(--forest-800); box-shadow: 0 6px 18px rgba(24,51,45,.16); }
.button-primary:hover:not(:disabled) { background: var(--forest-950); }
.button-secondary { color: var(--forest-800); background: var(--white); border-color: var(--line-dark); }
.button-ghost { min-height: 36px; color: rgba(255,255,255,.84); background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.16); }
.button-arrow { font-size: 18px; line-height: 0; }
.compare-button { min-width: 178px; min-height: 48px; }

.progress-panel { margin-top: 20px; padding: 15px 17px; background: var(--sage-light); border: 1px solid #d2e0d4; border-radius: 12px; }
.progress-copy { display: flex; align-items: center; gap: 12px; }
.progress-copy strong, .progress-copy span { display: block; }
.progress-copy strong { font-size: 12px; }
.progress-copy div span { margin-top: 2px; color: var(--muted); font-size: 11px; }
.spinner { width: 24px; height: 24px; border: 2px solid #bdd0c1; border-top-color: var(--forest-700); border-radius: 50%; animation: spin .8s linear infinite; }
.progress-track { height: 4px; margin-top: 13px; overflow: hidden; background: #d8e3da; border-radius: 10px; }
.progress-track span { display: block; width: 0; height: 100%; background: var(--forest-700); border-radius: inherit; transition: width .2s; }
@keyframes spin { to { transform: rotate(360deg); } }

.results { padding: 12px 0 90px; }
.results-toolbar { width: min(1280px, 92vw); margin: 0 auto 20px; display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; }
.results-toolbar h2 { margin: 0; font-family: var(--font-text); font-size: 32px; font-weight: 560; letter-spacing: -.02em; }
.result-actions { display: flex; gap: 9px; }

.stats-grid {
  width: min(1280px, 92vw);
  margin: 0 auto 16px;
  display: grid;
  grid-template-columns: repeat(5, minmax(0,1fr));
  overflow: hidden;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
}

.stat { padding: 15px 18px; border-right: 1px solid var(--line); }
.stat:last-child { border-right: 0; }
.stat span, .stat strong { display: block; }
.stat span { color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.stat strong { margin-top: 5px; font-family: var(--font-text); font-size: 23px; font-weight: 600; }
.stat strong.good { color: var(--forest-700); }
.stat strong.warn { color: var(--coral); }

.reader-shell { width: min(1280px, 92vw); margin: 0 auto; overflow: hidden; background: var(--white); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-md); }
.reader-topbar { min-height: 66px; padding: 11px 14px; display: flex; align-items: center; justify-content: space-between; gap: 14px; background: var(--paper); border-bottom: 1px solid var(--line); }
.segmented-control { padding: 3px; display: flex; background: var(--paper-deep); border: 1px solid var(--line); border-radius: 9px; }
.segmented-control button { min-height: 32px; padding: 0 13px; color: var(--muted); background: transparent; border: 0; border-radius: 6px; font-size: 11px; font-weight: 700; }
.segmented-control button.active { color: var(--forest-800); background: var(--white); box-shadow: 0 1px 4px rgba(20,35,30,.1); }
.reader-tools { display: flex; align-items: center; gap: 10px; }

.search-control { width: 220px; height: 38px; padding: 0 8px 0 11px; display: flex; align-items: center; gap: 7px; background: var(--white); border: 1px solid var(--line-dark); border-radius: 9px; }
.search-control > span { color: var(--muted); font-size: 18px; }
.search-control input { min-width: 0; width: 100%; color: var(--ink); background: transparent; border: 0; outline: 0; font-size: 11px; }
.search-control kbd { padding: 2px 5px; color: var(--muted); background: var(--paper-deep); border: 1px solid var(--line); border-radius: 4px; font-family: inherit; font-size: 8px; }

.diff-nav { height: 38px; display: flex; align-items: center; overflow: hidden; background: var(--white); border: 1px solid var(--line-dark); border-radius: 9px; }
.diff-nav button { width: 34px; height: 100%; color: var(--forest-700); background: transparent; border: 0; }
.diff-nav button:hover { background: var(--sage-light); }
.diff-nav span { min-width: 52px; color: var(--muted); text-align: center; font-size: 10px; font-variant-numeric: tabular-nums; }
.font-control { height: 38px; padding: 0 9px; display: flex; align-items: center; gap: 7px; background: var(--white); border: 1px solid var(--line-dark); border-radius: 9px; }
.font-control span { color: var(--forest-700); font-family: var(--font-text); font-size: 12px; font-weight: 700; }
.font-control input { width: 78px; }

.column-headings { display: grid; grid-template-columns: 1fr 1fr; background: var(--forest-900); color: var(--white); }
.column-headings > div { min-width: 0; padding: 11px 18px; display: flex; align-items: center; gap: 10px; border-right: 1px solid rgba(255,255,255,.14); }
.column-headings > div:last-child { border-right: 0; }
.column-headings span { width: 21px; height: 21px; display: grid; place-items: center; color: var(--forest-900); background: #dce8df; border-radius: 5px; font-size: 9px; font-weight: 900; }
.column-headings strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; letter-spacing: .02em; }

.comparison { height: min(68vh, 790px); min-height: 480px; display: grid; grid-template-columns: 1fr 1fr; overflow: auto; overscroll-behavior: contain; background: #f7f6f2; }
.text-pane { min-width: 0; padding: 0 0 45vh; color: #252b28; border-right: 1px solid var(--line-dark); font-family: var(--font-text); font-size: 20px; line-height: 1.92; }
.text-pane:last-child { border-right: 0; }
.comparison { display: block; }
.comparison-rows { min-width: 0; font-size: 20px; }
.compare-segment { display: grid; grid-template-columns: 1fr 1fr; padding: 0; }
.compare-cell { position: relative; min-width: 0; padding: 0 120px 0 18px; font-size: inherit; }
.compare-cell + .compare-cell { border-left: 1px solid var(--line-dark); }
.compare-segment { position: relative; min-height: 1.92em; padding: 0 120px 0 18px; }
.comparison.large-results .compare-segment { content-visibility: auto; contain-intrinsic-size: 48px; }
.compare-segment + .compare-segment { border-top: 1px solid rgba(213,218,213,.45); }
.comparison.only-differences .compare-segment.is-match { display: none; }
.compare-segment.is-current { background: rgba(255,240,217,.42); box-shadow: inset 3px 0 var(--amber); }
.compare-segment.is-match { opacity: .94; }
.compare-segment.is-changed, .compare-segment.is-only { background: rgba(255,247,238,.76); }
.text-pane .word { display: inline; margin-right: .28em; }
.text-pane mark.word { margin-right: .18em; padding: .06em .17em .09em; color: #5d241a; background: #ffd6c9; border-bottom: 1px solid #df8a75; border-radius: 3px; cursor: help; }
.text-pane .char-token { display: inline; }
.text-pane mark.char-token { padding: .05em .08em .07em; color: #5d241a; background: #ffd6c9; border-bottom: 1px solid #df8a75; border-radius: 3px; cursor: help; }
.text-pane mark.char-token.only-char { color: #643c11; background: #ffe1ad; border-color: #d99a3e; }
.word-group { display: inline-block; margin: .04em .18em .04em 0; }
.word-group.changed-group { display: inline-block; margin: .04em .18em .04em 0; }
.text-pane mark.word.only { color: #643c11; background: #ffe1ad; border-color: #d99a3e; }
.text-pane mark.word.search-hit { color: #173d54; background: #cceaf5; box-shadow: 0 0 0 2px #cceaf5; }
.placeholder { padding: 0 .08em; color: #b26a57; opacity: .45; }
.page-marker { position: absolute; top: 5px; right: 12px; padding: 2px 6px; color: var(--forest-700); background: var(--sage); border: 1px solid #c8d9ca; border-radius: 10px; font-family: var(--font-ui); font-size: 8px; font-weight: 800; letter-spacing: .03em; line-height: 1.4; }
.page-marker strong { font-size: 10px; }
.alignment-empty { margin: 120px auto; max-width: 360px; color: var(--muted); text-align: center; font-family: var(--font-ui); font-size: 12px; line-height: 1.6; }

.reader-footer { min-height: 52px; padding: 11px 16px; display: flex; align-items: center; justify-content: space-between; gap: 20px; color: var(--muted); background: var(--paper); border-top: 1px solid var(--line); font-size: 10px; }
.legend { display: flex; align-items: center; gap: 16px; }
.legend span { display: flex; align-items: center; gap: 6px; }
.legend-swatch { width: 12px; height: 12px; display: inline-block; border-radius: 3px; }
.legend-swatch.match { background: #f4f3ed; border: 1px solid #d9dcd5; }
.legend-swatch.changed { background: #ffd6c9; border: 1px solid #df8a75; }
.legend-swatch.only { background: #ffe1ad; border: 1px solid #d99a3e; }
.reader-footer p { margin: 0; text-align: right; }

.toast-region { position: fixed; right: 22px; bottom: 22px; z-index: 50; display: grid; gap: 9px; pointer-events: none; }
.toast { max-width: 380px; padding: 12px 15px; color: var(--white); background: var(--forest-950); border: 1px solid rgba(255,255,255,.12); border-radius: 10px; box-shadow: 0 10px 35px rgba(14,30,26,.25); font-size: 12px; line-height: 1.45; animation: toast-in .22s ease-out; }
.toast.error { background: #7b332a; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

dialog { width: min(660px, 90vw); padding: 0; color: var(--ink); background: var(--paper); border: 1px solid var(--line); border-radius: 20px; box-shadow: 0 30px 90px rgba(16,42,37,.28); }
dialog::backdrop { background: rgba(12,30,26,.58); backdrop-filter: blur(3px); }
dialog form { position: relative; padding: 32px; }
dialog h2 { margin: 0 0 15px; font-family: var(--font-text); font-size: 29px; font-weight: 560; }
dialog p { color: var(--muted); font-size: 13px; line-height: 1.7; }
dialog a { color: var(--forest-700); }
.dialog-close { position: absolute; top: 14px; right: 16px; width: 34px; height: 34px; color: var(--muted); background: var(--paper-deep); border: 0; border-radius: 50%; font-size: 22px; }
.method-grid { margin: 25px 0; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.method-grid div { padding: 15px; background: var(--white); border: 1px solid var(--line); border-radius: 11px; }
.method-grid span { color: var(--amber); font-size: 9px; font-weight: 900; }
.method-grid strong { display: block; margin: 5px 0; font-size: 13px; }
.method-grid p { margin: 0; font-size: 11px; line-height: 1.55; }
.dialog-action { width: 100%; }

footer { min-height: 110px; padding: 26px 5vw; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 20px; color: rgba(255,255,255,.68); background: var(--forest-950); font-size: 11px; }
footer > div strong, footer > div span { display: block; }
footer > div strong { color: var(--white); font-size: 13px; }
footer > div span { margin-top: 3px; }
footer .text-button { color: #cfe1d5; justify-self: center; }
footer p { margin: 0; text-align: right; }

@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; gap: 28px; padding-top: 50px; }
  .hero-note { max-width: 520px; }
  .source-grid { grid-template-columns: 1fr; }
  .source-selectors { grid-template-columns: 1fr; }
  .setup-header { align-items: flex-start; flex-direction: column; }
  .setup-note { max-width: none; text-align: left; }
  .options-bar { align-items: stretch; flex-direction: column; }
  .option-group { flex-wrap: wrap; }
  .compare-button { width: 100%; }
  .stats-grid { grid-template-columns: repeat(2,1fr); }
  .stat { border-bottom: 1px solid var(--line); }
  .reader-topbar { align-items: stretch; flex-direction: column; }
  .reader-tools { flex-wrap: wrap; }
  .search-control { flex: 1 1 220px; }
  .comparison { height: 70vh; }
  footer { grid-template-columns: 1fr; text-align: center; }
  footer > div, footer .text-button, footer p { justify-self: center; text-align: center; }
}

@media (max-width: 640px) {
  .app-header { padding: 0 18px; }
  .privacy-pill { display: none; }
  .header-actions .button { padding: 0 10px; font-size: 10px; }
  .hero, .workspace { width: calc(100% - 24px); }
  .hero { padding: 38px 2px 30px; }
  .hero h1 { font-size: 39px; }
  .hero-copy { font-size: 14px; }
  .workspace { padding: 14px; border-radius: 18px; }
  .compare-workspace { margin-top: 14px; }
  .selector-controls { grid-template-columns: 1fr; }
  .custom-upload { width: 100%; }
  .source-card { padding: 15px; }
  .file-summary { grid-template-columns: 38px minmax(0,1fr); }
  .detect-badge { grid-column: 2; justify-self: start; }
  .option-group { display: grid; grid-template-columns: 1fr 1fr; }
  .range-control input { width: 100%; }
  .results-toolbar { width: calc(100% - 24px); align-items: stretch; flex-direction: column; }
  .result-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .result-actions #newComparisonButton { grid-column: 1 / -1; }
  .stats-grid, .reader-shell { width: calc(100% - 24px); }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .stat:last-child { grid-column: 1 / -1; }
  .comparison { display: block; height: auto; min-height: 0; overflow: visible; }
  .compare-segment { grid-template-columns: 1fr; }
  .text-pane { height: 62vh; overflow: auto; border-right: 0; border-bottom: 1px solid var(--line-dark); }
  .compare-cell { height: auto; overflow: visible; border-right: 0; border-bottom: 0; }
  .compare-cell + .compare-cell { border-left: 0; border-top: 1px solid var(--line-dark); }
  .text-pane:last-child { border-bottom: 0; }
  .column-headings { display: none; }
  .reader-footer { align-items: flex-start; flex-direction: column; }
  .reader-footer p { text-align: left; }
  .legend { flex-wrap: wrap; }
  .method-grid { grid-template-columns: 1fr; }
}
