/* Tool-screen styles, shared by the Files, Scanner and Cleaner clients.
 *
 * Moved out of files/ when Scan and Cleaner became pages of their own: all
 * three draw the same dropzones, page grids, buttons and status lines, and
 * three copies would have drifted within a week.
 *
 * Colours come from shared/brand.css. Nothing here defines a colour of its
 * own, so changing the brand is one file.
 */

:root {
  /* Kept as aliases rather than renamed through 20 KB of rules.
   *
   * They point at SEMANTIC tokens, not at the ramp. That distinction is
   * the whole of dark mode here: --pf-green-800 is a fixed dark green,
   * so a button using it stayed dark while its label inverted to
   * near-black on top, measured at 2.51:1. --pf-primary is dark green in
   * light mode and bright green in dark, so the same rule works in both.
   *
   * Found by walking every visible text node and measuring it against
   * the colour actually painted behind it, which is the only way to
   * catch the one label in a corner. */
  --taadom-ink: var(--pf-ink);
  --taadom-forest: var(--pf-primary);
  --taadom-mint: var(--pf-accent);
  --taadom-lime: var(--pf-accent);
  --taadom-coral: var(--pf-danger);
  --taadom-paper: var(--pf-surface);
  --taadom-line: var(--pf-line);
  --taadom-muted: var(--pf-muted);
}


body {
  background: var(--pf-surface);
}

button,
input,
a {
  font: inherit;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.topbar {
  align-items: center;
  background: var(--pf-card);
  border-bottom: 1px solid var(--taadom-line);
  display: flex;
  justify-content: space-between;
  min-height: 76px;
  padding: 16px 24px;
}

.topbar h1,
.panel-head h2,
.result-panel h2 {
  font-size: 24px;
  font-weight: 780;
  letter-spacing: 0;
  line-height: 1.15;
  margin: 0;
}

.eyebrow {
  color: var(--taadom-forest);
  font-size: 12px;
  font-weight: 760;
  letter-spacing: 0.08em;
  margin: 0 0 4px;
  text-transform: uppercase;
}

.top-actions,
.result-actions,
.panel-head,
.mapping-head {
  align-items: center;
  display: flex;
  gap: 10px;
}

.shell {
  display: grid;
  flex: 1;
  grid-template-columns: 240px minmax(0, 1fr);
}

.sidebar {
  background: var(--pf-bar);
  color: var(--pf-on-bar);
  padding: 18px;
}

.nav-tab {
  align-items: center;
  border: 1px solid transparent;
  border-radius: 8px;
  display: flex;
  gap: 10px;
  height: 48px;
  margin-bottom: 8px;
  padding: 0 12px;
  width: 100%;
}

.nav-tab:hover:not(.is-disabled),
.nav-tab.active {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.16);
}

.nav-tab.is-disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.nav-tab-badge {
  background: rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  font-size: 10px;
  letter-spacing: 0.04em;
  margin-left: auto;
  padding: 2px 7px;
  text-transform: uppercase;
}

.nav-tab.active {
  color: var(--taadom-lime);
}

.workspace {
  padding: 24px;
  position: relative;
}

.feature-panel {
  display: none;
}

.feature-panel.active {
  display: block;
}

.panel-head {
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 18px;
}

.panel-caption {
  color: var(--taadom-muted);
  font-size: 14px;
  line-height: 1.45;
  margin: 7px 0 0;
  max-width: 720px;
}

.primary-btn,
.primary-link,
.secondary-btn,
.icon-btn {
  align-items: center;
  border-radius: 8px;
  display: inline-flex;
  gap: 8px;
  justify-content: center;
  min-height: 42px;
  padding: 0 14px;
  text-decoration: none;
}

.primary-btn,
.primary-link {
  background: var(--taadom-forest);
  color: var(--pf-on-primary);
  font-weight: 740;
}

.primary-btn:hover,
.primary-link:hover {
  background: var(--pf-chip);
}

.secondary-btn,
.icon-btn {
  background: var(--pf-card);
  border: 1px solid var(--taadom-line);
  color: var(--taadom-ink);
  font-weight: 700;
}

.small-btn {
  min-height: 34px;
  padding: 0 10px;
}

.dropzone {
  align-items: center;
  background: var(--pf-card);
  border: 1px dashed var(--taadom-mint);
  border-radius: 8px;
  color: var(--taadom-forest);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 10px;
  justify-content: center;
  min-height: 170px;
  padding: 24px;
}

