:root {
  color-scheme: light;
  font: 100%/1.6 "Malgun Gothic", "Apple SD Gothic Neo", system-ui, sans-serif;
  color: #172036;
  background: #fff;
  accent-color: #244bd7;
  --accent: #244bd7;
  --accent-dark: #193bb7;
  --tint: #f3f6ff;
  --line: #dce3ee;
  --muted: #515f75;
}
* { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }
a { color: var(--accent-dark); }
button, input, select { font: inherit; }
button, .button, select, input[type="number"] {
  min-height: 44px;
  border: 1px solid #aebacf;
  border-radius: .65rem;
  background: white;
  color: inherit;
  padding: .5rem .8rem;
}
button, select, summary { cursor: pointer; }
button:disabled { background: #f4f6fa; border-color: var(--line); color: #5c687b; cursor: default; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

.site-header { border-bottom: 1px solid var(--line); }
.site-header nav, main { width: min(66rem, calc(100% - 2rem)); margin-inline: auto; }
.site-header nav { display: flex; justify-content: center; gap: clamp(.35rem, 1.2vw, .7rem); padding-block: .55rem; }
.site-header a {
  display: grid;
  place-items: center;
  min-height: 48px;
  padding-inline: clamp(.55rem, 2.6vw, 1.25rem);
  border-radius: .65rem;
  color: var(--muted);
  font-size: clamp(1rem, 2.5vw, 1.1rem);
  font-weight: 700;
  text-align: center;
  text-decoration: none;
}
.site-header a:hover { background: var(--tint); }
.site-header a[aria-current] { background: var(--accent); color: #fff; }
main { padding-block: clamp(1rem, 3vw, 2rem); }
.intro { margin: 0 auto clamp(1rem, 3vw, 1.6rem); text-align: center; }
.intro h1 { margin: 0; font-size: clamp(1.8rem, 5vw, 3rem); line-height: 1.22; letter-spacing: -.055em; }
.intro p, .drop p { word-break: keep-all; }
.intro p { max-width: 42rem; margin: .75rem auto 0; color: var(--muted); }
form { padding: clamp(.85rem, 3vw, 1.65rem); border: 1px solid var(--line); border-radius: 1.15rem; }
.drop {
  padding: clamp(1rem, 3vw, 1.6rem) .75rem;
  text-align: center;
  background: var(--tint);
  border: 2px dashed #8da3ea;
  border-radius: .9rem;
}
.drop.has-files { background: #f7faff; border-style: solid; }
.drop.is-dragging { background: #e0eaff; border-color: var(--accent); }
.upload-icon {
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  margin: 0 auto .75rem;
  color: var(--accent);
}
.file-picker { display: inline-grid; position: relative; }
.picker-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: .5rem; }
.file-picker input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; pointer-events: none; }
.file-picker label { cursor: pointer; }
.file-picker:focus-within .button { outline: 3px solid var(--accent); outline-offset: 3px; }
.file-picker:hover .button { background: #eef2fb; }
.file-picker:hover .primary { background: var(--accent-dark); }
.file-picker:has(input:disabled) .button { background: #e5eaf3; border-color: var(--line); color: var(--muted); cursor: default; }
.drop p { margin: .65rem 0 0; }
.drop-help { font-size: .95rem; font-weight: 700; }
#limits, #folder-policy, #folder-help { font-size: .82rem; color: var(--muted); }
.queue { margin: .85rem 0 .3rem; font-size: .92rem; font-weight: 750; }
.file-list {
  max-height: 10rem;
  overflow: auto;
  list-style: none;
  margin: 0;
  padding: 0 .75rem;
  border: 1px solid var(--line);
  border-radius: .7rem;
}
.file-list li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: .6rem; padding-block: .4rem; font-size: .86rem; }
.file-list li + li { border-top: 1px solid var(--line); }
.file-list li div { overflow-wrap: anywhere; }
.file-list small { display: block; color: var(--muted); font-variant-numeric: tabular-nums; }
.thumbnail { display: grid; place-items: center; width: 48px; height: 48px; padding: 0; background: #f1f4f9; }
.thumbnail img { display: block; width: 100%; height: 100%; object-fit: contain; }
.thumbnail img:not([src]), article img:not([src]) { color: transparent; }
#image-preview { width: min(54rem, calc(100% - 2rem)); max-height: 90dvh; overflow: auto; border: 1px solid var(--line); border-radius: .85rem; padding: 1rem; color: inherit; }
html:has(#image-preview[open]) { overflow: hidden; }
#image-preview::backdrop { background: #17203699; }
.preview-header { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
#preview-title { margin: 0; font-size: 1.15rem; overflow-wrap: anywhere; }
#preview-close { flex: 0 0 auto; min-width: 44px; padding: .1rem; font-size: 1.65rem; line-height: 1; }
#preview-close:hover { background: var(--tint); }
#preview-filename { margin: .35rem 0 .85rem; color: var(--muted); overflow-wrap: anywhere; }
.preview-images { display: grid; gap: .75rem; }
@media (min-width: 42rem) {
  .preview-images.is-comparison { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.preview-images figure { margin: 0; min-width: 0; }
.preview-images figcaption { margin-bottom: .4rem; font-size: .88rem; }
.preview-images img { display: block; width: 100%; max-height: 55dvh; object-fit: contain; background: #f1f4f9; }

fieldset { min-width: 0; border: 0; padding: 0; margin: 1.45rem 0 1rem; }
legend { padding: 0; font-weight: 750; font-size: 1.15rem; margin-bottom: .65rem; }
.option { border: 1px solid var(--line); border-radius: .8rem; }
.option label { font-size: .9rem; }
.option-body { padding: clamp(.75rem, 2vw, 1.15rem); }
#resize-options, #compress-options {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
  gap: .75rem 1.5rem;
}
.option-field, #format { max-width: 20rem; }
#format-options { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: .35rem .75rem; }
#format { flex: 1 1 12rem; width: auto; }
#resize-options > .fields { max-width: 27rem; }
.target-fields { grid-template-columns: minmax(0, 1fr) minmax(5rem, .4fr); align-items: end; max-width: 27rem; }
.quality-label, .quality-scale { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.quality-label output { color: var(--accent-dark); font-weight: 750; }
.quality-scale { color: var(--muted); font-size: .8rem; }
.quality-scale input { flex: 1; min-width: 0; min-height: 44px; margin: 0; }
#quality-options, #target-options { max-width: 39rem; }
@media (min-width: 42rem) {
  #resize-options { grid-template-columns: minmax(0, 27rem) minmax(0, 1fr); }
  #compress-options { grid-template-columns: minmax(12rem, 18rem) minmax(0, 1fr); }
}
.option-body p { margin: .55rem 0 0; color: var(--muted); font-size: .82rem; }
.option-body p:first-child { margin-top: 0; }
label:has(input[type="checkbox"]) { display: flex; align-items: center; min-height: 44px; gap: .45rem; cursor: pointer; }
input[type="checkbox"] { width: 1.1rem; height: 1.1rem; margin: 0; flex-shrink: 0; }
input[type="number"], select { display: block; width: 100%; margin-block: .2rem; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.option-body .actions { margin-top: .4rem; }
.option-body button { font-size: .85rem; }
.controls { padding-top: .8rem; border-top: 1px solid var(--line); }
.primary, button[aria-pressed="true"] {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  font-weight: 750;
}
.primary { min-height: 48px; padding-inline: 1.25rem; }
.primary:not(:disabled):hover, button[aria-pressed="true"]:not(:disabled):hover { background: var(--accent-dark); }
.run-hint, #status { margin: .55rem 0 0; color: var(--muted); font-size: .88rem; overflow-wrap: anywhere; }
.run-hint:empty, #status:empty { margin: 0; }
progress { display: block; width: 100%; height: .65rem; margin-top: .9rem; }

.outcome { margin-top: 1.6rem; }
.outcome-heading { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .5rem; }
.outcome-heading h2, .details h2 { margin: 0; font-size: 1.2rem; }
#failures:empty, .results:empty { display: none; }
#failures { color: #8e2c17; overflow-wrap: anywhere; }
.results { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 19rem), 1fr)); gap: .75rem; margin-top: .7rem; }
article { padding: 1rem; border: 1px solid var(--line); border-radius: .85rem; overflow-wrap: anywhere; }
article h3 { margin: 0 0 .65rem; font-size: 1rem; }
article img { display: block; width: 100%; height: 9rem; object-fit: contain; background: #f1f4f9; border-radius: .55rem; }
.comparison { margin: .7rem 0; font-size: .88rem; font-variant-numeric: tabular-nums; }
.comparison p { margin: .3rem 0; }
.comparison strong { margin-right: .4rem; }
.size-change { color: var(--muted); }
.button { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.secondary, #zip { color: var(--accent-dark); font-weight: 700; }
.secondary:hover, #zip:not(:disabled):hover { background: var(--tint); }
.warning { color: #8a3208; font-size: .88rem; }
.details { border-top: 1px solid var(--line); margin-top: 1.5rem; padding-top: 1rem; }
.details p, .details li { color: var(--muted); }
.details ol { padding-left: 1.3rem; }
details { margin-top: .4rem; }
summary { padding-block: .5rem; }

.related-links { display: flex; flex-wrap: wrap; gap: .25rem 1rem; margin-top: .35rem; }
.related-links a { display: inline-flex; align-items: center; min-height: 44px; }
@media (max-width: 30rem) {
  .controls button { flex: 1; }
  .controls .primary { flex: 1 0 100%; }
}
