:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-2: #eef1f6;
  --text: #16181d;
  --muted: #545b69;
  --border: #d5dae3;
  --accent: #2f5bea;
  --accent-text: #ffffff;
  --accent-soft: #e6ecfd;
  --ok: #18794e;
  --warn: #a14a07;
  --err: #b42318;
  --focus: #f59e0b;
  --check-a: #e9ecf1;
  --check-b: #ffffff;
  --radius: 12px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --surface: #1c1f25;
    --surface-2: #252932;
    --text: #e8eaee;
    --muted: #a3aab8;
    --border: #353a45;
    --accent: #7b9bff;
    --accent-text: #0d1020;
    --accent-soft: #232c4a;
    --ok: #5fd39a;
    --warn: #f0a35c;
    --err: #ff8a80;
    --check-a: #2a2e36;
    --check-b: #1f2228;
  }
}

*, *::before, *::after { 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.6 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
}
a { color: var(--accent); }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
code { font: 0.92em ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--surface-2); padding: 0.1em 0.35em; border-radius: 4px; }
h1, h2, h3 { line-height: 1.25; }
h1 { font-size: clamp(1.7rem, 4vw, 2.4rem); margin: 0.4em 0 0.3em; letter-spacing: -0.01em; }
h2 { font-size: 1.4rem; margin: 1.8em 0 0.6em; }
h3 { font-size: 1.1rem; }

.wrap { max-width: 980px; margin: 0 auto; padding: 0 20px; }
.skip { position: absolute; left: -9999px; top: 0; background: var(--surface); padding: 8px 12px; z-index: 10; }
.skip:focus { left: 8px; top: 8px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; padding: 0; margin: -1px; }
.muted { color: var(--muted); }

.site-header { border-bottom: 1px solid var(--border); background: var(--surface); }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 60px; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.15rem; color: var(--text); text-decoration: none; }
.brand svg { width: 30px; height: 30px; flex: none; }
.site-header nav { display: flex; gap: 4px; flex-wrap: wrap; }
.site-header nav a { color: var(--text); text-decoration: none; padding: 6px 10px; border-radius: 8px; }
.site-header nav a:hover, .site-header nav a[aria-current="page"] { background: var(--surface-2); }

.hero { padding: 12px 0 8px; }
.lede { font-size: 1.1rem; color: var(--muted); max-width: 46em; margin-top: 0; }

/* Converter tool */
.tool { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin: 18px 0 8px; }
.drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-align: center;
  min-height: 170px; padding: 24px; border: 2px dashed var(--border); border-radius: var(--radius);
  background: var(--surface-2); cursor: pointer; transition: border-color .15s, background .15s;
}
.drop:hover, .drop.dragging { border-color: var(--accent); background: var(--accent-soft); }
.drop:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
.drop svg { width: 40px; height: 40px; color: var(--accent); }
.drop-title { font-size: 1.15rem; font-weight: 600; }
.drop-sub { color: var(--muted); }
.drop-touch { display: none; }
@media (hover: none) and (pointer: coarse) {
  .drop-pointer { display: none; }
  .drop-touch { display: block; }
}
.linkish { color: var(--accent); text-decoration: underline; }
kbd { font: 0.85em ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 4px; padding: 0 4px; background: var(--surface); }

.controls { display: flex; flex-wrap: wrap; gap: 12px 22px; align-items: center; margin-top: 16px; }
.control { display: inline-flex; align-items: center; gap: 8px; max-width: 100%; }
.control select { max-width: 100%; min-width: 0; }
.control > span:first-child { font-weight: 600; white-space: nowrap; }
select, input[type="number"] {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px;
}
input[type="number"] { width: 6.5em; }
input[type="range"] { width: 150px; accent-color: var(--accent); }
input[type="color"] { width: 44px; height: 34px; padding: 2px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
output { min-width: 3.2em; font-variant-numeric: tabular-nums; }
.note { margin: 12px 0 0; padding: 10px 12px; border-radius: 8px; background: var(--surface-2); color: var(--muted); font-size: 0.95rem; }
.local-note { margin: 12px 0 0; font-size: 0.92rem; color: var(--ok); display: flex; gap: 6px; align-items: center; }
.local-note svg { width: 16px; height: 16px; flex: none; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
  border-radius: 8px; padding: 8px 14px; border: 1px solid var(--accent);
  background: var(--accent); color: var(--accent-text);
}
.btn:hover { filter: brightness(1.08); }
.btn.secondary { background: transparent; color: var(--accent); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-icon { background: transparent; border: 1px solid transparent; color: var(--muted); cursor: pointer; border-radius: 8px; width: 34px; height: 34px; font-size: 1.2rem; line-height: 1; }
.btn-icon:hover { background: var(--surface-2); color: var(--text); }

.results-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 18px; }
.results-bar p { margin: 0 auto 0 0; color: var(--muted); }
.results { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 10px; }
.result {
  display: grid; grid-template-columns: 64px 1fr auto; gap: 14px; align-items: center;
  padding: 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface);
}
.thumb {
  width: 64px; height: 64px; border-radius: 6px; object-fit: contain; display: block;
  background-color: var(--check-b);
  background-image: linear-gradient(45deg, var(--check-a) 25%, transparent 25%, transparent 75%, var(--check-a) 75%),
    linear-gradient(45deg, var(--check-a) 25%, transparent 25%, transparent 75%, var(--check-a) 75%);
  background-size: 12px 12px; background-position: 0 0, 6px 6px;
}
.result-info { min-width: 0; }
.result-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin: 0; }
.result-meta { margin: 2px 0 0; color: var(--muted); font-size: 0.92rem; font-variant-numeric: tabular-nums; }
.result-meta .smaller { color: var(--ok); }
.result-error { color: var(--err); }
.result-actions { display: flex; align-items: center; gap: 4px; }

