/* ==========================================================================
   JPG to PDF Converter — Main Stylesheet
   Plain CSS, no build step. Mobile-first, responsive, dark-mode aware.
   ========================================================================== */

/* ---------- Design tokens ---------- */
:root {
  --color-bg: #f6f8fb;
  --color-surface: #ffffff;
  --color-surface-alt: #eef2f7;
  --color-border: #d9e0ea;
  --color-text: #1b2430;
  --color-text-muted: #5b6878;
  --color-primary: #1f5eff;
  --color-primary-hover: #174ad1;
  --color-primary-soft: #e7eeff;
  --color-success: #178a4c;
  --color-success-soft: #e3f5ea;
  --color-danger: #c62839;
  --color-danger-soft: #fdeaec;
  --color-warning: #9a6400;
  --color-warning-soft: #fff4d6;
  --color-focus: #ffb020;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.1);
  --shadow-md: 0 4px 12px rgba(16, 24, 40, 0.08), 0 2px 4px rgba(16, 24, 40, 0.06);
  --shadow-lg: 0 20px 40px rgba(16, 24, 40, 0.12);
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --container: 1120px;
  --header-h: 64px;
}

[data-theme="dark"] {
  --color-bg: #0f141b;
  --color-surface: #171e27;
  --color-surface-alt: #1f2833;
  --color-border: #2c3744;
  --color-text: #e8edf3;
  --color-text-muted: #9aa8b8;
  --color-primary: #5b8cff;
  --color-primary-hover: #7da3ff;
  --color-primary-soft: #1c2a47;
  --color-success: #3ccf7a;
  --color-success-soft: #14301f;
  --color-danger: #ff6b7a;
  --color-danger-soft: #3a1a1f;
  --color-warning: #ffc857;
  --color-warning-soft: #3a2f12;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.55);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --color-bg: #0f141b;
    --color-surface: #171e27;
    --color-surface-alt: #1f2833;
    --color-border: #2c3744;
    --color-text: #e8edf3;
    --color-text-muted: #9aa8b8;
    --color-primary: #5b8cff;
    --color-primary-hover: #7da3ff;
    --color-primary-soft: #1c2a47;
    --color-success: #3ccf7a;
    --color-success-soft: #14301f;
    --color-danger: #ff6b7a;
    --color-danger-soft: #3a1a1f;
    --color-warning: #ffc857;
    --color-warning-soft: #3a2f12;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.55);
  }
}

/* ---------- Reset & base ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--color-text);
  background: var(--color-bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

img,
canvas {
  max-width: 100%;
  display: block;
}

h1,
h2,
h3,
h4 {
  line-height: 1.2;
  margin: 0 0 0.6em;
  font-weight: 700;
  letter-spacing: -0.01em;
}

h1 {
  font-size: clamp(1.9rem, 4.5vw, 2.8rem);
}

h2 {
  font-size: clamp(1.4rem, 3vw, 1.9rem);
}

h3 {
  font-size: 1.15rem;
}

p {
  margin: 0 0 1em;
}

a {
  color: var(--color-primary);
  text-decoration: underline;
  text-underline-offset: 2px;
}

a:hover {
  color: var(--color-primary-hover);
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

/* Visible focus for keyboard users */
:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: -100px;
  left: 12px;
  background: var(--color-primary);
  color: #fff;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  z-index: 1000;
  text-decoration: none;
  font-weight: 600;
}

.skip-link:focus {
  top: 12px;
}

.container {
  width: min(100% - 2rem, var(--container));
  margin-inline: auto;
}

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: color-mix(in srgb, var(--color-surface) 92%, transparent);
  backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--color-border);
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: var(--header-h);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 800;
  font-size: 1.15rem;
  text-decoration: none;
  color: var(--color-text);
}

.brand-logo {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--color-primary), #7b3fe4);
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.site-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: 0.25rem;
}

