:root {
  --grund: #f5f6f8;
  --karte: #fff;
  --text: #1c2230;
  --leise: #6b7280;
  --rand: #e3e6eb;
  --akzent: #1f5fbf;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--grund);
  color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

.seite { max-width: 1200px; margin: 0 auto; padding: max(20px, env(safe-area-inset-top)) 20px 24px; }

/* Brotkrumen */
.pfad { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 15px; min-height: 22px; }
.pfad a { color: var(--akzent); text-decoration: none; }
.pfad a:hover { text-decoration: underline; }
.pfad-trenner { color: var(--leise); }
.pfad-aktiv { font-weight: 600; }

.kopf { margin: 18px 0 22px; }
.kopf h1 { margin: 0; font-size: clamp(24px, 4vw, 34px); }
.kopf p { margin: 4px 0 0; color: var(--leise); }

/* Kacheln */
.raster { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.raster-gross { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }

.kachel {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 16px 12px 14px; background: var(--karte); border: 1px solid var(--rand);
  border-radius: var(--radius); color: inherit; text-decoration: none; text-align: center;
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}
.kachel:hover { transform: translateY(-2px); border-color: var(--akzent); box-shadow: 0 6px 18px rgba(20, 40, 80, .1); }
.kachel:focus-visible { outline: 3px solid var(--akzent); outline-offset: 2px; }
.kachel-bild { display: flex; align-items: center; justify-content: center; width: 100%; height: 110px; }
.kachel-bild img { max-width: 100%; max-height: 100%; object-fit: contain; }
.raster-gross .kachel-bild { height: 90px; }
.flagge { font-size: 64px; line-height: 1; }
.kachel-titel { font-weight: 600; font-size: 15px; }
.kachel-unter { font-size: 13px; color: var(--leise); }

/* Detailseite */
.aktionen { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 18px; }
.knopf {
  font: inherit; font-weight: 600; padding: 10px 18px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--rand); background: var(--karte); color: var(--text);
}
.knopf:hover { border-color: var(--akzent); color: var(--akzent); }
.knopf-haupt { background: var(--akzent); border-color: var(--akzent); color: #fff; }
.knopf-haupt:hover { background: #174c99; color: #fff; }

.paar { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 720px) { .paar { grid-template-columns: 1fr; } }
.motiv { margin: 0; background: var(--karte); border: 1px solid var(--rand); border-radius: var(--radius); padding: 24px; }
.motiv-bild { display: flex; align-items: center; justify-content: center; aspect-ratio: 1; }
.motiv-bild img { max-width: 100%; max-height: 100%; object-fit: contain; }
.motiv figcaption { text-align: center; color: var(--leise); margin-top: 12px; font-size: 14px; }

/* Leiste unten: auf dem Desktop am Seitenende, am Handy fest am unteren Rand */
.leiste {
  display: flex; align-items: center; gap: 10px;
  max-width: 1200px; margin: 0 auto; padding: 14px 20px 40px;
  border-top: 1px solid var(--rand);
}
.leiste-zurueck {
  flex: 0 0 auto; display: flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--rand);
  background: var(--karte); color: var(--akzent); font-size: 26px; line-height: 1; text-decoration: none;
}
.leiste-pfad { min-width: 0; }
.leiste[hidden] { display: none; }

@media (max-width: 720px) {
  body { padding-bottom: calc(68px + env(safe-area-inset-bottom)); }
  .seite > .pfad { font-size: 14px; }
  .leiste {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; margin: 0;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
    background: rgba(255, 255, 255, .96); backdrop-filter: blur(8px);
    box-shadow: 0 -4px 16px rgba(20, 40, 80, .08);
  }
  .leiste-zurueck { width: 46px; height: 46px; }
  /* Ein langer Pfad scrollt waagerecht statt umzubrechen. */
  .leiste-pfad { flex-wrap: nowrap; overflow-x: auto; white-space: nowrap; scrollbar-width: none; font-size: 15px; }
  .leiste-pfad::-webkit-scrollbar { display: none; }
  .leiste-pfad a, .leiste-pfad .pfad-aktiv { padding: 10px 0; }
  .aktionen .knopf { flex: 1 1 100%; padding: 13px 18px; }
  .raster, .raster-gross { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kachel-bild { height: 90px; }
  .flagge { font-size: 52px; }
}

/* Druck: nur die gewählten A4-Blätter */
.druck { display: none; }

@page { size: A4 portrait; margin: 12mm; }

@media print {
  body { background: #fff; }
  .seite, .leiste { display: none !important; }
  .druck { display: block; }
  /* Keine feste Blatthöhe: Handy-Browser setzen Kopf- und Fußzeile (Datum, URL)
     dazu, eine volle A4-Höhe liefe dann auf eine zweite, leere Seite über. */
  .blatt { display: none; flex-direction: column; align-items: center; padding-top: 8mm; break-inside: avoid; }
  .blatt img { width: 100%; max-width: 186mm; max-height: 225mm; object-fit: contain; }
  .blatt p { margin: 6mm 0 0; font-size: 11pt; color: #555; }
  .blatt-farbe { -webkit-print-color-adjust: exact; print-color-adjust: exact; }

  body[data-druck="farbe"] .blatt-farbe,
  body[data-druck="ausmal"] .blatt-ausmal,
  body[data-druck="beide"] .blatt { display: flex; }
  body[data-druck="beide"] .blatt-farbe { break-after: page; }
}
