/* DMO Business Tools. One stylesheet, token-based. Design: docs/DESIGN_PLAN.md */

/* Self-hosted fonts (SIL OFL 1.1, see fonts/LICENSE.md). No third-party requests. */
@font-face {
  font-family: "Fraunces";
  src: url("/fonts/fraunces-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 900; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Hanken Grotesk";
  src: url("/fonts/hanken-grotesk-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 900; font-style: normal; font-display: swap;
}

:root {
  /* Surfaces */
  --bg: #fcf9f5;
  --surface: #ffffff;
  --surface-2: #f4efe8;
  --line: #e4ddd3;
  --line-strong: #cfc6dd;

  /* Ink */
  --ink: #1f1640;
  --muted: #5a5470;

  /* Brand */
  --brand: #542f9c;
  --brand-hover: #43247f;
  --brand-deep: #2e1a5e;
  --brand-soft: #eee8fb;
  --brand-line: #c9bceb;
  --primary: var(--brand);
  --primary-hover: var(--brand-hover);
  --primary-ink: #ffffff;
  --focus: #f0b400;

  /* Tool families: fill / ink / dot */
  --fam-convert: #ddf0e4;  --fam-convert-ink: #1e5b3a;  --fam-convert-dot: #3e9a66;
  --fam-organize: #ece6fb; --fam-organize-ink: #45278a; --fam-organize-dot: #7b5cd6;
  --fam-create: #fde7d6;   --fam-create-ink: #7a3310;   --fam-create-dot: #e0773a;
  --fam-check: #fff1c9;    --fam-check-ink: #6b4a00;    --fam-check-dot: #d9a400;
  --fam-match: #dcebf7;    --fam-match-ink: #1d4e78;    --fam-match-dot: #3c82c0;

  /* Status: always paired with a text label */
  --good: #1c6b3a; --good-bg: #e3f2e7;
  --warn: #7a4f00; --warn-bg: #fff2cf;
  --bad: #9e2424;  --bad-bg: #fbe4e2;
  --info: #1d4e78; --info-bg: #e2edf6;

  /* Development stand-in marker: deliberately NOT the brand colour */
  --dev: #3a2a00; --dev-bg: #ffd84d; --dev-bg-2: #f5c928;

  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-text: "Hanken Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --radius-sm: 8px; --radius: 12px; --radius-lg: 20px; --radius-pill: 999px;
  --shadow-card: 0 1px 0 rgba(31, 22, 64, 0.04), 0 8px 24px -12px rgba(31, 22, 64, 0.18);
  --shadow-lift: 0 1px 0 rgba(31, 22, 64, 0.04), 0 14px 30px -12px rgba(31, 22, 64, 0.28);
  --space: 1rem;
  --max: 72rem;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { font-size: 112.5%; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-text);
  line-height: 1.55;
  display: flex; flex-direction: column; min-height: 100vh;
}
.wrap { width: 100%; max-width: var(--max); margin: 0 auto; padding: 0 24px; }
h1, h2, .serif { font-family: var(--font-display); font-weight: 380; letter-spacing: -0.02em; font-variation-settings: "SOFT" 50, "opsz" 72; }
h1 { font-size: clamp(2rem, 3vw + 1rem, 3rem); line-height: 1.08; margin: 2rem 0 0.9rem; }
h2 { font-size: 1.5rem; line-height: 1.2; margin: 2.25rem 0 0.8rem; }
h3 { font-size: 1.05rem; font-weight: 650; margin: 0 0 0.5rem; }
p { margin: 0 0 1rem; }
a { color: var(--brand); text-underline-offset: 3px; }
a:hover { color: var(--brand-hover); }
main { flex: 1; padding-bottom: 5rem; outline: none; }
main.wrap { padding-bottom: 5rem; }
.lead { font-size: 1.12rem; color: var(--muted); max-width: 40rem; }
.muted { color: var(--muted); }
.small { font-size: 0.9rem; }
.eyebrow { display: block; font-family: var(--font-text); font-size: 0.72rem; font-weight: 650; letter-spacing: 0.08em; text-transform: uppercase; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Focus: always visible, never colour-only. */
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 6px; }
.skip-link { position: absolute; left: 8px; top: -60px; background: var(--ink); color: #fff; padding: 12px 16px; z-index: 10; border-radius: 8px; }
.skip-link:focus { top: 8px; color: #fff; }

/* Development marker: yellow tape. Never purple, so it cannot pass for normal chrome. */
.dev-banner {
  background: repeating-linear-gradient(135deg, var(--dev-bg) 0 14px, var(--dev-bg-2) 14px 28px);
  color: var(--dev); padding: 9px 16px; font-size: 0.88rem; font-weight: 650; text-align: center;
}

/* Header */
.site-header { background: var(--bg); }
.header-row { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; min-height: 76px; padding-top: 10px; padding-bottom: 10px; }
.brand { display: flex; align-items: baseline; gap: 0.55rem; text-decoration: none; color: var(--ink); margin-right: auto; }
.brand:hover { color: var(--ink); }
.brand-name { font-family: var(--font-display); font-size: 1.7rem; font-weight: 420; letter-spacing: -0.02em; line-height: 1; }
.brand-sub { font-size: 0.85rem; color: var(--muted); font-weight: 550; }
.main-nav { display: flex; gap: 4px; padding: 5px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-pill); }
.main-nav a { padding: 0 18px; border-radius: var(--radius-pill); text-decoration: none; color: var(--ink); font-weight: 550; min-height: 44px; display: inline-flex; align-items: center; }
.main-nav a:hover { background: var(--surface-2); color: var(--ink); }
.main-nav a[aria-current="page"] { background: var(--brand-soft); color: var(--fam-organize-ink); font-weight: 650; }
.account { position: relative; margin-left: auto; }
.account summary { list-style: none; cursor: pointer; padding: 0 20px; border-radius: var(--radius-pill); min-height: 44px; display: inline-flex; align-items: center; color: var(--brand); font-weight: 650; box-shadow: inset 0 0 0 1.5px var(--brand); }
.account summary:hover { background: var(--brand-soft); }
.account summary::-webkit-details-marker { display: none; }
.account summary::after { content: " ▾"; white-space: pre; }
.account-panel { position: absolute; right: 0; top: calc(100% + 8px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; width: 16rem; box-shadow: var(--shadow-card); z-index: 5; }
.account-panel p { margin: 0 0 0.25rem; }
.account-ws { color: var(--muted); font-size: 0.9rem; margin-bottom: 0.75rem !important; }

/* Footer */
.site-footer { background: var(--brand-deep); color: #fff; margin-top: auto; }
.footer-row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; padding-top: 28px; padding-bottom: 28px; }
.footer-line { font-family: var(--font-display); font-size: 1.25rem; font-weight: 380; margin: 0; }
.footer-name { color: #e6dff8; font-size: 0.9rem; margin: 0; }

/* Buttons: pills */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  min-height: 52px; padding: 12px 26px; border-radius: var(--radius-pill); border: 0;
  font: inherit; font-weight: 650; text-decoration: none; cursor: pointer; text-align: center;
  transition: background-color 0.15s ease-out, box-shadow 0.15s ease-out;
}
.btn-primary { background: var(--brand); color: var(--primary-ink); }
.btn-primary:hover { background: var(--brand-hover); color: var(--primary-ink); }
.btn-secondary { background: transparent; color: var(--brand); box-shadow: inset 0 0 0 1.5px var(--brand); }
.btn-secondary:hover { background: var(--brand-soft); color: var(--brand-hover); }
.btn-quiet { background: transparent; color: var(--brand); text-decoration: underline; padding-left: 10px; padding-right: 10px; }
.btn-large { min-height: 64px; font-size: 1.1rem; padding: 16px 36px; }
.btn-small { min-height: 44px; padding: 8px 18px; font-size: 0.95rem; }
.btn[disabled], .btn[aria-disabled="true"] { background: #efece7; color: var(--muted); box-shadow: none; cursor: not-allowed; }
.actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin: 1.5rem 0; align-items: center; }
.arrow-link { font-weight: 650; text-decoration: none; display: inline-flex; align-items: center; min-height: 44px; }
.arrow-link:hover { text-decoration: underline; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 1.35rem 1.5rem; }
.stack > * + * { margin-top: 1rem; }

/* Home */
.home-hero { text-align: center; padding-top: 1.5rem; }
.home-hero h1 { margin-top: 1.5rem; }
.home-hero .lead { margin-left: auto; margin-right: auto; font-size: 1.2rem; }
.start-card {
  margin: 2.25rem auto 0; max-width: 52rem; background: var(--surface); border: 1px solid var(--line);
  border-radius: 24px; padding: 2.75rem 2rem; box-shadow: var(--shadow-card);
  display: flex; flex-direction: column; align-items: center; gap: 0.9rem; text-align: center;
}
.start-card > svg { width: 64px; height: 64px; }
.start-card .serif { font-size: 1.75rem; margin: 0; }
.start-card .limits { margin: 0; }
.start-card .btn { min-width: 18rem; }
.review-pill {
  display: inline-flex; align-items: center; min-height: 48px; padding: 0 22px; margin-top: 1.25rem;
  border-radius: var(--radius-pill); background: var(--fam-check); color: var(--fam-check-ink); font-weight: 650; text-decoration: none;
}
.review-pill:hover { color: var(--fam-check-ink); text-decoration: underline; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; margin-top: 3.5rem; }
.section-head h2 { margin: 0; font-size: 1.9rem; }
.saved-count { text-align: center; margin-top: 0.75rem; }

/* Tool cards (the signature component) */
.tool-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.25rem; margin-top: 1.25rem; }
.tool-grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1.1rem; }
.tool-card {
  position: relative; display: flex; flex-direction: column; gap: 0.6rem; min-height: 13rem;
  padding: 1.5rem; border-radius: var(--radius-lg); text-decoration: none; color: var(--ink);
  transition: transform 0.18s ease-out, box-shadow 0.18s ease-out;
}
a.tool-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); color: var(--ink); }
.tool-card .tool-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.5rem; }
.tool-card .tool-name { font-family: var(--font-display); font-weight: 400; font-size: 1.4rem; line-height: 1.18; letter-spacing: -0.015em; }
.tool-card .tool-blurb { font-size: 0.95rem; line-height: 1.5; }
.tool-card .tool-foot { margin-top: auto; padding-top: 0.5rem; display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; }
.tool-card .tool-open { font-weight: 650; }
.tool-card .fam-icon { flex: none; width: 44px; height: 44px; }
.cols-4 .tool-card { min-height: 12rem; padding: 1.3rem; }
.cols-4 .tool-card .tool-name { font-size: 1.25rem; }
.fam-convert { background: var(--fam-convert); } .fam-convert, .fam-convert .tool-open { color: var(--fam-convert-ink); }
.fam-organize { background: var(--fam-organize); } .fam-organize, .fam-organize .tool-open { color: var(--fam-organize-ink); }
.fam-create { background: var(--fam-create); } .fam-create, .fam-create .tool-open { color: var(--fam-create-ink); }
.fam-check { background: var(--fam-check); } .fam-check, .fam-check .tool-open { color: var(--fam-check-ink); }
.fam-match { background: var(--fam-match); } .fam-match, .fam-match .tool-open { color: var(--fam-match-ink); }
a.tool-card.fam-convert:hover { color: var(--fam-convert-ink); } a.tool-card.fam-organize:hover { color: var(--fam-organize-ink); }
.tool-card.fam-vault, a.tool-card.fam-vault:hover { background: var(--brand-deep); color: #fff; }
.fam-vault .eyebrow { color: #d9cef7; } .fam-vault .tool-blurb { color: #e6dff8; }
/* Coming later: white, no link, no hover. Family shown by a dot. */
.tool-card.is-later { background: var(--surface); border: 1px solid var(--line); color: var(--ink); }
.tool-card.is-later .tool-blurb { color: var(--muted); }
.fam-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 0.45rem; vertical-align: 1px; }
.dot-convert { background: var(--fam-convert-dot); } .dot-organize { background: var(--fam-organize-dot); }
.dot-create { background: var(--fam-create-dot); } .dot-check { background: var(--fam-check-dot); } .dot-match { background: var(--fam-match-dot); }
.ink-convert { color: var(--fam-convert-ink); } .ink-organize { color: var(--fam-organize-ink); }
.ink-create { color: var(--fam-create-ink); } .ink-check { color: var(--fam-check-ink); } .ink-match { color: var(--fam-match-ink); }

/* Tools catalogue */
.tools-bar { display: flex; flex-wrap: wrap; gap: 0.75rem 1rem; align-items: center; margin-top: 1.75rem; }
.search-pill { display: flex; align-items: center; gap: 0.6rem; width: 26rem; max-width: 100%; min-height: 52px; padding: 0 1.1rem; background: var(--surface); border: 1.5px solid var(--line-strong); border-radius: var(--radius-pill); }
.search-pill:focus-within { border-color: var(--brand); }
.search-pill svg { flex: none; }
.search-pill input[type="search"] { border: 0; min-height: 48px; padding: 0; background: transparent; }
.search-pill input[type="search"]:focus-visible { outline: none; }
.chips { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.chip-btn { display: inline-flex; align-items: center; min-height: 44px; padding: 0 1rem; border-radius: var(--radius-pill); border: 1px solid var(--line); background: var(--surface); font: inherit; font-size: 0.95rem; font-weight: 550; color: var(--ink); cursor: pointer; }
.chip-btn:hover { border-color: var(--line-strong); }
.chip-btn[aria-pressed="true"] { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-deep); font-weight: 650; }
.dot-all { background: var(--ink); }
.family { margin-top: 3rem; }
.family-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 0.35rem 1rem; padding-bottom: 0.9rem; border-bottom: 1px solid var(--line); }
.family-head h2 { margin: 0; font-size: 1.9rem; }
.family-head p { margin: 0; color: var(--muted); }
.family-head .family-link { margin-left: auto; }
.tool-group { margin-top: 1.6rem; }
.tool-group-h { margin: 0 0 0.8rem; font-size: 1.15rem; font-family: var(--font-body, inherit); font-weight: 700; color: var(--muted); letter-spacing: 0.01em; }
.no-match { margin-top: 2.5rem; }

