*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; font-synthesis: none; }
/* The hidden attribute always wins, even over components that set their own display (e.g. buttons). */
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: var(--text-body); font-weight: 400; line-height: 1.6; }
em, i, cite, address, dfn, var { font-style: normal; }
b, strong, h1, h2, h3, th { font-weight: 700; }
h1 { font-size: var(--text-title); line-height: 1.25; margin: 0 0 var(--space-1); }
h2 { font-size: var(--text-heading); line-height: 1.3; margin: 0 0 var(--space-1); }
h3 { font-size: var(--text-body); margin: var(--space-3) 0 var(--space-1); }
a { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--accent); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
/* Off-screen buffer for the legacy copy path: selectable, and preserves whitespace exactly. */
.clipboard-buffer { position: fixed; top: 0; left: 0; width: 1px; height: 1px; padding: 0; border: 0; opacity: 0; pointer-events: none; white-space: pre; }
.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; user-select: none; }
.skip-link { position: absolute; left: var(--space-2); top: -64px; z-index: 10; padding: var(--space-1) var(--space-2); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.skip-link:focus { top: var(--space-1); }

/* Chrome: identical height, position and behaviour on every page. */
.site-header { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "brand nav theme"; align-items: center; gap: var(--space-3); height: 72px; padding: 0 var(--space-3); background: var(--surface); border-bottom: 1px solid var(--border); }
.brand { grid-area: brand; font-size: var(--text-heading); font-weight: 700; color: var(--text); text-decoration: none; }
.site-nav { grid-area: nav; min-width: 0; overflow-x: auto; }
.theme-toggle { grid-area: theme; }
@media (max-width: 767px) {
  .site-header { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "brand theme" "nav nav"; height: 120px; padding: var(--space-1) var(--space-2); row-gap: var(--space-1); }
}

/* Tool switcher: real links styled as a segmented control; the current page is filled with the accent. */
.site-nav ul { display: inline-flex; margin: 0; padding: 0; list-style: none; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.site-nav li + li { border-left: 1px solid var(--border); }
.site-nav a { display: flex; align-items: center; height: var(--control-height); padding: 0 var(--space-2); white-space: nowrap; color: var(--text); text-decoration: none; }
.site-nav a:hover { background: var(--surface-2); }
.site-nav a:focus-visible { outline-offset: -3px; }
.site-nav a[aria-current="page"] { background: var(--accent); color: var(--on-accent); font-weight: 700; }
.site-nav a[aria-current="page"]:focus-visible { outline-color: var(--on-accent); }

.page { max-width: 1200px; margin: 0 auto; padding: var(--space-4) var(--space-2) var(--space-5); }
.site-footer { padding: var(--space-3) var(--space-2); border-top: 1px solid var(--border); color: var(--text-muted); font-size: var(--text-small); text-align: center; }
.site-footer p { margin: var(--space-1) 0; }
.site-footer a { color: var(--text-muted); }
.lede { max-width: 70ch; margin: 0 0 var(--space-3); color: var(--text-muted); }

/* Buttons: exactly two variants. Default = secondary (outlined); .btn-primary = filled accent. */
button, a.btn-primary { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-1); min-height: var(--control-height); padding: 0 var(--space-2); font: inherit; font-weight: 400; color: var(--text); background: transparent; border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer; text-decoration: none; }
button:hover:not(:disabled) { border-color: var(--text); }
button:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary, a.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 700; }
.btn-primary:hover:not(:disabled) { border-color: var(--on-accent); }

/* Form inputs: same height, label above, same focus state across every tool. */
.field-label { display: block; margin: 0 0 var(--space-1); font-weight: 700; }
input[type="text"], input[type="number"], textarea { width: 100%; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
input[type="text"], input[type="number"] { height: var(--control-height); padding: 0 12px; }
textarea { min-height: 12rem; padding: 12px; font-family: var(--font-mono); line-height: 1.6; resize: vertical; }
input:focus-visible, textarea:focus-visible { outline: 2px solid var(--focus); outline-offset: 0; border-color: var(--focus); }
[aria-invalid="true"] { border: 2px solid var(--text); }
input[type="checkbox"], input[type="radio"] { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }
kbd { font: inherit; font-size: var(--text-small); color: inherit; }
.toolbar { display: flex; flex-wrap: wrap; gap: var(--space-1); margin: var(--space-2) 0 var(--space-3); }

/* Panels and cards: flat, 1px border, one radius. */
.panel { padding: var(--space-2); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.tool-cards { display: grid; gap: var(--space-2); grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); margin: 0; padding: 0; list-style: none; }
.tool-cards a { display: block; height: 100%; padding: var(--space-3); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); text-decoration: none; }
.tool-cards a:hover { border-color: var(--accent); }
.tool-cards p { margin: var(--space-1) 0 0; color: var(--text-muted); }

@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }
.prose { max-width: 70ch; }
.prose h2 { margin-top: var(--space-4); }