/* Content sections */
.section { margin-top: 2.2em; }
.steps { list-style: none; counter-reset: step; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.steps li { counter-increment: step; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.steps li::before { content: counter(step); display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: var(--accent-text); font-weight: 700; margin-bottom: 6px; }
.steps strong { display: block; }
.prose { max-width: 46em; }
.prose li { margin: 0.3em 0; }
.faq details { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 0 16px; margin: 8px 0; max-width: 46em; }
.faq summary { cursor: pointer; font-weight: 600; padding: 12px 0; }
.faq details p { margin: 0 0 14px; }
.links-grid { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px; }
.links-grid a { display: block; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); text-decoration: none; color: var(--text); font-weight: 500; }
.links-grid a:hover { border-color: var(--accent); color: var(--accent); }
.links-grid a[aria-current="page"] { border-color: var(--accent); background: var(--accent-soft); }

.callout {
  display: grid; grid-template-columns: auto 1fr; gap: 18px; align-items: center;
  margin: 2.4em 0 1em; padding: 20px; border-radius: var(--radius); background: var(--accent-soft); border: 1px solid var(--accent);
}
.callout svg { width: 56px; height: 56px; }
.callout h2 { margin: 0 0 4px; font-size: 1.25rem; }
.callout p { margin: 0 0 10px; }
.callout .callout-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; }
.store-line { margin: 18px 0 6px; }
.store-line .btn { padding: 11px 20px; font-size: 1.05rem; }
.store-note { margin: 0; font-size: 0.92rem; }
.ext-shots { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 24px 0 8px; }
.ext-shots figure { margin: 0; }
.ext-shots img { display: block; width: 100%; height: auto; border-radius: var(--radius); border: 1px solid var(--border); }
.ext-shots figcaption { margin-top: 6px; font-size: 0.92rem; color: var(--muted); }
@media (max-width: 720px) { .ext-shots { grid-template-columns: 1fr; } }
.perms dt { font-weight: 700; margin-top: 14px; }
.perms dd { margin: 4px 0 0 0; }
.steps-list li { margin: 0.4em 0; }

.site-footer { margin-top: 56px; border-top: 1px solid var(--border); background: var(--surface); padding: 22px 0 30px; color: var(--muted); font-size: 0.95rem; }
.site-footer p { margin: 0.3em 0; }
.footer-links { display: flex; gap: 4px 18px; flex-wrap: wrap; }

@media (max-width: 560px) {
  /* Four nav links must fit one row at 390 px, even with wide fallback fonts (DejaVu Sans). */
  .site-header nav { gap: 0; }
  .site-header nav a { padding: 6px 7px; font-size: 0.94rem; }
  .tool { padding: 12px; }
  .result { grid-template-columns: 52px 1fr; }
  .thumb { width: 52px; height: 52px; }
  .result-actions { grid-column: 1 / -1; justify-content: flex-end; }
  .callout { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

.guide-links { padding-left: 1.2em; max-width: 46em; }
.guide-links li { margin: 0.35em 0; }
fieldset.control { border: 0; padding: 0; margin: 0; flex-wrap: wrap; }
fieldset.control legend { font-weight: 600; float: left; margin-right: 8px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border: 1px solid var(--border, #ccd); border-radius: 999px; font-size: .9rem; cursor: pointer; }
#keep-jpeg-control > span { font-weight: 400; }
.tool:not([data-format="pdf"]):not([data-format="tiff"]) .move { display: none; }
.btn-icon.move { font-size: 1rem; }
[hidden] { display: none !important; }

/* Guides index */
.guide-cards { list-style: none; padding: 0; margin: 18px 0 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.guide-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.guide-card h2 { font-size: 1.12rem; margin: 0 0 6px; }
.guide-card h2 a { text-decoration: none; }
.guide-card h2 a:hover { text-decoration: underline; }
.guide-card p { margin: 0; color: var(--muted); font-size: 0.95rem; }
.by-source-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px 22px; }
.by-source h3 { font-size: 1rem; margin: 0.8em 0 0.3em; }
.by-source ul { list-style: none; padding: 0; margin: 0; }
.by-source li { margin: 0.15em 0; }
.footer-links span { color: var(--text); }

/* Resize / max file size controls */
#resize-control { flex-wrap: wrap; }
#resize-control > label, #target-control > label { font-weight: 600; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.resize-dims, .resize-pct { display: inline-flex; align-items: center; gap: 6px; }
.resize-dims[hidden], .resize-pct[hidden] { display: none; }
#resize-control input[type="number"] { width: 5.5em; }
#target-kb { width: 6em; }
#target-kb:disabled { opacity: .55; }
.result-meta .warn { color: var(--warn, #b45309); }
