/*
 * FindWebTools — design system.
 *
 * One stylesheet for the whole platform. Every page loads exactly this file
 * plus its own tool module, so a visitor who wants to compress one image
 * downloads no framework runtime (§39).
 *
 * Colour is derived from the logo: the mark is a blue-to-magenta gradient, but
 * a five-stop gradient is a logo, not a page (§13). The gradient appears on the
 * mark and one hero accent; everywhere else --brand carries buttons, links and
 * focus rings as a flat colour, where it clears WCAG AA on both grounds.
 *
 * Themes: bare :root is the complete light palette. The dark block redefines
 * tokens only, guarded so an explicit light choice beats a dark OS. No
 * component style lives inside a media query.
 */

/* ------------------------------------------------------------------ *
 * Tokens
 * ------------------------------------------------------------------ */

:root {
  /* Brand, sampled from logo.png */
  --brand: #3A6FE8;
  --brand-strong: #2C5AC9;
  --brand-soft: #E8EFFD;
  --brand-line: #C3D5FA;
  --grad: linear-gradient(135deg, #4D86FA 0%, #475AE5 38%, #8057F0 72%, #9835CD 100%);

  /* Neutrals, biased very slightly toward the brand hue */
  --bg: #F5F7FA;
  --surface: #FFFFFF;
  --surface-2: #EDF1F7;
  --ink: #10141B;
  --ink-2: #333C4A;
  --muted: #5A6474;
  --muted-2: #7B8697;
  --line: #DCE2EB;
  --line-soft: #E9EDF3;
  --code-bg: #F0F3F8;

  /* Semantic — deliberately not the brand hue */
  --ok: #17715E;
  --ok-soft: #E1F1EC;
  --warn: #8A5B10;
  --warn-soft: #F9F0DD;
  --danger: #A93526;
  --danger-soft: #FAE9E6;

  --shadow-1: 0 1px 2px rgba(16, 20, 27, .05);
  --shadow-2: 0 1px 2px rgba(16, 20, 27, .05), 0 10px 28px -18px rgba(16, 20, 27, .35);

  --radius: 10px;
  --radius-sm: 7px;
  --wrap: 1180px;

  --font-ui: "Manrope", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --brand: #6E9CFF;
    --brand-strong: #8FB4FF;
    --brand-soft: #17203180;
    --brand-line: #2B3A57;

    --bg: #0B0E13;
    --surface: #131820;
    --surface-2: #0F141B;
    --ink: #E9EDF4;
    --ink-2: #C6CEDA;
    --muted: #8E99A9;
    --muted-2: #77828F;
    --line: #232B36;
    --line-soft: #1B222C;
    --code-bg: #0E131A;

    --ok: #4FBFA0;
    --ok-soft: #10241F;
    --warn: #D9A441;
    --warn-soft: #241D10;
    --danger: #E4826C;
    --danger-soft: #2A1714;

    --shadow-1: 0 1px 2px rgba(0, 0, 0, .5);
    --shadow-2: 0 1px 2px rgba(0, 0, 0, .5), 0 10px 28px -18px rgba(0, 0, 0, .9);

    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --brand: #6E9CFF;
  --brand-strong: #8FB4FF;
  --brand-soft: #17203180;
  --brand-line: #2B3A57;

  --bg: #0B0E13;
  --surface: #131820;
  --surface-2: #0F141B;
  --ink: #E9EDF4;
  --ink-2: #C6CEDA;
  --muted: #8E99A9;
  --muted-2: #77828F;
  --line: #232B36;
  --line-soft: #1B222C;
  --code-bg: #0E131A;

  --ok: #4FBFA0;
  --ok-soft: #10241F;
  --warn: #D9A441;
  --warn-soft: #241D10;
  --danger: #E4826C;
  --danger-soft: #2A1714;

  --shadow-1: 0 1px 2px rgba(0, 0, 0, .5);
  --shadow-2: 0 1px 2px rgba(0, 0, 0, .5), 0 10px 28px -18px rgba(0, 0, 0, .9);

  color-scheme: dark;
}

/* ------------------------------------------------------------------ *
 * Base
 * ------------------------------------------------------------------ */

*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 15px/1.6 var(--font-ui);
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

h1, h2, h3, h4 { margin: 0; font-weight: 800; letter-spacing: -.018em; text-wrap: balance; line-height: 1.18; }
h1 { font-size: clamp(27px, 4.4vw, 40px); }
h2 { font-size: 22px; }
h3 { font-size: 17px; font-weight: 700; }
h4 { font-size: 15px; font-weight: 700; letter-spacing: -.008em; }

p { margin: 0 0 14px; }
p:last-child { margin-bottom: 0; }

a { color: var(--brand); text-decoration-color: color-mix(in srgb, var(--brand) 40%, transparent); text-underline-offset: 3px; }
a:hover { color: var(--brand-strong); text-decoration-color: currentColor; }

code, kbd, samp, pre { font-family: var(--font-mono); font-size: .92em; }

img { max-width: 100%; height: auto; }

:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 3px;
}

