/* GIF to JPG Converter — styles. Blue accent, animated UI, responsive, accessible. */
:root {
  --accent: #1d4ed8;
  --accent-dark: #1e40af;
  --accent-soft: #eff6ff;
  --ink: #1e3a8a;
  --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(29, 78, 216, .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 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 on the AVIF template). 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(--accent); color: #fff; padding: 8px 14px; border-radius: 0 0 8px 0; z-index: 10; }
.skip-link:focus { left: 0; }
a { color: var(--accent); }
:focus-visible { outline: 3px solid #3b82f6; 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(--accent), var(--accent-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 #93c5fd;
  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; } }

/* tool */
.tool { margin-top: 24px; }
.dropzone {
  border: 2px dashed #93c5fd; 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(--accent); box-shadow: var(--shadow); }
.dropzone.dragover {
  border-color: var(--accent); border-style: solid; background: var(--accent-soft);
  box-shadow: 0 0 0 4px rgba(29, 78, 216, .15), var(--shadow);
  transform: scale(1.01);
}
.dropzone.disabled { opacity: .55; cursor: not-allowed; }
.dz-icon { color: var(--accent); 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(--accent); 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(--accent); color: #fff; }
.seg-opt input:focus-visible + span { outline: 3px solid #3b82f6; outline-offset: -3px; }
#resize-width {
  width: 110px; padding: 8px 10px; font: inherit; font-weight: 600;
  border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--body);
}
#resize-width:disabled { background: #f3f4f6; color: var(--muted); cursor: not-allowed; }
#resize-on { accent-color: var(--accent); width: 18px; height: 18px; vertical-align: -3px; }

/* 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, #60a5fa, var(--accent)); 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; }
.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(--accent); color: #fff; box-shadow: 0 4px 14px rgba(29, 78, 216, .35); }
.btn-primary:hover:not(:disabled) { background: var(--accent-dark); }
.btn-ghost { background: #fff; color: var(--body); border: 1px solid var(--line); }
.btn-small { padding: 8px 14px; font-size: .9rem; background: var(--accent); 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(--accent); font-weight: 700; }
.grew-pill { background: #fef9c3; color: var(--warn-ink); 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: #eff6ff; border: 1px solid #93c5fd; border-radius: var(--radius); padding: 20px 22px; }
.privacy-meter { font-size: 1.05rem; }
.privacy-meter strong { font-size: 1.3rem; color: var(--accent); }
.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(--accent); }
.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; }
  #resize-width { 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 the preview reads clearly
   against any background. */
.fc-body { display: grid; grid-template-columns: minmax(0, 200px) minmax(0, 1fr); 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(29, 78, 216, 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(29, 78, 216, 0.6); outline-offset: 2px; }

@media (max-width: 640px) {
  .nav { display: none; }
  .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; }
}

/* ---------------- per-frame download links (extract-all-frames mode) ---------------- */
.fc-frames { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.fc-frames[hidden] { display: none; }
.frame-link {
  font-size: .82rem; font-weight: 700; color: var(--ink); text-decoration: none;
  background: var(--accent-soft); border: 1px solid #bfdbfe;
  padding: 4px 10px; border-radius: 999px;
}
.frame-link:hover { background: #dbeafe; }
/* card body grid: preview + info column, both shrinkable at 360px */
@media (max-width: 640px) {
  .fc-body { grid-template-columns: minmax(0, 1fr); }
}

/* ---------------- quality slider, background picker, resize ---------------- */
#quality { flex: 1; min-width: 180px; accent-color: var(--accent); }
#quality-val { font-weight: 700; color: var(--accent); min-width: 3ch; display: inline-block; }
#bg-color {
  width: 44px; height: 34px; padding: 2px; border: 1px solid var(--line);
  border-radius: 8px; background: #fff; cursor: pointer;
}
#bg-color:disabled { opacity: .45; cursor: not-allowed; }

/* ---------------- pick-a-frame selector ---------------- */
.fc-picker { margin-top: 12px; }
.fc-picker[hidden] { display: none; }
.fc-picker-title { font-weight: 700; color: var(--ink); margin: 0 0 10px; }
.fc-picker-anim {
  display: block; max-width: 100%; max-height: 180px; object-fit: contain;
  border: 1px solid var(--line); border-radius: 10px; margin-bottom: 12px;
  background: var(--accent-soft);
}
.frame-strip {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(0, 120px));
  gap: 8px; margin-bottom: 12px;
}
.frame-thumb {
  min-width: 0; padding: 6px; border: 2px solid var(--line); border-radius: 10px;
  background: #fff; cursor: pointer; font: inherit; text-align: center;
}
.frame-thumb img { width: 100%; height: auto; display: block; border-radius: 6px; }
.frame-thumb span { display: block; font-size: .8rem; font-weight: 700; color: var(--ink); margin-top: 4px; }
.frame-thumb:hover { border-color: var(--accent); }
.frame-thumb.is-selected { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 3px rgba(29, 78, 216, .15); }
.frame-thumb:focus-visible { outline: 3px solid #3b82f6; outline-offset: 2px; }
