:root {
  --bg: #fbfaf8;
  --surface: #ffffff;
  --surface-2: #f4f2ee;
  --border: #e2ded6;
  --border-strong: #cdc7bb;
  --text: #23201c;
  --text-dim: #5f594f;
  --text-faint: #8a8377;
  --accent: #8a5a2b;
  --accent-soft: #f2e7da;
  --good: #2f6b46;
  --warn: #8a5a2b;
  --radius: 10px;
  --maxw: 46rem;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #171614;
    --surface: #1f1e1b;
    --surface-2: #262421;
    --border: #35322d;
    --border-strong: #4a463f;
    --text: #eae7e1;
    --text-dim: #b3ada2;
    --text-faint: #8b857a;
    --accent: #d9a06a;
    --accent-soft: #2e261d;
    --good: #7bbd95;
    --warn: #d9a06a;
  }
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.65;
}

.skip {
  position: absolute;
  left: -9999px;
}
.skip:focus {
  left: 0.5rem;
  top: 0.5rem;
  z-index: 10;
  background: var(--surface);
  padding: 0.5rem 0.75rem;
  border: 2px solid var(--accent);
  border-radius: var(--radius);
}

/* ---------- structure ---------- */

.masthead {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.masthead > div,
main,
.footer > div {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 1.1rem;
}
.masthead > div {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.1rem;
  align-items: baseline;
  padding-top: 0.85rem;
  padding-bottom: 0.85rem;
}
.wordmark {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  color: var(--text);
  text-decoration: none;
}
.masthead nav {
  display: flex;
  gap: 1rem;
  font-size: 0.94rem;
  margin-left: auto;
}
.masthead nav a { color: var(--text-dim); }

main { padding-top: 1.6rem; padding-bottom: 3rem; }

.footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  font-size: 0.88rem;
  color: var(--text-dim);
}
.footer > div { padding-top: 1.6rem; padding-bottom: 2rem; }
.footer nav { display: flex; flex-wrap: wrap; gap: 0.9rem; margin-bottom: 0.8rem; }
.footer p { margin: 0.5rem 0; }

/* ---------- type ---------- */

h1 { font-size: 1.85rem; line-height: 1.22; letter-spacing: -0.02em; margin: 0 0 0.6rem; }
h2 { font-size: 1.28rem; line-height: 1.3; letter-spacing: -0.01em; margin: 2.2rem 0 0.7rem; }
h3 { font-size: 1.05rem; margin: 1.6rem 0 0.5rem; }
p { margin: 0 0 1rem; }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
ul, ol { padding-left: 1.25rem; margin: 0 0 1rem; }
li { margin-bottom: 0.35rem; }
small { font-size: 0.85rem; color: var(--text-dim); }
code { font-family: var(--mono); font-size: 0.9em; background: var(--surface-2); padding: 0.1em 0.35em; border-radius: 4px; }

.lede { font-size: 1.08rem; color: var(--text-dim); margin-bottom: 1.5rem; }

.crumbs {
  font-size: 0.85rem;
  color: var(--text-faint);
  margin-bottom: 1.1rem;
}
.crumbs a { color: var(--text-dim); }
.crumbs span { padding: 0 0.35rem; }

/* ---------- calculator ---------- */

.calc {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 1.15rem;
  margin: 1.4rem 0 1.8rem;
}
.calc h2 { margin-top: 0; }
.field { margin-bottom: 0.95rem; }
.field label {
  display: block;
  font-weight: 600;
  font-size: 0.93rem;
  margin-bottom: 0.3rem;
}
.field .hint {
  display: block;
  font-weight: 400;
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-top: 0.15rem;
}
input[type="number"], select {
  width: 100%;
  font: inherit;
  font-size: 1rem;
  padding: 0.5rem 0.6rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: 7px;
}
input[type="number"]:focus, select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.row { display: flex; gap: 0.6rem; }
.row > * { flex: 1; }
.row .unit { flex: 0 0 6.5rem; }

