/* Inter + JetBrains Mono, self-hosted, copied from pcar-buddy (SIL OFL 1.1, licences in fonts/). */
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 400 600; font-display: swap;
  src: url('/fonts/inter-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 400 600; font-display: swap;
  src: url('/fonts/inter-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'JetBrains Mono'; font-style: normal; font-weight: 400 600; font-display: swap;
  src: url('/fonts/jetbrains-mono-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'JetBrains Mono'; font-style: normal; font-weight: 400 600; font-display: swap;
  src: url('/fonts/jetbrains-mono-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }

/* Tokens copied verbatim from ~/Projects/pcar-buddy/src/styles/global.css. Change them there first. */
:root {
  --c-bg: #fcfcfb;
  --c-surface: #ffffff;
  --c-surface-2: #f4f4f2;
  --c-ink: #16161a;
  --c-ink-2: #55595f;
  --c-ink-3: #8b9098;
  --c-rule: #e6e6e3;
  --c-rule-2: #d2d2ce;
  --c-accent: #c1121f;
  --c-accent-soft: #fdeced;
  --c-crit: #b3261e;
  --c-major: #9a6100;
  --c-minor: #5b6470;
  --c-ok: #1f6f43;
  --c-src: #067647;
  --c-src-none: #8b9098;
  --shadow-card: 0 1px 2px rgb(16 16 26 / 0.04);
  --c-hero: #131316;
  --c-hero-ink: #f7f7f5;
  --c-hero-ink-2: #a2a6ad;
  --c-hero-rule: #2c2c33;
}

:root[data-theme='dark'] {
  --c-bg: #0e0e11;
  --c-surface: #16161a;
  --c-surface-2: #1d1d22;
  --c-ink: #f0f0ee;
  --c-ink-2: #a8adb5;
  --c-ink-3: #6f757e;
  --c-rule: #26262c;
  --c-rule-2: #34343c;
  --c-accent: #ff5a5f;
  --c-accent-soft: #2a1416;
  --c-crit: #ff6b60;
  --c-major: #e0a33a;
  --c-minor: #8d97a5;
  --c-ok: #4cc38a;
  --c-src: #3ddc97;
  --c-src-none: #6f757e;
  --shadow-card: 0 1px 2px rgb(0 0 0 / 0.4);
  --c-hero: #08080a;
  --c-hero-ink: #f7f7f5;
  --c-hero-ink-2: #9aa0a8;
  --c-hero-rule: #26262c;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --c-bg: #0e0e11;
    --c-surface: #16161a;
    --c-surface-2: #1d1d22;
    --c-ink: #f0f0ee;
    --c-ink-2: #a8adb5;
    --c-ink-3: #6f757e;
    --c-rule: #26262c;
    --c-rule-2: #34343c;
    --c-accent: #ff5a5f;
    --c-accent-soft: #2a1416;
    --c-crit: #ff6b60;
    --c-major: #e0a33a;
    --c-minor: #8d97a5;
    --c-ok: #4cc38a;
    --c-src: #3ddc97;
    --c-src-none: #6f757e;
    --shadow-card: 0 1px 2px rgb(0 0 0 / 0.4);
    --c-hero: #08080a;
    --c-hero-ink: #f7f7f5;
    --c-hero-ink-2: #9aa0a8;
    --c-hero-rule: #26262c;
  }
}

:root {
  --font-sans: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  color-scheme: light;
}
:root[data-theme='dark'] { color-scheme: dark; }
@media (prefers-color-scheme: dark) { :root:not([data-theme='light']) { color-scheme: dark; } }

* { box-sizing: border-box; }
html { background: var(--c-bg); -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--c-bg);
  color: var(--c-ink);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  line-height: 1.45rem;
  font-feature-settings: 'cv05' 1, 'ss01' 1;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
::selection { background: var(--c-accent); color: #fff; }
:focus-visible { outline: 2px solid var(--c-accent); outline-offset: 2px; border-radius: 2px; }

/* ---- chrome ---- */
.site-header {
  position: sticky; top: 0; z-index: 40;
  border-bottom: 1px solid var(--c-rule);
  background: color-mix(in srgb, var(--c-bg) 90%, transparent);
  backdrop-filter: blur(4px);
}
.site-header .bar {
  max-width: 1400px; margin: 0 auto; height: 48px; padding: 0 16px;
  display: flex; align-items: center; gap: 24px;
}
.wordmark { font-family: var(--font-mono); font-size: 0.9375rem; font-weight: 600; letter-spacing: -0.02em; white-space: nowrap; }
.wordmark span { color: var(--c-accent); }
.site-header nav { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.navlink { border-radius: 4px; padding: 4px 8px; font-size: 0.8125rem; color: var(--c-ink-2); transition: background 0.12s; }
.navlink:hover { background: var(--c-surface-2); }
.theme-toggle {
  margin-left: 4px; display: grid; place-items: center; width: 28px; height: 28px;
  border: 1px solid var(--c-rule); border-radius: 4px; background: none; color: var(--c-ink-2); cursor: pointer;
}
.theme-toggle:hover { background: var(--c-surface-2); }

main { max-width: 780px; margin: 0 auto; padding: 24px 16px 64px; }
section { padding: 24px 0; border-top: 1px solid var(--c-rule); }
section:first-child { border-top: 0; padding-top: 8px; }
h1.page { font-size: 1.375rem; line-height: 1.8rem; font-weight: 600; letter-spacing: -0.01em; margin: 0 0 4px; }
.lede { color: var(--c-ink-2); margin: 0 0 20px; }

.label {
  display: block; font-size: 0.6875rem; line-height: 1rem; letter-spacing: 0.07em;
  text-transform: uppercase; color: var(--c-ink-3); font-weight: 500;
}
.num, .mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--c-ink-3); }

/* ---- form ---- */
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
input[type='text'], select, textarea {
  font: inherit; color: var(--c-ink); background: var(--c-surface);
  border: 1px solid var(--c-rule-2); border-radius: 4px; padding: 7px 10px; width: 100%;
}
textarea { resize: vertical; min-height: 64px; }
input[type='text']:focus, select:focus, textarea:focus { outline: none; border-color: var(--c-ink-2); }
.item-row { display: flex; gap: 8px; }
.item-row input { font-size: 1rem; padding: 9px 12px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-top: 16px; }
.grid .wide { grid-column: 1 / -1; }

.chip {
  font: inherit; font-size: 0.8125rem; font-weight: 500; color: var(--c-ink);
  background: var(--c-surface); border: 1px solid var(--c-rule-2); border-radius: 4px;
  padding: 7px 14px; cursor: pointer; white-space: nowrap; transition: border-color 0.12s, color 0.12s;
  display: inline-flex; align-items: center; gap: 6px;
}
.chip:hover:not(:disabled) { border-color: var(--c-accent); color: var(--c-accent); }
.chip:disabled { color: var(--c-ink-3); cursor: default; }

/* US/UK: the selected option is the outlined, full-ink one; the other is plain and lighter. */
.seg { display: inline-flex; gap: 4px; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label {
  font-family: var(--font-mono); font-size: 0.8125rem; padding: 6px 12px; border-radius: 4px;
  border: 1px solid transparent; color: var(--c-ink-3); cursor: pointer;
}
.seg input:checked + label { border-color: var(--c-ink-2); color: var(--c-ink); font-weight: 600; }
.seg input:focus-visible + label { outline: 2px solid var(--c-accent); outline-offset: 2px; }

.examples { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.examples button {
  font: inherit; font-size: 0.75rem; color: var(--c-ink-2); background: none;
  border: 1px solid var(--c-rule); border-radius: 4px; padding: 2px 8px; cursor: pointer;
}
.examples button:hover { border-color: var(--c-accent); color: var(--c-accent); }

/* ---- status + output ---- */
.status { display: flex; align-items: center; gap: 8px; color: var(--c-ink-2); font-size: 0.8125rem; min-height: 24px; }
.status.error { color: var(--c-crit); font-weight: 500; }
.status.error::before { content: '✕'; font-weight: 700; }
.spinner { width: 12px; height: 12px; border: 2px solid var(--c-rule-2); border-top-color: var(--c-ink-2); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 0; }
.hidden { display: none !important; }

/* ---- rendered pattern ---- */
.pattern { overflow-wrap: anywhere; }
.pattern h1 { font-size: 1.5rem; line-height: 2rem; font-weight: 600; letter-spacing: -0.01em; margin: 8px 0 8px; }
.pattern h2 {
  font-size: 0.6875rem; line-height: 1rem; letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--c-ink-3); font-weight: 500; margin: 28px 0 10px; padding-top: 16px; border-top: 1px solid var(--c-rule);
}
.pattern h3 { font-size: 0.9375rem; font-weight: 600; margin: 20px 0 6px; }
.pattern h4 { font-size: 0.875rem; font-weight: 600; margin: 16px 0 4px; }
.pattern p { margin: 0 0 10px; }
.pattern ul, .pattern ol { margin: 0 0 10px; padding-left: 22px; }
.pattern li { margin: 2px 0; }
.pattern code { font-family: var(--font-mono); font-size: 0.8125rem; background: var(--c-surface-2); padding: 1px 4px; border-radius: 3px; }
.pattern hr { border: 0; border-top: 1px solid var(--c-rule); margin: 20px 0; }
.pattern table { border-collapse: collapse; margin: 0 0 12px; font-size: 0.8125rem; display: block; overflow-x: auto; }
.pattern th, .pattern td { border-bottom: 1px solid var(--c-rule); padding: 4px 16px 4px 0; text-align: left; vertical-align: top; }
.pattern th { font-size: 0.6875rem; letter-spacing: 0.07em; text-transform: uppercase; color: var(--c-ink-3); font-weight: 500; }
.pattern td:first-child { font-family: var(--font-mono); white-space: nowrap; }
/* Row and round lines: the "Row 1:" lead-in in mono, so the eye can find its place. */
.pattern .rowlead { font-family: var(--font-mono); font-weight: 600; font-size: 0.8125rem; }
.pattern .count { font-family: var(--font-mono); font-size: 0.8125rem; color: var(--c-ink-2); white-space: nowrap; }

.meta { display: flex; flex-wrap: wrap; gap: 20px; margin: 0 0 8px; }
.meta div { min-width: 0; }
.meta .v { font-family: var(--font-mono); font-size: 0.8125rem; }

/* ---- product picture ---- */
.picture { margin: 4px 0 16px; }
.picture img, .picture .ph {
  display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover;
  border: 1px solid var(--c-rule); border-radius: 4px; background: var(--c-surface-2);
}
.picture .ph { display: flex; align-items: center; justify-content: center; gap: 8px; color: var(--c-ink-3); font-size: 0.8125rem; }
.picture figcaption { margin-top: 6px; font-size: 0.75rem; color: var(--c-ink-3); }

/* ---- library ---- */
.library { list-style: none; margin: 0; padding: 0; }
.library li { border-bottom: 1px solid var(--c-rule); }
.library a { display: flex; gap: 12px; align-items: center; padding: 6px 0; }
.library .thumb { flex: none; width: 48px; height: 36px; border-radius: 3px; border: 1px solid var(--c-rule); background: var(--c-surface-2); object-fit: cover; }
.library a:hover .t { color: var(--c-accent); }
.library .t { font-weight: 500; flex: 1; min-width: 0; }
.library .i { color: var(--c-ink-3); font-size: 0.75rem; font-family: var(--font-mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40%; }
.library .d { color: var(--c-ink-3); font-size: 0.75rem; font-family: var(--font-mono); white-space: nowrap; }

footer { max-width: 780px; margin: 0 auto; padding: 16px; border-top: 1px solid var(--c-rule); color: var(--c-ink-3); font-size: 0.75rem; }

@media (max-width: 560px) {
  .item-row { flex-direction: column; }
  .library .i { display: none; }
}

@media print {
  .site-header, .no-print, footer { display: none !important; }
  body { background: #fff; color: #000; font-size: 11pt; line-height: 1.4; }
  main { max-width: none; padding: 0; }
  section { border: 0; padding: 0; }
  .pattern h2 { color: #444; }
  .pattern h2, .pattern h3 { break-after: avoid; }
  .pattern li, .pattern p { break-inside: avoid; }
  .picture img { max-height: 3.5in; width: auto; max-width: 100%; border: 0; }
  .picture .ph { display: none; }
}
