/* Layout: header bar, page hero with the primary calculator, then explanation, FAQ and links to the other calculators. */
:root {
  --bg: #f3f5fa;
  --surface: #ffffff;
  --fg: #141a2e;
  --muted: #5b6480;
  --line: #d9deeb;
  --accent: #2f4fd8;
  --accent-soft: #e6ebff;
  --good: #137a4b;
  --bad: #b3302a;
  --field: #f7f8fc;
  --display: "Bricolage Grotesque", "Inter", system-ui, sans-serif;
  --body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1220; --surface: #171c2e; --fg: #e8ecf8; --muted: #9aa3c0; --line: #2a3150;
    --accent: #8ea4ff; --accent-soft: #232c55; --good: #4fd394; --bad: #ff8a80; --field: #11152a;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg); font-family: var(--body); font-size: 16px; line-height: 1.6;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 0 48px;
}
a { color: var(--accent); }
.wrap { max-width: 1040px; margin: 0 auto; display: flex; flex-direction: column; gap: 32px; }
.wrap .wrap { width: 100%; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-block: 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-family: var(--display); font-weight: 800; font-size: 21px; letter-spacing: -0.01em; color: var(--fg); text-decoration: none; }
.mark { width: 32px; height: 32px; border-radius: 8px; background: var(--accent); color: var(--surface); display: grid; place-items: center; font-family: var(--mono); font-weight: 700; font-size: 17px; }
.topbar nav { display: flex; gap: 18px; flex-wrap: wrap; font-size: 14px; }
.topbar nav a { color: var(--muted); text-decoration: none; }
.topbar nav a:hover, .topbar nav a[aria-current="page"] { color: var(--fg); }
.crumbs { font-size: 13px; color: var(--muted); margin: 0; }
.crumbs a { color: var(--muted); }
.hero { display: flex; flex-direction: column; gap: 10px; }
h1 { font-family: var(--display); font-weight: 800; font-size: clamp(28px, 5vw, 44px); line-height: 1.1; letter-spacing: -0.02em; margin: 0; text-wrap: balance; max-width: 22ch; }
.lede { color: var(--muted); margin: 0; max-width: 62ch; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 310px), 1fr)); gap: 16px; }
.calc { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 20px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.calc.primary { max-width: 640px; padding: 24px; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.calc h2 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 0; font-weight: 600; font-family: var(--body); }
.calc h2 a { color: inherit; text-decoration: none; }
.calc h2 a:hover { color: var(--accent); }
.sentence { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 17px; font-weight: 500; }
.calc.primary .sentence { font-size: 19px; }
.nw { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.num { position: relative; display: inline-flex; align-items: center; }
.num input { width: 7.5ch; min-width: 0; font: 600 17px var(--mono); color: var(--fg); background: var(--field); border: 1.5px solid var(--line); border-radius: 8px; padding: 8px 10px; text-align: right; }
.num.pct input { padding-right: 26px; }
.num.pct::after { content: "%"; position: absolute; right: 9px; color: var(--muted); font: 600 15px var(--mono); pointer-events: none; }
.num input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.result { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--accent-soft); border-radius: 10px; padding: 12px 14px; min-height: 58px; flex-wrap: wrap; }
.answer { font: 700 clamp(22px, 3.2vw, 26px) var(--mono); color: var(--accent); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; min-width: 0; }
.answer.up { color: var(--good); }
.answer.down { color: var(--bad); }
.answer.empty { color: var(--muted); font-size: 15px; font-weight: 500; font-family: var(--body); }
.actions { display: flex; gap: 6px; }
.btn { flex: none; font: 600 13px var(--body); color: var(--accent); background: var(--surface); border: 1px solid var(--line); border-radius: 7px; padding: 6px 10px; cursor: pointer; }
.btn:hover { border-color: var(--accent); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.work { font: 500 13px var(--mono); color: var(--muted); margin: 0; overflow-wrap: anywhere; }
.work b { color: var(--fg); font-weight: 700; }
.more { font-size: 14px; font-weight: 600; text-decoration: none; }
.prose { max-width: 68ch; display: flex; flex-direction: column; gap: 14px; }
.prose h2 { font-family: var(--display); font-weight: 700; font-size: 24px; letter-spacing: -0.01em; margin: 12px 0 0; text-wrap: balance; }
.prose p, .prose li { margin: 0; }
.prose ul, .prose ol { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 6px; }
.formula { font: 600 16px var(--mono); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; overflow-x: auto; }
.examples { width: 100%; border-collapse: collapse; font-size: 15px; }
.examples th, .examples td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); }
.examples th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; }
.examples td:last-child { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.table-scroll { overflow-x: auto; }
details { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; }
details + details { margin-top: -4px; }
summary { cursor: pointer; font-weight: 600; }
details p { margin-top: 8px; color: var(--muted); }
.related h2 { font-family: var(--display); font-weight: 700; font-size: 22px; margin: 0 0 12px; }
.links { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 10px; }
.links a { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; text-decoration: none; color: var(--fg); font-weight: 600; }
.links a span { display: block; font-weight: 400; font-size: 13px; color: var(--muted); }
.links a:hover { border-color: var(--accent); }
footer { color: var(--muted); font-size: 13px; border-top: 1px solid var(--line); padding-top: 18px; display: flex; flex-wrap: wrap; gap: 8px 18px; }
footer a { color: var(--muted); }
@media (max-width: 520px) {
  .wrap { gap: 22px; }
  .topbar { padding-block: 14px; }
  .brand { font-size: 19px; }
  .mark { width: 28px; height: 28px; font-size: 15px; border-radius: 7px; }
  h1 { font-size: 27px; }
  .lede { font-size: 15px; }
  .grid { gap: 12px; }
  .calc, .calc.primary { padding: 16px; gap: 12px; }
  .sentence, .calc.primary .sentence { font-size: 16px; }
  .num input { width: 6.5ch; font-size: 16px; padding: 7px 9px; }
  .num.pct input { padding-right: 24px; }
}
@media (prefers-reduced-motion: no-preference) { .answer { transition: color .15s; } }

/* ===== theme: pocket ===== */
/* fonts: https://fonts.googleapis.com/css2?family=Rubik:wght@400;500;700;800&family=Share+Tech+Mono&family=Roboto+Mono:wght@500;600&display=swap */
/* Pocket: each calculator is a little hardware calculator. Charcoal bodies, LCD answer screens, orange keys. */
:root {
  --bg: #e4e6ea; --surface: #ffffff; --fg: #1f2226; --muted: #5d636c; --line: #c9cdd4;
  --accent: #f26a1b; --accent-soft: #ffe7d6; --good: #1d6b2f; --bad: #a3271c; --field: #3a3e45;
  --body-dark: #2a2d33; --lcd: #b7c4a0; --lcd-ink: #1e2a14;
  --display: "Rubik", system-ui, sans-serif;
  --body: "Rubik", system-ui, sans-serif;
  --mono: "Roboto Mono", ui-monospace, Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #15171b; --surface: #1f2226; --fg: #e9ebee; --muted: #a1a7b0; --line: #343840; --accent-soft: #3a2616; --good: #6fd38a; --bad: #ff8a7a; color-scheme: dark; }
}
.brand { font-weight: 800; }
.mark { background: var(--accent); color: #fff; border-radius: 50%; }
h1 { font-weight: 800; letter-spacing: -0.03em; }
.calc {
  background: var(--body-dark); border: 0; border-radius: 22px; padding: 22px;
  box-shadow: inset 0 2px 0 rgba(255,255,255,.08), 0 10px 24px rgba(20,22,26,.18);
  color: #e9ebee;
}
.calc.primary { border: 0; box-shadow: inset 0 2px 0 rgba(255,255,255,.08), 0 14px 30px rgba(20,22,26,.25); }
.calc h2 { color: #9aa0a9; font-weight: 500; letter-spacing: 0.14em; }
.calc h2 a:hover { color: var(--accent); }
.sentence { color: #e9ebee; }
.num input { background: var(--field); color: #fff; border: 0; border-radius: 10px; box-shadow: inset 0 -3px 0 rgba(0,0,0,.35); font-family: var(--mono); }
.num.pct::after { color: #b8bdc5; }
.num input:focus { box-shadow: inset 0 -3px 0 rgba(0,0,0,.35), 0 0 0 3px var(--accent); }
.result { order: -1; background: none; border-radius: 0; padding: 0; min-height: 0; flex-direction: column; align-items: stretch; gap: 10px; }
.calc h2 { order: -2; }
.answer, .answer.up, .answer.down, .answer.empty {
  display: block; background: var(--lcd); border-radius: 8px; border: 3px solid #14161a;
  box-shadow: inset 0 3px 8px rgba(0,0,0,.25); padding: 10px 14px; min-height: 70px;
  color: var(--lcd-ink); font-family: "Share Tech Mono", var(--mono); font-size: clamp(30px, 4.6vw, 40px); font-weight: 400; text-align: right; line-height: 1.3;
}
.answer.empty { color: #4a5a3a; font-size: 18px; display: flex; align-items: center; justify-content: flex-end; }
.actions { justify-content: flex-end; }
.btn { background: var(--accent); color: #fff; border: 0; border-radius: 999px; box-shadow: inset 0 -2px 0 rgba(0,0,0,.25); font-size: 12px; padding: 6px 12px; }
.btn:hover { filter: brightness(1.08); }
.work { color: #b8bdc5; }
.work b { color: #fff; }
.formula { background: var(--body-dark); color: var(--lcd); border: 0; border-radius: 12px; font-family: "Share Tech Mono", var(--mono); font-size: 19px; }
details { border-radius: 14px; }
.links a { border-radius: 14px; }
.links a:hover { border-color: var(--accent); }
.topbar nav a[aria-current="page"] { color: var(--accent); }
