:root {
  --bg: #f6f3ee;
  --card: #ffffff;
  --text: #1d2433;
  --muted: #667085;
  --line: #e4ded4;
  --brand: #1f3a5f;
  --brand-ink: #ffffff;
  --accent: #e0653a;
  --accent-soft: #fbe5dc;
  --bar-bg: #efe9e1;
  --ok: #2e7d4f;
  --veil: rgba(246, 243, 238, .72);
  --hero-bg: rgba(31, 58, 95, .86);
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 16px rgba(16, 24, 40, .05);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161f;
    --card: #1a202c;
    --text: #e8ebf1;
    --muted: #98a2b3;
    --line: #2b3342;
    --brand: #22416b;
    --accent: #f07a4f;
    --accent-soft: #3a2621;
    --bar-bg: #262d3b;
    --ok: #5cc28a;
    --veil: rgba(18, 22, 31, .80);
    --hero-bg: rgba(34, 65, 107, .82);
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

a { color: var(--accent); }

/* Hintergrundbild: fixiert, als Cover, leicht weichgezeichnet und durch einen Schleier abgeschwächt.
   Als eigene Ebene statt background-attachment: fixed, damit es auch auf iOS funktioniert. */
body::before,
body::after {
  content: "";
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0;
  z-index: -1;
  pointer-events: none;
}
body::before {
  background: url("Luftaufnahme.webp") center / cover no-repeat;
  filter: blur(3px);
  transform: scale(1.04); /* verhindert helle Ränder durch den Blur */
}
body::after { background: var(--veil); }

.hero {
  background: var(--hero-bg);
  color: var(--brand-ink);
  padding: 40px 16px 56px;
}
.hero .wrap { max-width: 760px; margin: 0 auto; }
.hero .kicker {
  text-transform: uppercase; letter-spacing: .12em; font-size: 12px; font-weight: 600;
  color: #ffc9b3; margin: 0 0 8px;
}
.hero h1 { font-size: clamp(26px, 5vw, 38px); line-height: 1.15; margin: 0 0 8px; text-wrap: balance; }
.hero p { margin: 0; opacity: .85; max-width: 60ch; }
.hero-link {
  display: inline-block; margin-top: 16px; padding: 8px 16px;
  border: 1.5px solid rgba(255, 255, 255, .55); border-radius: 999px;
  color: #fff; text-decoration: none; font-size: 14.5px; font-weight: 600;
  transition: background .12s, border-color .12s;
}
.hero-link:hover, .hero-link:focus-visible { background: rgba(255, 255, 255, .14); border-color: #fff; }
.hero-row { display: flex; align-items: center; gap: 24px; }
.hero-text { min-width: 0; flex: 1; }
.hero-logo {
  flex: none; width: 120px; height: 120px;
  border-radius: 18px;
  padding: 8px;
  background: #fff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, .25), 0 10px 28px rgba(0, 0, 0, .35);
}
@media (max-width: 520px) {
  .hero-row { gap: 14px; align-items: flex-start; }
  .hero-logo { width: 72px; height: 72px; border-radius: 12px; padding: 5px; }
}

main { max-width: 760px; margin: -32px auto 48px; padding: 0 16px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 20px;
}

.section-title {
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--accent); margin: 0 0 4px;
}
.section-title::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* ---------- Formular ---------- */

.question { padding: 18px 0; border-top: 1px solid var(--line); }
.question:first-of-type { border-top: 0; }
.question[hidden] { display: none; }
.q-label { display: block; font-weight: 650; margin-bottom: 4px; }
.q-num { color: var(--muted); font-weight: 500; margin-right: 4px; font-variant-numeric: tabular-nums; }
.q-hint { color: var(--muted); font-size: 14px; margin: 0 0 10px; }
.q-head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; width: 100%; padding: 0; }
.reset { background: none; border: 0; color: var(--muted); font-size: 13px; cursor: pointer; padding: 0; text-decoration: underline; white-space: nowrap; }
.reset[hidden] { display: none; }

.options { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.option { position: relative; }
.option input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.option span {
  display: inline-block; padding: 8px 14px; border-radius: 999px;
  border: 1.5px solid var(--line); background: var(--card);
  font-size: 15px; cursor: pointer; user-select: none;
  transition: border-color .12s, background .12s, color .12s;
}
.option:hover span { border-color: var(--accent); }
.option input:checked + span { background: var(--accent); border-color: var(--accent); color: #fff; }
.option input:focus-visible + span { outline: 3px solid var(--accent-soft); outline-offset: 2px; }
.option input[type=checkbox] + span::before { content: "＋ "; opacity: .6; }
.option input[type=checkbox]:checked + span::before { content: "✓ "; opacity: 1; }

input[type=text], input[type=password], textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--card);
  border: 1.5px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-top: 8px;
}
input[type=text]:focus, textarea:focus { outline: none; border-color: var(--accent); }
textarea { min-height: 130px; resize: vertical; }

.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.btn {
  display: inline-flex; align-items: center; gap: 8px; text-decoration: none;
  background: var(--accent); color: #fff; border: 0; border-radius: 999px;
  padding: 12px 22px; font: inherit; font-weight: 650; cursor: pointer;
}
.btn:hover { filter: brightness(1.05); }
.btn.secondary { background: transparent; color: var(--text); border: 1.5px solid var(--line); }
.small { font-size: 14px; color: var(--muted); }

