:root {
  --holz-dunkel: #412402;
  --holz: #5a3a17;
  --holz-mittel: #854f0b;
  --gold: #ba7517;
  --kachel: #fac775;
  --kachel-hell: #fbdca6;
  --creme: #faeeda;
  --creme-2: #f4e2c2;
  --linie: #e2c99a;
  --text: #412402;
  --text-2: #7a5320;
  --gruen: #2f8a4a;
  --rot: #a32d2d;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--creme); color: var(--text);
  font: 16px/1.35 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  -webkit-user-select: none; user-select: none; overscroll-behavior: none;
}
input, textarea, select, button { font: inherit; color: inherit; }
input, textarea { -webkit-user-select: text; user-select: text; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
.ico.klein-ico { width: 14px; height: 14px; vertical-align: -2px; }
.ico { width: 22px; height: 22px; display: inline-block; vertical-align: middle; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Kopfleiste in Holzoptik */
.kopf {
  position: sticky; top: 0; z-index: 5;
  padding: calc(var(--safe-t) + 10px) 16px 12px;
  color: var(--creme);
  background-color: var(--holz);
  background-image:
    repeating-linear-gradient(178deg, rgba(255,255,255,.05) 0 2px, transparent 2px 9px),
    repeating-linear-gradient(181deg, rgba(0,0,0,.10) 0 1px, transparent 1px 23px),
    linear-gradient(180deg, #6b4520, #4d300f);
  display: flex; align-items: center; gap: 10px;
}
.kopf h1 { font-size: 24px; font-weight: 600; margin: 0; flex: 1; letter-spacing: .2px; }
.kopf .knopf { color: var(--creme); padding: 6px 4px; font-size: 16px; }
.kopf .zurueck { display: flex; align-items: center; gap: 2px; }

main { padding: 14px 14px calc(90px + var(--safe-b)); }

/* Favoriten-Kacheln */
.kacheln { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kachel {
  position: relative; background: var(--kachel); border-radius: 16px; padding: 14px 8px 12px;
  text-align: center; min-height: 128px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  box-shadow: inset 0 -2px 0 rgba(65,36,2,.12);
  transition: transform .08s;
}
.kachel:active { transform: scale(.97); }
.kachel .name { font-size: 16px; font-weight: 600; margin-top: 8px; color: var(--holz-dunkel); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kachel .sub { font-size: 13px; color: var(--holz-mittel); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kachel .info { position: absolute; top: 6px; right: 6px; width: 32px; height: 32px; border-radius: 50%; color: var(--holz-mittel); display: flex; align-items: center; justify-content: center; }
.kachel .info .ico { width: 20px; height: 20px; }
.kachel .edit-leiste { display: flex; gap: 6px; margin-top: 8px; }
.kachel .edit-leiste button { width: 34px; height: 30px; border-radius: 8px; background: var(--creme); color: var(--holz-dunkel); display: flex; align-items: center; justify-content: center; }
.kachel .edit-leiste button.weg { color: var(--rot); }
.kachel .edit-leiste .ico { width: 18px; height: 18px; }

.avatar {
  width: 64px; height: 64px; border-radius: 50%; background: var(--holz-mittel); color: var(--creme);
  display: flex; align-items: center; justify-content: center; font-size: 22px; font-weight: 600; overflow: hidden; flex: none;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.klein { width: 42px; height: 42px; font-size: 15px; }
.avatar.gross { width: 104px; height: 104px; font-size: 36px; }

/* Listen */
.suche { display: flex; align-items: center; gap: 8px; background: var(--creme-2); border-radius: 12px; padding: 9px 12px; margin-bottom: 12px; color: var(--text-2); }
.suche input { border: 0; background: none; outline: none; flex: 1; font-size: 17px; color: var(--text); min-width: 0; }
.buchstabe { font-size: 13px; font-weight: 700; color: var(--gold); margin: 14px 4px 4px; }
.liste { background: #fff8ec; border-radius: 14px; overflow: hidden; }
.zeile { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-bottom: 1px solid var(--linie); width: 100%; text-align: left; }
.zeile:last-child { border-bottom: 0; }
.zeile:active { background: var(--creme-2); }
.zeile .mitte { flex: 1; min-width: 0; }
.zeile .titel { font-size: 17px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.zeile .unter { font-size: 14px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.zeile .notiz { font-size: 14px; color: var(--holz-mittel); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.zeile .zeit { font-size: 14px; color: var(--text-2); }
.rund { width: 40px; height: 40px; border-radius: 50%; background: var(--creme-2); color: var(--gruen); display: flex; align-items: center; justify-content: center; flex: none; }
.rund .ico { width: 20px; height: 20px; }
.tag { font-size: 14px; font-weight: 600; color: var(--text-2); margin: 16px 4px 6px; }
.tag:first-child { margin-top: 0; }

.leer { text-align: center; color: var(--text-2); padding: 40px 20px; }
.leer .gross { font-size: 18px; color: var(--text); font-weight: 600; margin-bottom: 6px; }
.leer button { margin-top: 16px; }

/* Knöpfe */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 18px; border-radius: 12px; background: var(--holz); color: var(--creme); font-weight: 600; font-size: 16px; }
.btn.hell { background: var(--creme-2); color: var(--holz-dunkel); }
.btn.rot { background: none; color: var(--rot); }
.btn.voll { width: 100%; }
.btn:active { opacity: .8; }

/* Kontakt-Detail */
.detail-kopf { text-align: center; padding: 10px 0 6px; }
.detail-kopf .avatar { margin: 0 auto 10px; }
.detail-kopf h2 { margin: 0; font-size: 26px; font-weight: 600; }
.detail-kopf .sub { color: var(--text-2); margin-top: 2px; }
.aktionen { display: flex; justify-content: center; gap: 14px; margin: 16px 0 18px; }
.aktion { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 12px; color: var(--text-2); width: 64px; }
.aktion span.k { width: 52px; height: 52px; border-radius: 50%; background: var(--kachel); color: var(--holz-dunkel); display: flex; align-items: center; justify-content: center; }
.aktion.anruf span.k { background: var(--gruen); color: #fff; }
.aktion.an span.k { background: var(--holz); color: var(--kachel); }
.block { background: #fff8ec; border-radius: 14px; padding: 4px 14px; margin-bottom: 12px; }
.block .reihe { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--linie); }
.block .reihe:last-child { border-bottom: 0; }
.block .label { font-size: 13px; color: var(--text-2); }
.block .wert { font-size: 17px; color: var(--holz-mittel); }
.block .text { white-space: pre-wrap; padding: 10px 0; -webkit-user-select: text; user-select: text; }
.block-titel { font-size: 13px; font-weight: 600; color: var(--text-2); margin: 16px 4px 6px; text-transform: uppercase; letter-spacing: .4px; }

/* Formular */
.feld { display: block; margin-bottom: 12px; }
.feld span { display: block; font-size: 13px; color: var(--text-2); margin: 0 4px 4px; }
.feld input, .feld textarea, .feld select, .nr-reihe input, .nr-reihe select {
  width: 100%; border: 1px solid var(--linie); background: #fff8ec; border-radius: 10px; padding: 11px 12px; font-size: 17px; outline: none;
}
.feld textarea { min-height: 90px; resize: vertical; }
.nr-reihe { display: flex; gap: 8px; margin-bottom: 8px; }
.nr-reihe select { width: 108px; flex: none; }
.nr-reihe button { color: var(--rot); flex: none; width: 36px; }
.foto-wahl { display: flex; align-items: center; justify-content: center; gap: 14px; margin-bottom: 16px; }

/* Ziffernblock */
.wahl-anzeige { text-align: center; font-size: 34px; font-weight: 300; min-height: 48px; letter-spacing: 1px; margin: 10px 0 2px; word-break: break-all; }
.wahl-treffer { text-align: center; min-height: 24px; color: var(--holz-mittel); font-size: 15px; margin-bottom: 12px; }
.wahl-treffer button { color: var(--holz-mittel); text-decoration: underline; }
.tasten { display: grid; grid-template-columns: repeat(3, 76px); gap: 16px 26px; justify-content: center; }
.taste { width: 76px; height: 76px; border-radius: 50%; background: var(--kachel); color: var(--holz-dunkel); display: flex; flex-direction: column; align-items: center; justify-content: center; }
.taste:active { background: var(--gold); }
.taste b { font-size: 32px; font-weight: 400; line-height: 1; }
.taste small { font-size: 10px; letter-spacing: 2px; color: var(--holz-mittel); height: 12px; }
.wahl-unten { display: grid; grid-template-columns: repeat(3, 76px); gap: 26px; justify-content: center; margin-top: 16px; align-items: center; }
.taste.gruen { background: var(--gruen); color: #fff; }
.loeschen { color: var(--holz-mittel); display: flex; align-items: center; justify-content: center; height: 76px; }

/* Untere Leiste */
nav.reiter {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: flex; justify-content: space-around; background: rgba(250,238,218,.96); border-top: 1px solid var(--linie);
  padding: 6px 4px calc(6px + var(--safe-b));
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
nav.reiter button { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--holz-mittel); width: 72px; padding: 4px 0; }
nav.reiter button.akt { color: var(--holz-dunkel); font-weight: 600; }
nav.reiter button.akt .ico { stroke-width: 2.4; }

/* Blatt von unten */
#sheet-bg { position: fixed; inset: 0; background: rgba(40,22,2,.4); z-index: 20; }
#sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 21; background: var(--creme);
  border-radius: 18px 18px 0 0; padding: 10px 16px calc(16px + var(--safe-b)); max-height: 88vh; overflow-y: auto;
  animation: hoch .18s ease-out;
}
#sheet::before { content: ""; display: block; width: 40px; height: 5px; border-radius: 3px; background: var(--linie); margin: 0 auto 12px; }
#sheet h3 { margin: 0 0 4px; font-size: 19px; }
#sheet .sub { color: var(--text-2); font-size: 14px; margin-bottom: 12px; }
#sheet .knoepfe { display: flex; gap: 10px; margin-top: 12px; }
#sheet .knoepfe .btn { flex: 1; }
@keyframes hoch { from { transform: translateY(40px); opacity: 0; } }

#toast { position: fixed; left: 50%; bottom: calc(96px + var(--safe-b)); transform: translateX(-50%); background: var(--holz-dunkel); color: var(--creme); padding: 10px 16px; border-radius: 12px; font-size: 15px; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 30; max-width: 90vw; text-align: center; }
#toast.an { opacity: 1; }

/* Anmeldung */
.login { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; gap: 14px; }
.login img { width: 88px; height: 88px; border-radius: 20px; }
.login h1 { margin: 0; font-size: 24px; }
.login input { width: 220px; text-align: center; font-size: 26px; letter-spacing: 6px; border: 1px solid var(--linie); background: #fff8ec; border-radius: 12px; padding: 10px; outline: none; }
.fehler { color: var(--rot); font-size: 14px; min-height: 18px; }
.hinweis { font-size: 14px; color: var(--text-2); line-height: 1.45; }
.hinweis ol { padding-left: 20px; margin: 6px 0; }

@media (min-width: 600px) {
  main { max-width: 560px; margin: 0 auto; }
  .kacheln { grid-template-columns: repeat(3, 1fr); }
}
