/* ==========================================================================
   Frontend Essentials design system (fe.css)
   One file shared by every tool. Rules (see AGENTS.md):
   - Change the look of the whole site ONLY in Part 1 (settings).
   - Tools never hard-code colors, sizes or fonts. They use these variables.
   - A tool's own tool.css may only style things unique to that tool.
   ========================================================================== */

/* ==========================================================================
   PART 1: SETTINGS (design tokens)
   ========================================================================== */
/* Site font: Inter (variable, weights 100-900, Latin), self-hosted. SIL Open Font
   License: see assets/fonts/inter-license.txt. Other scripts fall back to system fonts. */
@font-face {
  font-family: "Inter";
  src: url("fonts/inter.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
:root {
  /* ---- Colors: light theme ---- */
  --fe-page: #f6f7fb;            /* page background (soft tint) */
  --fe-bg: #ffffff;              /* surfaces: panels, inputs, dialogs, cards */
  --fe-panel: #f3f4f8;           /* panel headers, hover backgrounds */
  --fe-border: #e2e4ec;
  --fe-border-hover: #c7cad6;
  --fe-text: #111827;            /* main text */
  --fe-muted: #5b6272;           /* secondary text, labels, captions */
  --fe-link: #4f46e5;
  --fe-accent: #4f46e5;          /* main buttons, active tabs, focus ring */
  --fe-accent-hover: #4338ca;
  --fe-on-accent: #ffffff;       /* text on accent */
  --fe-ring: #c7d2fe;            /* soft focus glow on inputs */
  --fe-sel: #e0e7ff;             /* selected row / line */
  --fe-accent-soft: #eef2ff;     /* tinted backgrounds: badges, icon tiles */
  --fe-accent-2: #0ea5e9;        /* second accent: small highlights only */
  --fe-header-bg: rgba(255, 255, 255, .85); /* sticky header (see-through) */
  --fe-hero: linear-gradient(180deg, #e8ebff 0%, #f6f7fb 100%); /* homepage hero band */
  --fe-shadow-card: 0 1px 2px rgba(17, 24, 39, .04), 0 1px 3px rgba(17, 24, 39, .06);
  --fe-shadow-card-hover: 0 6px 20px rgba(79, 70, 229, .12);

  --fe-ok: #15803d;   --fe-ok-bg: #f0fdf4;   --fe-ok-border: #bbf7d0;
  --fe-warn: #92400e; --fe-warn-bg: #fffbeb; --fe-warn-border: #fde68a;
  --fe-err: #b91c1c;  --fe-err-bg: #fef2f2;  --fe-err-border: #fecaca;

  /* code / syntax colors (for any tool that shows code) */
  --fe-syn-key: #9333ea; --fe-syn-str: #15803d; --fe-syn-num: #c2410c;
  --fe-syn-bool: #2563eb; --fe-syn-null: #6b7280;
  /* search highlights */
  --fe-hit: #fef9c3; --fe-hit-current: #fde68a; --fe-mark: #facc15; --fe-mark-text: #1f2328;

  /* ---- Typography ---- */
  --fe-font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; /* Inter is self-hosted in assets/fonts */
  --fe-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --fe-text-xs: 12px;    /* badges, counters */
  --fe-text-sm: 14px;    /* captions, notes, code */
  --fe-text-md: 15px;    /* buttons, inputs, labels */
  --fe-text-base: 16px;  /* body text */
  --fe-text-lead: 18px;  /* intro paragraph under the page title */
  --fe-h1: 32px;
  --fe-h2: 24px;
  --fe-h3: 18px;
  --fe-weight-medium: 500;
  --fe-weight-bold: 600;
  --fe-weight-heading: 700;
  --fe-leading: 1.5;         /* UI line height */
  --fe-leading-prose: 1.65;  /* article / help text line height */

  /* ---- Spacing scale ---- */
  --fe-s1: 4px; --fe-s2: 8px; --fe-s3: 12px; --fe-s4: 16px;
  --fe-s5: 24px; --fe-s6: 32px; --fe-s7: 48px;

  /* ---- Shape ---- */
  --fe-radius-sm: 6px;   /* small controls, code chips */
  --fe-radius: 8px;      /* buttons, inputs, status boxes */
  --fe-radius-lg: 10px;  /* panels */
  --fe-radius-xl: 12px;  /* dialogs, cards */

  /* ---- Layout ---- */
  --fe-max: 1200px;      /* content width */
  --fe-prose-max: 780px; /* readable width for help text */
  --fe-header-h: 56px;
  --fe-tap: 44px;        /* smallest tap target on touch screens (Apple: 44pt, Android: 48dp) */

  /* ---- Effects ---- */
  --fe-shadow-toast: 0 6px 20px rgba(0, 0, 0, .25);
  --fe-shadow-dialog: 0 20px 60px rgba(0, 0, 0, .35);
  --fe-shadow-menu: 0 8px 24px rgba(0, 0, 0, .18);
  --fe-backdrop: rgba(0, 0, 0, .45);
  --fe-speed: .15s;

  color-scheme: light;
}

/* ---- Phones: smaller headings, same 16px body text (sizes follow mobile guidance) ---- */
@media (max-width: 600px) {
  :root { --fe-h1: 26px; --fe-h2: 21px; --fe-h3: 17px; --fe-text-lead: 17px; }
}

/* ---- Colors: dark theme (auto, follows the system) ---- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --fe-page: #0f1117; --fe-bg: #171a23; --fe-panel: #1e2230;
    --fe-border: #2a2f3d; --fe-border-hover: #3b4254;
    --fe-text: #e5e7eb; --fe-muted: #9aa3b2; --fe-link: #a5b4fc;
    --fe-accent: #4f46e5; --fe-accent-hover: #6366f1; --fe-on-accent: #ffffff;
    --fe-ring: #3730a3; --fe-sel: #26285a;
    --fe-accent-soft: #1e1b4b; --fe-accent-2: #38bdf8;
    --fe-header-bg: rgba(15, 17, 23, .85);
    --fe-hero: linear-gradient(180deg, #1b1d3d 0%, #0f1117 100%);
    --fe-shadow-card: none; --fe-shadow-card-hover: 0 6px 20px rgba(0, 0, 0, .35);
    --fe-ok: #8fd19e;   --fe-ok-bg: #1f2d24;   --fe-ok-border: #2f4a37;
    --fe-warn: #e3c07a; --fe-warn-bg: #312a1a; --fe-warn-border: #5a4a26;
    --fe-err: #f19c96;  --fe-err-bg: #33201f;  --fe-err-border: #5a3130;
    --fe-syn-key: #c3a6f5; --fe-syn-str: #93c99a; --fe-syn-num: #e5a877;
    --fe-syn-bool: #a5b4fc; --fe-syn-null: #8d96a0;
    --fe-hit: #35301f; --fe-hit-current: #4a4022; --fe-mark: #e3c07a; --fe-mark-text: #1f2329;
    color-scheme: dark;
  }
}
/* ---- Colors: dark theme (chosen by the visitor) ---- */
:root[data-theme="dark"] {
  --fe-page: #0f1117; --fe-bg: #171a23; --fe-panel: #1e2230;
  --fe-border: #2a2f3d; --fe-border-hover: #3b4254;
  --fe-text: #e5e7eb; --fe-muted: #9aa3b2; --fe-link: #a5b4fc;
  --fe-accent: #4f46e5; --fe-accent-hover: #6366f1; --fe-on-accent: #ffffff;
  --fe-ring: #3730a3; --fe-sel: #26285a;
    --fe-accent-soft: #1e1b4b; --fe-accent-2: #38bdf8;
    --fe-header-bg: rgba(15, 17, 23, .85);
    --fe-hero: linear-gradient(180deg, #1b1d3d 0%, #0f1117 100%);
    --fe-shadow-card: none; --fe-shadow-card-hover: 0 6px 20px rgba(0, 0, 0, .35);
  --fe-ok: #8fd19e;   --fe-ok-bg: #1f2d24;   --fe-ok-border: #2f4a37;
  --fe-warn: #e3c07a; --fe-warn-bg: #312a1a; --fe-warn-border: #5a4a26;
  --fe-err: #f19c96;  --fe-err-bg: #33201f;  --fe-err-border: #5a3130;
  --fe-syn-key: #c3a6f5; --fe-syn-str: #93c99a; --fe-syn-num: #e5a877;
  --fe-syn-bool: #a5b4fc; --fe-syn-null: #8d96a0;
  --fe-hit: #35301f; --fe-hit-current: #4a4022; --fe-mark: #e3c07a; --fe-mark-text: #1f2329;
  color-scheme: dark;
}

/* ==========================================================================
   PART 2: BASE
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  display: flex; flex-direction: column; min-height: 100vh; /* footer stays at the bottom on short pages */
  background: var(--fe-page);
  color: var(--fe-text);
  font-family: var(--fe-font);
  font-size: var(--fe-text-base);
  line-height: var(--fe-leading);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--fe-link); }
a:hover { text-decoration-thickness: 2px; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--fe-accent); outline-offset: 2px; }
kbd {
  padding: 1px 5px; border: 1px solid var(--fe-border); border-radius: 4px;
  background: var(--fe-panel); color: var(--fe-text);
  font-family: var(--fe-font); font-size: var(--fe-text-xs);
}
code { font-family: var(--fe-mono); font-size: .92em; }
.fe-sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; margin: -1px; padding: 0; border: 0;
}

