/* Layout: Aufnahme-Werkzeug fürs Handy. Dunkelgrüne Kopfzone mit Projektübersicht,
   darunter Arbeitsschritte als Kacheln; Eingaben in ruhigen Karten, automatisch
   gerechnete Werte in eigenen grün markierten Blöcken („A“ wie in EVEBI). */
@import url("fonts/fonts.css");

:root {
  --tief: #24481a;          /* Kopfzone */
  --tief-2: #376b1f;
  --gruen: #8cc21f;         /* EVEBI-Grün, Akzent */
  --gruen-text: #3f7310;    /* Grün für Schrift auf hellem Grund */
  --auto-bg: #eef6dd;       /* Hintergrund automatisch berechneter Werte */
  --stift: #2a63c2;         /* eigene Eingabe */
  --bg: #f1f2ec;
  --karte: #ffffff;
  --karte-2: #f6f7f2;
  --linie: #e0e3d8;
  --ink: #1b231c;
  --muted: #69735f;
  --warn: #b26a00;
  --fehler: #c2382f;
  --k-a: #2e9e48; --k-b: #8cc21f; --k-c: #e7bd22; --k-d: #ee8a2a; --k-e: #d6353d;  /* Effizienzskala */
  --schatten: 0 1px 2px rgba(27, 35, 28, .06), 0 4px 14px rgba(27, 35, 28, .06);
  --r: 14px;
  --r-s: 10px;
  --schrift: "Barlow", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  --schrift-eng: "Barlow Condensed", "Barlow", "Segoe UI", system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --tief: #1a3313; --tief-2: #24481a; --gruen: #9bd12a; --gruen-text: #a9da4a; --auto-bg: #1f2b17;
    --stift: #7aa7f0; --bg: #121511; --karte: #1b1f1a; --karte-2: #232822; --linie: #313830; --ink: #e9ede5; --muted: #a2ab99;
    --warn: #f0b04a; --fehler: #ff8a80; --schatten: 0 1px 2px rgba(0,0,0,.3); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --tief: #1a3313; --tief-2: #24481a; --gruen: #9bd12a; --gruen-text: #a9da4a; --auto-bg: #1f2b17;
  --stift: #7aa7f0; --bg: #121511; --karte: #1b1f1a; --karte-2: #232822; --linie: #313830; --ink: #e9ede5; --muted: #a2ab99;
  --warn: #f0b04a; --fehler: #ff8a80; --schatten: 0 1px 2px rgba(0,0,0,.3); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.45 var(--schrift); -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; overscroll-behavior-y: none; }
a, button, label, summary, select { touch-action: manipulation; }
input, select, textarea { font-size: max(16px, 1em); }   /* iPhone zoomt sonst beim Antippen hinein */
button, .kachel, .zeile, .projekt, .option, .chips button { -webkit-user-select: none; user-select: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--stift) 55%, transparent); outline-offset: 2px; }
[hidden] { display: none !important; }
h1, h2, h3 { text-wrap: balance; }
.zahl, .wert, .kz b { font-variant-numeric: tabular-nums; }

