:root {
  /* Sechs Noten, sechs Farben. Die Skala ist die Palette. */
  --n1: #2F6B4F;
  --n2: #5E8A45;
  --n3: #C9A227;
  --n4: #C97B1E;
  --n5: #A6431F;
  --n6: #7E2113;

  --grund:  #EDEEE8;
  --karte:  #FCFCFA;
  --tinte:  #1B211C;
  --leise:  #6C7569;
  --linie:  #D6D9CF;

  --serif: ui-serif, "New York", Georgia, serif;
  --sans:  -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  background: var(--grund);
}

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--tinte);
  background: var(--grund);
  /* Dynamic Island oben, Home-Indikator unten. */
  padding:
    calc(env(safe-area-inset-top) + 12px)
    max(env(safe-area-inset-left), 16px)
    calc(env(safe-area-inset-bottom) + 32px)
    max(env(safe-area-inset-right), 16px);
}

.huelle { max-width: 430px; margin: 0 auto; }

/*
 * Fuer die Tabellenansicht: nicht auf eine feste Breite festlegen,
 * sondern genau so breit wie die Tabelle es braucht - bis zum Rand
 * des Bildschirms. Der Scrollbalken in .tabelle-rahmen bleibt als
 * Rueckfall fuer den Fall, dass selbst das nicht reicht.
 */
.huelle--breit {
  max-width: 100%;
  width: fit-content;
}

/* ---------- Kopf ---------- */

.kopf {
  margin-bottom: 4px;
}

