/* Typeface: Public Sans (SIL Open Font License), self-hosted. */
@font-face { font-family: "Public Sans"; src: url("/fonts/PublicSans-Regular.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Public Sans"; src: url("/fonts/PublicSans-SemiBold.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Public Sans"; src: url("/fonts/PublicSans-Bold.woff2") format("woff2"); font-weight: 700; font-display: swap; }

:root {
  --paper: #f3f5f8;      /* page */
  --surface: #ffffff;    /* panels */
  --ink: #17212e;        /* text */
  --muted: #5a6576;
  --line: #d8dde5;
  --soft: #eaeef3;       /* quiet fills */
  --go: #0b6e4f;         /* primary action and "ready" */
  --go-ink: #ffffff;
  --go-soft: #e3f2ec;
  --mark: #fff0a6;       /* highlighter: drag-over */
  --link: #1d4ed8;
  --bad: #b42318;
  --bad-soft: #fdecea;
  --warn: #9a5b00;
  --pdf: #c2410c; --photo: #0b6e4f; --image: #4338ca;
  --r-panel: 16px; --r-ctl: 10px;
  color-scheme: light dark;
  accent-color: var(--go);
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0f141a; --surface: #161d25; --ink: #e8ecf1; --muted: #9ba6b5; --line: #2b3542; --soft: #1e2731;
    --go: #34c38f; --go-ink: #07261b; --go-soft: #12392b; --mark: #4d4300; --link: #8ab4ff;
    --bad: #ff8a80; --bad-soft: #3a1714; --warn: #f0b35a;
    --pdf: #fb923c; --photo: #34c38f; --image: #a5b4fc;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 16px/1.55 "Public Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}
a { color: var(--link); text-underline-offset: 2px; }
:focus-visible { outline: 3px solid var(--go); outline-offset: 2px; border-radius: 4px; }
img, canvas { max-width: 100%; }

/* ---------- frame ---------- */
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 20px; }
header.site { background: var(--surface); border-bottom: 1px solid var(--line); }
header.site .wrap { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 60px; }
.brand { font-weight: 700; font-size: 18px; color: var(--ink); text-decoration: none; letter-spacing: -0.01em; display: inline-flex; align-items: center; gap: 8px; }
.brand svg { width: 26px; height: 26px; }
nav.site { display: flex; gap: 4px; }
nav.site a { color: var(--ink); text-decoration: none; font-weight: 600; font-size: 15px; padding: 8px 12px; border-radius: var(--r-ctl); }
nav.site a:hover { background: var(--soft); }
main { padding-bottom: 56px; }
footer.site { border-top: 1px solid var(--line); background: var(--surface); color: var(--muted); font-size: 14px; }
footer.site .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px; padding-top: 20px; padding-bottom: 28px; }
footer.site p { margin: 0; }
footer.site a { color: var(--muted); }

/* ---------- type ---------- */
h1 { font-size: clamp(30px, 4.4vw, 44px); line-height: 1.12; letter-spacing: -0.025em; margin: 0 0 10px; font-weight: 700; }
h2 { font-size: 22px; line-height: 1.25; letter-spacing: -0.01em; margin: 40px 0 10px; }
h3 { font-size: 17px; margin: 24px 0 6px; }
p.lead { font-size: 18px; color: var(--muted); margin: 0 auto; max-width: 620px; }
.muted, small { color: var(--muted); }

/* ---------- hero (tool pages) ---------- */
.hero { text-align: center; padding: 44px 0 24px; }

/* ---------- tool panel ---------- */
.tool {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel);
  padding: 24px; margin: 0 auto; max-width: 960px;
}
.local { text-align: center; color: var(--muted); font-size: 14px; margin: 14px 0 0; display: flex; justify-content: center; align-items: center; gap: 6px; }
.local svg { width: 16px; height: 16px; flex: none; }