/* ==========================================================================
   PART 3: PAGE LAYOUT (every page uses these)
   ========================================================================== */
body > main { flex: 1 0 auto; width: 100%; }
.fe-wrap { max-width: calc(var(--fe-max) + 2 * var(--fe-s4)); margin: 0 auto; padding: 0 var(--fe-s4); }

.fe-skip {
  position: absolute; left: -9999px; top: var(--fe-s2); z-index: 100;
  padding: var(--fe-s2) var(--fe-s3); border: 2px solid var(--fe-accent); border-radius: var(--fe-radius-sm);
  background: var(--fe-page); color: var(--fe-text);
}
.fe-skip:focus { left: var(--fe-s4); }

/* Homepage hero: full-width tinted band, centered text */
.fe-hero { background: var(--fe-hero); border-bottom: 1px solid var(--fe-border); }
.fe-hero-inner { padding: var(--fe-s7) var(--fe-s4); text-align: center; }
.fe-hero h1 { margin: 0 auto var(--fe-s3); max-width: 800px; font-size: 44px; line-height: 1.15; letter-spacing: -.02em; font-weight: 800; }
.fe-hero h1 em { display: block; font-style: normal; color: var(--fe-link); }
.fe-hero .fe-lead { margin: 0 auto; max-width: 640px; font-size: 19px; }
@media (max-width: 600px) { .fe-hero h1 { font-size: 30px; } .fe-hero-inner { padding: var(--fe-s6) var(--fe-s4); } }

