/* Look angelehnt an das Home-Assistant-Dashboard: helle Flächen, große Rundungen,
   kleine Versal-Überschriften. Akzent: Violett. Hell/Dunkel per System oder Umschalter. */
:root {
  --hg: #e2e3e7;
  --flaeche: #f6f6f8;
  --flaeche-2: #ebebef;
  --linie: #dadbe0;
  --text: #1c1e23;
  --text-2: #585d69;
  --text-3: #8a8f9a;
  --akzent: #7c5cf5;
  --akzent-weich: rgba(124, 92, 245, .13);
  --akzent-text: #ffffff;
  --akzent-schrift: #6b49ee;
  --gruen: #2f9e55;
  --gruen-weich: rgba(47, 158, 85, .13);
  --rot: #d9443a;
  --rot-weich: rgba(217, 68, 58, .1);
  --kopf-hg: rgba(226, 227, 231, .85);
  --schatten: 0 1px 2px rgba(20, 22, 30, .05), 0 4px 14px rgba(20, 22, 30, .05);
  --overlay: rgba(20, 22, 30, .45);
  --bild-hg: #e9d6bd;
  --radius: 22px;
  --schrift: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --hg: #101216; --flaeche: #1b1e24; --flaeche-2: #252931; --linie: #2e333c;
    --text: #eceef2; --text-2: #a9aebb; --text-3: #737986;
    --akzent: #9b82ff; --akzent-weich: rgba(155, 130, 255, .16); --akzent-text: #120b2b; --akzent-schrift: #b4a2ff;
    --gruen: #5cc77f; --gruen-weich: rgba(92, 199, 127, .14); --rot: #ff7b70; --rot-weich: rgba(255, 123, 112, .12);
    --kopf-hg: rgba(16, 18, 22, .85); --schatten: none; --overlay: rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --hg: #101216; --flaeche: #1b1e24; --flaeche-2: #252931; --linie: #2e333c;
  --text: #eceef2; --text-2: #a9aebb; --text-3: #737986;
  --akzent: #9b82ff; --akzent-weich: rgba(155, 130, 255, .16); --akzent-text: #120b2b; --akzent-schrift: #b4a2ff;
  --gruen: #5cc77f; --gruen-weich: rgba(92, 199, 127, .14); --rot: #ff7b70; --rot-weich: rgba(255, 123, 112, .12);
  --kopf-hg: rgba(16, 18, 22, .85); --schatten: none; --overlay: rgba(0, 0, 0, .6);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--hg); color: var(--text); font: 15px/1.5 var(--schrift); min-height: 100vh; transition: background .2s, color .2s; }
button { font: inherit; color: inherit; cursor: pointer; }
h1, h2, h3 { font-family: var(--schrift); font-weight: 700; letter-spacing: -.02em; margin: 0; }
.label, .ueber, .d-text h3, .kat-kopf h2 { font-size: 11.5px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--text-2); }