.site-nav a {
  display: inline-block;
  padding: 0.5rem 0.8rem;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--color-text-muted);
  font-weight: 500;
}

.site-nav a:hover,
.site-nav a[aria-current="page"] {
  color: var(--color-text);
  background: var(--color-surface-alt);
}

.nav-toggle {
  display: none;
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.6rem;
  cursor: pointer;
}

.theme-toggle {
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  cursor: pointer;
  color: var(--color-text);
  flex-shrink: 0;
}

.theme-toggle:hover {
  background: var(--color-surface-alt);
}

.theme-toggle .icon-sun {
  display: none;
}

[data-theme="dark"] .theme-toggle .icon-sun {
  display: block;
}

[data-theme="dark"] .theme-toggle .icon-moon {
  display: none;
}

@media (max-width: 720px) {
  .nav-toggle {
    display: inline-flex;
  }
  .site-nav ul {
    display: none;
    position: absolute;
    top: var(--header-h);
    left: 0;
    right: 0;
    flex-direction: column;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding: 0.5rem 1rem 1rem;
    box-shadow: var(--shadow-md);
  }
  .site-nav ul.is-open {
    display: flex;
  }
  .site-nav a {
    display: block;
    padding: 0.75rem;
  }
}

/* ---------- Layout ---------- */
main {
  flex: 1;
}

.section {
  padding: 3rem 0;
}

.section-tight {
  padding: 2rem 0;
}

.section-title {
  text-align: center;
  margin-bottom: 0.4rem;
}

.section-lead {
  text-align: center;
  color: var(--color-text-muted);
  max-width: 640px;
  margin: 0 auto 2rem;
}

/* ---------- Hero ---------- */
.hero {
  padding: 3rem 0 1.5rem;
  text-align: center;
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

.hero > .container {
  position: relative;
  z-index: 1;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--color-success-soft);
  color: var(--color-success);
  font-weight: 600;
  font-size: 0.85rem;
  padding: 0.3rem 0.8rem;
  border-radius: 999px;
  margin-bottom: 1rem;
}

.hero p.lead {
  color: var(--color-text-muted);
  font-size: 1.1rem;
  max-width: 640px;
  margin: 0 auto 1.5rem;
}

/* ==========================================================================
   HERO VISUAL LAYER — floating 3D-style utility objects (additive, scoped)
   Decorative only: CSS transforms/keyframes + inline SVG, zero dependencies.
   Placement guarantees no overlap with hero copy at every breakpoint.
   ========================================================================== */

/* ---------- Layer + tokens ---------- */
.hero-visual-layer {
  --hero-anim-speed: 1;
  --hero-float-y: 16px;
  --hero-tilt: 2deg;
  --hero-shift-x: 8px;
  --hero-shadow: drop-shadow(0 12px 22px rgba(16, 24, 40, 0.13));
  --hero-shadow-hi: drop-shadow(0 18px 32px rgba(16, 24, 40, 0.17));
  --hero-glow: radial-gradient(60% 60% at 50% 40%, rgba(31, 94, 255, 0.15), rgba(31, 94, 255, 0) 70%);
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  overflow: visible;
  contain: layout style;
}

[data-theme="dark"] .hero-visual-layer {
  --hero-shadow: drop-shadow(0 12px 24px rgba(0, 0, 0, 0.5));
  --hero-shadow-hi: drop-shadow(0 18px 34px rgba(0, 0, 0, 0.55));
  --hero-glow: radial-gradient(60% 60% at 50% 40%, rgba(91, 140, 255, 0.18), rgba(91, 140, 255, 0) 70%);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .hero-visual-layer {
    --hero-shadow: drop-shadow(0 12px 24px rgba(0, 0, 0, 0.5));
    --hero-shadow-hi: drop-shadow(0 18px 34px rgba(0, 0, 0, 0.55));
    --hero-glow: radial-gradient(60% 60% at 50% 40%, rgba(91, 140, 255, 0.18), rgba(91, 140, 255, 0) 70%);
  }
}

