/* Lisa's Futterrechner
   Hell und gut lesbar: weißer Grund, dunkle Schrift, Salbei als Hauptfarbe, Terrakotta als Akzent.
   Die Rechner sind klar abgegrenzte Module und stehen im Mittelpunkt. */

:root {
  --bg: #ffffff;
  --bg-soft: #f6f7f5;
  --ink: #1d221f;
  --ink-2: #3f4642;
  --muted: #646b67;
  --line: #e3e6e2;
  --line-2: #cdd3cd;
  --sage: #3f6149;
  --sage-dark: #2c4634;
  --sage-soft: #eef3ec;
  --sage-tint: #f5f8f3;
  --terra: #b0532f;
  --terra-soft: #f8e9e1;
  --ochre: #c9953d;
  --error: #a3341f;

  --serif: "Fraunces", "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: "Source Sans 3", "Segoe UI", -apple-system, system-ui, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SFMono-Regular", Consolas, monospace;

  --radius: 10px;
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 76px; }
@media (max-width: 980px) { html { scroll-padding-top: 108px; } }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 16.5px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--sage-soft); }

h1, h2, h3, h4 { margin: 0; font-weight: 700; line-height: 1.2; color: var(--ink); letter-spacing: -.005em; }
p { margin: 0; }
a { color: var(--sage); }
sup { font-size: .66em; line-height: 0; }
abbr { text-decoration: none; color: var(--muted); font-weight: 400; font-size: .9em; margin-left: 2px; }

:focus-visible { outline: 2px solid var(--sage); outline-offset: 2px; }

.wrap { width: min(1120px, 100% - 40px); margin-inline: auto; }

.kicker {
  font-size: .78rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--terra); margin-bottom: 4px;
}

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 20;
  background: rgba(255, 255, 255, .96);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}
.header-inner { display: flex; align-items: center; gap: 28px; height: 60px; }
.brand { display: flex; align-items: center; gap: 9px; text-decoration: none; color: var(--ink); }
.paw { width: 24px; height: 24px; fill: var(--terra); flex: none; }
.brand-name { font-family: var(--serif); font-size: 1.22rem; white-space: nowrap; }
.brand-name em { font-style: italic; color: var(--sage); }

.main-nav { display: flex; gap: 22px; margin-left: auto; }
.main-nav a {
  text-decoration: none; color: var(--ink-2); font-size: .95rem; font-weight: 500;
  padding: 4px 0; border-bottom: 2px solid transparent;
}
.main-nav a:hover { color: var(--ink); border-bottom-color: var(--terra); }

