/* "Bazaar ledger": warm paper, deep ink, marigold action, leaf green for privacy/success. */
@font-face { font-family: "Bricolage Grotesque"; src: url("fonts/bricolage-grotesque.woff2") format("woff2"); font-weight: 200 800; font-display: swap; }
@font-face { font-family: "Instrument Sans"; src: url("fonts/instrument-sans-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Instrument Sans"; src: url("fonts/instrument-sans-600.woff2") format("woff2"); font-weight: 500 600; font-display: swap; }
@font-face { font-family: "Instrument Sans"; src: url("fonts/instrument-sans-700.woff2") format("woff2"); font-weight: 700 800; font-display: swap; }

:root {
  --bg: #FBFAF7; --surface: #FFFFFF; --surface-2: #F1EFEA; --text: #16161D; --muted: #5B5B66; --border: #E6E3DC; --field: #D9D5CC;
  --ink: #16161D; --ink-text: #FFFFFF;
  --accent: #F5A524; --accent-ink: #16161D; --accent-text: #8A4B00; --accent-soft: #FEF3DC;
  --leaf: #0B6B58; --leaf-soft: #E3F4EF; --leaf-ink: #0B4F42;
  --indigo: #3B44A8; --indigo-soft: #EEF0FF;
  --chili: #A3360B; --chili-soft: #FDE8E1;
  --ok: var(--leaf); --bad: #B42318; --warn: #8A4B00;
  --slab: #16161D; --slab-text: #FFFFFF; --slab-muted: #C9C8D0; --slab-border: transparent;
  --radius: 16px; --radius-sm: 12px;
  --shadow: 0 1px 2px rgb(22 22 29 / .04), 0 8px 24px rgb(22 22 29 / .06);
  --display: "Bricolage Grotesque", ui-sans-serif, system-ui, sans-serif;
  --font: "Instrument Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
/* Dark theme: follows the phone unless the visitor picked one with the header toggle (data-theme on <html>). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121216; --surface: #1B1B21; --surface-2: #26262E; --text: #F3F2EE; --muted: #A9A8B2; --border: #30303A; --field: #3C3C47;
    --ink: #F3F2EE; --ink-text: #16161D;
    --accent-text: #F5B54A; --accent-soft: #3A2A0C;
    --leaf: #4CC3A5; --leaf-soft: #12352D; --leaf-ink: #A6E9D7;
    --indigo: #9EA6FF; --indigo-soft: #23264A; --chili: #FF9B78; --chili-soft: #3D2017; --bad: #FF8A80;
    --slab: #24242C; --slab-text: #F3F2EE; --slab-muted: #B4B3BD; --slab-border: #34343F;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121216; --surface: #1B1B21; --surface-2: #26262E; --text: #F3F2EE; --muted: #A9A8B2; --border: #30303A; --field: #3C3C47;
  --ink: #F3F2EE; --ink-text: #16161D;
  --accent-text: #F5B54A; --accent-soft: #3A2A0C;
  --leaf: #4CC3A5; --leaf-soft: #12352D; --leaf-ink: #A6E9D7;
  --indigo: #9EA6FF; --indigo-soft: #23264A; --chili: #FF9B78; --chili-soft: #3D2017; --bad: #FF8A80;
  --slab: #24242C; --slab-text: #F3F2EE; --slab-muted: #B4B3BD; --slab-border: #34343F;
  color-scheme: dark;
}

* { 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.55 var(--font); }
a { color: var(--accent-text); }
h1, h2, h3 { font-family: var(--display); font-weight: 800; line-height: 1.1; letter-spacing: -0.02em; }
code { background: var(--surface-2); padding: 0 .3em; border-radius: 4px; font-size: .9em; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Header / footer */
header.site { background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
header.site .wrap { display: flex; align-items: center; gap: 8px; min-height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--display); font-weight: 800; font-size: 19px; color: var(--text); text-decoration: none; white-space: nowrap; margin-right: auto; }
.brand img { border-radius: 9px; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; padding: 5px 11px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
header.site .pill { white-space: nowrap; margin-right: 8px; }
.pill.leaf { background: var(--leaf-soft); color: var(--leaf-ink); }
.icon-btn, .menu-btn { flex-shrink: 0; min-width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); cursor: pointer; text-decoration: none; font: inherit; font-weight: 600; }
.menu-btn { padding: 0 14px; }
.icon-btn:hover, .menu-btn:hover { background: var(--surface-2); }
.theme-toggle svg { display: none; }
.theme-toggle[data-mode="auto"] .i-auto, .theme-toggle[data-mode="dark"] .i-dark, .theme-toggle[data-mode="light"] .i-light { display: block; }
@media (max-width: 560px) { header.site .pill, .menu-btn span { display: none; } .menu-btn { padding: 0; } }

/* Tools menu: a native popover panel from the right (works without JS). */
.tool-menu { margin: 0 0 0 auto; height: 100dvh; max-height: none; width: min(380px, 92vw); border: 0; border-left: 1px solid var(--border); padding: 16px; background: var(--surface); color: var(--text); overflow-y: auto; box-shadow: -12px 0 40px rgb(0 0 0 / .18); }
.tool-menu::backdrop { background: rgb(0 0 0 / .35); }
.tool-menu-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-size: 1.1rem; }
.tool-menu h2 { font-family: var(--font); font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 18px 0 6px; }
.tool-menu a { display: flex; align-items: center; gap: 12px; padding: 8px; border-radius: 12px; color: var(--text); text-decoration: none; font-weight: 600; }
.tool-menu a:hover, .tool-menu a[aria-current] { background: var(--surface-2); }
.tool-menu .icon-chip { width: 38px; height: 38px; border-radius: 10px; }

main.wrap { padding-top: 40px; padding-bottom: 96px; min-height: 70vh; }
footer.site { border-top: 1px solid var(--border); color: var(--muted); font-size: 14px; padding: 28px 0; }
footer.site .wrap { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
footer.site p { margin: 0; }
footer.site a { color: var(--muted); }

/* Type helpers */
.kicker { margin: 0 0 12px; font-size: 13px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--accent-text); }
.lede { font-size: 1.15rem; color: var(--muted); max-width: 36em; margin: 0 0 24px; }
.tool-head { margin-bottom: 24px; }
.tool-head h1 { font-size: clamp(1.9rem, 5vw, 2.6rem); margin: 0 0 8px; }
.tool-head .lede { margin-bottom: 0; }

/* Home: a searchable tool directory */
.dir-hero { padding: 8px 0 12px; }
.dir-hero h1 { font-size: clamp(2.2rem, 6vw, 3.6rem); line-height: 1.04; letter-spacing: -0.03em; margin: 0 0 14px; max-width: 16ch; }
.dir-hero .lede { max-width: 44em; }
.dir-hero .lede strong { color: var(--text); }
.dir-search { display: flex; align-items: center; gap: 10px; max-width: 640px; padding: 0 14px; border: 1px solid var(--field); border-radius: 16px; background: var(--surface); color: var(--muted); box-shadow: var(--shadow); }
.dir-search:focus-within { outline: 3px solid var(--accent); outline-offset: 2px; }
.dir-search input { border: 0; background: transparent; padding: 14px 0; min-height: 56px; font-size: 17px; outline: none; }
.dir-search input:focus-visible { outline: none; }
.dir-kbd { font: 600 12px var(--font); color: var(--muted); border: 1px solid var(--border); border-radius: 6px; padding: 2px 6px; white-space: nowrap; }
@media (hover: none) { .dir-kbd { display: none; } }
.dir-group { margin-top: 36px; }
.dir-group h2 { font-family: var(--font); font-size: 13px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0 0 12px; }
.dir-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); gap: 12px; }
.tcard { display: flex; align-items: center; gap: 14px; padding: 16px; border: 1px solid var(--border); border-radius: 18px; background: var(--surface); color: var(--text); text-decoration: none; transition: border-color .15s, transform .15s, box-shadow .15s; min-height: 84px; }
.tcard:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow); }
.tcard-text { display: grid; gap: 2px; min-width: 0; }
.tcard-text strong { font-size: 16px; line-height: 1.25; }
.tcard-text small { color: var(--muted); font-size: 13px; }
.tcard.soon { opacity: .65; }
.dir-grid.featured .tcard { flex-direction: column; align-items: flex-start; justify-content: space-between; min-height: 150px; padding: 20px; }
.dir-grid.featured .tcard-text strong { font-family: var(--display); font-size: 1.25rem; }
.tcard.dark { background: var(--slab); color: var(--slab-text); border-color: var(--slab-border); }
.tcard.dark small { color: var(--slab-muted); }
.tcard.dark .icon-chip { background: rgb(255 255 255 / .1); color: var(--accent); }
.icon-chip { width: 44px; height: 44px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; background: var(--surface-2); color: var(--text); }
.icon-chip.leaf { background: var(--leaf-soft); color: var(--leaf); }
.icon-chip.accent { background: var(--accent-soft); color: var(--accent-text); }
.icon-chip.indigo { background: var(--indigo-soft); color: var(--indigo); }
.icon-chip.chili { background: var(--chili-soft); color: var(--chili); }
.dir-why { margin-top: 56px; max-width: 70ch; }
.dir-why h2 { font-size: 1.5rem; }
.dir-why ul { padding-left: 1.1em; color: var(--muted); display: grid; gap: 8px; }
.dir-why strong { color: var(--text); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; }