/* Tool search (homepage and All tools page) */
.fe-search { display: block; max-width: 520px; margin: var(--fe-s5) auto 0; }
.fe-search input {
  width: 100%; padding: 12px 16px 12px 44px; border: 1px solid var(--fe-border); border-radius: 999px;
  background: var(--fe-bg) no-repeat 16px center; color: var(--fe-text); font: inherit; font-size: var(--fe-text-base);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%238b93a3' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E");
  box-shadow: var(--fe-shadow-card);
}
.fe-search input:focus { outline: none; border-color: var(--fe-accent); box-shadow: 0 0 0 3px var(--fe-ring); }
.fe-search-left { margin-left: 0; }

/* Full-width page section (homepage, listing pages) */
.fe-section { margin: var(--fe-s7) 0 0; }
.fe-section > h2 { margin: 0 0 var(--fe-s4); font-size: var(--fe-h2); font-weight: var(--fe-weight-heading); }

/* 404 page buttons */
.fe-404-actions { display: flex; flex-wrap: wrap; gap: var(--fe-s3); margin: var(--fe-s5) 0 0; }

/* Header (filled in by fe.js) */
.fe-header {
  position: sticky; top: 0; z-index: 50;
  border-bottom: 1px solid var(--fe-border); background: var(--fe-header-bg);
  -webkit-backdrop-filter: saturate(180%) blur(10px); backdrop-filter: saturate(180%) blur(10px);
}
.fe-header .fe-wrap { display: flex; align-items: center; justify-content: space-between; gap: var(--fe-s4); min-height: var(--fe-header-h); flex-wrap: wrap; }
.fe-brand { display: inline-flex; align-items: center; gap: 10px; color: var(--fe-text); font-weight: var(--fe-weight-heading); font-size: 18px; letter-spacing: -.01em; text-decoration: none; }
.fe-brand:hover { color: var(--fe-text); }
.fe-brand-mark { display: inline-flex; width: 28px; height: 28px; flex: none; }
.fe-brand-mark svg { display: block; width: 100%; height: 100%; }
.fe-nav { display: flex; align-items: center; gap: var(--fe-s4); flex-wrap: wrap; }
.fe-nav a { color: var(--fe-muted); text-decoration: none; font-size: var(--fe-text-md); font-weight: var(--fe-weight-medium); }
.fe-nav a:hover, .fe-nav a[aria-current="page"] { color: var(--fe-accent); }

/* Breadcrumb */
.fe-breadcrumb { margin: var(--fe-s4) 0 0; font-size: var(--fe-text-sm); color: var(--fe-muted); }
.fe-breadcrumb ol { display: flex; flex-wrap: wrap; gap: var(--fe-s2); list-style: none; margin: 0; padding: 0; }
.fe-breadcrumb li + li::before { content: "\203A"; margin-right: var(--fe-s2); color: var(--fe-muted); }
.fe-breadcrumb a { color: var(--fe-muted); text-decoration: none; }
.fe-breadcrumb a:hover { color: var(--fe-link); text-decoration: underline; }

/* Page title + intro */
.fe-intro { padding: var(--fe-s5) 0 var(--fe-s1); }
.fe-intro h1 { margin: 0 0 var(--fe-s2); font-size: var(--fe-h1); line-height: 1.25; font-weight: var(--fe-weight-heading); }
.fe-lead { margin: 0; max-width: var(--fe-prose-max); color: var(--fe-muted); font-size: var(--fe-text-lead); line-height: var(--fe-leading-prose); }
.fe-intro-meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--fe-s3); margin-top: var(--fe-s3); font-size: var(--fe-text-sm); color: var(--fe-muted); }

/* Tool pages: compact intro so the tool fits on the first screen.
   h1 and the version line share one row; the one-line lead sits under them. */
.fe-intro-tool { display: flex; flex-wrap: wrap; align-items: center; column-gap: var(--fe-s4); row-gap: var(--fe-s1); padding: var(--fe-s3) 0 0; }
.fe-intro-tool h1 { order: 1; margin: 0; }
.fe-intro-tool .fe-intro-meta { order: 2; margin: 0; }
.fe-intro-tool .fe-lead { order: 3; flex: 1 0 100%; font-size: var(--fe-text-md); }
.fe-intro-tool + .fe-tool { margin-top: var(--fe-s3); }

/* The tool area */
.fe-tool { margin: var(--fe-s4) 0 0; }

/* Fit-to-screen tools: add data-fe-fit to .fe-panes. fe.js sets --fe-fit-h so the
   whole tool (toolbar, panels, status) fits in the first screen on laptops and up. */
@media (min-width: 761px) {
  .fe-panes[data-fe-fit] { height: var(--fe-fit-h, 560px); }
  .fe-panes[data-fe-fit] > .fe-pane { min-height: 0; }
  .fe-panes[data-fe-fit] > .fe-pane > .fe-textarea { flex: 1 1 0; min-height: 0; resize: none; }
}
@media (max-width: 760px) {
  .fe-panes[data-fe-fit] > .fe-pane > .fe-textarea { height: 38vh; min-height: 200px; }
}