.wrap { width: 100%; max-width: var(--wrap); margin: 0 auto; padding: 0 20px; }

.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;
}

.skip-link {
  position: absolute; left: 12px; top: -60px; z-index: 100;
  background: var(--brand); color: #fff; padding: 10px 16px;
  border-radius: var(--radius-sm); font-weight: 700; text-decoration: none;
  transition: top .16s ease;
}
.skip-link:focus { top: 12px; color: #fff; }

/* ------------------------------------------------------------------ *
 * Header
 * ------------------------------------------------------------------ */

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 40;
}

.site-header .wrap {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 62px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
  font-weight: 800;
  font-size: 16.5px;
  letter-spacing: -.02em;
  flex: 0 0 auto;
}
.brand:hover { color: var(--ink); }
.brand img { width: 30px; height: 30px; display: block; border-radius: 7px; }
.brand span i { font-style: normal; color: var(--brand); }

.site-nav {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
}

.site-nav a {
  color: var(--ink-2);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  padding: 8px 11px;
  border-radius: var(--radius-sm);
}
.site-nav a:hover { background: var(--surface-2); color: var(--ink); }

.theme-toggle {
  appearance: none;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink-2);
  width: 34px; height: 34px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: grid; place-items: center;
  flex: 0 0 auto;
}
.theme-toggle:hover { background: var(--surface-2); color: var(--ink); }
.theme-toggle svg { width: 17px; height: 17px; }
.theme-toggle .i-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .i-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .i-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .i-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .i-moon { display: none; }
}

/* ------------------------------------------------------------------ *
 * Main / hero
 * ------------------------------------------------------------------ */

main { flex: 1 0 auto; padding: 34px 0 64px; }

.hero { text-align: center; padding: 12px 0 26px; }
.hero h1 { max-width: 20ch; margin: 0 auto 14px; }
.hero h1 em {
  font-style: normal;
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero .lead {
  max-width: 62ch;
  margin: 0 auto;
  color: var(--muted);
  font-size: 16.5px;
}

.search-wrap { max-width: 620px; margin: 26px auto 0; position: relative; }
.search-wrap svg {
  position: absolute; left: 15px; top: 50%; transform: translateY(-50%);
  width: 18px; height: 18px; color: var(--muted-2); pointer-events: none;
}
#tool-search {
  width: 100%;
  font: 500 16px var(--font-ui);
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 13px 16px 13px 44px;
  box-shadow: var(--shadow-1);
}
#tool-search::placeholder { color: var(--muted-2); font-weight: 400; }
#tool-search:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); outline: none; }

.filters {
  display: flex; flex-wrap: wrap; gap: 8px;
  justify-content: center;
  margin: 22px auto 0;
  max-width: 900px;
}