/* Tool hero (upload page opened from a tool) */
.tool-hero { margin: 0.5rem 0 0; padding: 2rem 2.25rem 2.25rem; border-radius: 28px; display: flex; justify-content: space-between; align-items: flex-end; gap: 1.5rem; }
.tool-hero h1 { margin: 0.4rem 0 0.7rem; color: inherit; }
.tool-hero .lead { color: inherit; margin: 0; max-width: 44rem; }
.tool-hero .back-link { font-weight: 650; text-decoration: none; color: inherit; display: inline-flex; min-height: 44px; align-items: center; }
.tool-hero .back-link:hover { text-decoration: underline; color: inherit; }
.tool-hero .hero-art { flex: none; width: 150px; height: 130px; }
.how { list-style: none; margin: 2rem 0 1.75rem; padding: 0; display: flex; justify-content: center; }
.how li { position: relative; flex: 1; max-width: 13rem; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 0.4rem; }
.how li + li::before { content: ""; position: absolute; top: 25px; right: calc(50% + 34px); width: calc(100% - 68px); height: 2px; background: var(--brand-line); }
.how-box { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; font-weight: 700; font-size: 1.1rem; background: var(--surface); color: var(--brand); border: 2px solid var(--brand); }
.how li:first-child .how-box { background: var(--brand); color: #fff; }
.how-text { display: flex; flex-direction: column; }
.how-title { font-weight: 650; }
.how-sub { font-size: 0.88rem; color: var(--muted); }

/* Tool pages */
.tool-hero .hero-status { margin: 1rem 0 0; }
.tool-hero .hero-status .badge { background: #fff; }
.tool-hero .hero-status .badge-dev { background: var(--dev-bg); }
.later-notice { margin-top: 1.5rem; }
.fact-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin-top: 0.5rem; }
.fact h3 { margin-bottom: 0.4rem; }
.fact p { margin: 0; font-size: 1.05rem; }
.meanwhile { margin-top: 1rem; }

/* Upload */
.dropzone {
  border: 2px dashed var(--brand-line); border-radius: 24px; background: var(--surface);
  padding: 2.5rem 1.25rem; text-align: center;
}
.dropzone .serif { font-size: 1.6rem; margin: 0 0 1rem; }
.dropzone.is-over { border-color: var(--brand); background: var(--brand-soft); }
.dropzone .btn { min-width: 16rem; }
.limits { margin: 0.75rem 0 0; color: var(--muted); font-size: 0.95rem; }
.file-list { list-style: none; margin: 1rem 0 0; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.file-list li { display: flex; align-items: center; gap: 0.75rem; padding: 0.6rem 0.75rem 0.6rem 1rem; border-top: 1px solid var(--line); }
.file-list li:first-child { border-top: 0; }
.file-name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.file-size { color: var(--muted); font-size: 0.9rem; white-space: nowrap; }
.file-list-head { display: flex; justify-content: space-between; align-items: baseline; margin-top: 1.25rem; }
.file-list-head h2 { margin: 1.25rem 0 0; font-size: 1.3rem; }
.notice { border-radius: var(--radius); padding: 0.9rem 1.1rem; margin: 1rem 0; border: 1px solid; }
.notice-warn { background: var(--warn-bg); color: var(--warn); border-color: #eed48a; }
.notice-bad { background: var(--bad-bg); color: var(--bad); border-color: #efb9b4; }
.notice-info { background: var(--brand-soft); color: var(--brand-deep); border-color: var(--brand-line); }
.notice-dev { background: #fff6cc; color: var(--dev); border-color: var(--dev-bg-2); border-left: 8px solid var(--dev-bg); }
.notice p:last-child, .notice ul:last-child { margin-bottom: 0; }

fieldset { border: 0; padding: 0; margin: 2.25rem 0 0; min-width: 0; }
legend { font-family: var(--font-display); font-size: 1.5rem; font-weight: 380; letter-spacing: -0.02em; margin-bottom: 0.8rem; padding: 0; }
.outcomes { display: grid; gap: 0.75rem; }
.outcome { display: flex; gap: 0.9rem; align-items: flex-start; background: var(--surface); border: 2px solid var(--line); border-radius: 16px; padding: 1rem 1.2rem; cursor: pointer; }
.outcome:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.outcome input { width: 1.4rem; height: 1.4rem; margin: 0.15rem 0 0; accent-color: var(--brand); flex: none; }
.outcome strong { display: block; font-size: 1.05rem; }
.outcome span { color: var(--muted); font-size: 0.95rem; }
.outcome .outcome-note { display: block; margin-top: 0.35rem; color: var(--brand-deep); font-size: 0.9rem; }
details.more { margin-top: 1.25rem; }
details.more summary { cursor: pointer; color: var(--brand); font-weight: 650; min-height: 44px; display: inline-flex; align-items: center; }
details.more .card { margin-top: 0.5rem; }

/* Progress: a storyboard of connected steps */
.stages { list-style: none; padding: 0.5rem 0; margin: 1.5rem 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); }
.stage { position: relative; display: grid; grid-template-columns: 2.5rem 1fr; gap: 0.9rem; padding: 0.85rem 1.25rem; align-items: start; }
.stage + .stage::before { content: ""; position: absolute; left: calc(1.25rem + 1.25rem - 1px); top: -0.6rem; height: 1.2rem; width: 2px; background: var(--brand-line); }
.stage-mark { width: 2.5rem; height: 2.5rem; border-radius: 12px; display: grid; place-items: center; font-weight: 700; font-size: 1rem; border: 2px solid var(--line-strong); color: var(--muted); background: var(--surface); position: relative; z-index: 1; }
.stage.is-done .stage-mark { background: var(--good); border-color: var(--good); color: #fff; }
.stage.is-active .stage-mark { background: var(--brand); border-color: var(--brand); color: #fff; }
.stage.is-problem .stage-mark { background: var(--bad); border-color: var(--bad); color: #fff; }
.stage-title { font-weight: 650; padding-top: 0.45rem; }
.stage-state { font-weight: 650; font-size: 0.9rem; margin-left: 0.5rem; }
.stage.is-done .stage-state { color: var(--good); }
.stage.is-active .stage-state { color: var(--brand); }
.stage.is-problem .stage-state { color: var(--bad); }
.stage.is-waiting .stage-state { color: var(--muted); }
.stage-detail { color: var(--muted); font-size: 0.95rem; }
.meter { height: 10px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-top: 0.4rem; max-width: 24rem; }
.meter > span { display: block; height: 100%; background: var(--brand); transition: width 0.3s ease; }

/* Status badges: text + shape, never colour alone. */
.badge { display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.82rem; font-weight: 650; padding: 0.2rem 0.7rem; border-radius: 99px; border: 1px solid transparent; white-space: nowrap; }
.badge-good { background: var(--good-bg); color: var(--good); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-bad { background: var(--bad-bg); color: var(--bad); }
.badge-info, .badge-busy { background: var(--info-bg); color: var(--info); }
.badge-dev { background: var(--dev-bg); color: var(--dev); }
.badge-neutral { background: #efece7; color: var(--muted); }
.tool-card .badge-good { background: #fff; }

/* Review */
.review-list { display: grid; gap: 1rem; margin-top: 1rem; }
.review-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 1.25rem 1.4rem; }
.review-card.is-needs { box-shadow: inset 6px 0 0 var(--warn); }
.review-card.is-approved { box-shadow: inset 6px 0 0 var(--good); }
.review-flow { display: grid; grid-template-columns: 1fr auto 1fr; gap: 0.75rem 1rem; align-items: start; }
.review-arrow { padding-top: 2rem; color: var(--muted); font-size: 1.3rem; }
.review-orig { overflow-wrap: anywhere; }
.label { display: block; font-weight: 650; margin-bottom: 0.3rem; }
.hint { display: block; color: var(--muted); font-size: 0.9rem; margin-bottom: 0.3rem; }
input[type="text"], input[type="search"], input[type="password"], input[type="date"], select {
  width: 100%; font: inherit; min-height: 48px; padding: 10px 14px;
  border: 1.5px solid #9d94ad; border-radius: 10px; background: #fff; color: var(--ink);
}
input[type="text"]:focus-visible, input[type="search"]:focus-visible, input[type="password"]:focus-visible, input[type="date"]:focus-visible, select:focus-visible { border-color: var(--brand); }
.field + .field { margin-top: 0.9rem; }
.questions { margin: 0.9rem 0 0; padding: 0.75rem 1rem 0.75rem 2.25rem; background: var(--warn-bg); color: var(--warn); border-radius: var(--radius); }
.review-meta { color: var(--muted); font-size: 0.9rem; margin: 0.5rem 0 0; }

/* Review v2: preview beside the fields */
.review-grid { display: grid; grid-template-columns: minmax(0, 15rem) minmax(0, 1fr); gap: 1rem 1.5rem; align-items: start; }
.review-grid.no-preview { grid-template-columns: 1fr; }
.preview { margin: 0.5rem 0 0; }
.preview img { display: block; width: 100%; height: auto; max-height: 18rem; object-fit: contain; object-position: top; background: #fff; border: 1px solid var(--line); border-radius: 10px; }
.preview figcaption { margin-top: 0.35rem; font-size: 0.9rem; }
.notice-good { background: var(--good-bg); color: var(--good); border-color: #a9d3b5; }
.check { display: flex; align-items: center; gap: 0.5rem; min-height: 44px; cursor: pointer; }
.check input { width: 1.25rem; height: 1.25rem; accent-color: var(--brand); }
.section-list { list-style: none; padding: 0; margin: 0 0 0.5rem; display: grid; gap: 0.5rem; }
.section-list li { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.6rem 0.9rem; overflow-wrap: anywhere; }
.table-scroll { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); }
.txn-table tr.is-excluded td { text-decoration: line-through; color: var(--muted); }
.txn-table tr.is-editing td { background: var(--brand-soft); }
.row-check { font-size: 0.85rem; color: var(--warn); margin-top: 0.2rem; }
.row-edit-grid { display: grid; grid-template-columns: 10rem minmax(12rem, 1fr) 8rem 8rem 9rem; gap: 0.5rem 0.75rem; }
.row-edit-grid .field + .field { margin-top: 0; }
.doc-layout { display: grid; grid-template-columns: minmax(0, 1fr) 16rem; gap: 1.5rem; align-items: start; }
.doc-side { position: sticky; top: 1rem; }
.output-row { flex-wrap: wrap; }
.output-actions { display: inline-flex; gap: 0.5rem; flex-wrap: wrap; }
.output-row > .card { flex-basis: 100%; margin-top: 0.75rem; } /* QuickBooks / Xero panel under a statement */
.plain { padding-left: 1.2rem; }
h2.flush { margin-top: 0; }

/* My Documents */
.toolbar { display: grid; grid-template-columns: 1fr auto; gap: 0.75rem; align-items: end; margin: 1rem 0; }
.segmented { display: inline-flex; gap: 4px; padding: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-pill); }
.segmented a { padding: 0 18px; text-decoration: none; font-weight: 650; color: var(--ink); min-height: 44px; display: inline-flex; align-items: center; border-radius: var(--radius-pill); }
.segmented a[aria-current="page"] { background: var(--brand); color: #fff; }
.doc-table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; }
.doc-table th, .doc-table td { text-align: left; padding: 0.8rem 1rem; border-top: 1px solid var(--line); vertical-align: top; }
.doc-table thead th { border-top: 0; background: var(--surface-2); font-size: 0.8rem; font-weight: 650; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.doc-table tbody tr:hover td { background: #faf8fe; }
.doc-table td a { font-weight: 650; overflow-wrap: anywhere; }
.empty { text-align: center; padding: 2.5rem 1rem; }

/* Document detail */
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 0.5rem 1.25rem; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: 0.35rem 0; }
.txn-table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.txn-table th, .txn-table td { padding: 0.55rem 0.7rem; border-top: 1px solid var(--line); text-align: left; }
.txn-table thead th { background: var(--surface-2); border-top: 0; font-size: 0.8rem; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.txn-table td.num, .txn-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.txn-table tr.is-flagged td { background: var(--warn-bg); }
.back { display: inline-flex; align-items: center; min-height: 44px; margin-top: 0.75rem; }
.history { list-style: none; padding: 0; margin: 0; font-size: 0.95rem; }
.history li { padding: 0.4rem 0; border-top: 1px solid var(--line); overflow-wrap: anywhere; }

.loading { color: var(--muted); padding: 2rem 0; }

/* Tablet */
@media (max-width: 1024px) {
  .tool-grid.cols-4 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .tool-grid, .tool-grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tool-hero .hero-art { display: none; }
}
@media (max-width: 900px) and (min-width: 641px) {
  .row-edit-grid { grid-template-columns: 1fr 1fr; }
  .doc-layout { grid-template-columns: 1fr; }
  .doc-side { position: static; max-width: 18rem; }
}

/* Phone: stack everything, keep big targets. */
@media (max-width: 640px) {
  html { font-size: 106.25%; }
  .wrap { padding: 0 16px; }
  h1 { font-size: 2rem; }
  .header-row { gap: 0.6rem; min-height: 0; }
  .brand-name { font-size: 1.45rem; }
  .account { order: 2; }
  .main-nav { order: 3; width: 100%; justify-content: space-between; }
  .main-nav a { flex: 1 1 auto; justify-content: center; padding: 0 10px; font-size: 0.92rem; white-space: nowrap; }
  .home-hero { text-align: left; padding-top: 0; }
  .start-card { padding: 1.75rem 1.1rem; }
  .start-card .btn, .home-primary .btn, .dropzone .btn { width: 100%; min-width: 0; }
  .tool-grid, .tool-grid.cols-4 { grid-template-columns: 1fr; }
  .tool-card, .cols-4 .tool-card { min-height: 0; }
  .search-pill { width: 100%; }
  .tool-hero { padding: 1.5rem 1.25rem 1.75rem; border-radius: 22px; }
  .fact-grid { grid-template-columns: 1fr; }
  .how { flex-direction: column; align-items: stretch; gap: 0.75rem; }
  .how li { flex-direction: row; max-width: none; text-align: left; gap: 0.8rem; }
  .how li + li::before { display: none; }
  .how-box { width: 44px; height: 44px; flex: none; }
  .how-text { display: flex; flex-direction: column; }
  .review-flow { grid-template-columns: 1fr; }
  .review-arrow { padding-top: 0; transform: rotate(90deg); justify-self: start; }
  .toolbar { grid-template-columns: 1fr; }
  .actions .btn { width: 100%; }
  .doc-table thead { display: none; }
  .doc-table, .doc-table tbody, .doc-table tr, .doc-table td { display: block; width: 100%; }
  .doc-table tr { border-top: 1px solid var(--line); padding: 0.5rem 0; }
  .doc-table tr:first-child { border-top: 0; }
  .doc-table td { border: 0; padding: 0.2rem 1rem; }
  .doc-table td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); font-size: 0.85rem; }
  .txn-table thead { display: none; }
  .txn-table, .txn-table tbody, .txn-table tr, .txn-table td { display: block; width: 100%; }
  .txn-table tr { border-top: 1px solid var(--line); padding: 0.4rem 0; }
  .txn-table td { border: 0; padding: 0.15rem 0.25rem; text-align: left !important; }
  .txn-table td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); font-size: 0.85rem; }
  .facts { grid-template-columns: 1fr; gap: 0.1rem; }
  .review-grid { grid-template-columns: 1fr; }
  /* Phones: show the top of the page (where names and dates are); full view is one tap away. */
  .preview img { max-height: 11rem; object-fit: cover; object-position: top; }
  .txn-table td:empty, .doc-table td:empty { display: none; }
  .doc-layout { grid-template-columns: 1fr; }
  .doc-side { position: static; order: -1; }
  .row-edit-grid { grid-template-columns: 1fr; }
  .table-scroll { overflow-x: visible; border: 0; background: transparent; }
  .facts dd { margin-bottom: 0.6rem; }
  .account-panel { right: -8px; }
  .footer-line { font-size: 1.1rem; }
}

/* Merge and share */
.merge-bar { margin: 1rem 0; align-items: center; }
.share { margin: 1.5rem 0; }
.share-form fieldset { margin: 0.75rem 0 0; }
.share-form legend { font-family: var(--font-text); font-size: 1rem; font-weight: 650; letter-spacing: 0; margin-bottom: 0.4rem; }
.choices { display: flex; flex-wrap: wrap; gap: 0.5rem 1.25rem; }
.choice { display: inline-flex; align-items: center; gap: 0.35rem; min-height: 44px; cursor: pointer; }
.choice input { width: 1.15rem; height: 1.15rem; accent-color: var(--brand); }
.share-url-row { display: flex; gap: 0.5rem; align-items: center; }
.share-url { flex: 1; min-width: 0; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 0.9rem; }
.share-list { list-style: none; padding: 0; margin: 0.5rem 0 0; }
.share-item { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; padding: 0.6rem 0; border-top: 1px solid var(--line); }
.share-item:first-child { border-top: 0; }
.share-page { background: var(--bg); }
.share-main { max-width: 40rem; margin: 0 auto; padding: 2.5rem 16px 4rem; }
.share-brand { font-family: var(--font-display); color: var(--brand); font-size: 1.1rem; margin: 0 0 1.5rem; }
.share-main .file-list li { justify-content: space-between; }
@media (max-width: 640px) {
  .share-url-row { flex-direction: column; align-items: stretch; }
  .share-main .file-list .file-name { flex: 1 1 100%; overflow-wrap: anywhere; }
}

/* PDF tools (merge, split). Family colours reuse Organize. */
.fam-pdf { background: var(--fam-organize); } .fam-pdf, .fam-pdf .tool-open { color: var(--fam-organize-ink); }
a.tool-card.fam-pdf:hover { color: var(--fam-organize-ink); }
.dot-pdf { background: var(--fam-organize-dot); } .ink-pdf { color: var(--fam-organize-ink); }
.back-link { display: inline-flex; align-items: center; min-height: 44px; margin-top: 0.75rem; font-weight: 650; }
.field-error { display: block; color: var(--bad); font-size: 0.92rem; font-weight: 600; margin: 0.35rem 0 0; }
.field-error:empty { display: none; }

.pdf-choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: 1.25rem; margin: 1.75rem 0; }
.pdf-choice {
  display: flex; flex-direction: column; gap: 0.4rem; padding: 1.75rem; min-height: 15rem;
  background: var(--fam-organize); color: var(--fam-organize-ink); border-radius: 24px; text-decoration: none;
  box-shadow: var(--shadow-card); transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.pdf-choice:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); color: var(--fam-organize-ink); }
.pdf-choice-art { width: 96px; height: 72px; margin-bottom: 0.5rem; }
.pdf-choice-name { font-family: var(--font-display); font-size: 2rem; line-height: 1.1; letter-spacing: -0.02em; }
.pdf-choice-text { font-size: 1.1rem; color: var(--ink); }
.pdf-group { margin-top: 2rem; }
.pdf-group-h { margin: 0 0 0.25rem; font-size: 1.35rem; }
.pdf-group .pdf-choices { margin-top: 0.9rem; }
.pdf-choices-sm { grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr)); gap: 1rem; }
.pdf-choice-sm { min-height: 0; padding: 1.1rem 1.2rem; }
.pdf-choice-sm .pdf-choice-art { width: 72px; height: 54px; margin-bottom: 0.2rem; }
.pdf-choice-sm .pdf-choice-name { font-size: 1.3rem; }
.pdf-choice-sm .pdf-choice-text { font-size: 0.98rem; }

.pdf-drop .or-docs { margin-top: 0.9rem; }
.doc-picker { margin-top: 1rem; }
.doc-picker h2 { margin-top: 0; font-size: 1.3rem; }
.doc-pick-list { list-style: none; margin: 0.5rem 0 0; padding: 0; max-height: 22rem; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--radius); }
.doc-pick-list li + li { border-top: 1px solid var(--line); }
.doc-pick-row { display: flex; gap: 0.8rem; align-items: center; padding: 0.7rem 0.9rem; min-height: 56px; cursor: pointer; }
.doc-pick-row:hover { background: var(--brand-soft); }
.doc-pick-row input { width: 1.3rem; height: 1.3rem; accent-color: var(--brand); flex: none; }
.doc-pick-text { display: flex; flex-direction: column; min-width: 0; }

.pdf-list { list-style: none; margin: 0.5rem 0 0; padding: 0; display: grid; gap: 0.75rem; }
.pdf-item {
  display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto; gap: 0.9rem; align-items: center;
  background: var(--surface); border: 1.5px solid var(--line); border-radius: 16px; padding: 0.75rem 1rem;
}
.pdf-item[draggable="true"] { cursor: grab; }
.pdf-item.is-dragging { opacity: 0.5; border-style: dashed; }
.pdf-item.is-problem { border-color: #efb9b4; background: var(--bad-bg); }
.pdf-pos {
  width: 2.1rem; height: 2.1rem; border-radius: 50%; background: var(--brand); color: #fff;
  display: grid; place-items: center; font-weight: 700;
}
.pdf-thumb { width: 64px; height: 82px; object-fit: contain; object-position: top; background: #fff; border: 1px solid var(--line); border-radius: 6px; flex: none; }
.pdf-thumb-empty { display: grid; place-items: center; color: var(--muted); font-size: 0.8rem; font-weight: 700; background: var(--surface-2); }
.pdf-item-text { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; }
.pdf-item-text .file-name { font-weight: 650; }
.pdf-problem { color: var(--bad); font-weight: 600; }
.pdf-note { color: var(--warn); }
.pdf-item-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; justify-content: flex-end; }
.pdf-order-note { margin-top: 1rem; }
.pdf-status { font-weight: 650; margin: 0; }
.pdf-status:empty { display: none; }
.pdf-why { margin: 0.15rem 0 0; }

/* The main action stays in reach while the list scrolls. */
.pdf-actionbar {
  position: sticky; bottom: 0; z-index: 5; margin: 1.5rem -24px 0; padding: 0.9rem 0;
  background: rgba(252, 249, 245, 0.97); border-top: 1px solid var(--line);
}
.pdf-actionbar-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }

.split-file { margin-top: 1.25rem; }
.split-file-row { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.split-file-text { flex: 1; min-width: 12rem; }
.split-file-text h2 { margin: 0; font-size: 1.35rem; }
.split-count { font-family: var(--font-display); font-size: 1.6rem; margin: 0.2rem 0 0; color: var(--brand); }
.pdf-modes { border: 0; padding: 0; margin: 1.75rem 0 0; }
.pdf-modes legend { font-family: var(--font-display); font-size: 1.5rem; margin-bottom: 0.75rem; padding: 0; }
/* single-PDF tools (public/pdf-more.js) */
.pdf-opts { margin: 1.25rem 0; max-width: 46rem; }
.pdf-opts .field { margin-bottom: 1rem; }
.pdf-opts-group { border: 0; padding: 0; margin: 0 0 1.25rem; }
.pdf-opts-group legend { font-weight: 700; font-size: 1.08rem; margin-bottom: 0.5rem; padding: 0; }
.pdf-opt-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: 0.6rem; }
.pdf-opt { display: flex; gap: 0.7rem; align-items: flex-start; background: var(--surface); border: 2px solid var(--line); border-radius: 14px; padding: 0.8rem 1rem; cursor: pointer; min-height: 44px; }
.pdf-opt:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.pdf-opt input { width: 1.25rem; height: 1.25rem; margin: 0.15rem 0 0; accent-color: var(--brand); flex: none; }
.pdf-opt strong { display: block; }
.pdf-opt .small { display: block; }
.pw-row { display: flex; gap: 0.5rem; align-items: center; }
.pw-row .input { flex: 1; min-width: 0; }
.check-row { display: flex; align-items: center; gap: 0.5rem; min-height: 44px; }
.check-row input { width: 1.2rem; height: 1.2rem; accent-color: var(--brand); }
.pdf-mode-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.75rem; }
.pdf-mode { display: flex; gap: 0.8rem; align-items: flex-start; background: var(--surface); border: 2px solid var(--line); border-radius: 16px; padding: 1rem 1.1rem; cursor: pointer; min-height: 44px; }
.pdf-mode.is-on, .pdf-mode:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.pdf-mode input { width: 1.4rem; height: 1.4rem; margin: 0.1rem 0 0; accent-color: var(--brand); flex: none; }
.pdf-mode strong { display: block; font-size: 1.08rem; }
.pdf-mode span span { color: var(--muted); font-size: 0.95rem; }
.pdf-explain { margin: 1.25rem 0 0.5rem; font-size: 1.05rem; }
.pdf-modes + div > .field { margin-top: 1.5rem; }
.btn[hidden] { display: none; }
.main-nav[hidden] { display: none; } /* signed out (sign-in, public pricing): no app nav */
.main-nav a[hidden] { display: none; } /* e.g. Clients, for a practice only */
.flush-bottom { margin-bottom: 0; }
.result-foot { margin-top: 1.5rem; }
.group-list { list-style: none; padding: 0; margin: 0.5rem 0 1rem; display: grid; gap: 0.9rem; max-width: 34rem; }
.group-input { display: flex; gap: 0.5rem; align-items: center; }
#extract-pages { max-width: 34rem; }

.page-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 0.9rem; margin: 0.75rem 0 0; }
.page-tile {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 0.35rem; padding: 0.5rem;
  background: var(--surface); border: 2px solid var(--line); border-radius: 12px; font: inherit; color: var(--ink);
}
button.page-tile { cursor: pointer; }
button.page-tile:hover { border-color: var(--brand-line); }
.page-tile.is-on { border-color: var(--brand); background: var(--brand-soft); box-shadow: inset 0 0 0 1px var(--brand); }
.page-tile.is-out { opacity: 0.55; }
.page-tile.is-in { border-color: var(--brand-line); }
.page-tile img { width: 100%; aspect-ratio: 8.5 / 11; object-fit: contain; background: #fff; border: 1px solid var(--line); border-radius: 4px; }
.page-pic-empty { display: block; width: 100%; aspect-ratio: 8.5 / 11; background: var(--surface-2); border-radius: 4px; }
.page-num { font-weight: 650; font-size: 0.95rem; }
.page-orig { color: var(--muted); font-weight: 500; }
.arr-summary { margin-top: 1.25rem; }
.arr-summary h2 { margin-top: 0; }
.arr-head-actions { display: inline-flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.page-dest { display: block; color: var(--brand); font-weight: 600; text-align: center; }
.page-check {
  position: absolute; top: 0.35rem; right: 0.35rem; width: 1.7rem; height: 1.7rem; border-radius: 50%;
  background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 700;
}

.pdf-result .lead strong { color: var(--ink); }
.result-actions-main .btn-large { min-width: 15rem; }
.result-file { margin-top: 1rem; }
.result-name { font-weight: 650; font-size: 1.15rem; margin: 0; }
.result-list { list-style: none; padding: 0; margin: 0.5rem 0 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.result-list li { display: flex; gap: 0.75rem; align-items: center; padding: 0.7rem 1rem; border-top: 1px solid var(--line); }
.result-list li:first-child { border-top: 0; }
.result-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.result-text p { margin: 0.2rem 0 0; }
.result-actions { display: flex; gap: 0.4rem; flex: none; }
.rename-field { margin-top: 1.25rem; max-width: 34rem; }
.save-folder { margin-top: 1rem; max-width: 34rem; }
.save-folder select { width: 100%; }
.naming-note { margin: 0.25rem 0 0.5rem; }
.rename-row { display: flex; gap: 0.5rem; align-items: center; }
.made-from { padding-left: 1.25rem; }
.made-from li { margin: 0.25rem 0; overflow-wrap: anywhere; }
.pdf-doc-actions { margin-top: 0; }

/* Merge: page order */
.arr-offer { margin-top: 1.5rem; }
.arr-offer h2, .arr-head h2 { margin: 0 0 0.4rem; }
.arr { margin-top: 1.75rem; }
.arr-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.arr-toolbar {
  position: sticky; top: 0; z-index: 4; margin: 0.75rem 0; padding: 0.75rem 1rem;
  background: var(--brand-soft); border: 1.5px solid var(--brand-line); border-radius: 14px;
}
.arr-hint { color: var(--brand-deep); font-weight: 600; }
.arr-sel { margin: 0 0 0.5rem; }
.arr-buttons { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.arr-goto { display: inline-flex; align-items: center; gap: 0.4rem; }
.arr-goto input.arr-pos { width: 4.5rem; min-height: 44px; padding: 6px 10px; text-align: center; font-weight: 700; }
.arr-tile { position: relative; padding: 0; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; cursor: grab; }
.arr-pick {
  display: flex; flex-direction: column; align-items: center; gap: 0.35rem; width: 100%; padding: 0.5rem;
  background: transparent; border: 0; border-radius: 10px; font: inherit; color: inherit; cursor: inherit;
}
.arr-pick img { pointer-events: none; }
.pdf-item[data-drag="1"] { cursor: grab; user-select: none; -webkit-user-select: none; }
.is-dragging { opacity: 0.35; }
body.is-drag-active, body.is-drag-active * { cursor: grabbing !important; }
.drag-ghost {
  position: fixed; left: 0; top: 0; z-index: 1000; pointer-events: none; margin: 0;
  box-shadow: var(--shadow-lift); opacity: 0.75; background: var(--surface); scale: 0.7; transform-origin: 0 0;
}
.arr-tile.drop-before, .arr-tile.drop-after { background: var(--brand-soft); border-color: var(--brand); }
/* Where the dragged item will land. */
.arr-tile.drop-before::before, .arr-tile.drop-after::after {
  content: ""; position: absolute; top: -2%; bottom: -2%; width: 6px; border-radius: 3px; background: var(--brand); z-index: 2;
  box-shadow: 0 0 0 3px rgba(84, 47, 156, 0.25);
}
.arr-tile.drop-before::before { left: -9px; }
.arr-tile.drop-after::after { right: -9px; }
.pdf-item { position: relative; }
.pdf-item.drop-before::before, .pdf-item.drop-after::after {
  content: ""; position: absolute; left: 1%; right: 1%; height: 5px; border-radius: 3px; background: var(--brand);
}
.pdf-item.drop-before::before { top: -9px; }
.pdf-item.drop-after::after { bottom: -9px; }
/* The selected page's number, as a box to type in. */
.arr-tile input.arr-no-input, .arr-tile.is-on input.arr-no-input {
  width: 3.4rem; min-height: 40px; height: 40px; padding: 0 0.4rem; text-align: center; font: inherit; font-weight: 700;
  background: #fff; color: var(--brand-deep); border: 2px solid var(--brand); border-radius: 10px; top: 0.3rem; left: 0.3rem; z-index: 3;
}
.arr-no {
  position: absolute; top: 0.35rem; left: 0.35rem; min-width: 1.7rem; height: 1.7rem; padding: 0 0.35rem; border-radius: 99px;
  background: var(--ink); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 0.85rem;
}
.arr-tile.is-on .arr-no { background: var(--brand); }
.file-tag { display: inline-block; padding: 0 0.4rem; border-radius: 6px; font-size: 0.78rem; font-weight: 700; }
.tag-0 { background: #e2edf6; color: #1d4e78; } .tag-1 { background: #fde7d6; color: #7a3310; } .tag-2 { background: #ddf0e4; color: #1e5b3a; }
.tag-3 { background: #fff1c9; color: #6b4a00; } .tag-4 { background: #ece6fb; color: #45278a; } .tag-5 { background: #fbe4e2; color: #9e2424; }
/* A turned page: the picture is turned to match (square box so it fits either way). */
.arr-pic { display: grid; place-items: center; width: 100%; aspect-ratio: 1; overflow: hidden; }
.arr-pic img, .arr-pic .page-pic-empty { width: 77%; transition: transform 0.15s ease; }
.arr-pic.rot-90 img, .arr-pic.rot-90 .page-pic-empty { transform: rotate(90deg); }
.arr-pic.rot-180 img, .arr-pic.rot-180 .page-pic-empty { transform: rotate(180deg); }
.arr-pic.rot-270 img, .arr-pic.rot-270 .page-pic-empty { transform: rotate(270deg); }
.arr-turn { color: var(--brand); font-weight: 700; white-space: nowrap; }
.arr-no { z-index: 1; }
.pdf-pos.file-tag { display: grid; place-items: center; border-radius: 50%; font-size: 1rem; padding: 0; }
.arr-removed { margin-top: 1.25rem; }
.arr-removed ul { list-style: none; padding: 0; margin: 0.4rem 0 0; display: grid; gap: 0.4rem; }
.arr-removed li { display: flex; align-items: center; gap: 0.75rem; }

@media (max-width: 900px) {
  .pdf-mode-list { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .pdf-choices { grid-template-columns: 1fr; }
  .pdf-choice { min-height: 0; padding: 1.35rem; }
  .pdf-choice-name { font-size: 1.7rem; }
  .pdf-item { grid-template-columns: auto auto minmax(0, 1fr); padding: 0.75rem; }
  .pdf-thumb { width: 52px; height: 66px; }
  .pdf-item-actions { grid-column: 1 / -1; justify-content: stretch; }
  .pdf-item-actions .btn { flex: 1 1 0; padding-left: 8px; padding-right: 8px; }
  .pdf-actionbar { margin: 1.25rem -16px 0; padding: 0.75rem 0; }
  .pdf-actionbar-row { flex-direction: column; align-items: stretch; gap: 0.5rem; }
  .pdf-actionbar .btn { width: 100%; }
  .page-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.5rem; }
  .page-tile { padding: 0.35rem; }
  .page-num { font-size: 0.85rem; }
  .result-list li { flex-wrap: wrap; }
  .result-actions { width: 100%; }
  .result-actions .btn { flex: 1; }
  .result-actions-main .btn-large { min-width: 0; }
  .rename-row { flex-wrap: wrap; }
  .rename-row input { flex: 1 1 12rem; }
  /* Phones: one compact row of icon buttons (names stay for screen readers). */
  .arr-toolbar { padding: 0.5rem 0.6rem; margin: 0.5rem 0; }
  .arr-sel { margin-bottom: 0.35rem; font-size: 0.95rem; }
  .arr-sel-more, .arr-lbl { display: none; }
  .arr-buttons { gap: 0.3rem; }
  .arr-buttons .btn { flex: 1 1 0; min-width: 44px; padding: 0 4px; font-size: 1.15rem; }
  .arr-goto { flex: 0 0 auto; order: 2; }
  .arr-pos-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .arr-goto input.arr-pos { width: 3.2rem; padding: 4px; }
  .arr-buttons [data-act="earlier"], .arr-buttons [data-act="later"] { order: 1; }
  .arr-buttons [data-act="left"], .arr-buttons [data-act="right"], .arr-buttons [data-act="remove"] { order: 3; }
  .arr-turn-file, .arr-done { order: 4; flex: 1 1 auto !important; font-size: 0.9rem !important; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
  a.tool-card:hover, .pdf-choice:hover { transform: none; }
}

/* ---- Client folders (My Documents) ---- */
.folders { margin: 1rem 0 0.5rem; }
.crumbs { list-style: none; display: flex; flex-wrap: wrap; gap: 0.25rem; padding: 0; margin: 0 0 0.75rem; font-weight: 600; }
.crumbs li + li::before { content: "›"; color: var(--muted); margin-right: 0.25rem; }
.crumbs a { display: inline-flex; align-items: center; min-height: 44px; }
.crumbs [aria-current] { display: inline-flex; align-items: center; min-height: 44px; color: var(--ink); }
.folder-tiles { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr)); gap: 0.75rem; }
.folder-tile { display: grid; grid-template-columns: 2.25rem 1fr; grid-template-rows: auto auto; column-gap: 0.75rem; align-items: center;
  padding: 0.85rem 1rem; min-height: 64px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  text-decoration: none; color: var(--ink); }
.folder-tile:hover { border-color: var(--primary); }
.folder-tile .folder-icon { grid-row: 1 / span 2; width: 2.25rem; height: 2.25rem; color: var(--primary); }
.folder-tile .folder-name { font-weight: 700; overflow-wrap: anywhere; }
.folder-tile .folder-count { color: var(--muted); font-size: 0.9rem; }
.folder-tile.is-unfiled { grid-template-columns: 1fr; }
.folder-tile.is-unfiled .folder-name, .folder-tile.is-unfiled .folder-count { grid-column: 1; }
.toolbar-single { grid-template-columns: 1fr; max-width: 32rem; }
.client-field { margin-top: 1.5rem; max-width: 36rem; }

.row-fixed { font-size: 0.85rem; color: var(--muted); margin-top: 0.2rem; }

/* Deleting */
.btn-danger { background: var(--bad); color: #fff; }
.btn-danger:hover { background: #8f1f16; color: #fff; }
.btn-danger-quiet { background: transparent; color: var(--bad); box-shadow: inset 0 0 0 1.5px var(--bad); }
.btn-danger-quiet:hover { background: var(--bad-bg); color: var(--bad); }
.delete-box { margin: 0.75rem 0; }
.delete-bar { align-items: center; }
.danger-zone { margin-top: 2rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.col-pick { width: 2.5rem; }
.col-pick input { width: 20px; height: 20px; }
.dup-group { margin: 1rem 0; }
.dup-group h2 { font-size: 1.05rem; margin-top: 0; }

/* Loan schedule & journal (public/loan.js) */
.loan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 0 1.5rem; }
.loan-term-row { display: flex; gap: 1rem; }
.loan-term-part { display: flex; align-items: center; gap: 0.4rem; }
.loan-term-part .input { width: 5.5rem; }
.loan-results { margin-top: 2rem; }
.loan-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); gap: 0.8rem; margin: 1rem 0; }
.loan-card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 1rem 1.2rem; display: flex; flex-direction: column; gap: 0.2rem; }
.loan-card strong { font-size: 1.5rem; font-family: var(--font-display); }
.table-wrap { overflow-x: auto; max-width: 100%; margin: 0.5rem 0 1rem; }
.loan-table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
.loan-table th, .loan-table td { padding: 0.45rem 0.7rem; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.loan-table .num, .loan-table td { text-align: right; }
.loan-table thead th { font-size: 0.9rem; color: var(--muted); }
