/* ═══════════════════════════════════════════════════════════════
   PDFBolt — Design System
   Colour tokens are injected as CSS custom properties by layout.php
   from inc/config.php, so PHP and CSS can never drift apart.
   ═══════════════════════════════════════════════════════════════ */

/* ── Reset ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
img, svg, video, canvas { display: block; max-width: 100%; }
input, button, textarea, select { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; padding: 0; }

/* ── Tokens ────────────────────────────────────────────────────── */
:root {
  --font-sans: 'Inter Tight', ui-sans-serif, system-ui, -apple-system,
               'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: ui-monospace, 'SF Mono', SFMono-Regular, Menlo, monospace;

  --r-sm: 8px;  --r-md: 12px;  --r-lg: 16px;  --r-xl: 22px;  --r-full: 999px;

  --sh-xs: 0 1px 2px rgba(20,20,28,.06);
  --sh-sm: 0 2px 6px rgba(20,20,28,.07), 0 1px 2px rgba(20,20,28,.04);
  --sh-md: 0 6px 20px rgba(20,20,28,.09), 0 2px 6px rgba(20,20,28,.05);
  --sh-lg: 0 18px 48px rgba(20,20,28,.14), 0 4px 12px rgba(20,20,28,.06);
  --sh-brand: 0 6px 20px rgba(255,77,46,.28);

  --wrap: 1200px;
  --wrap-narrow: 760px;
  --hdr-h: 68px;

  --ease: cubic-bezier(.4, 0, .2, 1);
  --ease-out: cubic-bezier(.16, 1, .3, 1);
}

/* ── Base ──────────────────────────────────────────────────────── */
body {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--c-ink);
  background: #fff;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: 'cv05' 1, 'ss01' 1;
}

h1, h2, h3, h4 { line-height: 1.15; letter-spacing: -.022em; font-weight: 700; }
h1 { font-size: clamp(2rem, 1.3rem + 2.6vw, 3.1rem); letter-spacing: -.032em; }
h2 { font-size: clamp(1.55rem, 1.1rem + 1.5vw, 2.2rem); letter-spacing: -.026em; }
h3 { font-size: 1.2rem; }
p  { text-wrap: pretty; }
:focus-visible { outline: 2px solid var(--c-brand); outline-offset: 3px; border-radius: 4px; }

.wrap { width: 100%; max-width: var(--wrap); margin-inline: auto; padding-inline: 20px; }
.wrap-narrow { max-width: var(--wrap-narrow); }
@media (min-width: 640px) { .wrap { padding-inline: 32px; } }

.muted { color: var(--c-muted); }
.center { text-align: center; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ── Buttons ───────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  padding: 12px 22px; border-radius: var(--r-full);
  font-weight: 600; font-size: .95rem; letter-spacing: -.01em;
  transition: transform .16s var(--ease), box-shadow .16s var(--ease),
              background-color .16s var(--ease), border-color .16s var(--ease);
  white-space: nowrap; border: 1.5px solid transparent;
}
.btn:active { transform: translateY(1px); }
.btn svg { flex: none; }

.btn-primary { background: var(--c-brand); color: #fff; box-shadow: var(--sh-brand); }
.btn-primary:hover { background: var(--c-brand-dark); box-shadow: 0 8px 26px rgba(255,77,46,.36); }

.btn-ghost { border-color: var(--c-line); background: #fff; color: var(--c-ink); }
.btn-ghost:hover { border-color: var(--c-ink); background: var(--c-surface); }

.btn-soft { background: var(--c-surface-2); color: var(--c-ink-2); }
.btn-soft:hover { background: var(--c-line); }

.btn-lg { padding: 15px 32px; font-size: 1.05rem; }
.btn-block { width: 100%; }
.btn[disabled], .btn[aria-disabled='true'] { opacity: .45; pointer-events: none; }

/* ── Header ────────────────────────────────────────────────────── */
.hdr {
  position: sticky; top: 0; z-index: 60;
  height: var(--hdr-h); display: flex; align-items: center;
  background: rgba(255,255,255,.86);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--c-line);
}
.hdr-in { display: flex; align-items: center; gap: 10px; width: 100%; }

.logo { display: flex; align-items: center; gap: 9px; font-weight: 800; font-size: 1.2rem; letter-spacing: -.03em; }
.logo-mark {
  width: 30px; height: 30px; border-radius: 9px; flex: none;
  display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, var(--c-brand), var(--c-brand-dark));
  box-shadow: var(--sh-brand);
}
.logo-mark svg { width: 17px; height: 17px; }