/* ---------- Soft ambient glow (no hard edges, no neon) ---------- */
.hero-glow {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(880px, 88%);
  aspect-ratio: 2 / 1;
  background: var(--hero-glow);
  filter: blur(6px);
}

/* ---------- Floating object base ---------- */
.hero-float {
  position: absolute;
  display: block;
  width: var(--hero-size, 78px);
  filter: var(--hero-shadow);
  transform-style: preserve-3d;
  will-change: transform;
  animation-name: hero-float-drift;
  animation-duration: calc(var(--hero-dur, 12s) * var(--hero-anim-speed));
  animation-delay: var(--hero-delay, 0s);
  animation-timing-function: ease-in-out;
  animation-iteration-count: infinite;
  animation-direction: alternate;
}

.hero-float svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.hero-float svg text {
  font-family: var(--font-sans);
  font-weight: 700;
}

/* Shared SVG paint helpers — driven by the existing theme tokens */
.s-surface { fill: var(--color-surface); }
.s-alt { fill: var(--color-surface-alt); }
.s-border { stroke: var(--color-border); }
.s-muted { fill: var(--color-text-muted); }
.s-primary { fill: var(--color-primary); }
.s-primary-soft { fill: var(--color-primary-soft); }
.s-primary-stroke { stroke: var(--color-primary); }
.s-danger { fill: var(--color-danger); }

/* ---------- Wide desktop composition: side gutters only ---------- */
.hero-float-pdf {
  --hero-size: 84px;
  --hero-dur: 11.5s;
  --hero-delay: -2.5s;
  right: 1.2%;
  bottom: 8%;
  z-index: 3;
}

.hero-float-image {
  --hero-size: 88px;
  --hero-dur: 13.5s;
  --hero-delay: -6s;
  --hero-tilt: 4deg;
  right: 2.4%;
  top: 6%;
  z-index: 2;
}

.hero-float-convert {
  --hero-size: 56px;
  --hero-dur: 22s;
  --hero-delay: -9s;
  right: 0.6%;
  top: 38%;
  z-index: 3;
  animation-name: hero-float-spin;
}

.hero-float-shield {
  --hero-size: 56px;
  --hero-dur: 9s;
  --hero-delay: -4s;
  left: 1.4%;
  top: 7%;
  z-index: 3;
  animation-name: hero-float-pulse;
}

.hero-float-document {
  --hero-size: 76px;
  --hero-dur: 12.5s;
  --hero-delay: -7.5s;
  --hero-tilt: 3.5deg;
  left: 2.2%;
  bottom: 7%;
  z-index: 2;
}

.hero-float-utility.is-qr {
  --hero-size: 42px;
  --hero-dur: 16.5s;
  --hero-delay: -11s;
  left: 0.9%;
  top: 42%;
  z-index: 1;
}

.hero-float-utility.is-code {
  --hero-size: 40px;
  --hero-dur: 14s;
  --hero-delay: -3.5s;
  --hero-shift-x: 10px;
  left: 6%;
  bottom: 26%;
  z-index: 1;
}

/* ---------- Motion ---------- */
@keyframes hero-float-drift {
  from {
    transform: translate3d(0, 0, 0) rotate(calc(var(--hero-tilt) * -1)) scale(1);
  }
  to {
    transform: translate3d(var(--hero-shift-x), calc(var(--hero-float-y) * -1), 0) rotate(var(--hero-tilt)) scale(1.03);
  }
}

@keyframes hero-float-pulse {
  0% {
    transform: translate3d(0, 0, 0) scale(1);
    opacity: 1;
    filter: var(--hero-shadow);
  }
  45% {
    transform: translate3d(0, -10px, 0) scale(1.035);
    opacity: 0.94;
    filter: var(--hero-shadow-hi);
  }
  100% {
    transform: translate3d(0, -2px, 0) scale(1.01);
    opacity: 1;
    filter: var(--hero-shadow);
  }
}