.pill {
  appearance: none;
  font: 600 13.5px var(--font-ui);
  background: var(--surface);
  color: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 15px;
  cursor: pointer;
  white-space: nowrap;
}
.pill:hover { border-color: var(--brand-line); color: var(--ink); }
.pill[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: #fff; }
:root[data-theme="dark"] .pill[aria-pressed="true"] { color: #0B0E13; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .pill[aria-pressed="true"] { color: #0B0E13; }
}

.result-count { text-align: center; color: var(--muted); font-size: 13.5px; margin: 18px 0 0; }

/* ------------------------------------------------------------------ *
 * Tool directory
 * ------------------------------------------------------------------ */

.cat-block { margin-top: 42px; }

.cat-head {
  display: flex; align-items: baseline; gap: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
  margin-bottom: 18px;
}
.cat-head h2 { font-size: 19px; }
.cat-head p { margin: 0; color: var(--muted); font-size: 13.5px; flex: 1; }
.cat-head .n {
  font-family: var(--font-mono); font-size: 12px; color: var(--muted-2);
  font-variant-numeric: tabular-nums;
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(252px, 1fr));
  gap: 14px;
}

.tool-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 17px 18px 18px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow-1);
  transition: border-color .14s ease, transform .14s ease, box-shadow .14s ease;
}
.tool-card:hover {
  border-color: var(--brand-line);
  transform: translateY(-2px);
  box-shadow: var(--shadow-2);
  color: inherit;
}
.tool-card:focus-within { border-color: var(--brand); }

.tool-card .ico {
  width: 38px; height: 38px;
  border-radius: 9px;
  background: var(--brand-soft);
  color: var(--brand);
  display: grid; place-items: center;
  flex: 0 0 auto;
}
.tool-card .ico svg { width: 20px; height: 20px; }

.tool-card h3 { font-size: 15.5px; font-weight: 700; letter-spacing: -.01em; }
.tool-card p { margin: 0; font-size: 13.4px; color: var(--muted); line-height: 1.5; }

.badge {
  position: absolute; top: 14px; right: 14px;
  font: 700 9.5px var(--font-mono);
  letter-spacing: .09em; text-transform: uppercase;
  padding: 3px 7px; border-radius: 4px;
  background: var(--ok-soft); color: var(--ok);
}

.empty {
  text-align: center; padding: 54px 20px; color: var(--muted);
  border: 1px dashed var(--line); border-radius: var(--radius);
  margin-top: 26px;
}
.empty strong { display: block; color: var(--ink); margin-bottom: 6px; font-size: 16px; }

/* ------------------------------------------------------------------ *
 * Tool page
 * ------------------------------------------------------------------ */

.tool-page { max-width: 880px; margin: 0 auto; }

.crumbs { font-size: 13px; color: var(--muted); margin-bottom: 16px; }
.crumbs ol { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.crumbs a {
  text-decoration: none;
  color: var(--muted);
  display: inline-block;
  padding: 5px 3px;
  margin: -5px -3px;   /* the target grows, the visual position does not */
  border-radius: 3px;
}
.crumbs a:hover { color: var(--brand); text-decoration: underline; }
.crumbs li[aria-current] { color: var(--ink-2); font-weight: 600; }
.crumbs .sep { color: var(--muted-2); }

.tool-head { margin-bottom: 22px; }
.tool-head h1 { font-size: clamp(25px, 3.6vw, 33px); margin-bottom: 10px; }
.tool-head .lead { color: var(--muted); font-size: 16px; max-width: 66ch; }

.privacy-note {
  display: inline-flex; align-items: center; gap: 8px;
  margin-top: 14px;
  background: var(--ok-soft); color: var(--ok);
  border-radius: 999px; padding: 6px 13px 6px 10px;
  font-size: 12.8px; font-weight: 600;
}
.privacy-note svg { width: 14px; height: 14px; flex: 0 0 auto; }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-1);
}

