/* Layout: a tool bench. Header, short hero, a row of colour-coded tool cards, then the active tool
   (files on the left, settings + result card on the right), then how-to and FAQ. */
:root {
  --bg: #eef0f4;
  --surface: #ffffff;
  --sunken: #f5f6f9;
  --ink: #141b2b;
  --muted: #566074;
  --line: #d8dde6;
  --line-strong: #b9c1cf;
  --brand: #16213a;
  --brand-accent: #ff5a3c;
  --ok: #137a3a;
  --err: #b42318;
  --shadow: 0 1px 2px rgba(20, 27, 43, .06), 0 6px 18px rgba(20, 27, 43, .06);

  /* Each tool has a bright tone (icon tiles) and a strong tone (buttons, white text at AA contrast). */
  --c-img2pdf: #ff5a4a; --cs-img2pdf: #c62f2a;
  --c-pdf2img: #ffb020; --cs-pdf2img: #b45309;
  --c-merge: #8b6cff;   --cs-merge: #5b3be0;
  --c-extract: #1fc2a8; --cs-extract: #0f766e;
  --c-combine: #4d8dff; --cs-combine: #1d5fd6;

  --font-display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --font-body: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1016; --surface: #151a23; --sunken: #1b212c; --ink: #e7eaf0; --muted: #9aa3b5;
    --line: #283040; --line-strong: #3a4456; --brand: #2a3a63; --ok: #4ade80; --err: #f87171;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1016; --surface: #151a23; --sunken: #1b212c; --ink: #e7eaf0; --muted: #9aa3b5;
  --line: #283040; --line-strong: #3a4456; --brand: #2a3a63; --ok: #4ade80; --err: #f87171;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3); color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; } /* components set display, which would otherwise override the attribute */
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 15px/1.55 var(--font-body);
  padding-inline: 16px; padding-block: 0 40px;
  -webkit-font-smoothing: antialiased;
}
.wrap { max-width: 1160px; margin: 0 auto; }
main.wrap { display: grid; gap: 22px; }
button, input, select { font: inherit; color: inherit; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--cs-combine); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Header ---------- */
.site-head { padding-block: 16px; }
.site-head .wrap { display: flex; align-items: center; justify-content: space-between; gap: 12px 24px; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; }
.brand svg { width: 38px; height: 38px; flex: none; }
.brand b { font-family: var(--font-display); font-weight: 700; font-size: 20px; letter-spacing: -.01em; }
.trust { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.trust svg { width: 16px; height: 16px; color: var(--ok); }

/* ---------- Hero ---------- */
.hero { display: grid; gap: 10px; padding-block: 8px 4px; }
.hero h1 {
  font-family: var(--font-display); font-weight: 700; font-size: clamp(28px, 4.2vw, 40px);
  line-height: 1.1; letter-spacing: -.02em; margin: 0; text-wrap: balance; max-width: 22ch;
}
.hero p { margin: 0; color: var(--muted); font-size: 16.5px; max-width: 62ch; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line); font-size: 13px; font-weight: 500;
}
.chip svg { width: 15px; height: 15px; color: var(--ok); }