@keyframes hero-float-spin {
  from {
    transform: rotate(-8deg) translate3d(0, 3px, 0) scale(1);
  }
  to {
    transform: rotate(352deg) translate3d(0, -3px, 0) scale(1.02);
  }
}

/* ---------- Responsive: shrink, then keep only what fits safely ---------- */
/* Up to 1280px the headline can fill the container, so the composition
   retreats to the four empty corners (text is centred and narrower). */
@media (max-width: 1280px) {
  .hero-visual-layer {
    --hero-anim-speed: 1.06;
  }
  .hero-float-utility,
  .hero-float-convert {
    display: none;
  }
  .hero-float-shield { left: 1.5%; top: 3%; --hero-size: 52px; }
  .hero-float-image { right: 1.5%; top: 3%; --hero-size: 60px; }
  .hero-float-document { left: 1.5%; bottom: 5%; --hero-size: 62px; }
  .hero-float-pdf { right: 1.5%; bottom: 5%; --hero-size: 64px; }
}

@media (max-width: 992px) {
  .hero-float-shield { left: 1.2%; top: 3%; --hero-size: 44px; }
  .hero-float-image { right: 1.2%; top: 3%; --hero-size: 48px; }
  .hero-float-document { left: 1.2%; bottom: 6%; --hero-size: 50px; }
  .hero-float-pdf { right: 1.2%; bottom: 6%; --hero-size: 52px; }
}

/* Mobile: only two primary objects, tucked into the empty top corners */
@media (max-width: 768px) {
  .hero-visual-layer {
    --hero-float-y: 6px;
    --hero-tilt: 2deg;
    --hero-shift-x: 3px;
  }
  .hero-float-document,
  .hero-float-shield {
    display: none;
  }
  /* Tucked into the empty strip above the badge (hero text starts ~48px) */
  .hero-float-pdf { left: 2%; right: auto; top: 2px; bottom: auto; --hero-size: 32px; }
  .hero-float-image { right: 2%; top: 4px; --hero-size: 34px; }
  .hero-glow { width: 94%; }
}

@media (max-width: 480px) {
  .hero-float-pdf { --hero-size: 28px; top: 2px; }
  .hero-float-image { --hero-size: 30px; top: 4px; }
}

/* ---------- Reduced motion: static, no floating, still visible ---------- */
@media (prefers-reduced-motion: reduce) {
  .hero-float,
  .hero-float-pdf,
  .hero-float-image,
  .hero-float-document,
  .hero-float-shield,
  .hero-float-convert,
  .hero-float-utility {
    animation: none !important;
    transform: none;
    will-change: auto;
  }
  .hero-float-pdf { transform: rotate(-3deg); }
  .hero-float-image { transform: rotate(3deg); }
  .hero-float-document { transform: rotate(-3.5deg); }
  .hero-float-utility.is-code { transform: rotate(4deg); }
  .hero-glow { opacity: 0.85; }
}

/* ---------- Converter card ---------- */
.converter {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: clamp(1rem, 3vw, 2rem);
  margin-bottom: 2rem;
}

/* Drop zone */
.dropzone {
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface-alt);
  padding: clamp(1.5rem, 5vw, 3rem) 1rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
  position: relative;
}

.dropzone:hover {
  border-color: var(--color-primary);
}

.dropzone.is-dragover {
  border-color: var(--color-primary);
  background: var(--color-primary-soft);
  transform: scale(1.005);
}

.dropzone-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 0.75rem;
  color: var(--color-primary);
}

.dropzone h2 {
  font-size: 1.25rem;
  margin-bottom: 0.25rem;
}

.dropzone p {
  color: var(--color-text-muted);
  margin-bottom: 1rem;
}

.dropzone small {
  display: block;
  color: var(--color-text-muted);
  margin-top: 0.75rem;
  font-size: 0.85rem;
}

