:root {
  color-scheme: light dark;
  --bg: #ffffff;
  --surface: #f4f6f9;
  --text: #18212e;
  --muted: #4a5565;
  --accent: #0b57c2;
  --on-accent: #ffffff;
  --border: #717b8a;
  --focus: #0b57c2;
  --highlight: #e3ecfb;
  --band-negative: #b3261e;
  --band-low: #8f4a00;
  --band-moderate: #1f4fb8;
  --band-healthy: #0b6b3a;
  --band-high: #6a3fb5;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #10151c;
    --surface: #19212c;
    --text: #e7edf4;
    --muted: #a9b4c3;
    --accent: #7fb0ff;
    --on-accent: #10151c;
    --border: #7a8698;
    --focus: #8fbaff;
    --highlight: #20314d;
    --band-negative: #ff9a8f;
    --band-low: #f3b65c;
    --band-moderate: #9cc1ff;
    --band-healthy: #6fd6a0;
    --band-high: #c9b0ff;
  }
}

/* Theme tokens (:root custom properties) are generated from src/theme.js and prepended by the build. */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.6;
}

a {
  color: var(--accent);
  text-underline-offset: 0.15em;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

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

h1 {
  font-size: clamp(1.9rem, 4vw + 1rem, 2.8rem);
  margin-block: 0 0.5rem;
}

h2 {
  font-size: 1.6rem;
  margin-block: 0 1rem;
}

h3 {
  font-size: 1.15rem;
  margin-block: 1.5rem 0.75rem;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.95em;
}

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

.wrap {
  max-width: 72rem;
  margin-inline: auto;
  padding-inline: 1rem;
}

.prose {
  max-width: 50rem;
}

.muted,
.hint {
  color: var(--muted);
}

.skip {
  position: absolute;
  inset-inline-start: 1rem;
  inset-block-start: -10rem;
  z-index: 10;
  padding: 0.5rem 1rem;
  background: var(--accent);
  color: var(--on-accent);
  border-radius: 0.375rem;
}

.skip:focus {
  inset-block-start: 1rem;
}

/* Header */
.site-header {
  border-block-end: 1px solid var(--border);
  background: var(--bg);
}

.header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1.5rem;
  padding-block: 0.75rem;
}

.brand {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
  text-decoration: none;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.nav a {
  color: var(--text);
  text-decoration: none;
}

.nav a:hover {
  text-decoration: underline;
}

.lang {
  position: relative;
  margin-inline-start: auto;
}

.lang summary {
  cursor: pointer;
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
}

.lang ul {
  position: absolute;
  inset-inline-end: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(2, minmax(9rem, 1fr));
  gap: 0.125rem 0.75rem;
  max-height: 70vh;
  overflow-y: auto;
  margin: 0.375rem 0 0;
  padding: 0.75rem;
  list-style: none;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.18);
}

.lang a {
  display: block;
  padding: 0.2rem 0.25rem;
}

.lang a[aria-current="page"] {
  font-weight: 700;
  color: var(--text);
}

/* Sections */
.hero {
  padding-block: 2.5rem 1rem;
}

.lead {
  font-size: 1.15rem;
  color: var(--muted);
  max-width: 44rem;
  margin: 0;
}

.section {
  padding-block: 2rem;
}

.section + .section {
  border-block-start: 1px solid var(--surface);
}

.notice {
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: var(--surface);
}

/* Calculator */
.calc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr));
  gap: 1rem;
  align-items: start;
}

.card {
  padding: 1.25rem;
  background: var(--surface);
  border-radius: 0.75rem;
}

.card h3 {
  margin-block-start: 0;
}

.field {
  margin-block-end: 0.9rem;
}

.field label {
  display: block;
  font-weight: 600;
  margin-block-end: 0.25rem;
}

.field .hint {
  margin: 0.25rem 0 0;
  font-size: 0.875rem;
}

input,
select,
button {
  font: inherit;
  color: inherit;
}

input,
select {
  width: 100%;
  min-height: 2.5rem;
  padding: 0.4rem 0.6rem;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 0.375rem;
}

.segmented {
  display: inline-flex;
  margin-block-end: 1rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  overflow: hidden;
}

.segmented button {
  min-height: 2.25rem;
  padding: 0.3rem 1rem;
  border: 0;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
}

.segmented button[aria-pressed="true"] {
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
}

.total {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin: 0.5rem 0 0;
  padding-block-start: 0.75rem;
  border-block-start: 1px solid var(--border);
}

.cap {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 0.75rem;
  margin: 0;
}

.cap-label {
  font-weight: 600;
}

.cap-value {
  font-size: 2.25rem;
  line-height: 1.1;
}

.band-tag {
  font-weight: 700;
}

.band-negative {
  color: var(--band-negative);
}

.band-low {
  color: var(--band-low);
}

.band-moderate {
  color: var(--band-moderate);
}

.band-healthy {
  color: var(--band-healthy);
}

.band-high {
  color: var(--band-high);
}

.status {
  min-height: 1.6em;
  margin-block: 0.5rem;
  color: var(--muted);
}

.summary th,
.summary td {
  padding: 0.35rem 0;
  border-block-end: 1px solid var(--border);
}

.summary th {
  font-weight: 400;
  text-align: start;
}

.summary td {
  text-align: end;
  font-variant-numeric: tabular-nums;
  padding-inline-start: 0.75rem;
}

.results .field {
  margin-block-start: 1rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.button {
  display: inline-block;
  min-height: 2.5rem;
  padding: 0.45rem 1.1rem;
  border: 1px solid var(--accent);
  border-radius: 0.375rem;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.button.secondary {
  background: var(--bg);
  color: var(--accent);
}

/* Content tables */
.data {
  margin-block: 1rem;
}

.data th,
.data td {
  padding: 0.5rem 0.5rem;
  border-block-end: 1px solid var(--border);
  text-align: start;
  vertical-align: top;
}

.data thead th {
  border-block-end-width: 2px;
}

.data .num {
  text-align: end;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.data tfoot th,
.data tfoot td {
  font-weight: 700;
}

.bands tr[aria-current="true"] {
  background: var(--highlight);
}

.your-result {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
}

.your-result[hidden] {
  display: none;
}

.your-result::before {
  content: "● ";
}

.steps li {
  margin-block-end: 0.75rem;
}

/* FAQ */
.faq-item {
  border-block-end: 1px solid var(--border);
  padding-block: 0.75rem;
}

.faq-item summary {
  cursor: pointer;
  font-weight: 600;
}

.faq-item p {
  margin-block: 0.5rem 0;
}

/* Footer */
.site-footer {
  margin-block-start: 2rem;
  padding-block: 1.5rem;
  border-block-start: 1px solid var(--border);
  font-size: 0.9rem;
}

.site-footer p {
  margin-block: 0.25rem;
}

/* Footer page links and breadcrumb (PLAN E4.3) */
.footer-links,
.breadcrumb ol {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  margin: 0 0 0.75rem;
  padding: 0;
  list-style: none;
}

.breadcrumb ol {
  gap: 0.25rem 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.breadcrumb li + li::before {
  content: "/";
  margin-inline: 0.5rem;
}

.lang-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr));
  gap: 0.25rem 1rem;
  padding: 0;
  list-style: none;
}

@media (max-width: 40rem) {
  .lang {
    margin-inline-start: 0;
  }

  .lang ul {
    inset-inline-end: auto;
    inset-inline-start: 0;
    grid-template-columns: repeat(2, minmax(7.5rem, 1fr));
  }

  .data th,
  .data td {
    padding-inline: 0.25rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }
}
