:root {
  font-family: 'Segoe UI', system-ui, sans-serif;
  color: #172b49;
  background: #f4f7fc;
  --surface: #fff;
  --muted: #4d607c;
  --line: #dce5f2;
  --brand: #1753ad;
  --brand-deep: #123d80;
  --brand-soft: #eaf2ff;
  --tray: #e8effa;
}

* { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }
p, h1, h2, dl, dd { margin: 0; }
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 3px solid #2162c7; outline-offset: 3px; }

.shell { width: min(1140px, calc(100% - 44px)); margin-inline: auto; }
.masthead { background: var(--surface); border-bottom: 1px solid var(--line); }
.masthead-inner { min-height: 60px; display: flex; justify-content: space-between; align-items: center; }
.brand { display: flex; gap: 10px; align-items: center; font-weight: 800; font-size: 1.15rem; letter-spacing: .09em; }
.brand-mark { width: 34px; height: 34px; border-radius: 9px; background: var(--brand); position: relative; }
.brand-mark::before, .brand-mark::after { content: ''; position: absolute; width: 13px; height: 13px; border: solid #fff; }
.brand-mark::before { left: 9px; top: 8px; border-width: 0 0 2px 2px; }
.brand-mark::after { right: 9px; bottom: 8px; border-width: 2px 2px 0 0; }
.offline { display: flex; align-items: center; gap: 8px; color: var(--brand-deep); font-size: .875rem; font-weight: 600; }
.offline span { width: 8px; height: 8px; border-radius: 50%; background: #2475dc; }
.intro { padding-block: 20px 18px; }
.intro h1 { font-size: clamp(1.85rem, 4vw, 2.4rem); letter-spacing: -.04em; line-height: 1.12; }
.intro p { color: var(--muted); margin-top: 7px; line-height: 1.45; }

.workspace { display: grid; grid-template-columns: minmax(0, .94fr) minmax(0, 1.06fr); gap: 22px; align-items: start; padding-bottom: 32px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 4px 14px #182e5708; }
.step { padding: 13px 20px; }
.step + .step { border-top: 1px solid var(--line); }
.step h2, .preview-header h2 { font-size: 1.05rem; line-height: 1.3; }
.step h2 { display: flex; align-items: center; gap: 9px; margin-bottom: 12px; }
.step-number { display: grid; place-items: center; width: 25px; height: 25px; border-radius: 7px; background: var(--brand-soft); color: var(--brand-deep); font-size: .78rem; }
.presets { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.preset { min-height: 45px; padding: 4px; color: inherit; background: var(--surface); border: 1px solid #c5d3e8; border-radius: 8px; font-weight: 650; }
.preset:not(:disabled):hover, .preset[aria-pressed="true"] { color: var(--brand-deep); border-color: var(--brand); background: var(--brand-soft); }
.preset[aria-pressed="true"] { box-shadow: inset 0 0 0 1px var(--brand); }
.dropzone { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; min-height: 89px; padding: 10px; border: 1px dashed #9cb2d3; border-radius: 10px; background: #f7faff; text-align: center; }
.dropzone.is-dragging { border-color: var(--brand); background: var(--brand-soft); }
.upload-mark { width: 17px; height: 17px; position: relative; color: var(--brand); border: solid currentColor; border-width: 0 2px 2px; border-radius: 0 0 3px 3px; }
.upload-mark::before { content: ''; position: absolute; width: 2px; height: 11px; left: 6px; top: 0; background: currentColor; }
.upload-mark::after { content: ''; position: absolute; width: 6px; height: 6px; left: 3px; top: 0; border: solid currentColor; border-width: 2px 0 0 2px; transform: rotate(45deg); }
.dropzone[aria-disabled="true"] .upload-mark { color: #617692; }
.dropzone .helper { width: 100%; overflow-wrap: anywhere; }
.dropzone.has-photo { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; min-height: 69px; text-align: left; }
.dropzone.has-photo .upload-mark { display: none; }
.original-preview { width: 48px; height: 48px; object-fit: contain; background: #e2eaf7; border-radius: 5px; }
.dropzone.has-photo .helper { grid-column: 2; grid-row: 1; }
.dropzone.has-photo .button { grid-column: 3; grid-row: 1; }
.helper { color: var(--muted); font-size: .875rem; line-height: 1.45; }
.message { border-radius: 8px; padding: 9px 11px; margin-top: 9px; background: #fff2e0; color: #703a13; font-size: .875rem; line-height: 1.4; }
.crop-workspace { min-height: 106px; display: grid; place-items: center; text-align: center; background: #f2f6fc; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.crop-workspace .cr-boundary { margin-top: 8px; border-radius: 6px; }
.crop-workspace .cr-slider-wrap { width: min(250px, 90%); margin-block: 3px; }
.crop-workspace .cr-slider { appearance: auto; accent-color: var(--brand); padding-block: 0; height: 36px; margin: 0; }
.crop-workspace .cr-slider::-webkit-slider-runnable-track { background: revert; height: revert; }
.crop-workspace .cr-slider::-webkit-slider-thumb { appearance: auto; background: revert; margin-top: revert; }
.crop-workspace .cr-slider:focus-visible { outline: 2px solid var(--brand); }
.crop-help { margin-top: 7px; }

fieldset { padding: 0; margin: 0; border: 0; min-width: 0; }
fieldset:disabled { color: var(--muted); }
.quantity { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: .9rem; font-weight: 600; }
.stepper { display: flex; border: 1px solid #c5d3e8; border-radius: 8px; }
.stepper button { width: 40px; color: var(--brand-deep); background: var(--brand-soft); border: 0; font-size: 1.15rem; }
.stepper button:first-child { border-radius: 7px 0 0 7px; }
.stepper button:last-child { border-radius: 0 7px 7px 0; }
.stepper button:disabled { color: #586b88; background: #eff3f9; }
.stepper button:not(:disabled):hover { background: #d5e5fc; }
input[type="number"] { width: 100%; min-width: 0; min-height: 38px; background: transparent; color: inherit; border: 0; appearance: textfield; }
input::-webkit-inner-spin-button, input::-webkit-outer-spin-button { appearance: none; margin: 0; }
.stepper input { width: 65px; text-align: center; }
.measurements { margin-top: 12px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px 12px; }
.measurements label { display: grid; gap: 4px; font-size: .875rem; font-weight: 600; }
.measurement { display: flex; align-items: center; padding-inline: 9px; gap: 5px; border: 1px solid #c5d3e8; border-radius: 8px; }
.measurement span { color: var(--muted); font-weight: 400; }
.measurement:focus-within, .stepper:focus-within { border-color: var(--brand); }

.preview { position: sticky; top: 12px; padding: 17px 18px 14px; }
.preview-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-bottom: 12px; }
.paper-size { color: var(--muted); font-size: .875rem; font-variant-numeric: tabular-nums; }
.preview-bed { display: grid; place-items: center; padding: 18px; background: var(--tray); border-radius: 10px; }
.paper { position: relative; width: min(100%, clamp(190px, 47vh * 210 / 297, 350px)); aspect-ratio: 210 / 297; background: var(--surface); box-shadow: 0 4px 13px #223d7124, 0 0 0 1px #233c6912; }
.paper canvas { display: block; width: 100%; height: 100%; }
.preview-empty { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 10px; color: var(--muted); font-size: .875rem; pointer-events: none; }
.sheet-mark { width: 24px; height: 30px; position: relative; border: 1.5px solid #667f9f; border-radius: 3px; }
.sheet-mark::after { content: ''; position: absolute; inset: 6px 5px 13px; border: 1px solid #667f9f; border-radius: 1px; }
.preview-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 12px; border-block: 1px solid var(--line); padding-block: 9px; }
.preview-stats div { padding-inline: 10px; }
.preview-stats div + div { border-left: 1px solid var(--line); }
.preview-stats dt { color: var(--muted); font-size: .85rem; }
.preview-stats dd { margin-top: 1px; font-weight: 700; font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.preview-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 11px; }
.button { display: inline-grid; place-items: center; padding: 6px 12px; min-height: 40px; border: 1px solid transparent; border-radius: 8px; font-weight: 650; font-size: .9rem; }
.button-secondary { background: var(--surface); color: var(--brand-deep); border-color: #9fb8df; }
.button-secondary:not(:disabled):hover { background: var(--brand-soft); border-color: var(--brand); }
.button-primary { background: var(--brand); color: #fff; }
.button-primary:not(:disabled):hover { background: var(--brand-deep); }
.button:disabled { background: #eff3f9; color: #536583; border-color: #d3dfee; }
.print-help { margin-top: 10px; }

@media (max-width: 760px) {
  .shell { width: min(560px, calc(100% - 30px)); }
  .workspace { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .preview { position: static; }
  .paper { width: min(100%, 315px); }
}

@media (max-width: 370px) {
  .step { padding-inline: 12px; }
  .preview { padding-inline: 12px; }
}
