:root {
  --bg: #faf7f2;
  --surface: #ffffff;
  --text: #292524;
  --muted: #78716c;
  --border: #e7e0d8;
  --accent: #b45309;
  --accent-dark: #92400e;
  --result-bg: #fef3e2;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
}

.wrap {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* Header */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.site-header .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1.5rem;
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
}
.brand {
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text);
  text-decoration: none;
}
.site-header nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
}
.site-header nav a {
  color: var(--accent-dark);
  text-decoration: none;
  font-size: 0.95rem;
}
.site-header nav a:hover { text-decoration: underline; }

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

h1 { font-size: 1.7rem; line-height: 1.25; margin: 0.5rem 0 0.25rem; }
h2 { font-size: 1.25rem; margin-top: 2rem; }
.lede { color: var(--muted); margin-top: 0; }

/* Calculator card */
.tool {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
  margin: 1.25rem 0;
}
.tool h2:first-child { margin-top: 0; }

.fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.75rem 1rem;
  margin-bottom: 1rem;
}
.field label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.2rem;
}
input, select {
  width: 100%;
  padding: 0.5rem 0.6rem;
  font: inherit;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
}
input:focus, select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}

fieldset {
  border: 1px solid var(--border);
  border-radius: 8px;
  margin: 0 0 1rem;
  padding: 0.75rem 1rem 1rem;
}
legend { font-weight: 600; font-size: 0.9rem; padding: 0 0.35rem; }

/* Results */
.results {
  background: var(--result-bg);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin-top: 1rem;
}
.big-result {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent-dark);
  margin: 0 0 0.25rem;
}
.muted { color: var(--muted); }

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.75rem 0;
}
th, td {
  text-align: left;
  padding: 0.45rem 0.6rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
}
th { font-weight: 600; }
td input { min-width: 4rem; }

@media (max-width: 480px) {
  th, td { padding: 0.35rem 0.3rem; }
  td input { min-width: 3.2rem; }
}

button {
  font: inherit;
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
button:hover { border-color: var(--accent); color: var(--accent-dark); }
button.remove {
  padding: 0.1rem 0.5rem;
  line-height: 1.4;
  color: var(--muted);
}
button.remove:hover { color: #b91c1c; border-color: #b91c1c; }

/* Tool cards on the homepage */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
  padding: 0;
  list-style: none;
}
.tool-grid a {
  display: block;
  height: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.25rem;
  color: inherit;
  text-decoration: none;
}
.tool-grid a:hover { border-color: var(--accent); }
.tool-grid h2 { margin: 0 0 0.35rem; font-size: 1.1rem; color: var(--accent-dark); }
.tool-grid p { margin: 0; font-size: 0.92rem; color: var(--muted); }

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 1.25rem 0 1.5rem;
  font-size: 0.9rem;
  color: var(--muted);
}
.site-footer nav { display: flex; gap: 1rem; margin-bottom: 0.5rem; }
.site-footer a { color: var(--accent-dark); text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }
.site-footer p { margin: 0; }