.tool-section { margin-top: 34px; }
.tool-section > h2 {
  font-size: 18px;
  padding-bottom: 9px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
}

/* ------------------------------------------------------------------ *
 * Form controls
 * ------------------------------------------------------------------ */

.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .field-label {
  font-size: 12.6px; font-weight: 700; color: var(--ink-2);
  letter-spacing: .01em;
}
.field .help { font-size: 12.2px; color: var(--muted); }

input[type="text"], input[type="number"], input[type="search"], textarea, select {
  font: 400 14.5px var(--font-ui);
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  width: 100%;
}
textarea { font-family: var(--font-mono); font-size: 13.2px; line-height: 1.62; resize: vertical; min-height: 168px; }
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft);
}
input[type="color"] {
  padding: 2px; width: 46px; height: 36px; border: 1px solid var(--line);
  border-radius: var(--radius-sm); background: var(--surface); cursor: pointer;
}

/* The native track is only a few pixels tall. Giving the input real height
   enlarges the hit area for a finger without thickening the track itself. */
input[type="range"] { width: 100%; accent-color: var(--brand); height: 30px; cursor: pointer; }

.check { display: flex; align-items: center; gap: 9px; font-size: 14px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--brand); margin: 0; flex: 0 0 auto; }

.opts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(196px, 1fr));
  gap: 15px 18px;
  margin: 0 0 17px;
}
.opts:empty { display: none; }

.opt-value {
  font-family: var(--font-mono); font-size: 12.4px; color: var(--brand);
  font-weight: 500; font-variant-numeric: tabular-nums;
}

/* Buttons */

