:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #eef2f8;
  --text: #0f172a;
  --muted: #5b6577;
  --border: #dbe1ea;
  --accent: #1d4ed8;
  --accent-hover: #1e40af;
  --accent-ink: #ffffff;
  --accent-soft: #e0e8ff;
  --ok: #15803d;
  --ok-soft: #dcfce7;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --err: #b91c1c;
  --checker: #e5e9f0;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 16px rgba(15, 23, 42, .05);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1120;
    --surface: #131b2e;
    --surface-2: #1b2540;
    --text: #e6eaf2;
    --muted: #97a1b5;
    --border: #27324d;
    --accent: #5b8cff;
    --accent-hover: #7aa2ff;
    --accent-ink: #0b1120;
    --accent-soft: #1d2a4d;
    --ok: #4ade80;
    --ok-soft: #12321f;
    --warn: #fbbf24;
    --warn-soft: #3a2c0b;
    --err: #f87171;
    --checker: #1f2940;
    --shadow: none;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0b1120;
  --surface: #131b2e;
  --surface-2: #1b2540;
  --text: #e6eaf2;
  --muted: #97a1b5;
  --border: #27324d;
  --accent: #5b8cff;
  --accent-hover: #7aa2ff;
  --accent-ink: #0b1120;
  --accent-soft: #1d2a4d;
  --ok: #4ade80;
  --ok-soft: #12321f;
  --warn: #fbbf24;
  --warn-soft: #3a2c0b;
  --err: #f87171;
  --checker: #1f2940;
  --shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
}

a { color: var(--accent); }

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }

/* Header / footer */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); }
.header-row, .footer-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; padding-top: 12px; padding-bottom: 12px;
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--accent); font-weight: 700; font-size: 1.15rem; text-decoration: none; }
.brand span { color: var(--text); }
.nav { display: flex; gap: 16px; flex-wrap: wrap; }
.nav a { color: var(--muted); text-decoration: none; font-size: .95rem; }
.nav a:hover { color: var(--accent); }
.site-footer { margin-top: 48px; border-top: 1px solid var(--border); background: var(--surface); color: var(--muted); font-size: .9rem; }

/* Hero */
.hero { padding: 28px 0 12px; }
.hero h1 { font-size: clamp(1.6rem, 4.5vw, 2.4rem); line-height: 1.2; margin: 0 0 8px; letter-spacing: -.01em; }
.lead { margin: 0; color: var(--muted); max-width: 760px; font-size: 1.05rem; }
.lead strong { color: var(--text); }

/* Tool layout */
.tool { display: grid; gap: 16px; margin: 16px 0 24px; }
.col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
@media (min-width: 900px) {
  .tool { grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); align-items: start; }
}

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
  min-width: 0;
}
.step { display: flex; align-items: center; gap: 10px; font-size: 1.05rem; margin: 0 0 14px; }
.step > span:first-child {
  display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink); font-size: .85rem; font-weight: 700; flex: none;
}

/* Form fields */
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; font-size: .9rem; color: var(--muted); }
.field input, .field select {
  font: inherit; font-size: 1rem; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; padding: 9px 10px; width: 100%;
}
.field input:focus, .field select:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; margin-top: 10px; }
.span-2 { grid-column: span 2; }
.note { font-size: .85rem; color: var(--muted); margin: 0 0 10px; }
.size-box summary { cursor: pointer; font-weight: 600; padding: 4px 0; }
.size-box summary .muted { font-weight: 400; font-size: .85rem; }

.slider { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; font-size: .9rem; color: var(--muted); }
.slider span { width: 96px; flex: none; }
.slider input { flex: 1; min-width: 0; accent-color: var(--accent); }
.check { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 10px; font-size: .95rem; cursor: pointer; }
.check input { margin-top: 4px; accent-color: var(--accent); width: 16px; height: 16px; flex: none; }