/* Help / SEO content below the tool */
.fe-content { max-width: var(--fe-prose-max); margin: var(--fe-s7) 0 0; line-height: var(--fe-leading-prose); }
.fe-content section { margin: 0 0 var(--fe-s6); }
.fe-content h2 { margin: 0 0 var(--fe-s3); font-size: var(--fe-h2); line-height: 1.3; font-weight: var(--fe-weight-heading); }
.fe-content h3 { margin: var(--fe-s4) 0 var(--fe-s2); font-size: var(--fe-h3); line-height: 1.35; font-weight: var(--fe-weight-bold); }
.fe-content p { margin: 0 0 var(--fe-s3); }
.fe-content ul, .fe-content ol { margin: 0 0 var(--fe-s3); padding-left: var(--fe-s5); }
.fe-content li { margin: 0 0 var(--fe-s1); }
.fe-content pre {
  margin: 0 0 var(--fe-s3); padding: var(--fe-s3); overflow: auto;
  border: 1px solid var(--fe-border); border-radius: var(--fe-radius); background: var(--fe-panel);
  font-family: var(--fe-mono); font-size: var(--fe-text-sm); line-height: 1.55;
}
.fe-content table, .fe-table { width: 100%; margin: 0 0 var(--fe-s3); border-collapse: collapse; font-size: var(--fe-text-md); }
.fe-content th, .fe-content td, .fe-table th, .fe-table td { padding: var(--fe-s2) var(--fe-s3); border-bottom: 1px solid var(--fe-border); text-align: left; vertical-align: top; }
.fe-content th, .fe-table th { font-weight: var(--fe-weight-bold); }
/* Wide tables scroll inside their own box on phones: <div class="fe-table-wrap"><table class="fe-table">… */
.fe-table-wrap { overflow-x: auto; margin: 0 0 var(--fe-s3); }
.fe-table-wrap table { margin: 0; min-width: 560px; }
.fe-content td code { overflow-wrap: anywhere; }

/* Feature grid */
.fe-features { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--fe-s3); margin: 0; padding: 0; list-style: none; }
.fe-content .fe-features { padding: 0; }
.fe-features li { position: relative; margin: 0; padding: 0 0 0 40px; } /* plain list, not cards: only tools look clickable */
.fe-features li::before { content: ""; position: absolute; left: 0; top: 0; width: 28px; height: 28px; border-radius: 50%; background: var(--fe-accent-soft); }
.fe-features li::after {
  content: ""; position: absolute; left: 6px; top: 6px; width: 16px; height: 16px; background: var(--fe-link);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7'/%3E%3C/svg%3E") center / contain no-repeat;
}
.fe-features strong { display: block; margin-bottom: var(--fe-s1); font-weight: var(--fe-weight-bold); }
.fe-features span { color: var(--fe-muted); font-size: var(--fe-text-md); line-height: var(--fe-leading); }

/* FAQ */
.fe-faq details, details.fe-accordion { border-bottom: 1px solid var(--fe-border); }
.fe-faq summary, details.fe-accordion > summary { cursor: pointer; padding: var(--fe-s3) 0; font-weight: var(--fe-weight-bold); list-style-position: inside; }
.fe-faq details > div, details.fe-accordion > div { padding: 0 0 var(--fe-s3); color: var(--fe-text); }

/* Cards (related tools, All tools page) */
.fe-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--fe-s3); margin: 0; padding: 0; list-style: none; }
.fe-content .fe-cards { padding: 0; }
.fe-card { display: block; height: 100%; padding: var(--fe-s4) var(--fe-s5); border: 1px solid var(--fe-border); border-radius: var(--fe-radius-xl); background: var(--fe-bg); color: var(--fe-text); text-decoration: none; box-shadow: var(--fe-shadow-card); transition: border-color var(--fe-speed), box-shadow var(--fe-speed), transform var(--fe-speed); }
a.fe-card:hover { border-color: var(--fe-accent); box-shadow: var(--fe-shadow-card-hover); transform: translateY(-2px); }
.fe-card-empty { border-style: dashed; box-shadow: none; text-align: center; }
.fe-card h3 { margin: 0 0 var(--fe-s1); font-size: var(--fe-h3); }
.fe-card p { margin: 0; color: var(--fe-muted); font-size: var(--fe-text-md); line-height: var(--fe-leading); }

/* Tool cards: icon, category tag and an "Open tool" link, so they read as clickable on phones too */
.fe-tool-card { display: flex; flex-direction: column; gap: var(--fe-s2); border-top: 3px solid var(--fe-accent); }
.fe-tool-card-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--fe-s1); }
.fe-tool-card-icon { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: var(--fe-radius); background: var(--fe-accent-soft); color: var(--fe-link); }
.fe-tool-card-tag { padding: 2px var(--fe-s2); border-radius: 999px; background: var(--fe-panel); color: var(--fe-muted); font-size: var(--fe-text-xs); font-weight: var(--fe-weight-medium); }
.fe-tool-card h3 { margin: 0; }
.fe-tool-card p { flex: 1; }
.fe-tool-card-go { display: inline-flex; align-items: center; gap: 6px; margin-top: var(--fe-s2); color: var(--fe-link); font-size: var(--fe-text-md); font-weight: var(--fe-weight-bold); }
.fe-tool-card-go svg { transition: transform var(--fe-speed); }
a.fe-tool-card:hover .fe-tool-card-go svg { transform: translateX(3px); }

