:root {
  color-scheme: light;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #192340;
  background: #f5f6fc;
  font-size: 100%;
  --ink: #192340;
  --muted: #56617a;
  --line: #e0e4f1;
  --primary: #3b49c7;
  --primary-hover: #2d389f;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 280px; }
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled, input:disabled { cursor: default; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }
[hidden] { display: none !important; }
p, h1, h2 { margin: 0; }

.shell { width: min(1080px, calc(100% - 64px)); margin-inline: auto; }
.site-header { background: #fff; border-bottom: 1px solid var(--line); }
.header-inner { min-height: 66px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: inline-flex; align-items: center; gap: 11px; font-size: 1.05rem; font-weight: 750; }
.brand-mark { flex: 0 0 auto; position: relative; display: inline-block; width: 30px; height: 30px; border-radius: 8px; background: var(--primary); }
.brand-mark::before, .brand-mark::after { content: ""; position: absolute; width: 11px; height: 13px; border: 1.5px solid white; border-radius: 2px; }
.brand-mark::before { top: 6px; left: 6px; opacity: .55; }
.brand-mark::after { top: 10px; left: 11px; background: var(--primary); }
.privacy { display: inline-flex; align-items: center; gap: 8px; margin-inline-start: auto; font-size: .875rem; color: var(--muted); }
.language-switcher { flex: 0 0 auto; color: var(--muted); font-size: .875rem; }
.language-switcher details { position: relative; }
.language-switcher summary { display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 5px 12px; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 8px; list-style: none; cursor: pointer; white-space: nowrap; }
.language-switcher summary::-webkit-details-marker { display: none; }
.language-switcher summary::after { content: ""; width: 6px; height: 6px; margin-block-start: -3px; border: solid var(--muted); border-width: 0 1.5px 1.5px 0; transform: rotate(45deg); }
.language-switcher details[open] summary, .language-switcher summary:hover { border-color: #a8afe8; }
.language-switcher ul { position: absolute; z-index: 2; inset-block-start: calc(100% + 6px); inset-inline-end: 0; min-width: max(100%, 11rem); max-height: min(60vh, 24rem); overflow: auto; overscroll-behavior: contain; margin: 0; padding: 5px; border: 1px solid var(--line); border-radius: 10px; background: #fff; box-shadow: 0 8px 24px #222b5820; list-style: none; }
.language-switcher a { display: block; padding: 8px 10px; border-radius: 5px; text-align: start; color: inherit; text-decoration: none; white-space: nowrap; }
.language-switcher a:hover, .language-switcher a:focus-visible { color: var(--primary); background: #f0f2ff; }
.language-switcher a:focus-visible { outline-offset: -2px; }
.language-switcher [aria-current] { color: var(--primary); background: #edf0ff; font-weight: 700; }
.lock { flex: 0 0 auto; position: relative; width: 12px; height: 9px; margin-top: 4px; border: 1.5px solid currentColor; border-radius: 2px; }
.lock::before { content: ""; position: absolute; width: 5px; height: 5px; border: 1.5px solid currentColor; border-bottom: 0; border-radius: 5px 5px 0 0; left: 2px; bottom: 6px; }

.intro { padding: 43px 0 29px; }
h1 { font-size: clamp(2.15rem, 5vw, 3.25rem); letter-spacing: -.055em; font-weight: 800; line-height: 1.16; }
:root[dir="rtl"] h1 { letter-spacing: normal; }
.intro-copy { line-height: 1.65; color: var(--muted); margin-top: 13px; }
.workspace { display: grid; grid-template-columns: minmax(0, .78fr) minmax(0, 1.22fr); grid-template-rows: repeat(4, max-content) 1fr; gap: 14px 18px; align-items: start; padding-bottom: 26px; }
.preview-panel { grid-area: 1 / 2 / 6 / 3; }
.download-panel { grid-area: 4 / 1; }
.panel { min-width: 0; padding: 19px 21px; background: #fff; border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 4px 12px #222b5806; }
.section-heading { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
h2 { font-size: 1.04rem; line-height: 1.4; font-weight: 750; }
.count, .dimensions { color: #3c49a0; background: #edf0ff; border-radius: 6px; font-weight: 650; font-variant-numeric: tabular-nums; font-size: .8125rem; padding: 4px 9px; white-space: nowrap; }
.hint { font-size: .875rem; line-height: 1.5; color: var(--muted); }
.source-panel > .hint { margin-top: 11px; }

.drop-zone { padding: 18px 10px 13px; text-align: center; border: 1px dashed #a8afe8; background: #f5f6ff; border-radius: 10px; margin-top: 13px; display: flex; align-items: center; flex-direction: column; }
.drop-zone.is-dragging { background: #e6eaff; border-color: var(--primary); }
.upload-icon { width: 31px; height: 28px; margin-bottom: 8px; position: relative; color: #4655ca; }
.upload-icon::before { content: ""; position: absolute; inset: 12px 2px 3px; border: 1.75px solid currentColor; border-top: 0; border-radius: 0 0 4px 4px; }
.upload-icon::after { content: ""; position: absolute; width: 1.75px; height: 15px; top: 3px; left: 14.5px; background: currentColor; }
.upload-icon span { position: absolute; top: 4px; left: 10px; width: 10px; height: 10px; border: solid currentColor; border-width: 1.75px 0 0 1.75px; transform: rotate(45deg); }
.button { display: inline-flex; min-height: 43px; gap: 10px; align-items: center; justify-content: center; padding: 8px 20px; border: 1px solid transparent; border-radius: 8px; font-size: .9375rem; font-weight: 700; }
.button-primary { background: var(--primary); color: #fff; }
.button-primary:hover:not(:disabled) { background: var(--primary-hover); }
.button-primary:disabled { background: #e7eaf5; color: #596581; }
.drop-hint { font-size: .8125rem; margin-top: 8px; color: var(--muted); }
.errors { margin-top: 12px; padding: 9px 11px; background: #fff2f1; color: #922b37; border: 1px solid #f3d2d4; border-radius: 8px; font-size: .875rem; overflow-wrap: anywhere; }
.errors p { font-weight: 700; }
.errors ul { padding-left: 1.15rem; margin: 5px 0 0; }

.size-presets, .size-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.size-presets { margin-top: 12px; }
.size-option { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 2px 8px; min-height: 40px; padding: 7px 9px; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 7px; text-align: start; }
.size-option span:first-child { font-weight: 700; font-size: .875rem; }
.size-option span:last-child { font-size: .8125rem; color: var(--muted); }
.size-option[aria-pressed="true"], .size-option:hover:not(:disabled) { background: #f1f3ff; border-color: #8e9aef; }
.size-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 7px; align-items: end; margin-top: 12px; }
.size-fields label { display: grid; gap: 4px; font-size: .875rem; color: var(--muted); }
.size-fields input { min-width: 0; width: 100%; height: 40px; padding: 6px 8px; border: 1px solid #cdd4e7; border-radius: 7px; color: var(--ink); background: #fff; }
.size-fields input[aria-invalid="true"] { border-color: #a73140; }
.button-secondary { min-height: 40px; padding-inline: 10px; background: #edf0ff; color: #303da1; border-color: #dce2fc; }
.button-secondary:hover:not(:disabled) { background: #e2e7ff; }
.button-secondary:disabled { opacity: .65; }
.size-error { grid-column: 1 / -1; color: #922b37; font-size: .875rem; }
.size-error:empty { display: none; }

.color-controls { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; justify-content: space-between; margin-top: 13px; }
.swatches { display: flex; align-items: center; gap: 8px; }
.swatch { display: grid; place-items: center; height: 29px; width: 29px; padding: 0; border-radius: 50%; border: 1px solid #bcc4d7; background: var(--swatch); }
.swatch[aria-pressed="true"] { outline: 2px solid var(--primary); outline-offset: 2px; }
.swatch:focus-visible { outline-style: dashed; }
.color-picker { display: flex; gap: 7px; align-items: center; padding: 4px 8px; border: 1px solid #d7dcec; border-radius: 7px; font: .8125rem/1.3 ui-monospace, monospace; color: #394361; }
.color-picker input { margin: 0; padding: 0; width: 26px; height: 26px; border: 0; background: transparent; cursor: pointer; }
.color-picker input::-webkit-color-swatch-wrapper { padding: 2px; }
.color-picker input::-webkit-color-swatch, .color-picker input::-moz-color-swatch { border: 1px solid #aeb6cb; border-radius: 4px; }
.download-panel .hint { margin-top: 6px; }
.download-button { margin-top: 13px; width: 100%; }
.download-icon { width: 14px; height: 15px; position: relative; border-bottom: 1.5px solid currentColor; }
.download-icon::before { content: ""; position: absolute; height: 10px; border-left: 1.5px solid currentColor; left: 6px; top: 0; }
.download-icon::after { content: ""; position: absolute; width: 5px; height: 5px; border: solid currentColor; border-width: 0 1.5px 1.5px 0; transform: rotate(45deg); left: 4px; top: 4px; }
.download-status { color: var(--muted); font-size: .875rem; overflow-wrap: anywhere; }
.download-status:not(:empty) { margin-top: 9px; }

.preview-heading { margin-bottom: 13px; }
.preview-stage {
  min-width: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  border: 1px solid #e3e7f4;
  border-radius: 11px;
  background: radial-gradient(#cfd6eb 1px, transparent 1px) 0 0 / 13px 13px, #f0f2fa;
}
.preview-frame { position: relative; width: min(100%, 520px, calc(368px * var(--output-ratio, .75))); aspect-ratio: var(--output-ratio, .75); background: #fff; outline: 1px solid #d7dcef; box-shadow: 0 6px 22px #222b5818; overflow: hidden; }
.preview-frame #preview-image { display: block; width: 100%; height: 100%; object-fit: contain; }
.preview-frame .source-preview { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.preview-empty { display: flex; align-items: center; flex-direction: column; justify-content: center; position: absolute; inset: 0; gap: 13px; padding: 10px; text-align: center; color: #596683; font-size: .875rem; background: #ffffffed; }
.picture-icon { display: block; width: 33px; height: 27px; position: relative; border: 1.5px solid #7988c1; border-radius: 5px; overflow: hidden; }
.picture-icon::before { content: ""; position: absolute; width: 4px; height: 4px; border: 1.5px solid #7988c1; border-radius: 50%; top: 5px; right: 5px; }
.picture-icon::after { content: ""; position: absolute; width: 19px; height: 19px; border: solid #7988c1; border-width: 1.5px 0 0 1.5px; top: 14px; left: 4px; transform: rotate(45deg); }
.preview-frame.can-position { cursor: grab; touch-action: none; user-select: none; }
.preview-frame.is-positioning { cursor: grabbing; }
.position-controls { margin-top: 11px; padding-top: 10px; border-top: 1px solid var(--line); }
.edit-scope { min-inline-size: 0; margin: 0 0 8px; padding: 0; border: 0; }
.edit-scope legend { margin-bottom: 5px; font-size: .875rem; font-weight: 650; color: var(--ink); }
.edit-scope-options { display: flex; flex-wrap: wrap; gap: 6px; }
.edit-scope-options label { display: flex; align-items: center; gap: 6px; min-height: 36px; padding: 5px 9px; border: 1px solid var(--line); border-radius: 7px; font-size: .875rem; cursor: pointer; }
.edit-scope-options label:has(input:checked) { border-color: #8e9aef; background: #f1f3ff; }
.edit-scope-options input { margin: 0; accent-color: var(--primary); }
.copy-batch { min-height: 36px; margin-top: 8px; }
.position-actions { display: flex; flex-wrap: wrap; align-items: end; gap: 8px 12px; margin-top: 7px; }
.adjust-control { flex: 1 1 165px; min-width: 0; display: grid; gap: 3px; font-size: .875rem; color: var(--muted); }
.adjust-heading { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; justify-content: space-between; }
.adjust-heading label { min-width: 0; overflow-wrap: anywhere; }
.adjust-value { display: inline-flex; flex: 0 0 auto; align-items: center; gap: 3px; font-variant-numeric: tabular-nums; }
.adjust-value input { width: 4.6rem; min-height: 34px; padding: 4px 6px; text-align: end; border: 1px solid var(--line); border-radius: 6px; color: var(--ink); background: #fff; }
.adjust-value input:disabled { opacity: .65; }
.adjust-control input[type="range"] { width: 100%; margin: 0; min-height: 28px; accent-color: var(--primary); }
.position-actions .button { min-height: 36px; }
.adjustment-error { margin-top: 7px; font-size: .875rem; color: #9b2531; }
.adjustment-error:empty { margin-top: 0; }
.export-control { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; font-size: .875rem; }
.export-control select { appearance: none; padding: 6px 28px 6px 8px; min-height: 36px; border: 1px solid var(--line); border-radius: 7px; color: var(--ink); background: linear-gradient(45deg, transparent 50%, var(--muted) 50%) right 13px center / 4px 4px no-repeat, linear-gradient(135deg, var(--muted) 50%, transparent 50%) right 9px center / 4px 4px no-repeat, #fff; font: inherit; }
.crop-controls { margin: 10px 0; padding: 8px 10px; border: 1px solid var(--line); border-radius: 7px; }
.crop-controls summary { cursor: pointer; font-weight: 650; font-size: .875rem; }
.crop-controls .hint { margin-top: 7px; }
.crop-stage { margin: 8px auto; position: relative; width: min(100%, 420px, calc(240px * var(--crop-ratio, 1))); aspect-ratio: var(--crop-ratio, 1); overflow: hidden; touch-action: none; cursor: crosshair; user-select: none; background: #e9eaf3; }
.crop-stage img { display: block; width: 100%; height: 100%; pointer-events: none; }
.crop-selection { position: absolute; pointer-events: none; border: 1px dashed #fff; box-shadow: 0 0 0 1px #303da1, 0 0 0 5000px #19234080; }
.crop-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(66px, 1fr)); gap: 5px; margin-top: 8px; }
.crop-fields label { display: grid; gap: 3px; min-width: 0; font-size: .8125rem; color: var(--muted); overflow-wrap: anywhere; }
.crop-fields input { min-height: 34px; min-width: 0; width: 100%; color: var(--ink); border: 1px solid var(--line); border-radius: 6px; padding: 4px 6px; }
.preview-caption { margin-top: 11px; overflow-wrap: anywhere; }
.queue { margin: 13px 0 0; padding: 13px 0 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; list-style: none; border-top: 1px solid var(--line); }
.queue-item { min-width: 0; display: flex; align-items: center; gap: 3px; border: 1px solid var(--line); border-radius: 8px; padding: 3px; }
.queue-item:has(.select-image[aria-pressed="true"]) { border-color: #8e9aef; background: #f1f3ff; }
.select-image { display: flex; flex: 1; min-width: 0; align-items: center; gap: 7px; padding: 2px; text-align: start; background: transparent; color: var(--ink); border: 0; border-radius: 5px; }
.select-image img { flex: 0 0 auto; width: 27px; height: 36px; object-fit: contain; border: 1px solid #d9deee; border-radius: 2px; }
.file-label { display: grid; gap: 3px; min-width: 0; }
.filename { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .875rem; }
.output-filename { color: var(--muted); font-size: .8125rem; font-variant-numeric: tabular-nums; }
.remove-image { display: grid; place-items: center; flex: 0 0 auto; width: 34px; height: 38px; border: 0; background: transparent; color: var(--muted); border-radius: 5px; font-size: 1.3rem; line-height: 1; }
.remove-image:hover:not(:disabled) { background: #fde8eb; color: #9b2531; }

.tool-notes { display: grid; gap: 10px; max-width: 700px; padding-block: 4px 32px; color: var(--muted); }
.tool-notes details { border-block-start: 1px solid var(--line); padding-block-start: 10px; }
.tool-notes summary { width: fit-content; font-size: .875rem; cursor: pointer; }
.tool-notes p { margin-block-start: 8px; line-height: 1.55; }
.not-found { padding-block: 64px; }
.not-found p { margin-block: 16px 22px; color: var(--muted); }
.not-found a { text-decoration: none; }

@media (max-width: 720px) {
  .shell { width: calc(100% - 32px); }
  .header-inner { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 10px; padding-block: 11px; }
  .privacy { grid-area: 2 / 1 / 3 / -1; margin-inline-start: 0; }
  .language-switcher { grid-area: 1 / 2; }
  .intro { padding-top: 28px; padding-bottom: 21px; }
  .workspace { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto; gap: 12px; }
  .preview-panel, .download-panel { grid-area: auto; }
  .panel { padding: 15px; border-radius: 12px; }
  .preview-stage { padding: 11px; }
}

@media (max-width: 390px) {
  .size-form, .queue { grid-template-columns: minmax(0, 1fr); }
}