.progress { position: sticky; top: 0; z-index: 5; height: 4px; background: var(--bar-bg); }
.progress div { height: 100%; width: 0; background: var(--accent); transition: width .2s; }

.notice { border-left: 4px solid var(--ok); }
.error { border-left: 4px solid var(--accent); }

/* ---------- Auswertung ---------- */

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between; align-items: center; }
.stats-line { color: var(--muted); font-size: 14px; }
.stats-line strong { color: var(--text); font-size: 20px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-top: 20px; }
.tile { background: var(--bg); border-radius: 12px; padding: 14px; }
.tile .t-q { font-size: 12.5px; color: var(--muted); line-height: 1.3; }
.tile .t-a { font-weight: 700; font-size: 17px; margin-top: 6px; line-height: 1.25; }
.tile .t-p { color: var(--accent); font-weight: 700; font-size: 14px; }

.result { padding: 18px 0; border-top: 1px solid var(--line); }
.result:first-of-type { border-top: 0; }
.result .meta { color: var(--muted); font-size: 13px; margin: 2px 0 12px; }

.bars { display: grid; gap: 8px; }
.bar-row { display: grid; grid-template-columns: minmax(110px, 38%) 1fr 74px; gap: 10px; align-items: center; font-size: 14.5px; }
.bar-label { line-height: 1.25; }
.bar-track { height: 14px; background: var(--bar-bg); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--brand); border-radius: 999px; min-width: 2px; }
@media (prefers-color-scheme: dark) { .bar-fill { background: #6d8fbf; } }
.bar-row.top .bar-fill { background: var(--accent); }
.bar-row.top .bar-label { font-weight: 650; }
.bar-val { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar-val small { color: var(--muted); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; font-size: 14px; }
.chip b { color: var(--accent); margin-left: 4px; }

.quotes { display: grid; gap: 12px; }
.quote { background: var(--bg); border-radius: 12px; padding: 14px 16px; margin: 0; }
.quote p { margin: 0; white-space: pre-line; }
.quote footer { margin-top: 6px; color: var(--muted); font-size: 13.5px; font-weight: 600; }

.empty { color: var(--muted); font-style: italic; margin: 0; }

/* ---------- Foto-Upload ---------- */

.photo-upload { margin-top: 14px; }
.photo-drop {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 18px 16px; text-align: center; cursor: pointer;
  border: 2px dashed var(--line); border-radius: 12px; background: var(--bg);
  transition: border-color .12s;
}
.photo-drop:hover, .photo-drop:focus-within { border-color: var(--accent); }
.photo-drop input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.photo-drop-title { font-weight: 650; color: var(--accent); }
/* Feste Thumbnail-Größe (ohne aspect-ratio, damit es auch auf älteren iPhones klein bleibt) */
.photo-previews { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.photo-previews:empty { display: none; }
.photo-thumb {
  position: relative; flex: none; width: 72px; height: 72px;
  border-radius: 8px; overflow: hidden; background: var(--bar-bg);
}
.photo-thumb img { width: 72px; height: 72px; object-fit: cover; display: block; }
.photo-remove {
  position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; border-radius: 50%;
  border: 0; background: rgba(0, 0, 0, .65); color: #fff; font-size: 15px; line-height: 22px; cursor: pointer; padding: 0;
}
.form-error { color: var(--accent); font-weight: 600; margin: 12px 0 0; }

/* ---------- Galerie ---------- */

.gallery-title { font-size: 15px; margin: 18px 0 10px; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
/* Quadratische Kacheln per padding-top (funktioniert auch ohne aspect-ratio) */
.gallery-item { position: relative; display: block; height: 0; padding-top: 100%; border-radius: 10px; overflow: hidden; background: var(--bar-bg); }
.gallery-item img { position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .2s; }
.gallery-item:hover img { transform: scale(1.04); }
.gallery-item:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.lightbox {
  position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: rgba(10, 12, 18, .92);
}
.lightbox[hidden] { display: none; }
.lightbox figure { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 10px; max-width: 92vw; }
.lightbox img { max-width: 92vw; max-height: 82vh; border-radius: 6px; box-shadow: 0 10px 40px rgba(0, 0, 0, .5); }
.lightbox figcaption { color: #e8ebf1; font-size: 14px; }
.lb-btn {
  position: absolute; border: 0; background: rgba(255, 255, 255, .12); color: #fff; cursor: pointer;
  width: 48px; height: 48px; border-radius: 50%; font-size: 30px; line-height: 48px; padding: 0;
}
.lb-btn:hover { background: rgba(255, 255, 255, .25); }
.lb-btn[hidden] { display: none; }
.lb-close { top: 16px; right: 16px; }
.lb-prev { left: 16px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 16px; top: 50%; transform: translateY(-50%); }
@media (max-width: 520px) {
  .lb-prev, .lb-next { top: auto; bottom: 20px; transform: none; }
}

@media (max-width: 520px) {
  .card { padding: 18px 16px; }
  .bar-row { grid-template-columns: 1fr 64px; }
  .bar-row .bar-label { grid-column: 1 / -1; }
}

@media print {
  body { background: #fff; color: #000; }
  body::before, body::after { display: none; }
  .hero-logo { box-shadow: none; width: 72px; height: 72px; }
  .hero-link { display: none; }
  .hero { background: #fff; color: #000; padding: 0 0 12px; }
  main { margin: 0; max-width: none; }
  .card { box-shadow: none; border: 0; padding: 0; }
  .no-print { display: none !important; }
  .result { break-inside: avoid; }
}
