/* Result-first flows: one action area per result, compact settings around it.
   Loaded last; keeps the existing palette (#f6f5f4 surfaces, black primary). */
@media screen {
  /* One disclosure style: chevron on the left, same size and position. */
  .flow-disclosure>summary, .export-inventory details>summary, .row-options>summary {
    display:flex; align-items:center; gap:0; min-height:30px; padding:4px 0; cursor:pointer;
    font-size:13px; line-height:1.4; color:#44443f; list-style:none;
  }
  .flow-disclosure>summary::-webkit-details-marker, .export-inventory details>summary::-webkit-details-marker { display:none; }
  .export-inventory details>summary::after { content:none!important; }
  .options-state { margin-left:10px; color:#6b6b66; font-size:12px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; min-width:0; }
  .options-state:empty { display:none; }

  /* Shared progress: green bar in a neutral track. */
  .import-progress { background:#f6f5f4; border-radius:6px; }
  .progress-side { display:inline-flex; align-items:baseline; gap:12px; flex-shrink:0; }
  .progress-cancel.text-button { margin:0; padding:2px 0; min-height:0; font-size:13px; }
  .progress-slow { margin:8px 0 0; font-size:13px; line-height:1.5; color:#5d5d58; }
  .is-indeterminate .progress-fill { width:28%!important; }
  :focus-visible { outline:2px solid #1a73e8; outline-offset:2px; }

  /* Export all: list first, one action area, settings collapsed. */
  .export-all-flow .export-inventory { padding:14px 16px 10px; }
  .export-all-flow .inventory-heading { display:grid; grid-template-columns:minmax(0,1fr) minmax(240px,auto); align-items:start; gap:12px 20px; padding-bottom:8px; }
  .export-all-flow .inventory-heading h2 { font-size:18px; margin:0 0 2px; }
  .export-all-flow #inventoryRows { display:block; margin:0; }
  .export-all-flow .inventory-row { display:grid; grid-template-columns:minmax(0,1fr) auto; gap:0 16px; align-items:center; padding:6px 0; min-height:40px; border-top:1px solid #e4e2e0; }
  .export-all-flow .inventory-row[hidden] { display:none; }
  .export-all-flow .inventory-row>label { grid-column:1; font-size:14px; font-weight:500; }
  .export-all-flow .inventory-count { color:#6b6b66; font-weight:400; font-size:13px; }
  .export-all-flow .inventory-formats { grid-column:2; grid-row:1; color:#6b6b66; font-size:12px; white-space:nowrap; }
  .export-all-flow .inventory-row>p { display:block; grid-column:1/-1; margin:0; padding-left:23px; color:#6b6b66; font-size:13px; line-height:1.5; }
  .export-all-flow #inventory-pdf>p, .export-all-flow #inventory-images>p, .export-all-flow #inventory-text>p, .export-all-flow #inventory-headings>p,
  .export-all-flow #inventory-tables>p, .export-all-flow #inventory-comments>p, .export-all-flow #inventory-links>p, .export-all-flow #inventory-notes>p { display:none; }
  .export-all-flow #inventory-pdf>p { display:block; }
  .export-all-flow .row-options, .export-all-flow .inventory-row>.inventory-gallery { grid-column:1/-1; margin:0 0 2px 23px; }
  .export-all-flow .row-options[hidden] { display:none; }
  .export-all-flow .row-options>.review-settings, .export-all-flow .row-options>.browser-pdf-placement,
  .export-all-flow .row-options>.browser-pdf-quality { margin:2px 0 8px; padding:10px 12px; background:#fff; border:1px solid #e6e4e1; border-radius:6px; }
  .export-all-flow .row-options>.browser-pdf-placement { display:flex; flex-wrap:wrap; align-items:flex-end; gap:6px 14px; margin-bottom:6px; }
  .export-all-flow .row-options>.browser-pdf-placement[hidden] { display:none; }
  .export-all-flow .row-options .browser-pdf-placement p { margin:0; font-size:12px; color:#6b6b66; flex:1 1 220px; }
  .export-all-flow .row-options>.browser-pdf-quality { display:flex; align-items:center; gap:10px; font-size:13px; color:#44443f; }
  .export-all-flow .browser-pdf-quality select { min-height:34px; font-size:13px; }
  .export-all-flow .row-options .review-settings fieldset { margin:0; padding:0; border:0; }
  .export-all-flow .row-options .review-settings legend { display:none; }
  .export-all-flow .inventory-gallery { margin-top:0; }
  .export-all-flow .inventory-gallery .comment-export, .export-all-flow .inventory-gallery .image-export-heading { display:none; }
  .export-all-flow #inventoryMissing { margin:8px 0 2px; font-size:12px; color:#6b6b66; }
  .export-all-flow .export-info { margin:2px 0 0; }
  .export-all-flow .inventory-note { font-size:12px; color:#6b6b66; margin:4px 0 6px; }

  /* The action area keeps the same place before, during and after. */
  .export-action { display:flex; flex-direction:column; align-items:stretch; gap:6px; min-width:0; }
  .export-action>.button { align-self:flex-end; white-space:nowrap; }
  .export-action #archiveSize { align-self:flex-end; text-align:right; font-size:12px; color:#62646b; }
  .export-action.is-empty #archiveSize { color:#8a4b00; }
  .export-action #archiveStatus { margin:0; font-size:12px; line-height:1.5; color:#42603a; text-align:right; }
  .export-action .import-progress { margin:0; padding:10px 12px; background:#fff; border:1px solid #e6e4e1; min-width:260px; }
  .export-action .archive-results { margin:0; padding:0; border:0; background:none; }
  .export-action .archive-results h3 { margin:0 0 6px; font-size:14px; line-height:1.4; text-align:right; }
  .export-action .archive-files { display:flex; flex-wrap:wrap; justify-content:flex-end; gap:8px; }
  .export-action .archive-file { display:flex; flex-direction:column; align-items:stretch; gap:3px; padding:0; border:0; background:none; min-width:0; }
  .export-action .archive-file>div { display:flex; flex-direction:column; align-items:center; }
  .export-action .archive-file strong { display:none; }
  .export-action .archive-file-meta { font-size:12px; color:#62646b; text-align:center; }
  .export-action .archive-file .button { white-space:nowrap; text-align:center; }

  /* Secondary block for single-format downloads. */
  .individual-downloads { margin:6px 0 0; border-top:1px solid #e4e2e0; padding-top:4px; }
  .individual-help { margin:2px 0 6px; font-size:12px; color:#6b6b66; }
  .individual-group { display:flex; align-items:center; flex-wrap:wrap; gap:6px 12px; padding:5px 0; border-top:1px solid #ecebe8; }
  .individual-group[hidden] { display:none; }
  .individual-name { min-width:180px; font-size:13px; color:#37352f; }
  .individual-group .inventory-actions { display:flex; flex-wrap:wrap; gap:6px; margin:0; padding:0; justify-content:flex-start; max-width:none; }
  .individual-group .format-chip, .individual-group .button { min-height:32px; padding:5px 10px; font-size:12px; }
  .individual-downloads .browser-pdf-hint { margin:0 0 4px; }
  .individual-downloads .browser-pdf-hint>summary { font-size:12px; color:#6b6b66; }
  .individual-downloads .browser-pdf-hint p { margin:2px 0 6px 18px; font-size:12px; line-height:1.55; color:#6b6b66; max-width:90ch; }
  .error-retry { margin-left:8px; vertical-align:baseline; }
}
@media screen and (max-width:700px) {
  .export-all-flow .inventory-heading { grid-template-columns:minmax(0,1fr); }
  .export-action>.button, .export-action #archiveSize, .export-action #archiveStatus, .export-action .archive-results h3 { align-self:stretch; text-align:left; }
  .export-action>.button { width:100%; }
  .export-action .archive-files { justify-content:stretch; }
  .export-action .archive-file { flex:1 1 140px; }
  .export-action .import-progress { min-width:0; }
  .export-all-flow .inventory-formats { font-size:11px; white-space:normal; text-align:right; }
  .individual-name { min-width:0; flex-basis:100%; }
  .options-state { white-space:normal; }
}
@media (prefers-reduced-motion:reduce) { .is-indeterminate .progress-fill { animation:none!important; transform:none!important; } }
@media print {
  .export-inventory, .import-progress, .individual-downloads, .error-retry, .progress-cancel { display:none!important; }
}

/* Comments to Excel: comments only — filters, two downloads, table preview. */
@media screen {
  .comments-excel-flow .export-inventory, .comments-excel-flow .document-preview-details, .comments-excel-flow .browser-pdf-placement,
  .comments-excel-flow .review-settings, .comments-excel-flow #printButton, .comments-excel-flow .preview-label, .comments-excel-flow #document,
  .comments-excel-flow #footerPreview, .comments-excel-flow #noCommentsNote, .comments-excel-flow .document-extras { display:none!important; }
  .comments-excel { margin:0 0 24px; padding:14px 16px; background:#f6f5f4; border-radius:6px; }
  .excel-head { display:flex; justify-content:space-between; align-items:flex-start; flex-wrap:wrap; gap:10px 20px; }
  .excel-head h2 { margin:0 0 2px; font-size:18px; line-height:1.4; }
  .excel-head p { margin:0; font-size:13px; color:#62646b; }
  .excel-head .import-progress { flex-basis:100%; margin:0; background:#fff; border:1px solid #e6e4e1; }
  .excel-actions { display:flex; gap:8px; flex-wrap:wrap; }
  .excel-actions[hidden], .excel-filters[hidden], .excel-preview[hidden] { display:none; }
  .excel-filters { display:flex; flex-wrap:wrap; align-items:flex-end; gap:8px 12px; margin:12px 0 4px; padding-top:10px; border-top:1px solid #e4e2e0; }
  .excel-filters .filter-field { display:flex; flex-direction:column; gap:3px; min-width:140px; font-size:12px; color:#44443f; }
  .excel-filters select, .excel-filters input[type=date], .excel-filters #commentAuthor { min-height:34px; height:34px; font-size:13px; background:#fff; border:1px solid #d7d7db; border-radius:6px; padding:4px 8px; }
  .excel-filters .text-button { min-height:34px; margin:0; font-size:13px; }
  .excel-filters #commentFilterStatus { margin:0 0 8px; font-size:12px; color:#42603a; }
  .excel-filters #commentFilterStatus.filter-error { color:#a02d25; }
  #excelStatus { margin:6px 0 0; font-size:12px; color:#42603a; }
  #excelStatus:empty { display:none; }
  .excel-preview { margin-top:8px; }
  .excel-table-wrap { overflow:auto; max-height:520px; background:#fff; border:1px solid #e6e4e1; border-radius:6px; }
  #excelTable { width:100%; border-collapse:collapse; font-size:13px; line-height:1.45; }
  #excelTable th { position:sticky; top:0; background:#fafaf9; text-align:left; font-weight:600; color:#37352f; }
  #excelTable th, #excelTable td { padding:7px 10px; border-bottom:1px solid #ecebe8; vertical-align:top; }
  #excelTable td:nth-child(6), #excelTable td:nth-child(7) { min-width:200px; }
  .excel-no-match { color:#62646b; text-align:center; }
  .excel-empty { margin:10px 0 0; padding:12px 14px; background:#fff; border:1px solid #e6e4e1; border-radius:6px; font-size:14px; }
  .excel-empty p { margin:4px 0 0; font-size:13px; color:#62646b; }
  .comments-excel .review-export-link { margin:10px 0 0; font-size:13px; }
}
@media screen and (max-width:700px) {
  .excel-actions, .excel-actions .button { width:100%; }
  .excel-filters .filter-field { flex:1 1 140px; min-width:0; }
}
@media print { .comments-excel { display:none!important; } }

/* Images: originals first, OCR as a compact secondary disclosure. */
@media screen {
  .ocr-controls.ocr-secondary { padding:8px 14px; margin:14px 0 6px; }
  .ocr-secondary>summary { font-size:14px; font-weight:500; color:#37352f; }
  .ocr-secondary[open]>summary { margin-bottom:4px; }
  .ocr-secondary .ocr-actions { margin-top:6px; }
  .ocr-secondary .ocr-help { font-size:13px; }
}

/* Home: H1, result switch, intake, example, hint — in that order. */
@media screen {
  .home-page .intro h1 { font-size:clamp(34px,3.6vw,50px); line-height:1.08; margin:0 0 10px; }
  .home-page .intro p { margin-bottom:0; }
  .home-page .intro { margin-bottom:14px; }
  .home-page .export-presets.result-switch { display:block; margin:0 0 14px; padding:0; border:0; }
  .home-page.loaded .export-presets.result-switch { display:block; margin:0 0 16px; }
  .result-switch legend { float:none; margin:0 0 6px; padding:0; font-size:13px; font-weight:600; color:#37352f; }
  .result-switch .preset-list { display:inline-flex; flex-wrap:wrap; gap:2px; padding:3px; background:#f6f5f4; border-radius:8px; }
  .result-switch .preset-option { position:relative; display:inline-flex; margin:0; padding:0; border:0; background:none; cursor:pointer; }
  .result-switch .preset-option input { position:absolute; inset:0; width:100%; height:100%; margin:0; opacity:0; cursor:pointer; }
  .result-switch .preset-option span { display:block; padding:7px 14px; border-radius:6px; font-size:14px; line-height:1.4; font-weight:500; color:#55554f; }
  .result-switch .preset-option:hover span { color:#191919; }
  .result-switch .preset-option input:checked+span { background:#fff; color:#191919; box-shadow:0 0 0 1px #dcdad6; }
  .result-switch .preset-option input:focus-visible+span { outline:2px solid #1a73e8; outline-offset:1px; }
  .result-switch .preset-description { margin:6px 0 0; font-size:13px; line-height:1.5; color:#62646b; }
  .home-page .intake-meta .demo-button { min-height:36px; padding:6px 14px; font-size:14px; margin:0; }
  .home-page .document-size-help { margin:8px 0 0; }
  .home-page .document-size-help>summary { font-size:12px; color:#62646b; }
  .home-page .document-size-help p { margin:2px 0 0 18px; font-size:12px; line-height:1.55; color:#62646b; max-width:80ch; }
  .home-page .intake-grid { margin-top:0; }
}
@media screen and (max-width:700px) {
  .home-page .intro h1 { font-size:clamp(28px,8.2vw,36px); }
  .result-switch .preset-list { display:flex; }
  .result-switch .preset-option { flex:1 1 0; }
  .result-switch .preset-option span { width:100%; text-align:center; padding:8px 6px; font-size:13px; }
}
@media screen {
  .home-page .export-presets.result-switch legend { font-size:15px; margin-bottom:6px; }
  .result-switch .preset-option span { display:flex; align-items:center; justify-content:center; height:100%; }
}
@media screen and (max-width:700px) { .home-page .intro h1 br { display:none; } }
/* Active tool: one indicator (a 2px bar), never a text underline as well.
   Same bar for links and the Images menu; keyboard focus keeps its outline. */
@media screen {
  .topbar .tool-nav a[aria-current="page"], .topbar .tool-nav a[aria-current="page"]:hover, .topbar .tool-nav a[aria-current="page"]:focus-visible { text-decoration:none; box-shadow:0 2px #191919; color:#191919; }
  .topbar .images-navigation.is-current>summary { box-shadow:0 2px #191919; color:#191919; text-decoration:none; }
}
/* One column on narrow screens: passage first, then its comments and changes. */
@media screen and (max-width:800px) {
  #document .doc-row:has(.doc-changes)>.doc-text { grid-row:1!important; }
  #document .doc-row:has(.doc-changes)>.doc-comments { grid-row:2!important; }
  #document .doc-row:has(.doc-changes)>.doc-changes { grid-row:3!important; margin-top:0; }
}
@media screen and (max-width:700px) {
  .export-all-flow .inventory-row>label { flex-wrap:nowrap; align-items:flex-start; gap:8px; }
  .export-all-flow .inventory-row>label input { margin-top:3px; }
  .export-all-flow .inventory-formats { max-width:42vw; }
}

/* Comments to Excel on narrow screens: readable cards instead of a wide table. */
@media screen {
  .excel-cards { display:none; margin:0; padding:0; list-style:none; }
  #excelTable tr.same-passage td { border-top-color:transparent; }
  #excelTable tr.same-passage td:first-child { color:#9a9a94; }
}
@media screen and (max-width:639px) {
  .comments-excel .excel-table-wrap { display:none; }
  .excel-cards { display:flex; flex-direction:column; gap:8px; }
  .excel-card { padding:10px 12px; background:#fff; border:1px solid #e6e4e1; border-radius:6px; font-size:14px; line-height:1.5; overflow-wrap:anywhere; }
  .excel-card-head { display:flex; flex-wrap:wrap; gap:2px 10px; align-items:baseline; margin:0; }
  .excel-card-head span { font-size:12px; color:#62646b; }
  .excel-card blockquote { margin:6px 0; padding:2px 0 2px 10px; border-left:2px solid #d7d5d1; color:#44443f; font-size:13px; }
  .excel-card-text { margin:4px 0 0; }
  .excel-card-text.is-clamped { display:-webkit-box; -webkit-line-clamp:4; -webkit-box-orient:vertical; overflow:hidden; }
  .excel-card-more.text-button { margin:2px 0 0; padding:2px 0; min-height:0; font-size:13px; }
  .excel-card-meta { margin:6px 0 0; font-size:12px; color:#7a7a74; }
  .excel-cards .excel-no-match { padding:10px; text-align:left; }
}

/* Result switch after import on result screens; Images empty state. */
@media screen {
  .result-switch.after-import { display:none; margin:0 0 14px; padding:0; border:0; }
  body.loaded .result-switch.after-import { display:block; }
  .result-switch.after-import legend { font-size:13px; }
  .merge-tool .export-inventory { display:none!important; }
  .merge-export-link { margin:6px 0 0; font-size:13px; }
  .image-recovery-actions { display:flex; flex-wrap:wrap; gap:8px; margin:8px 0 4px; }
  .image-recovery-actions[hidden] { display:none; }
  .session-notice { margin:0 0 12px; padding:10px 12px; background:#f6f5f4; border-radius:6px; font-size:14px; }
  .session-notice[hidden] { display:none; }
}
@media print { .result-switch { display:none!important; } }
@media screen {
  /* Merge shows its own format choice and download, not other tools' exports. */
  .merge-tool .document-extras { display:none!important; }
  .image-recovery-actions>.button { display:inline-flex; align-items:center; justify-content:center; min-height:42px; margin:0; text-decoration:none; }
}

/* Import panel: upload and Google Docs link as one compact block.
   One set of tokens; fields and settings keep the beige control surface. */
:root { --import-panel-bg:#edf4eb; --import-panel-line:#cbd9c7; --import-panel-accent:#2f6b3a; --import-panel-drop:#e1ecdd; --import-field-bg:#f6f5f4; }
@media screen {
  .intake-grid .intake-controls { display:flex; flex-wrap:wrap; align-items:center; column-gap:16px; box-sizing:border-box; padding:24px; background:var(--import-panel-bg); border:1px solid var(--import-panel-line); border-radius:8px; }
  .intake-grid .intake-controls>* { flex:1 1 100%; min-width:0; }
  .intake-grid .intake-controls .upload-panel { gap:24px; padding:0; margin:0; border:0; border-radius:6px; background:transparent; transition:background-color .15s, outline-color .15s; }
  .intake-grid .intake-controls .upload-panel.dragover { border:0; background:var(--import-panel-drop); outline:2px dashed var(--import-panel-accent); outline-offset:8px; }
  .intake-grid .upload-top .file-icon { background:#fff; border-color:var(--import-panel-line); }
  .intake-grid .upload-top h2 { margin-bottom:4px; }
  .drop-hint { display:none; }
  .intake-grid .upload-panel.dragover .upload-top .drop-hint { display:block; margin:0; color:var(--import-panel-accent); font-weight:600; }
  .intake-grid .upload-panel.dragover .upload-top p:not(.drop-hint) { display:none; }
  .intake-grid .intake-controls .google-import { margin:16px 0 0; padding:16px 0 0; border:0; border-top:1px solid var(--import-panel-line); border-radius:0; background:transparent; }
  .intake-grid .google-import>label { margin-bottom:8px; }
  .intake-grid .link-input-row #googleLinks { background:var(--import-field-bg); border-color:#d3d6cf; }
  .intake-grid .link-input-row .button { background:#fff; }
  .intake-grid .google-import #googleStatus { margin:8px 0 0; }
  .intake-grid .google-import #googleStatus.import-error { color:#a02d25; }
  .intake-grid .import-meta { margin-top:8px; align-items:center; flex-wrap:wrap; gap:4px 12px; }
  .intake-grid .import-meta>#googleSetupNotice { margin:0 auto 0 0; }
  .intake-grid .import-meta>.import-help:not([hidden])+#googleSetupNotice, .intake-grid .import-meta>.import-help[hidden]+#googleSetupNotice { margin:0 auto 0 0; }
  .intake-grid .intake-controls .intake-meta { flex:1 1 auto; margin:12px 0 0; gap:8px 20px; }
  .intake-grid .intake-controls>.document-size-help { flex:0 1 auto; margin:12px 0 0; }
  .intake-grid .intake-controls>.document-size-help[open] { flex-basis:100%; }
  .intake-grid .intake-controls>#error { margin:12px 0 0; padding:10px 12px; background:#fff; border:1px solid #e6c3bf; border-radius:6px; color:#8a2a22; font-size:14px; line-height:1.5; }
  .intake-grid .intake-controls>#error[hidden] { display:none; }
  .intake-grid .intake-controls>.import-progress { margin:16px 0 0; background:#fff; border:1px solid var(--import-panel-line); }
  .intake-grid .google-import textarea#googleLinks { background:var(--import-field-bg); }
}
@media screen and (max-width:700px) {
  .intake-grid .intake-controls { padding:16px; }
  .intake-grid .intake-controls .upload-panel { gap:12px; }
  .intake-grid .intake-controls .upload-panel.dragover { outline-offset:4px; }
  .intake-grid .intake-controls .google-import { margin-top:16px; padding-top:16px; }
  .intake-grid .intake-controls .intake-meta { gap:6px 16px; }
}
@media (prefers-reduced-motion:reduce) { .intake-grid .intake-controls .upload-panel { transition:none; } }
/* Where the size guidance wraps under the service row, keep the panel no taller than before. */
@media screen and (max-width:1100px) {
  .intake-grid .intake-controls .intake-meta { margin-top:8px; }
  .intake-grid .intake-controls>.document-size-help { margin-top:2px; }
}
@media screen and (max-width:700px) { .intake-grid .import-meta { margin-top:6px; row-gap:2px; } }
@media screen and (max-width:700px) { .intake-grid .intake-controls .intake-meta { row-gap:2px; } }
