/*
 * keeplocal — shared identity
 * ----------------------------------------------------------------------------
 * ONE stylesheet for keeplocal.tools and every tool subdomain. Each app's
 * src/style.css is a thin `@import` of this file plus room for app-local rules,
 * so a type or colour change is made once instead of six times.
 *
 * House: civic/data (MTC Lab identity system §3) — deep institutional field,
 * ONE restrained accent, serif reading register, sans chrome, mono for readings.
 * The accent is security-printing green: the ink certificates, cheques and
 * passport stamps are printed in, because green means "authentic instrument,
 * in your custody". That is exactly this product's claim.
 */

/* ---------------------------------------------------------------- 1. tokens */

:root {
  color-scheme: light;

  /* Type — canonical estate stack, no download, no CSP font-src needed. */
  --font-serif: "Source Serif 4", Charter, "Bitstream Charter", "Sitka Text", Cambria, Georgia, serif;
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  /* Field — near-black with a green cast. Not navy: vahti and Vigla own navy. */
  --ink: #0e1714;
  --paper: #f6f7f5;
  --panel: #ffffff;
  --panel-sunk: #eef1ee;
  --text: #0e1714;
  --muted: #5b6863;
  --rule: #d5dbd7;
  --rule-strong: #a8b3ad;

  /* The one accent. */
  --seal: #14624a;
  --seal-hover: #0e4b38;
  --seal-on: #ffffff;
  --seal-soft: #e4efe9;

  /* States are states, not brand colours. */
  --alarm: #a02a1e;
  --alarm-soft: #fbeae8;

  /* Ink band (the receipt) keeps the institutional field present in light mode. */
  --band: #0e1714;
  --band-text: #eef3f0;
  --band-muted: #93a49d;
  --band-rule: #2b3a34;
  --band-seal: #6fd0a6;

  --shadow: 0 1px 2px rgb(14 23 20 / 5%), 0 12px 32px rgb(14 23 20 / 6%);
  --radius: 6px;
  --radius-lg: 10px;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #0b120f;
  --panel: #141d19;
  --panel-sunk: #1b2621;
  --text: #eef3f0;
  --muted: #9baaa3;
  --rule: #2a3833;
  --rule-strong: #46554e;

  --seal: #6fd0a6;
  --seal-hover: #8ee0bc;
  --seal-on: #06231a;
  --seal-soft: #17332a;

  --alarm: #f2a099;
  --alarm-soft: #3a1c19;

  --band: #141d19;
  --band-text: #eef3f0;
  --band-muted: #9baaa3;
  --band-rule: #2a3833;
  --band-seal: #6fd0a6;

  --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 12px 32px rgb(0 0 0 / 34%);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --paper: #0b120f;
    --panel: #141d19;
    --panel-sunk: #1b2621;
    --text: #eef3f0;
    --muted: #9baaa3;
    --rule: #2a3833;
    --rule-strong: #46554e;

    --seal: #6fd0a6;
    --seal-hover: #8ee0bc;
    --seal-on: #06231a;
    --seal-soft: #17332a;

    --alarm: #f2a099;
    --alarm-soft: #3a1c19;

    --band: #141d19;
    --band-text: #eef3f0;
    --band-muted: #9baaa3;
    --band-rule: #2a3833;
    --band-seal: #6fd0a6;

    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 12px 32px rgb(0 0 0 / 34%);
  }
}

/* ------------------------------------------------------------------ 2. base */

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background: var(--paper);
  color: var(--text);
  font-family: var(--font-sans);
  font-synthesis-weight: none;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  font: inherit;
}

a {
  color: inherit;
}

/* Reading voice: the serif carries headings and prose. Chrome stays sans. */
h1,
h2,
h3,
.lede,
.reading {
  font-family: var(--font-serif);
  font-weight: 400;
  letter-spacing: -0.005em;
}

h1 {
  max-width: 22ch;
  margin: 0;
  font-size: clamp(1.85rem, 3.4vw, 2.8rem);
  line-height: 1.1;
}

.lede {
  max-width: 62ch;
  margin: 18px 0 30px;
  color: var(--muted);
  font-size: clamp(1.02rem, 1.5vw, 1.14rem);
  line-height: 1.65;
}

/* Wayfinding label. Replaces the uppercase letterspaced eyebrow: it states the
   origin you are actually on, which is information a privacy tool owes you. */
