/*
 * Print-shop styling: flat surfaces, hairline borders, crop marks and a cutting-mat grid.
 * Two brand colours, Blue #2563EB and Violet #8457F2. Each is used as-is wherever it passes contrast
 * (borders, fills, dots, sliders need ≥3:1; text ≥4.5:1), with a nearby shade of the same colour where it would fail:
 *  Blue (primary): every standard interaction: main buttons, links, selected tiles and options, focus,
 *    checkboxes, sliders, the current menu item.
 *    --blue        borders, selected states, focus, sliders: #2563EB on light (5.2:1); #3B82F6 on dark (4.8:1),
 *                  since #2563EB there is only 3.4:1 and hard to spot
 *    hover         borders turn a lighter blue (--border-hover, ≥3.3:1); plain rows get a faint blue tint (--hover-bg)
 *    --blue-text   #2563EB on light; #60A5FA on dark (6.9:1), since #2563EB text on dark is only 3.4:1
 *    --blue-fill   main buttons: #2563EB with white text (5.2:1) in both modes; hover #1D4ED8 (6.7:1)
 *  Violet #8457F2 (accent): secondary cues that must not compete with blue: the "new" dot, FAQ markers,
 *    solid number tiles (steps, FAQ, cards), fact icons, the Pro tag, "Save" labels, Reset / Clear all.
 *    --violet       #8457F2 everywhere: white text on it is 4.54:1, and as text on white it is 4.54:1 too
 *                   (a hair deeper than #8B5CF6, which is only 4.2:1 with white)
 *    --violet-text  violet text: #8457F2 on light; #A78BFA on dark (6.4:1), since #8457F2 text there is only 3.9:1
 *    --violet-hover Reset / Clear all on hover: #7C3AED (white 5.7:1)
 * Neutral greys in light mode; dark mode is a deep blue-grey (softer to read than pure black, tinted
 * little enough not to skew how photo colours look). Checkerboards stay neutral grey.
 * The header toggle sets data-theme, otherwise the system setting wins.
 */