.dropzone input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  overflow: hidden;
}

/* Clipboard-paste discoverability hint inside the drop zone */
.dropzone-tip {
  margin: 0.6rem 0 0 !important;
  font-size: 0.82rem;
  color: var(--color-text-muted);
}

.dropzone.is-compact .dropzone-tip {
  display: none;
}

kbd {
  font-family: var(--font-sans);
  font-size: 0.78em;
  font-weight: 600;
  padding: 0.05em 0.4em;
  border: 1px solid var(--color-border);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--color-surface);
  color: var(--color-text);
}

/* First-visit attention pulse on the drop zone (disabled if reduced motion) */
.dropzone.is-pulsing {
  animation: dropzonePulse 1.8s ease-in-out 3;
}

@keyframes dropzonePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(31, 94, 255, 0); border-color: var(--color-border); }
  50% { box-shadow: 0 0 0 6px rgba(31, 94, 255, 0.15); border-color: var(--color-primary); }
}

/* Privacy micro-copy directly under the drop zone */
.privacy-note {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin: 0.75rem 0 0;
  font-size: 0.88rem;
  color: var(--color-text-muted);
}

.privacy-note svg {
  flex-shrink: 0;
  margin-top: 0.2em;
  color: var(--color-success);
}

.privacy-note a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.privacy-note a:hover {
  color: var(--color-primary);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.7rem 1.3rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.05s;
  min-height: 44px;
  line-height: 1.2;
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: var(--color-primary);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--color-primary-hover);
  color: #fff;
}

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border-color: var(--color-border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--color-surface-alt);
}

.btn-danger {
  background: transparent;
  color: var(--color-danger);
  border-color: var(--color-border);
}

.btn-danger:hover:not(:disabled) {
  background: var(--color-danger-soft);
}

.btn-lg {
  padding: 0.9rem 1.8rem;
  font-size: 1.05rem;
}

.btn-block {
  width: 100%;
}

.btn svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* Workspace (visible once images are added) */
.workspace {
  margin-top: 1.5rem;
}

.workspace[hidden] {
  display: none;
}

.workspace-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.workspace-toolbar .toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.file-count {
  font-weight: 600;
}

.file-count span {
  color: var(--color-text-muted);
  font-weight: 400;
}

/* Thumbnail grid */
.thumb-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 1rem;
}

.thumb {
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  position: relative;
  cursor: grab;
  transition: box-shadow 0.15s, transform 0.15s, opacity 0.15s;
}

.thumb:hover {
  box-shadow: var(--shadow-sm);
}

.thumb.is-dragging {
  opacity: 0.45;
}

.thumb.is-dropTarget {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.thumb-index {
  position: absolute;
  top: 0.9rem;
  left: 0.9rem;
  z-index: 2;
  background: var(--color-primary);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  box-shadow: var(--shadow-sm);
}

.thumb-img-wrap {
  aspect-ratio: 1 / 1;
  width: 100%;
  border-radius: var(--radius-sm);
  background: repeating-conic-gradient(var(--color-border) 0 25%, transparent 0 50%) 0 0 / 16px 16px;
  overflow: hidden;
  display: grid;
  place-items: center;
}

.thumb-img-wrap img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transition: transform 0.2s;
}

.thumb-name {
  font-size: 0.78rem;
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0;
}

.thumb-meta {
  font-size: 0.72rem;
  color: var(--color-text-muted);
  margin: 0;
}

.thumb-actions {
  display: flex;
  justify-content: space-between;
  gap: 0.25rem;
}

.icon-btn {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  cursor: pointer;
  color: var(--color-text);
  transition: background 0.15s, color 0.15s;
  padding: 0;
}

.icon-btn svg {
  width: 16px;
  height: 16px;
}

.icon-btn:hover:not(:disabled) {
  background: var(--color-primary-soft);
  color: var(--color-primary);
}

