:root {
  --bg: #faf8f5;
  --fg: #1f1d1a;
  --muted: #5d5850;
  --accent: #b5651d;
  --line: #e4ded5;
  --card: #ffffff;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1a18;
    --fg: #f1ede6;
    --muted: #b3ab9f;
    --accent: #f2a65a;
    --line: #36332e;
    --card: #242220;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 17px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
main { max-width: 760px; margin: 0 auto; padding: 32px 16px 64px; }
header.brand { display: flex; align-items: center; gap: 14px; margin-bottom: 24px; }
header.brand img { width: 56px; height: 56px; border-radius: 14px; }
header.brand a { color: inherit; text-decoration: none; font-weight: 700; font-size: 22px; }
nav.lang { margin-left: auto; font-size: 15px; }
h1 { font-size: 30px; line-height: 1.25; margin: 8px 0 4px; }
h2 { font-size: 21px; margin: 36px 0 8px; padding-top: 12px; border-top: 1px solid var(--line); }
h3 { font-size: 17px; margin: 20px 0 4px; }
p.meta { color: var(--muted); margin-top: 0; }
a { color: var(--accent); }
ul { padding-left: 22px; }
li { margin: 4px 0; }
table { width: 100%; border-collapse: collapse; margin: 12px 0; font-size: 15px; }
th, td { text-align: left; vertical-align: top; padding: 8px 10px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; }
.table-wrap { overflow-x: auto; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; margin: 16px 0; }
.lead { font-size: 19px; color: var(--muted); }
footer { margin-top: 48px; color: var(--muted); font-size: 14px; }

/* Calculators */
:root { --warn: #9a4b00; --warn-bg: #fdf0e1; --field: #ffffff; }
@media (prefers-color-scheme: dark) {
  :root { --warn: #f5b26b; --warn-bg: #3a2a1a; --field: #1f1d1b; }
}
header.brand nav.lang { display: flex; gap: 14px; align-items: center; }
header.brand nav a { font-size: 15px; font-weight: 400; color: var(--accent); }
header.brand a.get { background: var(--accent); color: var(--bg); padding: 6px 12px; border-radius: 999px; text-decoration: none; font-weight: 600; font-size: 15px; white-space: nowrap; }
nav.crumbs { font-size: 14px; color: var(--muted); margin-bottom: 4px; }
nav.crumbs a { color: var(--muted); }

form.calc { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px 16px; }
form.calc label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; font-weight: 600; color: var(--muted); }
form.calc label.check { flex-direction: row; align-items: center; gap: 8px; align-self: end; padding-bottom: 10px; }
form.calc input[type=text], form.calc select {
  font: inherit; font-weight: 400; color: var(--fg); background: var(--field);
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; width: 100%; min-width: 0;
}
form.calc input:focus, form.calc select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
form.calc .wide { grid-column: 1 / -1; }
form.calc [hidden] { display: none; }
.hint { font-size: 14px; color: var(--muted); margin: 8px 0 0; }

#out { margin-top: 18px; }
dl.results { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; margin: 0; }
dl.results .r { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--bg); }
dl.results dt { font-size: 13px; color: var(--muted); }
dl.results dd { margin: 2px 0 0; font-size: 19px; font-weight: 600; font-variant-numeric: tabular-nums; }
dl.results .big dd { font-size: 24px; color: var(--accent); }
dl.results small { display: block; font-size: 13px; font-weight: 400; color: var(--muted); }
p.error { color: var(--warn); font-weight: 600; margin: 0; }
ul.warn { background: var(--warn-bg); color: var(--warn); border-radius: 10px; padding: 10px 12px 10px 30px; margin: 12px 0 0; font-size: 15px; }
details.marks { margin-top: 14px; }
details.marks summary { cursor: pointer; font-weight: 600; }
ol.marks { columns: 3 140px; font-variant-numeric: tabular-nums; margin: 8px 0 0; }
svg.figure { width: 100%; height: auto; max-height: 320px; color: var(--fg); margin-top: 16px; }
svg.figure text { font: 13px sans-serif; fill: var(--muted); }

aside.cta { display: flex; gap: 16px; align-items: flex-start; background: var(--card); border: 2px solid var(--accent); border-radius: 14px; padding: 18px; margin: 28px 0; }
aside.cta img { width: 64px; height: 64px; border-radius: 14px; flex: none; }
aside.cta h2 { border: 0; margin: 0 0 4px; padding: 0; font-size: 19px; }
aside.cta p { margin: 0 0 10px; }
.stores { display: flex; flex-wrap: wrap; gap: 10px; }
a.store { display: inline-block; background: var(--fg); color: var(--bg); text-decoration: none; font-weight: 600; padding: 10px 16px; border-radius: 10px; }
a.store small { display: block; font-size: 11px; font-weight: 400; opacity: .8; }
a.store[hidden] { display: none; }
p.small { font-size: 14px; color: var(--muted); margin: 8px 0 0; }

.keys { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.keys button, .chips button { font: inherit; font-size: 16px; min-width: 44px; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--fg); cursor: pointer; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chips button { font-size: 14px; }
table.lumber input { width: 100%; }
table.lumber td { padding: 4px; }
table.lumber button { font: inherit; border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 18px; }
button.add { font: inherit; margin-top: 8px; padding: 6px 12px; border-radius: 8px; border: 1px dashed var(--line); background: none; color: var(--accent); cursor: pointer; }
ul.tools { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
ul.tools li { margin: 0; }
ul.tools a { display: block; height: 100%; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; color: var(--fg); text-decoration: none; }
ul.tools a strong { color: var(--accent); display: block; }
ul.tools a span { font-size: 14px; color: var(--muted); }
.formula { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 15px; background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; overflow-x: auto; }
@media (max-width: 480px) {
  aside.cta { flex-direction: column; }
  header.brand { flex-wrap: wrap; gap: 10px; }
  header.brand img { width: 44px; height: 44px; border-radius: 11px; }
  header.brand a.get { padding: 5px 10px; font-size: 14px; }
}
