:root {
  --grund: #eef3fa;
  --flaeche: #ffffff;
  --tinte: #14233a;
  --leise: #5b6b82;
  --linie: #d5deea;
  --blau: #1f63a8;
  --blau-tief: #1f4f8f;
  --kopf: linear-gradient(180deg, #1f4f8f 0%, #2a66b0 100%);
  --kopf-text: #ffffff;
  --schatten: 0 1px 2px rgba(20, 35, 58, .08), 0 4px 12px rgba(20, 35, 58, .08);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --grund: #0d1726;
    --flaeche: #16233a;
    --tinte: #e6edf7;
    --leise: #9aabc4;
    --linie: #26385a;
    --blau: #6aa6f0;
    --blau-tief: #3d7fd0;
    --kopf: linear-gradient(180deg, #0d1726 0%, #12223a 100%);
    --kopf-text: #e6edf7;
    --schatten: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 14px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--grund);
  color: var(--tinte);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

.kopf {
  background: var(--kopf);
  color: var(--kopf-text);
  padding: calc(env(safe-area-inset-top) + 14px) 16px 14px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 2;
}
.kopf h1 { margin: 0; font-size: 1.35rem; font-weight: 650; letter-spacing: .01em; }
.kopf-knoepfe { display: flex; gap: 8px; align-items: center; }
.kopf button {
  font: inherit; color: inherit; cursor: pointer;
  background: rgba(255, 255, 255, .16); border: 0;
  min-height: 36px; border-radius: 18px;
}
.kopf button:hover { background: rgba(255, 255, 255, .26); }
.kopf button.text { padding: 0 14px; font-weight: 600; font-size: .95rem; }
.kopf button.rund { width: 36px; font-weight: 700; }

main {
  max-width: 720px; margin: 0 auto;
  padding: 20px 16px calc(env(safe-area-inset-bottom) + 28px);
}

/* Startraster */
.raster {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
  gap: 22px 10px;
}
.kachel {
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  text-decoration: none; color: var(--tinte);
  padding: 4px 0; border-radius: 16px;
}
.kachel:active .symbol { transform: scale(.93); }
.kachel:focus-visible { outline: 3px solid var(--blau); outline-offset: 2px; }
.kachel .name {
  font-size: .8rem; line-height: 1.2; text-align: center;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow-wrap: anywhere;
}

.symbol {
  width: 60px; height: 60px; flex: none;
  border-radius: 14px; overflow: hidden;
  background: var(--flaeche);
  box-shadow: var(--schatten);
  display: grid; place-items: center;
  transition: transform .12s ease;
}
.symbol { position: relative; }
.symbol img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.symbol.mit-bild { background: var(--flaeche); }
.symbol.buchstabe {
  --app-farbe: var(--blau-tief);
  background: var(--app-farbe); color: #fff;
  font-size: 1.6rem; font-weight: 650;
}

.leer, .hinweis { color: var(--leise); text-align: center; }
.hinweis { font-size: .9rem; margin: 0 0 14px; }

/* Bearbeiten */
.liste { list-style: none; margin: 0; padding: 0; background: var(--flaeche); border-radius: 14px; box-shadow: var(--schatten); }
.liste li { display: flex; align-items: center; gap: 6px; padding: 8px 8px 8px 12px; border-bottom: 1px solid var(--linie); }
.liste li:last-child { border-bottom: 0; }
.liste li.aus .symbol, .liste li.aus .zeile-text { opacity: .45; }
.zeile { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; cursor: pointer; }
.zeile .symbol { width: 40px; height: 40px; border-radius: 10px; box-shadow: none; border: 1px solid var(--linie); }
.zeile .symbol.buchstabe { font-size: 1.1rem; border: 0; }
.zeile-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.zeile-text .name { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.zeile-text .adresse { font-size: .78rem; color: var(--leise); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.schalter {
  appearance: none; -webkit-appearance: none; margin: 0 4px 0 0;
  width: 46px; height: 28px; border-radius: 14px; flex: none;
  background: var(--linie); position: relative; cursor: pointer;
  transition: background .15s;
}
.schalter::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 22px; height: 22px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .15s;
}
.schalter:checked { background: var(--blau); }
.schalter:checked::after { transform: translateX(18px); }
.schalter:focus-visible { outline: 3px solid var(--blau); outline-offset: 2px; }

.pfeile { display: flex; gap: 2px; flex: none; }
.pfeil {
  width: 34px; height: 34px; border: 0; border-radius: 8px;
  background: transparent; color: var(--blau); font-size: 1.1rem; cursor: pointer;
}
.pfeil:hover:not(:disabled) { background: var(--grund); }
.pfeil:disabled { color: var(--linie); cursor: default; }
.pfeil.weg { color: #c0392b; }

.eigene {
  margin-top: 22px; background: var(--flaeche); border-radius: 14px; box-shadow: var(--schatten);
  padding: 14px; display: grid; gap: 10px;
}
.eigene h2 { margin: 0; font-size: 1rem; }
.eigene input {
  font: inherit; color: var(--tinte); background: var(--grund);
  border: 1px solid var(--linie); border-radius: 10px; padding: 10px 12px; width: 100%;
}
.eigene input:focus { outline: 2px solid var(--blau); border-color: transparent; }
button.haupt {
  font: inherit; font-weight: 600; color: #fff; background: var(--blau-tief);
  border: 0; border-radius: 10px; padding: 11px; cursor: pointer;
}

/* Anleitung */
.anleitung { background: var(--flaeche); border-radius: 14px; box-shadow: var(--schatten); padding: 4px 18px 14px; }
.anleitung h2 { font-size: 1.05rem; margin: 18px 0 6px; color: var(--blau); }
.anleitung p, .anleitung li { margin: 6px 0; }
.anleitung ol { padding-left: 1.3em; }
.anleitung .stand { color: var(--leise); font-size: .8rem; margin-top: 18px; }

@media (min-width: 560px) {
  .raster { grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); }
  .symbol { width: 68px; height: 68px; border-radius: 16px; }
}
