:root {
  --bg: #faf9f7;
  --surface: #ffffff;
  --ink: #1c1917;
  --muted: #57534e;
  --line: #e7e5e4;
  --accent: #b45309;
  --accent-ink: #92400e;
  --accent-soft: #fef3e2;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.6;
  font-size: 17px;
}

header.site {
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

header.site .wrap {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  padding: 0.9rem 1.25rem;
}

.brand {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -0.01em;
}

.brand span { color: var(--accent); }

.tagline { color: var(--muted); font-size: 0.85rem; }

main, header.site .wrap, footer .wrap {
  max-width: 760px;
  margin: 0 auto;
}

main { padding: 1.5rem 1.25rem 3rem; }

h1 { font-size: 1.7rem; line-height: 1.25; margin: 0.5rem 0 0.4rem; letter-spacing: -0.01em; }
h2 { font-size: 1.25rem; margin: 2.2rem 0 0.6rem; }
h3 { font-size: 1.05rem; margin: 1.4rem 0 0.4rem; }

p.lead { color: var(--muted); margin-top: 0; }

a { color: var(--accent-ink); }

/* Calculator */
.calc {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1rem;
  margin: 1.25rem 0;
}

.calc table { width: 100%; border-collapse: collapse; }

.calc th {
  text-align: left;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  padding: 0.3rem 0.35rem;
  font-weight: 600;
}

.calc td { padding: 0.25rem 0.35rem; }

.calc input, .calc select {
  width: 100%;
  padding: 0.55rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
  color: var(--ink);
  background: var(--surface);
  min-width: 0;
}

.calc input:focus, .calc select:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: var(--accent);
}

.calc td.bf {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  font-weight: 600;
  min-width: 4.5rem;
}

.calc td.remove { width: 2rem; text-align: center; }

.calc button.x {
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0.3rem;
  line-height: 1;
}
.calc button.x:hover { color: var(--accent-ink); }

.calc-actions { margin-top: 0.6rem; }

button.add {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.5rem 0.9rem;
  font-size: 0.95rem;
  font-family: inherit;
  cursor: pointer;
  color: var(--accent-ink);
  font-weight: 600;
}
button.add:hover { background: var(--accent-soft); border-color: var(--accent); }

.totals {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 2px solid var(--ink);
}

.totals .box {
  background: var(--accent-soft);
  border-radius: 10px;
  padding: 0.6rem 1rem;
  flex: 1 1 10rem;
}

.totals .label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent-ink);
  font-weight: 600;
}

.totals .value {
  font-size: 1.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.hint { font-size: 0.85rem; color: var(--muted); margin: 0.5rem 0 0; }

/* Content */
.example, .note {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  padding: 0.9rem 1.1rem;
  margin: 1rem 0;
}

table.ref {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  font-variant-numeric: tabular-nums;
}

table.ref th, table.ref td {
  padding: 0.5rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--line);
}

table.ref th {
  background: var(--bg);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

table.ref tr:last-child td { border-bottom: 0; }

.table-scroll { overflow-x: auto; }

.formula {
  background: var(--ink);
  color: #fafaf9;
  border-radius: 8px;
  padding: 0.8rem 1.1rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.95rem;
  overflow-x: auto;
}

details.faq {
  border-bottom: 1px solid var(--line);
  padding: 0.6rem 0;
}

details.faq summary {
  font-weight: 600;
  cursor: pointer;
  padding: 0.25rem 0;
}

details.faq p { margin: 0.5rem 0 0.25rem; color: var(--muted); }

/* Homepage cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: 1rem; margin: 1.5rem 0; }

a.card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1.1rem 1.2rem;
  text-decoration: none;
  color: var(--ink);
}
a.card:hover { border-color: var(--accent); }
a.card .card-title { font-weight: 700; color: var(--accent-ink); margin-bottom: 0.25rem; }
a.card .card-desc { font-size: 0.9rem; color: var(--muted); }

.card.soon {
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 1.1rem 1.2rem;
  color: var(--muted);
}
.card.soon .card-title { font-weight: 700; margin-bottom: 0.25rem; }
.card.soon .card-desc { font-size: 0.9rem; }

footer {
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.85rem;
}
footer .wrap { padding: 1.25rem; }

@media (max-width: 540px) {
  body { font-size: 16px; }
  .calc { padding: 0.6rem; margin-left: -0.6rem; margin-right: -0.6rem; }
  .calc th, .calc td { padding: 0.2rem 0.15rem; }
  .totals .value { font-size: 1.25rem; }
}