.icon-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.icon-btn.remove:hover:not(:disabled) {
  background: var(--color-danger-soft);
  color: var(--color-danger);
}

/* Options panel */
.options {
  margin-top: 1.5rem;
  border-top: 1px solid var(--color-border);
  padding-top: 1.5rem;
}

.options-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem 1.25rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.field label,
.field legend {
  font-weight: 600;
  font-size: 0.9rem;
}

.field select,
.field input[type="text"],
.field input[type="number"] {
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  min-height: 44px;
  width: 100%;
}

.field .hint {
  font-size: 0.78rem;
  color: var(--color-text-muted);
}

.field input[type="range"] {
  width: 100%;
  accent-color: var(--color-primary);
  min-height: 44px;
}

.range-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.range-row output {
  font-variant-numeric: tabular-nums;
  min-width: 3.5ch;
  text-align: right;
  font-weight: 600;
}

fieldset.field {
  border: 0;
  padding: 0;
  margin: 0;
  min-width: 0;
}

.radio-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.radio-group label {
  font-weight: 500;
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.8rem;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  cursor: pointer;
  background: var(--color-surface);
  min-height: 40px;
}

.radio-group input {
  accent-color: var(--color-primary);
  margin: 0;
}

.radio-group label:has(input:checked) {
  border-color: var(--color-primary);
  background: var(--color-primary-soft);
  color: var(--color-primary);
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 500;
  cursor: pointer;
  min-height: 44px;
}

.check input {
  width: 20px;
  height: 20px;
  accent-color: var(--color-primary);
  margin: 0;
}

/* Convert bar */
.convert-bar {
  margin-top: 1.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
}

.convert-bar .summary {
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

/* Progress */
.progress {
  margin-top: 1rem;
}

.progress[hidden] {
  display: none;
}

.progress-track {
  width: 100%;
  height: 10px;
  background: var(--color-surface-alt);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--color-border);
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--color-primary), #7b3fe4);
  transition: width 0.2s;
}

.progress-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-top: 0.4rem;
}

/* Percentage stays pinned right; the Cancel button sits after it and must stay
   tappable (44px) because it is the only control live during a conversion. */
.progress-label #progress-pct {
  margin-left: auto;
}

#cancel-btn {
  min-height: 44px;
}

/* Result panel */
.result {
  margin-top: 1.5rem;
  background: var(--color-success-soft);
  border: 1px solid color-mix(in srgb, var(--color-success) 40%, transparent);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
}

.result[hidden] {
  display: none;
}

.result h3 {
  margin: 0 0 0.2rem;
  color: var(--color-success);
}

.result p {
  margin: 0;
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* Post-conversion engagement row */
.result-followup {
  flex-basis: 100%;
  border-top: 1px solid color-mix(in srgb, var(--color-success) 30%, transparent);
  padding-top: 0.9rem;
  margin-top: 0.25rem;
}

.result-followup > p {
  margin-bottom: 0.5rem;
  color: var(--color-text);
  font-size: 0.9rem;
}

.result-followup-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.bookmark-hint {
  font-size: 0.82rem;
  color: var(--color-text-muted);
}

.btn-sm {
  padding: 0.45rem 0.9rem;
  font-size: 0.88rem;
  min-height: 36px;
}

.btn-sm svg {
  width: 16px;
  height: 16px;
}

/* Alerts / toasts */
.alerts {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  width: min(100% - 2rem, 520px);
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.alert {
  pointer-events: auto;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-primary);
  border-radius: var(--radius-sm);
  padding: 0.8rem 1rem;
  box-shadow: var(--shadow-lg);
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  font-size: 0.92rem;
  animation: slideUp 0.2s ease-out;
}

.alert-error {
  border-left-color: var(--color-danger);
}

.alert-warning {
  border-left-color: var(--color-warning);
}

.alert-success {
  border-left-color: var(--color-success);
}

.alert p {
  margin: 0;
  flex: 1;
}

.alert button {
  background: transparent;
  border: 0;
  cursor: pointer;
  color: var(--color-text-muted);
  font-size: 1.2rem;
  line-height: 1;
  padding: 0 0.2rem;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Inline notice (e.g. browser unsupported) */
.notice {
  background: var(--color-warning-soft);
  color: var(--color-warning);
  border: 1px solid color-mix(in srgb, var(--color-warning) 40%, transparent);
  border-radius: var(--radius-sm);
  padding: 0.8rem 1rem;
  font-size: 0.92rem;
  margin-bottom: 1rem;
}

.notice[hidden] {
  display: none;
}

/* ---------- Feature cards ---------- */
.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
}

.feature {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 1.5rem;
}

.feature-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--color-primary-soft);
  color: var(--color-primary);
  display: grid;
  place-items: center;
  margin-bottom: 0.9rem;
}