.nav { display: none; margin-left: 14px; gap: 2px; }
@media (min-width: 1024px) { .nav { display: flex; } }
.nav-item { position: relative; }
.nav-btn {
  display: flex; align-items: center; gap: 4px; white-space: nowrap;
  padding: 9px 11px; border-radius: var(--r-sm);
  font-weight: 550; font-size: .9rem; color: var(--c-ink-2);
  transition: background-color .14s var(--ease), color .14s var(--ease);
}
/* The "Browse N tools" button only has room on wide screens. */
.hide-sm { display: none; }
@media (min-width: 1280px) { .hide-sm { display: inline-flex; } }
.nav-btn:hover, .nav-item[data-open='true'] .nav-btn { background: var(--c-surface); color: var(--c-ink); }
.nav-btn .chev { transition: transform .2s var(--ease); }
.nav-item[data-open='true'] .chev { transform: rotate(180deg); }

.hdr-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

/* Mega menu */
.mega {
  position: absolute; top: calc(100% + 10px); left: 50%; translate: -50% 0;
  width: min(92vw, 720px); padding: 18px;
  background: #fff; border: 1px solid var(--c-line);
  border-radius: var(--r-lg); box-shadow: var(--sh-lg);
  opacity: 0; visibility: hidden; transform: translateY(-6px);
  transition: opacity .18s var(--ease), transform .18s var(--ease), visibility .18s;
}
.nav-item[data-open='true'] .mega { opacity: 1; visibility: visible; transform: translateY(0); }
.mega-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 3px; }
@media (min-width: 640px) { .mega-grid { grid-template-columns: repeat(3, 1fr); } }
.mega-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--r-sm);
  font-size: .89rem; font-weight: 500; color: var(--c-ink-2);
  transition: background-color .13s var(--ease);
}
.mega-link:hover { background: var(--c-surface); color: var(--c-ink); }
.mega-link .ic { width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center; flex: none; }
.mega-link .ic svg { width: 15px; height: 15px; }

/* Mobile nav */
.burger { display: grid; place-items: center; width: 40px; height: 40px; border-radius: var(--r-sm); }
.burger:hover { background: var(--c-surface); }
@media (min-width: 1024px) { .burger { display: none; } }

.drawer {
  position: fixed; inset: var(--hdr-h) 0 0; z-index: 55;
  background: #fff; overflow-y: auto; padding: 20px;
  transform: translateX(100%); transition: transform .26s var(--ease-out);
  overscroll-behavior: contain;
}
.drawer[data-open='true'] { transform: translateX(0); }
.drawer-cat { font-size: .74rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .09em; color: var(--c-muted); margin: 22px 0 8px; }

/* ── Hero ──────────────────────────────────────────────────────── */
.hero { padding: clamp(46px, 7vw, 84px) 0 clamp(30px, 4vw, 46px); text-align: center; }
.hero h1 { max-width: 20ch; margin-inline: auto; }
.hero h1 .accent { color: var(--c-brand); }
.hero-sub {
  max-width: 60ch; margin: 18px auto 0;
  font-size: clamp(1rem, .95rem + .3vw, 1.18rem); color: var(--c-muted);
}
.hero-badges { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 26px; }
.badge {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 15px; border-radius: var(--r-full);
  background: var(--c-surface); border: 1px solid var(--c-line);
  font-size: .83rem; font-weight: 550; color: var(--c-ink-2);
}
.badge svg { width: 15px; height: 15px; color: var(--a-green); }