/* Round icon button (header theme switch) */
.fe-icon-btn, .fe-btn-icon {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border: 1px solid var(--fe-border); border-radius: 50%;
  background: var(--fe-bg); color: var(--fe-text); cursor: pointer;
}
.fe-icon-btn:hover, .fe-btn-icon:hover, .fe-menu[open] > .fe-icon-btn, .fe-menu[open] > .fe-btn-icon { border-color: var(--fe-border-hover); background: var(--fe-panel); }
.fe-theme-menu > summary::after { display: none; }
.fe-theme-menu .fe-menu-panel { min-width: 170px; }
.fe-theme-menu .fe-menu-item { gap: var(--fe-s2); }
.fe-theme-menu .fe-menu-item[aria-checked="true"] { color: var(--fe-link); font-weight: var(--fe-weight-bold); background: var(--fe-accent-soft); }

/* Footer (filled in by fe.js) */
.fe-footer { margin-top: var(--fe-s7); padding: var(--fe-s5) 0; border-top: 1px solid var(--fe-border); color: var(--fe-muted); font-size: var(--fe-text-sm); }
.fe-footer a { color: var(--fe-muted); }
.fe-footer-links { display: flex; flex-wrap: wrap; gap: var(--fe-s2) var(--fe-s5); margin: 0 0 var(--fe-s3); font-size: var(--fe-text-md); }
.fe-footer-links a { color: var(--fe-text); text-decoration: none; }
.fe-footer-links a:hover, .fe-footer-links a[aria-current="page"] { color: var(--fe-link); text-decoration: underline; }
.fe-footer-text { margin: 0; }
/* Phones: footer links in two columns, each a full tap row (owner's choice, Decisions log) */
@media (max-width: 600px) {
  .fe-footer-links { display: grid; grid-template-columns: 1fr 1fr; gap: 0 var(--fe-s4); }
  .fe-footer-links a, .fe-footer-btn { display: flex; align-items: center; min-height: var(--fe-tap); text-align: left; }
}
@media (pointer: coarse) { .fe-nav a { display: inline-flex; align-items: center; min-height: var(--fe-tap); } }
.fe-footer-btn { padding: 0; border: 0; background: none; color: var(--fe-text); font: inherit; cursor: pointer; }
.fe-footer-btn:hover { color: var(--fe-link); text-decoration: underline; }

/* Cookie consent banner (drawn by fe.js) */
.fe-consent {
  position: fixed; left: var(--fe-s4); right: var(--fe-s4); bottom: var(--fe-s4); z-index: 60;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--fe-s3) var(--fe-s5);
  max-width: 760px; margin: 0 auto; padding: var(--fe-s4) var(--fe-s5);
  border: 1px solid var(--fe-border); border-radius: var(--fe-radius-xl); background: var(--fe-bg); box-shadow: var(--fe-shadow-dialog);
}
.fe-consent-text { flex: 1 1 320px; margin: 0; font-size: var(--fe-text-md); line-height: var(--fe-leading); }
.fe-consent-btns { display: flex; gap: var(--fe-s2); }

/* ==========================================================================
   PART 4: CONTROLS AND COMPONENTS (for building tools)
   ========================================================================== */

/* Toolbar row above a tool */
.fe-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--fe-s2); margin: 0 0 var(--fe-s3); }
.fe-spacer { flex: 1; }

/* Buttons */
.fe-btn {
  appearance: none; display: inline-flex; align-items: center; justify-content: center; gap: var(--fe-s1);
  margin: 0; padding: var(--fe-s2) 14px;
  border: 1px solid var(--fe-border); border-radius: var(--fe-radius);
  background: var(--fe-bg); color: var(--fe-text);
  font: inherit; font-size: var(--fe-text-md); font-weight: var(--fe-weight-medium); line-height: 1.2;
  text-transform: none; letter-spacing: normal; text-decoration: none; box-shadow: none; cursor: pointer;
  transition: background var(--fe-speed), border-color var(--fe-speed);
}
.fe-btn:hover { background: var(--fe-panel); border-color: var(--fe-border-hover); color: var(--fe-text); }
.fe-btn-primary, .fe-primary { background: var(--fe-accent); border-color: var(--fe-accent); color: var(--fe-on-accent); }
.fe-btn-primary:hover, .fe-primary:hover { background: var(--fe-accent-hover); border-color: var(--fe-accent-hover); color: var(--fe-on-accent); }
.fe-btn-sm, .fe-small { padding: var(--fe-s1) 10px; font-size: var(--fe-text-sm); }

/* Label + control pairs (dropdowns, checkboxes) */
.fe-field { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-size: var(--fe-text-md); font-weight: 400; color: var(--fe-muted); }
.fe-field input[type="checkbox"], .fe-field input[type="radio"] { margin: 0; width: 16px; height: 16px; accent-color: var(--fe-accent); }
select.fe-select, .fe-field select {
  margin: 0; padding: 6px 32px 6px var(--fe-s3); width: auto; height: auto;
  -webkit-appearance: none; appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5 6 8l3.5-3.5' fill='none' stroke='%238b93a3' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
  border: 1px solid var(--fe-border); border-radius: var(--fe-radius);
  background-color: var(--fe-bg); color: var(--fe-text);
  font: inherit; font-size: var(--fe-text-md); text-transform: none; letter-spacing: normal;
}
select.fe-select:hover, .fe-field select:hover { border-color: var(--fe-border-hover); }