/* Buttons */
.btn {
  font: inherit; font-size: .95rem; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); cursor: pointer; text-decoration: none; min-height: 40px;
}
.btn:hover { border-color: var(--accent); }
.btn.ghost { background: transparent; }
.btn.small { font-size: .85rem; min-height: 34px; padding: 6px 12px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; font-size: 1.05rem; min-height: 48px; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.block { display: flex; width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.row { display: flex; gap: 12px; align-items: center; }
.grow { flex: 1; }

/* Upload & editor */
.drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  text-align: center; padding: 40px 16px; border: 2px dashed var(--border); border-radius: var(--radius);
  background: var(--surface-2); cursor: pointer; color: var(--muted); min-height: 220px;
}
.drop strong { color: var(--text); font-size: 1.05rem; }
.drop svg { color: var(--accent); }
.drop:hover, .drop.drag { border-color: var(--accent); background: var(--accent-soft); }

.stage {
  display: flex; justify-content: center; align-items: center; padding: 16px;
  background:
    repeating-conic-gradient(var(--checker) 0 25%, transparent 0 50%) 50% / 20px 20px,
    var(--surface-2);
  border-radius: var(--radius); margin-bottom: 6px;
}
#view {
  display: block; max-width: 100%; touch-action: none; cursor: grab;
  box-shadow: 0 0 0 1px var(--border), 0 6px 24px rgba(0, 0, 0, .18); background: #fff;
}
#view:active { cursor: grabbing; }
.hint { text-align: center; font-size: .85rem; margin: 0 0 8px; }

/* Result */
.out-wrap {
  display: flex; justify-content: center; align-items: center; padding: 14px; border-radius: 10px;
  background: var(--surface-2); margin-bottom: 10px; min-height: 120px;
}
.out-wrap img { max-width: 100%; max-height: 240px; box-shadow: 0 0 0 1px var(--border); background: #fff; }
.out-info { margin: 0 0 8px; font-variant-numeric: tabular-nums; font-weight: 600; text-align: center; }
.status { margin: 0 0 12px; padding: 8px 12px; border-radius: 10px; font-size: .9rem; }
.status.ok { background: var(--ok-soft); color: var(--ok); }
.status.warn { background: var(--warn-soft); color: var(--warn); }
.status:empty { display: none; }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.error { color: var(--err); font-size: .95rem; margin: 10px 0 0; }

/* Ads: placeholders reserve space so the layout doesn't jump when ads load */
.ad-slot {
  display: flex; align-items: center; justify-content: center;
  border: 1px dashed var(--border); border-radius: 10px; color: var(--muted);
  font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; overflow: hidden;
}
.ad-top { min-height: 90px; margin: 8px 0; }
.ad-box { min-height: 250px; margin-top: 16px; }
.ad-wide { min-height: 120px; margin: 24px 0; }

/* Content sections */
.content {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px; margin: 16px 0; box-shadow: var(--shadow);
}
.content h2 { margin-top: 0; font-size: 1.35rem; }
.content h3 { font-size: 1.1rem; margin-top: 22px; }
.steps li, .content ul li { margin-bottom: 8px; }
.content details { border-top: 1px solid var(--border); padding: 12px 0; }
.content details:last-child { border-bottom: 1px solid var(--border); }
.content summary { cursor: pointer; font-weight: 600; }
.content details p { margin: 8px 0 0; color: var(--muted); }

.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .92rem; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: var(--surface-2); font-weight: 600; }
td a { white-space: nowrap; }

/* Simple text pages */
.page { max-width: 760px; }
.page h1 { font-size: 1.9rem; margin: 28px 0 8px; }

@media (max-width: 480px) {
  .card, .content { padding: 14px; }
  .slider span { width: 80px; }
}

/* ---------- Multi-page additions ---------- */
.footer-links { padding-top: 16px; font-size: .88rem; display: flex; flex-wrap: wrap; gap: 6px 14px; }
.footer-links a { color: var(--muted); }

.form-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.form-card { border: 1px solid var(--border); border-radius: 12px; padding: 14px; background: var(--surface-2); }
.form-card h3 { margin: 0 0 8px; font-size: 1rem; }
.form-card ul { margin: 0; padding: 0; list-style: none; }
.form-card li { padding: 4px 0; }
.form-card li a { font-weight: 600; }

.tool-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.tool-card {
  display: flex; flex-direction: column; gap: 4px; padding: 16px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface-2); text-decoration: none; color: var(--text);
}
.tool-card:hover { border-color: var(--accent); }
.tool-card strong { color: var(--accent); }
.tool-card .muted { font-size: .9rem; }

.related h2 { font-size: 1.1rem; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.chips a {
  font-size: .88rem; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface-2); text-decoration: none; color: var(--text);
}
.chips a:hover { border-color: var(--accent); color: var(--accent); }
.content table th { width: 34%; }

