/* AVIF to JPG Converter — styles. Teal accent, animated UI, responsive, accessible. */
:root {
  --teal: #0f766e;
  --teal-dark: #0b5e57;
  --teal-soft: #ccfbf1;
  --ink: #134e4a;
  --body: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --bg: #f8fafc;
  --card: #ffffff;
  --ok: #15803d;
  --err: #b91c1c;
  --warn-bg: #fef9c3;
  --warn-ink: #854d0e;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(15, 118, 110, .12);
}
* { box-sizing: border-box; }
/* The `hidden` attribute alone loses to any author `display` rule (author
   origin beats the UA stylesheet), so elements this page hides with
   `hidden` — the batch bar, the target-size row, the target-size error and
   each card's Download link — all carry an author display rule and stayed
   visible: the batch bar showed "0 files" on load and stale text after
   Clear all (caught by the 2026-11-09 live-browser E2E). This rule makes
   `hidden` win everywhere on this page. */
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--body); background: var(--bg); line-height: 1.55;
}
.wrap { max-width: 880px; margin: 0 auto; padding: 0 20px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: -9999px; top: 0; background: var(--teal); color: #fff; padding: 8px 14px; border-radius: 0 0 8px 0; z-index: 10; }
.skip-link:focus { left: 0; }
a { color: var(--teal); }
:focus-visible { outline: 3px solid #14b8a6; outline-offset: 2px; border-radius: 4px; }

/* header / hero */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: #fff; border-bottom: 1px solid var(--line);
}
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-top: 12px; padding-bottom: 12px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.1rem; color: var(--ink); text-decoration: none; letter-spacing: -.02em; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--teal), var(--teal-dark));
  box-shadow: var(--shadow);
}
.brand-mark svg { width: 20px; height: 20px; fill: none; stroke: #fff; stroke-width: 2; }
.nav { display: flex; gap: 4px; }
.nav a {
  color: var(--muted); text-decoration: none; font-weight: 600; font-size: .92rem;
  padding: 8px 12px; border-radius: 10px; transition: background .18s, color .18s;
}
.nav a:hover, .nav a:focus-visible { background: #eef2f7; color: var(--ink); outline: none; }
.hero { text-align: center; padding: 40px 0 8px; animation: fadeUp .5s ease both; }
.hero h1 { margin: 0 0 10px; font-size: clamp(1.9rem, 5vw, 2.7rem); line-height: 1.1; color: var(--ink); letter-spacing: -.02em; }
.lede { font-size: 1.12rem; color: var(--body); max-width: 640px; margin: 0 auto 8px; }
.pills { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 14px auto 10px; }
.pill {
  font-size: .82rem; font-weight: 600; color: var(--ink);
  background: #fff; border: 1px solid #99f6e4;
  padding: 5px 11px; border-radius: 999px;
}
.kw-line { color: var(--muted); font-size: .95rem; max-width: 640px; margin: 0 auto; }
/* Anchored sections sit under the sticky header without this. */
.tool, .privacy, .guide, .faq { scroll-margin-top: 72px; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.avif-warning {
  margin: 20px 0 0; padding: 16px 18px; border-radius: var(--radius);
  background: #fef2f2; border: 2px solid #fca5a5; color: var(--err);
  animation: fadeUp .4s ease both;
}

/* tool */
.tool { margin-top: 24px; }
.dropzone {
  border: 2px dashed #99f6e4; border-radius: var(--radius); background: #fff;
  padding: 38px 20px; text-align: center; cursor: pointer;
  transition: border-color .2s, box-shadow .2s, transform .2s;
  animation: fadeUp .5s .08s ease both;
}
.dropzone:hover { border-color: var(--teal); box-shadow: var(--shadow); }
.dropzone.dragover {
  border-color: var(--teal); border-style: solid; background: var(--teal-soft);
  box-shadow: 0 0 0 4px rgba(15, 118, 110, .15), var(--shadow);
  transform: scale(1.01);
}
.dropzone.disabled { opacity: .55; cursor: not-allowed; }
.dz-icon { color: var(--teal); animation: bob 2.4s ease-in-out infinite; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
.dz-title { font-size: 1.25rem; font-weight: 700; color: var(--ink); margin: 10px 0 4px; }
.dz-sub { margin: 0 0 6px; color: var(--body); }
.dz-note { margin: 0; color: var(--muted); font-size: .85rem; }
.linklike { background: none; border: none; padding: 0; color: var(--teal); font: inherit; font-weight: 700; text-decoration: underline; cursor: pointer; }

/* settings */
.settings {
  margin: 18px 0 0; padding: 18px 20px; border: 1px solid var(--line);
  border-radius: var(--radius); background: #fff;
  animation: fadeUp .5s .14s ease both;
}
.settings legend { font-weight: 700; color: var(--ink); padding: 0 8px; }
.setting-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; padding: 8px 0; }
.setting-row + .setting-row { border-top: 1px dashed var(--line); }
.setting-label { font-weight: 600; min-width: 170px; }
.setting-hint { color: var(--muted); font-size: .85rem; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.seg-opt { position: relative; }
.seg-opt input { position: absolute; opacity: 0; }
.seg-opt span {
  display: inline-block; padding: 8px 20px; cursor: pointer; font-weight: 600;
  transition: background .15s, color .15s;
}
.seg-opt input:checked + span { background: var(--teal); color: #fff; }
.seg-opt input:focus-visible + span { outline: 3px solid #14b8a6; outline-offset: -3px; }
input[type="range"] { flex: 1; min-width: 180px; accent-color: var(--teal); }
#quality-val { font-weight: 700; color: var(--teal); min-width: 2ch; display: inline-block; }
.bg-opts { display: flex; flex-wrap: wrap; gap: 8px 14px; }
.bg-opt { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-weight: 600; }
.swatch { width: 18px; height: 18px; border-radius: 50%; border: 2px solid #d1d5db; display: inline-block; }
input[type="color"] { width: 34px; height: 26px; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: #fff; cursor: pointer; }

/* file cards */
.file-list { display: grid; gap: 12px; margin-top: 18px; }
.file-card {
  position: relative; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px 18px; overflow: hidden;
  animation: cardIn .4s ease both;
  transition: border-color .2s, box-shadow .2s;
}
@keyframes cardIn { from { opacity: 0; transform: translateY(12px) scale(.99); } to { opacity: 1; transform: none; } }
.file-card[data-status="done"] { border-color: #86efac; }
.file-card[data-status="error"] { border-color: #fca5a5; background: #fff7f7; }
.fc-top { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.fc-info { min-width: 0; }
.fc-name { display: block; font-weight: 700; color: var(--ink); word-break: break-all; }
.fc-meta { color: var(--muted); font-size: .88rem; }
.fc-status { flex-shrink: 0; font-size: .82rem; font-weight: 700; color: var(--muted); background: #f3f4f6; border-radius: 999px; padding: 4px 10px; }
.file-card[data-status="done"] .fc-status { background: #dcfce7; color: var(--ok); }
.file-card[data-status="error"] .fc-status { background: #fee2e2; color: var(--err); }
.fc-progress { height: 6px; background: #e5e7eb; border-radius: 999px; margin-top: 12px; overflow: hidden; }
.fc-bar { height: 100%; width: 0; background: linear-gradient(90deg, #14b8a6, var(--teal)); border-radius: 999px; transition: width .35s ease; }
.file-card[data-status="done"] .fc-bar { background: var(--ok); }
.fc-detail { display: flex; flex-wrap: wrap; gap: 4px 18px; margin-top: 10px; font-size: .92rem; }
.fc-est { color: var(--muted); }
.fc-result { font-weight: 700; color: var(--ink); }
.fc-result:empty { display: none; }
.fc-warn { margin-top: 10px; padding: 8px 12px; background: var(--warn-bg); color: var(--warn-ink); border-radius: 8px; font-size: .88rem; }
/* Exact-KB target mode: preset chips, custom KB input, per-file result line. */
.seg-opt input:disabled + span { opacity: .45; cursor: not-allowed; }
.target-presets { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.target-opt { position: relative; cursor: pointer; }
.target-opt input { position: absolute; opacity: 0; }
.target-opt span { display: inline-block; padding: 5px 13px; border: 1px solid var(--line); border-radius: 999px; font-size: .9rem; font-weight: 600; background: var(--card); transition: background .15s ease, color .15s ease, border-color .15s ease; }
.target-opt input:checked + span { background: var(--teal); color: #fff; border-color: var(--teal); }
.target-opt input:focus-visible + span { outline: 3px solid #14b8a6; outline-offset: 2px; }
#target-custom { width: 88px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; font: inherit; font-size: .92rem; }
#target-custom:disabled { opacity: .5; cursor: not-allowed; }
.target-invalid { display: block; margin-top: 6px; color: var(--err); font-size: .88rem; font-weight: 600; }
.fc-target { margin-top: 10px; padding: 8px 12px; background: #dcfce7; color: var(--ok); border-radius: 8px; font-size: .88rem; font-weight: 600; }
.fc-target.best-effort { background: #fef3c7; color: #92400e; }
.fc-error { margin-top: 10px; padding: 8px 12px; background: #fee2e2; color: var(--err); border-radius: 8px; font-size: .9rem; }
.fc-actions { margin-top: 12px; }
.check {
  position: absolute; right: 16px; bottom: 14px; width: 26px; height: 26px; color: var(--ok);
  opacity: 0; transform: scale(.5);
}
.file-card[data-status="done"] .check { opacity: 1; transform: scale(1); transition: opacity .3s .1s, transform .3s .1s cubic-bezier(.34, 1.56, .64, 1); }
.file-card[data-status="done"] .check path { stroke-dasharray: 24; stroke-dashoffset: 24; animation: draw .45s .15s ease forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }

/* buttons + batch bar */
.btn {
  display: inline-block; border: none; border-radius: 10px; padding: 11px 20px;
  font: inherit; font-weight: 700; cursor: pointer; text-decoration: none;
  transition: transform .15s, box-shadow .15s, background .15s;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--teal); color: #fff; box-shadow: 0 4px 14px rgba(15, 118, 110, .35); }
.btn-primary:hover:not(:disabled) { background: var(--teal-dark); }
.btn-ghost { background: #fff; color: var(--body); border: 1px solid var(--line); }
.btn-small { padding: 8px 14px; font-size: .9rem; background: var(--teal); color: #fff; }
.batch-bar {
  margin-top: 16px; display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px;
  animation: fadeUp .4s ease both;
  position: sticky; bottom: 12px; box-shadow: var(--shadow);
}
.batch-stats { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; }
.batch-stats .sep { color: var(--muted); }
.batch-stats .arrow { color: var(--teal); font-weight: 700; }
.saved-pill { background: #dcfce7; color: var(--ok); font-weight: 700; font-size: .85rem; border-radius: 999px; padding: 3px 10px; }
.batch-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* privacy / guide / faq */
.privacy, .guide, .faq { margin-top: 44px; }
.privacy h2, .guide h2, .faq h2 { color: var(--ink); font-size: 1.4rem; margin-bottom: 8px; }
.privacy { background: #ecfdf5; border: 1px solid #a7f3d0; border-radius: var(--radius); padding: 20px 22px; }
.privacy-meter { font-size: 1.05rem; }
.privacy-meter strong { font-size: 1.3rem; color: var(--teal); }
.privacy-ok { color: var(--ok); font-weight: 600; }
.privacy-steps { margin: 10px 0 0; padding-left: 22px; }
.privacy-steps li { margin: 4px 0; }
kbd { background: #fff; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 1px 6px; font: .85em ui-monospace, monospace; }
.guide .steps { padding-left: 22px; }
.guide .steps li, .guide ul li { margin: 6px 0; }
.guide code { background: #f3f4f6; border-radius: 4px; padding: 1px 5px; font-size: .9em; }
.faq details { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; margin-bottom: 10px; }
.faq summary { font-weight: 700; color: var(--ink); cursor: pointer; }
.faq summary:hover { color: var(--teal); }
.faq details p { margin: 8px 0 2px; }

.site-footer { margin-top: 56px; border-top: 1px solid var(--line); background: #fff; padding: 18px 0 26px; color: var(--muted); font-size: .85rem; }
.site-footer .wrap { display: flex; flex-wrap: wrap; gap: 4px 16px; align-items: baseline; justify-content: space-between; }
.site-footer p { margin: 0; }
.site-footer .footer-note { color: var(--muted); }

/* responsive */
@media (max-width: 640px) {
  .hero { padding-top: 28px; }
  .dropzone { padding: 28px 14px; }
  .setting-row { flex-direction: column; align-items: flex-start; gap: 6px; }
  .setting-label { min-width: 0; }
  input[type="range"] { width: 100%; }
  .batch-bar { position: static; }
  .fc-top { flex-direction: column; gap: 6px; }
}

/* reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  html { scroll-behavior: auto; }
}

/* ---------------- file-card output preview ----------------
   Checkerboard behind the image so PNG transparency reads as
   transparent, not white. */
.fc-body { display: flex; gap: 16px; align-items: flex-start; margin-top: 12px; }
.fc-info { flex: 1 1 auto; min-width: 0; }
.fc-preview {
  flex: 0 0 200px; width: 200px; height: 180px; margin: 0;
  position: relative; cursor: zoom-in;
  border: 1px solid var(--line); border-radius: 12px; overflow: hidden;
  background-color: #fff;
  background-image:
    linear-gradient(45deg, #e8ebf2 25%, transparent 25%, transparent 75%, #e8ebf2 75%),
    linear-gradient(45deg, #e8ebf2 25%, transparent 25%, transparent 75%, #e8ebf2 75%);
  background-size: 16px 16px; background-position: 0 0, 8px 8px;
  display: flex; flex-direction: column;
}
.fc-preview img { width: 100%; height: 152px; object-fit: contain; display: block; }
.fc-preview:focus-visible { outline: 3px solid rgba(15, 118, 110, 0.45); outline-offset: 2px; }
.fc-preview-hint {
  position: absolute; inset: 0 0 28px 0; display: grid; place-items: center;
  background: rgba(20, 26, 46, 0.55); color: #fff; font-weight: 700; font-size: 0.85rem;
  opacity: 0; transition: opacity 0.18s; pointer-events: none;
}
.fc-preview:hover .fc-preview-hint, .fc-preview:focus-visible .fc-preview-hint { opacity: 1; }
.fc-preview-cap {
  height: 28px; flex: none; display: grid; place-items: center;
  background: rgba(255, 255, 255, 0.92); border-top: 1px solid var(--line);
  font-size: 0.78rem; font-weight: 700; color: var(--muted);
}

/* ---------------- lightbox (click a preview to view full size) ---------------- */
.lightbox { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; }
.lightbox[hidden] { display: none; }
.lightbox-backdrop { position: absolute; inset: 0; background: rgba(10, 12, 24, 0.82); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.lightbox-panel {
  position: relative; margin: 0; max-width: min(92vw, 1100px); max-height: 88vh;
  display: flex; flex-direction: column; align-items: center;
  animation: cardIn 0.25s ease both;
}
.lightbox-panel img {
  max-width: 100%; max-height: calc(88vh - 64px); width: auto; height: auto;
  object-fit: contain; border-radius: 12px; box-shadow: 0 24px 70px rgba(0, 0, 0, 0.5);
  background-color: #111; background-image:
    linear-gradient(45deg, #222 25%, transparent 25%, transparent 75%, #222 75%),
    linear-gradient(45deg, #222 25%, transparent 25%, transparent 75%, #222 75%);
  background-size: 16px 16px; background-position: 0 0, 8px 8px;
}
.lightbox-cap {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px 16px;
  margin-top: 14px; color: #e8e4f7; font-size: 0.9rem; text-align: center;
}
.lightbox-name { font-weight: 800; color: #fff; overflow-wrap: anywhere; }
.lightbox-meta { color: #b9b3d6; }
.lightbox-close {
  position: absolute; top: -14px; right: -14px; width: 38px; height: 38px;
  border-radius: 50%; border: 0; cursor: pointer; z-index: 2;
  background: #fff; color: var(--ink); font-size: 1.4rem; line-height: 1;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}
.lightbox-close:hover { background: #eef2f7; }
.lightbox-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 44px; height: 44px; border-radius: 50%; border: 0; cursor: pointer; z-index: 2;
  background: rgba(255, 255, 255, 0.92); color: var(--ink);
  font-size: 1.7rem; line-height: 1; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}
.lightbox-nav:hover { background: #fff; }
.lightbox-nav[hidden] { display: none; }
.lightbox-prev { left: -8px; }
.lightbox-next { right: -8px; }
.lightbox-close:focus-visible, .lightbox-nav:focus-visible { outline: 3px solid rgba(15, 118, 110, 0.6); outline-offset: 2px; }

@media (max-width: 640px) {
  .nav { display: none; }
  .fc-body { flex-direction: column; }
  .fc-preview { flex: none; width: 100%; height: 200px; }
  .fc-preview img { height: 172px; }
  .lightbox { padding: 12px; }
  .lightbox-prev { left: 2px; }
  .lightbox-next { right: 2px; }
  .lightbox-close { top: -10px; right: 0; }
  .site-footer .wrap { flex-direction: column; gap: 2px; }
}