/* Layout */
.split { display: grid; grid-template-columns: minmax(300px, 440px) 1fr; gap: 28px; align-items: start; }
@media (max-width: 880px) { .split { grid-template-columns: 1fr; } }

/* Forms */
.form fieldset { border: 0; padding: 0; margin: 0 0 22px; display: grid; gap: 14px; }
.form legend { font-family: var(--display); font-weight: 800; font-size: 1.15rem; margin-bottom: 12px; padding: 0; }
.form label { display: grid; gap: 6px; font-size: 15px; font-weight: 700; }
.form .opt { font-weight: 400; color: var(--muted); }
.form .row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.split > *, .form .row > *, .form label { min-width: 0; }
@media (max-width: 380px) { .form .row { grid-template-columns: 1fr; } }
.form .check { display: flex; align-items: center; gap: 10px; font-weight: 600; }
input, select, textarea { font: inherit; font-weight: 400; font-size: 16px; color: var(--text); background: var(--surface); border: 1px solid var(--field); border-radius: var(--radius-sm); padding: 12px 14px; width: 100%; min-height: 50px; }
textarea { resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 15px; line-height: 1.6; }
textarea.hero-input { border: 2px solid var(--ink); }
input[type=checkbox], input[type=radio] { width: 20px; min-height: 20px; accent-color: var(--ink); }
input:focus-visible, select:focus-visible, textarea:focus-visible, .btn:focus-visible, a:focus-visible, .seg label:focus-within { outline: 3px solid var(--accent); outline-offset: 2px; }
input.upper { text-transform: uppercase; }
[aria-invalid=true] { border-color: var(--bad); }
.field-error { color: var(--bad); font-size: 13px; font-weight: 600; }
.hint { font-size: 13px; font-weight: 400; color: var(--muted); margin: 0; }