/* Single-card tools (PDF, join) */
@media (min-width: 900px) {
  .tool.tool-single { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
}
.tool-single .card > * + * { margin-top: 14px; }
.tool-single .card > .field, .tool-single .card > .check, .tool-single .card > .slider { margin-bottom: 0; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0 12px; }
.grid-3 .field, .tool-single .grid-2 .field { margin-bottom: 6px; }
.drop.drop-sm { min-height: 150px; padding: 24px 16px; }
.file-info { font-weight: 600; text-align: center; }
.small-h { font-size: 1rem; margin-bottom: 0; }
.slider b { font-weight: 600; min-width: 40px; text-align: right; color: var(--text); }

.file-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.file-list:empty { display: none; }
.file-item {
  display: flex; align-items: center; gap: 10px; padding: 8px; border: 1px solid var(--border);
  border-radius: 10px; background: var(--surface-2);
}
.file-item img { width: 48px; height: 48px; object-fit: cover; border-radius: 6px; background: #fff; flex: none; }
.file-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .92rem; }
.file-actions { display: flex; gap: 4px; flex: none; }
.file-actions .btn { min-width: 34px; padding: 4px 8px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.slots { gap: 12px; }
.drop.slot { min-height: 170px; padding: 16px; }
.drop.slot img { max-width: 100%; max-height: 110px; border-radius: 6px; background: #fff; }
.drop.slot.has-file { border-style: solid; border-color: var(--accent); }

/* Word to PDF: off-screen render area for document pages */
.w2p-host { position: absolute; left: -20000px; top: 0; width: max-content; background: #fff; color: #000; }
.w2p-host section { margin: 0 !important; box-shadow: none !important; }
/* docx-preview turns on automatic hyphenation for every document; Word does not. */
.w2p-host .docx { hyphens: manual !important; -webkit-hyphens: manual !important; }

/* Breadcrumb */
.crumbs { margin: 18px 0 -12px; font-size: .85rem; color: var(--muted); }
.crumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; }
.crumbs li + li::before { content: "›"; margin-right: 6px; opacity: .7; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--accent); text-decoration: underline; }
.page .crumbs, .crumbs + .page h1 { margin-top: 12px; }

/* ---------- Header nav ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  -webkit-backdrop-filter: saturate(1.6) blur(12px); backdrop-filter: saturate(1.6) blur(12px);
}
.site-header .header-row {
  display: grid; grid-template-columns: auto 1fr auto; grid-template-areas: "brand nav lang";
  align-items: center; gap: 8px 16px; padding-top: 10px; padding-bottom: 10px;
}
.site-header .brand { grid-area: brand; }
.main-nav { grid-area: nav; display: flex; justify-content: center; gap: 4px; min-width: 0; }
.main-nav a, .site-header .lang {
  display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
  padding: 7px 12px; border-radius: 999px; border: 1px solid transparent;
  color: var(--muted); font-size: .9rem; font-weight: 500; text-decoration: none;
  transition: color .15s, background-color .15s, border-color .15s;
}
.nav-ico { width: 17px; height: 17px; flex: none; opacity: .85; }
.main-nav a:hover { color: var(--text); background: var(--surface-2); }
.main-nav a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.main-nav a[aria-current="page"] .nav-ico { opacity: 1; }
.main-nav a:focus-visible, .site-header .lang:focus-visible, .brand:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.site-header .lang { grid-area: lang; justify-self: end; color: var(--text); border-color: var(--border); background: var(--surface); }
.site-header .lang:hover { border-color: var(--accent); color: var(--accent); }

/* The nav is a row under the logo: centred when it fits, swipeable when it doesn't. */
@media all {
  .site-header .header-row { grid-template-columns: 1fr auto; grid-template-areas: "brand lang" "nav nav"; padding-bottom: 6px; }
  .main-nav {
    justify-content: safe center; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 2px 16px 4px;
    scroll-snap-type: x proximity; scroll-padding: 0 16px;
    -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 16px, #000 calc(100% - 24px), transparent);
            mask-image: linear-gradient(90deg, transparent 0, #000 16px, #000 calc(100% - 24px), transparent);
  }
  .main-nav::-webkit-scrollbar { display: none; }
  .main-nav a { scroll-snap-align: start; background: var(--surface-2); }
  .main-nav a[aria-current="page"] { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
}
@media (max-width: 480px) {
  .main-nav a { padding: 6px 11px; font-size: .86rem; }
}
@media (prefers-reduced-motion: reduce) { .main-nav a, .site-header .lang { transition: none; } }

/* ---------- Site search (glass) ---------- */
.search-band {
  position: relative; z-index: 40; padding: 14px 0 6px;
  background:
    radial-gradient(420px 120px at 12% 0%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 70%),
    radial-gradient(360px 120px at 88% 10%, color-mix(in srgb, #a855f7 18%, transparent), transparent 70%),
    radial-gradient(300px 100px at 55% 100%, color-mix(in srgb, #06b6d4 14%, transparent), transparent 70%);
}
.site-search { position: relative; max-width: 720px; margin: 0 auto; }
.search-box {
  position: relative; display: flex; align-items: center; gap: 10px; height: 52px; padding: 0 12px 0 16px;
  border-radius: 16px; border: 1px solid color-mix(in srgb, var(--text) 14%, transparent);
  background: color-mix(in srgb, var(--surface) 62%, transparent);
  -webkit-backdrop-filter: blur(16px) saturate(1.7); backdrop-filter: blur(16px) saturate(1.7);
  box-shadow: inset 0 1px 0 color-mix(in srgb, #fff 35%, transparent), 0 6px 24px rgba(15, 23, 42, .08);
  transition: border-color .2s, box-shadow .25s, transform .25s, background-color .2s;
}
.search-box:hover { border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.site-search.is-focused .search-box {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--surface) 80%, transparent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent), 0 10px 34px color-mix(in srgb, var(--accent) 22%, transparent);
  transform: translateY(-1px);
}
.search-ico { width: 20px; height: 20px; flex: none; color: var(--muted); transition: color .2s; }
.site-search.is-focused .search-ico { color: var(--accent); }
.search-box input {
  flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: transparent;
  color: var(--text); font: inherit; font-size: 1rem;
}
.search-box input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
.search-demo {
  position: absolute; left: 46px; right: 70px; top: 50%; transform: translateY(-50%);
  pointer-events: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); font-size: 1rem;
}
.search-demo b {
  font-weight: 600; color: var(--accent); padding: 1px 4px; margin: 0 1px; border-radius: 6px;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
}
.search-demo b:empty { padding: 0; margin: 0; }
.search-caret { display: inline-block; width: 2px; height: 1.1em; margin-left: 2px; vertical-align: -.2em; background: var(--accent); animation: search-blink 1s steps(1) infinite; }
@keyframes search-blink { 50% { opacity: 0; } }
.search-clear {
  display: grid; place-items: center; width: 30px; height: 30px; flex: none; padding: 0; border: 0; border-radius: 50%;
  background: var(--surface-2); color: var(--muted); cursor: pointer;
}
.search-clear svg { width: 16px; height: 16px; }
.search-clear:hover { color: var(--text); }
.search-kbd {
  flex: none; min-width: 24px; padding: 2px 7px; border-radius: 6px; text-align: center; font: 600 .8rem/1.4 ui-monospace, monospace;
  color: var(--muted); border: 1px solid var(--border); background: var(--surface); box-shadow: 0 1px 0 var(--border);
}
.site-search.is-focused .search-kbd, .search-clear:not([hidden]) ~ .search-kbd { display: none; }

.search-results {
  position: absolute; left: 0; right: 0; top: calc(100% + 8px); margin: 0; padding: 6px; list-style: none;
  max-height: min(420px, 62vh); overflow-y: auto; border-radius: 16px;
  border: 1px solid color-mix(in srgb, var(--text) 12%, transparent);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  -webkit-backdrop-filter: blur(24px) saturate(1.6); backdrop-filter: blur(24px) saturate(1.6);
  box-shadow: 0 18px 50px rgba(2, 6, 23, .28);
  opacity: 0; visibility: hidden; transform: translateY(-6px) scale(.99); transform-origin: top center;
  transition: opacity .16s, transform .16s, visibility 0s .16s;
}
.site-search.is-open .search-results { opacity: 1; visibility: visible; transform: none; transition: opacity .16s, transform .16s; }
.search-results .sr-head { padding: 6px 10px 4px; font-size: .75rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.search-results .sr-empty { padding: 14px 12px; color: var(--muted); font-size: .92rem; }
.search-results a {
  display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 10px;
  color: var(--text); text-decoration: none;
}
.search-results [aria-selected="true"] a, .search-results a:hover { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.sr-kind {
  flex: none; min-width: 46px; padding: 2px 8px; border-radius: 999px; text-align: center;
  font-size: .72rem; font-weight: 700; letter-spacing: .02em;
}
.sr-form { color: var(--accent); background: var(--accent-soft); }
.sr-tool { color: #7c3aed; background: color-mix(in srgb, #a855f7 16%, transparent); }
.sr-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.sr-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-sub { font-size: .82rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-results mark { color: inherit; background: color-mix(in srgb, #facc15 45%, transparent); border-radius: 3px; padding: 0 1px; }
.sr-go { width: 18px; height: 18px; flex: none; color: var(--muted); opacity: 0; transform: translateX(-4px); transition: opacity .15s, transform .15s; }
.search-results [aria-selected="true"] .sr-go, .search-results a:hover .sr-go { opacity: 1; transform: none; color: var(--accent); }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .sr-tool { color: #c4b5fd; }
  :root:not([data-theme="light"]) .search-results mark { background: color-mix(in srgb, #facc15 32%, transparent); }
}
:root[data-theme="dark"] .sr-tool { color: #c4b5fd; }
@media (max-width: 600px) {
  .search-band { padding-top: 10px; }
  .search-box { height: 48px; border-radius: 14px; }
  .search-kbd { display: none; }
  .search-demo { right: 48px; font-size: .95rem; }
}
@media (prefers-reduced-motion: reduce) {
  .search-box, .search-results, .sr-go { transition: none; }
  .search-caret { animation: none; }
}

/* ---------- Animated logo ---------- */
.brand { gap: 10px; }
.brand .logo { width: 32px; height: 32px; flex: none; overflow: visible; filter: drop-shadow(0 3px 8px rgba(79, 70, 229, .35)); transition: transform .25s; }
.brand:hover .logo { transform: rotate(-6deg) scale(1.06); }
.wordmark { font-size: 1.2rem; font-weight: 800; letter-spacing: -.02em; color: var(--text); }
.wordmark b {
  font-weight: 800;
  background: linear-gradient(90deg, #2563eb, #7c3aed, #2563eb); background-size: 200% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: ps-text 6s linear infinite;
}
.logo .lp { transform-box: fill-box; transform-origin: center; animation: ps-photo 3.2s cubic-bezier(.65, 0, .35, 1) infinite; }
.logo .lc { animation: 3.2s cubic-bezier(.65, 0, .35, 1) infinite; }
.logo .lc-tl { animation-name: ps-tl; }
.logo .lc-tr { animation-name: ps-tr; }
.logo .lc-br { animation-name: ps-br; }
.logo .lc-bl { animation-name: ps-bl; }
.logo .ls { animation: ps-sun 3.2s ease-in-out infinite; }
.logo .lsh { animation: ps-shine 6.4s ease-in-out infinite; }
.brand:hover .logo .lp, .brand:hover .logo .lc, .brand:hover .logo .ls { animation-duration: 1.6s; }

@keyframes ps-photo { 0%, 12%, 100% { transform: scale(1); } 45%, 62% { transform: scale(.78); } }
@keyframes ps-tl { 0%, 12%, 100% { transform: none; } 45%, 62% { transform: translate(2.4px, 2.4px); } }
@keyframes ps-tr { 0%, 12%, 100% { transform: none; } 45%, 62% { transform: translate(-2.4px, 2.4px); } }
@keyframes ps-br { 0%, 12%, 100% { transform: none; } 45%, 62% { transform: translate(-2.4px, -2.4px); } }
@keyframes ps-bl { 0%, 12%, 100% { transform: none; } 45%, 62% { transform: translate(2.4px, -2.4px); } }
@keyframes ps-sun { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(.8px); } }
@keyframes ps-shine { 0%, 55% { transform: translateX(0); } 85%, 100% { transform: translateX(50px); } }
@keyframes ps-text { to { background-position: -200% 0; } }

@media (prefers-reduced-motion: reduce) {
  .logo *, .wordmark b { animation: none !important; }
  .brand:hover .logo { transform: none; }
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .wordmark b { background-image: linear-gradient(90deg, #7aa2ff, #c4b5fd, #7aa2ff); }
}
:root[data-theme="dark"] .wordmark b { background-image: linear-gradient(90deg, #7aa2ff, #c4b5fd, #7aa2ff); }

/* ---------- Custom size buttons ---------- */
.custom-btn {
  position: relative; display: flex; align-items: center; gap: 12px; width: 100%; margin: 4px 0 12px; padding: 12px 14px;
  border: 1.5px solid transparent; border-radius: 14px; cursor: pointer; text-align: left; font: inherit; color: var(--text);
  background:
    linear-gradient(color-mix(in srgb, #f97316 9%, var(--surface)), color-mix(in srgb, #f59e0b 6%, var(--surface))) padding-box,
    linear-gradient(120deg, #ea580c, #f59e0b, #f97316, #ea580c) border-box;
  background-size: 100% 100%, 300% 100%;
  box-shadow: 0 6px 20px color-mix(in srgb, #f97316 22%, transparent);
  animation: custom-border 6s linear infinite;
  transition: transform .15s, box-shadow .2s;
}
.custom-btn:hover { transform: translateY(-1px); box-shadow: 0 10px 28px color-mix(in srgb, #f97316 32%, transparent); }
.custom-btn:focus-visible { outline: 2px solid #ea580c; outline-offset: 3px; }
.custom-btn[aria-pressed="true"] {
  background:
    linear-gradient(color-mix(in srgb, #f97316 18%, var(--surface)), color-mix(in srgb, #f59e0b 14%, var(--surface))) padding-box,
    linear-gradient(120deg, #ea580c, #f59e0b, #f97316, #ea580c) border-box;
  background-size: 100% 100%, 300% 100%;
}
.custom-ico {
  display: grid; place-items: center; width: 40px; height: 40px; flex: none; border-radius: 11px; color: #fff;
  background: linear-gradient(135deg, #ea580c, #f59e0b);
}
.custom-ico svg { width: 22px; height: 22px; }
.custom-txt { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.3; }
.custom-txt strong { font-size: 1rem; }
.custom-txt small { color: var(--muted); font-size: .84rem; }
.custom-tag {
  flex: none; padding: 3px 10px; border-radius: 999px; font-size: .75rem; font-weight: 700; color: #fff;
  background: #c2410c;
}
.custom-btn[aria-pressed="true"] .custom-tag { background: linear-gradient(90deg, #16a34a, #22c55e); }
@keyframes custom-border { to { background-position: 0 0, -300% 0; } }

.size-box.flash { animation: size-flash 1.4s ease-out; border-radius: 12px; }
@keyframes size-flash {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 55%, transparent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
  100% { box-shadow: 0 0 0 14px transparent; background: transparent; }
}

.hero-cta { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.custom-cta {
  display: inline-flex; align-items: center; gap: 8px; min-height: 48px; padding: 10px 18px; border-radius: 12px;
  font-weight: 700; text-decoration: none; color: #fff;
  /* Deep enough orange that white text keeps readable contrast. */
  background: linear-gradient(120deg, #c2410c, #ea580c, #c2410c); background-size: 200% 100%;
  box-shadow: 0 8px 22px color-mix(in srgb, #f97316 38%, transparent);
  animation: custom-border 5s linear infinite; transition: transform .15s;
}
.custom-cta svg { width: 20px; height: 20px; }
.custom-cta:hover { transform: translateY(-1px); }
.custom-cta:focus-visible { outline: 2px solid #ea580c; outline-offset: 3px; }
@media (max-width: 480px) {
  .custom-tag { display: none; }
  .hero-cta > * { flex: 1; justify-content: center; text-align: center; }
}
@media (prefers-reduced-motion: reduce) {
  .custom-btn, .custom-cta, .size-box.flash { animation: none; }
}

/* ---------- Hero tool buttons (compress / convert) ---------- */
.tool-cta {
  display: inline-flex; align-items: center; gap: 8px; min-height: 48px; padding: 10px 18px; border-radius: 12px;
  font-weight: 700; text-decoration: none; color: #fff; background-size: 200% 100%;
  animation: custom-border 5s linear infinite; transition: transform .15s;
}
.tool-cta .nav-ico { width: 20px; height: 20px; opacity: 1; }
.tool-cta:hover { transform: translateY(-1px); }
.tool-cta:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.cta-compress { background-image: linear-gradient(120deg, #15803d, #16a34a, #15803d); box-shadow: 0 8px 22px color-mix(in srgb, #16a34a 34%, transparent); }
.cta-convert { background-image: linear-gradient(120deg, #be185d, #db2777, #be185d); box-shadow: 0 8px 22px color-mix(in srgb, #db2777 34%, transparent); }
@media (max-width: 600px) {
  .hero-cta > * { flex: 1 1 calc(50% - 10px); justify-content: center; text-align: center; padding-left: 10px; padding-right: 10px; }
}
@media (prefers-reduced-motion: reduce) { .tool-cta { animation: none; } }

/* ---------- Segmented choice, chips ---------- */
.seg { display: flex; gap: 4px; padding: 4px; margin: 0 0 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.field .seg { margin-top: 4px; }
.seg-opt { flex: 1; position: relative; }
.seg-opt input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg-opt span {
  display: block; padding: 8px 10px; border-radius: 9px; text-align: center; font-weight: 600; font-size: .92rem;
  color: var(--muted); transition: background-color .15s, color .15s, box-shadow .15s;
}
.seg-opt input:checked + span { background: var(--surface); color: var(--accent); box-shadow: 0 1px 3px rgba(15, 23, 42, .12); }
.seg-opt input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.chip {
  padding: 7px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); font: inherit; font-size: .88rem; font-weight: 600; cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip-input { width: 110px; padding: 7px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-size: .88rem; }

/* ---------- Compressor: format results side by side ---------- */
.fmt-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 12px; }
.fmt-card {
  position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 12px; min-width: 0;
  border-radius: 12px; border: 1.5px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; text-align: left; cursor: pointer; transition: border-color .15s, box-shadow .15s, transform .15s;
}
.fmt-card:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); }
.fmt-card[aria-checked="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
.fmt-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.fmt-name { font-size: .78rem; font-weight: 800; letter-spacing: .06em; color: var(--muted); }
.fmt-size { font-size: 1.2rem; font-weight: 800; }
.fmt-meta { font-size: .78rem; color: var(--ok); }
.fmt-card.warn .fmt-meta { color: var(--warn); }
.fmt-card.fail .fmt-meta { color: var(--err); }
.fmt-card.busy .fmt-size { opacity: .4; }
.fmt-card.busy::after {
  content: ""; position: absolute; top: 12px; right: 12px; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--border); border-top-color: var(--accent); animation: fmt-spin .8s linear infinite;
}
.fmt-badge { position: absolute; top: 10px; right: 10px; padding: 2px 8px; border-radius: 999px; font-size: .68rem; font-weight: 800; color: #fff; background: #15803d; }
@keyframes fmt-spin { to { transform: rotate(360deg); } }
@media (max-width: 420px) {
  .fmt-grid { gap: 6px; }
  .fmt-card { padding: 10px 8px; }
  .fmt-size { font-size: 1rem; }
  .fmt-badge { position: static; margin-top: 4px; }
}

/* ---------- Converter list ---------- */
.cv-item .cv-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.cv-item .file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cv-item img { background: repeating-conic-gradient(var(--checker) 0 25%, transparent 0 50%) 0 0 / 12px 12px; }
/* Desktop: tighter pills so all nav items fit on one row. */
@media (min-width: 900px) {
  .main-nav { gap: 2px; }
  .main-nav a { padding: 6px 10px; gap: 6px; font-size: .86rem; background: transparent; }
  .main-nav a:hover { background: var(--surface-2); }
  .main-nav a[aria-current="page"] { background: var(--accent-soft); }
}
@media (min-width: 900px) and (max-width: 1179px) { .main-nav .nav-ico { display: none; } }

/* Converter: per-image download button */
.cv-dl { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; font-weight: 600; padding-left: 12px; padding-right: 14px; }
.cv-dl[hidden] { display: none; }
.cv-dl svg { width: 16px; height: 16px; flex: none; }
.cv-item .file-actions { display: flex; align-items: center; gap: 6px; flex: none; }
@media (max-width: 420px) { .cv-dl { padding-left: 10px; padding-right: 10px; font-size: .82rem; } }