/* Kopf */
.kopf { position: sticky; top: 0; z-index: 10; background: var(--kopf-hg); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.kopf-innen { max-width: 1200px; margin: 0 auto; padding: 16px 16px 10px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.ueber { margin: 0 0 2px; }
h1 { font-size: 30px; line-height: 1.05; letter-spacing: -.03em; }
.kopf-knoepfe { display: flex; gap: 8px; align-items: center; }
.rund-knopf { width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--flaeche); box-shadow: var(--schatten); display: grid; place-items: center; color: var(--text-2); }
.rund-knopf svg { width: 19px; height: 19px; }
.modus-knopf { display: inline-flex; align-items: center; gap: 7px; border: 0; background: var(--flaeche); box-shadow: var(--schatten); border-radius: 999px; padding: 9px 15px; font-size: 12px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--text-2); }
.modus-knopf svg { width: 17px; height: 17px; }
.modus-knopf.an { background: var(--akzent); color: var(--akzent-text); }
.bar-tabs { max-width: 1200px; margin: 0 auto; padding: 0 16px 12px; display: flex; gap: 6px; }
.bar-tabs button { flex: 1; border: 0; background: var(--flaeche); box-shadow: var(--schatten); border-radius: 14px; padding: 9px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.bar-tabs button.aktiv { background: var(--akzent-weich); color: var(--akzent-schrift); box-shadow: none; }

main { max-width: 1200px; margin: 0 auto; padding: 8px 16px 16px; }

/* Filter */
.filter { display: grid; gap: 10px; margin-bottom: 8px; }
.suche { display: flex; align-items: center; gap: 10px; background: var(--flaeche); box-shadow: var(--schatten); border-radius: 16px; padding: 0 14px; border: 1.5px solid transparent; }
.suche svg { width: 18px; height: 18px; color: var(--text-3); flex: none; }
.suche input { flex: 1; min-width: 0; background: transparent; border: 0; outline: 0; color: var(--text); font: inherit; padding: 12px 0; }
.suche input::placeholder { color: var(--text-3); }
.suche:focus-within { border-color: var(--akzent); }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 0; background: var(--flaeche); box-shadow: var(--schatten); color: var(--text-2); border-radius: 999px; padding: 7px 14px; font-size: 13px; font-weight: 500; white-space: nowrap; }
.chip.an { background: var(--akzent); color: var(--akzent-text); }
.chips.klein .chip { font-size: 12px; padding: 5px 11px; box-shadow: none; background: var(--flaeche-2); }
.chips.klein .chip.an { background: var(--akzent-weich); color: var(--akzent-schrift); }
.schalter { display: inline-flex; align-items: center; gap: 10px; font-size: 14px; color: var(--text-2); cursor: pointer; user-select: none; }
.schalter input { position: absolute; opacity: 0; pointer-events: none; }
.schiene { width: 40px; height: 24px; border-radius: 999px; background: var(--flaeche-2); border: 1px solid var(--linie); position: relative; flex: none; transition: background .2s; }
.schiene::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--text-3); transition: transform .2s, background .2s; }
.schalter input:checked + .schiene { background: var(--akzent); border-color: var(--akzent); }
.schalter input:checked + .schiene::after { transform: translateX(16px); background: #fff; }
.schalter input:focus-visible + .schiene { outline: 2px solid var(--akzent); outline-offset: 2px; }
.anzahl { color: var(--text-3); font-size: 11.5px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; margin: 12px 0 12px; }

/* Raster */
.raster { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
@media (min-width: 700px) { .raster { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; } }
.karte { position: relative; display: flex; flex-direction: column; text-align: left; background: var(--flaeche); border: 0; box-shadow: var(--schatten); border-radius: var(--radius); overflow: hidden; padding: 0; transition: transform .15s, box-shadow .15s; }
.karte:hover { box-shadow: 0 0 0 2px var(--akzent); }
.karte:active { transform: scale(.98); }
.bild { aspect-ratio: 2/3; width: 100%; background: var(--bild-hg); position: relative; overflow: hidden; }
.bild img { width: 100%; height: 100%; object-fit: contain; display: block; }
.karte-text { padding: 12px 14px 14px; display: grid; gap: 4px; }
.karte h3 { font-size: 16px; line-height: 1.25; }
.karte .kurz { font-size: 12.5px; color: var(--text-2); line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.tag { font-size: 11px; font-weight: 500; padding: 3px 8px; border-radius: 999px; background: var(--flaeche-2); color: var(--text-2); }
.tag.af { background: var(--gruen-weich); color: var(--gruen); }
.karte.weg .bild, .karte.weg .karte-text { opacity: .4; filter: grayscale(.9); }
.weg-schild { position: absolute; top: 10px; left: 10px; z-index: 2; background: var(--flaeche); color: var(--text); font-size: 11px; font-weight: 600; padding: 5px 10px; border-radius: 999px; box-shadow: var(--schatten); }
.leer { text-align: center; color: var(--text-3); padding: 40px 0; }

/* Detail */
.detail { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.detail-hg { position: absolute; inset: 0; background: var(--overlay); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.blatt { position: relative; width: 100%; max-width: 640px; max-height: 92vh; overflow-y: auto; background: var(--flaeche); border-radius: 26px 26px 0 0; animation: hoch .25s ease-out; padding-bottom: env(safe-area-inset-bottom); }
@media (min-width: 700px) { .detail { align-items: center; } .blatt { border-radius: 26px; } }
@keyframes hoch { from { transform: translateY(40px); opacity: 0; } }
.zu { position: absolute; top: 12px; right: 12px; z-index: 3; width: 38px; height: 38px; border-radius: 50%; border: 0; background: var(--flaeche); color: var(--text); box-shadow: 0 2px 8px rgba(0,0,0,.18); display: grid; place-items: center; }
.zu svg { width: 18px; height: 18px; }
.d-bild { width: 100%; aspect-ratio: 2/3; background: var(--bild-hg); }
.d-bild img { width: 100%; height: 100%; object-fit: cover; display: block; }
.d-text { padding: 20px 20px 26px; display: grid; gap: 18px; }
/* Breite Bildschirme: Bild links in voller Höhe, Text rechts */
@media (min-width: 760px) {
  .blatt { max-width: 980px; height: min(88vh, 860px); max-height: none; overflow: hidden; display: grid; grid-template-columns: auto minmax(0, 1fr); }
  #d-inhalt { display: contents; }
  .d-bild { height: 100%; width: calc(min(88vh, 860px) * 2 / 3); aspect-ratio: auto; }
  .blatt .d-text { overflow-y: auto; padding: 30px 30px 34px; align-content: start; }
}
.d-text h2 { font-size: 28px; line-height: 1.1; letter-spacing: -.03em; }
.d-text .lead { color: var(--text-2); margin: 6px 0 0; }
.d-text h3 { margin-bottom: 8px; }
.zliste { list-style: none; margin: 0; padding: 4px 14px; display: grid; background: var(--flaeche-2); border-radius: 16px; }
.zliste li { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--linie); }
.zliste li:last-child { border-bottom: 0; }
.zliste .menge { flex: 0 0 92px; font-weight: 600; color: var(--akzent-schrift); font-variant-numeric: tabular-nums; }
.zliste .opt { color: var(--text-3); }
.zliste .fehlt { color: var(--rot); }
.zliste .fehlt-hinweis { margin-left: auto; font-size: 11px; font-weight: 600; color: var(--rot); white-space: nowrap; }
.schritte { margin: 0; padding: 0; list-style: none; counter-reset: s; display: grid; gap: 12px; }
.schritte li { counter-increment: s; display: flex; gap: 12px; }
.schritte li::before { content: counter(s); flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--akzent-weich); color: var(--akzent-schrift); font-size: 12px; font-weight: 700; display: grid; place-items: center; margin-top: -1px; }
.hinweis-box { background: var(--rot-weich); color: var(--rot); border-radius: 14px; padding: 11px 14px; font-size: 13.5px; font-weight: 500; }
.vorbereitung { background: var(--flaeche-2); border-radius: 16px; padding: 12px 14px; }
.vorbereitung h4 { margin: 0 0 6px; font-size: 14px; }
.vorbereitung p { margin: 4px 0 0; font-size: 13.5px; color: var(--text-2); }
.quelle { font-size: 11.5px; color: var(--text-3); }
.quelle a { color: var(--text-2); }
.infozeile { display: flex; flex-wrap: wrap; gap: 6px; }

/* Vorrat */
.vorrat-kopf p { color: var(--text-2); margin: 0 0 6px; }
.sync { font-size: 12.5px; color: var(--text-3) !important; }
.kat { margin-top: 22px; }
.kat-kopf { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.kat-kopf button { border: 0; background: none; color: var(--akzent-schrift); font-size: 12.5px; font-weight: 600; }
.zgitter { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.zknopf { display: flex; align-items: center; gap: 12px; text-align: left; background: var(--flaeche); box-shadow: var(--schatten); border: 0; border-radius: 16px; padding: 12px 14px; }
.zknopf .haken { width: 24px; height: 24px; border-radius: 8px; border: 1.5px solid var(--text-3); flex: none; display: grid; place-items: center; }
.zknopf.da .haken { background: var(--akzent); border-color: var(--akzent); }
.zknopf.da .haken::after { content: ""; width: 10px; height: 6px; border-left: 2px solid var(--akzent-text); border-bottom: 2px solid var(--akzent-text); transform: rotate(-45deg) translate(1px,-1px); }
.zknopf:not(.da) { color: var(--text-3); box-shadow: none; background: var(--flaeche-2); }
.zknopf .wie-oft { margin-left: auto; font-size: 11px; color: var(--text-3); }

/* QR */
.qr-karte { max-width: 420px; margin: 10px auto; text-align: center; background: var(--flaeche); box-shadow: var(--schatten); border-radius: 26px; padding: 28px 22px; display: grid; gap: 10px; justify-items: center; }
.qr-karte p { color: var(--text-2); margin: 0; }
.qr-bild { background: #fff; padding: 14px; border-radius: 16px; width: min(280px, 100%); }
.qr-bild img, .qr-bild svg { width: 100%; height: auto; display: block; }
.qr-url { font-size: 13px; word-break: break-all; }

/* PIN */
.pin-blatt { position: relative; width: calc(100% - 32px); max-width: 360px; margin: auto; align-self: center; background: var(--flaeche); border-radius: 24px; padding: 24px; display: grid; gap: 10px; animation: hoch .2s ease-out; }
.pin-blatt p { margin: 0; color: var(--text-2); font-size: 14px; }
.pin-blatt input { background: var(--flaeche-2); border: 1.5px solid transparent; border-radius: 14px; color: var(--text); font: 600 22px/1 var(--schrift); letter-spacing: .3em; text-align: center; padding: 12px; outline: 0; }
.pin-blatt input:focus { border-color: var(--akzent); }
.fehler { color: var(--rot) !important; }
.pin-knoepfe { display: flex; gap: 8px; }
.pin-knoepfe .knopf { flex: 1; }
.knopf { border: 0; background: var(--akzent); color: var(--akzent-text); font-weight: 600; border-radius: 14px; padding: 11px 18px; }
.knopf.zweit { background: var(--flaeche-2); color: var(--text); }

.fuss { max-width: 1200px; margin: 0 auto; padding: 24px 16px 40px; color: var(--text-3); font-size: 12px; }

:focus-visible { outline: 2px solid var(--akzent); outline-offset: 2px; }

@media print {
  body { background: #fff; color: #000; }
  .kopf, .fuss, #ansicht-karte, #ansicht-vorrat { display: none !important; }
  #ansicht-qr { display: block !important; }
  .qr-karte { box-shadow: none; background: #fff; }
  .qr-karte p, .qr-karte h2 { color: #000; }
  .qr-karte .knopf { display: none; }
}