.origin-label,
.card-kicker {
  margin: 0 0 14px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
}

.origin-label::before {
  content: "";
  display: inline-block;
  width: 18px;
  height: 0;
  margin-right: 9px;
  border-top: 1px solid var(--rule-strong);
  vertical-align: 0.3em;
}

/* -------------------------------------------------------------- 3. masthead */

.site-header {
  width: min(1160px, calc(100% - 40px));
  min-height: 68px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 20px;
  border-bottom: 1px solid var(--rule);
}

.brand-cluster {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand {
  width: fit-content;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
  font-family: var(--font-serif);
  font-size: 1.2rem;
  font-weight: 400;
  letter-spacing: -0.01em;
  text-decoration: none;
}

/* The mark: a bracket pair closed around a solid block. Containment, drawn —
   never an emoji. Inherits currentColor so it works on any field. */
.brand-mark {
  width: 20px;
  height: 20px;
  flex: none;
  color: var(--seal);
}

.brand-mark svg {
  display: block;
  width: 100%;
  height: 100%;
}

/* The header badge is itself a reading, not a label: it shows the live count. */
.local-badge {
  min-height: 32px;
  padding: 5px 11px;
  display: inline-flex;
  align-items: baseline;
  gap: 7px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--muted);
  font-size: 0.78rem;
  white-space: nowrap;
  cursor: pointer;
}

.local-badge:hover {
  border-color: var(--seal);
  color: var(--text);
}

.local-badge .badge-value {
  color: var(--seal);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

.theme-toggle {
  justify-self: end;
  min-height: 34px;
  padding: 6px 12px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  font-size: 0.84rem;
  cursor: pointer;
}

.theme-toggle:hover {
  border-color: var(--rule-strong);
}

/* ------------------------------------------------------- 4. the tool switcher */

.tool-navigation {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 0.87rem;
}

.nav-label {
  flex: none;
  color: var(--muted);
}

/* Scrolls on narrow screens WITH an affordance: a fade at the live edge, so
   nothing is ever silently clipped mid-word. */
.tool-switcher {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: thin;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
  /* The affordance: content running under the right edge fades instead of
     being guillotined mid-word. Invisible when the row already fits. */
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 26px), transparent);
  mask-image: linear-gradient(to right, #000 calc(100% - 26px), transparent);
}

.nav-tool {
  flex: none;
  padding: 6px 10px;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  scroll-snap-align: start;
  cursor: pointer;
}

.nav-tool:hover {
  color: var(--text);
}

.nav-tool[aria-current="page"] {
  border-bottom-color: var(--seal);
  background: transparent;
  color: var(--text);
}

/* ------------------------------------------------- 5. the receipt (signature) */

/*
 * The one thing an upload-model competitor structurally cannot print: a reading
 * taken in the visitor's own browser, right now. Set as a printed slip — leader
 * dots, mono figures — because it is a record, not a claim.
 */
.receipt {
  border: 1px solid var(--band-rule);
  border-radius: var(--radius-lg);
  background: var(--band);
  color: var(--band-text);
  overflow: hidden;
}

.receipt-head {
  padding: 14px 20px 12px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--band-rule);
}

.receipt-title {
  margin: 0;
  color: var(--band-text);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 400;
}

.receipt-stamp {
  color: var(--band-muted);
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-variant-numeric: tabular-nums;
}

.receipt-rows {
  margin: 0;
  padding: 8px 20px 14px;
}

.receipt-rows > div {
  padding: 7px 0;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: baseline;
  gap: 0;
}

/* Leader dots, drawn with a pseudo-element so the <dl> stays valid markup. */
.receipt-rows > div::before {
  content: "";
  grid-column: 2;
  margin: 0 10px;
  border-bottom: 1px dotted var(--band-rule);
  transform: translateY(-0.3em);
}

.receipt-rows dt {
  grid-column: 1;
  color: var(--band-muted);
  font-size: 0.86rem;
}