/* ---------- Kopfzone */
.kopf {
  position: sticky; top: 0; z-index: 20;
  background: var(--tief); color: #fff;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 16px 10px;
  display: flex; align-items: center; gap: 10px;
}
.kopf h1 { margin: 0; flex: 1; min-width: 0; font-size: 18px; font-weight: 600; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kopf h1 small { display: block; font-size: 13px; font-weight: 400; opacity: .75; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kopf .rund { width: 40px; height: 40px; border-radius: 12px; border: 0; background: rgba(255,255,255,.12); color: #fff; display: grid; place-items: center; flex: none; }
.kopf .rund svg { width: 20px; height: 20px; }
.logo { width: 34px; height: 34px; border-radius: 10px; background: var(--gruen); display: grid; place-items: center; flex: none; }
.logo svg { width: 22px; height: 22px; }

main { max-width: 720px; margin: 0 auto; padding: 0 16px calc(env(safe-area-inset-bottom, 0px) + 40px); display: grid; gap: 14px; }
body.mit-leiste main { padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 96px); }

/* Hero unter der Kopfzone */
.hero { background: linear-gradient(180deg, var(--tief) 0, var(--tief-2) 100%); color: #fff; margin: 0 -16px; padding: 6px 16px 18px; display: grid; gap: 14px; }
.hero h2 { margin: 0; font-size: 26px; line-height: 1.15; font-weight: 700; }
.hero p { margin: 0; opacity: .8; font-size: 15px; }
.hero .foto-mini { width: 64px; height: 64px; border-radius: 12px; object-fit: cover; flex: none; border: 2px solid rgba(255,255,255,.25); }
.hero-zeile { display: flex; gap: 12px; align-items: center; }
.kennzahlen { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.kz { background: rgba(255,255,255,.1); border-radius: 12px; padding: 8px 10px; min-width: 0; }
.kz b { display: block; font-family: var(--schrift-eng); font-size: 24px; font-weight: 600; line-height: 1.1; }
.kz span { font-size: 12px; opacity: .8; }
.fortschritt { height: 6px; border-radius: 99px; background: rgba(255,255,255,.18); overflow: hidden; }
.fortschritt i { display: block; height: 100%; background: var(--gruen); border-radius: 99px; }
.fortschritt-text { font-size: 13px; opacity: .85; display: flex; justify-content: space-between; }

/* ---------- Karten */
.karte { background: var(--karte); border-radius: var(--r); box-shadow: var(--schatten); padding: 16px; display: grid; gap: 14px; min-width: 0; }
.karte > h3 { margin: 0; font-size: 13px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.karte > .titelzeile { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.karte > .titelzeile h3 { margin: 0; font-size: 13px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.hinweis { margin: 0; font-size: 14px; color: var(--muted); }
.hinweis.warn { color: var(--warn); }

/* Automatisch berechnet */
.auto { background: var(--auto-bg); border-radius: var(--r); padding: 14px 16px; display: grid; gap: 8px; }
.auto-kopf { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--gruen-text); }
.auto-liste { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 6px 14px; }
.auto-liste div { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; border-bottom: 1px dashed color-mix(in srgb, var(--gruen-text) 25%, transparent); padding: 3px 0; min-width: 0; }
.auto-liste span { color: var(--muted); }
.auto-liste b { font-weight: 600; text-align: right; }
.a { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 6px; background: var(--gruen); color: #1b2a07; font-size: 12px; font-weight: 700; }

/* ---------- Felder */
.felder { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.felder .ganz { grid-column: 1 / -1; }
.feld { display: grid; gap: 5px; min-width: 0; }
.feld > label, .feld > .lbl { font-size: 13px; font-weight: 500; color: var(--muted); }
.eingabe { position: relative; display: flex; align-items: center; background: var(--karte-2); border: 1.5px solid transparent; border-radius: var(--r-s); transition: border-color .15s; }
.eingabe:focus-within { border-color: var(--stift); background: var(--karte); }
.eingabe input, .eingabe select { flex: 1; min-width: 0; border: 0; background: transparent; padding: 12px; font-size: 17px; outline: none; appearance: none; }
.eingabe select { padding-right: 34px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 52%, calc(100% - 12px) 52%; background-size: 6px 6px; background-repeat: no-repeat; }
.eingabe .einheit { padding-right: 12px; color: var(--muted); font-size: 15px; white-space: nowrap; }
.eingabe input.zahl { text-align: right; }
textarea { width: 100%; border: 1.5px solid transparent; background: var(--karte-2); border-radius: var(--r-s); padding: 10px 12px; font-size: 16px; min-height: 64px; resize: vertical; }
textarea:focus { border-color: var(--stift); outline: none; background: var(--karte); }

/* Umschalter */
.wahl { display: grid; grid-template-columns: repeat(var(--n, 3), minmax(0, 1fr)); gap: 8px; }
.wahl button { display: grid; justify-items: center; gap: 6px; padding: 12px 6px; border-radius: var(--r-s); border: 1.5px solid var(--linie); background: var(--karte); font-size: 14px; font-weight: 500; line-height: 1.2; text-align: center; min-width: 0; }
.wahl button svg { width: 34px; height: 26px; color: var(--muted); }
.wahl button[aria-pressed="true"] { border-color: var(--stift); background: color-mix(in srgb, var(--stift) 9%, var(--karte)); color: var(--stift); font-weight: 600; }
.wahl button[aria-pressed="true"] svg { color: var(--stift); }
.wahl.text button { padding: 11px 6px; }

/* Zähler */
.zaehler { display: flex; align-items: center; justify-content: space-between; background: var(--karte-2); border-radius: var(--r-s); padding: 4px; }
.zaehler button { width: 44px; height: 44px; border-radius: 9px; border: 0; background: var(--karte); box-shadow: var(--schatten); font-size: 22px; font-weight: 600; }
.zaehler b { font-size: 20px; font-family: var(--schrift-eng); }

/* Schalter */
.schalter { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.schalter input { appearance: none; width: 50px; height: 30px; border-radius: 99px; background: var(--linie); position: relative; flex: none; transition: background .15s; }
.schalter input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: left .15s; }
.schalter input:checked { background: var(--gruen); }
.schalter input:checked::after { left: 23px; }
.schalter span { font-size: 15px; }
.schalter small { display: block; color: var(--muted); font-size: 13px; }

/* Kompass */
.kompass { display: grid; grid-template-columns: repeat(3, 64px); grid-template-rows: repeat(3, 52px); gap: 6px; justify-content: center; }
.kompass button { border: 1.5px solid var(--linie); background: var(--karte); border-radius: 12px; font-weight: 600; font-size: 15px; }
.kompass button[aria-pressed="true"] { background: var(--stift); border-color: var(--stift); color: #fff; }
.kompass .mitte { display: grid; place-items: center; color: var(--muted); font-size: 11px; text-align: center; line-height: 1.1; }
.kompass .mitte svg { width: 30px; height: 30px; }

/* ---------- Kacheln (Arbeitsschritte) */
.kacheln { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.kachel { position: relative; display: grid; gap: 8px; align-content: start; padding: 14px; border-radius: var(--r); background: var(--karte); box-shadow: var(--schatten); color: var(--ink); text-decoration: none; min-height: 118px; min-width: 0; }
.kachel .nr { position: absolute; top: 12px; right: 12px; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; background: var(--karte-2); color: var(--muted); }
.kachel.fertig .nr { background: var(--gruen); color: #1b2a07; }
.kachel .ico { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; }
.kachel .ico svg { width: 22px; height: 22px; }
.kachel b { font-size: 16px; font-weight: 600; line-height: 1.2; }
.kachel span { font-size: 13px; color: var(--muted); line-height: 1.3; overflow-wrap: anywhere; }
.kachel.breit { grid-column: 1 / -1; min-height: 0; grid-template-columns: 40px minmax(0, 1fr); align-items: center; }

/* ---------- Listen */
.liste { display: grid; }
.zeile { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--linie); color: var(--ink); text-decoration: none; }
.zeile:last-child { border-bottom: 0; padding-bottom: 0; }
.zeile:first-child { padding-top: 0; }
.zeile .t { display: block; font-weight: 600; overflow-wrap: anywhere; }
.zeile .u { display: block; font-size: 13px; color: var(--muted); }
.zeile .rechts { display: grid; justify-items: end; gap: 4px; font-size: 14px; }
.richtung { display: inline-grid; place-items: center; min-width: 30px; height: 22px; padding: 0 6px; border-radius: 6px; background: var(--karte-2); font-size: 12px; font-weight: 700; color: var(--muted); }

/* U-Wert-Kennzeichen (Effizienzfarben) */
.upill { display: inline-flex; align-items: baseline; gap: 3px; padding: 2px 8px; border-radius: 99px; font-size: 13px; font-weight: 600; color: #fff; white-space: nowrap; }
.upill.k-a { background: var(--k-a); } .upill.k-b { background: var(--k-b); color: #1b2a07; } .upill.k-c { background: var(--k-c); color: #2a2205; }
.upill.k-d { background: var(--k-d); color: #2a1605; } .upill.k-e { background: var(--k-e); } .upill.k-0 { background: var(--linie); color: var(--muted); }

/* Schichtbild */
.schichtbild { display: flex; height: 54px; border-radius: 10px; overflow: hidden; border: 1px solid var(--linie); }
.schichtbild i { display: block; min-width: 3px; position: relative; }
.schichtbild i + i { border-left: 1px solid rgba(0,0,0,.18); }
.m-putz { background: #d9d6cc; } .m-mauer { background: #b5583f; } .m-beton { background: #9aa3a8; }
.m-daemm { background: repeating-linear-gradient(135deg, #f2d35b 0 6px, #f7e391 6px 12px); }
.m-holz { background: #b88a55; } .m-luft { background: #dcecf6; } .m-sonst { background: #8e8a80; }
.legende { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: var(--muted); }
.legende span { display: inline-flex; align-items: center; gap: 5px; }
.legende i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* Schichten-Editor */
.schicht { display: grid; grid-template-columns: 26px minmax(0, 1fr) 92px 34px; gap: 8px; align-items: center; }
.schicht .farbe { width: 26px; height: 38px; border-radius: 6px; }
.schicht .eingabe input { padding: 10px; font-size: 16px; }
.schicht .eingabe select { padding: 10px 30px 10px 10px; font-size: 16px; }
.schicht .lam { grid-column: 2 / 4; font-size: 13px; color: var(--muted); margin-top: -4px; display: flex; gap: 6px; align-items: center; }
.schicht .lam input { width: 76px; border: 0; border-bottom: 1px dashed var(--linie); background: transparent; font-size: 16px; text-align: right; padding: 2px; }

/* Öffnungen: Typ über die volle Breite, darunter Breite × Höhe, Anzahl */
.oeff { display: grid; grid-template-columns: minmax(0, 1fr) 12px minmax(0, 1fr) 74px 34px; gap: 6px; align-items: center; padding: 10px; border-radius: 12px; background: var(--karte-2); }
.oeff .typ { grid-column: 1 / -1; }
.oeff .eingabe { background: var(--karte); }
.oeff .eingabe input, .oeff .eingabe select { padding: 10px 8px; font-size: 16px; }
.oeff .einheit { padding-right: 8px; font-size: 13px; }
.oeff .mal { text-align: center; color: var(--muted); }

/* ---------- Knöpfe */
.knopf { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 10px 18px; border-radius: 12px; border: 1.5px solid var(--linie); background: var(--karte); color: var(--ink); font-weight: 600; font-size: 15px; text-decoration: none; }
.knopf svg { width: 18px; height: 18px; }
.knopf.haupt { background: var(--gruen); border-color: var(--gruen); color: #1b2a07; }
.knopf.dunkel { background: var(--tief); border-color: var(--tief); color: #fff; }
.knopf.gefahr { color: var(--fehler); }
.knopf.klein { min-height: 36px; padding: 6px 12px; font-size: 14px; }
.knopf.voll { width: 100%; }
.icon-knopf { width: 34px; height: 34px; border-radius: 9px; border: 0; background: var(--karte-2); color: var(--muted); display: grid; place-items: center; }
.icon-knopf svg { width: 16px; height: 16px; }
.reihe { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.weiter { display: flex; justify-content: flex-end; }
/* Feste Leiste unten wie in einer App: Übersicht + nächster Schritt */
.fussleiste { position: fixed; left: 0; right: 0; bottom: 0; z-index: 15; display: flex; gap: 8px; justify-content: center;
  padding: 10px 16px calc(env(safe-area-inset-bottom, 0px) + 10px); background: color-mix(in srgb, var(--karte) 92%, transparent);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); border-top: 1px solid var(--linie); }
.fussleiste .knopf { flex: 1; max-width: 340px; min-height: 50px; }
.fussleiste .knopf.zurueck { flex: 0 0 auto; padding: 10px 14px; }

/* Vorlagen-Chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button { border: 1.5px dashed var(--linie); background: transparent; border-radius: 99px; padding: 7px 12px; font-size: 14px; text-align: left; }
.chips button:active { background: var(--karte-2); }

/* Auswahlkarten (Heizung) */
.optionen { display: grid; gap: 8px; }
.option { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 12px; align-items: center; padding: 12px; border-radius: 12px; border: 1.5px solid var(--linie); background: var(--karte); text-align: left; }
.option .ico { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: var(--karte-2); }
.option .ico svg { width: 22px; height: 22px; }
.option b { display: block; font-weight: 600; font-size: 15px; line-height: 1.25; }
.option small { color: var(--muted); font-size: 13px; }
.option[aria-pressed="true"] { border-color: var(--stift); box-shadow: inset 0 0 0 1px var(--stift); }

/* Prüfliste */
.pruef { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.pruef li { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 8px; font-size: 15px; }
.pruef .ok { color: var(--k-a); font-weight: 700; }
.pruef .offen { color: var(--warn); font-weight: 700; }

/* Foto */
.foto { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 12px; background: var(--karte-2); max-width: 100%; }
.foto-leer { aspect-ratio: 4 / 3; border-radius: 12px; border: 2px dashed var(--linie); display: grid; place-items: center; color: var(--muted); text-align: center; padding: 16px; }
.foto-leer svg { width: 44px; height: 44px; }

/* Projektkarten */
.projekt { display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px; border-radius: var(--r); background: var(--karte); box-shadow: var(--schatten); color: var(--ink); text-decoration: none; }
.projekt img, .projekt .platz { width: 56px; height: 56px; border-radius: 12px; object-fit: cover; background: var(--auto-bg); display: grid; place-items: center; }
.projekt .platz svg { width: 28px; height: 28px; color: var(--gruen-text); }
.projekt b { display: block; font-size: 16px; overflow-wrap: anywhere; }
.projekt span { font-size: 13px; color: var(--muted); }
.ring { width: 42px; height: 42px; }

.bestaetigen { display: grid; gap: 10px; padding: 14px; border-radius: var(--r); background: color-mix(in srgb, var(--fehler) 9%, var(--karte)); border: 1.5px solid color-mix(in srgb, var(--fehler) 40%, transparent); }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(env(safe-area-inset-bottom, 0px) + 20px); background: var(--tief); color: #fff;
  padding: 11px 18px; border-radius: 99px; font-size: 15px; z-index: 50; max-width: calc(100% - 32px); box-shadow: 0 6px 20px rgba(0,0,0,.2); }

@media (max-width: 440px) {
  .auto-liste { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 380px) {
  .felder { grid-template-columns: minmax(0, 1fr); }
  .kacheln { gap: 8px; }
  .oeff { grid-template-columns: minmax(0, 1fr) 10px minmax(0, 1fr) 66px 30px; gap: 4px; }
}
@media (prefers-reduced-motion: no-preference) {
  .toast { animation: rein .2s ease-out; }
  @keyframes rein { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }
  .kachel, .projekt, .option, .wahl button { transition: transform .12s; }
  .kachel:active, .projekt:active, .option:active, .wahl button:active { transform: scale(.98); }
}