/* ── Tool grid ─────────────────────────────────────────────────── */
.section { padding: clamp(34px, 5vw, 58px) 0; }
.section-head { margin-bottom: 26px; }
.section-head h2 { margin-bottom: 7px; }
.section-head p { color: var(--c-muted); }

/* Explicit column counts beat auto-fill here — auto-fill leaves awkward
   3-across-then-1 rows on tablets. These breakpoints are predictable. */
.tool-grid { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 560px)  { .tool-grid { grid-template-columns: repeat(2, 1fr); gap: 14px; } }
@media (min-width: 900px)  { .tool-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1200px) { .tool-grid { grid-template-columns: repeat(4, 1fr); } }

.tool-card {
  position: relative; display: block; padding: 18px;
  background: #fff; border: 1px solid var(--c-line); border-radius: var(--r-lg);
  transition: transform .2s var(--ease-out), box-shadow .2s var(--ease-out),
              border-color .2s var(--ease);
  overflow: hidden;
}
.tool-card::after {
  content: ''; position: absolute; inset: 0 0 auto 0; height: 3px;
  background: var(--tool-accent, var(--c-brand));
  transform: scaleX(0); transform-origin: left;
  transition: transform .28s var(--ease-out);
}
.tool-card:hover { transform: translateY(-3px); box-shadow: var(--sh-md); border-color: transparent; }
.tool-card:hover::after { transform: scaleX(1); }

