/* ==========================================================================
   WebP to PNG Converter - single stylesheet
   Order: tokens -> reset -> layout -> header -> converter -> content -> ads
          -> footer -> responsive
   No external fonts or CSS frameworks: the page renders on first paint.
   ========================================================================== */

/* ---------- Design tokens ---------- */
:root {
  --bg:            #f6f7f9;
  --surface:       #ffffff;
  --surface-alt:   #f1f3f6;
  --border:        #e2e6ec;
  --border-strong: #cbd2dc;
  --text:          #16202e;
  --text-muted:    #5b6675;
  --text-faint:    #8a94a3;
  --accent:        #2f6df0;
  --accent-hover:  #2559cc;
  --accent-soft:   #eaf1fe;
  --success:       #12855b;
  --success-soft:  #e6f5ef;
  --danger:        #c2321f;
  --danger-soft:   #fdecea;

  --radius:    12px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-md: 0 4px 20px -6px rgba(16, 24, 40, .12);

  --wrap:   1140px;
  --gutter: 20px;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* Dark palette. Declared twice on purpose: once for the OS preference (unless
   the visitor has explicitly chosen light) and once for an explicit choice, so
   the toggle can override the system in both directions. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:            #0e131b;
    --surface:       #161d27;
    --surface-alt:   #1c2531;
    --border:        #28313d;
    --border-strong: #3a4553;
    --text:          #e8ecf2;
    --text-muted:    #a3adbb;
    --text-faint:    #7c8797;
    --accent:        #6d9bff;
    --accent-hover:  #8bb0ff;
    --accent-soft:   #1b2740;
    --success:       #4ecfa0;
    --success-soft:  #142a23;
    --danger:        #ff8f7e;
    --danger-soft:   #33191a;
    --shadow-md:     0 4px 20px -6px rgba(0, 0, 0, .5);
  }
}