.receipt-rows dd {
  grid-column: 3;
  margin: 0;
  color: var(--band-seal);
  font-family: var(--font-mono);
  font-size: 0.86rem;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.receipt-rows dd[data-state="pending"] {
  color: var(--band-muted);
}

.receipt-rows dd[data-state="fail"] {
  color: #f2a099;
}

.receipt-foot {
  padding: 12px 20px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  border-top: 1px solid var(--band-rule);
  color: var(--band-muted);
  font-size: 0.8rem;
  line-height: 1.5;
}

.receipt-foot a {
  color: var(--band-seal);
  text-decoration-color: color-mix(in srgb, var(--band-seal) 40%, transparent);
  text-underline-offset: 3px;
}

.receipt-recheck {
  flex: none;
  min-height: 30px;
  padding: 5px 11px;
  border: 1px solid var(--band-rule);
  border-radius: var(--radius);
  background: transparent;
  color: var(--band-text);
  font-size: 0.78rem;
  cursor: pointer;
}

.receipt-recheck:hover {
  border-color: var(--band-seal);
  color: var(--band-seal);
}

/* ------------------------------------------------------------- 6. the answer */

/*
 * When a result exists it IS the page. Filename plus the number, large and in
 * the mono reading face; the sales headline demotes to a caption below.
 */
.answer {
  margin: 0 0 26px;
  padding: 20px 22px;
  border: 1px solid var(--rule);
  border-left: 3px solid var(--seal);
  border-radius: var(--radius-lg);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.answer[hidden] {
  display: none;
}

.answer-file {
  margin: 0 0 8px;
  overflow: hidden;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.answer-value {
  margin: 0;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: clamp(2rem, 5.5vw, 3.1rem);
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
  letter-spacing: -0.02em;
}

.answer-note {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

/*
 * Notices — what the core says it did to the file, inside the answer card so a
 * result can never appear without them. Reading register (serif), because these
 * are sentences to be read, not readings to be scanned.
 */
.answer-notices {
  margin: 16px 0 0;
  padding: 14px 16px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--panel-sunk);
}

.answer-notices[hidden] {
  display: none;
}

.notices-title {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.notices-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.notice {
  margin: 0;
  color: var(--text);
  font-family: var(--font-serif);
  font-size: 0.95rem;
  line-height: 1.55;
}

.notice + .notice {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--rule);
}

/*
 * A contradiction notice says the download is not what the page promised. It
 * takes the alarm register and drags the whole answer card with it, so someone
 * who only glances at the result cannot read it as an unqualified success.
 */
.answer-notices[data-level="contradiction"] {
  border-color: var(--alarm);
  background: var(--alarm-soft);
}

.answer-notices[data-level="contradiction"] .notices-title,
.notice[data-level="contradiction"] {
  color: var(--alarm);
}

.notice[data-level="contradiction"] {
  font-weight: 600;
}

.answer[data-notice="contradiction"] {
  border-color: var(--alarm);
  border-left-color: var(--alarm);
}

.answer[data-notice="contradiction"] .answer-value {
  color: var(--alarm);
}

/*
 * The archive's own warnings, shown above its entry list. Same register as a
 * notice: this is the core telling the user what will not work, before they
 * press a button that would have failed.
 */
.archive-warnings {
  margin: 16px 0 0;
  padding: 14px 16px;
  border: 1px solid var(--alarm);
  border-radius: var(--radius);
  background: var(--alarm-soft);
}

.archive-warnings[hidden] {
  display: none;
}

.archive-warnings .notices-title {
  color: var(--alarm);
}

/* A row the core says cannot be extracted says so instead of offering a button. */
.entry-blocked {
  color: var(--alarm);
  font-size: 0.82rem;
}

/*
 * Small standing labels on an entry row: unsafe path, duplicate name. The row
 * stacks its details in a column, so the pill has to claim only its own width
 * rather than stretching the full cell.
 */
.entry-flag {
  align-self: flex-start;
  margin-top: 2px;
  padding: 2px 8px;
  border: 1px solid currentcolor;
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.72rem;
  white-space: nowrap;
}

.entry-flag[data-level="alarm"] {
  color: var(--alarm);
}

/* The headline steps down once an answer is on screen. */
.tool-panel[data-answered="true"] h1 {
  font-size: clamp(1.15rem, 2vw, 1.35rem);
  line-height: 1.35;
  color: var(--muted);
}

.tool-panel[data-answered="true"] .lede {
  display: none;
}

/* ----------------------------------------------------------- 7. the dropzone */

.drop-zone {
  position: relative;
  overflow: hidden;
  border: 1px dashed var(--rule-strong);
  border-radius: var(--radius-lg);
  background: var(--panel);
  transition: border-color 140ms ease, background 140ms ease;
}

.drop-zone:hover,
.drop-zone[data-dragging="true"] {
  border-color: var(--seal);
  background: var(--seal-soft);
}

.drop-zone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.drop-zone label {
  min-height: 150px;
  padding: 26px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  cursor: pointer;
}

.drop-zone:has(input:focus-visible) {
  outline: 2px solid var(--seal);
  outline-offset: 3px;
}

.drop-zone input:disabled + label {
  opacity: 0.55;
  cursor: not-allowed;
}

.drop-icon {
  width: 34px;
  height: 34px;
  margin-bottom: 12px;
  display: grid;
  place-items: center;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--panel-sunk);
  color: var(--seal);
  font-size: 1.05rem;
}

.drop-title {
  max-width: 100%;
  overflow: hidden;
  font-size: 1rem;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drop-detail {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.88rem;
}

.drop-zone[data-loaded="true"] .drop-title {
  font-family: var(--font-mono);
  font-size: 0.92rem;
  font-weight: 400;
}

/* ------------------------------------------------------- 8. the status strip */

.result {
  min-height: 44px;
  margin-top: 14px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--panel-sunk);
  color: var(--muted);
  font-size: 0.9rem;
}

.status-dot {
  width: 7px;
  height: 7px;
  flex: none;
  border-radius: 50%;
  background: var(--muted);
}

.result[data-state="working"] .status-dot {
  background: var(--seal);
  animation: pulse 1s ease-in-out infinite alternate;
}

.result[data-state="success"] {
  color: var(--seal);
}

.result[data-state="success"] .status-dot {
  background: var(--seal);
}

.result[data-state="error"] {
  border-color: var(--alarm);
  background: var(--alarm-soft);
  color: var(--alarm);
}

.result[data-state="error"] .status-dot {
  background: var(--alarm);
}

/*
 * "notice": the operation succeeded, but the core reported something that
 * contradicts the page's copy. It reads as alarm rather than success on
 * purpose — this is the line directly under the button the user just pressed,
 * and it carries the core's sentence verbatim.
 */
.result[data-state="notice"] {
  align-items: flex-start;
  border-color: var(--alarm);
  background: var(--alarm-soft);
  color: var(--alarm);
  line-height: 1.5;
}

.result[data-state="notice"] .status-dot {
  margin-top: 7px;
  background: var(--alarm);
}

@keyframes pulse {
  to { opacity: 0.3; }
}

/* ---------------------------------------------------------------- 9. layout */

main {
  width: min(1080px, calc(100% - 40px));
  margin: clamp(34px, 5vw, 60px) auto 64px;
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(272px, 0.7fr);
  gap: clamp(28px, 5vw, 64px);
  align-items: start;
}

.tool-panel {
  min-width: 0;
}

/* --------------------------------------------------------- 10. work surfaces */

.merge-queue,
.organize-editor,
.compress-editor {
  margin-top: 16px;
  padding: 18px;
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  background: var(--panel);
}

.organize-editor-header > div,
.compress-editor-header > div {
  min-width: 0;
}

.organize-source-name {
  max-width: 360px;
  display: block;
  overflow: hidden;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.merge-queue-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 20px;
}

.merge-queue-header h2 {
  margin: 0;
  font-size: 1.1rem;
}

.merge-queue-header span {
  color: var(--muted);
  font-size: 0.84rem;
}

.merge-list {
  margin: 14px 0 16px;
  padding: 0;
  display: grid;
  gap: 6px;
  list-style: none;
}

.organize-list {
  max-height: 410px;
  margin: 12px 0 16px;
  padding: 0 3px 0 0;
  display: grid;
  gap: 6px;
  overflow-y: auto;
  list-style: none;
}

.merge-file {
  min-width: 0;
  padding: 9px 10px;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--panel-sunk);
}

.organize-page {
  min-width: 0;
  padding: 9px 10px;
  display: grid;
  grid-template-columns: 30px minmax(90px, 1fr) auto auto;
  align-items: center;
  gap: 11px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--panel-sunk);
}