.btn {
  appearance: none;
  font: 700 14px var(--font-ui);
  border-radius: var(--radius-sm);
  padding: 10px 17px;
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  display: inline-flex; align-items: center; gap: 7px;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { background: var(--surface-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 15px; height: 15px; }

.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
/* color kept explicit on hover: applied on the live site by the owner, folded
   back in here so a full upload cannot silently revert it. */
.btn-primary:hover:not(:disabled) { background: var(--brand-strong); border-color: var(--brand-strong); color: white; }
:root[data-theme="dark"] .btn-primary { color: #0B0E13; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .btn-primary { color: #0B0E13; }
}

.btn-sm { font-size: 12.6px; padding: 6px 11px; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--ink); }

.btn-row { display: flex; flex-wrap: wrap; gap: 9px; align-items: center; }

/* ------------------------------------------------------------------ *
 * Dropzone + file list
 * ------------------------------------------------------------------ */

.dropzone {
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  padding: 34px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color .14s ease, background .14s ease;
  display: block;
  width: 100%;
  font: inherit;
  color: inherit;
}
.dropzone:hover, .dropzone.is-over { border-color: var(--brand); background: var(--brand-soft); }
.dropzone svg { width: 30px; height: 30px; color: var(--brand); margin-bottom: 9px; }
.dropzone b { display: block; font-size: 15.5px; font-weight: 700; margin-bottom: 4px; }
.dropzone span { display: block; font-size: 13px; color: var(--muted); }

.file-list { list-style: none; margin: 16px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.file-list li {
  display: flex; align-items: center; gap: 11px;
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  font-size: 13.4px;
}
.file-list .fname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.file-list .fsize { font-family: var(--font-mono); font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.file-list .thumb { width: 34px; height: 34px; border-radius: 5px; object-fit: cover; background: var(--line-soft); flex: 0 0 auto; }

/* ------------------------------------------------------------------ *
 * Results
 * ------------------------------------------------------------------ */

.result { margin-top: 18px; }
.result:empty { display: none; }

.result-head {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-bottom: 13px;
}
.result-head h3 { font-size: 15px; }
.result-head .spacer { flex: 1; }

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(104px, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 14px;
}
.stat-row div { background: var(--surface); padding: 10px 12px; }
.stat-row dt { font-size: 11px; color: var(--muted); font-weight: 600; letter-spacing: .02em; margin-bottom: 3px; }
.stat-row dd {
  margin: 0; font-size: 16px; font-weight: 700;
  font-variant-numeric: tabular-nums; letter-spacing: -.01em;
}
.stat-row dd.good { color: var(--ok); }
.stat-row dd.bad { color: var(--danger); }

.out-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.out-list li {
  display: flex; align-items: center; gap: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 11px 12px;
  background: var(--surface);
}
.out-list .thumb { width: 46px; height: 46px; border-radius: 6px; object-fit: cover; background: var(--surface-2); flex: 0 0 auto; }
.out-list .meta { flex: 1; min-width: 0; }
.out-list .meta b { display: block; font-size: 13.6px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.out-list .meta span { font-size: 12.3px; color: var(--muted); font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

.out-box {
  background: var(--code-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 13px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.62;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: auto;
  margin: 0;
  min-height: 60px;
  color: var(--ink-2);
}
.out-box.is-empty { color: var(--muted-2); }

.kv { display: flex; flex-direction: column; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.kv > div { background: var(--surface); display: flex; align-items: center; gap: 12px; padding: 10px 12px; flex-wrap: wrap; }
.kv dt { font-size: 12.4px; font-weight: 700; color: var(--muted); min-width: 92px; }
.kv dd { margin: 0; flex: 1; min-width: 140px; font-family: var(--font-mono); font-size: 13px; word-break: break-all; }

.msg {
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  font-size: 13.6px;
  margin-top: 14px;
  border: 1px solid transparent;
}
.msg-error { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 28%, transparent); }
.msg-ok { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 28%, transparent); }
.msg-warn { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }

.progress {
  height: 6px; border-radius: 999px; background: var(--surface-2);
  overflow: hidden; margin-top: 14px;
}
.progress i { display: block; height: 100%; background: var(--brand); width: 0; transition: width .18s ease; }

.spinner {
  width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid color-mix(in srgb, currentColor 30%, transparent);
  border-top-color: currentColor;
  animation: spin .7s linear infinite;
  flex: 0 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------------ *
 * Instructions / FAQ / related
 * ------------------------------------------------------------------ */

.steps { margin: 0; padding-left: 22px; color: var(--ink-2); }
.steps li { margin-bottom: 8px; }

.faq details {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  margin-bottom: 9px;
}
.faq summary {
  cursor: pointer;
  padding: 13px 15px;
  font-weight: 700;
  font-size: 14.5px;
  list-style: none;
  display: flex; align-items: center; gap: 10px;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: ""; margin-left: auto; width: 8px; height: 8px; flex: 0 0 auto;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(45deg) translate(-2px, -2px);
  transition: transform .16s ease;
}
.faq details[open] summary::after { transform: rotate(-135deg) translate(-2px, -2px); }
/* No reading-measure cap here. Inside a bordered card, text that stops short
   of the edge reads as a layout bug rather than as typography — the card is
   already narrow enough to keep the line length comfortable. */
.faq .a { padding: 0 15px 14px; color: var(--muted); font-size: 14px; }

.related-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(212px, 1fr)); gap: 12px; }
.related-grid a {
  display: block; text-decoration: none; color: inherit;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 13px 14px; background: var(--surface);
}
.related-grid a:hover { border-color: var(--brand-line); color: inherit; }
.related-grid b { display: block; font-size: 14px; font-weight: 700; margin-bottom: 3px; }
.related-grid span { font-size: 12.6px; color: var(--muted); line-height: 1.45; }

/* ------------------------------------------------------------------ *
 * Support page
 *
 * The pending state is a normal state, so it is styled as information —
 * not as a warning, and never as a disabled control.
 * ------------------------------------------------------------------ */

.support-reasons {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.support-reasons li {
  position: relative;
  padding-left: 26px;
  color: var(--ink-2);
  font-size: 14.6px;
  line-height: 1.55;
}

.support-reasons li::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 7px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--brand);
}

.support-pending {
  margin-top: 22px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.support-pending h2 {
  font-size: 16px;
  margin-bottom: 9px;
}

.support-pending p {
  color: var(--muted);
  font-size: 14.4px;
}

/* ---- contribution amount ---- */

.amount-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(78px, 1fr));
  gap: 10px;
  margin: 14px 0 0;
}

.amount-btn {
  appearance: none;
  font: 700 17px var(--font-ui);
  font-variant-numeric: tabular-nums;
  background: var(--surface);
  color: var(--ink);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px 8px;
  cursor: pointer;
  transition: border-color .12s ease, background .12s ease;
}
.amount-btn:hover { border-color: var(--brand-line); }
.amount-btn[aria-pressed="true"] {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand-strong);
  box-shadow: inset 0 0 0 1px var(--brand);
}

.amount-custom {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  max-width: 260px;
}
.amount-custom .cur {
  font: 700 16px var(--font-ui);
  color: var(--muted);
  flex: 0 0 auto;
}
.amount-custom input {
  font: 600 16px var(--font-ui);
  font-variant-numeric: tabular-nums;
}

.amount-summary {
  margin-top: 16px;
  padding: 13px 15px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--line);
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}
.amount-summary dt {
  font-size: 12.4px;
  font-weight: 700;
  color: var(--muted);
  margin: 0;
}
.amount-summary dd {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}
.amount-summary dd.none { font-size: 15px; font-weight: 600; color: var(--muted); }