:root {
  /* Colours from the EditSpec brand kit (BRAND.md). Where a kit colour is too light for small text,
     the text variant is one step deeper; each is noted. */
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --field-border: #8492a6; /* text fields and dropdowns: 3.2:1, so it's clear where to type (kit border is 1.2:1) */
  --placeholder: #64748b;  /* lighter than typed text, still 4.8:1 */
  --text: #0f172a;
  --muted: #3f4d61;       /* secondary text: 7.8:1 or more on every surface, readable in bright light */
  --blue: #2563eb;
  --blue-text: #1e40af;   /* links and selected text: 7.9:1 on the pale blue selected fill */
  --blue-hover: #1e3a8a;
  --blue-soft: #eff4ff;
  --blue-fill: #2563eb;
  --blue-fill-hover: #1d4ed8;
  --violet: #8457f2;
  --violet-text: #5b2fd0; /* 7.6:1 on white */
  --violet-hover: #7c3aed;
  --control-h: 40px;
  --control-sm: 34px;
  --hover-bg: #f1f5f9;
  --border-hover: color-mix(in srgb, var(--blue) 65%, var(--border-strong));
  --on-blue: #ffffff;
  /* Status: kit #16A34A / #D97706 are 3.3:1 as text, so text uses #15803D / #B45309 (5.0:1). */
  --ok: #15803d;
  --ok-soft: #ecf8f1;
  --warn: #b45309;
  --warn-soft: #fcf4eb;
  --err: #dc2626;
  --checker-a: #e5e5e5;
  --checker-b: #ffffff;
  --grid: rgb(15 23 42 / .045);
  --pop: 0 1px 2px rgb(15 23 42 / .06), 0 8px 24px rgb(15 23 42 / .1);
  --radius: 10px;
  --radius-sm: 7px;
  --sun: block; --moon: none; --knob-x: 0px;
  --brand-gradient: linear-gradient(135deg, #2563eb, #8457f2); /* brand kit: logo, theme knob and menu icon */
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1220; --surface: #111827; --surface-2: #1f2937; --border: #273244; --border-strong: #334155; --field-border: #5b677d; --placeholder: #8494aa;
    --text: #f1f5f9; --muted: #b4bfcf; --blue: #3b82f6; --blue-text: #93c5fd; --blue-hover: #bfdbfe;
    --blue-soft: rgb(59 130 246 / .16); --blue-fill: #2563eb; --blue-fill-hover: #1d4ed8; --on-blue: #ffffff;
    --violet: #8457f2; --violet-text: #b9a3fb; --violet-hover: #7c3aed;
    --hover-bg: #1f2937; --border-hover: color-mix(in srgb, var(--blue) 70%, var(--border-strong));
    --ok: #4ade80; --ok-soft: rgb(74 222 128 / .12); --warn: #f59e0b; --warn-soft: rgb(245 158 11 / .12); --err: #f87171;
    --checker-a: #1f1f1f; --checker-b: #121212; --grid: rgb(255 255 255 / .055);
    --pop: 0 0 0 1px #334155, 0 12px 32px rgb(0 0 0 / .5);
    --sun: none; --moon: block; --knob-x: 28px;
    color-scheme: dark;
  }
}
/* Kit dark primary hover is #3B82F6, but white text on it is 3.7:1, so buttons darken to #1D4ED8 (6.7:1). */
:root[data-theme="dark"] {
  --bg: #0b1220; --surface: #111827; --surface-2: #1f2937; --border: #273244; --border-strong: #334155; --field-border: #5b677d; --placeholder: #8494aa;
  --text: #f1f5f9; --muted: #b4bfcf; --blue: #3b82f6; --blue-text: #93c5fd; --blue-hover: #bfdbfe;
  --blue-soft: rgb(59 130 246 / .16); --blue-fill: #2563eb; --blue-fill-hover: #1d4ed8; --on-blue: #ffffff;
  --violet: #8457f2; --violet-text: #b9a3fb; --violet-hover: #7c3aed;
  --hover-bg: #1f2937; --border-hover: color-mix(in srgb, var(--blue) 70%, var(--border-strong));
  --ok: #4ade80; --ok-soft: rgb(74 222 128 / .12); --warn: #f59e0b; --warn-soft: rgb(245 158 11 / .12); --err: #f87171;
  --checker-a: #1f1f1f; --checker-b: #121212; --grid: rgb(255 255 255 / .055);
  --pop: 0 0 0 1px #334155, 0 12px 32px rgb(0 0 0 / .5);
  --sun: none; --moon: block; --knob-x: 28px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; color: var(--text); background: var(--bg);
  font: 16px/1.55 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  -webkit-font-smoothing: antialiased;
  /* Short pages: main grows so the footer sits at the bottom of the window. */
  min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column;
}
body > main { flex: 1 0 auto; }
body > .site-header, body > .site-footer { flex: none; }
a { color: var(--blue-text); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { color: var(--blue-hover); }
.wrap { max-width: 1160px; margin: 0 auto; padding: 0 16px; }
[hidden] { display: none !important; }

/* header */
.site-header { position: sticky; top: 0; z-index: 20; background: var(--surface); border-bottom: 1px solid var(--border); }
.header-inner { display: flex; align-items: center; gap: 20px; min-height: 68px; }
.brand { display: flex; align-items: center; gap: 9px; white-space: nowrap; color: var(--text); text-decoration: none; }
/* Brand-kit logo and mark, used as supplied: navy lettering on light, light lettering on dark. */
.brand .logo { display: block; height: 40px; width: auto; }
.logo-dark { display: none !important; }
:root[data-theme="dark"] .logo-light { display: none !important; }
:root[data-theme="dark"] .logo-dark { display: block !important; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .logo-light { display: none !important; }
  :root:not([data-theme="light"]) .logo-dark { display: block !important; }
}
.brand:hover { color: var(--text); }
.theme-toggle, .menu-toggle { flex: none; display: grid; place-items: center; cursor: pointer; padding: 0; font: inherit; }
.theme-toggle svg, .menu-toggle svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Light/dark switch: a pill track with faint sun and moon, and a brand-gradient knob that slides to the active side. */
.theme-toggle { border: 0; background: none; border-radius: 999px; }
.tt-track { position: relative; display: block; width: 60px; height: 32px; border-radius: 999px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--border-strong); transition: background-color .2s; }
.tt-ico { position: absolute; top: 9px; width: 14px; height: 14px; color: var(--muted); }
.tt-ico-sun { left: 9px; }
.tt-ico-moon { right: 9px; }
.tt-knob { position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%;
  background: var(--brand-gradient); color: #fff; box-shadow: 0 1px 2px rgb(15 23 42 / .25); transform: translateX(var(--knob-x)); transition: transform .25s cubic-bezier(.3, .7, .4, 1); }
.tt-knob svg { width: 14px; height: 14px; stroke-width: 2.2; }
.tt-knob .sun { display: var(--sun); }
.tt-knob .moon { display: var(--moon); }
.theme-toggle:hover .tt-track { background: var(--hover-bg); }

/* Menu button (small screens): hairline square, brand-gradient lines that fold into a cross when open. */
.menu-toggle { display: none; width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); }
.menu-toggle svg { width: 22px; height: 22px; overflow: visible; }
.mt-line { stroke: url(#menuGrad); stroke-width: 2.2; transform-box: fill-box; transform-origin: center; transition: transform .25s cubic-bezier(.3, .7, .4, 1), opacity .15s, d .2s; }
.menu-toggle:hover .mt-2 { d: path("M4 12h16"); }
.menu-toggle[aria-expanded="true"] { border-color: var(--border-strong); background: var(--surface-2); }
.menu-toggle[aria-expanded="true"] .mt-1 { transform: translateY(5px) rotate(45deg); }
.menu-toggle[aria-expanded="true"] .mt-2 { opacity: 0; }
.menu-toggle[aria-expanded="true"] .mt-3 { transform: translateY(-5px) rotate(-45deg); }
@media (max-width: 720px) {
  .header-inner { gap: 4px; min-height: 60px; }
  .brand .logo { height: 34px; }
}


/* A small violet dot marks a new tool in the nav; "(new)" is there for screen readers. */
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* A secondary action set as a text link, e.g. Clear all: violet, so it never competes with the sky buttons. */
.link-btn { font: inherit; font-size: 13px; font-weight: 600; color: var(--violet-text); background: none; border: 0; padding: 0 4px; height: var(--control-sm); cursor: pointer; text-underline-offset: 3px; }
.link-btn:hover { text-decoration: underline; }

/* hero: headline and description, with the two promises in a row underneath */
.hero { padding: 44px 16px 26px; }
.hero h1 { font-size: clamp(30px, 4.4vw, 46px); line-height: 1.08; margin: 0 0 12px; letter-spacing: -0.03em; font-weight: 800; }
.lede { margin: 0; color: var(--muted); font-size: 18px; max-width: 60ch; }
.facts { list-style: none; margin: 18px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 12px 32px; }
.facts li { display: flex; gap: 10px; align-items: center; font-size: 13px; color: var(--muted); }
/* Each icon sits on a solid violet tile with a white icon. */
.facts svg { flex: none; box-sizing: content-box; width: 16px; height: 16px; padding: 7px; border-radius: var(--radius-sm); background: var(--violet); fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.facts span { display: grid; line-height: 1.35; }
.facts strong { font-size: 14px; font-weight: 600; color: var(--text); }

/* tool layout */
.tool {
  display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px;
  grid-template-areas: "work panel"; align-items: start;
}
/* Preview + download bar stay in view while the settings column scrolls, until the tool ends. */
.work { grid-area: work; position: sticky; top: 84px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; min-width: 0; }
.work .canvas-wrap { max-height: min(540px, calc(100vh - 320px)); }
/* The stage is a cutting mat: a faint grid the photo sits on. */
.stage {
  border: 1px solid var(--border); border-radius: var(--radius); min-height: 400px; display: flex;
  background-color: var(--surface);
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 24px 24px; background-position: -1px -1px;
}
.panel { grid-area: panel; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 0 20px; }
@media (max-width: 1024px) {
  .tool { grid-template-columns: minmax(0, 1fr) 320px; gap: 14px; }
  .panel { padding: 0 16px; }
}
@media (max-width: 760px) {
  .tool { grid-template-columns: minmax(0, 1fr); grid-template-areas: "stage" "panel" "result"; }
  .work { display: contents; }
  .work .canvas-wrap { max-height: min(540px, 62vh); }
  .stage { grid-area: stage; min-height: 300px; }
  .stage:has(.editor:not([hidden])) { min-height: 0; } /* photo open: the stage is as tall as the photo needs */
  .result { grid-area: result; }
}

/* Crop marks at the four corners frame the drop area, like a print ready to be trimmed. */
.drop {
  --mark: var(--text); --len: 22px; --w: 2px;
  flex: 1; margin: 22px; border-radius: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 40px 16px; text-align: center; color: var(--muted);
  background:
    linear-gradient(var(--mark) 0 0) top left / var(--len) var(--w), linear-gradient(var(--mark) 0 0) top left / var(--w) var(--len),
    linear-gradient(var(--mark) 0 0) top right / var(--len) var(--w), linear-gradient(var(--mark) 0 0) top right / var(--w) var(--len),
    linear-gradient(var(--mark) 0 0) bottom left / var(--len) var(--w), linear-gradient(var(--mark) 0 0) bottom left / var(--w) var(--len),
    linear-gradient(var(--mark) 0 0) bottom right / var(--len) var(--w), linear-gradient(var(--mark) 0 0) bottom right / var(--w) var(--len);
  background-repeat: no-repeat;
}
.drop:hover, .drop.over { --mark: var(--blue); }
.drop.over { background-color: var(--blue-soft); }
.drop svg { color: var(--muted); width: 40px; height: 40px; margin-bottom: 2px; }
.drop-title { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -0.01em; color: var(--text); }
.drop .btn { margin-top: 4px; }
.drop-hint { margin: 0; font-size: 13px; max-width: 44ch; }
.drop-hint.err { color: var(--err); }

.editor { flex: 1; display: flex; flex-direction: column; padding: 10px; gap: 10px; min-width: 0; }
.canvas-wrap {
  /* Height follows the photo's shape (set in app.js); these are only the limits. */
  position: relative; height: 400px; max-height: min(540px, 62vh); min-height: 160px; display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm); overflow: hidden; touch-action: none;
}
#preview {
  display: block; max-width: 100%; box-shadow: 0 0 0 1px var(--border), 0 6px 20px rgb(0 0 0 / .1);
  background-color: var(--checker-b);
  background-image: linear-gradient(45deg, var(--checker-a) 25%, transparent 25%, transparent 75%, var(--checker-a) 75%), linear-gradient(45deg, var(--checker-a) 25%, transparent 25%, transparent 75%, var(--checker-a) 75%);
  background-size: 16px 16px; background-position: 0 0, 8px 8px;
}
#preview.pannable { cursor: grab; }
#preview.pannable:active { cursor: grabbing; }
/* Crop box: the area outside is dimmed; thirds lines help framing. */
.crop-box { position: absolute; box-shadow: 0 0 0 100vmax rgb(0 0 0 / .55); outline: 1px solid #fff; cursor: move; touch-action: none; }
.crop-box[hidden] { display: none; }
.crop-box:focus-visible { outline: 2px solid var(--blue); }
.crop-box::before, .crop-box::after { content: ""; position: absolute; pointer-events: none; border: 0 solid rgb(255 255 255 / .45); }
.crop-box::before { inset: 0 33.333%; border-left-width: 1px; border-right-width: 1px; }
.crop-box::after { inset: 33.333% 0; border-top-width: 1px; border-bottom-width: 1px; }
.crop-box span { position: absolute; width: 14px; height: 14px; margin: -7px; background: #fff; border: 1px solid var(--blue); border-radius: 3px; z-index: 1; }
.crop-box span::before { content: ""; position: absolute; inset: -10px; } /* bigger touch target */
.crop-box [data-h="nw"] { left: 0; top: 0; cursor: nwse-resize; }
.crop-box [data-h="n"] { left: 50%; top: 0; cursor: ns-resize; }
.crop-box [data-h="ne"] { left: 100%; top: 0; cursor: nesw-resize; }
.crop-box [data-h="e"] { left: 100%; top: 50%; cursor: ew-resize; }
.crop-box [data-h="se"] { left: 100%; top: 100%; cursor: nwse-resize; }
.crop-box [data-h="s"] { left: 50%; top: 100%; cursor: ns-resize; }
.crop-box [data-h="sw"] { left: 0; top: 100%; cursor: nesw-resize; }
.crop-box [data-h="w"] { left: 0; top: 50%; cursor: ew-resize; }
/* Crop fields under the photo while the crop box is open; sizes are in the photo's pixels. */
.crop-tools { display: grid; grid-template-columns: minmax(0, 1.6fr) repeat(4, minmax(0, 1fr)); gap: 8px; }
.crop-tools > *, .crop-tools input, .crop-tools select { min-width: 0; }
.crop-tools[hidden] { display: none; }
@media (max-width: 900px) { .crop-tools { grid-template-columns: repeat(4, minmax(0, 1fr)); } .crop-tools .ratio { grid-column: 1 / -1; } }
@media (max-width: 560px) { .crop-tools { grid-template-columns: repeat(2, minmax(0, 1fr)); } .crop-tools .ratio { grid-column: 1 / -1; } }
.stage-top { display: flex; justify-content: flex-end; }
/* Violet action buttons (Reset, Clear all): filled violet with white text; hover darkens it.
   IDs so they outrank the shared hover and focus rules. */
#resetAll, #clearAll { display: inline-flex; align-items: center; gap: 6px; background: var(--violet); border-color: var(--violet); color: #fff; font-size: 14px; font-weight: 700; } /* white on brand violet is 4.5:1, so larger, bolder text */
#resetAll:hover, #clearAll:hover, #resetAll:focus-visible, #clearAll:focus-visible { background: var(--violet-hover); border-color: var(--violet-hover); color: #fff; }
.btn-violet svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
/* Progress sits in the middle of the photo, so it's never hidden behind the phone's Download bar. */
.busy { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 2; max-width: calc(100% - 24px); display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--border); padding: 10px 14px; border-radius: 12px; font-size: 14px; font-weight: 600; box-shadow: 0 8px 24px -8px rgb(15 23 42 / .3); }
.spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--border); border-top-color: var(--blue); animation: spin .8s linear infinite; }
/* First-use AI download: a thin bar under the status text. */
.load-bar { display: block; width: 100%; height: 4px; margin-top: 6px; border-radius: 2px; background: var(--surface-2); overflow: hidden; }
.load-bar[hidden] { display: none; }
.load-bar > span { display: block; width: 0; height: 100%; background: var(--blue); transition: width .2s linear; }
.busy { flex-wrap: wrap; }
.busy .load-bar { flex-basis: 100%; min-width: min(220px, 100%); margin-top: 4px; }
@keyframes spin { to { transform: rotate(360deg); } }
.stage-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.zoom { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 160px; font-size: 14px; color: var(--muted); }
.zoom input { flex: 1; }
.icon-btns { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.icon-btn { width: var(--control-sm); height: var(--control-sm); display: grid; place-items: center; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); cursor: pointer; }
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.stage-hint { margin: 0; font-size: 13px; color: var(--muted); }

