@font-face {
  font-family: Manrope;
  src: url('/assets/manrope.woff2') format('woff2');
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
}

:root {
  color-scheme: light;
  --page: #f6f7fa;
  --surface: #fff;
  --text: #242837;
  --muted: #555e70;
  --line: #dce0e7;
  --strong-line: #838c9d;
  --accent: #9c3520;
  --button: #ae3d25;
  --button-hover: #92301d;
  --button-text: #fff;
  --tint: #f9e7dc;
  --stage: #eef1f5;
  --stage-square: #e0e4eb;
  --hero-rule: #e2e6ed;
  --shadow: #28324a0e;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #1d1b18;
  --surface: #25221e;
  --text: #f7eee2;
  --muted: #c4b8a9;
  --line: #4a4239;
  --strong-line: #918575;
  --accent: #ffa082;
  --button: #f99f83;
  --button-hover: #ffb69d;
  --button-text: #2d160e;
  --tint: #432b23;
  --stage: #2c2822;
  --stage-square: #373129;
  --hero-rule: #3c352d;
  --shadow: #0002;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --page: #1d1b18;
    --surface: #25221e;
    --text: #f7eee2;
    --muted: #c4b8a9;
    --line: #4a4239;
    --strong-line: #918575;
    --accent: #ffa082;
    --button: #f99f83;
    --button-hover: #ffb69d;
    --button-text: #2d160e;
    --tint: #432b23;
    --stage: #2c2822;
    --stage-square: #373129;
    --hero-rule: #3c352d;
    --shadow: #0002;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--page); color: var(--text); font: 500 1rem/1.55 Manrope, system-ui, sans-serif; }
button, input, select { font: inherit; }
button:not(:disabled), summary, select, input[type="range"], input[type="color"] { cursor: pointer; }
select, input { color: inherit; }
a { color: var(--accent); text-underline-offset: 0.2em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
svg { display: block; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { line-height: 1.15; }
.visually-hidden, .skip-link:not(:focus) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip-link:focus { position: fixed; z-index: 2; inset: 10px auto auto 10px; border-radius: 8px; padding: 12px; background: var(--surface); }
.site-header { border-bottom: 1px solid var(--hero-rule); }
.site-header-inner, .site-footer-inner, .editor, .site-copy, .site-hero { width: min(100% - 2rem, 71rem); margin-inline: auto; }
.site-header-inner { display: flex; align-items: center; gap: clamp(0.5rem, 3vw, 2rem); min-height: 4.45rem; }
.brand { display: inline-flex; align-items: center; gap: 0.45rem; white-space: nowrap; font-size: 1.21rem; font-weight: 800; letter-spacing: -0.065em; color: var(--text); text-decoration: none; }
.brand img { flex: none; }
.brand span { color: var(--accent); margin-left: -0.42rem; }
.top-nav { display: flex; gap: clamp(0.55rem, 2vw, 1.65rem); margin-left: auto; }
.top-nav a { padding-block: 0.75rem; color: var(--text); text-decoration: none; font-size: 0.87rem; font-weight: 700; }
.top-nav a:hover, .site-footer a:hover { text-decoration: underline; }
.theme-toggle { flex: none; display: grid; place-items: center; width: 44px; height: 44px; margin-left: auto; border: 1px solid var(--line); border-radius: 50%; background: var(--surface); color: var(--text); }
.top-nav + .theme-toggle { margin-left: 0; }
.theme-toggle:hover { background: var(--tint); }
.theme-toggle svg, .device-note svg, .button svg, .file-icon svg, .drop-art svg { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.theme-toggle svg, .button svg { width: 20px; height: 20px; }

.site-hero { padding-block: clamp(1.55rem, 3.25vw, 2.8rem) clamp(1.2rem, 2.8vw, 2rem); text-align: center; }
.site-hero h1 { max-width: 850px; margin-inline: auto; font-size: clamp(2.05rem, 4.1vw, 3.55rem); font-weight: 800; letter-spacing: -0.03em; line-height: 1.025; text-wrap: balance; }
.site-hero p { max-width: 40rem; margin: 0.65rem auto 0; font-size: clamp(0.92rem, 1.45vw, 1.05rem); color: var(--muted); text-wrap: pretty; }

.editor { display: grid; grid-template-columns: 1.04fr 1fr; align-items: stretch; border: 1px solid var(--line); border-radius: 1.34rem; background: var(--surface); box-shadow: 0 8px 35px var(--shadow); }
.editor-input, .editor-output { min-width: 0; padding: clamp(1rem, 2.45vw, 1.8rem); }
.editor-output { border-left: 1px solid var(--line); }
.panel-heading { display: flex; min-height: 2rem; align-items: center; justify-content: space-between; gap: 0.6rem; margin-bottom: 0.8rem; }
.panel-heading h2 { font-size: 1.13rem; font-weight: 800; letter-spacing: -0.035em; }
.drop-zone { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 12.5rem; padding: 1rem; border: 1.5px dashed var(--strong-line); border-radius: 1rem; background: var(--page); text-align: center; transition: border-color 140ms, background-color 140ms, transform 140ms; }
.drop-zone.is-over { transform: scale(1.012); border-color: var(--accent); background: var(--tint); }
.drop-art { position: relative; width: 57px; height: 46px; margin: 0 auto 0.75rem; color: var(--accent); }
.drop-art span, .preview-art span { position: absolute; border: 1.5px solid currentColor; border-radius: 7px; }
.drop-art span { width: 37px; height: 31px; }
.drop-art span:first-child { top: 5px; left: 8px; transform: rotate(-12deg); background: var(--surface); }
.drop-art span:last-child { display: grid; place-items: center; top: 11px; left: 15px; transform: rotate(8deg); background: var(--tint); }
.drop-art svg { width: 17px; height: 17px; }
.drop-title { font-size: 1.175rem; font-weight: 800; letter-spacing: -0.04em; }
.drop-copy { margin-top: 0.1rem; color: var(--muted); font-size: 0.85rem; }
.drop-zone button { margin-top: 0.85rem; }
.drop-zone.has-images { flex-direction: row; justify-content: space-between; gap: 0.5rem; min-height: 65px; padding: 0.6rem 0.7rem; }
.drop-zone.has-images .drop-art, .drop-zone.has-images .drop-copy { display: none; }
.drop-zone.has-images .drop-title { font-size: 0.9rem; }
.drop-zone.has-images button { margin-top: 0; }
.button { display: inline-flex; justify-content: center; align-items: center; gap: 0.45rem; min-height: 46px; padding: 0.55rem 1.15rem; border: 1px solid transparent; border-radius: 0.65rem; font-size: 0.9rem; font-weight: 800; white-space: nowrap; }
.primary { background: var(--button); color: var(--button-text); }
.primary:hover:not(:disabled) { background: var(--button-hover); }
.secondary { background: var(--surface); border-color: var(--strong-line); color: var(--text); }
.secondary:hover:not(:disabled) { background: var(--tint); }
.button.compact { padding-inline: 0.65rem; min-height: 44px; font-size: 0.8rem; }
.button:active:not(:disabled) { transform: translateY(1px); }
.button:disabled { color: var(--muted); background: var(--stage); border-color: var(--line); }
.device-note { display: flex; align-items: center; gap: 0.42rem; margin-block: 0.6rem 1.1rem; color: var(--muted); font-size: 0.78rem; font-weight: 700; }
.device-note svg { width: 16px; height: 16px; color: var(--accent); }

.editor-error, .export-warning { padding: 0.75rem; border: 1px solid var(--line); border-radius: 0.6rem; background: var(--tint); color: var(--text); font-size: 0.83rem; }
.reorder-hint { color: var(--muted); font-size: 0.78rem; }
.image-list { display: grid; gap: 0.4rem; margin: 0.55rem 0 1.15rem; padding: 0; list-style: none; }
.image-list:empty { margin: 0; }
.image-list li { display: grid; position: relative; grid-template-columns: auto auto minmax(0, 1fr) auto; align-items: center; min-height: 57px; gap: 0.35rem; padding: 0.27rem; border: 1px solid var(--line); border-radius: 0.65rem; }
.image-list li.is-moving { opacity: 0.48; }
.image-list li[data-drop-position]::after { position: absolute; right: 0; left: 0; content: ''; height: 2px; border-radius: 2px; background: var(--accent); }
.image-list li[data-drop-position="before"]::after { top: -4px; }
.image-list li[data-drop-position="after"]::after { bottom: -4px; }
.file-thumb { width: 42px; height: 42px; overflow: hidden; border-radius: 0.38rem; background: var(--stage); }
.file-thumb img { width: 100%; height: 100%; object-fit: cover; }
.file-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.79rem; font-weight: 800; }
.file-icon { display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 0.42rem; background: transparent; color: var(--text); }
.file-icon:disabled { opacity: 0.4; }
.file-icon:hover:not(:disabled), .file-icon:focus-visible { background: var(--stage); color: var(--accent); }
.file-icon svg { width: 18px; height: 18px; }
.file-icon.move { cursor: grab; touch-action: none; }
.file-icon.move:active { cursor: grabbing; }
.input-actions, .row-actions { display: flex; align-items: center; gap: 0.3rem; }
.row-actions { gap: 0; }
.row-actions .up, .row-actions .down { display: none; }
.trim-controls { grid-column: 1 / -1; padding: 0 0.42rem; border-top: 1px solid var(--line); }
.trim-controls summary { min-height: 31px; padding-block: 0.3rem; color: var(--muted); font-size: 0.76rem; font-weight: 800; }
.trim-controls summary::marker { color: var(--accent); }
.trim-controls[open] summary { margin-bottom: 0.2rem; }
.stitch-tools { margin-bottom: 1.1rem; }

fieldset { min-width: 0; border: 0; margin: 0; padding: 0; }
legend { padding: 0; margin-bottom: 0.56rem; font-size: 0.94rem; font-weight: 800; letter-spacing: -0.02em; }
.layout-options, .format-options { display: grid; gap: 0.4rem; }
.layout-options { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.format-options { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.choice { display: flex; position: relative; align-items: center; justify-content: center; gap: 0.3rem; min-width: 0; min-height: 44px; padding: 0.3rem; border: 1px solid var(--strong-line); border-radius: 0.57rem; cursor: pointer; color: var(--text); font-size: 0.78rem; font-weight: 800; text-align: center; }
.choice input { position: absolute; width: 100%; height: 100%; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.choice:has(input:checked) { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: var(--tint); color: var(--accent); }
.choice:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 3px; }
.layout-icon { display: grid; flex: none; width: 18px; height: 16px; gap: 2px; }
.layout-icon i { border: 1px solid currentColor; border-radius: 2px; }
.layout-icon.stack { grid-template-rows: repeat(2, 1fr); }
.layout-icon.row { grid-template-columns: repeat(2, 1fr); }
.layout-icon.grid { grid-template: repeat(2, 1fr) / repeat(2, 1fr); }
.layout-details { border-top: 1px solid var(--line); margin-top: 1rem; }
.layout-details summary { min-height: 44px; padding-block: 0.75rem; color: var(--text); font-size: 0.87rem; font-weight: 800; }
.layout-details summary::marker { color: var(--accent); }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.85rem; padding-top: 0.15rem; }
.setting { display: flex; flex-direction: column; gap: 0.3rem; min-width: 0; font-size: 0.81rem; font-weight: 750; }
.setting select, .setting input[type="number"], .setting input[type="text"], .sort-control select { width: 100%; min-height: 44px; border: 1px solid var(--strong-line); border-radius: 0.5rem; padding: 0.28rem 0.4rem; background: var(--surface); font-weight: 700; }
.setting input[type="color"] { display: block; width: 100%; height: 44px; padding: 0.2rem 0.4rem; border: 1px solid var(--strong-line); border-radius: 0.5rem; background: var(--surface); }
.sort-control select { font-size: 0.78rem; }
.columns-setting { margin-top: 0.6rem; max-width: 8rem; }
.setting-note { margin-top: 0.6rem; color: var(--muted); font-size: 0.78rem; }
.range-setting { display: grid; grid-template-columns: 1fr auto; align-items: center; column-gap: 0.55rem; row-gap: 0; }
.range-setting output, .trim-amount { color: var(--muted); font-variant-numeric: tabular-nums; }
.image-options, .preset-actions { display: flex; flex-wrap: wrap; gap: 0.65rem 1rem; align-items: end; margin-top: 0.85rem; }
.image-options .setting { width: 8.5rem; }
.editor[data-workflow="receipts"] .image-options .check-setting { order: -1; }
.check-setting { display: inline-flex; gap: 0.4rem; align-items: center; min-height: 44px; font-size: 0.82rem; font-weight: 800; cursor: pointer; }
.check-setting input { width: 1.1rem; height: 1.1rem; margin: 0; accent-color: var(--accent); }
.preset-actions .setting { flex: 1 1 8rem; }
#saved-presets { display: grid; gap: 0.35rem; margin: 0.55rem 0 0; padding: 0; list-style: none; }
#saved-presets:empty { margin: 0; }
#saved-presets li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.4rem; }
#saved-presets li button:first-child { white-space: normal; overflow-wrap: anywhere; text-align: left; justify-content: start; }
.range-setting input { grid-column: 1 / -1; width: 100%; height: 44px; margin: 0; accent-color: var(--accent); }

.preview-size { color: var(--muted); text-align: right; font-size: 0.78rem; font-weight: 700; }
.preview-stage { display: grid; place-items: center; min-height: 15.6rem; padding: 1rem; overflow: hidden; border: 1px solid var(--line); border-radius: 1rem; background: var(--stage); }
.preview-stage.has-transparency { background-image: conic-gradient(var(--stage-square) 25%, var(--stage) 0 50%, var(--stage-square) 0 75%, var(--stage) 0); background-size: 20px 20px; }
.preview-empty { text-align: center; color: var(--muted); font-size: 0.85rem; font-weight: 700; }
.preview-art { position: relative; width: 135px; height: 95px; margin: 0 auto 0.67rem; color: var(--strong-line); }
.preview-art span { width: 92px; height: 62px; overflow: hidden; }
.preview-art span:first-child { top: 12px; left: 13px; background: var(--surface); transform: rotate(-11deg); }
.preview-art span:last-child { top: 19px; left: 28px; background: var(--page); transform: rotate(7deg); }
.preview-art svg { position: absolute; inset: auto 0 0; width: 100%; fill: currentColor; opacity: 0.69; }
.preview-art svg path:last-child { opacity: 0.42; }
#open-preview { position: relative; display: block; max-width: 100%; padding: 0; border: 0; border-radius: 2px; background: transparent; cursor: zoom-in; }
.zoom-icon { position: absolute; right: 0.3rem; bottom: 0.3rem; display: grid; place-items: center; width: 1.75rem; height: 1.75rem; border: 1px solid var(--line); border-radius: 0.4rem; background: var(--surface); color: var(--text); }
.zoom-icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
#preview-dialog { width: min(70rem, calc(100% - 1rem)); max-width: none; max-height: calc(100% - 1rem); padding: 0; border: 1px solid var(--line); border-radius: 0.8rem; background: var(--surface); color: var(--text); }
#preview-dialog[open] { display: grid; grid-template-rows: auto minmax(0, 1fr); }
#preview-dialog::backdrop { background: #131923c7; }
.zoom-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; padding: 0.55rem; border-bottom: 1px solid var(--line); }
.zoom-toolbar [aria-pressed="true"] { border-color: var(--accent); background: var(--tint); color: var(--accent); }
.zoom-toolbar h2 { flex: 1 1 auto; font-size: 1rem; }
.zoom-scroll { overflow: auto; padding: 0.45rem; background: var(--stage); }
.zoom-scroll canvas { display: block; margin-inline: auto; }
.fit-width .zoom-scroll canvas { max-width: 100%; height: auto; }
#preview-canvas { display: block; max-width: 100%; max-height: 17.5rem; width: auto; height: auto; object-fit: contain; border-radius: 2px; box-shadow: 0 3px 9px #1b120d30; }
.page-navigation { display: flex; align-items: center; justify-content: center; gap: 0.5rem; margin-top: 0.35rem; color: var(--muted); font-size: 0.8rem; font-weight: 750; }
.page-navigation button:disabled { opacity: 0.4; }
.file-settings { display: grid; gap: 0.65rem; margin-top: 1rem; }
.file-actions { display: flex; gap: 0.5rem; }
.file-actions .primary { flex: 1; }
#preview-jump { display: none; }
#editor-output { scroll-margin-block-start: 0.5rem; }
.copy-action { display: flex; align-items: center; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.7rem; }
#copy-status { margin: 0; }

.site-copy { padding-block: 2.7rem; }
.site-copy h1 { font-size: clamp(2.1rem, 5vw, 3.5rem); letter-spacing: -0.03em; }
.site-copy h2 { margin-top: 1.7rem; letter-spacing: -0.035em; }
.site-copy h3 { margin-top: 0.8rem; }
.site-copy p, .site-copy ul, .site-copy ol { margin-top: 0.6rem; }
.site-copy details { max-width: 52rem; border-bottom: 1px solid var(--line); padding: 0.65rem 0; }
.site-copy details:first-of-type { margin-top: 0.65rem; }
.site-copy summary { min-height: 30px; font-weight: 800; }
.site-copy summary::marker { color: var(--accent); }
.site-copy.legal-copy { max-width: 48rem; padding-block: 3.05rem; }
.related-tools ul, .site-footer nav ul { display: flex; flex-wrap: wrap; gap: 0.6rem 1.2rem; list-style: none; padding: 0; }
.related-tools a { display: inline-block; font-weight: 750; }
.site-footer { border-top: 1px solid var(--hero-rule); }
.site-footer-inner { display: flex; flex-wrap: wrap; gap: 0.65rem 1.5rem; align-items: center; padding-block: 1.3rem; font-size: 0.82rem; color: var(--muted); }
.site-footer nav ul { margin: 0; }
.site-footer nav a { display: inline-block; padding-block: 0.25rem; color: var(--text); text-decoration: none; }

@media (pointer: coarse) {
  .reorder-hint, .file-icon.move { display: none; }
  .image-list li { grid-template-columns: auto minmax(0, 1fr); }
  .row-actions { grid-column: 1 / -1; justify-content: flex-end; }
  .row-actions .up, .row-actions .down { display: grid; }
  .row-actions .down { margin-inline-end: auto; }
}

@media (max-width: 720px) {
  .editor { grid-template-columns: 1fr; }
  .editor-output { border-left: 0; border-top: 1px solid var(--line); }
  .site-header-inner { min-height: 3.8rem; }
  .preview-stage { min-height: 12rem; }
  body:has(.editor.has-output) { padding-bottom: calc(62px + env(safe-area-inset-bottom)); }
  .editor.has-output .file-actions {
    position: fixed; z-index: 3; inset: auto 0 0;
    justify-content: center; padding: 0.45rem 0.75rem calc(0.45rem + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line); background: var(--surface); box-shadow: 0 -4px 18px var(--shadow);
  }
  .editor.has-output #preview-jump { display: inline-flex; }
  .editor.has-output .file-actions .button { padding-inline: 0.55rem; }
  .editor.has-output .file-actions .primary { flex: 1 1 auto; max-width: 16rem; }
  .editor.has-output .file-actions .primary svg { width: 16px; height: 16px; }
}

@media (max-width: 390px) {
  .site-header-inner, .site-footer-inner, .editor, .site-copy, .site-hero { width: calc(100% - 1.5rem); }
  .editor-input, .editor-output { padding: 0.85rem; }
  .choice { font-size: 0.75rem; }
  .layout-icon { width: 15px; height: 14px; }
  .top-nav a { font-size: 0.78rem; }
}

@media (max-width: 340px) {
  .top-nav a:last-child { display: none; }
  .layout-icon { display: none; }
  .image-list li { gap: 0.15rem; }
}

@media (prefers-reduced-motion: reduce) {
  .drop-zone { transition: none; }
}