.dropzone.compact {
  min-height: 96px;
}

.dropzone input,
.file-btn input {
  display: none;
}

.file-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.file-row {
  align-items: center;
  background: var(--pf-card);
  border: 1px solid var(--taadom-line);
  border-radius: 8px;
  display: flex;
  justify-content: space-between;
  padding: 12px 14px;
}

.file-row span:last-child {
  color: var(--taadom-muted);
  font-size: 13px;
}

.dropzone-hint {
  color: var(--taadom-muted);
  font-size: 12px;
  font-weight: 500;
}

.list-head {
  align-items: center;
  color: var(--taadom-muted);
  display: flex;
  font-size: 13px;
  font-weight: 600;
  justify-content: space-between;
  padding: 2px 2px 0;
}

.file-row.reorderable {
  gap: 10px;
  justify-content: flex-start;
}

.file-row.reorderable .drag-handle {
  color: var(--taadom-muted);
  cursor: grab;
  flex: 0 0 auto;
  height: 18px;
  width: 18px;
}

.file-row.reorderable .order-badge {
  align-items: center;
  background: var(--pf-primary);
  border-radius: 999px;
  color: var(--pf-on-primary);
  display: inline-flex;
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 700;
  height: 22px;
  justify-content: center;
  min-width: 22px;
  padding: 0 6px;
}

.file-row.reorderable .file-name {
  flex: 1 1 auto;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-row.reorderable .file-size {
  color: var(--taadom-muted);
  flex: 0 0 auto;
  font-size: 13px;
}

.file-row .row-actions {
  display: inline-flex;
  flex: 0 0 auto;
  gap: 4px;
}

.icon-btn.tiny {
  align-items: center;
  border-radius: 6px;
  display: inline-flex;
  height: 30px;
  justify-content: center;
  min-height: 30px;
  padding: 0;
  width: 30px;
}

.icon-btn.tiny:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

.file-row.dragging {
  opacity: 0.5;
}

.file-row.drop-target {
  border-color: var(--taadom-forest, var(--pf-primary));
  box-shadow: inset 0 2px 0 var(--taadom-forest, var(--pf-primary));
}

.loaded-file {
  align-items: center;
  background: var(--pf-card);
  border: 1px solid var(--taadom-line);
  border-radius: 8px;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-top: 12px;
  padding: 10px 14px;
}

.loaded-file .loaded-name {
  align-items: center;
  color: var(--taadom-ink);
  display: inline-flex;
  font-weight: 600;
  gap: 8px;
  overflow: hidden;
}

.loaded-file .loaded-name span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-line {
  color: var(--taadom-muted);
  min-height: 24px;
}

.status-line.error {
  color: var(--pf-danger);
}

.page-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  margin-top: 18px;
}

.page-grid.tight {
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
}

.page-card {
  background: var(--pf-card);
  border: 2px solid transparent;
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(20, 33, 31, 0.08);
  overflow: hidden;
  position: relative;
}

.page-card.selected {
  border-color: var(--taadom-coral);
}

.page-card.mapped,
.page-card.source-picked,
.page-card.replacement-picked {
  border-color: var(--taadom-mint);
}

.page-card img {
  display: block;
  height: auto;
  width: 100%;
}

.page-preview {
  position: relative;
}

.page-label {
  align-items: center;
  background: var(--pf-card);
  border-top: 1px solid var(--taadom-line);
  display: flex;
  font-size: 13px;
  font-weight: 720;
  justify-content: space-between;
  min-height: 36px;
  padding: 0 10px;
}

.editor-toolbar {
  align-items: end;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 8px;
}

.editor-meta {
  align-items: center;
  color: var(--taadom-muted);
  display: flex;
  font-size: 13px;
  min-height: 42px;
}

.document-editor {
  display: grid;
  gap: 22px;
  margin-top: 18px;
}

.office-editor-shell {
  background: var(--pf-card);
  border: 1px solid var(--taadom-line);
  border-radius: 8px;
  height: min(74vh, 860px);
  margin-top: 18px;
  min-height: 560px;
  overflow: hidden;
}

.office-editor-frame {
  height: 100%;
  width: 100%;
}