/* panel */
/* Each step is numbered with the same violet tile as the FAQ and tool cards. */
.group { position: relative; padding: 18px 0; border-bottom: 1px solid var(--border); display: grid; gap: 10px; }
.group:last-child { border-bottom: 0; }
.group[hidden] { display: none; }
#fillBox { display: grid; gap: 10px; }
#fmtSeg { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); } /* formats: three per row */
/* Controls that only work with a photo are shown dimmed and inert until one is loaded. */
.size-locked { opacity: .4; filter: grayscale(1); pointer-events: none; user-select: none; }
/* Numbered steps make the order of the panel obvious. */
.panel { counter-reset: step; }
.group h2 { margin: 0; font-size: 15px; color: var(--text); font-weight: 600; display: flex; align-items: center; gap: 12px; }
.group.group-off h2::before, .group[hidden] h2::before { counter-increment: none; }
.group h2[data-step]::before { content: attr(data-step); }
.group h2::before { counter-increment: step; content: counter(step, decimal-leading-zero); flex: none; }
.label { margin: 0; font-size: 14px; color: var(--muted); }
.hint { font-size: 13px; color: var(--muted); margin: 0; }
.hint.err { color: var(--err); }
.field { display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; font-size: 13px; color: var(--muted); min-width: 0; }
.field.inline { display: flex; align-items: center; gap: 8px; }
.field.inline input { width: 72px; }
/* Every field, option and button shares one shape: --control-h tall, hairline border, --radius-sm corners. */
input[type="text"], input[type="email"], input[type="password"], input:not([type]), input[inputmode], select {
  font: inherit; font-size: 15px; color: var(--text); background: var(--surface); border: 1px solid var(--field-border);
  border-radius: var(--radius-sm); height: var(--control-h); padding: 0 12px; width: 100%; min-width: 0;
}
::placeholder { color: var(--placeholder); opacity: 1; }
select {
  -webkit-appearance: none; appearance: none; padding-right: 34px; cursor: pointer;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23888888' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center / 16px;
}
.dims { display: grid; grid-template-columns: 1fr auto 1fr 86px; gap: 8px; align-items: end; }
.lock { width: var(--control-h); height: var(--control-h); border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface); color: var(--muted); display: grid; place-items: center; cursor: pointer; }
.lock svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.dpi-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
/* File size stack: chips, the Max size field and the checkbox get the same spacing as the rest of the panel. */
.out-size { display: grid; gap: 10px; }
.out-size[hidden] { display: none; }
.kb-row + .check { margin-top: 2px; }
.kb-row { display: grid; grid-template-columns: 1fr 1fr 86px; gap: 8px; align-items: end; }
.kb-row.single { grid-template-columns: 1fr 86px; }

/* File-size shortcuts: Default (no limit) spans two columns, then six sizes, so both rows fill. */
.chips { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.chip-default { grid-column: span 2; }
.chip { font: inherit; font-size: 14px; height: var(--control-h); padding: 0 6px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); cursor: pointer; white-space: nowrap; }

/* Presets are two-column tiles: a one-line name, then one line per size. A flex column (not grid) so Safari
   grows the button to fit its text instead of letting the next row cover it. */