.drop {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  min-height: 190px; padding: 28px 16px; text-align: center; cursor: pointer;
  border: 2px dashed var(--line); border-radius: 14px; background: var(--paper);
  font-size: 18px; font-weight: 600; transition: background .15s, border-color .15s;
}
.drop:hover { border-color: var(--go); }
.drop.over { background: var(--mark); border-color: var(--ink); }
.drop input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.drop:focus-within { outline: 3px solid var(--go); outline-offset: 2px; }
.drop .pickbtn {
  margin: 8px 0 2px; padding: 14px 30px; border-radius: var(--r-ctl); background: var(--go); color: var(--go-ink);
  font-size: 18px; font-weight: 700;
}
.drop small { display: block; font-size: 14px; font-weight: 400; }
.tool.loaded .drop { min-height: 0; padding: 12px 16px; flex-direction: row; flex-wrap: wrap; font-size: 15px; gap: 12px; }
.tool.loaded .drop .pickbtn { margin: 0; padding: 8px 16px; font-size: 15px; background: var(--soft); color: var(--ink); border: 1px solid var(--line); }
.tool.loaded .drop small { display: none; }

/* controls */
button, select, input[type=text], input[type=number] {
  font: inherit; font-size: 15px; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-ctl); padding: 9px 12px; min-height: 42px;
}
select { max-width: 100%; min-width: 0; }
button { cursor: pointer; font-weight: 600; background: var(--soft); }
button:hover { border-color: var(--muted); }
button.primary { background: var(--go); color: var(--go-ink); border-color: var(--go); padding: 12px 26px; font-size: 16px; font-weight: 700; }
button.primary:hover { filter: brightness(1.06); }
button:disabled { opacity: .45; cursor: default; filter: none; }
input[type=text]:focus, input[type=number]:focus, select:focus { border-color: var(--go); outline: none; box-shadow: 0 0 0 3px var(--go-soft); }
input[type=number] { width: 6.5em; }
input[type=range] { width: min(240px, 100%); }
input[type=checkbox] { width: 18px; height: 18px; vertical-align: middle; }
.row { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; margin: 14px 0; }
.row label { display: inline-flex; gap: 8px; align-items: center; white-space: nowrap; }
.row label > select, .row label > input[type=range] { flex: 1 1 auto; min-width: 0; }
.row label:has(select) { flex: 1 1 auto; min-width: 0; }
.unit { display: inline-flex; gap: 6px; align-items: center; }
.chips { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.chips button { border-radius: 999px; padding: 6px 14px; min-height: 36px; font-size: 14px; }
.options { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: center; padding: 14px 0 0; border-top: 1px solid var(--line); margin-top: 16px; }
.go-row { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 12px; align-items: center; margin-top: 16px; }
#range { flex: 1 1 6em; min-width: 0; width: auto; }

/* file list */
.files { list-style: none; padding: 0; margin: 16px 0 0; }
.files:empty { display: none; }
.files li { display: flex; gap: 8px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-ctl); margin-bottom: 8px; background: var(--surface); font-size: 15px; }
.files li span.name { flex: 1; overflow-wrap: anywhere; }
.files li button { padding: 4px 10px; min-height: 34px; font-size: 14px; }

/* status + results */
.status { margin: 12px 0 0; font-size: 15px; }
.status:empty { margin: 0; }
.status.ok { color: var(--go); font-weight: 600; }
.status.bad { color: var(--bad); font-weight: 600; }
.hint { font-size: 15px; color: var(--muted); margin: 10px 0; }
.hint:empty { margin: 0; }
.result:empty { display: none; }
.result { margin-top: 18px; display: grid; gap: 12px; }
.result p { margin: 0; }

/* The "ready" panel: the one memorable moment, when a file is done. */
.ready { border: 2px solid var(--go); background: var(--go-soft); border-radius: 14px; padding: 18px 20px; display: grid; gap: 12px; }
.ready .stamp { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; color: var(--go); font-size: 19px; }
.ready .stamp svg { width: 24px; height: 24px; }
.ready .facts { margin: 0; color: var(--ink); }
.ready .actions-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
a.download { display: inline-flex; align-items: center; gap: 8px; background: var(--go); color: var(--go-ink); text-decoration: none; font-weight: 700; padding: 12px 22px; border-radius: var(--r-ctl); }
a.download:hover { filter: brightness(1.06); }
a.download.secondary { background: var(--surface); color: var(--ink); border: 1px solid var(--line); font-weight: 600; }
.ready .muted, .ready .note { font-size: 14px; }
.failed { border: 2px solid var(--bad); background: var(--bad-soft); border-radius: 14px; padding: 16px 20px; display: grid; gap: 10px; }

