/* ============================================================
   ToolDeck — "workshop utility" design system
   Native CSS, no dependencies, no external requests.
   Rules: one accent (cobalt), all-sharp corners, 2px ink borders,
   hard offset shadows, display type = Cabinet Grotesk (self-hosted),
   numbers = JetBrains Mono (self-hosted). Both color modes supported.
   ============================================================ */

@font-face {
  font-family: "Cabinet Grotesk";
  src: url("fonts/cabinet-400.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Cabinet Grotesk";
  src: url("fonts/cabinet-500.woff2") format("woff2");
  font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Cabinet Grotesk";
  src: url("fonts/cabinet-700.woff2") format("woff2");
  font-weight: 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Cabinet Grotesk";
  src: url("fonts/cabinet-800.woff2") format("woff2");
  font-weight: 800; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("fonts/jetbrains-var.woff2") format("woff2");
  font-weight: 400 800; font-style: normal; font-display: swap;
}

:root {
  --paper: #f4f3ef;
  --surface: #fcfbf8;
  --ink: #16181d;
  --ink-soft: #4c515b;
  --cobalt: #1e4fd8;
  --cobalt-deep: #16389e;
  --cobalt-soft: #e3eafc;
  --line: #16181d;
  --line-faint: #c9c7bf;
  --grid-line: rgba(22, 24, 29, 0.05);
  --shadow: #16181d;
  --err: #b42318;
  --ok: #0b6b3a;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #131418;
    --surface: #1a1c21;
    --ink: #e9eaee;
    --ink-soft: #a2a7b1;
    --cobalt: #8aa6ff;
    --cobalt-deep: #b0c2ff;
    --cobalt-soft: #1f2739;
    --line: #3d414a;
    --line-faint: #2b2e35;
    --grid-line: rgba(233, 234, 238, 0.04);
    --shadow: #000000;
    --err: #f08377;
    --ok: #58c98d;
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 34px 34px;
  color: var(--ink);
  font: 16.5px/1.6 "Cabinet Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  display: flex;
  min-height: 100vh;
  flex-direction: column;
}

::selection { background: var(--cobalt); color: var(--paper); }

main { flex: 1; padding-bottom: 48px; }
.container { max-width: 980px; margin: 0 auto; padding: 0 20px; width: 100%; }

h1, h2, h3 { letter-spacing: -0.02em; }
h1 { font-size: clamp(2.4rem, 5.5vw, 3.6rem); font-weight: 800; line-height: 1.04; margin: 0 0 10px; }
h2 {
  font-size: 1.45rem; font-weight: 800; line-height: 1.25;
  margin: 44px 0 14px; padding-bottom: 8px;
  border-bottom: 2px solid var(--line);
}
h3 { font-size: 1.1rem; font-weight: 700; margin: 24px 0 8px; }
p { margin: 8px 0; max-width: 68ch; }

a { color: var(--cobalt); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

code {
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
  background: var(--cobalt-soft);
  padding: 1px 5px;
}

.mono, .stat .num, .result .big, table.data td.num, .slider-val, .pw-output {
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.muted { color: var(--ink-soft); }
.small { font-size: 0.85rem; }
.tagline { color: var(--ink-soft); font-size: 1.08rem; margin: 0; }

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

.site-header {
  background: var(--surface);
  border-bottom: 2px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 62px; }

.brand {
  display: inline-flex; align-items: center; gap: 9px;
  font-weight: 800; font-size: 1.22rem; color: var(--ink);
  letter-spacing: -0.02em;
}
.brand:hover { text-decoration: none; }
.brand-mark { display: block; width: 21px; height: 21px; }

.site-nav { display: flex; gap: 22px; }
.site-nav a {
  color: var(--ink-soft); font-weight: 700; font-size: 0.82rem;
  text-transform: uppercase; letter-spacing: 0.09em;
  font-family: "JetBrains Mono", ui-monospace, Menlo, monospace;
  padding: 4px 0;
  border-bottom: 2px solid transparent;
}
.site-nav a:hover { color: var(--cobalt); text-decoration: none; border-bottom-color: var(--cobalt); }
.site-nav a[aria-current="page"] { color: var(--cobalt); border-bottom-color: var(--cobalt); }

.site-footer {
  border-top: 2px solid var(--line);
  background: var(--surface);
  margin-top: 56px;
  padding: 30px 0 40px;
  font-size: 0.92rem;
}
.footer-inner { display: flex; flex-wrap: wrap; gap: 20px 48px; justify-content: space-between; }
.footer-nav { display: flex; flex-direction: column; gap: 7px; }
.footer-nav a { color: var(--ink-soft); }
.footer-nav a:hover { color: var(--cobalt); }
.footer-brand p { max-width: 320px; }
.footnote {
  font-family: "JetBrains Mono", ui-monospace, Menlo, monospace;
  font-size: 0.74rem; color: var(--ink-soft); margin-top: 6px;
}

/* ---------- Hero (index) ---------- */

.hero {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 44px;
  align-items: center;
  padding: 60px 0 10px;
}
.hero h1 { font-size: clamp(2.4rem, 4.6vw, 3.4rem); }
.hero h1 .mark {
  background: var(--cobalt);
  color: var(--paper);
  padding: 0 0.14em;
}
.hero-sub { font-size: 1.12rem; color: var(--ink-soft); max-width: 34rem; margin: 14px 0 22px; }
@media (max-width: 820px) {
  .hero { grid-template-columns: 1fr; gap: 30px; padding-top: 40px; }
}

.hero-widget {
  background: var(--surface);
  border: 2px solid var(--line);
  box-shadow: 7px 7px 0 var(--shadow);
  padding: 22px;
}
.hw-row { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.hw-row input[type="number"] {
  width: 96px;
  flex: 0 0 auto;
  font-family: "JetBrains Mono", ui-monospace, Menlo, monospace;
  font-weight: 700; font-size: 1.05rem;
  padding: 9px 10px;
  border: 2px solid var(--line);
  background: var(--paper);
  color: var(--ink);
}
.hw-row .hw-op { font-weight: 800; font-size: 1.3rem; }
.hw-out {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 2px solid var(--line);
  font-family: "JetBrains Mono", ui-monospace, Menlo, monospace;
  font-size: 1.7rem; font-weight: 700;
  color: var(--cobalt);
}
.hw-cap {
  font-family: "JetBrains Mono", ui-monospace, Menlo, monospace;
  font-size: 0.72rem; color: var(--ink-soft); margin-top: 12px;
  letter-spacing: 0.04em;
}

/* ---------- Tool cards ---------- */

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(215px, 1fr));
  gap: 16px;
  margin: 22px 0 8px;
}

.tool-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--surface);
  border: 2px solid var(--line);
  padding: 18px;
  color: inherit;
  box-shadow: 4px 4px 0 var(--shadow);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}