.feature-unavailable {
  align-items: start;
  background: var(--pf-tint);
  border: 1px solid var(--pf-tint-line);
  border-radius: 12px;
  color: var(--taadom-ink);
  display: grid;
  gap: 14px;
  grid-template-columns: auto 1fr;
  margin: 8px 0;
  padding: 24px;
}

.feature-unavailable strong {
  display: block;
  font-size: 17px;
  margin-bottom: 6px;
}

.feature-unavailable p {
  color: var(--taadom-muted);
  line-height: 1.5;
  margin: 0 0 8px;
  max-width: 62ch;
}

.feature-unavailable p:last-child {
  margin-bottom: 0;
}

.engine-empty {
  align-items: start;
  color: var(--taadom-ink);
  display: grid;
  gap: 10px;
  height: 100%;
  justify-content: center;
  padding: 42px;
}

.engine-empty strong {
  font-size: 18px;
}

.engine-empty span {
  color: var(--taadom-muted);
}

.engine-empty code {
  background: var(--pf-tint);
  border: 1px solid var(--pf-tint-line);
  border-radius: 8px;
  color: var(--taadom-forest);
  display: block;
  line-height: 1.45;
  max-width: 820px;
  overflow-wrap: anywhere;
  padding: 12px;
}

.edit-page {
  background: var(--pf-card);
  box-shadow: 0 12px 34px rgba(20, 33, 31, 0.16);
  margin: 0 auto;
  max-width: 980px;
  overflow: hidden;
  position: relative;
  width: 100%;
}

.edit-page img {
  display: block;
  height: 100%;
  inset: 0;
  object-fit: fill;
  position: absolute;
  width: 100%;
  z-index: 0;
}

.editable-text-block {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 2px;
  caret-color: var(--taadom-forest);
  color: transparent;
  min-width: 8px;
  outline: none;
  overflow: visible;
  padding: 0 1px;
  position: absolute;
  white-space: pre-wrap;
  z-index: 1;
}

.editable-text-block:hover {
  background: rgba(255, 255, 255, 0.36);
  border-color: rgba(47, 184, 148, 0.55);
  color: var(--block-color, var(--pf-ink));
}

.editable-text-block:focus {
  background: rgba(255, 255, 255, 0.96);
  border-color: var(--taadom-mint);
  box-shadow: 0 0 0 2px rgba(47, 184, 148, 0.18);
  color: var(--block-color, var(--pf-ink));
  z-index: 2;
}

.editable-text-block.changed {
  background: rgba(255, 255, 255, 0.92);
  color: var(--block-color, var(--pf-ink));
}

.editable-text-block.ocr-block {
  outline: 1px dashed rgba(229, 109, 79, 0.55);
}

.field {
  display: grid;
  gap: 5px;
}

.field.grow {
  flex: 1 1 260px;
}

.field.small {
  width: 92px;
}

.field span,
.toggle-field span {
  color: var(--taadom-muted);
  font-size: 12px;
  font-weight: 760;
  text-transform: uppercase;
}

.field input {
  background: var(--pf-card);
  border: 1px solid var(--taadom-line);
  border-radius: 8px;
  height: 42px;
  padding: 0 10px;
}

.toggle-field {
  align-items: center;
  background: var(--pf-card);
  border: 1px solid var(--taadom-line);
  border-radius: 8px;
  display: flex;
  gap: 8px;
  height: 42px;
  padding: 0 12px;
}

.edit-overlay {
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--taadom-mint);
  color: var(--taadom-ink);
  overflow: hidden;
  padding: 2px 4px;
  position: absolute;
  white-space: nowrap;
}

.edit-overlay button {
  background: var(--taadom-coral);
  border-radius: 999px;
  color: var(--pf-on-primary);
  font-size: 11px;
  height: 18px;
  line-height: 18px;
  margin-left: 6px;
  width: 18px;
}

.replace-layout {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.converter-layout {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(240px, 340px) minmax(0, 1fr);
}

.converter-controls {
  display: grid;
  gap: 12px;
}

.field select {
  background: var(--pf-card);
  border: 1px solid var(--taadom-line);
  border-radius: 8px;
  height: 42px;
  padding: 0 10px;
}

.muted-row {
  color: var(--taadom-muted);
}

.format-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 16px;
}

.format-grid div {
  background: var(--pf-card);
  border: 1px solid var(--taadom-line);
  border-radius: 8px;
  display: grid;
  gap: 4px;
  padding: 14px;
}