.presets { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.preset-group { grid-column: 1 / -1; margin: 10px 0 2px; font-size: 12px; font-weight: 600; color: var(--muted); }
.preset-group:first-child { margin-top: 0; }
.preset {
  font: inherit; text-align: left; display: flex; flex-direction: column; justify-content: flex-start; gap: 2px; min-width: 0;
  padding: 9px 10px 10px; border-radius: var(--radius-sm); cursor: pointer; line-height: 1.35;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
}
.preset strong { font-size: 13.5px; font-weight: 600; margin-bottom: 1px; }
.preset small { display: block; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 400; }
.preset[aria-pressed="true"] small { color: var(--blue-text); }
.preset[data-w="0"] { grid-column: 1 / -1; } /* Original size stands alone above the groups */

/* Choices are separate option boxes; the chosen one is tinted like every other selected control. */
.seg { display: flex; gap: 6px; }
.seg button {
  flex: 1; display: flex; align-items: center; justify-content: center; font: inherit; font-size: 14px; color: var(--text);
  border: 1px solid var(--border-strong); background: var(--surface); min-height: var(--control-h); padding: 4px 8px; border-radius: var(--radius-sm); cursor: pointer; line-height: 1.2; min-width: 0;
}
.seg button:disabled { opacity: .4; cursor: not-allowed; }
.icon-btn:disabled, .btn.ghost:disabled { opacity: .4; cursor: not-allowed; }

.slider-row { display: grid; grid-template-columns: 96px 1fr auto; align-items: center; gap: 10px; font-size: 14px; color: var(--muted); }
.slider-row input[type="range"] { width: 100%; }
/* Sliders are drawn by hand so they match in every browser: blue up to the handle, grey after it. */
input[type="range"] { -webkit-appearance: none; appearance: none; height: 20px; background: transparent; cursor: pointer; }
input[type="range"]::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: linear-gradient(to right, var(--blue) var(--p, 0%), var(--border-strong) var(--p, 0%)); }
input[type="range"]::-moz-range-track { height: 4px; border-radius: 2px; background: var(--border-strong); }
input[type="range"]::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--blue); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; margin-top: -6px; border-radius: 50%; background: var(--blue); border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--blue); }
input[type="range"]::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: var(--blue); border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--blue); }
.check { display: flex; gap: 9px; align-items: flex-start; font-size: 14px; color: var(--text); }
.check input { accent-color: var(--blue); margin-top: 3px; }

.swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.swatches button, .swatches .custom {
  width: 30px; height: 30px; border-radius: 4px; border: 1px solid var(--border-strong); background: var(--c); cursor: pointer; padding: 0; position: relative;
}
.swatches button[aria-pressed="true"], .swatches .custom.on { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--text); }
.swatches .transparent {
  background-color: #fff;
  background-image: linear-gradient(45deg, #ccc 25%, transparent 25%, transparent 75%, #ccc 75%), linear-gradient(45deg, #ccc 25%, transparent 25%, transparent 75%, #ccc 75%);
  background-size: 10px 10px; background-position: 0 0, 5px 5px;
}
.swatches .custom { background: conic-gradient(#f44336, #ffeb3b, #4caf50, #00bcd4, #3f51b5, #e91e63, #f44336); overflow: hidden; }
.swatches .custom input { opacity: 0; width: 100%; height: 100%; cursor: pointer; border: 0; padding: 0; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; font: inherit; font-weight: 600; border-radius: var(--radius-sm); height: var(--control-h); padding: 0 16px; border: 1px solid transparent; cursor: pointer; white-space: nowrap; }
/* Never wider than its container: a long label wraps onto two lines instead of spilling out. */
.btn { max-width: 100%; }
a.btn { height: auto; min-height: var(--control-h); padding-top: 8px; padding-bottom: 8px; white-space: normal; text-align: center; line-height: 1.3; }
.btn.primary { background: var(--blue-fill); color: var(--on-blue); }
.btn.primary:hover { background: var(--blue-fill-hover); }
.btn.primary:disabled { opacity: .5; cursor: progress; }
.btn.ghost { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.btn.small { height: var(--control-sm); padding: 0 12px; font-size: 13px; font-weight: 500; }
.btn.big { height: 46px; padding: 0 24px; font-size: 16px; }

/* result bar */
.result {
  display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
}
.result-info { flex: 1; min-width: 0; }
.result-main { margin: 0; font-weight: 600; font-size: 17px; font-variant-numeric: tabular-nums; }
.result-sub { margin: 0; font-size: 13px; color: var(--muted); }
.badge { font-size: 13px; font-weight: 600; padding: 3px 9px; border-radius: 5px; white-space: nowrap; }
.badge.ok { color: var(--ok); background: var(--ok-soft); }
.badge.warn { color: var(--warn); background: var(--warn-soft); }
/* Narrow result bar: size + badge on one row, details on one line, full-width download below. */
@media (max-width: 1024px) {
  .result { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; }
  .result-info { grid-column: 1; }
  .result-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .badge { grid-column: 2; grid-row: 1; align-self: start; }
  .result .btn { grid-column: 1 / -1; margin-top: 6px; }
}
@media (max-width: 760px) {
  .result { position: sticky; bottom: 0; z-index: 5; border-radius: 0; margin: 0 -16px; border-width: 1px 0 0; box-shadow: 0 -8px 24px rgb(0 0 0 / .08); }
}

/* content */
/* Reading column lines up with the headline instead of floating in the middle. */
.content { padding-top: 72px; padding-bottom: 8px; }
/* Pages without the "More photo tools" list end on the content: keep clear space above the footer. */
.content:last-child { padding-bottom: 88px; }
.content > * { max-width: 720px; }
.content h2 { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.2; margin: 48px 0 12px; }
.content > :first-child { margin-top: 0; }
.content p, .content li { color: var(--text); line-height: 1.7; }
.content h3 { font-size: 17px; margin: 24px 0 6px; }
/* Page sections share one quiet card style: surface, hairline border, a solid violet number tile.
   No heavy rules (in dark mode a text-coloured rule reads as a bright white bar). */
.content .steps li::before, .link-grid a::before, .faq summary::before, .group h2::before {
  display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: var(--radius-sm);
  background: var(--violet); color: #fff; /* solid violet tile, white number */
  font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums;
}

/* How it works: steps run across the page as cards. */
.content > .steps { max-width: none; }
.content .steps { list-style: none; counter-reset: s; padding: 0; margin: 20px 0 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(210px, 100%), 1fr)); gap: 12px; }
.content .steps li { counter-increment: s; margin: 0; padding: 16px 18px 18px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); line-height: 1.6; }
.content .steps li::before { content: counter(s, decimal-leading-zero); display: grid; margin-bottom: 12px; }

/* Questions: heading on the left, the answers in one rounded panel on the right. */
.content > .faq { max-width: none; display: grid; grid-template-columns: 260px minmax(0, 720px); gap: 0 48px; margin-top: 72px; align-items: start; }
.faq h2 { margin: 0; position: sticky; top: 92px; }
.faq > div { min-width: 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 0 20px; counter-reset: faq; }
.faq details + details { border-top: 1px solid var(--border); }
.faq details { counter-increment: faq; }
.faq summary { list-style: none; display: flex; align-items: center; gap: 14px; padding: 16px 0; font-weight: 600; cursor: pointer; }
.faq summary::before { content: counter(faq, decimal-leading-zero); flex: none; }
.faq summary span { flex: 1; min-width: 0; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; flex: none; font-size: 22px; font-weight: 300; line-height: 1; color: var(--violet); transition: transform .2s; }
.faq details[open] summary::after { transform: rotate(45deg); }
.faq summary:hover span { color: var(--blue-text); }
.faq details p { margin: -4px 0 18px 42px; color: var(--muted); max-width: 64ch; }
@media (max-width: 760px) {
  .content > .faq { grid-template-columns: minmax(0, 1fr); margin-top: 48px; }
  .faq h2 { position: static; margin-bottom: 12px; }
  .faq > div { padding: 0 16px; }
}

/* More tools: numbered cards; the border turns light blue on hover, like every other control. */
.related { padding-top: 80px; padding-bottom: 72px; }
.related h2 { font-size: 20px; font-weight: 800; letter-spacing: -0.01em; margin: 0 0 14px; }
.link-grid { list-style: none; counter-reset: tool; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr)); gap: 10px; }
.link-grid li { counter-increment: tool; display: grid; }
.link-grid a {
  display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 0 12px; align-items: center; padding: 14px 16px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
  text-decoration: none; color: var(--text); font-weight: 600; font-size: 15px; transition: border-color .15s;
}
.link-grid a::before { content: counter(tool, decimal-leading-zero); grid-row: 1 / 3; }
.link-grid a::after { content: "→"; grid-column: 3; grid-row: 1 / 3; color: var(--muted); transition: transform .15s, color .15s; }
.link-grid a:hover { border-color: var(--border-hover); color: var(--blue-text); }
.link-grid a:hover::after { color: var(--blue-text); transform: translateX(3px); }
.link-grid .tag { margin-left: 6px; vertical-align: 1px; }
.link-grid small { display: block; font-weight: 400; color: var(--muted); font-size: 13px; }