:root[data-theme="dark"] {
  --bg:            #0e131b;
  --surface:       #161d27;
  --surface-alt:   #1c2531;
  --border:        #28313d;
  --border-strong: #3a4553;
  --text:          #e8ecf2;
  --text-muted:    #a3adbb;
  --text-faint:    #7c8797;
  --accent:        #6d9bff;
  --accent-hover:  #8bb0ff;
  --accent-soft:   #1b2740;
  --success:       #4ecfa0;
  --success-soft:  #142a23;
  --danger:        #ff8f7e;
  --danger-soft:   #33191a;
  --shadow-md:     0 4px 20px -6px rgba(0, 0, 0, .5);
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
/* Components below set display:flex/grid, which would otherwise beat the UA
   rule for [hidden] and leave "hidden" elements on screen. */
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
body {
  margin: 0;
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
img, svg { max-width: 100%; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; letter-spacing: -.02em; font-weight: 650; }
h1 { font-size: clamp(1.9rem, 1.3rem + 2.4vw, 2.7rem); }
h2 { font-size: clamp(1.35rem, 1.1rem + 1vw, 1.65rem); }
h3 { font-size: 1.06rem; font-weight: 640; }
p  { margin: 0 0 1em; }
code { font-family: var(--mono); font-size: .88em; background: var(--surface-alt); padding: .12em .38em; border-radius: 5px; }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }

/* Focus: always visible, never removed. */
:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

.skip-link {
  position: absolute; left: 50%; top: 0; transform: translate(-50%, -120%);
  z-index: 100; background: var(--accent); color: #fff; font-weight: 600;
  padding: .7rem 1.2rem; border-radius: 0 0 10px 10px; text-decoration: none;
}
.skip-link:focus { transform: translate(-50%, 0); color: #fff; }

/* ---------- Layout ---------- */
.wrap { width: 100%; max-width: var(--wrap); margin-inline: auto; padding-inline: var(--gutter); }

/* ---------- Header ---------- */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; min-height: 62px;
}
.brand {
  display: inline-flex; align-items: center; gap: .55rem;
  color: var(--text); text-decoration: none; font-weight: 680; font-size: 1.05rem;
  letter-spacing: -.02em;
}
.brand-mark { color: var(--accent); flex: none; }
.site-nav { display: flex; gap: 1.35rem; font-size: .95rem; }
.site-nav a { color: var(--text-muted); text-decoration: none; font-weight: 500; }
.site-nav a:hover { color: var(--text); text-decoration: underline; }

/* ---------- Hero + converter ---------- */
.hero { padding: clamp(1.75rem, 1rem + 3vw, 3rem) 0 .5rem; text-align: center; }
.crumbs { font-size: .84rem; color: var(--text-faint); margin-bottom: .75rem; }
.crumbs a { color: var(--text-muted); text-decoration: none; }
.crumbs a:hover { color: var(--accent); text-decoration: underline; }
.crumbs span { margin: 0 .35rem; }
.hub-grid { max-width: 900px; margin: 0 auto; text-align: left; }
.hero h1 { margin-bottom: .35em; }
.lede {
  max-width: 60ch; margin: 0 auto 1.75rem;
  font-size: 1.06rem; color: var(--text-muted);
}

.tool-card {
  max-width: 860px; margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: clamp(1rem, .5rem + 2vw, 1.75rem);
  text-align: left;
}

.dropzone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface-alt);
  padding: clamp(1.5rem, 1rem + 3vw, 2.75rem) 1.25rem;
  text-align: center;
  transition: border-color .15s ease, background-color .15s ease;
}
.dropzone.is-dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.dropzone-icon { color: var(--accent); display: block; margin: 0 auto .6rem; }
.dropzone-title { font-size: 1.1rem; font-weight: 620; margin-bottom: .3rem; }
.dropzone-sub { color: var(--text-faint); font-size: .9rem; margin-bottom: .85rem; }
.dropzone-hint { margin: 1rem 0 0; font-size: .86rem; color: var(--text-muted); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  font: inherit; font-weight: 600; font-size: .96rem; line-height: 1;
  padding: .72rem 1.3rem; border-radius: 10px; border: 1px solid transparent;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); color: #fff; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-alt); color: var(--text); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface-alt); color: var(--text); }
.btn-sm { padding: .5rem .85rem; font-size: .87rem; border-radius: 8px; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }

/* ---------- Theme toggle ---------- */
.theme-toggle {
  display: inline-grid; place-items: center;
  width: 36px; height: 36px; padding: 0; flex: none;
  border-radius: 9px; border: 1px solid var(--border);
  background: transparent; color: var(--text-muted); cursor: pointer;
}
.theme-toggle:hover { background: var(--surface-alt); color: var(--text); }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun,
:root:not([data-theme="light"]) .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon,
:root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .theme-toggle .icon-sun { display: none; }
  :root:not([data-theme="dark"]) .theme-toggle .icon-moon { display: block; }
}
:root[data-theme="light"] .theme-toggle .icon-sun { display: none; }
:root[data-theme="light"] .theme-toggle .icon-moon { display: block; }

/* ---------- Conversion options ---------- */
.options {
  display: flex; flex-wrap: wrap; gap: 1.25rem 2rem; align-items: center;
  margin-top: 1.15rem; padding: .9rem 1rem;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface-alt);
}
.option { display: flex; align-items: center; gap: .6rem; font-size: .9rem; }
.option label { color: var(--text-muted); font-weight: 550; }
.option input[type="range"] { width: 150px; accent-color: var(--accent); }
.option input[type="color"] {
  width: 34px; height: 30px; padding: 0; cursor: pointer;
  border: 1px solid var(--border-strong); border-radius: 7px; background: none;
}
.option output { font-variant-numeric: tabular-nums; font-weight: 620; min-width: 3.2em; }
.option-hint { font-size: .82rem; color: var(--text-faint); }

