/* Free PDF Toolkit with no upload styles.
   Kept in an external file so the Content-Security-Policy can use style-src 'self'
   (no 'unsafe-inline'). Fonts are self-hosted: no request ever goes to Google Fonts. */

/* Archivo (variable, wght 100-900) - SIL OFL 1.1, from @fontsource-variable/archivo 5.3.0. See docs/VENDOR.md */
@font-face {
  font-family: 'Archivo';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url(vendor/archivo-5.3.0/archivo-latin-ext-wght-normal.woff2) format('woff2');
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
}
@font-face {
  font-family: 'Archivo';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url(vendor/archivo-5.3.0/archivo-latin-wght-normal.woff2) format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}

:root {
  --bg: #f4f4f2;
  --surface: #ffffff;
  --surface-2: #ececea;
  --ink: #1b1b19;
  --muted: #63635d;
  --faint: #9a9a93;
  --line: #dededb;
  --accent: #cf2417;
  --accent-ink: #ffffff;
  --accent-soft: #fbeae8;
  --accent-hover: #a91d12;
  --ok: #1d7a3a;
  --shadow: 0 1px 2px rgba(20, 20, 18, .06), 0 8px 24px rgba(20, 20, 18, .07);
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141413;
    --surface: #1e1e1c;
    --surface-2: #282826;
    --ink: #f0efeb;
    --muted: #a8a8a0;
    --faint: #74746c;
    --line: #343432;
    --accent: #ff5142;
    --accent-ink: #1c0a08;
    --accent-soft: #3a1a16;
    --accent-hover: #ff6f61;
    --ok: #4cc06e;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
}
.wrap { max-width: 1120px; margin: 0 auto; padding: 28px 20px 64px; }

/* ---------- intro ---------- */
.intro { max-width: 720px; }
.intro h1 {
  font-size: clamp(30px, 5.4vw, 46px);
  line-height: 1.05;
  letter-spacing: -0.02em;
  font-weight: 800;
  margin: 6px 0 14px;
}
.intro h1 .no { color: var(--accent); }
.lede { font-size: 17px; color: var(--muted); margin: 0 0 18px; max-width: 620px; }
.lede strong { color: var(--ink); font-weight: 600; }
.points { display: flex; flex-wrap: wrap; gap: 8px 22px; list-style: none; margin: 0; padding: 0; }
.points li { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 500; color: var(--muted); }
.points svg { flex: none; color: var(--ok); }

/* ---------- drop zone ---------- */
.dropzone {
  margin-top: 30px;
  border: 2px dashed var(--line);
  border-radius: 14px;
  background: var(--surface);
  padding: 40px 24px;
  text-align: center;
  transition: border-color .15s, background .15s;
  cursor: pointer;
}
.dropzone:hover { border-color: var(--faint); }
.dropzone.dragging { border-color: var(--accent); background: var(--accent-soft); }
.dropzone .dz-icon {
  width: 56px; height: 56px; margin: 0 auto 14px;
  border-radius: 14px; background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
}
.dropzone h2 { font-size: 20px; font-weight: 700; margin: 0 0 6px; letter-spacing: -0.01em; }
.dropzone p { margin: 0; color: var(--muted); font-size: 14.5px; }
.dropzone .browse {
  display: inline-block; margin-top: 18px;
  background: var(--accent); color: var(--accent-ink);
  font-weight: 600; font-size: 15px;
  padding: 11px 22px; border-radius: 8px; min-height: 44px;
}
.dropzone:hover .browse { background: var(--accent-hover); }
.dropzone.compact { padding: 16px 20px; margin-top: 22px; text-align: left; display: flex; align-items: center; gap: 14px; }
.dropzone.compact .dz-icon { width: 40px; height: 40px; margin: 0; border-radius: 10px; }
.dropzone.compact h2 { font-size: 15.5px; margin: 0; }
.dropzone.compact p { font-size: 13.5px; }
.dropzone.compact .browse { margin: 0 0 0 auto; padding: 9px 16px; min-height: 40px; font-size: 14px; white-space: nowrap; }