.tool-card:hover {
  text-decoration: none;
  transform: translate(-2px, -2px);
  box-shadow: 7px 7px 0 var(--shadow);
}
.tool-card:active { transform: translate(1px, 1px); box-shadow: 2px 2px 0 var(--shadow); }

.tool-glyph {
  width: 46px; height: 46px;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--line);
  background: var(--cobalt-soft);
  color: var(--cobalt);
  font-weight: 800; font-size: 1.25rem;
  margin-bottom: 8px;
  letter-spacing: -0.03em;
}
.glyph-swatches { display: flex; gap: 4px; }
.glyph-swatches span { width: 11px; height: 26px; border: 1px solid var(--line); }
.glyph-swatches .sw1 { background: #1e4fd8; }
.glyph-swatches .sw2 { background: #e2a33d; }
.glyph-swatches .sw3 { background: #b23a2f; }

.tool-name { font-weight: 700; font-size: 1.02rem; }
.tool-desc { color: var(--ink-soft); font-size: 0.85rem; line-height: 1.45; }

.tool-card.card-accent { background: var(--cobalt); border-color: var(--cobalt-deep); }
.tool-card.card-accent .tool-name, .tool-card.card-accent .tool-desc { color: var(--paper); }
.tool-card.card-accent .tool-desc { opacity: 0.85; }
.tool-card.card-accent .tool-glyph { background: var(--paper); color: var(--cobalt); border-color: var(--paper); }

.tool-card.card-invert { background: var(--ink); }
.tool-card.card-invert .tool-name, .tool-card.card-invert .tool-desc { color: var(--paper); }
.tool-card.card-invert .tool-desc { color: var(--ink-soft); }
.tool-card.card-invert .tool-glyph { background: transparent; color: var(--cobalt); }

@media (prefers-color-scheme: dark) {
  .tool-card.card-invert { background: #0d0e11; }
  .tool-card.card-invert .tool-desc { color: var(--ink-soft); }
}

/* ---------- "Why" rows ---------- */

.why-rows { margin-top: 18px; }
.why-row { border-top: 2px solid var(--line); padding: 18px 2px; display: grid; grid-template-columns: 240px 1fr; gap: 18px; }
.why-row:last-child { border-bottom: 2px solid var(--line); }
.why-row h3 { margin: 0; font-size: 1.05rem; }
.why-row p { margin: 0; color: var(--ink-soft); }
@media (max-width: 680px) { .why-row { grid-template-columns: 1fr; gap: 6px; } }

/* ---------- Tool pages ---------- */

.page-head { padding: 46px 0 6px; display: flow-root; }
.page-head .tool-glyph { float: left; width: 56px; height: 56px; font-size: 1.5rem; margin: 6px 22px 6px 0; }
.page-head h1 { font-size: clamp(2rem, 4.4vw, 2.9rem); }
.page-head .tagline { max-width: 40rem; }

.tool-panel {
  background: var(--surface);
  border: 2px solid var(--line);
  box-shadow: 6px 6px 0 var(--shadow);
  padding: 24px;
  margin: 20px 0;
}

.field { margin: 0 0 15px; }
.field > label {
  display: block;
  font-weight: 700;
  font-size: 0.72rem;
  color: var(--ink-soft);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-family: "JetBrains Mono", ui-monospace, Menlo, monospace;
}

input[type="text"], input[type="number"], input[type="date"], select, textarea {
  width: 100%;
  padding: 10px 12px;
  font: inherit;
  color: var(--ink);
  background: var(--paper);
  border: 2px solid var(--line);
  border-radius: 0;
}
textarea { resize: vertical; min-height: 120px; }
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--cobalt);
  outline-offset: 1px;
}
button:focus-visible, a:focus-visible { outline: 2px solid var(--cobalt); outline-offset: 2px; }

input[type="checkbox"] { accent-color: var(--cobalt); width: 16px; height: 16px; }

.row { display: flex; gap: 14px; flex-wrap: wrap; }
.row > .field { flex: 1 1 140px; }

.btn {
  display: inline-block;
  background: var(--ink);
  color: var(--paper);
  border: 2px solid var(--ink);
  padding: 10px 18px;
  font: inherit; font-weight: 700;
  cursor: pointer;
  box-shadow: 3px 3px 0 var(--shadow);
  transition: transform 0.08s ease, box-shadow 0.08s ease, background 0.12s ease;
}
.btn:hover { background: var(--cobalt); border-color: var(--cobalt); text-decoration: none; }
.btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--shadow); }
.btn.secondary {
  background: var(--surface);
  color: var(--ink);
  border: 2px solid var(--line);
}
.btn.secondary:hover { color: var(--cobalt); border-color: var(--cobalt); background: var(--surface); }