.format-grid span {
  color: var(--taadom-muted);
  font-size: 13px;
}

.mapping-panel,
.result-panel {
  background: var(--pf-card);
  border: 1px solid var(--taadom-line);
  border-radius: 8px;
  margin-top: 18px;
  padding: 16px;
}

.mapping-head {
  justify-content: space-between;
}

.mapping-head h3 {
  font-size: 16px;
  font-weight: 780;
  margin: 0;
}

.mapping-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.mapping-pill {
  align-items: center;
  background: var(--pf-tint);
  border: 1px solid var(--pf-tint-line);
  border-radius: 999px;
  color: var(--taadom-forest);
  display: inline-flex;
  font-size: 13px;
  font-weight: 720;
  gap: 8px;
  min-height: 32px;
  padding: 0 10px;
}

.mapping-pill button {
  color: var(--pf-danger);
  font-weight: 900;
}

.processing {
  align-items: center;
  /* Was a hardcoded near-white, which in dark mode put a white sheet
     over the page for the length of every job. The flat value is the
     fallback for anything without color-mix. */
  background: var(--pf-paper);
  background: color-mix(in srgb, var(--pf-paper) 94%, transparent);
  inset: 0;
  justify-content: center;
  position: absolute;
  text-align: center;
  z-index: 10;
}

.processing:not(.hidden) {
  display: flex;
  flex-direction: column;
}

.processing h2 {
  font-size: 22px;
  font-weight: 780;
  margin: 14px 0 4px;
}

/* Below the detail line, far enough that it is not pressed by somebody
   reading rather than deciding. */
.processing .secondary-btn {
  margin-top: 18px;
}

.spinner {
  animation: spin 0.9s linear infinite;
  border: 4px solid var(--pf-line);
  border-top-color: var(--taadom-mint);
  border-radius: 999px;
  height: 48px;
  width: 48px;
}

.result-panel {
  align-items: center;
  display: flex;
  justify-content: space-between;
}


.lucide {
  height: 18px;
  width: 18px;
}

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

@media (max-width: 900px) {
  .shell,
  .replace-layout,
  .converter-layout,
  .format-grid {
    grid-template-columns: 1fr;
  }

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

  .nav-tab {
    margin: 0;
  }
}

@media (max-width: 640px) {
  .topbar,
  .panel-head,
  .result-panel {
    align-items: stretch;
    flex-direction: column;
  }

  .workspace {
    padding: 16px;
  }

  .sidebar {
    grid-template-columns: 1fr;
  }
}

/* ------------------------------------------------------------------ */
/* UI polish: motion, hover/focus feedback, empty states, refinements */
/* ------------------------------------------------------------------ */

.primary-btn,
.primary-link,
.secondary-btn,
.icon-btn {
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease,
    box-shadow 0.15s ease, transform 0.06s ease;
}

.primary-btn:active,
.primary-link:active,
.secondary-btn:active,
.icon-btn:active {
  transform: translateY(1px);
}

.secondary-btn:hover,
.icon-btn:not(:disabled):hover {
  background: var(--pf-tint);
  border-color: var(--taadom-mint);
}