/* Segmented control: radios styled as pills. Markup: <div class="seg"><label><input type=radio> 5%</label>…</div> */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 6px; }
.seg label { position: relative; display: flex; align-items: center; justify-content: center; min-height: 46px; border: 1px solid var(--field); border-radius: var(--radius-sm); background: var(--surface); font-weight: 600; cursor: pointer; text-align: center; padding: 6px; }
.seg input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.seg label:has(input:checked) { background: var(--ink); border-color: var(--ink); color: var(--ink-text); }
.seg.soft { background: var(--surface-2); padding: 4px; border-radius: 14px; }
.seg.soft label { border: 0; background: transparent; color: var(--muted); }
.seg.soft label:has(input:checked) { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgb(0 0 0 / .14); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: inherit; font-weight: 700; border: 1px solid var(--border); background: var(--surface); color: var(--text); padding: 12px 20px; border-radius: 14px; cursor: pointer; text-decoration: none; min-height: 50px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.dark { background: var(--ink); border-color: var(--ink); color: var(--ink-text); }
.btn:hover { filter: brightness(.97); }
.btn[disabled] { opacity: .6; cursor: wait; }
.btn.block { width: 100%; }

/* Sticky action bar (phones) */
.action-bar { position: sticky; bottom: 0; z-index: 15; display: flex; gap: 10px; align-items: center; background: var(--surface); border-top: 1px solid var(--border); padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); margin: 24px -16px -96px; box-shadow: 0 -8px 24px rgb(22 22 29 / .06); }
.action-bar.inline { margin: 24px -16px 0; }
.action-bar .total { flex: 1; min-width: 0; }
.action-bar .total small { display: block; font-size: 12px; color: var(--muted); }
.action-bar .total strong { font-family: var(--display); font-size: 22px; }