.result {
  background: var(--cobalt-soft);
  border: 2px solid var(--line);
  padding: 14px 18px;
  margin-top: 16px;
}
.result .big { font-size: 1.65rem; font-weight: 700; letter-spacing: -0.01em; color: var(--cobalt); }
@media (prefers-color-scheme: dark) { .result .big { color: var(--cobalt-deep); } }
.result .sub { color: var(--ink-soft); font-size: 0.85rem; margin-top: 3px; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px;
  margin-top: 16px;
}
.stat { background: var(--paper); border: 2px solid var(--line); padding: 12px 14px; }
.stat .num { font-size: 1.4rem; font-weight: 700; line-height: 1.25; }
.stat .lbl {
  color: var(--ink-soft); font-size: 0.68rem; text-transform: uppercase;
  letter-spacing: 0.08em; font-family: "JetBrains Mono", ui-monospace, Menlo, monospace;
}

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chip {
  background: var(--surface);
  border: 2px solid var(--line);
  padding: 4px 12px;
  font-size: 0.85rem; font-weight: 700;
  cursor: pointer;
}
.chip:hover { border-color: var(--cobalt); color: var(--cobalt); }

.tabs { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 20px; }
.tab {
  padding: 8px 16px;
  border: 2px solid var(--line);
  background: var(--surface);
  color: var(--ink-soft);
  cursor: pointer;
  font: inherit; font-size: 0.9rem; font-weight: 700;
}
.tab.active { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.tab:hover:not(.active) { color: var(--cobalt); border-color: var(--cobalt); }

.slider-row { display: flex; align-items: center; gap: 14px; }
.slider-row input[type="range"] { flex: 1; accent-color: var(--cobalt); }
.slider-val { font-weight: 700; font-size: 1.2rem; min-width: 56px; text-align: right; }

.pw-output {
  font-size: 1.05rem;
  word-break: break-all;
  background: var(--paper);
  border: 2px dashed var(--line-faint);
  padding: 14px;
  min-height: 54px;
  user-select: all;
}
.strength-bar { height: 10px; border: 2px solid var(--line); overflow: hidden; margin-top: 10px; }
.strength-fill { height: 100%; width: 0; transition: width 0.2s ease; }

.swatch {
  height: 120px;
  border: 2px solid var(--line);
  display: flex;
  align-items: flex-end;
  padding: 12px;
  font-family: "JetBrains Mono", ui-monospace, Menlo, monospace;
  font-weight: 700; font-size: 0.85rem;
}

/* ---------- Tables ---------- */

table.data { width: 100%; border-collapse: collapse; font-size: 0.92rem; border: 2px solid var(--line); }
table.data th, table.data td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--line-faint); }
table.data th {
  color: var(--ink-soft); font-size: 0.68rem; text-transform: uppercase;
  letter-spacing: 0.08em; border-bottom: 2px solid var(--line);
  font-family: "JetBrains Mono", ui-monospace, Menlo, monospace;
}
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; font-family: "JetBrains Mono", ui-monospace, Menlo, monospace; }