/*
 * The return page reuses this list for the order reference, which is a single
 * 29-character unbroken token. At 22px on a 360px phone that is wider than the
 * screen, so the reference — and only the reference — is allowed to break and
 * set at a size that fits. An amount never needs either.
 */
.amount-summary dd.reference {
  font-size: 14px;
  font-weight: 600;
  font-family: var(--mono, ui-monospace, SFMono-Regular, Menlo, monospace);
  letter-spacing: 0;
  overflow-wrap: anywhere;
  word-break: break-all;
  min-width: 0;
}
.return-links { display: flex; flex-wrap: wrap; gap: 10px; }
.return-links .btn { margin-left: 0 !important; }

.support-action {
  margin-top: 22px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

/* ------------------------------------------------------------------ *
 * Footer
 * ------------------------------------------------------------------ */

.site-footer {
  flex: 0 0 auto;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding: 40px 0 30px;
  margin-top: 40px;
}

.footer-cols {
  display: grid;
  grid-template-columns: minmax(220px, 1.3fr) repeat(auto-fit, minmax(150px, 1fr));
  gap: 30px 26px;
}

.footer-cols h2 {
  font-size: 11px; letter-spacing: .11em; text-transform: uppercase;
  color: var(--muted); font-weight: 700; margin-bottom: 12px;
}
/* Padding rather than gap carries the spacing, so each link is a ~33px target
   on a phone instead of a 21px line of text with dead space around it. */
.footer-cols nav { display: flex; flex-direction: column; gap: 2px; }
.footer-cols nav a {
  font-size: 13.3px;
  color: var(--ink-2);
  text-decoration: none;
  padding: 6px 0;
  border-radius: 3px;
}
.footer-cols nav a:hover { color: var(--brand); }

.footer-brand p { font-size: 13.2px; color: var(--muted); margin: 12px 0 0; max-width: 34ch; }

.assoc {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 13px 15px;
  background: var(--surface-2);
}
.assoc a { font-weight: 700; font-size: 14px; text-decoration: none; display: inline-block; padding: 4px 0; }
.assoc p { margin: 5px 0 0; font-size: 12.6px; color: var(--muted); line-height: 1.5; }

.footer-legal {
  margin-top: 30px; padding-top: 18px;
  border-top: 1px solid var(--line);
  font-size: 12.6px; color: var(--muted);
  display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center;
}
.footer-legal a { color: var(--ink-2); display: inline-block; padding: 5px 2px; margin: -5px -2px; }

/* ------------------------------------------------------------------ *
 * Support reminder
 *
 * Sits in the corner, above nothing that matters. It is not a modal: no
 * overlay, no dimming, and the page stays fully usable behind it.
 * ------------------------------------------------------------------ */

.support-popup {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 70;
  width: min(320px, calc(100vw - 40px));
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
  padding: 16px 18px 17px;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity .2s ease, transform .2s ease;
}

.support-popup.is-in { opacity: 1; transform: translateY(0); }

.support-popup__title {
  margin: 0 22px 6px 0;
  font-weight: 800;
  font-size: 14.5px;
  letter-spacing: -.01em;
}

.support-popup__body {
  margin: 0 0 13px;
  font-size: 13.3px;
  line-height: 1.5;
  color: var(--muted);
}

.support-popup__close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  appearance: none;
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.support-popup__close:hover { background: var(--surface-2); color: var(--ink); }

/* The toast is transient and more urgent, so it steps above the reminder
   rather than landing on top of it. */
body.has-support-popup .toast { bottom: 26px; }

@media (max-width: 600px) {
  .support-popup {
    right: 12px;
    left: 12px;
    bottom: 12px;
    width: auto;
  }
  body.has-support-popup .toast { bottom: 168px; }
}

@media (prefers-reduced-motion: reduce) {
  .support-popup { transition: none; transform: none; }
}

/* ------------------------------------------------------------------ *
 * Toast + live region
 * ------------------------------------------------------------------ */

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 22px);
  background: var(--ink);
  color: var(--bg);
  padding: 11px 18px;
  border-radius: 999px;
  font-size: 13.6px;
  font-weight: 600;
  box-shadow: var(--shadow-2);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
  z-index: 90;
  max-width: calc(100vw - 40px);
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); color: #fff; }