.species-switch { display: inline-flex; border: 1px solid var(--line-2); border-radius: 8px; overflow: hidden; }
.species-switch button {
  border: 0; background: #fff; cursor: pointer; font: inherit; font-size: .9rem; font-weight: 600;
  padding: 5px 14px; color: var(--ink-2);
}
.species-switch button + button { border-left: 1px solid var(--line-2); }
.species-switch button[aria-checked="true"] { background: var(--sage); color: #fff; }

/* ---------- Intro ---------- */
.intro { padding: 44px 0 40px; background: var(--sage-tint); border-bottom: 1px solid var(--line); }
.intro-inner { display: grid; grid-template-columns: 1fr 260px; gap: 48px; align-items: center; }
.intro h1 { font-size: clamp(1.8rem, 3.6vw, 2.6rem); line-height: 1.12; letter-spacing: -.015em; }
.intro h1 span { color: var(--sage); }
.intro-lead { color: var(--ink-2); font-size: 1.06rem; max-width: 60ch; margin-top: 14px; }
.intro-points { list-style: none; padding: 0; margin: 18px 0 0; display: flex; flex-wrap: wrap; gap: 8px 24px; }
.intro-points li { position: relative; padding-left: 26px; font-weight: 600; font-size: .95rem; color: var(--sage-dark); }
.intro-points li::before {
  content: ""; position: absolute; left: 0; top: 50%; width: 18px; height: 18px; margin-top: -9px;
  border-radius: 50%; background: var(--sage);
}
.intro-points li::after {
  content: ""; position: absolute; left: 6px; top: 50%; width: 5px; height: 9px; margin-top: -6px;
  border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.intro-art { width: 100%; height: auto; display: block; }
.intro-video {
  display: inline-flex; align-items: center; gap: 10px; margin-top: 20px;
  padding: 9px 16px 9px 12px; border-radius: 999px; background: var(--sage); color: #fff;
  text-decoration: none; font-weight: 700; font-size: .95rem;
}
.intro-video svg { width: 18px; height: 18px; fill: currentColor; }
.intro-video span { font-weight: 400; opacity: .85; font-size: .88rem; }
.intro-video:hover { background: var(--sage-dark); }
.calc-video { background: var(--sage-tint); }
.video-frame { max-width: 1000px; }
.video-frame iframe { display: block; width: 100%; height: 640px; border: 0; background: transparent; }
html.video-fallback-fullscreen, html.video-fallback-fullscreen body { height: 100%; overflow: hidden; }
html.video-fallback-fullscreen #videoFrame {
  position: fixed !important; inset: 0 !important; z-index: 2147483647;
  width: 100vw !important; height: 100vh !important; height: 100dvh !important;
  max-width: none !important; border: 0 !important; background: #fff;
}
.video-more { margin-top: 12px; font-size: .95rem; }
.video-more a { font-weight: 600; }
.main-nav .nav-video { color: var(--sage); font-weight: 700; }

/* ---------- Abschnitte ---------- */
.calc { padding: 48px 0 52px; }
.calc + .calc { border-top: 1px solid var(--line); }
.calc-knowledge { background: var(--bg-soft); }

.chapter { display: grid; grid-template-columns: 52px 1fr; align-items: start; margin-bottom: 22px; }
.chapter-no {
  font-size: 1.05rem; font-weight: 700; color: var(--terra); font-variant-numeric: tabular-nums;
  width: 40px; height: 40px; border: 1.5px solid var(--terra); border-radius: 50%;
  display: grid; place-items: center; margin-top: 2px;
}
.chapter h2 { font-size: clamp(1.35rem, 2.3vw, 1.65rem); margin-bottom: 6px; }
.chapter p:not(.kicker) { color: var(--ink-2); max-width: 70ch; }

/* Rechner-Modul */
.calc-grid {
  display: grid; grid-template-columns: minmax(270px, 400px) 1fr; gap: 0; align-items: stretch;
  border: 1px solid var(--line-2); border-radius: var(--radius); background: #fff; overflow: hidden;
  box-shadow: 0 1px 2px rgba(29, 34, 31, .05);
}
.calc-grid > .form { padding: 26px 28px; }
.calc-grid > .result { border-left: 1px solid var(--line); }

.steps-wrap, .calc > .wrap > .note { margin-left: 0; }

/* ---------- Formulare ---------- */
.form { display: grid; gap: 20px; align-content: start; }
.field { display: grid; gap: 6px; border: 0; padding: 0; margin: 0; min-width: 0; }
.field-label { font-weight: 600; font-size: .95rem; color: var(--ink); padding: 0; }
.opt { font-weight: 400; color: var(--muted); font-size: .88em; margin-left: 4px; }
.field small, .hint { color: var(--muted); font-size: .87rem; line-height: 1.5; display: block; }

input, select {
  font: inherit; color: var(--ink); width: 100%;
  padding: 10px 12px; border: 1px solid var(--line-2); border-radius: 8px; background: #fff;
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:hover, select:hover { border-color: #aab2ab; }
input:focus, select:focus { outline: none; border-color: var(--sage); box-shadow: 0 0 0 3px var(--sage-soft); }
input.invalid { border-color: var(--error); background: #fdf1ee; }

.input-unit { position: relative; display: flex; }
.input-unit input { padding-right: 52px; font-variant-numeric: tabular-nums; font-size: 1.05rem; }
.input-unit > span {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  color: var(--muted); font-size: .92rem; pointer-events: none;
}
.input-unit.with-select input { padding-right: 12px; border-radius: 8px 0 0 8px; }
.input-unit.with-select select { width: auto; flex: none; border-left: 0; border-radius: 0 8px 8px 0; background: var(--bg-soft); font-size: .92rem; }
.input-short { max-width: 150px; }

/* Etikett-Optik für die Deklaration */
.field-group { border: 1.5px solid var(--ink); border-radius: 4px; background: #fff; padding: 2px 14px 4px; }
.field-group::before {
  content: "Analytische Bestandteile"; display: block;
  font-weight: 700; font-size: .8rem; letter-spacing: .06em; text-transform: uppercase;
  padding: 9px 0 8px; border-bottom: 1.5px solid var(--ink);
}
.field-inline { grid-template-columns: 1fr 124px; align-items: center; gap: 12px; padding: 6px 0; }
.field-inline + .field-inline { border-top: 1px solid var(--line); }
.field-inline .field-label { font-weight: 500; }
.field-inline input { padding-top: 7px; padding-bottom: 7px; text-align: right; padding-right: 32px; }
.field-inline .input-unit > span { right: 10px; }

.seg { display: flex; border: 1px solid var(--line-2); border-radius: 8px; overflow: hidden; background: #fff; }
.seg label { flex: 1 1 0; }
.seg label + label { border-left: 1px solid var(--line-2); }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg span { display: block; text-align: center; cursor: pointer; font-size: .94rem; font-weight: 500; padding: 9px 10px; color: var(--ink-2); }
.seg span:hover { background: var(--bg-soft); }
.seg input:checked + span { background: var(--sage); color: #fff; }
.seg input:focus-visible + span { outline: 2px solid var(--sage-dark); outline-offset: -4px; }

.check { display: flex; gap: 10px; align-items: center; cursor: pointer; font-size: .95rem; }
.check input { width: 18px; height: 18px; accent-color: var(--sage); margin: 0; }

.presets { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: .9rem; color: var(--muted); }
.chip {
  font: inherit; font-size: .88rem; font-weight: 600; cursor: pointer; color: var(--sage-dark);
  padding: 4px 12px; border-radius: 999px; border: 1px solid var(--line-2); background: #fff;
}
.chip:hover { background: var(--sage-soft); border-color: var(--sage); }

.msg { font-size: .9rem; color: var(--error); font-weight: 600; }
.msg:empty { display: none; }
.msg.warn { color: #7d5a14; }

.rows { display: grid; gap: 8px; }
.row { display: grid; grid-template-columns: 1fr 100px 32px; gap: 8px; align-items: center; }
.row .input-unit input { min-width: 0; padding-right: 30px; text-align: right; }
.row .input-unit > span { right: 10px; }
.row .remove {
  border: 0; background: transparent; cursor: pointer; color: var(--muted); font-size: 1.3rem; line-height: 1; height: 32px; border-radius: 6px;
}
.row .remove:hover { color: var(--error); background: #fdf1ee; }
.btn-text {
  justify-self: start; font: inherit; font-weight: 600; font-size: .93rem; color: var(--sage);
  background: none; border: 0; padding: 4px 0; cursor: pointer;
}
.btn-text:hover { color: var(--sage-dark); text-decoration: underline; text-underline-offset: 3px; }

.linked { margin: 0; }
.linked div { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.linked dt { color: var(--ink-2); }
.linked dd { margin: 0; font-weight: 700; color: var(--sage-dark); font-variant-numeric: tabular-nums; text-align: right; }

/* ---------- Ergebnis ---------- */
.result { background: var(--sage-tint); padding: 26px 30px 26px; }
.result-label { font-size: .8rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--sage); }
.result-value {
  font-weight: 700; font-size: clamp(2.3rem, 4.2vw, 3rem); line-height: 1.1; letter-spacing: -.02em;
  color: var(--sage-dark); font-variant-numeric: tabular-nums; margin-top: 4px;
}
.result-unit { font-size: 1.05rem; font-weight: 600; color: var(--ink-2); margin-left: 8px; letter-spacing: 0; }
.result-sub { color: var(--ink-2); font-size: .93rem; margin-top: 2px; }

.ledger { margin: 18px 0 0; border-top: 1px solid #dbe3d7; }
.ledger div { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; padding: 8px 0; border-bottom: 1px solid #dbe3d7; }
.ledger dt { color: var(--ink-2); }
.ledger dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }

.mini-title, caption {
  font-size: .78rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); text-align: left; padding-bottom: 6px;
}

table { width: 100%; border-collapse: collapse; font-size: .93rem; margin-top: 22px; background: #fff; border-radius: 8px; overflow: hidden; }
caption { background: transparent; }
th { text-align: left; font-weight: 600; font-size: .84rem; color: var(--ink-2); padding: 8px 12px; background: var(--bg-soft); border-bottom: 1px solid var(--line); }
td { padding: 8px 12px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
tbody tr:last-child td { border-bottom: 0; }
.ts-table td:not(:first-child), .ts-table th:not(:first-child) { text-align: right; }
.ts-table + .hint { margin-top: 10px; }

.factor-table td:last-child { text-align: right; color: var(--ink-2); }
.factor-table tr.active td { background: var(--sage-soft); color: var(--sage-dark); font-weight: 700; }
.factor-table tr.active td:first-child { box-shadow: inset 3px 0 0 var(--sage); }

.composition { margin-top: 22px; }
.comp-bar { display: flex; height: 12px; border-radius: 3px; overflow: hidden; background: var(--line); }
.comp-bar span { display: block; height: 100%; transition: width .3s ease; }
.comp-bar span + span { box-shadow: inset 1px 0 0 #fff; }
.comp-legend { list-style: none; padding: 0; margin: 9px 0 0; display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: .86rem; color: var(--ink-2); }
.comp-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; }

/* ---------- Rechenweg ---------- */
.steps-wrap { margin-top: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.steps-wrap > summary {
  display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap;
  padding: 12px 18px 12px 40px; cursor: pointer; list-style: none; position: relative; border-radius: var(--radius);
}
.steps-wrap > summary:hover { background: var(--bg-soft); }
.steps-wrap > summary::-webkit-details-marker, .step > summary::-webkit-details-marker { display: none; }
.steps-wrap > summary::before, .step > summary::after {
  content: ""; width: 7px; height: 7px; border: solid var(--sage); border-width: 0 2px 2px 0;
  transition: transform .15s ease;
}
.steps-wrap > summary::before { position: absolute; left: 18px; top: 19px; transform: rotate(-45deg); }
.steps-wrap[open] > summary::before { transform: rotate(45deg); top: 17px; }
.sw-title { font-weight: 700; color: var(--ink); }
.sw-sub { font-size: .9rem; color: var(--muted); }
.sw-hide, .steps-wrap[open] .sw-show { display: none; }
.steps-wrap[open] .sw-hide { display: inline; }
.sw-hint { margin: -4px 18px 6px 40px; font-size: .84rem; color: var(--muted); }

.steps { list-style: none; padding: 0 10px 10px; margin: 0; }
.steps li + li .step { border-top: 1px solid var(--line); }
.step > summary {
  display: grid; grid-template-columns: 26px minmax(150px, 1.1fr) minmax(0, 1.6fr) 150px 12px;
  align-items: baseline; gap: 12px; padding: 9px 8px; cursor: pointer; list-style: none; font-size: .94rem; border-radius: 6px;
}
.step > summary:hover { background: var(--bg-soft); }
.step > summary::after { justify-self: end; transform: rotate(45deg); align-self: center; margin-top: -4px; }
.step[open] > summary::after { transform: rotate(-135deg); margin-top: 2px; }
.step-num { font-weight: 700; color: var(--terra); font-variant-numeric: tabular-nums; }
.step-title { color: var(--ink); font-weight: 500; }
.step-calc { font-family: var(--mono); font-size: .8rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.step-result { font-weight: 700; color: var(--sage-dark); font-variant-numeric: tabular-nums; white-space: nowrap; justify-self: end; }
.step-body { padding: 2px 30px 14px 46px; }
.formula { display: grid; grid-template-columns: 90px 1fr; gap: 10px; align-items: baseline; font-size: .9rem; margin: 3px 0; }
.formula .lbl { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; font-weight: 700; }
.formula code { font-family: var(--mono); font-size: .86rem; color: var(--ink); word-break: break-word; }
.why { margin-top: 10px; font-size: .93rem; color: var(--ink-2); max-width: 78ch; }
.why strong { color: var(--terra); margin-right: 4px; }

/* ---------- Hinweise ---------- */
.note {
  margin-top: 18px; padding: 12px 16px; border-left: 3px solid var(--terra); background: var(--terra-soft);
  border-radius: 0 8px 8px 0; font-size: .94rem; color: var(--ink-2); max-width: 90ch;
}
.note strong { display: block; font-weight: 700; color: var(--terra); margin-bottom: 2px; }
.note-inline { margin-top: 20px; font-size: .9rem; background: #fff; }

/* ---------- Wissen ---------- */
.roadmap {
  list-style: none; padding: 0; margin: 0; counter-reset: rm;
  columns: 3 240px; column-gap: 32px;
}
.roadmap li {
  counter-increment: rm; break-inside: avoid;
  display: grid; grid-template-columns: 32px 1fr; column-gap: 4px;
  padding: 10px 0; border-top: 1px solid var(--line-2); color: var(--ink-2); font-size: .95rem;
}
.roadmap li::before { content: counter(rm, decimal-leading-zero); grid-row: span 2; font-weight: 700; color: var(--terra); }
.roadmap b { display: block; color: var(--ink); }

.sub-h { font-size: 1.2rem; margin: 40px 0 12px; }
.glossary { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); column-gap: 32px; margin: 0; }
.glossary div { padding: 12px 0; border-top: 1px solid var(--line-2); }
.glossary dt { font-weight: 700; color: var(--sage-dark); margin-bottom: 2px; }
.glossary dd { margin: 0; font-size: .93rem; color: var(--ink-2); }

/* ---------- Footer ---------- */
.site-footer { background: var(--sage-dark); color: #e8ece6; padding: 36px 0; font-size: .92rem; }
.footer-inner { display: grid; grid-template-columns: 220px 1fr; gap: 32px; align-items: baseline; }
.footer-brand { font-family: var(--serif); font-size: 1.25rem; color: #fff; }
.footer-brand em { color: #c9d8c4; }
.site-footer strong { color: #fff; }

/* ---------- Tierart / Modus ---------- */
body[data-species="hund"] .only-katze,
body[data-species="hund"] .only-katze-row,
body[data-species="katze"] .only-hund,
body[data-species="katze"] .only-hund-row { display: none; }

body[data-mode="auto"] .mode-manual,
body[data-mode="manual"] .mode-auto,
body[data-mode="manual"] .mode-auto-kpi { display: none; }
.mode-manual { display: grid; gap: 20px; }

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
  .header-inner { flex-wrap: wrap; height: auto; padding-top: 10px; row-gap: 0; }
  .species-switch { margin-left: auto; }
  .main-nav {
    order: 3; width: 100%; margin: 0; gap: 20px; overflow-x: auto; scrollbar-width: none;
    padding: 6px 0 8px; white-space: nowrap;
  }
  .main-nav::-webkit-scrollbar { display: none; }
  .calc-grid { grid-template-columns: 1fr; }
  .calc-grid > .result { border-left: 0; border-top: 1px solid var(--line); }
  .footer-inner { grid-template-columns: 1fr; gap: 10px; }
  .intro-inner { grid-template-columns: 1fr 170px; gap: 28px; }
}
@media (max-width: 560px) {
  body { font-size: 16px; }
  .wrap { width: calc(100% - 28px); }
  .intro { padding: 28px 0 26px; }
  .intro-inner { grid-template-columns: 1fr; }
  .intro-art { display: none; }
  .intro-lead { font-size: 1rem; }
  .calc { padding: 36px 0 40px; }
  .chapter { grid-template-columns: 44px 1fr; }
  .chapter-no { width: 34px; height: 34px; font-size: .95rem; }
  .calc-grid > .form { padding: 20px 18px; }
  .result { padding: 20px 18px; }
  .brand-name { font-size: 1.05rem; }
  .paw { width: 21px; height: 21px; }
  .formula { grid-template-columns: 1fr; gap: 0; min-width: 0; }
  /* iOS Safari can keep an intrinsic min-content width for grid items inside
     nested <details>. Use a shrinkable flex row and let long results wrap. */
  .steps, .step, .step-body { min-width: 0; }
  .step > summary {
    display: flex; align-items: flex-start; gap: 8px; min-width: 0;
  }
  .step-num { flex: 0 0 22px; }
  .step-title { flex: 1 1 0%; min-width: 0; overflow-wrap: anywhere; }
  .step-result {
    flex: 0 1 auto; min-width: 0; max-width: 40%; white-space: normal;
    text-align: right; overflow-wrap: anywhere; line-height: 1.3;
  }
  .step > summary::after { flex: 0 0 7px; margin-left: auto; align-self: flex-start; }
  .step-calc { display: none; }
  .step-body { padding-left: 8px; padding-right: 8px; overflow-wrap: anywhere; }
  .formula code { min-width: 0; overflow-wrap: anywhere; word-break: break-word; }
  .why { overflow-wrap: anywhere; }
  .field-inline { grid-template-columns: 1fr 112px; }
}

@media print {
  .site-header, .intro, .presets, #r-add, .row .remove { display: none; }
  .calc { padding: 20px 0; break-inside: avoid; }
  .calc-grid { box-shadow: none; }
}