/* Text inputs */
.fe-input {
  margin: 0; padding: 6px 10px; width: 100%; height: auto; min-width: 0;
  border: 1px solid var(--fe-border); border-radius: var(--fe-radius-sm);
  background: var(--fe-bg); color: var(--fe-text);
  font: inherit; font-size: var(--fe-text-sm); text-transform: none; letter-spacing: normal; box-shadow: none;
}
.fe-input:focus { outline: none; border-color: var(--fe-accent); box-shadow: 0 0 0 2px var(--fe-ring); }
.fe-textarea {
  display: block; width: 100%; margin: 0; padding: var(--fe-s3);
  border: 0; border-radius: 0; background: var(--fe-bg); color: var(--fe-text);
  font-family: var(--fe-mono); font-size: var(--fe-text-sm); line-height: 1.55; tab-size: 4;
  resize: vertical; box-shadow: none; text-transform: none; letter-spacing: normal;
}
.fe-textarea:focus { outline: none; box-shadow: inset 0 0 0 2px var(--fe-accent); }
.fe-input::placeholder, .fe-textarea::placeholder { color: var(--fe-muted); opacity: 1; }

/* Side-by-side panels (input / output) */
.fe-panes { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--fe-s3); }
@media (max-width: 760px) { .fe-panes { grid-template-columns: minmax(0, 1fr); } }
.fe-pane { position: relative; display: flex; flex-direction: column; min-width: 0; border: 1px solid var(--fe-border); border-radius: var(--fe-radius-lg); background: var(--fe-bg); overflow: hidden; }
.fe-pane-head { display: flex; justify-content: space-between; align-items: center; gap: var(--fe-s2); padding: var(--fe-s2) var(--fe-s3); border-bottom: 1px solid var(--fe-border); background: var(--fe-panel); font-size: var(--fe-text-sm); font-weight: var(--fe-weight-bold); color: var(--fe-muted); }
.fe-pane-foot { display: flex; align-items: center; gap: var(--fe-s2); flex-wrap: wrap; padding: var(--fe-s2) var(--fe-s3); border-top: 1px solid var(--fe-border); background: var(--fe-panel); }
.fe-actions { display: flex; align-items: center; gap: 6px; }
.fe-meta { font-weight: 400; font-size: var(--fe-text-sm); color: var(--fe-muted); }

/* Drag-and-drop overlay: add .fe-drop to a .fe-pane; label comes from data-drop-label */
.fe-pane.fe-drop { border-color: var(--fe-accent); box-shadow: 0 0 0 2px var(--fe-ring); }
.fe-pane.fe-drop::after {
  content: attr(data-drop-label); position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--fe-bg); opacity: .94; color: var(--fe-accent);
  font-size: var(--fe-text-lead); font-weight: var(--fe-weight-bold); border-radius: var(--fe-radius-lg); pointer-events: none;
}

/* Tabs */
.fe-tabs { display: inline-flex; border: 1px solid var(--fe-border); border-radius: 7px; overflow: hidden; }
.fe-tab {
  appearance: none; margin: 0; padding: var(--fe-s1) var(--fe-s3); border: 0; border-radius: 0;
  background: var(--fe-bg); color: var(--fe-muted);
  font: inherit; font-size: var(--fe-text-xs); font-weight: var(--fe-weight-bold); line-height: 1.3;
  text-transform: none; letter-spacing: normal; box-shadow: none; cursor: pointer;
}
.fe-tab:hover { background: var(--fe-panel); color: var(--fe-text); }
.fe-tab.active, .fe-tab[aria-selected="true"] { background: var(--fe-accent); color: var(--fe-on-accent); }
.fe-tab:focus-visible { outline-offset: -3px; }

/* Menus: keep the first screen simple, put extra options one click away.
   <details class="fe-menu"><summary class="fe-btn">Options</summary><div class="fe-menu-panel">…</div></details>
   Add .fe-menu-end to open toward the left (for menus on the right edge). fe.js closes
   open menus on outside click and Esc. */
.fe-menu { position: relative; display: inline-block; }
.fe-menu > summary { list-style: none; }
.fe-menu > summary::-webkit-details-marker { display: none; }
.fe-menu > summary::after { content: ""; width: 6px; height: 6px; margin-left: 2px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: translateY(-2px) rotate(45deg); opacity: .7; }
.fe-menu[open] > summary { background: var(--fe-panel); border-color: var(--fe-border-hover); }
.fe-menu-panel {
  position: absolute; z-index: 30; top: calc(100% + var(--fe-s1)); left: 0;
  display: flex; flex-direction: column; align-items: stretch; gap: var(--fe-s1);
  min-width: 220px; padding: var(--fe-s2);
  border: 1px solid var(--fe-border); border-radius: var(--fe-radius-lg);
  background: var(--fe-bg); box-shadow: var(--fe-shadow-menu);
  font-weight: 400; color: var(--fe-text);
}
.fe-menu-end .fe-menu-panel { left: auto; right: 0; }
.fe-menu-panel .fe-field { justify-content: space-between; padding: 6px var(--fe-s2); border-radius: var(--fe-radius-sm); color: var(--fe-text); }
.fe-menu-panel .fe-field:has(input[type="checkbox"]) { justify-content: flex-start; cursor: pointer; }
.fe-menu-panel .fe-field:hover { background: var(--fe-panel); }
.fe-menu-item {
  appearance: none; display: flex; align-items: center; width: 100%; margin: 0; padding: 6px var(--fe-s2);
  border: 0; border-radius: var(--fe-radius-sm); background: transparent; color: var(--fe-text);
  font: inherit; font-size: var(--fe-text-md); text-align: left; text-transform: none; letter-spacing: normal; box-shadow: none; cursor: pointer;
}
.fe-menu-item:hover { background: var(--fe-panel); }
.fe-menu-hint { padding: 0 var(--fe-s2) var(--fe-s1); font-size: var(--fe-text-xs); color: var(--fe-muted); }