.items { display: grid; gap: 10px; }
.item { display: flex; gap: 12px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-ctl); padding: 10px; }
.item img { width: 56px; height: 56px; object-fit: cover; border-radius: 6px; flex: none; }
.item .meta { flex: 1; min-width: 0; font-size: 14px; overflow-wrap: anywhere; }
.item a.download { padding: 8px 14px; font-size: 14px; }
.item.bad { border-color: var(--bad); color: var(--bad); }

ul.check { list-style: none; padding: 0; margin: 0; }
.check li { margin: 3px 0; padding-left: 1.4em; text-indent: -1.4em; font-size: 15px; }
.check .ok::before { content: "✓"; color: var(--go); display: inline-block; width: 1.4em; text-indent: 0; font-weight: 700; }
.check .bad::before { content: "✗"; color: var(--bad); display: inline-block; width: 1.4em; text-indent: 0; font-weight: 700; }
.check .warn::before { content: "!"; color: var(--warn); display: inline-block; width: 1.4em; text-indent: 0; font-weight: 700; }
.check .info::before { content: ""; display: inline-block; width: 1.4em; }
.note { border-left: 3px solid var(--line); padding: 2px 12px; font-size: 14px; color: var(--muted); }
.preview { display: block; max-width: 100%; border: 1px solid var(--line); border-radius: 8px; background: #fff; }

/* PDF page views */
.pages { display: flex; flex-wrap: wrap; gap: 14px; margin: 16px 0; justify-content: center; }
.pages:empty { display: none; }
.page { position: relative; border: 1px solid var(--line); border-radius: 6px; line-height: 0; background: #fff; }
.page canvas { display: block; max-width: 100%; height: auto; border-radius: 6px; }
.page .num { position: absolute; left: 6px; bottom: 6px; line-height: 1.3; font-size: 12px; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 6px; padding: 2px 6px; display: inline-flex; gap: 4px; align-items: center; }
label.page { cursor: pointer; }
label.page:has(input:checked) { outline: 3px solid var(--go); }
.page .layer { position: absolute; inset: 0; touch-action: none; cursor: crosshair; }
.box { position: absolute; background: #000; border-radius: 1px; }
.box:hover { outline: 2px solid var(--link); }
.place { position: absolute; outline: 2px dashed var(--link); cursor: move; touch-action: none; }
.place img { width: 100%; height: 100%; display: block; }
.box .x, .place .x {
  position: absolute; bottom: 100%; right: 0; margin-bottom: 4px; width: 28px; height: 28px; min-height: 0; padding: 0;
  border-radius: 14px; font-size: 16px; line-height: 1; background: var(--surface); box-shadow: 0 1px 2px rgba(0,0,0,.25);
}
canvas.pad { border: 1px solid var(--line); border-radius: var(--r-ctl); width: 100%; max-width: 520px; height: 170px; touch-action: none; background: #fff; display: block; }
.actions { position: sticky; bottom: 0; background: var(--surface); padding: 12px 0 4px; border-top: 1px solid var(--line); margin-top: 8px; z-index: 2; }
.actions .go-row { margin-top: 0; justify-content: flex-start; }
fieldset { border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px 16px; margin: 16px 0 0; min-width: 0; }
legend { font-weight: 700; padding: 0 6px; }
details.req { margin: 10px 0 16px; font-size: 15px; }
details.req summary { cursor: pointer; font-weight: 600; color: var(--link); }
details.req ul { margin: 8px 0; padding-left: 20px; }
.spec-summary { font-size: 15px; margin: 4px 0 0; }

/* ---------- article content below tools ---------- */
.content { max-width: 720px; margin: 16px auto 0; }
.content ul, .content ol { padding-left: 22px; }
.content li { margin: 4px 0; }
.content details { border-bottom: 1px solid var(--line); padding: 12px 0; }
.content details summary { cursor: pointer; font-weight: 600; font-size: 16px; }
.content details p { margin: 8px 0 0; }
.related { display: flex; flex-wrap: wrap; gap: 8px; margin: 28px 0 0; padding: 0; list-style: none; }
.related a { display: inline-block; padding: 8px 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); text-decoration: none; color: var(--ink); font-size: 14px; font-weight: 600; }
.related a:hover { border-color: var(--go); }
.updated { font-size: 13px; color: var(--muted); margin-top: 20px; }
table { border-collapse: collapse; width: 100%; font-size: 15px; margin: 8px 0; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
#info th { white-space: nowrap; }
#info:empty { display: none; }
.ad { margin: 32px 0; min-height: 100px; }
.ad .adlabel { display: block; color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.page-text { max-width: 720px; margin: 0 auto; padding-top: 40px; }

/* ---------- home ---------- */
.home-hero { text-align: center; padding: 56px 0 28px; }
.home-hero h1 { font-size: clamp(34px, 5.4vw, 56px); max-width: 820px; margin: 0 auto 14px; }
.home-hero p { font-size: 19px; color: var(--muted); max-width: 640px; margin: 0 auto; }
.group { margin: 28px 0 0; }
.group h2 { margin: 0 0 12px; font-size: 18px; display: flex; align-items: center; gap: 10px; }
.group h2::before { content: ""; width: 10px; height: 10px; border-radius: 3px; background: var(--c, var(--ink)); }
.tiles { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.tile {
  display: grid; grid-template-columns: 44px 1fr; gap: 4px 14px; align-items: start; padding: 18px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel);
  color: var(--ink); text-decoration: none;
}
.tile:hover { border-color: var(--c, var(--go)); }
.tile .ico { grid-row: span 2; width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: color-mix(in srgb, var(--c) 14%, transparent); color: var(--c); }
.tile .ico svg { width: 24px; height: 24px; }
.tile b { font-size: 17px; line-height: 1.3; }
.tile span { color: var(--muted); font-size: 14px; line-height: 1.45; }
.pdf { --c: var(--pdf); } .photo { --c: var(--photo); } .image { --c: var(--image); }
.why { display: grid; gap: 24px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); margin: 56px 0 0; padding-top: 32px; border-top: 1px solid var(--line); }
.why h3 { margin: 0 0 4px; }
.why p { margin: 0; color: var(--muted); font-size: 15px; }

@media (max-width: 640px) {
  .wrap { padding: 0 14px; }
  .tool { padding: 16px; border-radius: 12px; }
  .hero { padding: 28px 0 16px; }
  nav.site a { padding: 8px 8px; font-size: 14px; }
  .brand > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
  .drop { min-height: 160px; }
}
@media (pointer: coarse) {
  button, select, input[type=text], input[type=number] { min-height: 44px; }
  .files li button { min-width: 44px; min-height: 40px; }
  .box .x, .place .x { width: 36px; height: 36px; border-radius: 18px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
/* Success is shown by the ready panel; keep the status line for screen readers only. */
.status.ok { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.panel-grid { display: grid; gap: 20px; align-items: start; }
.panel-grid canvas#view { margin: 0 auto; }
@media (min-width: 860px) { .panel-grid { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); } }

/* Guides */
.cta { display: inline-block; padding: 12px 22px; border-radius: 10px; background: var(--go); color: #fff; font-weight: 700; text-decoration: none; }
.cta:hover { filter: brightness(1.08); }
.content code { font-size: 0.92em; background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 1px 4px; }
.guide-list { max-width: 720px; margin: 8px auto 0; display: grid; gap: 10px; }
.guide-list a { display: block; padding: 16px 18px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; text-decoration: none; color: var(--ink); }
.guide-list a:hover { border-color: var(--go); }
.guide-list b { display: block; font-size: 17px; }
.guide-list span { display: block; color: var(--muted); font-size: 15px; margin-top: 2px; }
.guide-links { margin: 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 8px 32px; }
.guide-links a { font-weight: 600; }
.content .related { padding: 0; }

/* Signature tool */
.sig-compare { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 4px 0 8px; }
.sig-compare figure { margin: 0; }
.sig-compare figcaption { font-size: 14px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.sig-box { border: 1px solid var(--line); border-radius: 10px; background: #fff; padding: 8px; min-height: 120px; display: flex; align-items: center; justify-content: center; }
.sig-box canvas.sig { max-width: 100%; max-height: 260px; height: auto; display: block; }
.checker { background-color: #fff; background-image: linear-gradient(45deg, #e5e7eb 25%, transparent 25%, transparent 75%, #e5e7eb 75%), linear-gradient(45deg, #e5e7eb 25%, transparent 25%, transparent 75%, #e5e7eb 75%); background-size: 16px 16px; background-position: 0 0, 8px 8px; }
@media (max-width: 600px) { .sig-compare { grid-template-columns: 1fr; } }
.options label.range { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.options label.range input { width: 160px; }
.sizes { margin: 10px 0 0; font-size: 14px; color: var(--muted); }
.sizes a { margin-left: 10px; font-weight: 600; }
