:root:has(> body.wfn-platform[data-converter]) {
  --page: #ededed;
  --panel: #fff;
  --nav: #f0f0f0;
  --heading: #e7e7e7;
  --gold: #555;
  --text: #232323;
  --muted: #535353;
  --border: #d2d2d2;
  --link: #414141;
  --primary: #434343;
  --soft: #f5f5f5;
  --input: #fafafa;
  --selected: #e6e6e6;
  --shadow: #0000001a;
  --converter-outline: #929292;
  --converter-hover: #ececec;
  --converter-on-primary: #fff;
}

:root[data-theme="dark"]:has(> body.wfn-platform[data-converter]) {
  --page: #202020;
  --panel: #292929;
  --nav: #303030;
  --heading: #353535;
  --gold: #d5d5d5;
  --text: #f0f0f0;
  --muted: #cecece;
  --border: #484848;
  --link: #dedede;
  --primary: #d5d5d5;
  --soft: #303030;
  --input: #272727;
  --selected: #3d3d3d;
  --shadow: #0005;
  --converter-outline: #808080;
  --converter-hover: #383838;
  --converter-on-primary: #222;
}

body[data-converter] .tools-header {
  --header-surface: var(--panel);
  --header-rail: var(--soft);
  --header-hover: var(--converter-hover);
  --header-line: var(--border);
  --header-ink: var(--text);
  --header-muted: var(--muted);
  --header-accent: var(--primary);
  --header-accent-surface: var(--selected);
  --header-shadow: var(--shadow);
}

body[data-converter] .quota-track > span { background: var(--converter-outline); }
body[data-converter] :focus-visible { outline-color: var(--primary); }

.wfn-platform .webp-tool {
  --webp-surface: var(--panel);
  --webp-soft: var(--soft);
  --webp-line: var(--border);
  --webp-drop-line: var(--converter-outline);
  --webp-ink: var(--text);
  --webp-muted: var(--muted);
  --webp-accent: var(--primary);
  --webp-tint: var(--selected);
  --webp-hover: var(--converter-hover);
  --webp-primary-ink: var(--converter-on-primary);
  border-color: var(--webp-line);
  background: var(--webp-surface);
  color: var(--webp-ink);
}

.wfn-platform .webp-heading {
  align-items: flex-start;
  gap: 14px;
  background: var(--webp-soft);
  border-color: var(--webp-line);
}

.webp-heading > div { align-items: flex-start; min-width: 0; }
.webp-heading-copy { min-width: 0; }
.webp-heading-copy p {
  margin: 4px 0 0;
  color: var(--webp-muted);
  font-size: 15px;
  font-weight: 400;
  line-height: 1.75;
}

.webp-heading-mark,
.webp-upload-mark {
  display: grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  border: 1px solid var(--webp-line);
  border-radius: 4px;
  background: var(--webp-tint);
  color: var(--webp-accent);
}
.webp-heading-mark .icon,
.webp-upload-mark .icon { width: 22px; height: 22px; }
.webp-tool .heading-detail { margin-top: 5px; color: var(--webp-muted); font-size: 14px; }

.wfn-platform .webp-form { display: grid; gap: 20px; }
.webp-settings { display: flex; flex-wrap: wrap; align-items: end; gap: 12px 16px; }
.webp-direction { flex: 1 1 315px; min-width: 0; margin: 0; padding: 0; border: 0; }
.webp-direction legend,
.webp-target,
.webp-source-label { padding: 0; font-size: 14px; font-weight: 600; }
.webp-direction legend, .webp-source-label { margin-bottom: 7px; }
.webp-direction-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border: 1px solid var(--webp-line);
  border-radius: 4px;
  background: var(--webp-soft);
}
.webp-form :is(.webp-direction-options > label, .webp-target, .webp-dropzone) { margin: 0; }
.webp-direction-options > label { min-width: 0; cursor: pointer; }
.webp-direction-options label + label { border-inline-start: 1px solid var(--webp-line); }
.webp-direction-options label > span {
  display: grid;
  align-items: center;
  min-height: 43px;
  height: 100%;
  padding: 5px 8px;
  border-block-end: 2px solid transparent;
  border-radius: 3px;
  text-align: center;
  line-height: 1.5;
  transition: color 150ms ease, background-color 150ms ease;
}
.webp-direction-options label:hover > span { background: var(--webp-hover); }
.webp-direction-options input:checked + span {
  border-block-end-color: var(--webp-accent);
  background: var(--webp-tint);
  color: var(--webp-accent);
  font-weight: 600;
}
.webp-direction-options input:focus-visible + span,
.webp-dropzone:focus-within { outline: 2px solid var(--webp-accent); outline-offset: 2px; }
.webp-target { display: grid; flex: 0 1 180px; min-width: 0; gap: 7px; }
.webp-target select {
  width: 100%;
  min-height: 45px;
  padding: 7px 10px;
  border: 1px solid var(--webp-line);
  border-radius: 4px;
  background: var(--webp-surface);
  color: var(--webp-ink);
  font: inherit;
  font-weight: 400;
}