.nav-tab {
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

/* Keyboard focus ring across interactive controls */
button:focus-visible,
a:focus-visible,
select:focus-visible,
input:focus-visible,
[contenteditable]:focus-visible {
  outline: 2px solid var(--taadom-mint);
  outline-offset: 2px;
}

select:focus,
.field input:focus {
  border-color: var(--taadom-mint);
  box-shadow: 0 0 0 3px rgba(47, 184, 148, 0.16);
  outline: none;
}

/* Dropzone: clear hover / drag affordance */
.dropzone {
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.dropzone:hover,
.dropzone:focus-within {
  background: var(--pf-tint);
  border-color: var(--taadom-mint);
  box-shadow: 0 0 0 3px rgba(47, 184, 148, 0.12);
}

/* Page cards: subtle lift on hover */
.page-card {
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.page-card:hover {
  box-shadow: 0 16px 36px rgba(20, 33, 31, 0.14);
  transform: translateY(-2px);
}

/* File rows: gentle hover, smooth reorder feedback */
.file-row {
  transition: border-color 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}

.file-row.reorderable:hover {
  border-color: var(--taadom-mint);
}

/* Result panel reads as a success banner */
.result-panel {
  border-left: 3px solid var(--taadom-mint);
  gap: 16px;
}

/* Loaded-file chip picks up hover on its clear button via .secondary-btn rules */

/* Edit-mode select needs room for its descriptive labels */
.edit-mode-field {
  min-width: 220px;
}

.edit-mode-field select {
  width: 100%;
}

/* Empty-state hints so tool pages never look blank before a file loads */
.page-grid:empty {
  border: 1px dashed var(--taadom-line);
  border-radius: 8px;
  color: var(--taadom-muted);
  display: block;
  font-size: 13px;
  padding: 22px;
  text-align: center;
}

.page-grid:empty::before {
  content: "Loaded pages will appear here.";
}

#replaceSourceGrid:empty::before {
  content: "Source pages appear here.";
}

#replaceNewGrid:empty::before {
  content: "Replacement pages appear here.";
}

#officeEditorFrame:empty {
  align-items: center;
  color: var(--taadom-muted);
  display: flex;
  font-size: 14px;
  height: 100%;
  justify-content: center;
  padding: 24px;
  text-align: center;
}

#officeEditorFrame:empty::before {
  content: "Choose an edit mode and load a PDF to open it in the browser editor.";
}

/* Nav active accent bar */
.nav-tab {
  position: relative;
}

.nav-tab.active::before {
  background: var(--taadom-lime);
  border-radius: 0 3px 3px 0;
  content: "";
  height: 22px;
  left: -18px;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
}

/* ---- Edit: text overlay editor ------------------------------------------ */

.edit-document {
  display: grid;
  gap: 18px;
  margin-top: 4px;
  max-height: 70vh;
  overflow-y: auto;
  padding-right: 4px;
}

.panel-note {
  color: var(--taadom-muted);
  font-size: 12px;
  margin: 0 0 8px;
}

.checkbox-field {
  align-items: center;
  /* Not reusing .field here on purpose: .field.small pins a 92px width, which
     is narrower than this label and clipped it. */
  color: var(--taadom-muted);
  display: flex;
  flex: 0 0 auto;
  flex-direction: row;
  font-size: 12px;
  gap: 8px;
  white-space: nowrap;
}

.checkbox-field input {
  accent-color: var(--taadom-forest);
  height: 15px;
  width: 15px;
}

/* Dimmed, not hidden: a choice that has stopped applying should still
   be visible, so it is obvious the setting exists and why it is off. */
.checkbox-field.is-disabled {
  opacity: 0.5;
}

/* ---- Tidy: duplicate finder --------------------------------------------- */

.tidy-summary {
  background: var(--taadom-paper);
  border: 1px solid var(--taadom-mint);
  border-radius: 12px;
  display: grid;
  gap: 4px;
  padding: 16px;
}

.tidy-summary strong { font-size: 20px; }
.tidy-summary span { color: var(--taadom-muted); font-size: 13px; }

.tidy-actions { display: flex; gap: 10px; }

.tidy-results { display: grid; gap: 10px; margin-top: 4px; }

.tidy-group {
  background: var(--pf-card);
  border: 1px solid var(--taadom-mint);
  border-radius: 10px;
  display: grid;
  gap: 6px;
  padding: 12px;
}

.tidy-group.skipped { border-color: var(--taadom-line); opacity: 0.55; }

.tidy-group-head {
  align-items: center;
  background: none;
  border: 0;
  /* Explicit, because a <button> with no colour takes the browser's
     own black, which on the dark card measured 1.24:1. It looked
     right in light mode by accident, exactly like the File Processor
     tiles did. Found by the contrast sweep, not by looking. */
  color: var(--pf-ink);
  cursor: pointer;
  display: flex;
  font: inherit;
  gap: 8px;
  min-height: 36px;
  padding: 0;
  text-align: left;
  width: 100%;
}

.tidy-group-title { font-size: 14px; font-weight: 700; }

/* Every file in a group is the same shape, and both parts of the row
   are controls: the badge swaps which copy is kept, the name opens a
   preview. The keeper used to be drawn differently from the rest,
   which made it read as a heading rather than as one of the choices. */
.tidy-row {
  align-items: center;
  border-radius: 8px;
  display: flex;
  gap: 10px;
  padding: 4px 6px;
}

