/* Оформление «Книжной полки». Мобильный экран — главный случай. */
:root {
  --papier: #fbf7f0;
  --karte: #ffffff;
  --tinte: #2a2320;
  --tinte-leicht: #7a6d64;
  --linie: #e7ddd0;
  --haupt: #c0562f;          /* тёплый книжный красный */
  --haupt-dunkel: #a3461f;
  --gruen: #3f7d53;
  --blau: #2f6a95;
  --gold: #c9961f;
  --schatten: 0 2px 8px rgba(42, 35, 32, .08);
  --radius: 14px;
  --unten: 64px;             /* высота нижнего меню */
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  background: var(--papier);
  color: var(--tinte);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior-y: contain;
}
body.hat-menu { padding-bottom: calc(var(--unten) + env(safe-area-inset-bottom)); }

h1, h2, h3 { margin: 0 0 .4em; line-height: 1.2; font-weight: 700; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
a { color: var(--blau); }

.verborgen { display: none !important; }

/* ——— кнопки ——— */
button {
  font: inherit; cursor: pointer; border: 0; border-radius: 10px;
  padding: 11px 16px; background: var(--linie); color: var(--tinte);
  transition: transform .06s ease, filter .15s ease;
}
button:active { transform: scale(.97); }
button.leise { background: transparent; color: var(--tinte-leicht); padding: 8px 10px; }
button.rand { background: #fff; border: 1.5px solid var(--linie); }
button.haupt, button.rand.haupt { background: var(--haupt); color: #fff; font-weight: 600; border-color: var(--haupt); }
button.haupt:disabled { background: var(--tinte-leicht); }
button.gefahr { background: #fff; border: 1.5px solid #d9534f; color: #c0392b; }
button.breit { display: block; width: 100%; }
button:disabled { opacity: .6; cursor: default; }

input, select, textarea {
  font: inherit; width: 100%; padding: 11px 12px;
  border: 1.5px solid var(--linie); border-radius: 10px;
  background: #fff; color: var(--tinte);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--haupt); outline-offset: -1px; }
label.feld { display: block; margin-bottom: 10px; }
label.feld > span { display: block; font-size: .82rem; color: var(--tinte-leicht); margin-bottom: 3px; }
.reihe { display: flex; gap: 8px; }
.reihe > * { flex: 1; min-width: 0; }

/* ——— шапка ——— */
header.oben {
  position: sticky; top: 0; z-index: 20;
  background: var(--papier); border-bottom: 1px solid var(--linie);
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
  display: flex; align-items: center; gap: 10px;
}
header.oben .titel { font-weight: 700; font-size: 1.05rem; flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.inhalt { padding: 12px 14px 20px; max-width: 760px; margin: 0 auto; }

/* ——— нижнее меню ——— */
nav.unten {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  display: flex; background: #fff; border-top: 1px solid var(--linie);
  padding-bottom: env(safe-area-inset-bottom);
}
nav.unten button {
  flex: 1; background: none; border-radius: 0; padding: 7px 2px 8px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: .68rem; color: var(--tinte-leicht); position: relative;
}
nav.unten button .zeichen { font-size: 1.35rem; line-height: 1; }
nav.unten button.aktiv { color: var(--haupt); font-weight: 600; }
.punkt {
  position: absolute; top: 4px; right: 50%; margin-right: -22px;
  min-width: 17px; height: 17px; border-radius: 9px; background: var(--haupt);
  color: #fff; font-size: .66rem; font-weight: 700; line-height: 17px; text-align: center; padding: 0 4px;
}

/* ——— поиск и фильтры ——— */
.suche { display: flex; gap: 8px; margin-bottom: 10px; }
.marken { display: flex; gap: 7px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 10px;
  scrollbar-width: none; }
.marken::-webkit-scrollbar { display: none; }
.marke {
  flex: 0 0 auto; padding: 7px 13px; border-radius: 999px; background: #fff;
  border: 1.5px solid var(--linie); font-size: .86rem; white-space: nowrap;
}
.marke.aktiv { background: var(--tinte); color: #fff; border-color: var(--tinte); }

/* ——— полка ——— */
.regal { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 12px; }
.buch { position: relative; cursor: pointer; }
.buch .bild {
  width: 100%; aspect-ratio: 2 / 3; border-radius: 8px; background: #efe6d8 center/cover no-repeat;
  box-shadow: var(--schatten); display: flex; align-items: center; justify-content: center;
  overflow: hidden; font-size: .7rem; color: var(--tinte-leicht); text-align: center; padding: 6px;
}
.buch .name { font-size: .78rem; font-weight: 600; margin-top: 5px; line-height: 1.25;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.buch .autor { font-size: .72rem; color: var(--tinte-leicht); overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.fahne {
  position: absolute; top: 5px; left: 5px; padding: 2px 7px; border-radius: 999px;
  font-size: .66rem; font-weight: 700; color: #fff; background: var(--gruen);
}
.fahne.verkauf { background: var(--gold); }
.fahne.privat { background: var(--tinte-leicht); }
.herz { position: absolute; top: 4px; right: 4px; font-size: 1.1rem;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,.3)); }

.leer { text-align: center; color: var(--tinte-leicht); padding: 34px 16px; }
.leer .gross { font-size: 2.4rem; display: block; margin-bottom: 8px; }

/* ——— карточки списков ——— */
.karte {
  background: var(--karte); border: 1px solid var(--linie); border-radius: var(--radius);
  padding: 13px; margin-bottom: 11px; box-shadow: var(--schatten);
}
.karte .kopf { display: flex; align-items: center; gap: 10px; }
.karte .kopf .wachsen { flex: 1; min-width: 0; }
.zeile { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-top: 1px solid var(--linie); }
.zeile:first-of-type { border-top: 0; }
.zeile img, .zeile .platzhalter {
  width: 38px; height: 56px; object-fit: cover; border-radius: 5px; background: #efe6d8; flex: 0 0 auto;
}
.klein { font-size: .8rem; color: var(--tinte-leicht); }
.preis { font-weight: 700; color: var(--gold); }

/* ——— всплывающее окно ——— */
.schleier {
  position: fixed; inset: 0; z-index: 50; background: rgba(42, 35, 32, .55);
  display: flex; align-items: flex-end; justify-content: center; padding: 0;
}
.blatt {
  background: var(--papier); width: 100%; max-width: 620px; max-height: 92vh; overflow-y: auto;
  border-radius: 18px 18px 0 0; padding: 16px 16px calc(20px + env(safe-area-inset-bottom));
  animation: hoch .18s ease-out;
}
@keyframes hoch { from { transform: translateY(26px); } to { transform: none; } }
.blatt .griff { width: 42px; height: 4px; background: var(--linie); border-radius: 2px; margin: 0 auto 12px; }

#kamera { width: 100%; max-height: 54vh; background: #000; border-radius: 12px; display: block; }

.meldung { padding: 10px 12px; border-radius: 10px; margin-bottom: 10px; font-size: .9rem; }
.meldung.fehler { background: #fbeae8; color: #9b2c20; }
.meldung.gut { background: #e8f3ea; color: #2c5c3c; }

.lader { text-align: center; padding: 26px; color: var(--tinte-leicht); }

/* ——— вход ——— */
.tor { max-width: 380px; margin: 0 auto; padding: 8vh 20px 30px; }
.tor .zeichen { font-size: 3.4rem; text-align: center; display: block; margin-bottom: 6px; }
.tor h1 { text-align: center; }
.tor p.unter { text-align: center; color: var(--tinte-leicht); margin: 0 0 22px; }
.wechsel { text-align: center; margin-top: 14px; }

.code-kasten {
  font-size: 1.6rem; font-weight: 700; letter-spacing: .18em; text-align: center;
  background: #fff; border: 1.5px dashed var(--haupt); border-radius: 10px; padding: 12px; margin: 6px 0 2px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --papier: #1b1816; --karte: #241f1d; --tinte: #f0e8df; --tinte-leicht: #a79a90;
    --linie: #3a322e; --schatten: 0 2px 8px rgba(0,0,0,.3);
  }
  input, select, textarea, button.rand, nav.unten, .buch .bild { background: #241f1d; }
  button.gefahr { background: #241f1d; }
  .buch .bild, .zeile img, .zeile .platzhalter { background: #332b27; }
  .meldung.fehler { background: #3a211e; color: #f0a79c; }
  .meldung.gut { background: #1f3326; color: #a6d7b4; }
}
