:root {
  --bg: #f7f7f5;
  --card: #ffffff;
  --text: #1c1c1e;
  --muted: #6b6b70;
  --line: #e2e2de;          /* dividers only */
  --line-strong: #8e8e89;   /* borders of controls, ≥ 3:1 */
  --accent: #c22f23;
  --fill: #c22f23;          /* filled buttons, white text ≥ 4.5:1 */
  --accent-soft: #fdecea;
  --ok: #1f7a4a;
  --radius: 14px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151516;
    --card: #1e1e20;
    --text: #ededee;
    --muted: #9a9aa1;
    --line: #313134;
    --line-strong: #6e6e75;
    --accent: #ff5a4b;
    --fill: #d6382b;
    --accent-soft: #3a1f1c;
    --ok: #4cc78a;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
a { color: inherit; }
.wrap { max-width: 760px; margin: 0 auto; padding: 0 16px; }

header.top { display: flex; align-items: center; gap: 12px; padding: 14px 0 6px; }
/* Wider than the text column, so the tool names fit in every language. */
@media (min-width: 1100px) {
  header.top { --w: min(1120px, calc(100vw - 48px)); width: var(--w); margin-left: calc((100% - var(--w)) / 2); }
}
.brand { display: inline-flex; align-items: center; gap: 8px; font-size: 18px; font-weight: 700; text-decoration: none; letter-spacing: -0.01em; }
.logo { width: 28px; height: 28px; flex-shrink: 0; }
@media (max-width: 899px) { .brand { font-size: 16px; gap: 6px; } .logo { width: 24px; height: 24px; } }
@media (max-width: 370px) { .brand { font-size: 0; } }

/* Tool colours: icon on a tinted square. Decorative, the name always sits next to it. */
.t-compress { --tc: #c22f23; }
.t-merge    { --tc: #6941c6; }
.t-jpg2pdf  { --tc: #b25e00; }
.t-pdf2jpg  { --tc: #147a55; }
.t-idcard   { --tc: #1f5fbf; }
@media (prefers-color-scheme: dark) {
  .t-compress { --tc: #ff6b5e; }
  .t-merge    { --tc: #a98bff; }
  .t-jpg2pdf  { --tc: #f2a03d; }
  .t-pdf2jpg  { --tc: #45c98f; }
  .t-idcard   { --tc: #74a8ff; }
}
.tile {
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 44px; height: 44px; border-radius: 12px; font-size: 20px;
  color: var(--tc); background: color-mix(in srgb, var(--tc) 13%, transparent);
}

/* Header tool links: icon and name on wide screens, icons only on phones so
   the header stays one row in every language. */
.toolnav { display: flex; gap: 4px; margin-left: auto; font-size: 14px; }
.toolnav a {
  display: inline-flex; align-items: center; gap: 8px; padding: 4px 8px 4px 4px; border-radius: 12px;
  color: var(--muted); text-decoration: none; white-space: nowrap;
}
.toolnav .tile { width: 32px; height: 32px; border-radius: 9px; font-size: 15px; }
.toolnav a:hover, .toolnav a[aria-current="page"] { color: var(--text); background: var(--card); }
.toolnav a[aria-current="page"] { font-weight: 600; box-shadow: inset 0 0 0 1px var(--line); }
@media (max-width: 1099px) {
  .toolnav { gap: 0; }
  .toolnav a { padding: 4px; }
  .toolnav .label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
}

h1 { font-size: clamp(30px, 6vw, 44px); line-height: 1.1; letter-spacing: -0.02em; margin: 28px 0 10px; }
h1.with-tile { display: flex; align-items: center; gap: 14px; }
h1.with-tile .tile { width: 52px; height: 52px; border-radius: 14px; font-size: 24px; }
@media (max-width: 520px) {
  h1.with-tile { gap: 12px; }
  h1.with-tile .tile { width: 44px; height: 44px; font-size: 20px; }
}
.lead { color: var(--muted); font-size: 18px; margin: 0 0 28px; }

.tool { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.level-label { margin: 0 0 8px; font-size: 14px; font-weight: 600; color: var(--muted); }
.levels { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 8px; margin-bottom: 8px; }
.levels button {
  font: inherit; font-size: 15px; padding: 10px 8px; min-height: 44px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--line-strong); background: transparent; color: var(--text);
}
/* The chosen option as a solid chip, like a segmented control. */
.levels button[aria-pressed="true"] { border-color: var(--text); background: var(--text); color: var(--bg); font-weight: 600; }
#level-note { color: var(--muted); font-size: 14px; min-height: 1.5em; margin: 0 0 14px; }

#drop {
  border: 2px dashed var(--line-strong); border-radius: var(--radius); padding: 32px 16px;
  text-align: center; cursor: pointer; transition: border-color .15s, background .15s;
}
#drop:hover, #drop:focus-visible, #drop.over { border-color: var(--accent); background: var(--accent-soft); outline: none; }
#drop > * { pointer-events: none; } /* keeps .over from flickering over the children */
#drop .choose {
  display: inline-block; margin-bottom: 12px; padding: 12px 22px; border-radius: 12px;
  background: var(--fill); color: #fff; font-weight: 600; font-size: 17px;
}
#drop strong { display: block; font-size: 18px; margin-bottom: 4px; }
#drop .hint { display: block; color: var(--muted); font-size: 15px; }
@media (pointer: coarse) {
  #drop { padding: 24px 16px; }
  #drop strong, #drop .hint { display: none; }
  #drop .choose { margin-bottom: 0; }
}
.icon { width: 1em; height: 1em; flex-shrink: 0; }
.private { display: flex; gap: 8px; align-items: center; justify-content: center; color: var(--muted); font-size: 14px; margin: 14px 0 0; }

/* "Download all" above the results, as wide as the rows below it. */
.all { margin-top: 16px; }
.all[hidden] { display: none; }
.all .row-action { width: 100%; justify-content: center; }
.all + #results { margin-top: 8px; }
#results { list-style: none; margin: 16px 0 0; padding: 0; }
#results li { padding: 10px 12px; border-radius: 10px; background: var(--bg); margin-top: 6px; font-size: 15px; }
#results .line { display: flex; justify-content: space-between; gap: 12px; }
#results .extra { display: flex; flex-wrap: wrap; gap: 8px; }
#results .extra:not(:empty) { margin-top: 10px; }
.row-action {
  display: inline-flex; align-items: center; min-height: 44px; padding: 8px 14px; border-radius: 10px;
  font: inherit; font-size: 15px; text-decoration: none; cursor: pointer;
  border: 1px solid var(--line-strong); background: var(--card); color: var(--text);
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.row-action.primary { background: var(--fill); border-color: var(--fill); color: #fff; font-weight: 600; }
#results .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
#results .status { flex-shrink: 0; color: var(--muted); font-variant-numeric: tabular-nums; }
#results li.ok .status { color: var(--ok); font-weight: 600; }
#results li.err .status { color: var(--accent); }
#results li.same .status, #results li.err .status { white-space: normal; text-align: right; flex-shrink: 1; }
/* Phones: the file name gets the whole first line, the result goes below it. */
@media (max-width: 520px) {
  #results .line { flex-direction: column; gap: 2px; }
  #results li.same .status, #results li.err .status { text-align: left; }
}

.queue { list-style: none; margin: 16px 0 0; padding: 0; }
.queue li {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  border-radius: 10px; background: var(--bg); margin-top: 6px; font-size: 15px;
}
.queue .pos { color: var(--muted); font-variant-numeric: tabular-nums; flex-shrink: 0; }
.queue .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queue .size { color: var(--muted); font-variant-numeric: tabular-nums; flex-shrink: 0; }
.queue .actions { display: flex; gap: 6px; flex-shrink: 0; }
.queue .actions button {
  font: inherit; width: 40px; height: 40px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--line-strong); background: var(--card); color: var(--text);
}
.queue .actions .remove { margin-left: 8px; }
@media (max-width: 420px) { .queue .size { display: none; } }
.queue .actions button:disabled { opacity: .35; cursor: default; }
.run {
  display: block; width: 100%; margin-top: 12px; font: inherit; font-size: 17px; font-weight: 600;
  padding: 12px 18px; border-radius: 12px; border: 0; background: var(--fill); color: #fff; cursor: pointer;
}
.run:disabled { opacity: .5; cursor: default; }
.run[hidden] { display: none; }
#hint:empty { display: none; }
#hint { margin: 8px 0 0; }

.pro { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.pro-title { margin: 0 0 10px; font-size: 14px; font-weight: 600; color: var(--muted); }
/* One full-width row each, label left and badge right, so they line up. */
.pro-options { display: flex; flex-direction: column; gap: 8px; }
.pro-options button {
  font: inherit; font-size: 14px; padding: 8px 12px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--line-strong); background: transparent; color: var(--text);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: 100%; min-height: 44px; text-align: left;
}
.pro-options .badge { flex-shrink: 0; }
.pro-options button:hover { border-color: var(--accent); }
.pro-options button[data-counted] { border-color: var(--accent); background: var(--accent-soft); }
.badge { font-size: 12px; font-weight: 700; padding: 1px 6px; border-radius: 6px; border: 1px solid var(--line-strong); color: var(--muted); }
#pro-note { margin: 10px 0 0; }

section.info { margin: 48px 0; }
section.info h2 { font-size: 24px; letter-spacing: -0.01em; margin: 0 0 14px; }
.steps { padding-left: 20px; }
.steps li { margin-bottom: 6px; }
details { border-top: 1px solid var(--line); padding: 14px 0; }
details:last-of-type { border-bottom: 1px solid var(--line); }
summary { cursor: pointer; font-weight: 600; }
details p { color: var(--muted); margin: 8px 0 0; }

footer { border-top: 1px solid var(--line); padding: 20px 0 40px; color: var(--muted); font-size: 14px; }
.footer-links { display: flex; gap: 16px; margin-bottom: 14px; }
footer .langs { display: flex; flex-wrap: wrap; gap: 6px 14px; }
footer .langs a { color: var(--muted); text-decoration: none; }
footer .langs a:hover { color: var(--text); }
footer .langs a[aria-current="page"] { color: var(--text); font-weight: 600; }

.tools { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.tools a {
  display: grid; grid-template-columns: auto 1fr; column-gap: 14px; align-items: start;
  padding: 16px 18px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--card); text-decoration: none; transition: border-color .15s, transform .15s;
}
.tools a:hover { border-color: var(--tc, var(--accent)); }
.tools a .tile { grid-row: span 2; }
.tools strong { display: block; font-size: 18px; margin: 2px 0 2px; }
.tools a > span:not(.tile) { color: var(--muted); font-size: 15px; }

/* Hub and 404: a 2 × 2 grid, icon on top. */
.tools.grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 48px; }
.tools.grid a { display: flex; flex-direction: column; gap: 10px; height: 100%; padding: 18px; }
.tools.grid strong { margin: 0; }
/* An odd card out takes the whole last row, icon beside the text. */
.tools.grid li:last-child:nth-child(odd) { grid-column: 1 / -1; }
.tools.grid li:last-child:nth-child(odd) a { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 2px 14px; }
@media (max-width: 520px) { .tools.grid li:last-child:nth-child(odd) .tile { grid-row: auto; } }
@media (max-width: 520px) {
  .tools.grid { gap: 10px; }
  .tools.grid a { padding: 16px 14px; }
  .tools.grid strong { font-size: 17px; line-height: 1.25; }
  .tools.grid a > span:not(.tile) { display: none; }
}

.legal h1 { font-size: 32px; }
.legal h2 { font-size: 20px; margin-top: 28px; }
.legal p, .legal li { color: var(--text); }

@media (max-width: 520px) {
  .levels button { font-size: 14px; padding: 10px 4px; }
  #drop { padding: 36px 12px; }
}

.contact label { display: block; font-weight: 600; font-size: 15px; margin: 16px 0 6px; }
.contact input, .contact textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--card);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
}
.contact textarea { min-height: 160px; resize: vertical; }
.contact input:focus, .contact textarea:focus { outline: none; border-color: var(--accent); }
.contact button {
  margin-top: 16px; font: inherit; font-weight: 600; padding: 11px 22px; border-radius: 10px;
  border: 0; background: var(--fill); color: #fff; cursor: pointer;
}
.contact button:disabled { opacity: .6; cursor: default; }
.contact .hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
#contact-status { min-height: 1.5em; margin: 12px 0 0; }
#contact-status.ok { color: var(--ok); font-weight: 600; }
#contact-status.err { color: var(--accent); }
.note { color: var(--muted); font-size: 14px; }

/* --- ID card copy ------------------------------------------------------------ */
.idcard .side + .side { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.side-title { font-size: 17px; margin: 0 0 10px; }
.slot {
  border: 2px dashed var(--line-strong); border-radius: var(--radius); padding: 26px 16px;
  text-align: center; cursor: pointer; transition: border-color .15s, background .15s;
}
.slot:hover, .slot:focus-visible, .slot.over { border-color: var(--accent); background: var(--accent-soft); outline: none; }
.slot > * { pointer-events: none; }
.slot .choose {
  display: inline-flex; align-items: center; gap: 10px; padding: 12px 22px; border-radius: 12px;
  background: var(--fill); color: #fff; font-weight: 600; font-size: 17px;
}
.slot .hint { display: block; color: var(--muted); font-size: 15px; margin-top: 10px; }
@media (pointer: coarse) { .slot .hint { display: none; } }
.side-status:empty { display: none; }
.side-status { color: var(--accent); }
.editor .note { margin: 0 0 8px; }
.stage { position: relative; width: fit-content; max-width: 100%; margin: 0 auto 10px; touch-action: pan-y; }
.stage .photo { display: block; max-width: 100%; max-height: 62vh; width: auto; height: auto; border-radius: 8px; }
.stage svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.stage polygon { fill: rgba(31, 95, 191, .12); stroke: #fff; stroke-width: 3; vector-effect: non-scaling-stroke; filter: drop-shadow(0 0 1.5px rgba(0,0,0,.8)); }
.handle {
  position: absolute; width: 44px; height: 44px; margin: -22px 0 0 -22px; padding: 0;
  border: 0; background: transparent; cursor: grab; touch-action: none;
}
.handle::after {
  content: ""; position: absolute; inset: 10px; border-radius: 50%;
  border: 3px solid #fff; background: rgba(31, 95, 191, .35); box-shadow: 0 0 0 1.5px rgba(0,0,0,.6);
}
.handle.active { cursor: grabbing; }
.handle.active::after, .handle:focus-visible::after { inset: 6px; background: rgba(31, 95, 191, .55); }
.handle:focus-visible { outline: none; }
.side-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.side-actions .row-action { gap: 8px; }
.editor .card {
  display: block; width: 100%; max-width: 420px; aspect-ratio: 1011 / 638; height: auto; margin: 0 0 10px;
  border-radius: 10px; cursor: crosshair; touch-action: none; background: var(--bg);
}
.id-output { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.id-output[hidden] { display: none; }
.id-output label { display: block; font-weight: 600; font-size: 15px; margin: 0 0 6px; }
.id-output label.check { display: flex; align-items: center; gap: 10px; min-height: 44px; margin: 0; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--fill); }
.id-output input[type=text] {
  width: 100%; font: inherit; color: var(--text); background: var(--card); min-height: 44px;
  border: 1px solid var(--line-strong); border-radius: 10px; padding: 10px 12px; margin-bottom: 14px;
}
.id-output input[type=text]:focus { outline: none; border-color: var(--accent); }
.id-output input:disabled { opacity: .5; }
.id-output .run { margin-top: 4px; }
.id-output .reset, #clear { gap: 8px; margin-top: 14px; }
#clear[hidden] { display: none; }
