:root {
  --bg: #fafaf7; --fg: #1b1d1f; --muted: #5d6368; --line: #e3e3dc; --card: #fff;
  --accent: #0b6e4f; --accent-fg: #fff; --chip: #eef3ef; --err: #b42318;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --bg: #121414; --fg: #ecedeb; --muted: #a3a8a6; --line: #2b2f2e; --card: #1a1d1c; --accent: #37b38a; --accent-fg: #06110d; --chip: #1f2a26; --err: #f97066; color-scheme: dark; }
}
:root[data-theme="dark"] { --bg: #121414; --fg: #ecedeb; --muted: #a3a8a6; --line: #2b2f2e; --card: #1a1d1c; --accent: #37b38a; --accent-fg: #06110d; --chip: #1f2a26; --err: #f97066; color-scheme: dark; }
* { box-sizing: border-box; }
/* Class display rules (.result, .btn) would otherwise beat the hidden attribute. */
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
main { max-width: 820px; margin: 0 auto; padding: 8px 16px 48px; }
.top { display: flex; flex-wrap: wrap; gap: 8px 20px; align-items: center; justify-content: space-between; max-width: 820px; margin: 0 auto; padding: 14px 16px; }
.logo { font-size: 20px; text-decoration: none; color: var(--fg); }
.logo b { color: var(--accent); }
nav { display: flex; gap: 16px; flex-wrap: wrap; }
nav a { color: var(--fg); text-decoration: none; font-size: 15px; }
h1 { font-size: clamp(26px, 5vw, 36px); line-height: 1.15; margin: 12px 0 8px; }
h2 { font-size: 20px; margin: 32px 0 10px; }
.lead { color: var(--muted); font-size: 17px; margin-top: 0; }
.muted, small { color: var(--muted); }
.tool, .kit, .mini, .app { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin: 16px 0; }
.drop { display: grid; gap: 4px; place-items: center; text-align: center; border: 2px dashed var(--line); border-radius: 12px; padding: 28px 12px; cursor: pointer; }
.drop.over, .drop:hover { border-color: var(--accent); }
.drop span { color: var(--muted); font-size: 14px; }
.opts { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin-top: 14px; }
.opts label, .mini label { display: grid; gap: 4px; font-size: 14px; color: var(--muted); }
.opts .chk { grid-column: 1 / -1; display: flex; gap: 8px; align-items: center; color: var(--fg); }
input, select { font: inherit; color: var(--fg); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; min-width: 0; }
.result { display: grid; gap: 10px; justify-items: start; margin-top: 16px; }
.result img { max-width: 100%; max-height: 260px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.btn { display: inline-block; border: 1px solid var(--line); border-radius: 10px; padding: 10px 16px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; color: var(--fg); background: var(--card); }
.btn.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.err { color: var(--err); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips a { background: var(--chip); padding: 6px 10px; border-radius: 999px; text-decoration: none; font-size: 14px; }
.chips.big a { font-size: 16px; padding: 8px 14px; }
.cta { border: 1px solid var(--accent); border-radius: 14px; padding: 16px; margin: 24px 0; }
.cta p { margin: 6px 0 12px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.card { display: grid; gap: 4px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px; text-decoration: none; color: var(--fg); }
.card span { color: var(--muted); font-size: 14px; }
table { width: 100%; border-collapse: collapse; font-size: 15px; display: block; overflow-x: auto; }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
details { border-bottom: 1px solid var(--line); padding: 10px 0; }
summary { cursor: pointer; font-weight: 600; }
.row { display: grid; gap: 4px; margin-bottom: 12px; font-size: 14px; color: var(--muted); }
.kit-doc { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.kit-out { grid-column: 1 / -1; display: flex; gap: 8px; align-items: center; font-size: 14px; }
.kit-out img { height: 56px; border: 1px solid var(--line); background: #fff; }
.kit-download { margin-top: 14px; }
.mini { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
.mini output { grid-column: 1 / -1; font-size: 18px; }
.related { margin-top: 40px; }
.related h2 { font-size: 16px; }
footer { max-width: 820px; margin: 0 auto; padding: 24px 16px; color: var(--muted); font-size: 14px; border-top: 1px solid var(--line); }
figure { margin: 12px 0; display: grid; gap: 4px; }
figure img { max-width: 100%; max-height: 220px; border: 1px solid var(--line); background: #fff; justify-self: start; }
main, .top, footer { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.opts .wide { grid-column: span 2; }
.batch { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin: 16px 0; }
.batch-list, .app-list { list-style: none; padding: 0; margin: 14px 0 0; }
.batch-list li, .app-list li { display: grid; grid-template-columns: 56px 1fr auto; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.batch-list li b, .app-list li b { overflow-wrap: anywhere; font-weight: 600; }
.batch-list img, .batch-list .ph, .app-list img, .app-list .ph { width: 56px; height: 56px; object-fit: contain; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.batch-list .x, .app-list .x { border: 0; background: none; color: var(--muted); font-size: 22px; line-height: 1; cursor: pointer; padding: 4px 8px; }
.batch-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.batch-note:empty { display: none; }

/* Shared pieces for public/apps/ tools */
.app-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.app-status { color: var(--muted); font-size: 14px; margin: 10px 0 0; }
.app-status:empty, .app-note:empty { display: none; }
.app-note { font-size: 14px; color: var(--muted); margin: 10px 0 0; }
.progress { height: 6px; border-radius: 999px; background: var(--chip); overflow: hidden; margin-top: 10px; }
.progress > i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
/* A step that can't be measured: a short bar slides across instead. */
.progress.wait > i { width: 35%; animation: wait 1.3s ease-in-out infinite; }
@keyframes wait { from { transform: translateX(-100%); } to { transform: translateX(290%); } }
@media (prefers-reduced-motion: reduce) { .progress.wait > i { width: 100%; animation: none; opacity: .45; } }
.stage { margin-top: 14px; max-width: 100%; overflow: hidden; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); }
.stage canvas, .stage img { display: block; max-width: 100%; height: auto; margin: 0 auto; }
.checker { background-color: #fff; background-image: linear-gradient(45deg, #ddd 25%, transparent 25%, transparent 75%, #ddd 75%), linear-gradient(45deg, #ddd 25%, transparent 25%, transparent 75%, #ddd 75%); background-size: 16px 16px; background-position: 0 0, 8px 8px; }
textarea { font: inherit; color: var(--fg); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%; min-height: 160px; }

/* ---- apps: pdf ---- */
.opts .pdf-full { grid-column: 1 / -1; }
[data-app="image-to-pdf"] .opts select:disabled { opacity: .5; }
.pdf-move { display: flex; gap: 2px; }
.app-list .pdf-move .x { font-size: 18px; min-width: 32px; min-height: 36px; padding: 4px 6px; border-radius: 8px; }
.app-list .pdf-move .x:hover:not(:disabled), .app-list .pdf-move .x:focus-visible { color: var(--fg); background: var(--chip); }
.app-list .pdf-move .x:disabled { opacity: .3; cursor: default; }
.app-list .ph.pdf-ph { display: grid; place-items: center; background: var(--chip); color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: .04em; }
.pdf-result { margin-top: 14px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); display: grid; gap: 4px; font-size: 15px; overflow-wrap: anywhere; }
.pdf-result p { margin: 0; }
.pdf-result .muted, .pdf-result .err { font-size: 14px; }
.pdf-preview { padding: 10px; }
.pdf-preview img { max-height: 420px; width: auto; box-shadow: 0 0 0 1px var(--line); }

/* ---- apps: ai ---- */
.ai-result { margin-top: 4px; }
.ai-stage { display: grid; place-items: center; }
.ai-stage canvas { max-height: 70vh; width: auto; max-width: 100%; }
.ai-color input[type=color] { width: 100%; min-height: 42px; padding: 4px; cursor: pointer; }
.ai-compare { margin-top: 14px; max-width: 100%; overflow: hidden; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); }
.ai-compare.zoom { max-height: 75vh; overflow: auto; -webkit-overflow-scrolling: touch; }
.ai-frame { position: relative; width: min(100%, calc(70vh * var(--ar, 1))); margin: 0 auto; --pos: 50%; }
.ai-frame img { display: block; width: 100%; height: auto; }
.ai-frame .ai-before { position: absolute; inset: 0; height: 100%; clip-path: inset(0 calc(100% - var(--pos)) 0 0); }
.ai-line { position: absolute; top: 0; bottom: 0; left: var(--pos); width: 2px; margin-left: -1px; background: var(--accent); pointer-events: none; }
.ai-tag { position: absolute; top: 8px; padding: 2px 8px; border-radius: 999px; background: var(--card); color: var(--fg); border: 1px solid var(--line); font-size: 12px; pointer-events: none; }
.ai-tag-l { left: 8px; }
.ai-tag-r { right: 8px; }
.ai-tools { display: flex; gap: 10px; align-items: center; margin-top: 10px; }
.ai-slider { flex: 1; min-width: 0; padding: 0; accent-color: var(--accent); }
.ai-saved figure img { max-height: 320px; }

/* ---- apps: convert ---- */
.app[data-app="convert"] input[type="range"] { flex: 1; width: 0; min-width: 0; padding: 0; border: 0; background: none; accent-color: var(--accent); }
.cv-q span { display: flex; gap: 8px; align-items: center; min-height: 40px; }
.cv-q output { min-width: 3ch; text-align: right; color: var(--fg); font-variant-numeric: tabular-nums; }
.cv-heic { margin: 12px 0 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--chip); font-size: 14px; }
.cv-heic ul { margin: 6px 0 0; padding-left: 20px; }
.cv-heic li { margin: 4px 0; }
.cv-stage img { max-height: 320px; width: auto; }
.ocr-text { display: grid; gap: 4px; margin-top: 14px; font-size: 14px; color: var(--muted); }
.ocr-text textarea { min-height: 200px; resize: vertical; font-size: 15px; line-height: 1.5; }
.app[data-app="image-to-text"] .app-list:empty { display: none; }

/* ---- apps: edit ---- */
/* Overlays sit on the photo itself, so they use fixed white and black like
   the photo backgrounds above; page colours come from the tokens. */
.ed-work { margin-top: 4px; }
.drop.ed-small { padding: 12px; }
.drop.ed-small span { display: none; }
.ed-stage { padding: 22px; }
.ed-frame { position: relative; margin: 0 auto; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.ed-stage .ed-frame > canvas { display: block; width: 100%; height: 100%; max-width: none; margin: 0; }
.ed-shade { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.ed-hole { position: absolute; box-shadow: 0 0 0 100vmax rgb(0 0 0 / .55); }
.ed-box { position: absolute; border: 2px solid #fff; box-shadow: 0 0 0 1px rgb(0 0 0 / .55), inset 0 0 0 1px rgb(0 0 0 / .35); cursor: move; touch-action: none; outline: none; }
.ed-box:focus-visible { border-color: var(--accent); }
.ed-box.ed-thirds { background-image: linear-gradient(to right, transparent calc(33.33% - .5px), rgb(255 255 255 / .45) calc(33.33% - .5px), rgb(255 255 255 / .45) calc(33.33% + .5px), transparent calc(33.33% + .5px), transparent calc(66.67% - .5px), rgb(255 255 255 / .45) calc(66.67% - .5px), rgb(255 255 255 / .45) calc(66.67% + .5px), transparent calc(66.67% + .5px)), linear-gradient(to bottom, transparent calc(33.33% - .5px), rgb(255 255 255 / .45) calc(33.33% - .5px), rgb(255 255 255 / .45) calc(33.33% + .5px), transparent calc(33.33% + .5px), transparent calc(66.67% - .5px), rgb(255 255 255 / .45) calc(66.67% - .5px), rgb(255 255 255 / .45) calc(66.67% + .5px), transparent calc(66.67% + .5px)); }
/* 44 px touch targets with a 20 px dot drawn in the middle. */
.ed-h { position: absolute; width: 44px; height: 44px; margin: -22px 0 0 -22px; touch-action: none; }
.ed-h::after { content: ""; position: absolute; left: 12px; top: 12px; width: 20px; height: 20px; border-radius: 50%; background: var(--accent); border: 3px solid #fff; box-shadow: 0 0 0 1px rgb(0 0 0 / .45); }
.ed-h[data-h="nw"] { left: 0; top: 0; cursor: nwse-resize; }
.ed-h[data-h="ne"] { left: 100%; top: 0; cursor: nesw-resize; }
.ed-h[data-h="sw"] { left: 0; top: 100%; cursor: nesw-resize; }
.ed-h[data-h="se"] { left: 100%; top: 100%; cursor: nwse-resize; }
.ed-box.dragging .ed-h::after { transform: scale(1.15); }
.ed-kept { position: absolute; border: 2px dashed #fff; box-shadow: 0 0 0 1px rgb(0 0 0 / .45); pointer-events: none; }
.ed-info { font-size: 14px; color: var(--muted); margin: 8px 0 0; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.ed-label { font-size: 14px; color: var(--muted); margin: 14px 0 6px; }
.ed-tools { display: flex; flex-wrap: wrap; gap: 0 24px; }
.ed-seg { display: flex; flex-wrap: wrap; gap: 6px; }
.ed-seg button { font: inherit; font-size: 14px; color: var(--fg); background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px; min-height: 42px; cursor: pointer; }
.ed-seg button:hover { border-color: var(--accent); }
.ed-seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.ed-posrow { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.ed-pos.ed-seg { display: grid; grid-template-columns: repeat(3, 42px); gap: 4px; }
.ed-pos.ed-seg button { width: 42px; height: 42px; padding: 0; border-radius: 8px; display: grid; place-items: center; }
.ed-pos.ed-seg button::after { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.ed-pos.ed-seg button[aria-pressed="true"]::after { background: var(--accent-fg); }
.ed-val { color: var(--fg); font-variant-numeric: tabular-nums; }
.ed-work .opts input[type="range"] { padding: 0; border: 0; background: none; accent-color: var(--accent); min-height: 36px; width: 100%; }
.ed-work .opts input[type="color"] { padding: 3px; height: 44px; width: 100%; cursor: pointer; }
.ed-work .opts textarea { min-height: 72px; }
.ed-work input[type="checkbox"] { accent-color: var(--accent); width: 20px; height: 20px; flex: none; margin: 0; }
.ed-work .opts .wide { grid-column: 1 / -1; }
.ed-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin: 0; }
.ed-facts div { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.ed-facts dt { font-size: 13px; color: var(--muted); }
.ed-facts dd { margin: 2px 0 0; font-weight: 600; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.ed-out { display: block; margin-top: 8px; }
.ed-out img { max-width: 100%; max-height: 260px; border: 1px solid var(--line); border-radius: 6px; }

/* Home: how-it-works picture */
.how { margin: 0; display: grid; grid-template-columns: 1fr auto 1fr auto 1fr; align-items: center; gap: 8px; }
.how-step { text-align: center; }
.how-step p { margin: 10px 0 0; font-size: 14px; line-height: 1.35; }
.how-step p span { display: block; color: var(--muted); font-size: 13px; }
.how-arrow { color: var(--accent); font-size: 26px; font-weight: 700; }
.how-phone, .how-tool, .how-form { margin: 0 auto; background: var(--card); border: 1px solid var(--line); border-radius: 14px; height: 150px; }
.how-phone { width: 92px; padding: 14px 8px; border-width: 3px; border-color: var(--fg); border-radius: 18px; }
.how-phone svg { width: 100%; height: 100%; display: block; }
.how .sky { fill: var(--chip); } .how .skin { fill: #d9a37a; } .how .shirt { fill: var(--accent); }
.how-tool { width: 150px; display: flex; flex-direction: column; justify-content: center; gap: 10px; padding: 12px; }
.how-kb { font-size: 22px; font-weight: 700; color: var(--accent); background: var(--chip); border-radius: 10px; padding: 8px 4px; font-variant-numeric: tabular-nums; }
.how-lock { font-size: 12px; color: var(--muted); }
.how-lock::before { content: "🔒 "; }
.how-form { width: 170px; padding: 14px 12px; display: flex; flex-direction: column; gap: 9px; text-align: left; }
.how-line { height: 8px; border-radius: 4px; background: var(--line); }
.how-line.w70 { width: 70%; } .how-line.w50 { width: 50%; } .how-line.w60 { width: 60%; }
.how-up { display: flex; align-items: center; gap: 8px; border: 1.5px dashed var(--accent); border-radius: 8px; padding: 6px; font-size: 12px; line-height: 1.25; color: var(--muted); }
.how-up svg { width: 30px; height: 36px; flex: none; }
.how-up b { color: var(--fg); }
.how-up i { margin-left: auto; font-style: normal; font-weight: 700; color: var(--accent-fg); background: var(--accent); border-radius: 50%; width: 22px; height: 22px; display: grid; place-items: center; font-size: 13px; }
@media (max-width: 600px) {
  .how { grid-template-columns: 1fr; gap: 2px; }
  .how-arrow { font-size: 0; line-height: 1; text-align: center; }
  .how-arrow::after { content: "↓"; font-size: 24px; }
  .how-phone, .how-tool, .how-form { height: 124px; }
  .how-phone { width: 78px; padding: 10px 6px; }
}