/* ---------- Tool cards (tabs) ---------- */
.tools { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 900px) {
  .tools {
    grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: minmax(196px, 1fr);
    overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 6px; scrollbar-width: thin;
  }
  .tool { scroll-snap-align: start; }
}
.tool {
  --tint: color-mix(in srgb, var(--tc) 11%, var(--surface));
  display: flex; align-items: center; gap: 11px; padding: 11px 12px; text-decoration: none;
  background: var(--surface); border: 1.5px solid var(--line); border-radius: 14px; cursor: pointer;
  transition: transform .15s, border-color .15s, box-shadow .15s, background .15s;
}
.tool:hover { transform: translateY(-1px); border-color: color-mix(in srgb, var(--tc) 55%, var(--line)); }
.tool[aria-selected="true"] {
  background: var(--tint); border-color: var(--tc);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--tc) 22%, transparent), var(--shadow);
}
.tool-ic {
  width: 42px; height: 42px; flex: none; border-radius: 12px; display: grid; place-items: center; color: #fff;
  background: linear-gradient(140deg, var(--tc), var(--tcs));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), 0 2px 6px color-mix(in srgb, var(--tcs) 35%, transparent);
}
.tool-ic svg { width: 24px; height: 24px; }
.tool-tx { display: grid; min-width: 0; line-height: 1.25; }
.tool-tx b { font-weight: 600; font-size: 14.5px; }
.tool-tx small { color: var(--muted); font-size: 12.5px; font-family: var(--font-mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
[data-tool="img2pdf"] { --tc: var(--c-img2pdf); --tcs: var(--cs-img2pdf); }
[data-tool="pdf2img"] { --tc: var(--c-pdf2img); --tcs: var(--cs-pdf2img); }
[data-tool="merge"]   { --tc: var(--c-merge);   --tcs: var(--cs-merge); }
[data-tool="extract"] { --tc: var(--c-extract); --tcs: var(--cs-extract); }
[data-tool="combine"] { --tc: var(--c-combine); --tcs: var(--cs-combine); }

/* ---------- Tool panel ---------- */
.panel:not(.on) { display: none; }
.work { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
@media (max-width: 860px) { .work { grid-template-columns: minmax(0, 1fr); } }
.inputs { min-width: 0; display: grid; gap: 12px; }
.side { display: grid; gap: 24px; position: sticky; top: 16px; }
@media (max-width: 860px) { .side { position: static; } }

.drop {
  position: relative; display: grid; place-items: center; gap: 8px; text-align: center; cursor: pointer;
  padding: 30px 16px; border: 2px dashed color-mix(in srgb, var(--tc) 45%, var(--line)); border-radius: 14px;
  background: color-mix(in srgb, var(--tc) 4%, var(--surface)); transition: border-color .15s, background .15s;
}
.drop:hover, .drop.over { border-color: var(--tc); background: color-mix(in srgb, var(--tc) 10%, var(--surface)); }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.drop strong { font-family: var(--font-display); font-size: 20px; font-weight: 600; }
.drop .sub { color: var(--muted); font-size: 13.5px; }
.drop .pick {
  margin-top: 2px; padding: 8px 16px; border-radius: 999px; background: var(--tcs); color: #fff; font-weight: 600; font-size: 14px;
}
.badges { display: flex; gap: 6px; justify-content: center; }
.fbadge { width: 34px; height: 40px; display: block; }
.fb-page { fill: var(--surface); stroke: var(--line-strong); stroke-width: 1.5; }
.fb-fold { stroke: var(--line-strong); stroke-width: 1.5; stroke-linejoin: round; }
.fb-line { stroke: var(--line-strong); stroke-width: 2; stroke-linecap: round; }

.listhead { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 13px; color: var(--muted); }
.link {
  background: none; border: 0; color: var(--ink); cursor: pointer; padding: 2px 0; font-size: 13px; font-weight: 600;
  text-decoration: underline; text-decoration-color: var(--tc); text-decoration-thickness: 2px; text-underline-offset: 3px;
}
.link:hover { text-decoration-color: var(--ink); }

ul.files { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
ul.files li {
  display: grid; grid-template-columns: 18px 46px minmax(0, 1fr) auto; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 6px 8px;
}
ul.files li.dragging { opacity: .4; }
ul.files li.target { border-color: var(--tc); }
.grip { cursor: grab; color: var(--muted); font-family: var(--font-mono); text-align: center; user-select: none; letter-spacing: -2px; }
.thumb { width: 46px; height: 46px; border-radius: 6px; background: var(--sunken); object-fit: cover; display: block; }
.fname { min-width: 0; }
.fname b { display: block; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fname small { font-family: var(--font-mono); font-size: 12px; color: var(--muted); }
.rowbtns { display: flex; gap: 2px; }
.icon {
  width: 32px; height: 32px; border-radius: 8px; border: 0; background: none; cursor: pointer; color: var(--muted);
  display: grid; place-items: center;
}
.icon svg { width: 16px; height: 16px; }
.icon:hover { background: var(--sunken); color: var(--ink); }
.icon:disabled { opacity: .3; cursor: default; background: none; }

.opts {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 18px;
  display: grid; gap: 14px; box-shadow: var(--shadow); border-top: 4px solid var(--tc);
}
.opts h2 { font-family: var(--font-display); font-weight: 600; font-size: 21px; margin: 0; text-wrap: balance; }
.hint { margin: -8px 0 0; color: var(--muted); font-size: 13.5px; }
.field { display: grid; gap: 5px; }
.field > span { font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.field select, .field input[type="text"], .field input[type="number"], .field input[type="email"] {
  width: 100%; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--sunken);
}
.field input[type="color"] { width: 100%; height: 40px; border: 1px solid var(--line); border-radius: 8px; background: var(--sunken); padding: 3px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.check { display: flex; gap: 8px; align-items: center; font-size: 14px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 10px; padding: 11px 14px;
  font-weight: 600; cursor: pointer; border: 1px solid transparent; text-decoration: none;
}
.btn svg { width: 18px; height: 18px; }
.btn.primary { background: var(--tcs); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.secondary { background: var(--sunken); border-color: var(--line); }
.btn.secondary:hover { border-color: var(--tc); }
.btn:disabled { opacity: .55; cursor: default; filter: none; }
.status, .mail-status { margin: 0; font-size: 13.5px; color: var(--muted); }
.status { min-height: 1.5em; }
.mail-status:empty { display: none; }
.status[data-kind="ok"], .mail-status[data-kind="ok"] { color: var(--ok); }
.status[data-kind="err"], .mail-status[data-kind="err"] { color: var(--err); }

/* ---------- Result card ---------- */
.result {
  display: grid; gap: 12px; padding: 14px; border-radius: 12px;
  background: color-mix(in srgb, var(--tc) 9%, var(--surface)); border: 1.5px solid color-mix(in srgb, var(--tc) 50%, var(--line));
}
.result-head { display: flex; align-items: center; gap: 12px; min-width: 0; }
.result-head .fbadge { width: 40px; height: 47px; flex: none; }
.result-title { font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--ok); }
.result-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.result-actions .dl-btn { grid-column: 1 / -1; }
.result-actions.solo .mail-btn, .result-actions.no-mail .share-btn { grid-column: 1 / -1; }
.result .fname a, .fine a { color: inherit; }
.mail-form { display: grid; gap: 10px; padding-top: 4px; border-top: 1px dashed color-mix(in srgb, var(--tc) 40%, var(--line)); }
.fine { margin: 0; font-size: 12px; color: var(--muted); }

/* ---------- Page grids ---------- */
.pages { display: grid; grid-template-columns: repeat(auto-fill, minmax(124px, 1fr)); gap: 12px; }
.page {
  position: relative; background: var(--surface); border: 1.5px solid var(--line); border-radius: 10px; padding: 8px;
  display: grid; gap: 6px; justify-items: center; align-content: start; cursor: pointer; text-align: center;
}
.page canvas, .page img { max-width: 100%; height: auto; display: block; box-shadow: 0 1px 3px rgba(0, 0, 0, .18); background: #fff; }
.page .pn { font-family: var(--font-mono); font-size: 12px; color: var(--muted); }
.page.sel { border-color: var(--tc); background: color-mix(in srgb, var(--tc) 12%, var(--surface)); }
.page.sel::after {
  content: "✓"; position: absolute; top: 6px; right: 6px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--tcs); color: #fff; font-size: 13px; display: grid; place-items: center;
}
.page.static { cursor: default; }
.preview { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px; overflow: auto; max-height: 70vh; }
.preview canvas { max-width: 100%; height: auto; display: block; margin: 0 auto; }

/* ---------- Ads ---------- */
.ad { display: grid; gap: 4px; justify-items: center; min-width: 0; }
.ad-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.ad ins { width: 100%; }
.ad-top { min-height: 110px; }
.ad-box {
  width: 100%; display: grid; place-items: center; border: 1px dashed var(--line-strong); border-radius: 8px;
  color: var(--muted); font-family: var(--font-mono); font-size: 12px; background: var(--sunken);
}
.ad-top .ad-box { height: 90px; }
.ad-side .ad-box { height: 250px; }
.ad-bottom .ad-box { height: 120px; }

/* ---------- Content ---------- */
.content { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 28px; padding-top: 10px; }
@media (max-width: 860px) { .content { grid-template-columns: minmax(0, 1fr); } }
.content h2 { font-family: var(--font-display); font-size: 23px; font-weight: 600; margin: 0 0 12px; text-wrap: balance; }
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; counter-reset: s; }
.steps li { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 12px; counter-increment: s; }
.steps li::before {
  content: counter(s); width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  background: var(--brand); color: #fff; font-weight: 600; font-size: 14px;
}
.steps b { display: block; }
.steps span { color: var(--muted); }
.faq details { border-bottom: 1px solid var(--line); padding-block: 12px; }
.faq summary { cursor: pointer; font-weight: 600; }
.faq p { margin: 8px 0 0; color: var(--muted); max-width: 65ch; }
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; grid-column: 1 / -1; }
.feature { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.feature b { display: block; margin-bottom: 2px; }
.feature span { color: var(--muted); font-size: 14px; }

/* ---------- Footer / legal pages ---------- */
.site-foot { margin-top: 40px; border-top: 1px solid var(--line); padding-top: 22px; }
.site-foot .wrap { display: flex; flex-wrap: wrap; gap: 14px 32px; justify-content: space-between; color: var(--muted); font-size: 13.5px; }
.site-foot nav { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.site-foot a { text-decoration: none; }
.site-foot a:hover { color: var(--ink); text-decoration: underline; }
.doc { max-width: 720px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 28px clamp(18px, 4vw, 40px); }
.doc h1 { font-family: var(--font-display); font-size: 32px; margin: 0 0 4px; letter-spacing: -.01em; }
.doc h2 { font-family: var(--font-display); font-size: 20px; margin: 26px 0 6px; }
.doc p, .doc li { color: var(--ink); }
.doc .meta { color: var(--muted); margin: 0 0 18px; }
.doc a { color: var(--cs-combine); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