.feature-icon svg {
  width: 22px;
  height: 22px;
}

.feature h3 {
  margin-bottom: 0.35rem;
}

.feature p {
  color: var(--color-text-muted);
  margin: 0;
  font-size: 0.95rem;
}

/* ---------- Steps ---------- */
.steps {
  list-style: none;
  counter-reset: step;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
}

.steps li {
  counter-increment: step;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 1.5rem 1.5rem 1.5rem 4.2rem;
  position: relative;
}

.steps li::before {
  content: counter(step);
  position: absolute;
  left: 1.25rem;
  top: 1.4rem;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-primary), #7b3fe4);
  color: #fff;
  font-weight: 800;
  display: grid;
  place-items: center;
}

.steps h3 {
  margin-bottom: 0.3rem;
}

.steps p {
  margin: 0;
  color: var(--color-text-muted);
  font-size: 0.95rem;
}

/* ---------- FAQ ---------- */
.faq {
  max-width: 800px;
  margin: 0 auto;
}

.faq details {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  margin-bottom: 0.75rem;
  overflow: hidden;
}

.faq summary {
  cursor: pointer;
  padding: 1rem 1.25rem;
  font-weight: 600;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  min-height: 44px;
}

.faq summary::-webkit-details-marker {
  display: none;
}

.faq summary::after {
  content: "+";
  font-size: 1.4rem;
  color: var(--color-text-muted);
  line-height: 1;
  flex-shrink: 0;
}

.faq details[open] summary::after {
  content: "−";
}

.faq details > div {
  padding: 0 1.25rem 1.1rem;
  color: var(--color-text-muted);
}

.faq details > div p:last-child {
  margin-bottom: 0;
}

/* ---------- Content pages ---------- */
.page-content {
  max-width: 760px;
  margin: 0 auto;
  padding: 2.5rem 0 3.5rem;
}

.page-content h1 {
  margin-bottom: 0.4rem;
}

.page-content .updated {
  color: var(--color-text-muted);
  font-size: 0.9rem;
  margin-bottom: 2rem;
}

.page-content h2 {
  margin-top: 2rem;
  font-size: 1.35rem;
}

.page-content ul,
.page-content ol {
  padding-left: 1.4rem;
}

.page-content li {
  margin-bottom: 0.4rem;
}

.callout {
  background: var(--color-primary-soft);
  border-left: 4px solid var(--color-primary);
  padding: 1rem 1.25rem;
  border-radius: var(--radius-sm);
  margin: 1.5rem 0;
}

.callout p:last-child {
  margin-bottom: 0;
}

/* Contact form (client-side only) */
.contact-form {
  display: grid;
  gap: 1rem;
  margin-top: 1.5rem;
}

.contact-form textarea {
  font: inherit;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: inherit;
  min-height: 140px;
  resize: vertical;
  width: 100%;
}

/* 404 */
.error-page {
  text-align: center;
  padding: 5rem 0;
}