/* ---------- Status + progress ---------- */
.status { margin: 1rem 0 0; font-size: .93rem; color: var(--text-muted); min-height: 1.5em; }
.status:empty { margin: 0; min-height: 0; }
.status.is-error { color: var(--danger); font-weight: 550; }
.status.is-done  { color: var(--success); font-weight: 550; }

.progress {
  margin-top: .6rem; height: 6px; border-radius: 99px;
  background: var(--surface-alt); overflow: hidden;
}
.progress-bar {
  height: 100%; width: 0%; background: var(--accent);
  border-radius: 99px; transition: width .2s ease;
}

/* ---------- File list ---------- */
.file-list { list-style: none; margin: 1.15rem 0 0; padding: 0; display: grid; gap: .7rem; }
.file-list:empty { margin: 0; }

.file-item {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) auto;
  gap: .9rem; align-items: center;
  padding: .7rem; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--surface);
}
.file-item.is-error { border-color: var(--danger); background: var(--danger-soft); }

.thumb {
  width: 64px; height: 64px; border-radius: 8px; overflow: hidden;
  background:
    linear-gradient(45deg, var(--surface-alt) 25%, transparent 25%, transparent 75%, var(--surface-alt) 75%) 0 0/16px 16px,
    linear-gradient(45deg, var(--surface-alt) 25%, transparent 25%, transparent 75%, var(--surface-alt) 75%) 8px 8px/16px 16px,
    var(--surface);
  border: 1px solid var(--border);
  display: grid; place-items: center; flex: none;
}
.thumb img { width: 100%; height: 100%; object-fit: contain; display: block; }
.thumb-fallback { color: var(--text-faint); font-size: .68rem; font-weight: 600; letter-spacing: .04em; }

.file-meta { min-width: 0; }
.file-name {
  font-weight: 600; font-size: .95rem; margin: 0 0 .15rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.file-sub { margin: 0; font-size: .83rem; color: var(--text-muted); }
.file-sub .sep { opacity: .5; margin: 0 .35rem; }
.file-state { font-weight: 600; }
.file-state.is-done  { color: var(--success); }
.file-state.is-error { color: var(--danger); }
.file-actions { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; justify-content: flex-end; }

.icon-btn {
  width: 34px; height: 34px; display: grid; place-items: center;
  border-radius: 8px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text-muted);
  cursor: pointer; padding: 0; flex: none;
}
.icon-btn:hover { background: var(--surface-alt); color: var(--danger); border-color: var(--danger); }

.toolbar {
  display: flex; flex-wrap: wrap; gap: .6rem; align-items: center;
  margin-top: 1.15rem; padding-top: 1.15rem; border-top: 1px solid var(--border);
}
.toolbar .btn-ghost { margin-left: auto; }

.privacy-note {
  display: flex; align-items: center; justify-content: center; gap: .5rem;
  max-width: 860px; margin: 1.1rem auto 0;
  font-size: .9rem; color: var(--success); font-weight: 550; text-align: left;
}
.privacy-note svg { flex: none; }

.alert {
  max-width: 860px; margin: 1rem auto 0; padding: .9rem 1.1rem;
  border-radius: var(--radius); border: 1px solid var(--danger);
  background: var(--danger-soft); color: var(--text); text-align: left; font-size: .95rem;
}

/* ---------- Tool grid (hub page + "other tools" blocks) ---------- */
.tool-grid {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: .85rem;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}
.tool-grid a {
  display: block; height: 100%;
  padding: 1rem 1.1rem; text-decoration: none;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
  transition: border-color .15s ease, background-color .15s ease;
}
.tool-grid a:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.tool-grid a[aria-current="page"] { border-color: var(--accent); background: var(--accent-soft); }
.tool-grid .tool-name { display: block; font-weight: 640; font-size: 1rem; margin-bottom: .2rem; }
.tool-grid .tool-desc { display: block; font-size: .86rem; color: var(--text-muted); line-height: 1.5; }

