:root {
  color-scheme: light;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: #111;
  background: #fff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #fff;
}

a {
  color: inherit;
}

.page {
  width: min(100%, 920px);
  margin: 0 auto;
  padding: 32px 20px 64px;
}

.topline,
.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: center;
}

.topline,
.muted,
footer {
  color: #555;
  font-size: 0.95rem;
}

.language-switch {
  position: relative;
  display: inline-block;
  margin-bottom: 36px;
  color: #555;
  font-size: 0.95rem;
}

.language-button {
  min-height: 40px;
  gap: 8px;
  padding-right: 14px;
}

.language-button::after {
  width: 0;
  height: 0;
  border-top: 5px solid currentColor;
  border-right: 4px solid transparent;
  border-left: 4px solid transparent;
  content: "";
}

.language-menu {
  position: absolute;
  z-index: 10;
  top: calc(100% + 6px);
  left: 0;
  display: grid;
  min-width: 160px;
  padding: 6px;
  border: 1px solid #111;
  border-radius: 4px;
  background: #fff;
}

.language-menu[hidden] {
  display: none;
}

.language-menu a {
  display: block;
  padding: 8px 10px;
  text-decoration: none;
}

.language-menu a:hover,
.language-menu a:focus-visible {
  background: #f4f4f4;
}

.language-menu [aria-current="page"] {
  color: #111;
  font-weight: 700;
}

h1,
h2 {
  line-height: 1.18;
  letter-spacing: 0;
  color: #111;
}

h1 {
  margin: 0 0 16px;
  font-size: clamp(2rem, 7vw, 3.2rem);
}

h2 {
  margin: 0 0 12px;
  font-size: clamp(1.35rem, 4vw, 1.8rem);
}

h3 {
  margin: 22px 0 8px;
  font-size: 1.05rem;
  line-height: 1.3;
}

p {
  margin: 0 0 16px;
}

.lead {
  max-width: 56ch;
  font-size: 1.15rem;
}

.stat {
  margin: 18px 0 24px;
  font-weight: 700;
}

main > section {
  margin-top: 52px;
  padding-top: 32px;
  border-top: 1px solid #cfcfcf;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 28px 0 36px;
}

.button,
button {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  border: 1px solid #111;
  border-radius: 4px;
  background: #fff;
  color: #111;
  font: inherit;
  font-size: 0.95rem;
  text-decoration: none;
  cursor: pointer;
}

.button:hover,
button:hover {
  background: #f4f4f4;
}

button:disabled {
  border-color: #999;
  background: #eee;
  color: #666;
  cursor: wait;
}

.tool-submit:disabled,
.tool-submit:disabled:hover {
  background: #555;
  color: #fff;
}

.button:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
.language-menu a:focus-visible {
  outline: 3px solid #111;
  outline-offset: 2px;
}

.tool-form {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 12px;
  align-items: center;
  width: fit-content;
  max-width: 100%;
  margin: 24px 0 10px;
  padding: 12px;
  border: 1px solid #111;
  background: #fff;
}

label {
  display: grid;
  gap: 8px;
  font-weight: 700;
}

.file-picker {
  display: inline-flex;
  gap: 0;
  font-weight: 400;
}

.file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
}

.file-button {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  border: 1px solid #111;
  border-radius: 4px;
  background: #fff;
  color: #111;
  font-size: 0.95rem;
  cursor: pointer;
}

.file-picker:hover .file-button {
  background: #f4f4f4;
}

.file-picker:focus-within .file-button {
  outline: 3px solid #111;
  outline-offset: 2px;
}