.tidy-row.is-keeper {
  background: var(--pf-ok-soft);
}

.tidy-badge {
  border: 1px solid transparent;
  border-radius: 5px;
  flex: 0 0 auto;
  font: inherit;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.5px;
  padding: 3px 7px;
}

button.tidy-badge {
  cursor: pointer;
}

/* The one being kept is not a button you can press: pressing it would
   mean keeping what is already kept. Disabled rather than hidden, so
   the row still reads as a pair of options. */
button.tidy-badge:disabled {
  cursor: default;
}

button.tidy-badge.remove:hover {
  border-color: var(--pf-primary);
  color: var(--pf-primary);
}

.tidy-badge.keep { background: var(--pf-ok-soft); color: var(--taadom-forest); }
.tidy-badge.remove { background: var(--pf-danger-soft); color: var(--taadom-coral); }

.tidy-row.is-keeper .tidy-badge.keep {
  background: var(--pf-primary);
  color: var(--pf-on-primary);
}

.tidy-eye {
  color: var(--taadom-muted);
  flex: 0 0 auto;
  opacity: 0;
}

.tidy-row:hover .tidy-eye {
  opacity: 1;
}

.tidy-eye svg {
  height: 15px;
  width: 15px;
}

button.tidy-file {
  background: none;
  border: 0;
  color: inherit;
  cursor: pointer;
  flex: 1;
  font: inherit;
  padding: 0;
  text-align: left;
}

button.tidy-file:hover strong {
  text-decoration: underline;
}

.tidy-file { display: grid; min-width: 0; }
.tidy-file strong {
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tidy-file small { color: var(--taadom-muted); font-size: 11px; }

.scan-thumb {
  background: var(--pf-card);
  border: 1px solid var(--taadom-line);
  border-radius: 6px;
  flex: 0 0 auto;
  height: 54px;
  object-fit: cover;
  width: 40px;
}


/* ---- Page frame --------------------------------------------------------
 *
 * The shared chrome sits above and below each client, so the body is a
 * column and the tool area takes the slack. Without this a short tool page
 * leaves the footer floating in the middle of the viewport.
 */

#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

#app > .pf-footer {
  margin-top: auto;
}

/* Undo and redo moved into the foot of the tool list when the in-page header
   was replaced by the shared bar. They sit on dark green there, so the white
   button treatment from the workspace would be a slab of white in a dark
   column. */
.nav-history {
  border-top: 1px solid rgba(255, 255, 255, 0.16);
  display: flex;
  gap: 8px;
  margin-top: 14px;
  padding-top: 14px;
}

.nav-history .icon-btn {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.24);
  color: var(--pf-on-bar);
  flex: 1;
  font-size: 14px;
  font-weight: 600;
  min-height: 38px;
  padding: 0 8px;
}

.nav-history .icon-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
}

/* ---- Single-tool pages -------------------------------------------------
 *
 * Scanner and Cleaner are one job each, so they get a centred column rather
 * than the Files client's tool list. A sidebar listing one item is furniture.
 */

.tool-page {
  flex: 1;
  margin: 0 auto;
  max-width: 940px;
  padding: 36px 24px 48px;
  width: 100%;
}

.tool-page > header {
  margin-bottom: 26px;
}

.tool-page h1 {
  font-size: clamp(27px, 4vw, 34px);
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}

.tool-lede {
  color: var(--pf-muted);
  font-size: 17px;
  margin: 0;
  max-width: 64ch;
}

.tool-card {
  background: var(--pf-card);
  border: 1px solid var(--pf-line);
  border-radius: 16px;
  margin-bottom: 20px;
  padding: 24px;
}

.tool-card > h2 {
  font-size: 18px;
  margin-bottom: 4px;
}

.tool-card > .panel-caption {
  color: var(--pf-muted);
  font-size: 14.5px;
  margin: 0 0 16px;
}

.tool-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 18px;
}

/* A short, plain statement of where the work happens. Both of these tools
   invite someone to hand over a folder of personal files or a photograph of
   a document, so the answer belongs on the page, not in a privacy policy. */
.tool-privacy {
  align-items: flex-start;
  background: var(--pf-tint);
  border: 1px solid var(--pf-tint-line);
  border-radius: 12px;
  color: var(--pf-ink);
  display: flex;
  font-size: 14px;
  gap: 10px;
  margin-bottom: 22px;
  padding: 12px 14px;
}