.related { padding-block: 1.4rem; }
.related h2 { font-size: 1.2rem; }

/* ---------- Content ---------- */
.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 2.5rem;
  padding-block: 1rem 2rem;
}
.content-main { min-width: 0; max-width: 76ch; }
.section { padding-block: 1.4rem; }
.section > p:last-child { margin-bottom: 0; }

.reason-list { margin: 0; padding-left: 1.2rem; display: grid; gap: .55rem; }
.reason-list li { padding-left: .15rem; }

.steps { margin: 0; padding-left: 1.35rem; display: grid; gap: 1.1rem; counter-reset: none; }
.steps li::marker { font-weight: 700; color: var(--accent); }
.steps h3 { margin-bottom: .25em; }
.steps p { margin: 0; color: var(--text-muted); }

.faq { display: grid; gap: .55rem; }
.faq details {
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); overflow: hidden;
}
.faq summary {
  cursor: pointer; list-style: none; padding: .9rem 2.6rem .9rem 1.1rem;
  font-weight: 600; font-size: 1rem; position: relative;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: ""; position: absolute; right: 1.15rem; top: 50%;
  width: 9px; height: 9px; margin-top: -6px;
  border-right: 2px solid var(--text-faint); border-bottom: 2px solid var(--text-faint);
  transform: rotate(45deg); transition: transform .15s ease;
}
.faq details[open] summary::after { transform: rotate(225deg); margin-top: -2px; }
.faq summary:hover { background: var(--surface-alt); }
.faq details > p { margin: 0; padding: 0 1.1rem 1.05rem; color: var(--text-muted); }

/* ==========================================================================
   AD SLOTS
   Every unit reserves its height up-front so a late-loading ad cannot push
   the page around (CLS). If an ad never loads, the reserved box simply stays
   empty - nothing else in the layout depends on it.
   ========================================================================== */
.ad-slot {
  display: block;
  margin-inline: auto;
  margin-block: 1.75rem;
}
.ad-slot::before {
  content: "Advertisement";
  display: block;
  font-size: .68rem; letter-spacing: .09em; text-transform: uppercase;
  color: var(--text-faint); text-align: center; margin-bottom: .35rem;
}
.ad-container {
  display: grid; place-items: center;
  width: 100%;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface-alt);
  color: var(--text-faint);
  font-size: .72rem; letter-spacing: .14em; font-weight: 600;
  overflow: hidden;
}
/* Height reservations, matched to standard AdSense responsive sizes. */
.ad-slot--leaderboard .ad-container { min-height: 100px; }
.ad-slot--incontent   .ad-container { min-height: 250px; }
.ad-slot--rail        .ad-container { min-height: 600px; }

@media (min-width: 768px) {
  .ad-slot--leaderboard .ad-container { min-height: 90px; max-width: 970px; margin-inline: auto; }
}

/* Desktop-only sidebar rail. Hidden until there is room for it. */
.ad-slot--rail { display: none; }

/* Keep mobile ad density low: drop the in-content rectangle on small screens. */
@media (max-width: 599px) {
  .ad-slot--incontent { display: none; }
}

/* ---------- Footer ---------- */
.site-footer {
  margin-top: 2rem;
  background: var(--surface);
  border-top: 1px solid var(--border);
  font-size: .93rem;
}
.footer-inner {
  display: grid; gap: 1.75rem;
  grid-template-columns: minmax(0, 1fr);
  padding-block: 2.25rem 1.5rem;
}
.footer-brand p { color: var(--text-muted); margin: .4rem 0 0; max-width: 42ch; }
.footer-heading { font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-faint); margin: 0 0 .6rem; font-weight: 650; }
.footer-nav ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; }
.footer-nav a { color: var(--text-muted); text-decoration: none; }
.footer-nav a:hover { color: var(--accent); text-decoration: underline; }
.footer-bottom {
  border-top: 1px solid var(--border);
  padding-block: 1rem 1.5rem;
}
.footer-bottom p { margin: 0; color: var(--text-faint); font-size: .85rem; }