.site-footer { border-top: 1px solid var(--border); background: var(--surface); }
.footer-inner { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; flex-wrap: wrap; padding-top: 22px; padding-bottom: 22px; font-size: 14px; color: var(--muted); }
.footer-inner p { margin: 0; }
.footer-inner strong { font-size: 15px; font-weight: 700; color: var(--text); margin-right: 8px; }
.footer-brand { display: flex; align-items: center; flex-wrap: wrap; }
.footer-brand img { flex: none; margin-right: 8px; }
.footer-inner a { color: var(--muted); }
.footer-links { display: flex; flex-wrap: wrap; gap: 6px 20px; }
.footer-links a[aria-current] { color: var(--text); font-weight: 600; text-decoration-color: var(--blue); }
/* Privacy and Terms */
.page-legal .content { padding-top: 28px; }
.page-legal .content a[target="_blank"]::after { content: "\2197" / ""; margin-left: 2px; font-size: .85em; }
.legal-meta { color: var(--muted); font-size: 14px; margin: 0 0 20px; }
.legal-summary { padding: 18px 22px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.content .legal-summary h2 { margin: 0 0 8px; font-size: 18px; letter-spacing: 0; }
.legal-summary ul { margin: 0; padding-left: 20px; }
.page-legal .content ul { padding-left: 22px; }
.page-legal .content ul li + li { margin-top: 6px; }
.footer-inner a:hover { color: var(--text); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation-duration: .01ms !important; }
}

/* ------------------------------ product photos ------------------------------ */
/* Like the resizer, the photos and download bar stay in view until the tool ends;
   the photo grid scrolls inside its own box when the batch is long. */