/* Status box (result of an action) */
.fe-status { margin: var(--fe-s3) 0 0; padding: 10px 14px; border: 1px solid var(--fe-border); border-radius: var(--fe-radius); background: var(--fe-panel); color: var(--fe-muted); font-size: var(--fe-text-md); }
.fe-status.ok { color: var(--fe-ok); background: var(--fe-ok-bg); border-color: var(--fe-ok-border); }
.fe-status.warn { color: var(--fe-warn); background: var(--fe-warn-bg); border-color: var(--fe-warn-border); }
.fe-status.err { color: var(--fe-err); background: var(--fe-err-bg); border-color: var(--fe-err-border); }
.fe-status-detail, .fe-status .fe-fixlist { display: block; margin-top: var(--fe-s1); font-size: var(--fe-text-sm); }
.fe-status .fe-btn { margin-top: var(--fe-s2); }
.fe-status.fe-busy::before {
  content: ""; display: inline-block; width: 12px; height: 12px; margin-right: var(--fe-s2); vertical-align: -1px;
  border: 2px solid var(--fe-border); border-top-color: var(--fe-accent); border-radius: 50%;
  animation: fe-spin .8s linear infinite;
}
@keyframes fe-spin { to { transform: rotate(360deg); } }

/* Small print under a tool, and the keyboard shortcuts list */
.fe-note { margin: var(--fe-s2) 0 0; font-size: var(--fe-text-sm); color: var(--fe-muted); }
.fe-keys { margin: var(--fe-s2) 0 0; font-size: var(--fe-text-sm); color: var(--fe-muted); }
.fe-keys summary { cursor: pointer; display: inline-block; padding: 2px var(--fe-s1); border-radius: 4px; }
.fe-keys ul { margin: 6px 0 0 18px; padding: 0; line-height: 1.9; }
.fe-keys li { margin: 0; padding: 0; }

/* Badges (changelog types, labels) */
.fe-badge { display: inline-block; padding: 1px var(--fe-s2); border-radius: 999px; border: 1px solid var(--fe-border); background: var(--fe-panel); color: var(--fe-muted); font-size: var(--fe-text-xs); font-weight: var(--fe-weight-bold); line-height: 1.6; vertical-align: middle; }
.fe-badge.added { color: var(--fe-ok); background: var(--fe-ok-bg); border-color: var(--fe-ok-border); }
.fe-badge.changed { color: var(--fe-link); background: var(--fe-sel); border-color: var(--fe-ring); }
.fe-badge.fixed { color: var(--fe-warn); background: var(--fe-warn-bg); border-color: var(--fe-warn-border); }
.fe-badge.removed, .fe-badge.security { color: var(--fe-err); background: var(--fe-err-bg); border-color: var(--fe-err-border); }

/* Changelog list (dialog and changelog page) */
.fe-changelog, .fe-content .fe-changelog, .fe-content .fe-changelog ul { margin: 0; padding: 0; list-style: none; }
.fe-changelog > li { margin: 0 0 var(--fe-s5); }
.fe-changelog h2, .fe-changelog h3 { display: flex; align-items: baseline; gap: var(--fe-s2); flex-wrap: wrap; margin: 0 0 var(--fe-s2); font-size: var(--fe-h3); }
.fe-changelog time { color: var(--fe-muted); font-size: var(--fe-text-sm); font-weight: 400; }
.fe-changelog ul { margin: 0; padding: 0; list-style: none; }
.fe-changelog ul li { display: flex; gap: var(--fe-s2); align-items: baseline; margin: 0 0 6px; line-height: var(--fe-leading); }
.fe-changelog ul li .fe-badge { flex: none; min-width: 70px; text-align: center; }

