/* Fonts are local copies of the Google Fonts latin subsets (SIL Open Font License), so no visitor request leaves this site. */
@font-face { font-family: "Bricolage Grotesque"; font-style: normal; font-weight: 400 800; font-display: swap; src: url("fonts/bricolage-grotesque-latin.woff2") format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-style: normal; font-weight: 400 600; font-display: swap; src: url("fonts/jetbrains-mono-latin.woff2") format("woff2"); }

:root {
  color-scheme: light;
  --canvas: #E4E7FF;   --dots: #00000026;
  --surface: #FFFFFF;  --raised: #F1F2FF;    --code-bg: #FFFFFF;
  --ink: #000000;      --muted: #3D3D5C;
  --border: #000000;   --shadow-ink: #000000;
  --accent: #6C5CE7;   --accent-fg: #FFFFFF;
  --select: #FFE14D;   --select-fg: #000000;
  --error: #FF5277;    --error-fg: #B0002A;   --error-surface: #FFE3E9;
  --warning: #FFB347;  --warning-fg: #8A4B00; --warning-surface: #FFF6D1;
  --info: #00B3FF;     --info-fg: #005F87;    --info-surface: #E0F5FF;
  --green: #7CFF8A;    --yellow: #FFE14D;     --pink: #FF9EB0;
  --stamp: #8250DF;
  --radius: 0.25rem;   --bw: 2px;
  --shadow: 4px 4px 0 0 var(--shadow-ink);
  --sans: "Bricolage Grotesque", system-ui, sans-serif;
  --mono: "JetBrainsMono Nerd Font Mono", "JetBrains Mono", monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --canvas: #15122B;   --dots: #F3F0FF22;
    --surface: #262147;  --raised: #1D1938;    --code-bg: #1D1938;
    --ink: #F3F0FF;      --muted: #BDB6E6;
    --border: #F3F0FF;   --shadow-ink: #B9A8FF;
    --select: #6C5CE7;   --select-fg: #FFFFFF;
    --error-fg: #FF8A8A;   --error-surface: #3A1830;
    --warning-fg: #FFE14D; --warning-surface: #3A3018;
    --info-fg: #7FD9FF;    --info-surface: #132E45;
    --stamp: #A371F7;
  }
}

