:root {
  color-scheme: light dark;
  --bg: #ffffff;
  --fg: #1a1a1a;
  --muted: #5f6368;
  --border: #d7dbe0;
  --accent: #1a56db;
  --accent-fg: #ffffff;
  --error: #b3261e;
  --surface: #f7f8fa;
  --radius: 8px;
  --max-width: 720px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --fg: #e8eaed;
    --muted: #9aa0a6;
    --border: #33373d;
    --accent: #7aa2f7;
    --accent-fg: #14161a;
    --error: #f28b82;
    --surface: #1c1f24;
  }
}

* {
  box-sizing: border-box;
}

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

main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1.5rem 1rem 4rem;
}

h1, h2, h3 {
  line-height: 1.25;
}

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

label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

input, select {
  width: 100%;
  padding: 0.5rem 0.6rem;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--fg);
}

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

input.invalid, select.invalid {
  border-color: var(--error);
}

button {
  font-size: 1rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--fg);
  cursor: pointer;
}

.field {
  margin-bottom: 1rem;
}

.error-text {
  color: var(--error);
  font-size: 0.9rem;
  margin-top: 0.25rem;
}

.error-text ul {
  margin: 0;
  padding-left: 1.25rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th, td {
  text-align: right;
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid var(--border);
}

th:first-child, td:first-child {
  text-align: left;
}

/* Generic calculator-widget patterns shared by every calculator page --
   moved here rather than kept per-calculator so a new calculator gets
   them for free. See AGENTS.md "Layout-shift reservation": #results and
   .loading-indicator are always rendered at final size, never
   hidden/display:none after first paint. */

.row {
  display: flex;
  gap: 0.75rem;
}

.radio-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 400;
}

.radio-label input {
  width: auto;
}

.loading-indicator {
  visibility: hidden;
  min-height: 1.5em;
  margin: 0.5rem 0;
  color: var(--muted);
}

.loading-indicator.visible {
  visibility: visible;
}

#results {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.results-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.4rem 1rem;
  margin: 0;
}

.results-grid dt {
  color: var(--muted);
}

.results-grid dd {
  margin: 0;
  font-weight: 600;
  text-align: right;
}

.table-scroll {
  overflow-x: auto;
  margin-top: 1rem;
}

.content-section,
.faq {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.content-section h3,
.faq h3 {
  font-size: 1.05rem;
}

.content-section p,
.faq p {
  color: var(--muted);
}

@media (max-width: 480px) {
  .row {
    flex-direction: column;
  }

  .results-grid {
    grid-template-columns: 1fr;
    text-align: left;
  }

  .results-grid dd {
    text-align: left;
    margin-bottom: 0.5rem;
  }
}