.page-list-empty {
  padding: 18px;
  border: 1px dashed var(--rule);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
}

.file-order {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}

.file-details {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.file-name {
  overflow: hidden;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-size {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-variant-numeric: tabular-nums;
}

.file-actions {
  display: flex;
  gap: 5px;
}

.file-action {
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
}

.file-action:hover:not(:disabled) {
  border-color: var(--seal);
  color: var(--seal);
}

.file-action.remove-action:hover:not(:disabled) {
  border-color: var(--alarm);
  color: var(--alarm);
}

.file-action:disabled,
.primary-action:disabled,
.secondary-action:disabled,
.text-action:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

/* ---------------------------------------------------------------- 11. forms */

.page-add-form {
  margin-top: 18px;
}

.page-add-form > label {
  display: block;
  margin-bottom: 7px;
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 600;
}

.page-add-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.page-add-row input {
  min-width: 0;
  min-height: 40px;
  padding: 9px 11px;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  font-family: var(--font-mono);
}

.page-add-form p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 0.79rem;
  line-height: 1.45;
}

.page-list-tools {
  margin-top: 16px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  color: var(--muted);
  font-size: 0.79rem;
}

.quality-presets {
  min-width: 0;
  margin: 18px 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  border: 0;
}

.quality-presets legend {
  margin-bottom: 8px;
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 600;
}

.quality-presets label {
  position: relative;
  min-width: 0;
  padding: 11px;
  display: flex;
  align-items: flex-start;
  gap: 9px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--panel-sunk);
  cursor: pointer;
}

