:root {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #252b35;
  background: #f7f7f2;
  font-synthesis: none;
  --muted: #626977;
  --blue: #2456d9;
  --border: #e1e3e5;
}

* { box-sizing: border-box; }
body { margin: 0; }
button, input { font: inherit; }
p { line-height: 1.6; }
h1, h2, h3, p { margin: 0; }
.site-header, main { width: min(1184px, calc(100% - 80px)); margin-inline: auto; }
.site-header { display: flex; align-items: center; justify-content: space-between; padding: 27px 0; border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 12px; font-size: 16px; font-weight: 700; letter-spacing: -0.5px; }
.brand-mark { display: grid; grid-template-columns: repeat(2, 10px); gap: 3px; transform: rotate(-8deg); }
.brand-mark i { width: 10px; height: 10px; border-radius: 2px; background: var(--blue); }
.brand-mark i:last-child { background: #a5bdf5; }
.header-note { font-size: 12px; color: var(--muted); }
.intro { display: flex; align-items: flex-end; justify-content: space-between; gap: 32px; padding: 55px 0 48px; }
.eyebrow { font-size: 10px; font-weight: 700; letter-spacing: 2px; color: var(--blue); margin-bottom: 17px; }
h1 { font-size: clamp(36px, 4.6vw, 58px); line-height: 1.08; font-weight: 650; letter-spacing: -2.8px; }
h1 span { color: #777e87; }
.intro-copy { max-width: 300px; font-size: 14px; color: var(--muted); padding-bottom: 4px; }
#uploadForm { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 32px; align-items: start; }
.section-heading { display: flex; align-items: center; gap: 10px; margin-bottom: 19px; }
.step { color: var(--muted); font-size: 10px; font-weight: 600; border: 1px solid #d7dadf; border-radius: 50%; width: 25px; height: 25px; display: grid; place-items: center; flex-shrink: 0; }
h2 { font-size: 16px; font-weight: 650; letter-spacing: -0.3px; }
.source-card, .sizes-card, .results-card { background: #fff; border: 1px solid var(--border); border-radius: 14px; }
.source-card { padding: 20px; }
.drop-area { border-radius: 8px; transition: background 0.2s ease; }
.drop-area.dragover { background: #eaf0ff; outline: 2px solid var(--blue); outline-offset: 4px; }
.file-input { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0; clip-path: inset(50%); overflow: hidden; }
.file-picker { display: flex; flex-direction: column; align-items: center; cursor: pointer; gap: 18px; }
.preview-frame { display: grid; width: 100%; aspect-ratio: 1; overflow: hidden; border: 1px dashed #b9c4d3; border-radius: 8px; background-color: #f5f7fa; background-image: linear-gradient(45deg, #e9edf2 25%, transparent 25%), linear-gradient(-45deg, #e9edf2 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #e9edf2 75%), linear-gradient(-45deg, transparent 75%, #e9edf2 75%); background-size: 20px 20px; background-position: 0 0, 0 10px, 10px -10px, -10px 0; }
.preview-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; background: #f5f7fa; color: #4e5d73; }
.preview-empty svg { margin-bottom: 8px; color: #6f88ad; }
.preview-empty > span { font-size: 14px; font-weight: 600; }
.preview-empty small { font-size: 12px; color: var(--muted); }
#imagePreview { width: 100%; height: 100%; min-height: 0; object-fit: cover; }
.picker-button { display: flex; align-items: center; justify-content: center; gap: 9px; width: 100%; border: 1px solid #d4dbe7; border-radius: 7px; padding: 10px; font-size: 13px; font-weight: 600; color: #304263; background: #fff; }
.picker-button > span { font-size: 18px; line-height: 1; font-weight: 400; }
.file-picker:hover .picker-button { background: #f0f4ff; border-color: #a4b9e8; }
#selectedFile { font-size: 12px; font-weight: 600; margin-top: 16px; overflow-wrap: anywhere; text-align: center; }
.image-meta { font-size: 11px; color: var(--muted); text-align: center; margin-top: 3px; }
#uploadHint { font-size: 11px; color: var(--muted); margin-top: 17px; padding-top: 16px; border-top: 1px solid #eceef0; }
.source-notes { padding: 25px 6px; }
.source-notes h3 { font-size: 12px; font-weight: 600; margin-bottom: 13px; }
.source-notes p { display: flex; align-items: baseline; gap: 11px; font-size: 12px; color: var(--muted); margin-top: 11px; }
.source-notes p > span { flex: 0 0 14px; color: #5c6f92; text-align: center; }
.sizes-card { padding: 24px; }
.sizes-intro { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 23px; }
.sizes-intro p { font-size: 12px; color: var(--muted); }
#selectionCount, .result-count { font-size: 11px; font-weight: 600; color: #3458a3; background: #eff3fd; border: 1px solid #e1e8fa; padding: 5px 9px; border-radius: 5px; white-space: nowrap; }
/* Two column layout for size groups on desktop */
.size-groups { display: grid; gap: 25px; }
.size-group { border: 0; margin: 0; padding: 0; min-width: 0; }
.size-group legend { width: 100%; font-size: 13px; font-weight: 650; margin-bottom: 11px; padding: 0; }
.size-group legend > span { color: var(--muted); font-size: 11px; font-weight: 400; margin-left: 8px; }
.sizes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.sizes label { display: grid; grid-template-columns: minmax(0, 1fr) 15px; align-content: start; align-items: center; gap: 4px 5px; border: 1px solid #e2e5ea; background: #fff; border-radius: 7px; padding: 11px; cursor: pointer; transition: border-color 0.15s ease, background 0.15s ease; }
.sizes label:hover { border-color: #a4b5d4; background: #f8faff; }
.sizes label:has(input:checked) { border-color: #6d91ea; background: #f0f5ff; }
.sizes input { grid-column: 2; grid-row: 1; width: 15px; height: 15px; margin: 0; accent-color: var(--blue); }
.sizes label > span { grid-column: 1; grid-row: 1; font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.sizes small { grid-column: 1 / -1; font-size: 10px; line-height: 1.5; color: var(--muted); }
.form-actions { display: flex; align-items: center; justify-content: space-between; gap: 18px; border-top: 1px solid #e9ebee; padding-top: 22px; margin-top: 24px; }
.form-actions p { font-size: 11px; color: #49566a; }
.form-actions p > span { color: var(--muted); }
button { background: var(--blue); color: #fff; border: 1px solid transparent; border-radius: 7px; padding: 12px 22px; font-size: 13px; font-weight: 600; cursor: pointer; flex-shrink: 0; transition: background 0.15s ease; }
button:hover:not(:disabled) { background: #1844b9; }
button:disabled { opacity: 0.65; cursor: wait; }
.drop-area:has(input:disabled) .file-picker { cursor: wait; opacity: 0.65; }
.sizes label:has(input:disabled) { cursor: wait; opacity: 0.65; }
:focus-visible { outline: 3px solid #1643b7; outline-offset: 4px; }
.drop-area:focus-within { outline: 3px solid #1643b7; outline-offset: 5px; }
.sizes label:focus-within { outline: 2px solid #1643b7; outline-offset: 2px; }
.feedback { margin-top: 18px; }
.feedback p { padding: 14px 18px; border: 1px solid #d8e4fa; border-radius: 8px; background: #eef4ff; color: #2b4f8a; font-size: 13px; }
.feedback #error { border-color: #f0d4cc; color: #943320; background: #fff3ef; }
.feedback p + p { margin-top: 10px; }
#error:empty, #status:empty { display: none; }
#results { margin-top: 34px; }
.results-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 19px; }
.results-heading .section-heading { margin-bottom: 0; }
.results-card { padding: 24px; }
.download-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.download-heading h3 { font-size: 16px; font-weight: 600; margin-bottom: 4px; }
.download-heading p, .expiry-note { font-size: 12px; color: var(--muted); }
#resultLinks { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
#resultLinks a { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-width: 0; border: 1px solid #e0e6ef; border-radius: 7px; background: #f8faff; color: #2853b7; padding: 16px; text-decoration: none; }
#resultLinks a:hover { background: #eef3ff; border-color: #97b0e9; }
.result-label { min-width: 0; overflow-wrap: anywhere; font-size: 13px; font-weight: 600; }
.result-label small { display: block; font-size: 10px; font-weight: 400; color: var(--muted); margin-top: 4px; }
.download-arrow { font-size: 20px; }
.expiry-note { padding-top: 18px; margin-top: 20px; border-top: 1px solid #eceef0; }
.site-footer { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 27px 0 32px; margin-top: 40px; border-top: 1px solid var(--border); font-size: 11px; color: var(--muted); }
[hidden] { display: none !important; } /* hidden initially */

/* Responsive adjustments */
@media (max-width: 1050px) {
  .site-header, main { width: calc(100% - 48px); }
  #uploadForm { grid-template-columns: 270px minmax(0, 1fr); gap: 24px; }
  .sizes { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sizes-intro { align-items: flex-start; flex-direction: column; gap: 8px; }
  .form-actions { align-items: stretch; flex-direction: column; }
}
@media (max-width: 700px) {
  .site-header, main { width: calc(100% - 32px); }
  .site-header { padding-block: 21px; }
  .header-note { display: none; }
  .intro { align-items: flex-start; flex-direction: column; gap: 20px; padding: 35px 0 30px; }
  h1 { letter-spacing: -1.8px; }
  .intro-copy { font-size: 13px; max-width: 350px; }
  #uploadForm { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .source-card { padding: 18px; }
  .preview-frame { width: min(100%, 280px); }
  .source-notes { padding: 20px 4px; }
  .section-heading { margin-bottom: 14px; }
  .sizes-card, .results-card { padding: 17px; }
  .sizes-intro { flex-direction: row; align-items: center; }
  .sizes-intro p { max-width: 130px; }
  .size-group legend > span { display: block; margin: 3px 0 0; }
  .sizes label { padding: 12px 9px; min-height: 66px; }
  .form-actions { gap: 14px; }
  .results-heading, .download-heading { align-items: flex-start; flex-direction: column; }
  #downloadAll { width: 100%; }
  #resultLinks { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #resultLinks a { padding: 12px; }
  .site-footer { flex-direction: column; align-items: flex-start; gap: 6px; margin-top: 28px; }
}
@media (prefers-reduced-motion: reduce) {
  .drop-area, .sizes label, button { transition: none; }
}