/* Notices */
.alert { border-radius: var(--radius-sm); padding: 12px 14px; background: var(--surface-2); border: 1px solid var(--border); }
.alert.error { border-color: var(--bad); color: var(--bad); background: var(--surface); }
.alert.success, .note.leaf { background: var(--leaf-soft); border-color: transparent; color: var(--leaf-ink); }
.note { margin: 0; display: flex; gap: 10px; align-items: flex-start; border-radius: var(--radius-sm); padding: 12px 14px; background: var(--accent-soft); color: var(--text); font-size: 14px; line-height: 1.45; }
.note svg { flex-shrink: 0; margin-top: 1px; }

.prose { max-width: 70ch; }
.prose h2 { font-size: 1.35rem; margin-top: 2em; }
.prose p { color: var(--muted); }
.seo { margin-top: 64px; }

.paper { background: #fff; color: #1c1917; border: 1px solid #e7e2da; border-radius: 4px; box-shadow: var(--shadow); padding: clamp(16px, 4vw, 40px); font-size: 14px; overflow-x: auto; position: relative; }
.paper h3 { margin: 0 0 4px; font-size: 1.3rem; }
.paper p { margin: 2px 0; }
.inv-head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; border-bottom: 2px solid #1c1917; padding-bottom: 12px; margin-bottom: 12px; }
.inv-meta { text-align: right; }
.inv-meta strong { letter-spacing: .1em; }
.bill-to span { color: #57534e; }
.inv-table, .inv-totals { width: 100%; border-collapse: collapse; margin-top: 12px; }
.inv-table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: #57534e; border-bottom: 1px solid #d6d3d1; padding: 6px 4px; }
.inv-table td { border-bottom: 1px solid #f0ede8; padding: 7px 4px; }
.inv-table .empty { color: #a16207; text-align: center; padding: 20px; }
.inv-totals { width: auto; margin-left: auto; min-width: 260px; }
.inv-totals td { padding: 4px 6px; }
.inv-totals .grand td { font-weight: 700; font-size: 1.05rem; border-top: 2px solid #1c1917; padding-top: 8px; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.words { font-style: italic; margin-top: 12px !important; }
.fine { color: #78716c; font-size: 12px; margin-top: 16px !important; }
.warn { color: #a16207; }

@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff; }
  header.site, footer.site, .no-print, .seo, .tool-head, .action-bar { display: none !important; }
  main.wrap { padding: 0; max-width: none; }
  .split { display: block; }
  .paper { border: 0; box-shadow: none; padding: 0; }
}

/* Paper stays paper in dark mode: anything inside uses light colours. */
.paper code { background: #F1EFEA; color: inherit; }
@media (max-width: 420px) {
  .paper { padding: 14px; font-size: 13px; }
  .inv-table th, .inv-table td { padding: 6px 3px; font-size: 12px; }
  .inv-table th { letter-spacing: 0; }
  .inv-totals { min-width: 0; width: 100%; }
}