.out {
  margin-top: 1.1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}
.out .headline {
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
  margin-bottom: 0.15rem;
}
.out .headline .unit-label { font-size: 0.95rem; font-weight: 500; color: var(--text-dim); }
.out .sub { font-size: 0.92rem; color: var(--text-dim); margin-bottom: 0.8rem; }
.out dl { display: grid; grid-template-columns: auto 1fr; gap: 0.3rem 0.9rem; margin: 0.7rem 0 0; font-size: 0.93rem; }
.out dt { color: var(--text-dim); }
.out dd { margin: 0; font-variant-numeric: tabular-nums; }
.out .empty { color: var(--text-faint); font-size: 0.95rem; }

.flag {
  margin-top: 0.9rem;
  padding: 0.6rem 0.75rem;
  border-radius: 7px;
  font-size: 0.9rem;
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
}

.air-fields {
  margin: 1.15rem 0 0;
  padding: 0.9rem;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface-2);
}
.air-fields > p { margin-top: 0; font-size: 0.92rem; }
.air-fields .field:last-child { margin-bottom: 0; }

.food-compare, .comparison {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
}
.food-panel {
  min-width: 0;
  padding: 0.9rem;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface-2);
}
.food-panel h3 { margin: 0 0 0.8rem; font-size: 1rem; }
.food-panel .field:last-child { margin-bottom: 0; }
.comparison { margin-top: 1rem; }
.comparison > div {
  min-width: 0;
  padding: 0.8rem;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface-2);
}
.comparison h3 { margin: 0 0 0.65rem; font-size: 1rem; }
.comparison dl { grid-template-columns: 1fr; gap: 0.1rem; margin: 0; }
.comparison dt { font-size: 0.84rem; }
.comparison dd { margin-bottom: 0.55rem; font-weight: 600; }

.note {
  background: var(--surface-2);
  border-left: 3px solid var(--border-strong);
  padding: 0.75rem 0.9rem;
  border-radius: 0 7px 7px 0;
  font-size: 0.92rem;
  margin: 1.2rem 0;
}
.note strong { color: var(--text); }

/* ---------- data ---------- */

.tablewrap { overflow-x: auto; margin: 1.1rem 0; }
table { border-collapse: collapse; width: 100%; font-size: 0.93rem; }
th, td { text-align: left; padding: 0.5rem 0.7rem; border-bottom: 1px solid var(--border); }
th { font-weight: 600; color: var(--text-dim); font-size: 0.87rem; }
td { font-variant-numeric: tabular-nums; }
caption { text-align: left; font-size: 0.87rem; color: var(--text-dim); padding-bottom: 0.5rem; }

.cards { display: grid; gap: 0.7rem; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); margin: 1.2rem 0; padding: 0; list-style: none; }
.cards li { margin: 0; }
.cards a {
  display: block;
  height: 100%;
  padding: 0.8rem 0.9rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
}
.cards a:hover { border-color: var(--accent); }
.cards .t { font-weight: 650; display: block; margin-bottom: 0.15rem; }
.cards .d { font-size: 0.88rem; color: var(--text-dim); }

.breedlist { columns: 2 12rem; column-gap: 1.4rem; padding: 0; list-style: none; margin: 0.8rem 0 1.4rem; }
.breedlist li { margin: 0 0 0.4rem; break-inside: avoid; }
.breedlist .kg { color: var(--text-faint); font-size: 0.85rem; font-variant-numeric: tabular-nums; }

.srcline { font-size: 0.85rem; color: var(--text-dim); margin-top: 1.5rem; padding-top: 0.9rem; border-top: 1px solid var(--border); }

@media (max-width: 30rem) {
  body { font-size: 16px; }
  h1 { font-size: 1.5rem; }
  .row { flex-wrap: wrap; }
  .row .unit { flex: 1 1 100%; }
  .food-compare, .comparison { grid-template-columns: 1fr; }
}