.file-name {
  min-width: 0;
  max-width: min(320px, 55vw);
  overflow: hidden;
  color: #555;
  font-size: 0.95rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-name:empty {
  display: none;
}

.tool-submit {
  background: #111;
  color: #fff;
}

.tool-submit:hover {
  background: #333;
}

.tool-options {
  display: grid;
  flex-basis: 100%;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 12px;
  padding-top: 12px;
  border-top: 1px solid #ddd;
}

.tool-options[hidden] {
  display: none;
}

.option-field {
  display: grid;
  gap: 4px;
  font-size: 0.95rem;
  font-weight: 700;
}

.option-field input,
.option-field select {
  min-height: 34px;
  padding: 0 8px;
  border: 1px solid #999;
  background: #fff;
  color: #111;
  font: inherit;
}

.option-toggle {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 0.95rem;
  font-weight: 700;
}

.option-toggle input {
  width: 16px;
  height: 16px;
  margin: 0;
}

.status,
.notice {
  margin-top: 10px;
  padding: 0;
  color: #555;
  font-size: 0.95rem;
}

.preview,
.result {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid #ddd;
}

.preview {
  display: flex;
  max-width: 520px;
  gap: 12px;
  align-items: center;
  margin-top: 18px;
  padding: 12px;
  border: 1px solid #ddd;
}

.result {
  display: grid;
  gap: 12px;
}

.preview[hidden],
.result[hidden] {
  display: none;
}

img {
  max-width: 100%;
  height: auto;
}

.preview h2,
.result h2 {
  margin: 0;
  font-size: 1rem;
}

.preview img {
  width: 72px;
  height: 72px;
  flex: 0 0 72px;
  object-fit: cover;
  border: 1px solid #ddd;
}

.preview-meta {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.preview-name {
  overflow: hidden;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview-size,
.preview-output {
  color: #555;
  font-size: 0.95rem;
}

.compare {
  --position: 50%;
  position: relative;
  width: 100%;
  margin-top: 12px;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  border: 1px solid #ddd;
  background: #f4f4f4;
  touch-action: none;
}

.compare-square {
  aspect-ratio: 1;
  background-color: #fff;
  background-image:
    linear-gradient(45deg, #ddd 25%, transparent 25%),
    linear-gradient(-45deg, #ddd 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #ddd 75%),
    linear-gradient(-45deg, transparent 75%, #ddd 75%);
  background-position: 0 0, 0 12px, 12px -12px, -12px 0;
  background-size: 24px 24px;
}

.compare img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
  pointer-events: none;
  user-select: none;
}

.compare-before {
  position: absolute;
  inset: 0;
  clip-path: inset(0 calc(100% - var(--position)) 0 0);
}

.compare-range {
  position: absolute;
  z-index: 4;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: ew-resize;
  pointer-events: none;
}

.compare-divider {
  position: absolute;
  z-index: 3;
  top: 0;
  bottom: 0;
  left: var(--position);
  width: 2px;
  background: #fff;
  box-shadow: 0 0 0 1px #111;
  transform: translateX(-1px);
  pointer-events: none;
}

.compare-handle {
  position: absolute;
  top: 50%;
  left: 50%;
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid #111;
  border-radius: 999px;
  background: #fff;
  color: #111;
  transform: translate(-50%, -50%);
}

.compare-handle::before {
  content: "↔";
}

.compare-label {
  position: absolute;
  z-index: 2;
  top: 10px;
  padding: 3px 8px;
  background: #fff;
  color: #111;
  font-size: 0.85rem;
  font-weight: 700;
}

.compare-label-before {
  left: 10px;
}

.compare-label-after {
  right: 10px;
}

.examples-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-top: 18px;
}

.examples-grid-single {
  grid-template-columns: minmax(0, 520px);
}

.example-card {
  border: 1px solid #ddd;
  background: #fff;
}

.example-card h3 {
  margin: 0;
  padding: 12px 12px 0;
}

.example-card .compare {
  margin-top: 12px;
  aspect-ratio: 4 / 3;
  border-right: 0;
  border-bottom: 0;
  border-left: 0;
}

.example-card .compare-square {
  aspect-ratio: 1;
}

footer {
  margin-top: 56px;
  padding-top: 24px;
  border-top: 1px solid #ddd;
}

@media (max-width: 520px) {
  .page {
    padding: 24px 16px 44px;
  }

  .file-name {
    max-width: 100%;
  }

  .tool-options {
    grid-template-columns: 1fr;
  }

  .examples-grid {
    grid-template-columns: 1fr;
  }

  .language-button {
    width: auto;
  }
}