.product-tool .stage { flex-direction: column; }
.product-tool .stage.over { outline: 2px dashed var(--blue); outline-offset: -8px; }
.batch { padding: 14px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; flex: 1; min-width: 0; }
.batch-bar { display: flex; align-items: center; gap: 10px; }
.batch-bar > * { flex: none; }
.batch-count { margin: 0; font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; margin-right: auto; }
/* Preview as: platform buttons in one row, up to a set width, then it scrolls sideways. */
.batch-bar > .preview-tabs { flex: 0 1 auto; }
.preview-tabs { display: flex; align-items: center; gap: 8px; min-width: 0; max-width: min(560px, 100%); font-size: 13px; color: var(--muted); }
.preview-tabs[hidden] { display: none; }
.pt-row { flex: 1; display: flex; gap: 6px; min-width: 0; overflow-x: auto; scroll-snap-type: x proximity; scrollbar-width: thin; padding: 2px 0; }
.pt-row .chip { flex: none; height: var(--control-sm); padding: 0 12px; display: inline-flex; align-items: center; gap: 6px; scroll-snap-align: start; }
.pt-row .chip span { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.pt-row .chip[aria-pressed="true"] span { color: inherit; opacity: .8; }
@media (max-width: 720px) { .batch-bar { flex-wrap: wrap; } .batch-bar > .preview-tabs { order: 3; flex-basis: 100%; max-width: 100%; } }
.pgrid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(min(168px, 100%), 1fr)); gap: 10px;
  max-height: max(260px, calc(100vh - 350px)); overflow-y: auto; overscroll-behavior: contain; padding-right: 2px; grid-auto-rows: max-content; align-content: start;
}
.pcard { margin: 0; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); display: flex; flex-direction: column; transition: opacity .15s, border-color .15s; }
.pcard.skipped { opacity: .45; }
.pcard.failed { border-color: color-mix(in srgb, var(--err) 55%, var(--border)); }
.pthumb { position: relative; display: block; width: 100%; aspect-ratio: var(--ratio, 1); border: 0; padding: 0; cursor: zoom-in; background: repeating-conic-gradient(var(--checker-a) 0 25%, var(--checker-b) 0 50%) 0 0 / 16px 16px; }
.pthumb canvas { width: 100%; height: 100%; display: block; }
.pstate { position: absolute; inset: 0; display: grid; place-items: center; padding: 10px; text-align: center; font-size: 13px; font-weight: 600; color: var(--text); background: color-mix(in srgb, var(--surface) 78%, transparent); }
.pcard.failed .pstate { color: var(--err); }
.pcard figcaption { display: flex; align-items: center; gap: 6px; padding: 6px 6px 6px 8px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.pnum { font-size: 12px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 18px; }
.pmode { flex: 1; min-width: 0; height: 30px; font-size: 12.5px; padding: 0 24px 0 8px; background-position: right 6px center; background-size: 14px; }
.pacts { display: flex; gap: 2px; width: 100%; justify-content: flex-end; }
.pacts .icon-btn { width: 28px; height: 28px; border-color: transparent; background: transparent; color: var(--muted); }
.pacts .icon-btn svg { width: 16px; height: 16px; }
.pacts [data-a="del"]:hover { color: var(--violet-text); }
.pacts [data-a="skip"][aria-pressed="true"] { color: var(--warn); background: var(--warn-soft); }
.padd { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 168px; border: 1.5px dashed var(--border-strong); border-radius: var(--radius-sm); background: transparent; color: var(--muted); font: inherit; font-size: 14px; cursor: pointer; }
.padd:hover { border-color: var(--blue); color: var(--blue-text); }
.padd svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

.mselect { position: relative; }
.mselect-btn { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px; font: inherit; font-size: 15px; text-align: left; color: var(--text); background: var(--surface); border: 1px solid var(--field-border); border-radius: var(--radius-sm); height: var(--control-h); padding: 0 10px 0 12px; cursor: pointer; }
.mselect-btn[aria-expanded="true"] { border-color: var(--blue); }
.mselect { min-width: 0; }
.mselect-btn span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mselect-btn svg { width: 16px; height: 16px; flex: none; fill: none; stroke: var(--muted); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; transition: transform .15s; }
.mselect-btn[aria-expanded="true"] svg { transform: rotate(180deg); }
.mselect-menu { position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 6px); max-height: min(420px, 60vh); overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--pop); padding: 4px; }
.mselect-menu[hidden] { display: none; }
.mselect-group { margin: 10px 8px 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
.mopt { display: flex; gap: 10px; align-items: flex-start; padding: 7px 8px; border-radius: 5px; cursor: pointer; }
.mopt input { accent-color: var(--blue); width: 16px; height: 16px; margin: 2px 0 0; flex: none; }
.mopt span { display: grid; gap: 1px; min-width: 0; }
.mopt strong { font-size: 14px; font-weight: 600; }
.mopt small { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.mselect-note { margin: 6px 8px 4px; padding-top: 8px; border-top: 1px solid var(--border); font-size: 12px; color: var(--muted); }
.market-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.market-list:empty { display: none; }
.market-list li { display: grid; gap: 1px; padding: 10px; border-radius: var(--radius-sm); border: 1px solid var(--border); font-size: 12px; color: var(--muted); }
.market-list strong { font-size: 13.5px; color: var(--text); }
.custom-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 6px; }
.custom-grid input[aria-invalid="true"] { border-color: var(--err); }
.logo-row { display: flex; gap: 8px; flex-wrap: wrap; }
#logoBox { display: grid; gap: 10px; transition: opacity .15s; }
/* Locked controls look exactly like the resizer's photo- and size-locked ones. */
#logoBox.locked, .swatches button:disabled, .swatches .custom.locked { opacity: .4; filter: grayscale(1); cursor: not-allowed; }
.swatches .custom.locked input { cursor: not-allowed; }
#logoOpts { display: grid; gap: 10px; }
#logoOpts[hidden] { display: none; }
#logoPos { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* Count, file name and download line up on the input's baseline. */
.product-result { display: grid; grid-template-columns: minmax(0, 1fr) minmax(180px, 250px) auto; align-items: end; gap: 14px; }
.product-result .result-main { white-space: nowrap; }
.product-result .result-main small { font-size: 13px; font-weight: 400; color: var(--muted); margin-left: 6px; }
.product-result .result-sub { min-height: 1.4em; }
.name-field { gap: 4px; }
.name-field > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.name-field small { font-size: 12px; color: var(--muted); }
.viewer { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); padding: 12px; width: min(760px, calc(100vw - 32px)); max-height: calc(100vh - 32px); box-shadow: var(--pop); }
.viewer::backdrop { background: rgb(0 0 0 / .6); }
.viewer[open] { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.viewer-bar { display: flex; align-items: center; gap: 6px; }
.viewer-bar select { flex: 0 1 auto; width: auto; min-width: 0; height: var(--control-sm); margin-right: auto; font-size: 14px; text-overflow: ellipsis; }
.viewer-bar .icon-btn { flex: none; }
.viewer canvas { width: 100%; max-width: 100%; height: auto; max-height: calc(100vh - 170px); object-fit: contain; border-radius: var(--radius-sm); background: repeating-conic-gradient(var(--checker-a) 0 25%, var(--checker-b) 0 50%) 0 0 / 16px 16px; }
@media (max-width: 1024px) {
  .product-result { grid-template-columns: minmax(0, 1fr) auto; }
  .product-result .result-info { grid-column: 1 / -1; }
  .product-result .btn { grid-column: auto; margin-top: 0; align-self: end; }
}
@media (max-width: 760px) {
  .pgrid { max-height: none; overflow: visible; }
}
@media (max-width: 480px) {
  .product-result { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .product-result .btn { width: 100%; }
  .pgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .batch { padding: 10px; }
  .padd { min-height: 140px; }
}

/* ------------------------------ interaction states ------------------------------ */
/* One pattern for every control, the same in light and dark (only the tokens change). States switch
 * instantly (no transitions) and never draw anything outside the control:
 *  rest      hairline border (--border-strong) on the surface colour
 *  hover     the border turns light blue (--border-hover); rows and icons without a border get a light tint instead
 *  focus     the border turns accent (keyboard, and any field holding the caret); borderless rows and
 *            icons get the hover tint, text links an underline
 *  selected  accent border, pale accent fill, accent text
 * Selected and disabled controls don't react to hover. */
:where(.btn.ghost, .icon-btn:not(.pacts .icon-btn), .chip, .seg button, .lock, .preset, .mselect-btn, input[type="text"], input[type="email"], input[type="password"], input:not([type]), input[inputmode], select):hover:not(:disabled):not(:focus):not([aria-checked="true"]):not([aria-pressed="true"]):not([aria-expanded="true"]) {
  border-color: var(--border-hover);
}
:where(.theme-toggle, .menu-toggle, .pacts .icon-btn):hover:not([aria-pressed="true"]) { background-color: var(--hover-bg); color: var(--text); }
:where(.mopt):hover { background-color: var(--hover-bg); }

.seg button[aria-checked="true"], .chip[aria-pressed="true"], .lock[aria-pressed="true"], .preset[aria-pressed="true"] {
  border-color: var(--blue); background-color: var(--blue-soft); color: var(--blue-text); font-weight: 600;
}

:focus { outline: none; }
.btn.ghost:focus-visible, .icon-btn:not(.pacts .icon-btn):focus-visible, .chip:focus-visible, .seg button:focus-visible, .lock:focus-visible, .preset:focus-visible, .mselect-btn:focus-visible,
input[type="text"]:focus, input[type="email"]:focus, input[type="password"]:focus, input:not([type]):focus, input[inputmode]:focus, select:focus { border-color: var(--blue); }
.custom-grid input[aria-invalid="true"]:focus { border-color: var(--err); }
.btn.primary:focus-visible { background: var(--blue-fill-hover); }
:where(.theme-toggle, .menu-toggle, .pacts .icon-btn, .mopt, .pthumb):focus-visible,
.mopt:has(input:focus-visible) { background-color: var(--hover-bg); color: var(--text); }
:where(a, .faq summary, .link-btn):focus-visible { text-decoration: underline; text-decoration-thickness: 2px; color: var(--blue-text); }
/* Buttons that are links (CTAs) never show a link underline. */
a.btn, a.btn:hover, a.btn:focus-visible { text-decoration: none; }
a.btn.primary, a.btn.primary:hover, a.btn.primary:focus-visible { color: var(--on-blue, #fff); }
.nav-link:focus-visible, .nav-btn:focus-visible { text-decoration: none; color: var(--text); box-shadow: inset 0 -2px 0 var(--blue); }
a.nav-item:focus-visible, a.tool-card:focus-visible { text-decoration: none; color: var(--text); }
a.tool-card:focus-visible { border-color: var(--blue); }
.swatches button:focus-visible, .swatches .custom:has(input:focus-visible) { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--blue); }
/* Native checkboxes and sliders have no border of their own, so they keep a thin keyboard-only outline. */
input[type="checkbox"]:focus-visible, input[type="range"]:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

/* ------------------------------ small phones ------------------------------ */
@media (max-width: 480px) {
  .hero { padding: 28px 16px 16px; }
  .hero h1 { margin-bottom: 8px; }
  .lede { font-size: 16px; }
  .tool { gap: 12px; }
  .drop { margin: 8px; padding: 28px 12px; }
  .editor { padding: 8px; }
  .work .canvas-wrap { max-height: min(440px, 52vh); }
  .stage-bar { gap: 8px; }
  .zoom { flex-basis: 100%; }
  .icon-btns { margin-left: 0; width: 100%; }
  .panel { padding: 0 14px; }
  .dims { grid-template-columns: 1fr auto 1fr 76px; gap: 6px; }
  .slider-row { grid-template-columns: auto 1fr auto; gap: 10px; }
  .slider-row label { white-space: nowrap; font-size: 13px; }
  /* Let long segment labels wrap instead of overflowing. */
  .seg button { padding: 4px; font-size: 13px; }
  .preset { padding: 8px 9px 9px; }
  .result { padding: 10px 16px 12px; gap: 8px 12px; }
  .result-main { font-size: 15px; }
  .result-sub { font-size: 12px; }
  .btn.big { padding: 0 20px; }
  .content { padding-top: 48px; }
  .content h2 { font-size: 23px; margin-top: 36px; }
  .related { padding-top: 56px; padding-bottom: 48px; }
  .content:last-child { padding-bottom: 56px; }
  .footer-inner { flex-direction: column; gap: 6px; }
}

/* Bigger hit areas on touch screens. */
@media (pointer: coarse) {
  .icon-btn { width: 44px; height: 44px; }
  .pacts .icon-btn { width: 36px; height: 36px; }
  .lock { width: 44px; height: 44px; }
  .swatches { gap: 10px; }
  .swatches button, .swatches .custom { width: 36px; height: 36px; }
  input[type="text"], input[type="email"], input[type="password"], input:not([type]), input[inputmode], select { font-size: 16px; } /* stops iOS zooming into fields */
  .check input { width: 20px; height: 20px; margin-top: 1px; }
  input[type="range"] { min-height: 28px; }
}

/* Phones: the photo buttons sit in even rows — the three icons across, then two equal text buttons. */
@media (max-width: 560px) {
  .icon-btns { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; margin-left: 0; width: 100%; }
  .icon-btns > * { grid-column: span 3; width: auto; height: var(--control-h); justify-content: center; }
  .icon-btns > .icon-btn { grid-column: span 2; }
  /* Tools without Crop photo: New photo takes the whole row. */
  .icon-btns:not(:has(#cropBtn:not([hidden]))) #change { grid-column: 1 / -1; }
}


/* ------------------------------------------------------------------ */
/* Main menu. Desktop: tool groups open a panel under the header.
   Up to 1024px (tablets and phones): everything folds behind the menu button into one stacked list.
   1025–1240px: the full menu with slightly tighter spacing.
   The header is wider than the page content so the full menu fits on laptops. */
.site-header .wrap { max-width: 1320px; }
.nav { display: flex; align-items: stretch; gap: 2px; margin-left: 28px; flex: 1; min-width: 0; align-self: stretch; }
.nav-link, .nav-btn {
  display: flex; align-items: center; gap: 4px; padding: 0 10px; font: inherit; font-size: 15px; font-weight: 500; color: var(--muted);
  text-decoration: none; white-space: nowrap; background: none; border: 0; cursor: pointer; box-shadow: inset 0 -2px 0 transparent;
}
.nav-link:hover, .nav-btn:hover, .nav-btn[aria-expanded="true"] { color: var(--text); }
.nav-link[aria-current], .nav-btn.active { color: var(--text); font-weight: 600; box-shadow: inset 0 -2px 0 var(--blue); }
.nav-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform .15s; }
.nav-btn[aria-expanded="true"] svg { transform: rotate(180deg); }
.nav-group { position: relative; display: flex; }
.nav-menu {
  display: none; position: absolute; top: calc(100% + 6px); left: 0; z-index: 30; min-width: 300px; padding: 8px; gap: 2px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: 0 1px 2px rgb(15 23 42 / .06), 0 12px 24px -6px rgb(15 23 42 / .14), 0 28px 56px -12px rgb(15 23 42 / .18);
  animation: menu-in .16s ease-out;
}
@keyframes menu-in { from { opacity: 0; transform: translateY(-4px); } }
.nav-btn[aria-expanded="true"] + .nav-menu { display: grid; }
.nav-group:first-child .nav-menu { grid-template-columns: repeat(2, minmax(0, 1fr)); min-width: 640px; }
.nav-end .nav-menu { left: auto; right: 0; }
.nav-item { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 12px; align-items: start; padding: 10px 12px; border-radius: 10px; color: var(--text); text-decoration: none; transition: background-color .15s; }
.ti-text { display: grid; gap: 2px; min-width: 0; }
.nav-item strong { display: block; font-size: 14px; font-weight: 600; }
.nav-item small { font-size: 13px; color: var(--muted); line-height: 1.4; }
a.nav-item:hover, a.nav-item:focus-visible { background: var(--hover-bg); }
/* Each tool is its own tile with a hairline edge, so rows stay separated on hover and on the current page. */
.nav-menu { gap: 6px; }
.nav-item { border: 1px solid var(--border); background: var(--surface); transition: border-color .15s, background-color .15s; }
a.nav-item:hover, a.nav-item:focus-visible { border-color: var(--border-hover); background: var(--hover-bg); }
a.nav-item[aria-current] { border-color: var(--blue); background: var(--blue-soft); }
/* Tool icon: a soft blue tile that turns brand gradient with a white icon on hover. */
.ti-icon { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 10px; background: var(--blue-soft); color: var(--blue-text); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--blue) 14%, transparent); transition: background .15s, color .15s; }
.ti-icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
a.nav-item:hover .ti-icon, a.nav-item:focus-visible .ti-icon, a.nav-item[aria-current] .ti-icon, a.tool-card:hover .ti-icon, a.tool-card:focus-visible .ti-icon { background: var(--brand-gradient); color: #fff; box-shadow: none; }
.is-soon .ti-icon { background: var(--surface-2); color: var(--muted); box-shadow: inset 0 0 0 1px var(--border); }
.nav-item[aria-current] strong { color: var(--blue-text); }
.nav-item.is-soon:not(a) { cursor: default; }
.nav-auth { display: flex; align-items: center; gap: 8px; margin-left: auto; padding-left: 12px; }
.nav-auth .btn { height: var(--control-sm); padding: 0 14px; font-size: 14px; }

/* Small tags: Pro (violet), Soon (grey). */
.tag { display: inline-flex; align-items: center; height: 18px; padding: 0 6px; border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; line-height: 1; }
.tag-pro { background: var(--violet); color: #fff; }
/* AI: an outlined tag on menu and home entries, and the word itself in page text. */
.nav-link .tag { margin-left: 4px; }
.tag-ai { color: var(--violet-text); box-shadow: inset 0 0 0 1px currentColor; }
.ai-word { color: var(--violet-text); font-weight: 700; }
.tag-soon { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.tag-lg { height: 26px; padding: 0 10px; font-size: 13px; vertical-align: middle; margin-left: 6px; }

@media (min-width: 1025px) and (max-width: 1240px) {
  .nav { margin-left: 12px; }
  .nav-link, .nav-btn { padding: 0 8px; }
  .header-inner { gap: 16px; }
}
@media (max-width: 1024px) {
  .menu-toggle { display: grid; }
  .theme-toggle { margin-left: auto; }
  .nav {
    display: none; position: absolute; top: 100%; left: 0; right: 0; flex-direction: column; gap: 0; margin: 0;
    max-height: calc(100dvh - 60px); overflow-y: auto; overscroll-behavior: contain;
    padding: 4px 16px 16px; background: var(--surface); border-bottom: 1px solid var(--border); box-shadow: 0 16px 32px rgb(0 0 0 / .14);
  }
  .nav.open { display: flex; }
  .nav-group { flex-direction: column; }
  .nav-link, .nav-btn { justify-content: space-between; min-height: 50px; padding: 0 2px; font-size: 16px; border-bottom: 1px solid var(--border); box-shadow: none; width: 100%; text-align: left; }
  .nav-link[aria-current], .nav-btn.active { box-shadow: inset 3px 0 0 var(--blue); padding-left: 12px; }
  .nav-menu, .nav-group:first-child .nav-menu { position: static; min-width: 0; grid-template-columns: minmax(0, 1fr); padding: 4px 0 8px; border: 0; border-radius: 0; box-shadow: none; background: none; }
  .nav-item { padding: 10px 12px; }
  .nav-auth { margin: 14px 0 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; }
  .nav-auth .btn { height: var(--control-h); font-size: 15px; }
}
@media (min-width: 560px) and (max-width: 1024px) {
  .nav-group:first-child .nav-menu { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ------------------------------------------------------------------ */
/* Site pages: home, pricing, log in / sign up, coming soon. */
.page-home .content > *, .page-pricing .content > * { max-width: none; }
.page-home .content, .page-pricing .content { padding-top: 24px; }
.page-auth .content, .page-soon .content { padding-top: 8px; }

.tool-cat + .tool-cat { margin-top: 40px; }
.tool-cat h2, .home-plans h2 { font-size: 22px; margin: 0 0 14px; }
.tool-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(250px, 100%), 1fr)); gap: 10px; }
.tool-card {
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 14px; align-items: start; padding: 16px 18px; border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface); color: var(--text); text-decoration: none; transition: border-color .15s, box-shadow .15s;
}
.tool-card .ti-text { gap: 4px; }
.tool-card .ti-icon { width: 40px; height: 40px; }
.tool-card .ti-icon svg { width: 20px; height: 20px; }
.tool-card strong { display: block; font-size: 16px; font-weight: 600; }
.nowrap { white-space: nowrap; }
/* Tags sit inline after the name, so a wrapped name keeps its tag beside the last word. */
.tool-card strong .tag, .nav-item strong .tag { margin-left: 6px; vertical-align: 2px; }
.tool-card small { font-size: 14px; color: var(--muted); line-height: 1.45; }
a.tool-card:hover { border-color: var(--border-hover); box-shadow: 0 6px 18px -8px rgb(15 23 42 / .18); }
.tool-card.is-soon { background: var(--surface-2); }
.home-plans { margin-top: 64px; }
.home-plans > p { color: var(--muted); max-width: 640px; }

/* Plan cards */
.plans { list-style: none; margin: 20px 0 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; align-items: stretch; max-width: 860px; }
.plan { position: relative; display: flex; flex-direction: column; gap: 10px; padding: 22px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.plan.featured { border: 2px solid var(--blue); padding: 21px; }
.plan-flag { position: absolute; top: -11px; left: 20px; padding: 3px 10px; border-radius: 999px; background: var(--blue-fill); color: var(--on-blue); font-size: 12px; font-weight: 700; }
.plan h3 { margin: 0; font-size: 20px; }
.plan-for { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.45; }
.plan-price { margin: 6px 0 0; display: flex; align-items: baseline; gap: 4px; }
.plan-price .amt { font-size: 36px; font-weight: 800; letter-spacing: -0.02em; line-height: 1; font-variant-numeric: tabular-nums; }
.plan-price .cur { font-size: 22px; margin-right: 1px; vertical-align: top; }
.plan-price .per, .plan-bill { color: var(--muted); font-size: 14px; }
.plan-bill { margin: 0; min-height: 1.4em; }
.plan > .btn { width: 100%; margin-top: 4px; }
.plan-feats { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 8px; }
.plan-feats li { position: relative; padding-left: 24px; font-size: 14px; line-height: 1.5; color: var(--text); }
.plan-feats li::before { content: "✓"; position: absolute; left: 0; top: 0; color: var(--blue-text); font-weight: 700; }
.plans-note { margin-top: 16px; font-size: 13px; color: var(--muted); max-width: 760px; }
@media (max-width: 700px) { .plans { grid-template-columns: minmax(0, 1fr); max-width: 520px; } }

/* Pricing: billing and currency switches */
.billing { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; }
.billing .seg { display: inline-grid; grid-auto-flow: column; grid-template-columns: none; gap: 4px; }
.billing .seg button { padding: 0 16px; }
.billing .seg button[aria-pressed="true"] { border-color: var(--blue); background: var(--blue-soft); color: var(--blue-text); }
.save { font-size: 12px; font-weight: 700; color: var(--violet-text); margin-left: 4px; }

/* Comparison table: scrolls sideways on small screens instead of squashing. */
.cmp-wrap { max-width: 860px; overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.cmp { width: 100%; min-width: 440px; border-collapse: collapse; font-size: 14px; }
.cmp th, .cmp td { padding: 11px 14px; text-align: center; border-bottom: 1px solid var(--border); }
.cmp th[scope="row"], .cmp thead th:first-child { text-align: left; font-weight: 400; color: var(--text); }
.cmp thead th { font-size: 15px; font-weight: 700; }
.cmp tr:last-child > * { border-bottom: 0; }
.cmp-group th { text-align: left; font-size: 12px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); background: var(--surface-2); }
.cmp .yes { color: var(--blue-text); font-weight: 700; }
.cmp .no { color: var(--muted); }
.cmp th[scope="row"] { position: sticky; left: 0; background: var(--surface); }

/* Log in / Sign up and Coming soon */
.auth-card, .soon-card { max-width: 440px; padding: 24px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.soon-card { max-width: 560px; }
.soon-card p:first-child { margin-top: 0; }
.auth-soon { margin: 0 0 18px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--blue-soft); font-size: 14px; line-height: 1.5; }
.auth-form { display: grid; gap: 14px; }
.auth-form .btn { width: 100%; }
.auth-msg { margin: 0; font-size: 14px; color: var(--muted); }
.auth-alt { margin: 18px 0 0; font-size: 14px; color: var(--muted); }

/* Upsell card at the end of a free tool's panel */
.upsell .btn { justify-self: start; gap: 8px; }

/* ------------------------------------------------------------------ */
/* Cookie banner (consent.js, only when ads are on). A compact card in the bottom-left corner on
   desktop, a slim sheet across the bottom on phones. Reject and Accept are the same size. */
.consent {
  position: fixed; left: 20px; bottom: 20px; z-index: 60; width: min(400px, calc(100vw - 40px));
  max-height: min(80dvh, calc(100dvh - 40px)); overflow-y: auto; overscroll-behavior: contain;
  padding: 16px; background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); border-radius: 14px;
  box-shadow: 0 1px 2px rgb(15 23 42 / .06), 0 16px 40px -8px rgb(15 23 42 / .28);
  opacity: 0; transform: translateY(8px); transition: opacity .2s, transform .2s;
}
.consent.in { opacity: 1; transform: none; }
.consent[hidden] { display: none; }
.consent-text { margin: 0; font-size: 13.5px; line-height: 1.5; color: var(--muted); }
.consent-text strong { color: var(--text); font-weight: 700; }
.consent-links { display: flex; flex-wrap: wrap; align-items: center; gap: 0 16px; margin-top: 2px; line-height: 1.5; }
.consent-links > * { display: inline-flex; align-items: center; min-height: 32px; height: auto; line-height: inherit; }
.consent-links a, .consent-links .link-btn { color: var(--blue-text); font-weight: 600; font-size: 13.5px; }
.consent-links [hidden] { display: none; }
.consent-more { margin-top: 12px; border: 1px solid var(--border); border-radius: 12px; }
.consent-more[hidden] { display: none; }
.consent-row { display: flex; align-items: center; gap: 14px; padding: 10px 12px; cursor: pointer; }
.consent-row + .consent-row { border-top: 1px solid var(--border); }
.consent-row > span:first-child { flex: 1; min-width: 0; display: grid; gap: 2px; }
.consent-row strong { font-size: 14px; font-weight: 600; }
.consent-row small { font-size: 13px; line-height: 1.45; color: var(--muted); }
.consent-always { flex: none; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.consent-row input { flex: none; width: 20px; height: 20px; accent-color: var(--blue); cursor: pointer; }
.consent-save { display: flex; width: calc(100% - 24px); margin: 2px 12px 12px; }
.consent-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
@media (max-width: 560px) {
  .consent { left: 8px; right: 8px; bottom: 8px; width: auto; padding: 12px; border-radius: 12px; }
  .consent-actions .btn { height: 38px; }
}
@media (prefers-reduced-motion: reduce) { .consent { transition: none; } }
/* "Cookie settings" in the footer looks like the links beside it. */
.link-btn { padding: 0; border: 0; background: none; font: inherit; color: inherit; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.link-btn:hover { color: var(--text); }
.ad-slot { margin-top: 32px; min-height: 90px; }