.error-page .code {
  font-size: clamp(4rem, 15vw, 7rem);
  font-weight: 800;
  line-height: 1;
  background: linear-gradient(135deg, var(--color-primary), #7b3fe4);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin-bottom: 0.5rem;
}

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--color-border);
  background: var(--color-surface);
  padding: 2rem 0;
  margin-top: 2rem;
  font-size: 0.9rem;
  color: var(--color-text-muted);
}

.site-footer .container {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.site-footer ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
}

.site-footer a {
  color: var(--color-text-muted);
}

.site-footer a:hover {
  color: var(--color-text);
}

/* ---------- Utilities ---------- */
.text-center {
  text-align: center;
}

.mt-1 {
  margin-top: 1rem;
}

.mt-2 {
  margin-top: 2rem;
}

.no-js-msg {
  background: var(--color-danger-soft);
  color: var(--color-danger);
  padding: 1rem;
  text-align: center;
  font-weight: 600;
}

/* ---------- Print ---------- */
@media print {
  .site-header,
  .site-footer,
  .converter,
  .alerts {
    display: none !important;
  }
}

/* ==========================================================================
   Priority improvement cycle — additive styles (no existing rules removed)
   ========================================================================== */

/* ---------- Related tools ---------- */
.related-tools {
  padding: 2.5rem 0 3rem;
  border-top: 1px solid var(--color-border, rgba(148, 163, 184, .25));
}
.related-tools h2 {
  font-size: 1.25rem;
  margin: 0 0 1rem;
}
.related-tools ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: .625rem;
}
.related-tools a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: .5rem 1rem;
  border-radius: 999px;
  border: 1px solid var(--color-border, rgba(148, 163, 184, .35));
  background: var(--color-surface, transparent);
  color: inherit;
  text-decoration: none;
  font-size: .9375rem;
  line-height: 1.4;
}
.related-tools a:hover,
.related-tools a:focus-visible {
  border-color: var(--color-primary, #1f5eff);
  color: var(--color-primary, #1f5eff);
}

/* ---------- 404 page extras ---------- */
.error-page-links {
  margin-top: 2.5rem;
}
.error-page-links h2 {
  font-size: 1.125rem;
  margin: 0 0 .75rem;
}
.error-page-links ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: .5rem;
}
.error-page-links a {
  color: var(--color-primary, #1f5eff);
  text-decoration: none;
}
.error-page-links a:hover,
.error-page-links a:focus-visible {
  text-decoration: underline;
}

/* ---------- Progress component a11y polish ---------- */
.progress[hidden] { display: none; }
.progress-track {
  overflow: hidden;
}
.progress-fill {
  transition: width .2s ease;
}
@media (prefers-reduced-motion: reduce) {
  .progress-fill { transition: none; }
}

/* ---------- Mobile typography (preserve desktop design above 768px) ---------- */
@media (max-width: 768px) {
  html, body {
    overflow-x: hidden;
  }
  body {
    font-size: 16px;
    line-height: 1.6;
  }
  h1 { font-size: clamp(1.625rem, 6vw, 2.25rem); line-height: 1.25; }
  h2 { font-size: clamp(1.3rem, 4.6vw, 1.75rem); line-height: 1.3; }
  h3 { font-size: clamp(1.1rem, 3.6vw, 1.375rem); line-height: 1.35; }
  p, li, label, legend, small, input, select, textarea, button {
    line-height: 1.6;
  }
  input, select, textarea {
    font-size: 16px; /* prevents iOS auto-zoom on focus */
  }
  .btn, .nav-toggle, .theme-toggle, button[type="button"], button[type="submit"] {
    min-height: 44px;
  }
  input[type="text"], input[type="number"], input[type="email"], input[type="url"],
  input[type="password"], select, textarea {
    min-height: 44px;
  }
  img, video, canvas, svg {
    max-width: 100%;
  }
  .related-tools a {
    width: 100%;
    justify-content: flex-start;
    border-radius: 12px;
  }
}