/* ------------------------------------------------------------------ *
 * Responsive — tested at the §38 boundaries: 600/601 and 1098/1099
 * ------------------------------------------------------------------ */

@media (max-width: 1098px) {
  .wrap { padding: 0 18px; }
  .tool-grid { grid-template-columns: repeat(auto-fill, minmax(228px, 1fr)); }
}

@media (max-width: 600px) {
  body { font-size: 14.5px; }
  main { padding: 22px 0 44px; }
  .wrap { padding: 0 15px; }
  .site-header .wrap { min-height: 56px; gap: 10px; }
  .site-nav a { padding: 7px 8px; font-size: 13.4px; }
  .hero { padding: 6px 0 18px; }
  .hero .lead { font-size: 15px; }
  .tool-grid { grid-template-columns: 1fr; }
  .panel { padding: 15px; }
  .opts { grid-template-columns: 1fr; gap: 13px; }
  .btn { padding: 10px 14px; }
  .btn-row .btn { flex: 1 1 auto; justify-content: center; }
  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .footer-cols { grid-template-columns: 1fr; gap: 24px; }
  .out-list li { flex-wrap: wrap; }
  .kv dt { min-width: 100%; }
  .toast { bottom: 16px; }
}

/*
 * Very narrow phones.
 *
 * A second navigation link pushed the header past 320px. Rather than hide a
 * link behind a menu — which buries Support on the devices most likely to
 * need it — the header simply tightens: smaller mark, tighter padding, same
 * two links, tap targets still above 30px.
 */
@media (max-width: 400px) {
  .site-header .wrap { gap: 8px; }
  .brand { font-size: 15px; gap: 8px; }
  .brand img { width: 26px; height: 26px; }
  .site-nav { gap: 1px; }
  .site-nav a { padding: 7px 6px; font-size: 12.8px; }
  .theme-toggle { width: 32px; height: 32px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}

@media print {
  .site-header, .site-footer, .btn, .dropzone, .toast { display: none !important; }
}