/* ---------- Article pages (privacy / terms / contact) ---------- */
.page-header { padding: 2.25rem 0 .5rem; }
.page-header .updated { color: var(--text-faint); font-size: .88rem; margin: 0; }
.prose { max-width: 72ch; padding-bottom: 2rem; }
.prose h2 { margin-top: 2rem; }
.prose h3 { margin-top: 1.5rem; }
.prose ul { padding-left: 1.2rem; display: grid; gap: .45rem; margin: 0 0 1em; }
.callout {
  border: 1px solid var(--border); border-left: 3px solid var(--accent);
  background: var(--surface); border-radius: var(--radius);
  padding: 1rem 1.15rem; margin: 0 0 1.5rem;
}
.callout p:last-child { margin-bottom: 0; }
.contact-link { font-size: 1.05rem; font-weight: 600; }

/* ---------- Responsive ---------- */
@media (max-width: 520px) {
  body { font-size: 16px; }
  .site-nav { gap: 1rem; font-size: .9rem; }
  /* The whole page is the "how it works" guide; drop the link before it wraps. */
  .site-nav a[href$="#how-to"] { display: none; }
  .brand-text { font-size: .98rem; }
  .file-item { grid-template-columns: 52px minmax(0, 1fr); }
  .thumb { width: 52px; height: 52px; }
  .file-actions { grid-column: 1 / -1; justify-content: stretch; }
  .file-actions .btn { flex: 1; }
  .toolbar .btn { flex: 1 1 100%; }
  .toolbar .btn-ghost { margin-left: 0; }
  .privacy-note { align-items: flex-start; }
}

@media (min-width: 1080px) {
  /* The second column only exists when a rail ad is actually present. While the
     slot is commented out, the article gets the full width and centres itself
     instead of leaving a dead 300px gutter. Uncommenting the ad restores the
     two-column layout with no other change. */
  .content-grid:has(.ad-slot--rail) { grid-template-columns: minmax(0, 1fr) 300px; }
  .content-grid:not(:has(.ad-slot--rail)) .content-main { margin-inline: auto; }
  .ad-slot--rail {
    display: block;
    position: sticky; top: 1.5rem;
    margin-block: 0; padding-top: 1.4rem;
  }
}

/* Contact page: the address stays in [at]/[dot] form on screen, so this hint
   explains that the link is still clickable. */
.contact-hint { font-size: .85rem; color: var(--text-faint); white-space: nowrap; }

/* ---------- Contact form ---------- */
.contact-form {
  display: grid; gap: 1.1rem;
  max-width: 34rem; margin: 0 0 1.25rem;
  padding: 1.25rem;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface);
}
.field { display: grid; gap: .35rem; }
.field label { font-weight: 600; font-size: .93rem; }
.field input,
.field textarea {
  font: inherit; font-size: .96rem; color: var(--text);
  width: 100%; padding: .65rem .8rem;
  border: 1px solid var(--border-strong); border-radius: 9px;
  background: var(--bg);
  transition: border-color .15s ease;
}
.field textarea { resize: vertical; min-height: 8rem; line-height: 1.55; }
.field input:focus, .field textarea:focus { border-color: var(--accent); }
.field input::placeholder, .field textarea::placeholder { color: var(--text-faint); }
.field-hint { font-size: .82rem; color: var(--text-faint); }
.contact-form .btn { justify-self: start; }

.form-status { margin: 0; font-size: .92rem; color: var(--text-muted); }
.form-status:empty { display: none; }
.form-status.is-done { color: var(--success); font-weight: 550; }
.form-status.is-error { color: var(--danger); font-weight: 550; }
.form-note { font-size: .87rem; color: var(--text-muted); max-width: 34rem; }