/* The same panel, for something that is not reassuring. Used when a
   browser will not keep a draft, which is the one case where someone
   has to change their own behaviour to avoid losing work. */
.tool-privacy.is-warning {
  background: var(--pf-warn-soft);
  border-color: var(--pf-warn-line);
  color: var(--pf-ink);
}

.tool-privacy.is-warning svg {
  color: var(--pf-warn);
}

.tool-privacy svg {
  flex: none;
  height: 18px;
  margin-top: 2px;
  width: 18px;
}

@media (max-width: 860px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px;
  }

  .nav-tab {
    margin-bottom: 0;
    width: auto;
  }

  .nav-history {
    border-top: 0;
    margin-top: 0;
    padding-top: 0;
    width: 100%;
  }
}

@media (max-width: 560px) {
  .tool-page {
    padding: 24px 16px 36px;
  }

  .tool-card {
    padding: 18px;
  }
}

/* Dragging photos onto the page is how most people will do this on a laptop.
   The file input alone gives no feedback that a drop will land. */
.dropzone.is-dragging {
  background: var(--pf-tint);
  border-color: var(--pf-primary);
}


/* ---- hidden ------------------------------------------------------------
 *
 * Last in the file on purpose, and the only place it is defined.
 *
 * This used to come from the Tailwind CDN, which injected its copy at
 * runtime and so landed after everything here. With the CDN gone (it was
 * being loaded to supply one utility class) the rule has to win on its own,
 * and a plain `.hidden` earlier in the file loses to any later rule that
 * sets display: `.tidy-summary` is a grid, `.tidy-actions` is a flex, and
 * both were showing an empty box and an Export button before anything had
 * been scanned. The pre-existing `.result-panel.hidden` override was the
 * same bug, patched one selector at a time.
 */
.hidden {
  display: none !important;
}


/* ---- Cleaner preview ----------------------------------------------------
 *
 * The files never left the browser, so this is a blob URL and nothing
 * else: no request, no upload, no wait. It exists because two photos
 * with the same dimensions and almost the same size are impossible to
 * tell apart in a list, which is the moment somebody stops trusting
 * the tool.
 */

.tidy-preview {
  background: rgba(0, 0, 0, 0.62);
  display: flex;
  inset: 0;
  padding: 24px 16px;
  position: fixed;
  z-index: 200;
}

.tidy-preview-sheet {
  background: var(--pf-card);
  border: 1px solid var(--pf-line);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  margin: auto;
  max-height: 100%;
  max-width: 760px;
  overflow: hidden;
  width: 100%;
}

.tidy-preview-sheet header,
.tidy-preview-sheet footer {
  align-items: center;
  display: flex;
  gap: 14px;
  justify-content: space-between;
  padding: 14px 16px;
}

.tidy-preview-sheet header {
  border-bottom: 1px solid var(--pf-line);
}

.tidy-preview-sheet footer {
  border-top: 1px solid var(--pf-line);
}

.tidy-preview-text {
  display: grid;
  min-width: 0;
}

.tidy-preview-text strong {
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tidy-preview-text small {
  color: var(--pf-muted);
  font-size: 12.5px;
}

.tidy-preview-body {
  align-items: center;
  background: var(--pf-surface);
  display: flex;
  flex: 1;
  justify-content: center;
  min-height: 220px;
  overflow: auto;
  padding: 16px;
}

.tidy-preview-body img {
  display: block;
  max-height: 60vh;
  max-width: 100%;
  object-fit: contain;
}

.tidy-preview-body object {
  height: 60vh;
  width: 100%;
}

.tidy-preview-body pre {
  align-self: stretch;
  color: var(--pf-ink);
  font-size: 13px;
  line-height: 1.5;
  margin: 0;
  max-height: 60vh;
  overflow: auto;
  white-space: pre-wrap;
  width: 100%;
  word-break: break-word;
}

.tidy-preview-none {
  color: var(--pf-muted);
  display: grid;
  gap: 5px;
  justify-items: center;
  padding: 32px 16px;
  text-align: center;
}

.tidy-preview-none strong {
  color: var(--pf-ink);
  font-size: 15px;
}

.tidy-preview-none svg {
  color: var(--pf-muted);
  height: 30px;
  margin-bottom: 6px;
  width: 30px;
}