/* Toasts (short "Copied" messages) */
.fe-toasts { position: fixed; left: 50%; bottom: var(--fe-s5); transform: translateX(-50%); z-index: 9999; margin: 0; display: flex; flex-direction: column; align-items: center; gap: var(--fe-s2); pointer-events: none; }
.fe-toast { max-width: min(560px, 90vw); padding: 9px var(--fe-s4); border-radius: var(--fe-radius); background: var(--fe-text); color: var(--fe-bg); font-size: var(--fe-text-md); box-shadow: var(--fe-shadow-toast); opacity: 0; transform: translateY(8px); transition: opacity .18s, transform .18s; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fe-toast.show { opacity: 1; transform: none; }
.fe-toast.ok { background: var(--fe-ok-bg); color: var(--fe-ok); border: 1px solid var(--fe-ok-border); }
.fe-toast.err { background: var(--fe-err-bg); color: var(--fe-err); border: 1px solid var(--fe-err-border); }

/* Dialog (opened with FE.dialog) */
.fe-dialog { width: min(620px, 92vw); max-height: 85vh; margin: auto; padding: 0; border: 1px solid var(--fe-border); border-radius: var(--fe-radius-xl); background: var(--fe-bg); color: var(--fe-text); box-shadow: var(--fe-shadow-dialog); font-family: var(--fe-font); font-size: var(--fe-text-md); }
.fe-dialog::backdrop { background: var(--fe-backdrop); }
.fe-dlg-head { position: sticky; top: 0; display: flex; align-items: center; justify-content: space-between; gap: var(--fe-s3); padding: var(--fe-s3) var(--fe-s4); border-bottom: 1px solid var(--fe-border); background: var(--fe-panel); }
.fe-dlg-title { margin: 0; font-size: var(--fe-text-lead); font-weight: var(--fe-weight-bold); line-height: 1.3; color: var(--fe-text); }
.fe-dlg-body { padding: var(--fe-s4); }
.fe-dlg-body p { margin: 0 0 10px; line-height: var(--fe-leading); }
.fe-dlg-muted { color: var(--fe-muted); font-size: var(--fe-text-sm); }
.fe-dlg-row { display: flex; gap: var(--fe-s2); flex-wrap: wrap; margin-top: var(--fe-s3); }
.fe-dlg-link { display: block; width: 100%; margin: 0 0 6px; padding: var(--fe-s2) 10px; border: 1px solid var(--fe-border); border-radius: var(--fe-radius); background: var(--fe-panel); color: var(--fe-text); font-family: var(--fe-mono); font-size: var(--fe-text-xs); word-break: break-all; height: auto; }

/* Print: hide chrome */
/* ==========================================================================
   ATOMS: the smallest building blocks. One class per atom, plus variant classes.
   Tools use ONLY these (never their own sizes, colours or fonts).
   Full list with variants: AGENTS.md section 5 > Component catalogue.
   ========================================================================== */

/* Heading: .fe-h1 (page title) · .fe-h2 (section) · .fe-h3 (card / sub-section) */
.fe-h1, .fe-h2, .fe-h3 { margin: 0; color: var(--fe-text); font-weight: var(--fe-weight-heading); }
.fe-h1 { font-size: var(--fe-h1); line-height: 1.25; }
.fe-h2 { font-size: var(--fe-h2); line-height: 1.3; }
.fe-h3 { font-size: var(--fe-h3); line-height: 1.35; font-weight: var(--fe-weight-bold); }

/* Text: .fe-lead (intro line) · .fe-text (body) · .fe-note (small grey note) · .fe-meta (tiny counters) */
.fe-text { margin: 0; font-size: var(--fe-text-base); line-height: var(--fe-leading-prose); }

/* Link: <a> (default) · .fe-link-muted (breadcrumbs, quiet links) · .fe-link-nav (menus, footer) */
.fe-link-muted { color: var(--fe-muted); text-decoration: none; }
.fe-link-muted:hover { color: var(--fe-link); text-decoration: underline; }
.fe-link-nav { color: var(--fe-text); text-decoration: none; font-weight: var(--fe-weight-medium); }
.fe-link-nav:hover, .fe-link-nav[aria-current="page"] { color: var(--fe-link); }

/* Button: .fe-btn (secondary) · .fe-btn-primary · .fe-btn-sm (small) · .fe-btn-icon (round, icon only; needs aria-label) */

/* Select: .fe-select · .fe-select-compact (narrow, long text ends in "...") */
select.fe-select-compact, .fe-field select.fe-select-compact { max-width: 190px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

/* Checkbox: input.fe-checkbox (or any checkbox inside .fe-field) */
input.fe-checkbox { margin: 0; width: 16px; height: 16px; accent-color: var(--fe-accent); }

/* Code: <code> (inline) · .fe-code-block (multi-line example; <pre> inside help content looks the same) */
.fe-code-block {
  margin: 0 0 var(--fe-s3); padding: var(--fe-s3); overflow: auto;
  border: 1px solid var(--fe-border); border-radius: var(--fe-radius); background: var(--fe-panel);
  font-family: var(--fe-mono); font-size: var(--fe-text-sm); line-height: 1.55;
}

/* Keyboard key: <kbd> · Badge: .fe-badge + .added / .changed / .fixed / .removed · Icon: FE.icon(name, size) in fe.js */

/* ---- Touch screens: every tappable control is at least --fe-tap (44px) tall ---- */
@media (pointer: coarse) {
  .fe-btn, .fe-menu-item, select.fe-select, .fe-field select, .fe-input { min-height: var(--fe-tap); }
  .fe-btn-icon, .fe-icon-btn { width: var(--fe-tap); height: var(--fe-tap); }
  input.fe-checkbox, .fe-field input[type="checkbox"] { width: 20px; height: 20px; }
}
/* ---- Phones: text boxes at least 16px so iPhone Safari doesn't zoom in when tapped ---- */
@media (max-width: 760px) {
  .fe-input, .fe-textarea, select.fe-select, .fe-field select { font-size: 16px; }
}

@media print { .fe-header, .fe-footer, .fe-toolbar, .fe-skip, .fe-consent { display: none !important; } }