.tool-ic {
  width: 44px; height: 44px; border-radius: var(--r-md);
  display: grid; place-items: center; margin-bottom: 14px;
  background: color-mix(in srgb, var(--tool-accent) 12%, #fff);
  color: var(--tool-accent);
  transition: background-color .2s var(--ease), color .2s var(--ease);
}
.tool-ic svg { width: 22px; height: 22px; }
.tool-card:hover .tool-ic { background: var(--tool-accent); color: #fff; }

.tool-card h3 { font-size: 1.02rem; font-weight: 650; margin-bottom: 6px; letter-spacing: -.017em; }
.tool-card p { font-size: .875rem; line-height: 1.55; color: var(--c-muted); }

/* Tools that are not built yet — visibly de-emphasised, never
   pretending to be ready. The flag is derived from whether the engine
   file exists, so this can never drift out of sync. */
.tool-card.is-soon { background: var(--c-surface); border-style: dashed; }
.tool-card.is-soon .tool-ic { opacity: .45; }
.tool-card.is-soon h3 { color: var(--c-ink-2); }
.tool-card.is-soon p  { opacity: .8; }
.tool-card.is-soon:hover { transform: none; box-shadow: var(--sh-xs); }
.tool-card.is-soon::after { display: none; }
.tool-soon {
  position: absolute; top: 14px; right: 14px;
  font-size: .66rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em;
  padding: 3px 9px; border-radius: var(--r-full);
  background: var(--c-surface-2); color: var(--c-muted);
}

/* Category chips */
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 22px;
  scrollbar-width: none; -ms-overflow-style: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  padding: 8px 16px; border-radius: var(--r-full); white-space: nowrap;
  border: 1px solid var(--c-line); background: #fff;
  font-size: .875rem; font-weight: 550; color: var(--c-ink-2);
  transition: all .15s var(--ease);
}
.chip:hover { border-color: var(--c-ink-2); }
.chip[aria-pressed='true'] { background: var(--c-ink); border-color: var(--c-ink); color: #fff; }

/* ── Dropzone ──────────────────────────────────────────────────── */
.drop {
  position: relative; display: grid; place-items: center; gap: 16px;
  padding: clamp(38px, 7vw, 68px) 24px; text-align: center;
  border: 2px dashed var(--c-line); border-radius: var(--r-xl);
  background: var(--c-surface);
  transition: border-color .18s var(--ease), background-color .18s var(--ease);
}
.drop[data-drag='true'] { border-color: var(--c-brand); background: var(--c-brand-soft); }
.drop-ic {
  width: 62px; height: 62px; border-radius: 50%; display: grid; place-items: center;
  background: #fff; color: var(--c-brand); box-shadow: var(--sh-sm);
}
.drop-ic svg { width: 28px; height: 28px; }
.drop-hint { font-size: .875rem; color: var(--c-muted); }

/* ── File queue ────────────────────────────────────────────────── */
/* minmax(0,1fr) is essential — a bare 1fr uses min-width:auto, which
   lets a long filename force the row wider than the viewport. */
.queue { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; margin-top: 22px; }
.queue > * { min-width: 0; }
.qitem {
  display: flex; align-items: center; gap: 13px; padding: 13px 15px;
  border: 1px solid var(--c-line); border-radius: var(--r-md); background: #fff;
  min-width: 0; max-width: 100%;
}
.qitem-thumb {
  width: 38px; height: 46px; border-radius: 5px; flex: none;
  background: var(--c-surface-2); display: grid; place-items: center;
  color: var(--c-muted); overflow: hidden;
}
.qitem-thumb img { width: 100%; height: 100%; object-fit: cover; }
.qitem-meta { min-width: 0; flex: 1 1 auto; overflow: hidden; }
.qitem-name { font-size: .9rem; font-weight: 550; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.qitem-sub { font-size: .78rem; color: var(--c-muted); }
.qitem-x { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  color: var(--c-muted); flex: none; }
.qitem-x:hover { background: var(--c-surface-2); color: var(--c-brand); }

/* ── Progress ──────────────────────────────────────────────────── */
.bar { height: 6px; border-radius: var(--r-full); background: var(--c-surface-2); overflow: hidden; }
.bar-fill {
  height: 100%; border-radius: inherit; width: 0%;
  background: linear-gradient(90deg, var(--c-brand), #FF8A6B);
  transition: width .3s var(--ease);
}

/* ── Tool page layout ──────────────────────────────────────────── */
.tool-hero { padding: 34px 0 26px; text-align: center; }
.tool-hero .tool-ic { margin-inline: auto; width: 56px; height: 56px; }
.tool-hero .tool-ic svg { width: 27px; height: 27px; }
.tool-hero h1 { margin-top: 14px; }
.tool-hero p { max-width: 58ch; margin: 12px auto 0; color: var(--c-muted); font-size: 1.05rem; }

.panel {
  background: #fff; border: 1px solid var(--c-line);
  border-radius: var(--r-xl); padding: clamp(18px, 3vw, 28px);
  box-shadow: var(--sh-sm);
}
/* Options stack on phones and go side-by-side from tablet up. */
.opt-row {
  display: grid; gap: 10px; align-items: center;
  padding: 14px 0; border-bottom: 1px solid var(--c-line);
}
.opt-row:last-child { border-bottom: 0; }
@media (min-width: 620px) {
  .opt-row { grid-template-columns: 160px 1fr; column-gap: 16px; }
  .opt-help { grid-column: 2; margin-top: -4px; }
}
.opt-label { font-weight: 600; font-size: .92rem; }
.opt-help  { font-size: .8rem; color: var(--c-muted); line-height: 1.5; }

.field {
  width: 100%; max-width: 100%;
  padding: 11px 14px; border: 1.5px solid var(--c-line); border-radius: var(--r-sm);
  background: #fff; font-size: 16px;   /* 16px stops iOS zooming on focus */
  transition: border-color .15s var(--ease);
}
@media (min-width: 620px) { .field { font-size: .93rem; } }
.field:focus { outline: none; border-color: var(--c-brand); }
select.field { appearance: none; padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='none' stroke='%236E6E7C' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round' d='m1 1.5 5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 13px center; }
input[type='range'] { flex: 1; min-width: 0; accent-color: var(--c-brand); height: 24px; }

/* Segmented control scrolls rather than overflowing on narrow screens. */
.seg {
  display: flex; padding: 3px; gap: 3px; background: var(--c-surface-2);
  border-radius: var(--r-full); max-width: 100%;
  overflow-x: auto; scrollbar-width: none; -ms-overflow-style: none;
}
.seg::-webkit-scrollbar { display: none; }
.seg button {
  padding: 9px 15px; border-radius: var(--r-full); white-space: nowrap;
  font-size: .87rem; font-weight: 550; color: var(--c-ink-2); flex: 0 0 auto;
}
.seg button[aria-pressed='true'] { background: #fff; color: var(--c-ink); box-shadow: var(--sh-xs); }

/* ── Interactive editors (organise, crop, sign, redact, forms) ──── */
.tool-mount { margin-top: 4px; }

.pg-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding-bottom: 12px; margin-bottom: 12px; border-bottom: 1px solid var(--c-line);
}
.pg-toolbar .btn { padding: 7px 12px; font-size: .82rem; }

.pg-grid {
  display: grid; gap: 10px; max-height: 460px; overflow-y: auto;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  padding: 2px;
}
@media (min-width: 640px) { .pg-grid { grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); } }

.pg-cell {
  position: relative; border: 2px solid var(--c-line); border-radius: var(--r-sm);
  background: #fff; cursor: grab; overflow: hidden;
  transition: border-color .14s var(--ease), transform .14s var(--ease);
}
.pg-cell:hover { border-color: var(--c-ink-2); }
.pg-cell.is-sel { border-color: var(--c-brand); background: var(--c-brand-soft); }
.pg-cell.is-drag { opacity: .4; }
.pg-cell.is-over { border-color: var(--c-brand); transform: scale(1.04); }

.pg-thumb { aspect-ratio: 1 / 1.35; display: grid; place-items: center; overflow: hidden; background: var(--c-surface); }
.pg-thumb img { max-width: 100%; max-height: 100%; transition: transform .2s var(--ease); }

.pg-num {
  position: absolute; bottom: 3px; left: 3px;
  font-size: .68rem; font-weight: 700; padding: 1px 6px;
  background: rgba(20,20,28,.72); color: #fff; border-radius: var(--r-full);
}
.pg-acts {
  position: absolute; top: 3px; right: 3px; display: flex; gap: 2px;
  opacity: 0; transition: opacity .14s var(--ease);
}
.pg-cell:hover .pg-acts, .pg-cell.is-sel .pg-acts { opacity: 1; }
@media (hover: none) { .pg-acts { opacity: 1; } }
.pg-acts button {
  width: 22px; height: 22px; border-radius: 5px; font-size: .72rem; line-height: 1;
  background: rgba(255,255,255,.94); color: var(--c-ink-2); box-shadow: var(--sh-xs);
}
.pg-acts button:hover { background: var(--c-brand); color: #fff; }

/* Crop / signature canvas stage */
.crop-stage {
  position: relative; border: 1px solid var(--c-line); border-radius: var(--r-md);
  overflow: hidden; background: var(--c-surface); touch-action: none; cursor: crosshair;
  max-height: 520px;
}
.crop-box {
  position: absolute; border: 2px dashed var(--c-brand);
  background: rgba(255,77,46,.12); pointer-events: none;
}
.sig-pad {
  border: 2px dashed var(--c-line); border-radius: var(--r-md);
  background: #fff; touch-action: none; cursor: crosshair; width: 100%; display: block;
}

/* ── Prose (tool copy + blog) ──────────────────────────────────── */
.prose { max-width: 68ch; }
.prose h2 { margin: 2em 0 .55em; }
.prose h3 { margin: 1.6em 0 .45em; font-size: 1.1rem; }
.prose p, .prose li { color: var(--c-ink-2); line-height: 1.75; }
.prose p { margin-bottom: 1.1em; }
.prose ul { margin: 0 0 1.1em; padding-left: 1.3em; list-style: disc; }
.prose ol { margin: 0 0 1.1em; padding-left: 1.3em; list-style: decimal; }
.prose li { margin-bottom: .45em; }
.prose a { color: var(--c-brand); text-decoration: underline; text-underline-offset: 2px; }
.prose strong { color: var(--c-ink); font-weight: 650; }

/* FAQ */
.faq { border-top: 1px solid var(--c-line); }
.faq details { border-bottom: 1px solid var(--c-line); }
.faq summary {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 18px 0; font-weight: 600; cursor: pointer; list-style: none;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: '+'; font-size: 1.35rem; font-weight: 400; color: var(--c-muted);
  transition: transform .2s var(--ease); flex: none;
}
.faq details[open] summary::after { transform: rotate(45deg); }
.faq details > div { padding-bottom: 18px; color: var(--c-ink-2); line-height: 1.7; }

/* ── Ad slots — fixed height so they never cause layout shift ──── */
.ad {
  display: grid; place-items: center; margin: 30px auto;
  background: var(--c-surface); border-radius: var(--r-md);
  overflow: hidden; max-width: 100%;
}
.ad[data-fmt='leaderboard'] { min-height: 90px; }
.ad[data-fmt='rect']        { min-height: 250px; max-width: 336px; }
.ad[data-fmt='inarticle']   { min-height: 250px; }
.ad:empty::after {
  content: 'Advertisement'; font-size: .7rem; letter-spacing: .1em;
  text-transform: uppercase; color: var(--c-line);
}

/* ── Footer ────────────────────────────────────────────────────── */
.ftr { margin-top: 70px; padding: 54px 0 30px; background: var(--c-surface); border-top: 1px solid var(--c-line); }
.ftr-grid { display: grid; gap: 34px; grid-template-columns: 1fr; }
@media (min-width: 700px)  { .ftr-grid { grid-template-columns: 1.4fr repeat(3, 1fr); } }
.ftr h4 { font-size: .76rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .09em; color: var(--c-muted); margin-bottom: 13px; }
.ftr a { display: block; padding: 4px 0; font-size: .89rem; color: var(--c-ink-2); }
.ftr a:hover { color: var(--c-brand); }
.ftr-bot {
  margin-top: 40px; padding-top: 22px; border-top: 1px solid var(--c-line);
  display: flex; flex-wrap: wrap; gap: 14px; justify-content: space-between;
  font-size: .83rem; color: var(--c-muted);
}

/* ── Utility ───────────────────────────────────────────────────── */
.hide { display: none !important; }
.stack   { display: grid; gap: 16px; }
.row     { display: flex; align-items: center; gap: 12px; }
.row-end { margin-left: auto; }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.fade-in { animation: fadeIn .3s var(--ease-out) both; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE LAYER
   Phone-first refinements. The base styles above already handle
   desktop; everything here fixes the small and mid widths.
   ═══════════════════════════════════════════════════════════════ */

/* Nothing may ever push the page sideways. */
html, body { max-width: 100%; overflow-x: clip; }
img, svg, canvas, video, iframe, table, pre { max-width: 100%; }
/* Long URLs in prose are the usual culprits. Filenames are handled
   separately with an ellipsis, so they must NOT wrap. */
.prose a, .prose p, .prose li { overflow-wrap: anywhere; }
h1, h2, h3 { overflow-wrap: break-word; }

/* ── Phones (≤ 639px) ──────────────────────────────────────────── */
@media (max-width: 639px) {
  :root { --hdr-h: 60px; }

  .wrap { padding-inline: 16px; }

  /* Give the logo room; hide the secondary CTA. */
  .logo { font-size: 1.08rem; }
  .logo-mark { width: 27px; height: 27px; border-radius: 8px; }
  .hdr-actions .btn { display: none; }

  .hero { padding: 32px 0 22px; }
  .hero-sub { font-size: 1rem; }
  .hero-badges { gap: 6px; margin-top: 20px; }
  .badge { padding: 6px 12px; font-size: .78rem; }

  .section { padding: 28px 0; }
  .section-head { margin-bottom: 18px; }

  .tool-hero { padding: 22px 0 18px; }
  .tool-hero p { font-size: .98rem; }

  /* Primary actions become full-width thumb targets. */
  .btn-lg { width: 100%; padding: 15px 24px; }
  .drop .btn-lg { width: auto; min-width: min(100%, 280px); }
  [data-action] .btn { width: 100%; }

  .drop { padding: 32px 16px; border-radius: var(--r-lg); }
  .drop-ic { width: 54px; height: 54px; }

  .panel { padding: 16px; border-radius: var(--r-lg); }

  /* Result buttons stack instead of squeezing side by side. */
  [data-result] .row { flex-direction: column; align-items: stretch; }
  [data-result] .row .btn { width: 100%; }

  .qitem { padding: 11px 12px; gap: 10px; }
  .qitem-thumb { width: 32px; height: 40px; }

  /* A 3-way segmented control cannot fit on a phone in one row, and a
     hidden horizontal scroll just looks broken. Let it wrap evenly. */
  .seg {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(88px, 1fr));
    overflow: visible; width: 100%; border-radius: var(--r-lg);
  }
  .seg button { padding: 10px 8px; font-size: .82rem; border-radius: var(--r-md); }

  /* Options label sits above its control, so tighten the gap. */
  .opt-row { padding: 12px 0; gap: 8px; }

  .ftr { margin-top: 44px; padding: 36px 0 24px; }
  .ftr-grid { gap: 26px; }
  .ftr-bot { flex-direction: column; gap: 10px; }

  .prose h2 { margin-top: 1.5em; }
  .faq summary { padding: 15px 0; font-size: .95rem; }

  .ad { margin: 22px auto; }
}

/* Very small phones (iPhone SE and similar) */
@media (max-width: 360px) {
  .wrap { padding-inline: 13px; }
  .logo span:last-child { font-size: 1rem; }
  .tool-card { padding: 15px; }
  .seg button { padding: 8px 12px; font-size: .82rem; }
}

/* ── Tablets (640–1023px) ──────────────────────────────────────── */
@media (min-width: 640px) and (max-width: 1023px) {
  .hero { padding: 44px 0 28px; }
  /* The nav is hidden here, so the burger needs to be obvious. */
  .hdr-actions .btn { padding: 10px 16px; font-size: .88rem; }
  .ftr-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Tablet landscape / small laptop — nav appears at 1024 */
@media (min-width: 1024px) and (max-width: 1179px) {
  .nav-btn { padding: 8px 8px; font-size: .855rem; }
  .logo span:last-child { font-size: 1.1rem; }
}

/* ── Touch devices ─────────────────────────────────────────────── */
@media (hover: none) {
  /* Hover lift is meaningless on touch and causes sticky states. */
  .tool-card:hover { transform: none; box-shadow: none; border-color: var(--c-line); }
  .tool-card:active { transform: scale(.985); background: var(--c-surface); }
  .tool-card:hover .tool-ic {
    background: color-mix(in srgb, var(--tool-accent) 12%, #fff);
    color: var(--tool-accent);
  }
  /* Mega menus are hover-driven; never show them on touch. */
  .mega { display: none; }
  /* Minimum comfortable tap target. */
  .qitem-x, .burger { min-width: 40px; min-height: 40px; }
  .mega-link, .ftr a { padding-block: 9px; }
}

/* ── Landscape phones — reclaim vertical space ─────────────────── */
@media (max-height: 480px) and (orientation: landscape) {
  .hero { padding: 22px 0 16px; }
  .drop { padding: 22px 16px; }
  .drawer { padding: 14px 20px; }
}

/* ── Accessibility preferences ─────────────────────────────────── */
@media (prefers-contrast: more) {
  .tool-card, .panel, .field { border-color: var(--c-ink-2); }
  .muted, .qitem-sub, .opt-help { color: var(--c-ink-2); }
}

/* ── Print ─────────────────────────────────────────────────────── */
@media print {
  .hdr, .ftr, .ad, .drop, .btn, .drawer, .chips { display: none !important; }
  body { color: #000; background: #fff; }
  .panel, .tool-card { border: 1px solid #ccc; box-shadow: none; }
  a[href^='http']::after { content: ' (' attr(href) ')'; font-size: .8em; color: #555; }
}