/* ---------- tool explainers (empty state) ---------- */
.tools { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 22px; }
.tool { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.tool .t-icon { width: 38px; height: 38px; border-radius: 9px; background: var(--surface-2); color: var(--accent); display: flex; align-items: center; justify-content: center; margin-bottom: 12px; }
.tool h3 { margin: 0 0 5px; font-size: 16px; font-weight: 700; }
.tool p { margin: 0; font-size: 14px; color: var(--muted); }
@media (max-width: 680px) { .tools { grid-template-columns: 1fr; } }

.compare {
  margin-top: 22px; font-size: 14px; color: var(--muted);
  border-left: 3px solid var(--accent); padding: 4px 0 4px 14px; max-width: 680px;
}
.compare strong { color: var(--ink); }

/* ---------- workspace ---------- */
.files-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 26px; }
.file-chip {
  display: inline-flex; align-items: center; gap: 9px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 8px 6px 14px; font-size: 13.5px; max-width: 100%;
}
.file-chip .fname { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.file-chip .fmeta { color: var(--faint); font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12px; white-space: nowrap; }
.file-chip button {
  border: 0; background: var(--surface-2); color: var(--muted);
  width: 36px; height: 36px; border-radius: 999px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; flex: none;
}
.file-chip button:hover { color: var(--accent); }

.toolbar {
  margin-top: 16px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px 14px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px;
}
.sel-count { font-size: 14px; font-weight: 600; margin-right: 2px; }
.sel-count span { color: var(--muted); font-weight: 500; }
.tgroup { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tgroup .glabel { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); margin-right: 2px; }
.tbtn {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font: inherit; font-size: 13.5px; font-weight: 500;
  min-height: 40px; padding: 7px 13px; border-radius: 8px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 7px;
}
.tbtn:hover:not(:disabled) { border-color: var(--faint); background: var(--surface-2); }
.tbtn:disabled { opacity: .42; cursor: not-allowed; }
.tbtn.danger:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.range-form { display: flex; gap: 6px; align-items: center; }
.range-form input {
  font: inherit; font-size: 13.5px; width: 128px; min-height: 40px;
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px;
  background: var(--surface); color: var(--ink);
}
.range-form input::placeholder { color: var(--faint); }
.toolbar .spacer { flex: 1; }

/* ---------- page grid ---------- */
.grid {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(158px, 1fr));
  gap: 14px;
}
@media (max-width: 480px) { .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; } }
.card {
  background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius);
  overflow: hidden; cursor: pointer; position: relative;
  transition: border-color .12s, box-shadow .12s;
}
.card:hover { border-color: var(--faint); }
.card.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.card.dragging { opacity: .4; }
.card.drop-before { box-shadow: -3px 0 0 0 var(--accent); }
.card.drop-after { box-shadow: 3px 0 0 0 var(--accent); }
.thumb {
  position: relative; background: #e9e9e6; aspect-ratio: 1 / 1.18;
  display: flex; align-items: flex-start; justify-content: center; overflow: hidden;
}
@media (prefers-color-scheme: dark) { .thumb { background: #2c2c2a; } }
.thumb canvas { width: 100%; height: 100%; object-fit: contain; object-position: top center; display: block; }
.thumb .loading {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: var(--faint); font-size: 12px; font-family: ui-monospace, Menlo, monospace;
}
.pos-chip {
  position: absolute; top: 8px; left: 8px; z-index: 2;
  background: rgba(20,20,18,.82); color: #fff;
  font-family: ui-monospace, Menlo, monospace; font-size: 11.5px; font-weight: 600;
  padding: 3px 8px; border-radius: 999px;
}
.check {
  position: absolute; top: 8px; right: 8px; z-index: 2;
  width: 26px; height: 26px; border-radius: 999px;
  background: var(--accent); color: var(--accent-ink);
  display: none; align-items: center; justify-content: center;
}
.card.selected .check { display: flex; }
.rot-badge {
  position: absolute; bottom: 8px; right: 8px; z-index: 2;
  background: rgba(20,20,18,.82); color: #fff;
  font-family: ui-monospace, Menlo, monospace; font-size: 11.5px;
  padding: 3px 8px; border-radius: 999px;
}
.card-meta { padding: 9px 11px 4px; }
.card-meta .src { display: block; font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-meta .pg { display: block; font-size: 12px; color: var(--faint); font-family: ui-monospace, Menlo, monospace; margin-top: 1px; }
.card-actions { display: flex; gap: 4px; padding: 6px 8px 9px; }
.card-actions button {
  flex: 1; border: 1px solid var(--line); background: var(--surface); color: var(--muted);
  min-height: 38px; border-radius: 7px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.card-actions button:hover { color: var(--ink); border-color: var(--faint); background: var(--surface-2); }

/* ---------- export bar ---------- */
.exportbar {
  position: sticky; bottom: 14px; z-index: 5;
  margin-top: 22px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow);
  padding: 14px; display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
}
.exportbar .stats { font-size: 13.5px; color: var(--muted); font-family: ui-monospace, Menlo, monospace; margin-right: auto; }
.btn {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font: inherit; font-size: 14.5px; font-weight: 600;
  min-height: 46px; padding: 10px 18px; border-radius: 9px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px;
}
.btn:hover:not(:disabled) { border-color: var(--faint); background: var(--surface-2); }
.btn:disabled { opacity: .42; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
@media (max-width: 680px) {
  .exportbar .stats { width: 100%; margin-right: 0; }
  .exportbar .btn { flex: 1 1 auto; justify-content: center; }
}

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translate(-50%, 16px);
  background: #1d1d1b; color: #f4f3ef; font-size: 14px; font-weight: 500;
  padding: 12px 18px; border-radius: 10px; box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
  max-width: min(92vw, 560px); text-align: center; z-index: 50;
}
@media (prefers-color-scheme: dark) { .toast { background: #f0efeb; color: #1b1b19; } }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--accent); color: #fff; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ======================================================================
   Site chrome (header, footer), content pages and ad slots.
   Added with the AdSense/content pages; see docs/ADSENSE.md.
   ====================================================================== */
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }
.skip-link { position: absolute; left: -9999px; top: 8px; background: var(--surface); color: var(--ink); padding: 8px 12px; border-radius: 6px; z-index: 100; }
.skip-link:focus { left: 8px; }

.site-header { background: var(--surface); border-bottom: 1px solid var(--line); }
.site-header-inner { max-width: 1120px; margin: 0 auto; padding: 10px 20px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 22px; }
.brand { display: inline-flex; align-items: center; gap: 9px; font-weight: 800; font-size: 16.5px; letter-spacing: -0.01em; color: var(--ink); text-decoration: none; min-height: 44px; }
.brand:hover { color: var(--ink); }
.brand img { display: block; }
.site-nav { display: flex; flex-wrap: wrap; gap: 2px 4px; margin-left: auto; }
.site-nav a { color: var(--muted); text-decoration: none; font-size: 14.5px; font-weight: 600; padding: 10px 10px; border-radius: 7px; }
.site-nav a:hover { color: var(--ink); background: var(--surface-2); }
.site-nav a[aria-current="page"] { color: var(--accent); }
@media (max-width: 680px) { .site-nav { margin-left: 0; } .site-nav a { padding: 8px 8px; } }

.site-footer { border-top: 1px solid var(--line); background: var(--surface); margin-top: 24px; }
.site-footer-inner { max-width: 1120px; margin: 0 auto; padding: 22px 20px 30px; font-size: 13.5px; color: var(--muted); }
.site-footer nav { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-bottom: 10px; }
.site-footer a, .site-footer .linklike { color: var(--muted); font-weight: 600; text-decoration: none; padding: 6px 0; display: inline-block; }
.site-footer a:hover, .site-footer .linklike:hover { color: var(--ink); text-decoration: underline; }
.site-footer p { margin: 0; }
.linklike { background: none; border: 0; font: inherit; cursor: pointer; }

/* Long-form content pages */
.prose { max-width: 780px; }
.prose h1 { font-size: clamp(28px, 4.6vw, 40px); line-height: 1.1; letter-spacing: -0.02em; font-weight: 800; margin: 8px 0 12px; }
.prose h2 { font-size: 21px; letter-spacing: -0.01em; margin: 30px 0 8px; }
.prose p, .prose li { color: var(--ink); }
.prose ul, .prose ol { padding-left: 22px; }
.prose li { margin: 6px 0; }
.prose code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: .92em; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
.muted { color: var(--muted) !important; }
.contact-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin: 18px 0; }
.contact-card h2 { margin-top: 0; }
.contact-email { font-size: 19px; font-weight: 700; word-break: break-all; }
.faq-item { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 0 18px; margin: 10px 0; }
.faq-item summary { cursor: pointer; font-weight: 700; padding: 14px 0; min-height: 44px; }
.faq-item p { margin: 0 0 16px; color: var(--muted); }
.guide-list { display: grid; gap: 12px; margin: 18px 0; }
.guide-card { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; text-decoration: none; color: var(--ink); }
.guide-card:hover { border-color: var(--faint); color: var(--ink); }
.guide-card h2 { margin: 0 0 4px; font-size: 18px; color: var(--accent); }
.guide-card p { margin: 0; color: var(--muted); }
a.btn { text-decoration: none; }

/* Home page content below the tool */
.home-content { max-width: 780px; margin-top: 40px; }
.home-content h2 { font-size: 24px; letter-spacing: -0.01em; margin: 32px 0 8px; }
.home-content ol, .home-content ul { padding-left: 22px; }
.home-content li { margin: 6px 0; }

/* Ad slots: clearly labelled, separated from tool controls, collapse when unfilled.
   ins.adsbygoogle needs display:block; set here instead of an inline style attribute. */
.ad-slot { margin: 30px 0; padding-top: 6px; border-top: 1px solid var(--line); text-align: center; min-height: 0; }
.ad-label { display: block; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); margin-bottom: 6px; }
ins.adsbygoogle { display: block; }
.ad-slot:has(ins.adsbygoogle[data-ad-status="unfilled"]) { display: none; }