.quality-presets label:has(input:checked) {
  border-color: var(--seal);
  background: var(--seal-soft);
}

.quality-presets input {
  flex: none;
  margin: 3px 0 0;
  accent-color: var(--seal);
}

.quality-presets span {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.quality-presets strong {
  color: var(--text);
  font-size: 0.87rem;
  font-weight: 600;
}

.quality-presets small {
  color: var(--muted);
  font-size: 0.73rem;
  line-height: 1.35;
}

.compress-scope {
  margin: -7px 0 16px;
  color: var(--muted);
  font-size: 0.79rem;
  line-height: 1.5;
}

.rotation-control {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 0.79rem;
}

.rotation-control select {
  min-height: 32px;
  padding: 5px 24px 5px 8px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
}

/* -------------------------------------------------------------- 12. actions */

.primary-action {
  width: 100%;
  min-height: 46px;
  padding: 11px 18px;
  border: 1px solid var(--seal);
  border-radius: var(--radius);
  background: var(--seal);
  color: var(--seal-on);
  font-weight: 600;
  cursor: pointer;
}

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

.secondary-action {
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
}

.secondary-action:hover:not(:disabled) {
  border-color: var(--seal);
  color: var(--seal);
}

.text-action {
  flex: none;
  padding: 3px 0;
  border: 0;
  background: transparent;
  color: var(--seal);
  font-weight: 600;
  cursor: pointer;
}

.text-action:hover:not(:disabled) {
  text-decoration: underline;
}

.download-action {
  width: 100%;
  margin-top: 9px;
}

.compress-output {
  margin-top: 16px;
}

.compression-stats {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--panel-sunk);
}

.compression-stats div {
  padding: 11px 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  border-left: 1px solid var(--rule);
}

.compression-stats div:first-child {
  border-left: 0;
}

.compression-stats dt {
  color: var(--muted);
  font-size: 0.75rem;
}

.compression-stats dd {
  margin: 0;
  color: var(--text);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  text-align: left;
}

/* --------------------------------------------------------- 13. the inspector */

.local-inspector {
  width: min(560px, calc(100% - 32px));
  max-width: none;
  max-height: min(720px, calc(100% - 32px));
  padding: 0;
  overflow: auto;
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 28px 80px rgb(0 0 0 / 34%);
}

.local-inspector::backdrop {
  background: rgb(14 23 20 / 62%);
}

.inspector-content {
  padding: clamp(20px, 4vw, 28px);
}

.inspector-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}

.inspector-header h2 {
  margin: 0;
  font-size: 1.5rem;
}

.inspector-close {
  width: 36px;
  height: 36px;
  flex: none;
  padding: 0;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--panel-sunk);
  color: var(--text);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
}

#local-inspector-description {
  margin: 12px 0 20px;
  color: var(--muted);
  line-height: 1.6;
}

/*
 * The receipt rows appear twice: on the dark ink band, and inside this light
 * dialog. The band palette would be unreadable on the panel, so re-map it.
 */
.inspector-rows > div::before {
  border-bottom-color: var(--rule-strong);
}

.inspector-rows dt {
  color: var(--muted);
}

.inspector-rows dd {
  color: var(--seal);
}

.inspector-rows dd[data-state="pending"] {
  color: var(--muted);
}

.inspector-rows dd[data-state="fail"] {
  color: var(--alarm);
}