.kopf-zeile {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.kopf-knoepfe {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.kopf h1 {
  font-family: var(--serif);
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0;
}

.kopf time {
  font-size: 13px;
  color: var(--leise);
  font-variant-numeric: tabular-nums;
}

.knopf {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--linie);
  border-radius: 999px;
  background: var(--karte);
  color: var(--leise);
  font-size: 13px;
  text-decoration: none;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}

/* ---------- Karte ---------- */

.karte {
  display: block;
  background: var(--karte);
  border: 1px solid var(--linie);
  border-radius: 14px;
  padding: 14px 16px 16px;
  margin-bottom: 12px;
  color: inherit;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.karte:active { background: #F4F4EE; }

/*
 * Markiert die Durchsicht, an der ein Volk eingegangen ist - der
 * schwarze Balken aus der frueheren Excel-Tabelle, jetzt als Banner
 * oben auf der jeweiligen Karte statt einer Linie im Blatt.
 */
.ende-linie {
  margin: -14px -16px 14px;
  padding: 9px 16px;
  background: var(--tinte);
  color: var(--grund);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  text-align: center;
  border-radius: 13px 13px 0 0;
}

.zeile {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.volk {
  font-family: var(--serif);
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.1;
}

.volk small {
  display: block;
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--leise);
  margin-top: 3px;
}

.gesamt {
  font-family: var(--serif);
  font-size: 42px;
  font-weight: 600;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.gesamt small {
  display: block;
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--leise);
  margin-top: 4px;
}

/*
 * Die Breite der beiden Felder entspricht ihrem Gewicht in der Formel:
 * Verhalten doppelt, Schwarm einfach. Die Gewichtung ist damit sichtbar,
 * nicht nur erklaert.
 */
.waage {
  display: flex;
  gap: 3px;
  margin-top: 14px;
  border-radius: 8px;
  overflow: hidden;
}

.feld {
  min-height: 52px;
  padding: 7px 10px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  color: #fff;
}

.feld--verhalten { flex: 2; }
.feld--staerke   { flex: 1; }
.feld--schwarm   { flex: 1; }
.feld--merkmal   { flex: 1; }

.feld b {
  font-family: var(--serif);
  font-size: 21px;
  font-weight: 600;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.feld span {
  font-size: 10px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  opacity: 0.85;
  margin-bottom: 4px;
}

.s1 { background: var(--n1); }
.s2 { background: var(--n2); }
.s3 { background: var(--n3); }
.s4 { background: var(--n4); }
.s5 { background: var(--n5); }
.s6 { background: var(--n6); }
.s0 { background: #B7BCB2; }

/* Farbe der Gesamtnote auf der Startseite, gleiche Skala wie ueberall sonst. */
.gesamt .n1 { color: var(--n1); }
.gesamt .n2 { color: var(--n2); }
.gesamt .n3 { color: var(--n3); }
.gesamt .n4 { color: var(--n4); }
.gesamt .n5 { color: var(--n5); }
.gesamt .n6 { color: var(--n6); }

/* Veraltete Bewertungen werden zurueckgenommen, nicht versteckt. */
.veraltet .waage { opacity: 0.42; }
.veraltet .gesamt { color: var(--leise); }
.veraltet .gesamt span { color: var(--leise); }

/* Eingegangene Voelker bleiben sichtbar, treten aber zurueck. */
.inaktiv { opacity: 0.55; }

.koenigin {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin: 10px 0 0;
  font-size: 12.5px;
  color: var(--leise);
  padding-top: 9px;
  border-top: 1px solid var(--linie);
}

/*
 * Bleibt immer in derselben Zeile wie die Durchsicht-Info rechts, auch
 * bei einer langen Herkunft wie "Koenigs Bienen 2026" - dann wird
 * abgeschnitten statt in eine zweite Zeile umzubrechen.
 */
.koenigin-info {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.koenigin .durchsicht-info {
  flex-shrink: 0;
  white-space: nowrap;
}

.ableger-info {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin-top: 6px;
  font-size: 12px;
  color: var(--leise);
}

.phase-info {
  flex-shrink: 0;
  white-space: nowrap;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--n3);
  color: #fff;
  font-size: 10.5px;
  font-weight: 600;
}

.phase-info.phase-fertig { background: var(--n1); }

/*
 * Herkunft der Koenigin auf den ersten Blick: eigene Nachzucht vs.
 * Zuechter, als sehr dezente Einfaerbung der ganzen Kachel statt
 * einzelner Textfarben - kaum mehr als ein Hauch Farbton.
 */
.karte.zukauf    { background: #DFEEE3; border-color: #A9CBB4; }
.karte.nachzucht { background: #DDE9F5; border-color: #A9C7E3; }

.hinweis {
  margin: 10px 0 0;
  padding: 11px 12px;
  background: #F3F2EA;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--leise);
}

.fuss {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  font-size: 12.5px;
  color: var(--leise);
}

.warnung {
  color: var(--n5);
  font-weight: 600;
}

.leer {
  background: var(--karte);
  border: 1px dashed var(--linie);
  border-radius: 14px;
  padding: 32px 20px;
  text-align: center;
  color: var(--leise);
  font-size: 15px;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* ---------- Königinnen und Abstammung ---------- */

.zurueck {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-size: 15px;
  color: var(--leise);
  text-decoration: none;
  margin-bottom: 4px;
}

.linie { margin-bottom: 28px; }

.linie h2 {
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 600;
  margin: 0 0 10px;
}

.ahn {
  position: relative;
  padding: 0 0 0 22px;
  margin: 0;
  list-style: none;
}

.ahn li {
  position: relative;
  background: var(--karte);
  border: 1px solid var(--linie);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 10px;
}

/* Verbindung zur Mutter: eine durchgehende Linie am linken Rand. */
.ahn li::before {
  content: "";
  position: absolute;
  left: -13px;
  top: -11px;
  bottom: 50%;
  width: 1px;
  background: var(--linie);
}

.ahn li::after {
  content: "";
  position: absolute;
  left: -13px;
  top: 50%;
  width: 11px;
  height: 1px;
  background: var(--linie);
}

.ahn li:first-child::before { top: 24px; }

.ahn .amtierend { border-color: var(--n1); border-width: 2px; }

.name {
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 600;
}

.zeitraum {
  font-size: 12.5px;
  color: var(--leise);
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}

.merkmale {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 9px;
}

.marke {
  font-size: 11.5px;
  letter-spacing: 0.03em;
  padding: 3px 9px;
  border-radius: 999px;
  background: #EAEBE3;
  color: var(--leise);
}

.marke--aktiv { background: var(--n1); color: #fff; }
.marke--nachzucht { background: #E4EDE5; color: #2F6B4F; }

/*
 * Jahresfarbe der Koenigin (Opalithplaettchen-Code): 1/6 weiss, 2/7 gelb,
 * 3/8 rot, 4/9 gruen, 5/0 blau. Erscheint ueberall, wo eine Koenigin
 * auftaucht, unabhaengig vom frei eingetragenen Zeichnungsfeld.
 */
.jahresfarbe {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  margin-left: 4px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  vertical-align: 1px;
}

.jahresfarbe--weiss { background: #fff; color: var(--tinte); border: 1px solid var(--linie); }
.jahresfarbe--gelb  { background: #F0C300; color: var(--tinte); }
.jahresfarbe--rot   { background: #C0392B; color: #fff; }
.jahresfarbe--gruen { background: #2F6B4F; color: #fff; }
.jahresfarbe--blau  { background: #2B6CB0; color: #fff; }

/* "..." zum Einblenden frueherer Behandlungen, ohne Javascript. */
.mehr summary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 0 14px;
  margin-top: 8px;
  border: 1px solid var(--linie);
  border-radius: 999px;
  background: var(--karte);
  color: var(--leise);
  font-size: 14px;
  cursor: pointer;
  list-style: none;
}

.mehr summary::-webkit-details-marker { display: none; }

.herkunftstext {
  margin: 9px 0 0;
  font-size: 13px;
  line-height: 1.45;
  color: var(--leise);
}

/* Abstammung ist die einzige nachvollziehbare Mutterlinie ohne DB-Eintrag
 * fuer die Mutter - deshalb deutlicher hervorgehoben als die uebrigen,
 * eher ergaenzenden Angaben zur Koenigin. */
.abstammung {
  margin: 9px 0 0;
  padding: 9px 11px;
  background: #EDF3EE;
  border-left: 3px solid var(--n1);
  border-radius: 0 8px 8px 0;
  font-size: 13px;
  line-height: 1.45;
  color: var(--tinte);
}

.abstammung-label {
  display: block;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--n1);
  margin-bottom: 3px;
}

.nachweis {
  margin: 9px 0 0;
  padding-top: 9px;
  border-top: 1px solid var(--linie);
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--leise);
  font-variant-numeric: tabular-nums;
}

.wetter {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--leise);
  font-variant-numeric: tabular-nums;
}

.info {
  background: var(--karte);
  border: 1px solid var(--linie);
  border-radius: 14px;
  padding: 0 16px;
  margin-bottom: 4px;
}

.info-zeile {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 14px;
  padding: 11px 0;
  border-bottom: 1px solid var(--linie);
  font-size: 13.5px;
}

.info-zeile:last-child { border-bottom: none; }

.info-zeile span { color: var(--leise); }

.info-zeile b {
  font-weight: 600;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.wetter::before {
  content: "";
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--linie);
  margin-right: 7px;
  vertical-align: 2px;
}

.quelle {
  margin: 28px 0 0;
  font-size: 11.5px;
  color: var(--leise);
  text-align: center;
}

.quelle a { color: inherit; }

/* ---------- Formular (Durchsicht erfassen/bearbeiten) ---------- */

.formular {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 4px;
}

.formular label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--leise);
}

.formular input,
.formular select,
.formular textarea {
  font: inherit;
  font-size: 16px; /* verhindert Auto-Zoom beim Fokus auf iOS */
  color: var(--tinte);
  background: var(--karte);
  border: 1px solid var(--linie);
  border-radius: 10px;
  padding: 10px 12px;
  min-height: 44px;
}

.formular textarea {
  min-height: 80px;
  resize: vertical;
}

.formular-zeile {
  display: flex;
  gap: 10px;
}

.formular-zeile label {
  flex: 1;
  min-width: 0;
}

.knopf--speichern {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  margin-top: 6px;
  border: none;
  border-radius: 12px;
  background: var(--tinte);
  color: var(--grund);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.knopf--speichern:active { opacity: 0.85; }

.gefahrenzone {
  margin-top: 18px;
  padding: 14px 16px;
  border: 1px solid #E3B7AE;
  border-radius: 12px;
  background: #FBF1EF;
}

.knopf--gefahr {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border: none;
  border-radius: 12px;
  background: var(--n6);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.knopf--gefahr:active { opacity: 0.85; }

/* ---------- Filter + Tabelle (Uebersichtstabelle) ---------- */

.filter {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  margin: 4px 0 20px;
}

.filter label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--leise);
}

.filter select {
  font: inherit;
  font-size: 15px;
  color: var(--tinte);
  background: var(--karte);
  border: 1px solid var(--linie);
  border-radius: 10px;
  padding: 9px 10px;
  min-height: 40px;
}

.filter .knopf {
  min-height: 40px;
  border: none;
  background: var(--tinte);
  color: var(--grund);
  cursor: pointer;
  font-size: 14px;
}

.tabelle-rahmen {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--linie);
  border-radius: 14px;
  background: var(--karte);
}

.tabelle {
  border-collapse: collapse;
  font-size: 13.5px;
}

.tabelle th,
.tabelle td {
  padding: 12px 14px;
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--linie);
}

.tabelle td.zahl,
.tabelle th.zahl {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.tabelle thead th {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--leise);
  background: #F3F2EA;
  position: sticky;
  top: 0;
}

.tabelle th a {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: inherit;
  text-decoration: none;
}

.tabelle tbody tr:last-child td { border-bottom: none; }

.tabelle tbody tr:hover td { background: #F8F8F3; }

.tabelle tbody tr.inaktiv { color: var(--leise); }

.tabelle tbody tr.inaktiv .zellnote { opacity: 0.55; }

.tabelle td:first-child a {
  color: var(--tinte);
  font-weight: 600;
  text-decoration: none;
}

.zellnote {
  display: inline-flex;
  min-width: 30px;
  justify-content: center;
  padding: 3px 9px;
  border-radius: 999px;
  color: #fff;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