.webp-dropzone {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 15px;
  min-height: 116px;
  padding: 17px;
  border: 1px dashed var(--webp-drop-line);
  border-radius: 4px;
  background: var(--webp-soft);
  cursor: pointer;
  transition: background-color 150ms ease, border-color 150ms ease;
}
.webp-dropzone:hover, .webp-dropzone.is-dragging {
  border-color: var(--webp-accent);
  background: var(--webp-hover);
}
.webp-dropzone.has-file { border-style: solid; }
.webp-file-copy { display: grid; gap: 3px; min-width: 0; overflow-wrap: anywhere; }
.webp-file-copy strong { font-size: 15px; line-height: 1.55; }
.webp-file-copy > span { color: var(--webp-muted); font-size: 14px; line-height: 1.75; }
#webp-max { display: inline-block; min-inline-size: 6ch; white-space: nowrap; font-variant-numeric: tabular-nums; }
.webp-picker {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 41px;
  padding: 6px 12px;
  border: 1px solid var(--webp-drop-line);
  border-radius: 4px;
  background: var(--webp-surface);
  color: var(--webp-ink);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}
.webp-dropzone:hover .webp-picker { border-color: var(--webp-accent); }

.webp-actions { display: grid; grid-template-columns: max-content minmax(0, 1fr); align-items: center; gap: 16px; }
.webp-form #webp-submit {
  min-height: 43px;
  border-color: var(--webp-accent);
  border-radius: 4px;
  background: var(--webp-accent);
  color: var(--webp-primary-ink);
  font-size: 14px;
}
.webp-form #webp-submit:not(:disabled):hover { filter: brightness(1.1); }
.webp-form #webp-submit:disabled {
  border-color: var(--webp-drop-line);
  background: var(--webp-soft);
  color: var(--webp-muted);
  opacity: 1;
  cursor: default;
}

.webp-tool .field-help, .webp-tool .status-message,
.webp-tool .remaining-inline, .webp-tool .block-footer {
  margin-block: 0;
  font-size: 14px;
  line-height: 1.75;
}
.webp-tool .field-help, .webp-tool .remaining-inline, .webp-tool .block-footer { color: var(--webp-muted); }
.webp-tool .block-footer { background: var(--webp-soft); border-color: var(--webp-line); }
.webp-tool .webp-result {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 9px 16px;
  margin: 0 25px 20px;
  padding: 14px;
  border: 1px solid var(--webp-line);
  border-radius: 4px;
  background: var(--webp-soft);
  overflow-wrap: anywhere;
}
.webp-result-copy { min-width: 0; }
.webp-result .result-title { margin: 0 0 4px; color: var(--webp-ink); }
.webp-result #webp-download {
  border-color: var(--webp-drop-line);
  background: var(--webp-surface);
  color: var(--webp-ink);
  font-size: 14px;
}

@media (max-width: 560px) {
  .webp-heading-copy p { font-size: 14px; }
  .webp-heading-mark, .webp-upload-mark { width: 38px; height: 38px; }
  .wfn-platform .webp-heading { flex-wrap: wrap; gap: 5px; }
  .webp-tool .heading-detail { margin: 0 0 0 49px; }
  .webp-target { flex-basis: 100%; }
  .webp-dropzone { grid-template-columns: auto minmax(0, 1fr); gap: 10px; padding: 12px; }
  .webp-picker { grid-column: 1 / -1; }
  .webp-actions { min-block-size: 49px; }
  .webp-tool .webp-result { margin-inline: 17px; }
}

@media (prefers-reduced-motion: reduce) {
  .webp-dropzone, .webp-direction-options label > span { transition: none; }
}