.proof-explanation {
  margin: 16px 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.6;
}

.proof-explanation code,
.inspector-content code {
  padding: 2px 5px;
  border-radius: 4px;
  background: var(--panel-sunk);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.82rem;
}

.source-link {
  width: fit-content;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--seal);
  font-weight: 600;
  text-underline-offset: 3px;
}

/* ------------------------------------------------------------ 14. side panel */

.trust-card {
  padding: 0;
  border: 0;
  background: transparent;
}

/*
 * In the app sidebar the receipt lives in a ~320px column, where a
 * label-leader-value row would wrap mid-directive. Stack it there: the same
 * readings, set as a spec sheet rather than a ledger line.
 */
.trust-card .receipt-rows > div {
  grid-template-columns: minmax(0, 1fr);
  gap: 3px;
}

.trust-card .receipt-rows > div::before {
  display: none;
}

.trust-card .receipt-rows dt,
.trust-card .receipt-rows dd {
  grid-column: 1;
  text-align: left;
}

.trust-card .receipt-rows dt {
  font-size: 0.8rem;
}

.trust-card .receipt-rows dd {
  overflow-wrap: anywhere;
}

.trust-note {
  margin: 16px 0 0;
  padding: 16px 18px;
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  background: var(--panel);
}

.trust-note h2 {
  margin: 0 0 8px;
  font-size: 1.08rem;
}

.trust-note p {
  margin: 0;
  color: var(--muted);
  font-size: 0.89rem;
  line-height: 1.6;
}

/* ---------------------------------------------------------------- 15. footer */

footer {
  width: min(1080px, calc(100% - 40px));
  margin: 0 auto;
  padding: 22px 0 44px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: 0.85rem;
}

footer p {
  margin: 0;
}

footer a {
  color: var(--muted);
  text-underline-offset: 3px;
}

footer a:hover {
  color: var(--text);
}

footer nav a {
  margin-right: 16px;
}

/* The maker's mark — quiet, muted, never in the hero. */
.maker-mark {
  color: var(--muted);
}

.maker-mark a {
  color: var(--muted);
}

/* ------------------------------------------------------------ 16. focus ring */

:where(button, a, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--seal);
  outline-offset: 3px;
}

.receipt :where(button, a):focus-visible {
  outline-color: var(--band-seal);
}

/* ------------------------------------------------------------ 17. responsive */

@media (max-width: 960px) {
  .site-header {
    grid-template-columns: 1fr auto;
    padding: 12px 0 10px;
  }

  .tool-navigation {
    width: 100%;
    grid-column: 1 / -1;
    grid-row: 2;
    gap: 10px;
  }

  /* Keep the toggle on the masthead row; the nav takes the row below it. */
  .theme-toggle {
    grid-row: 1;
    grid-column: 2;
  }

  main {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  main {
    margin-top: 30px;
  }

  .merge-file {
    grid-template-columns: 30px minmax(0, 1fr);
  }

  .organize-page {
    grid-template-columns: 30px minmax(0, 1fr) auto;
  }

  .file-actions {
    grid-column: 2;
  }

  .organize-page .file-actions {
    grid-column: 2 / -1;
  }

  .page-add-row {
    grid-template-columns: 1fr;
  }

  .page-list-tools {
    align-items: flex-start;
    flex-direction: column;
  }

  .quality-presets {
    grid-template-columns: 1fr;
  }

  .receipt-rows > div {
    grid-template-columns: 1fr auto;
    gap: 12px;
  }

  .receipt-rows > div::before {
    display: none;
  }

  .receipt-rows dd {
    grid-column: 2;
  }
}

@media (max-width: 520px) {
  .site-header {
    width: calc(100% - 28px);
    gap: 10px;
  }

  main,
  footer {
    width: calc(100% - 28px);
  }

  /* The headline must not eat the first screen: the dropzone stays above the
     fold at 390px. */
  h1 {
    font-size: 1.6rem;
  }

  .lede {
    margin: 14px 0 20px;
    font-size: 0.98rem;
  }

  /* Drop the "Tools" caption so the tool names themselves fit without
     scrolling — remove the clipping rather than decorate it. The switcher
     still scrolls (with its edge fade) for apps that carry more tools. */
  .nav-label {
    display: none;
  }

  .receipt-head,
  .receipt-rows,
  .receipt-foot {
    padding-inline: 15px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