* { box-sizing: border-box; }
html { font-size: 18px; }
body {
  margin: 0; font: 1rem/1.5 var(--sans); color: var(--ink);
  background-color: var(--canvas);
  background-image: radial-gradient(var(--dots) 1.2px, transparent 1.2px);
  background-size: 16px 16px;
}
h1, h2, h3 { font-weight: 800; letter-spacing: -0.01em; margin: 0; }
p { margin: 0.4rem 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; box-shadow: 0 0 0 6px #FF527766; }

.wrap { max-width: 72rem; margin: 0 auto; padding: 16px; display: grid; gap: 18px; }
.card {
  background: var(--surface); border: var(--bw) solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px;
}
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.label { display: block; text-transform: uppercase; font-weight: 800; font-size: 0.7rem; letter-spacing: 0.06em; color: var(--muted); }
.field-label { font-weight: 800; margin: 0 0 4px; letter-spacing: -0.01em; }
.row-gap { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.error { color: var(--error-fg); background: var(--error-surface); border: var(--bw) solid var(--error); border-radius: var(--radius); padding: 6px 10px; font-weight: 600; }

.head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.head h1 { font-size: 2rem; }

.sticker {
  display: inline-block; padding: 0 6px; line-height: 1.5; white-space: nowrap;
  font-size: 0.72rem; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase;
  color: #000000; background: var(--pink);
  border: var(--bw) solid var(--shadow-ink); border-radius: 4px;
  box-shadow: 2px 2px 0 0 var(--shadow-ink);
  transform: rotate(var(--tilt, -3deg));
}
.sticker.ok { background: var(--green); --tilt: 2deg; }
.sticker.wait { background: var(--yellow); --tilt: -2deg; }
.sticker.info { background: var(--info); --tilt: 1.5deg; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; cursor: pointer; text-decoration: none;
  font: inherit; font-size: 0.9rem; font-weight: 700; color: var(--ink); background: var(--surface);
  border: var(--bw) solid var(--border); border-radius: var(--radius); min-height: 2rem;
  transition: transform 80ms, box-shadow 80ms;
}
.btn:not(:disabled):hover { transform: translate(-1px, -1px); box-shadow: 3px 3px 0 0 var(--shadow-ink); }
.btn:not(:disabled):active { transform: translate(3px, 3px); box-shadow: none; }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn.primary { background: var(--accent); color: var(--accent-fg); }
.btn.send {
  background: linear-gradient(135deg, #6C5CE7 0%, #FF5277 100%); color: #FFFFFF;
  box-shadow: 3px 3px 0 0 var(--shadow-ink); font-size: 1rem; padding: 6px 18px;
}
.btn.small-btn { font-size: 0.8rem; padding: 1px 8px; min-height: 1.75rem; }

.seg { display: inline-flex; overflow: hidden; background: var(--surface); border: var(--bw) solid var(--border); border-radius: var(--radius); }
.seg button { font: inherit; font-weight: 800; padding: 4px 14px; cursor: pointer; border: 0; background: transparent; color: var(--ink); min-height: 2rem; }
.seg button + button { border-left: var(--bw) solid var(--border); }
.seg button[aria-pressed="true"] { background: var(--select); color: var(--select-fg); }
.seg button:focus-visible { outline-offset: -4px; box-shadow: none; }

.tooltip, [data-tip]::after {
  max-width: 18rem; padding: 4px 8px; z-index: 50;
  font: 600 0.8rem/1.35 var(--sans); color: var(--ink); background: var(--surface);
  border: var(--bw) solid var(--border); border-radius: var(--radius);
  box-shadow: 3px 3px 0 0 var(--shadow-ink);
  text-transform: none; letter-spacing: normal; white-space: normal;
}
[data-tip] { position: relative; }
[data-tip]::after {
  content: attr(data-tip); position: absolute; left: 50%; bottom: calc(100% + 8px);
  width: max-content; transform: translateX(-50%);
  opacity: 0; pointer-events: none; transition: opacity 120ms;
}
[data-tip=""]::after { display: none; }
[data-tip]:hover::after { opacity: 1; transition-delay: 300ms; }
[data-tip]:focus-visible::after { opacity: 1; transition-delay: 0ms; }
.sticker[data-tip]::after { transform: translateX(-50%) rotate(calc(-1 * var(--tilt, -3deg))); }

.check {
  appearance: none; margin: 0; flex: none; width: 1.15em; height: 1.15em; cursor: pointer;
  display: inline-grid; place-content: center; background: var(--surface);
  border: var(--bw) solid var(--border); box-shadow: 2px 2px 0 0 var(--shadow-ink); border-radius: 4px;
  transition: transform 80ms, box-shadow 80ms;
}
.check::after {
  content: ""; width: 0.6em; height: 0.32em; opacity: 0;
  border: solid var(--select-fg); border-width: 0 0 3px 3px; transform: rotate(-45deg) translate(1px, -1px);
}
.check:checked { background: var(--select); }
.check:checked::after { opacity: 1; }
.check:active { transform: translate(2px, 2px); box-shadow: none; }
.switch {
  appearance: none; margin: 0; flex: none; position: relative; cursor: pointer;
  width: 2.4em; height: 1.35em; border-radius: 999px; background: var(--surface);
  border: var(--bw) solid var(--border); box-shadow: 2px 2px 0 0 var(--shadow-ink);
  transition: background 120ms, transform 80ms, box-shadow 80ms;
}
.switch::before {
  content: ""; position: absolute; top: 50%; left: 2px; width: 0.95em; height: 0.95em;
  border-radius: 50%; background: var(--ink); transform: translateY(-50%); transition: left 120ms;
}
.switch:checked { background: var(--select); }
.switch:checked::before { left: calc(100% - 0.95em - 2px); background: var(--select-fg); }
.switch:active { transform: translate(2px, 2px); box-shadow: none; }
.choice { display: inline-flex; align-items: center; gap: 0.5em; min-height: 1.75rem; cursor: pointer; font-weight: 600; }

.drop { text-align: center; padding: 28px 16px; border-style: dashed; }
.drop.over { background: var(--select); color: var(--select-fg); }
.drop-title { font-weight: 800; font-size: 1.4rem; letter-spacing: -0.01em; }
.file-btn { font-size: 1rem; padding: 6px 18px; margin: 6px 0; }
.formats { margin-top: 6px; }
.formats summary { cursor: pointer; font-weight: 700; }

.job-row { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: center; }
.job-name { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; min-width: 0; }
.job-name strong { overflow-wrap: anywhere; }
.job-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.pages { list-style: none; margin: 0; padding: 0; display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr)); }
.page { min-width: 0; border: var(--bw) solid var(--border); border-radius: var(--radius); background: var(--raised); padding: 8px; display: grid; gap: 6px; align-content: start; }
.page.selected { background: var(--select); color: var(--select-fg); }
.page-thumb { display: block; width: 100%; max-height: 24rem; background: #FFFFFF; border: var(--bw) solid var(--border); aspect-ratio: var(--ratio, 0.77); object-fit: contain; }
.page-thumb.pending { display: grid; place-content: center; color: #3D3D5C; font-weight: 700; }
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 6px; }
.crops { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.crops li { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 6px; font-size: 0.8rem; font-weight: 600; background: var(--surface); color: var(--ink); border: var(--bw) solid var(--border); border-radius: 4px; padding: 2px 6px; }
.crops label { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }

.export-grid { display: flex; flex-wrap: wrap; gap: 18px 32px; align-items: flex-end; margin: 6px 0 10px; }
.note ul { margin: 6px 0; padding-left: 1.2rem; }
.note li { margin: 3px 0; }

.scrim { position: fixed; inset: 0; background: #0006; z-index: 60; }
.dialog {
  /* Anchored at the top, not centred: a centred dialog moves when its content height changes, also during a crop drag. */
  position: fixed; left: 50%; top: 1rem; transform: translateX(-50%); z-index: 61;
  width: min(60rem, calc(100vw - 2rem)); max-height: calc(100dvh - 2rem); overflow: auto; padding: 16px;
  background: var(--surface); border: var(--bw) solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.crop-stage { position: relative; margin: 8px auto; width: fit-content; max-width: 100%; touch-action: none; user-select: none; cursor: crosshair; border: var(--bw) solid var(--border); background: #FFFFFF; }
.crop-stage img { display: block; max-width: 100%; max-height: calc(100dvh - 15rem); }
.crop-box { position: absolute; border: 2px solid #6C5CE7; outline: 2px solid #FFFFFF; background: #6C5CE722; cursor: move; box-shadow: 0 0 0 9999px #0005; }
.crop-box .h { position: absolute; width: 1.1rem; height: 1.1rem; background: #FFE14D; border: 2px solid #000000; border-radius: 4px; }
.crop-box .nw { left: -0.6rem; top: -0.6rem; cursor: nwse-resize; }
.crop-box .ne { right: -0.6rem; top: -0.6rem; cursor: nesw-resize; }
.crop-box .sw { left: -0.6rem; bottom: -0.6rem; cursor: nesw-resize; }
.crop-box .se { right: -0.6rem; bottom: -0.6rem; cursor: nwse-resize; }
.crop-foot { justify-content: flex-end; }
.crop-foot #crop-size { margin-right: auto; font-family: var(--mono); min-height: 3em; }

@media (max-width: 40rem) {
  .head { flex-direction: column; align-items: flex-start; }
  .head h1 { font-size: 1.6rem; }
  .pages { grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr)); gap: 10px; }
  .dialog { top: 0.5rem; width: calc(100vw - 1rem); max-height: calc(100dvh - 1rem); padding: 10px; }
  .crop-stage img { max-height: calc(100dvh - 17rem); }
  [data-tip]::after { display: none; }
}

.office-note { margin-top: 8px; color: var(--warning-fg); background: var(--warning-surface); border: var(--bw) solid var(--warning); border-radius: var(--radius); padding: 4px 10px; display: inline-block; }
.enhance-box { border-top: var(--bw) solid var(--border); padding-top: 12px; margin: 10px 0; display: grid; gap: 10px; }
.enhance-options { display: flex; flex-wrap: wrap; gap: 14px 28px; align-items: flex-end; }
.caveat { flex-basis: 100%; margin: 0; padding: 6px 10px; font-weight: 600; color: var(--info-fg); background: var(--info-surface); border: var(--bw) solid var(--info); border-radius: var(--radius); }
.compare-dialog { width: min(80rem, calc(100vw - 2rem)); }
.compare-grid { display: grid; gap: 12px; grid-template-columns: 1fr; }
.compare-grid figure { margin: 0; min-width: 0; }
.compare-grid[data-view="original"] figure:last-child, .compare-grid[data-view="enhanced"] figure:first-child { display: none; }
.compare-scroll { overflow: auto; max-height: 40dvh; border: var(--bw) solid var(--border); background: #FFFFFF; }
.compare-grid[data-view="original"] .compare-scroll, .compare-grid[data-view="enhanced"] .compare-scroll { max-height: 70dvh; }
.compare-scroll img { display: block; max-width: none; }

.engine { margin-top: 10px; padding-top: 10px; border-top: var(--bw) solid var(--border); display: grid; gap: 6px; }
.engine p { margin: 0; }
.engine-facts { margin: 0; padding-left: 1.2rem; }
.bar { height: 0.9rem; border: var(--bw) solid var(--border); border-radius: var(--radius); background: var(--raised); overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; background: var(--select); transition: width 120ms; }
.licenses { width: 100%; border-collapse: collapse; margin: 8px 0; font-size: 0.9rem; }
.licenses th, .licenses td { border: var(--bw) solid var(--border); padding: 4px 8px; text-align: left; vertical-align: top; }
.licenses th { background: var(--raised); font-weight: 800; }
a { color: var(--accent); font-weight: 600; }
@media (prefers-color-scheme: dark) { a { color: #B9A8FF; } }

.test-note { background: var(--warning-surface); border-color: var(--warning); color: var(--ink); font-size: 0.95rem; }
.test-note strong { color: var(--warning-fg); }