/* ---------- Invoice ---------- */

.invoice-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 26px; align-items: start; }
@media (max-width: 780px) { .invoice-layout { grid-template-columns: 1fr; } }

.invoice-sheet {
  background: #ffffff;
  color: #16181d;
  border: 2px solid var(--line);
  padding: 28px;
  font-size: 0.9rem;
  box-shadow: 6px 6px 0 var(--shadow);
}
.invoice-sheet h2 { margin: 0 0 2px; font-size: 1.5rem; letter-spacing: 0.08em; border: 0; padding: 0; }
.invoice-sheet .inv-meta { color: #5b6068; font-size: 0.8rem; font-family: "JetBrains Mono", ui-monospace, Menlo, monospace; }
.invoice-sheet table { width: 100%; border-collapse: collapse; margin-top: 18px; }
.invoice-sheet th { text-align: left; border-bottom: 2px solid #16181d; padding: 6px 8px; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.07em; }
.invoice-sheet td { border-bottom: 1px solid #d8d5cd; padding: 7px 8px; vertical-align: top; }
.invoice-sheet .num { text-align: right; font-family: "JetBrains Mono", ui-monospace, Menlo, monospace; font-variant-numeric: tabular-nums; }
.invoice-sheet .totals { margin-top: 14px; margin-left: auto; width: 230px; }
.invoice-sheet .totals div { display: flex; justify-content: space-between; padding: 4px 8px; }
.invoice-sheet .totals .grand { border-top: 2px solid #16181d; font-weight: 800; font-size: 1.05rem; }
.invoice-sheet .whitespace-pre { white-space: pre-wrap; }

.item-row { display: grid; grid-template-columns: 1fr 64px 90px 34px; gap: 8px; margin-bottom: 8px; }
.item-row input { padding: 8px 10px; }

/* ---------- FAQ ---------- */

details.faq { border-top: 2px solid var(--line); padding: 14px 2px; }
details.faq:last-of-type { border-bottom: 2px solid var(--line); }
details.faq summary { font-weight: 700; cursor: pointer; }
details.faq summary:hover { color: var(--cobalt); }
details.faq p { color: var(--ink-soft); }

/* ---------- Ads / misc ---------- */

.ad-slot { margin: 10px 0; min-height: 0; }
.ads-on .ad-slot { min-height: 90px; margin: 30px 0; border: 2px dashed var(--line-faint); }

.error-text { color: var(--err); font-size: 0.88rem; margin-top: 6px; }
.ok-text { color: var(--ok); }

.skip-note { color: var(--ink-soft); font-size: 0.8rem; }

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ---------- Print (invoice) ---------- */

@media print {
  body { background: #fff; color: #000; }
  .site-header, .site-footer, .no-print, .ad-slot, .page-head, details.faq, .related, .home-note, .hero { display: none !important; }
  .invoice-layout { display: block; }
  .invoice-sheet { border: 0; box-shadow: none; padding: 0; max-width: 100%; }
  main.container { max-width: 100%; padding: 0; }
  @page { margin: 16mm; }
}
